Search in sources :

Example 1 with EntityTO

use of org.apache.syncope.common.lib.to.EntityTO in project syncope by apache.

the class AbstractAttrs method loadMembershipAttrTOs.

@SuppressWarnings("unchecked")
private List<MembershipTO> loadMembershipAttrTOs() {
    List<MembershipTO> memberships = new ArrayList<>();
    try {
        membershipSchemas.clear();
        for (MembershipTO membership : (List<MembershipTO>) PropertyResolver.getPropertyField("memberships", anyTO).get(anyTO)) {
            setSchemas(membership.getGroupKey(), anyTypeClassRestClient.list(getMembershipAuxClasses(membership, anyTO.getType())).stream().map(EntityTO::getKey).collect(Collectors.toList()));
            setAttrs(membership);
            if (AbstractAttrs.this instanceof PlainAttrs && !membership.getPlainAttrs().isEmpty()) {
                memberships.add(membership);
            } else if (AbstractAttrs.this instanceof DerAttrs && !membership.getDerAttrs().isEmpty()) {
                memberships.add(membership);
            } else if (AbstractAttrs.this instanceof VirAttrs && !membership.getVirAttrs().isEmpty()) {
                memberships.add(membership);
            }
        }
    } catch (WicketRuntimeException | IllegalArgumentException | IllegalAccessException ex) {
    // ignore
    }
    return memberships;
}
Also used : EntityTO(org.apache.syncope.common.lib.to.EntityTO) MembershipTO(org.apache.syncope.common.lib.to.MembershipTO) WicketRuntimeException(org.apache.wicket.WicketRuntimeException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with EntityTO

use of org.apache.syncope.common.lib.to.EntityTO in project syncope by apache.

the class SyncopeConsoleApplication method getDomains.

public List<String> getDomains() {
    synchronized (LOG) {
        if (domains == null) {
            domains = newClientFactory().create(new AnonymousAuthenticationHandler(anonymousUser, anonymousKey)).getService(DomainService.class).list().stream().map(EntityTO::getKey).collect(Collectors.toList());
            domains.add(0, SyncopeConstants.MASTER_DOMAIN);
            domains = ListUtils.unmodifiableList(domains);
        }
    }
    return domains;
}
Also used : EntityTO(org.apache.syncope.common.lib.to.EntityTO) DomainService(org.apache.syncope.common.rest.api.service.DomainService) AnonymousAuthenticationHandler(org.apache.syncope.client.lib.AnonymousAuthenticationHandler)

Example 3 with EntityTO

use of org.apache.syncope.common.lib.to.EntityTO in project syncope by apache.

the class NotificationWizardBuilder method getSchemas.

private List<String> getSchemas() {
    AnyTypeTO type = null;
    try {
        type = anyTypeRestClient.read(AnyTypeKind.USER.name());
    } catch (SyncopeClientException e) {
        LOG.error("While reading all any types", e);
    }
    String[] anyTypeClasses = type == null ? new String[0] : type.getClasses().toArray(new String[] {});
    List<String> result = new ArrayList<>();
    result.add("username");
    result.addAll(schemaRestClient.<PlainSchemaTO>getSchemas(SchemaType.PLAIN, null, anyTypeClasses).stream().map(EntityTO::getKey).collect(Collectors.toList()));
    result.addAll(schemaRestClient.<DerSchemaTO>getSchemas(SchemaType.DERIVED, null, anyTypeClasses).stream().map(EntityTO::getKey).collect(Collectors.toList()));
    result.addAll(schemaRestClient.<VirSchemaTO>getSchemas(SchemaType.VIRTUAL, null, anyTypeClasses).stream().map(EntityTO::getKey).collect(Collectors.toList()));
    Collections.sort(result);
    return result;
}
Also used : EntityTO(org.apache.syncope.common.lib.to.EntityTO) PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) ArrayList(java.util.ArrayList) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) DerSchemaTO(org.apache.syncope.common.lib.to.DerSchemaTO) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO)

Example 4 with EntityTO

use of org.apache.syncope.common.lib.to.EntityTO in project syncope by apache.

the class UserSyncopeOperations method bulkDelete.

private Map<String, BulkActionResult.Status> bulkDelete(final AnyQuery query) {
    query.setPage(0);
    query.setSize(0);
    int count = userService.search(query).getTotalCount();
    BulkAction bulkAction = new BulkAction();
    bulkAction.setType(BulkAction.Type.DELETE);
    query.setSize(PAGE_SIZE);
    for (int page = 1; page <= (count / PAGE_SIZE) + 1; page++) {
        query.setPage(page);
        bulkAction.getTargets().addAll(userService.search(query).getResult().stream().map(EntityTO::getKey).collect(Collectors.toList()));
    }
    return userService.bulk(bulkAction).readEntity(BulkActionResult.class).getResults();
}
Also used : EntityTO(org.apache.syncope.common.lib.to.EntityTO) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) BulkAction(org.apache.syncope.common.lib.to.BulkAction)

Example 5 with EntityTO

use of org.apache.syncope.common.lib.to.EntityTO in project syncope by apache.

the class Realm method buildTabList.

