Search in sources :

Example 26 with AnyTypeClassTO

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

the class ProvisionAuxClassesPanel method onBeforeRender.

@Override
protected void onBeforeRender() {
    super.onBeforeRender();
    IModel<List<String>> model;
    List<String> choices;
    if (provision == null) {
        model = new ListModel<>(Collections.<String>emptyList());
        choices = Collections.emptyList();
    } else {
        model = new PropertyModel<>(provision, "auxClasses");
        choices = new ArrayList<>();
        AnyTypeTO anyType = null;
        try {
            anyType = new AnyTypeRestClient().read(provision.getAnyType());
        } catch (Exception e) {
            LOG.error("Could not read AnyType {}", provision.getAnyType(), e);
        }
        if (anyType != null) {
            for (AnyTypeClassTO aux : new AnyTypeClassRestClient().list()) {
                if (!anyType.getClasses().contains(aux.getKey())) {
                    choices.add(aux.getKey());
                }
            }
        }
    }
    addOrReplace(new AjaxPalettePanel.Builder<String>().build("auxClasses", model, new ListModel<>(choices)).hideLabel().setOutputMarkupId(true).setEnabled(provision != null));
}
Also used : AjaxPalettePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxPalettePanel) AnyTypeRestClient(org.apache.syncope.client.console.rest.AnyTypeRestClient) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) ArrayList(java.util.ArrayList) List(java.util.List) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) AnyTypeClassRestClient(org.apache.syncope.client.console.rest.AnyTypeClassRestClient)

Example 27 with AnyTypeClassTO

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

the class ResourceMappingPanel method setAttrNames.

@Override
protected void setAttrNames(final AjaxTextFieldPanel toBeUpdated) {
    toBeUpdated.setRequired(true);
    toBeUpdated.setEnabled(true);
    Set<String> choices = new HashSet<>();
    if (SyncopeConstants.REALM_ANYTYPE.equals(provision.getAnyType())) {
        choices.add("key");
        choices.add("name");
        choices.add("fullpath");
    } else {
        AnyTypeTO anyType = null;
        try {
            anyType = anyTypeRestClient.read(provision.getAnyType());
        } catch (Exception e) {
            LOG.error("Could not read AnyType {}", provision.getAnyType(), e);
        }
        List<AnyTypeClassTO> anyTypeClassTOs = new ArrayList<>();
        if (anyType != null) {
            try {
                anyTypeClassTOs.addAll(anyTypeClassRestClient.list(anyType.getClasses()));
            } catch (Exception e) {
                LOG.error("Could not read AnyType classes for {}", anyType.getClasses(), e);
            }
        }
        for (String auxClass : provision.getAuxClasses()) {
            try {
                anyTypeClassTOs.add(anyTypeClassRestClient.read(auxClass));
            } catch (Exception e) {
                LOG.error("Could not read AnyTypeClass for {}", auxClass, e);
            }
        }
        switch(provision.getAnyType()) {
            case "USER":
                choices.addAll(USER_FIELD_NAMES);
                break;
            case "GROUP":
                choices.addAll(GROUP_FIELD_NAMES);
                break;
            default:
                choices.addAll(ANY_OBJECT_FIELD_NAMES);
        }
        for (AnyTypeClassTO anyTypeClassTO : anyTypeClassTOs) {
            choices.addAll(anyTypeClassTO.getPlainSchemas());
            choices.addAll(anyTypeClassTO.getDerSchemas());
            choices.addAll(anyTypeClassTO.getVirSchemas());
        }
    }
    final List<String> names = new ArrayList<>(choices);
    Collections.sort(names);
    toBeUpdated.setChoices(names);
}
Also used : ArrayList(java.util.ArrayList) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) HashSet(java.util.HashSet)

Example 28 with AnyTypeClassTO

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

the class AnyTypeClassLogic method delete.

@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPECLASS_DELETE + "')")
public AnyTypeClassTO delete(final String key) {
    AnyTypeClass anyTypeClass = anyTypeClassDAO.find(key);
    if (anyTypeClass == null) {
        LOG.error("Could not find anyTypeClass '" + key + "'");
        throw new NotFoundException(key);
    }
    AnyTypeClassTO deleted = binder.getAnyTypeClassTO(anyTypeClass);
    anyTypeClassDAO.delete(key);
    return deleted;
}
Also used : NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) AnyTypeClass(org.apache.syncope.core.persistence.api.entity.AnyTypeClass) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

AnyTypeClassTO (org.apache.syncope.common.lib.to.AnyTypeClassTO)28 Test (org.junit.jupiter.api.Test)19 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)12 PlainSchemaTO (org.apache.syncope.common.lib.to.PlainSchemaTO)11 UserTO (org.apache.syncope.common.lib.to.UserTO)10 Response (javax.ws.rs.core.Response)8 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)7 GroupTO (org.apache.syncope.common.lib.to.GroupTO)6 ItemTO (org.apache.syncope.common.lib.to.ItemTO)6 ProvisionTO (org.apache.syncope.common.lib.to.ProvisionTO)6 AnyTypeClassService (org.apache.syncope.common.rest.api.service.AnyTypeClassService)6 AnyTypeTO (org.apache.syncope.common.lib.to.AnyTypeTO)5 MappingTO (org.apache.syncope.common.lib.to.MappingTO)5 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)5 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)5 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 StatusPatch (org.apache.syncope.common.lib.patch.StatusPatch)4 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)4 SchemaType (org.apache.syncope.common.lib.types.SchemaType)4