Search in sources :

Example 1 with AnyTypeTO

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

the class SearchITCase method issueSYNCOPE980.

@Test
public void issueSYNCOPE980() {
    AnyTypeTO service = new AnyTypeTO();
    service.setKey("SERVICE");
    service.setKind(AnyTypeKind.ANY_OBJECT);
    Response response = anyTypeService.create(service);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusInfo().getStatusCode());
    String serviceKey = null;
    try {
        AnyObjectTO anyObjectTO = new AnyObjectTO();
        anyObjectTO.setName("one");
        anyObjectTO.setRealm(SyncopeConstants.ROOT_REALM);
        anyObjectTO.setType(service.getKey());
        anyObjectTO.getMemberships().add(new MembershipTO.Builder().group("29f96485-729e-4d31-88a1-6fc60e4677f3").build());
        serviceKey = createAnyObject(anyObjectTO).getEntity().getKey();
        AnyObjectPatch anyObjectPatch = new AnyObjectPatch();
        anyObjectPatch.setKey("fc6dbc3a-6c07-4965-8781-921e7401a4a5");
        anyObjectPatch.getMemberships().add(new MembershipPatch.Builder().group("29f96485-729e-4d31-88a1-6fc60e4677f3").build());
        updateAnyObject(anyObjectPatch);
        PagedResult<AnyObjectTO> matching = anyObjectService.search(new AnyQuery.Builder().fiql(SyncopeClient.getAnyObjectSearchConditionBuilder(service.getKey()).inGroups("29f96485-729e-4d31-88a1-6fc60e4677f3").query()).build());
        assertEquals(1, matching.getSize());
        assertEquals(serviceKey, matching.getResult().get(0).getKey());
    } finally {
        if (serviceKey != null) {
            anyObjectService.delete(serviceKey);
        }
        anyTypeService.delete(service.getKey());
    }
}
Also used : Response(javax.ws.rs.core.Response) AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) MembershipPatch(org.apache.syncope.common.lib.patch.MembershipPatch) MembershipTO(org.apache.syncope.common.lib.to.MembershipTO) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) AnyObjectPatch(org.apache.syncope.common.lib.patch.AnyObjectPatch) AnyQuery(org.apache.syncope.common.rest.api.beans.AnyQuery) Test(org.junit.jupiter.api.Test)

Example 2 with AnyTypeTO

use of org.apache.syncope.common.lib.to.AnyTypeTO 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 3 with AnyTypeTO

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

the class AnyTypeServiceImpl method create.

@Override
public Response create(final AnyTypeTO anyTypeTO) {
    AnyTypeTO created = logic.create(anyTypeTO);
    URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
    return Response.created(location).header(RESTHeaders.RESOURCE_KEY, created.getKey()).build();
}
Also used : AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) URI(java.net.URI)

Example 4 with AnyTypeTO

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

the class SchemaRestClient method getSchemas.

public <T extends SchemaTO> List<T> getSchemas(final SchemaType schemaType, final AnyTypeKind kind) {
    final AnyTypeService client = getService(AnyTypeService.class);
    final List<String> classes = new ArrayList<>();
    switch(kind) {
        case USER:
        case GROUP:
            final AnyTypeTO type = client.read(kind.name());
            if (type != null) {
                classes.addAll(type.getClasses());
            }
            break;
        default:
            new AnyTypeRestClient().listAnyTypes().stream().filter(anyTypeTO -> (anyTypeTO.getKind() != AnyTypeKind.USER && anyTypeTO.getKind() != AnyTypeKind.GROUP)).forEach((anyTypeTO) -> {
                classes.addAll(anyTypeTO.getClasses());
            });
    }
    return getSchemas(schemaType, null, classes.toArray(new String[] {}));
}
Also used : AnyTypeService(org.apache.syncope.common.rest.api.service.AnyTypeService) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) SchemaService(org.apache.syncope.common.rest.api.service.SchemaService) SchemaType(org.apache.syncope.common.lib.types.SchemaType) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO) ArrayList(java.util.ArrayList) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) DerSchemaTO(org.apache.syncope.common.lib.to.DerSchemaTO) List(java.util.List) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) EntityTO(org.apache.syncope.common.lib.to.EntityTO) SchemaTO(org.apache.syncope.common.lib.to.SchemaTO) SchemaQuery(org.apache.syncope.common.rest.api.beans.SchemaQuery) Collections(java.util.Collections) AnyTypeService(org.apache.syncope.common.rest.api.service.AnyTypeService) ArrayList(java.util.ArrayList) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO)

Example 5 with AnyTypeTO

use of org.apache.syncope.common.lib.to.AnyTypeTO 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

AnyTypeTO (org.apache.syncope.common.lib.to.AnyTypeTO)18 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)9 Test (org.junit.jupiter.api.Test)9 AnyTypeClassTO (org.apache.syncope.common.lib.to.AnyTypeClassTO)6 ArrayList (java.util.ArrayList)5 Response (javax.ws.rs.core.Response)4 PlainSchemaTO (org.apache.syncope.common.lib.to.PlainSchemaTO)4 EntityTO (org.apache.syncope.common.lib.to.EntityTO)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 AnyTypeClassRestClient (org.apache.syncope.client.console.rest.AnyTypeClassRestClient)2 AnyTypeRestClient (org.apache.syncope.client.console.rest.AnyTypeRestClient)2 ActionsPanel (org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel)2 WizardMgtPanel (org.apache.syncope.client.console.wizards.WizardMgtPanel)2 DerSchemaTO (org.apache.syncope.common.lib.to.DerSchemaTO)2 RoleTO (org.apache.syncope.common.lib.to.RoleTO)2 UserTO (org.apache.syncope.common.lib.to.UserTO)2 VirSchemaTO (org.apache.syncope.common.lib.to.VirSchemaTO)2