private List<ITab> buildTabList(final PageReference pageRef) {
    List<ITab> tabs = new ArrayList<>();
    tabs.add(new ITabComponent(new Model<>("DETAILS"), StandardEntitlement.REALM_CREATE, StandardEntitlement.REALM_UPDATE, StandardEntitlement.REALM_DELETE) {

        private static final long serialVersionUID = -5861786415855103549L;

        @Override
        public Panel getPanel(final String panelId) {
            final ActionsPanel<RealmTO> actionPanel = new ActionsPanel<>("actions", null);
            if (realmTO.getFullPath().startsWith(SyncopeConstants.ROOT_REALM)) {
                actionPanel.add(new ActionLink<RealmTO>(realmTO) {

                    private static final long serialVersionUID = 2802988981431379827L;

                    @Override
                    public void onClick(final AjaxRequestTarget target, final RealmTO ignore) {
                        onClickCreate(target);
                    }
                }, ActionLink.ActionType.CREATE, StandardEntitlement.REALM_CREATE).hideLabel();
                actionPanel.add(new ActionLink<RealmTO>(realmTO) {

                    private static final long serialVersionUID = 2802988981431379828L;

                    @Override
                    public void onClick(final AjaxRequestTarget target, final RealmTO ignore) {
                        onClickEdit(target, realmTO);
                    }
                }, ActionLink.ActionType.EDIT, StandardEntitlement.REALM_UPDATE).hideLabel();
                actionPanel.add(new ActionLink<RealmTO>(realmTO) {

                    private static final long serialVersionUID = 2802988981431379827L;

                    @Override
                    public void onClick(final AjaxRequestTarget target, final RealmTO ignore) {
                        onClickTemplate(target);
                    }
                }, ActionLink.ActionType.TEMPLATE, StandardEntitlement.REALM_UPDATE).hideLabel();
                actionPanel.add(new ActionLink<RealmTO>(realmTO) {

                    private static final long serialVersionUID = 2802988981431379829L;

                    @Override
                    public void onClick(final AjaxRequestTarget target, final RealmTO ignore) {
                        onClickDelete(target, realmTO);
                    }
                }, ActionLink.ActionType.DELETE, StandardEntitlement.REALM_DELETE, true).hideLabel();
            }
            RealmDetails panel = new RealmDetails(panelId, realmTO, actionPanel, false);
            panel.setContentEnabled(false);
            actionPanel.setEnabled(true);
            return panel;
        }

        @Override
        public boolean isVisible() {
            return SyncopeConsoleApplication.get().getSecuritySettings().getAuthorizationStrategy().isActionAuthorized(this, RENDER);
        }
    });
    final Triple<UserFormLayoutInfo, GroupFormLayoutInfo, Map<String, AnyObjectFormLayoutInfo>> formLayoutInfo = FormLayoutInfoUtils.fetch(anyTypes.stream().map(EntityTO::getKey).collect(Collectors.toList()));
    for (final AnyTypeTO anyType : anyTypes) {
        tabs.add(new ITabComponent(new Model<>(anyType.getKey()), String.format("%s_SEARCH", anyType.getKey())) {

            private static final long serialVersionUID = 1169585538404171118L;

            @Override
            public WebMarkupContainer getPanel(final String panelId) {
                return new AnyPanel(panelId, anyType, realmTO, formLayoutInfo, true, pageRef);
            }

            @Override
            public boolean isVisible() {
                return SyncopeConsoleApplication.get().getSecuritySettings().getAuthorizationStrategy().isActionAuthorized(this, RENDER);
            }
        });
    }
    return tabs;
}
Also used : ActionsPanel(org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel) ArrayList(java.util.ArrayList) RealmTO(org.apache.syncope.common.lib.to.RealmTO) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) EntityTO(org.apache.syncope.common.lib.to.EntityTO) ActionsPanel(org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel) ConnObjectPanel(org.apache.syncope.client.console.wizards.any.ConnObjectPanel) AjaxBootstrapTabbedPanel(de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel) Panel(org.apache.wicket.markup.html.panel.Panel) WizardMgtPanel(org.apache.syncope.client.console.wizards.WizardMgtPanel) Model(org.apache.wicket.model.Model) GroupFormLayoutInfo(org.apache.syncope.client.console.layout.GroupFormLayoutInfo) ITabComponent(org.apache.syncope.client.console.commons.ITabComponent) UserFormLayoutInfo(org.apache.syncope.client.console.layout.UserFormLayoutInfo) Map(java.util.Map)

Aggregations

EntityTO (org.apache.syncope.common.lib.to.EntityTO)7 ArrayList (java.util.ArrayList)3 Response (javax.ws.rs.core.Response)2 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)2 AnyTypeTO (org.apache.syncope.common.lib.to.AnyTypeTO)2 AjaxBootstrapTabbedPanel (de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)1 ArrayUtils (org.apache.commons.lang3.ArrayUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 ITabComponent (org.apache.syncope.client.console.commons.ITabComponent)1 GroupFormLayoutInfo (org.apache.syncope.client.console.layout.GroupFormLayoutInfo)1 UserFormLayoutInfo (org.apache.syncope.client.console.layout.UserFormLayoutInfo)1 ActionsPanel (org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel)1