Search in sources :

Example 6 with VirSchema

use of org.apache.syncope.core.persistence.api.entity.VirSchema in project syncope by apache.

the class GroupDataBinderImpl method getGroupTO.

@Transactional(readOnly = true)
@Override
public GroupTO getGroupTO(final Group group, final boolean details) {
    GroupTO groupTO = new GroupTO();
    // set sys info
    groupTO.setCreator(group.getCreator());
    groupTO.setCreationDate(group.getCreationDate());
    groupTO.setLastModifier(group.getLastModifier());
    groupTO.setLastChangeDate(group.getLastChangeDate());
    groupTO.setKey(group.getKey());
    groupTO.setName(group.getName());
    if (group.getUserOwner() != null) {
        groupTO.setUserOwner(group.getUserOwner().getKey());
    }
    if (group.getGroupOwner() != null) {
        groupTO.setGroupOwner(group.getGroupOwner().getKey());
    }
    Map<DerSchema, String> derAttrValues = derAttrHandler.getValues(group);
    Map<VirSchema, List<String>> virAttrValues = details ? virAttrHandler.getValues(group) : Collections.<VirSchema, List<String>>emptyMap();
    fillTO(groupTO, group.getRealm().getFullPath(), group.getAuxClasses(), group.getPlainAttrs(), derAttrValues, virAttrValues, group.getResources(), details);
    if (details) {
        // dynamic realms
        groupTO.getDynRealms().addAll(groupDAO.findDynRealms(group.getKey()));
    }
    // Static user and AnyType membership counts
    groupTO.setStaticUserMembershipCount(groupDAO.countUMembers(group));
    groupTO.setStaticAnyObjectMembershipCount(groupDAO.countAMembers(group));
    // Dynamic user and AnyType membership counts
    groupTO.setDynamicUserMembershipCount(groupDAO.countUDynMembers(group));
    groupTO.setDynamicAnyObjectMembershipCount(groupDAO.countADynMembers(group));
    if (group.getUDynMembership() != null) {
        groupTO.setUDynMembershipCond(group.getUDynMembership().getFIQLCond());
    }
    group.getADynMemberships().forEach(memb -> {
        groupTO.getADynMembershipConds().put(memb.getAnyType().getKey(), memb.getFIQLCond());
    });
    group.getTypeExtensions().forEach(typeExt -> {
        groupTO.getTypeExtensions().add(getTypeExtensionTO(typeExt));
    });
    return groupTO;
}
Also used : DerSchema(org.apache.syncope.core.persistence.api.entity.DerSchema) VirSchema(org.apache.syncope.core.persistence.api.entity.VirSchema) List(java.util.List) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with VirSchema

use of org.apache.syncope.core.persistence.api.entity.VirSchema in project syncope by apache.

the class ResourceDataBinderImpl method getResourceTO.

@Override
public ResourceTO getResourceTO(final ExternalResource resource) {
    ResourceTO resourceTO = new ResourceTO();
    // set the resource name
    resourceTO.setKey(resource.getKey());
    // set the connector instance
    ConnInstance connector = resource.getConnector();
    resourceTO.setConnector(connector == null ? null : connector.getKey());
    resourceTO.setConnectorDisplayName(connector == null ? null : connector.getDisplayName());
    // set the provision information
    resource.getProvisions().stream().map(provision -> {
        ProvisionTO provisionTO = new ProvisionTO();
        provisionTO.setKey(provision.getKey());
        provisionTO.setAnyType(provision.getAnyType().getKey());
        provisionTO.setObjectClass(provision.getObjectClass().getObjectClassValue());
        provisionTO.getAuxClasses().addAll(provision.getAuxClasses().stream().map(cls -> cls.getKey()).collect(Collectors.toList()));
        provisionTO.setSyncToken(provision.getSerializedSyncToken());
        if (provision.getMapping() != null) {
            MappingTO mappingTO = new MappingTO();
            provisionTO.setMapping(mappingTO);
            mappingTO.setConnObjectLink(provision.getMapping().getConnObjectLink());
            populateItems(provision.getMapping().getItems(), mappingTO);
        }
        virSchemaDAO.findByProvision(provision).forEach(virSchema -> {
            provisionTO.getVirSchemas().add(virSchema.getKey());
            MappingItem linkingMappingItem = virSchema.asLinkingMappingItem();
            ItemTO itemTO = new ItemTO();
            itemTO.setKey(linkingMappingItem.getKey());
            BeanUtils.copyProperties(linkingMappingItem, itemTO, ITEM_IGNORE_PROPERTIES);
            provisionTO.getMapping().getLinkingItems().add(itemTO);
        });
        return provisionTO;
    }).forEachOrdered(provisionTO -> {
        resourceTO.getProvisions().add(provisionTO);
    });
    if (resource.getOrgUnit() != null) {
        OrgUnit orgUnit = resource.getOrgUnit();
        OrgUnitTO orgUnitTO = new OrgUnitTO();
        orgUnitTO.setKey(orgUnit.getKey());
        orgUnitTO.setObjectClass(orgUnit.getObjectClass().getObjectClassValue());
        orgUnitTO.setSyncToken(orgUnit.getSerializedSyncToken());
        orgUnitTO.setConnObjectLink(orgUnit.getConnObjectLink());
        populateItems(orgUnit.getItems(), orgUnitTO);
        resourceTO.setOrgUnit(orgUnitTO);
    }
    resourceTO.setEnforceMandatoryCondition(resource.isEnforceMandatoryCondition());
    resourceTO.setPropagationPriority(resource.getPropagationPriority());
    resourceTO.setRandomPwdIfNotProvided(resource.isRandomPwdIfNotProvided());
    resourceTO.setCreateTraceLevel(resource.getCreateTraceLevel());
    resourceTO.setUpdateTraceLevel(resource.getUpdateTraceLevel());
    resourceTO.setDeleteTraceLevel(resource.getDeleteTraceLevel());
    resourceTO.setProvisioningTraceLevel(resource.getProvisioningTraceLevel());
    resourceTO.setPasswordPolicy(resource.getPasswordPolicy() == null ? null : resource.getPasswordPolicy().getKey());
    resourceTO.setAccountPolicy(resource.getAccountPolicy() == null ? null : resource.getAccountPolicy().getKey());
    resourceTO.setPullPolicy(resource.getPullPolicy() == null ? null : resource.getPullPolicy().getKey());
    resourceTO.getConfOverride().addAll(resource.getConfOverride());
    Collections.sort(resourceTO.getConfOverride());
    resourceTO.setOverrideCapabilities(resource.isOverrideCapabilities());
    resourceTO.getCapabilitiesOverride().addAll(resource.getCapabilitiesOverride());
    resourceTO.getPropagationActions().addAll(resource.getPropagationActions().stream().map(Entity::getKey).collect(Collectors.toList()));
    return resourceTO;
}
Also used : ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) PullPolicy(org.apache.syncope.core.persistence.api.entity.policy.PullPolicy) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) AnyType(org.apache.syncope.core.persistence.api.entity.AnyType) Autowired(org.springframework.beans.factory.annotation.Autowired) Entity(org.apache.syncope.core.persistence.api.entity.Entity) JexlUtils(org.apache.syncope.core.provisioning.java.jexl.JexlUtils) OrgUnit(org.apache.syncope.core.persistence.api.entity.resource.OrgUnit) AuthContextUtils(org.apache.syncope.core.spring.security.AuthContextUtils) ParseException(java.text.ParseException) ImplementationDAO(org.apache.syncope.core.persistence.api.dao.ImplementationDAO) AnyTypeClass(org.apache.syncope.core.persistence.api.entity.AnyTypeClass) MappingTO(org.apache.syncope.common.lib.to.MappingTO) OrgUnitItem(org.apache.syncope.core.persistence.api.entity.resource.OrgUnitItem) Implementation(org.apache.syncope.core.persistence.api.entity.Implementation) SchemaType(org.apache.syncope.common.lib.types.SchemaType) ConnInstanceDAO(org.apache.syncope.core.persistence.api.dao.ConnInstanceDAO) ResourceDataBinder(org.apache.syncope.core.provisioning.api.data.ResourceDataBinder) Collectors(java.util.stream.Collectors) MappingItem(org.apache.syncope.core.persistence.api.entity.resource.MappingItem) AnyTypeDAO(org.apache.syncope.core.persistence.api.dao.AnyTypeDAO) EntityFactory(org.apache.syncope.core.persistence.api.entity.EntityFactory) List(java.util.List) AccountPolicy(org.apache.syncope.core.persistence.api.entity.policy.AccountPolicy) Provision(org.apache.syncope.core.persistence.api.entity.resource.Provision) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) PolicyDAO(org.apache.syncope.core.persistence.api.dao.PolicyDAO) ConfDAO(org.apache.syncope.core.persistence.api.dao.ConfDAO) ExternalResourceHistoryConfDAO(org.apache.syncope.core.persistence.api.dao.ExternalResourceHistoryConfDAO) IntAttrName(org.apache.syncope.core.provisioning.api.IntAttrName) ResourceHistoryConfTO(org.apache.syncope.common.lib.to.ResourceHistoryConfTO) BeanUtils(org.apache.syncope.core.spring.BeanUtils) HashSet(java.util.HashSet) PasswordPolicy(org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy) ItemTO(org.apache.syncope.common.lib.to.ItemTO) SyncopeClientCompositeException(org.apache.syncope.common.lib.SyncopeClientCompositeException) ClientExceptionType(org.apache.syncope.common.lib.types.ClientExceptionType) Item(org.apache.syncope.core.persistence.api.entity.resource.Item) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) Mapping(org.apache.syncope.core.persistence.api.entity.resource.Mapping) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ItemContainerTO(org.apache.syncope.common.lib.to.ItemContainerTO) IteratorChain(org.apache.syncope.common.lib.collections.IteratorChain) ExternalResourceHistoryConf(org.apache.syncope.core.persistence.api.entity.resource.ExternalResourceHistoryConf) ConnInstance(org.apache.syncope.core.persistence.api.entity.ConnInstance) VirSchema(org.apache.syncope.core.persistence.api.entity.VirSchema) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) Component(org.springframework.stereotype.Component) MappingPurpose(org.apache.syncope.common.lib.types.MappingPurpose) OrgUnitTO(org.apache.syncope.common.lib.to.OrgUnitTO) VirSchemaDAO(org.apache.syncope.core.persistence.api.dao.VirSchemaDAO) IntAttrNameParser(org.apache.syncope.core.provisioning.java.IntAttrNameParser) Collections(java.util.Collections) AnyTypeClassDAO(org.apache.syncope.core.persistence.api.dao.AnyTypeClassDAO) OrgUnit(org.apache.syncope.core.persistence.api.entity.resource.OrgUnit) Entity(org.apache.syncope.core.persistence.api.entity.Entity) MappingTO(org.apache.syncope.common.lib.to.MappingTO) MappingItem(org.apache.syncope.core.persistence.api.entity.resource.MappingItem) OrgUnitTO(org.apache.syncope.common.lib.to.OrgUnitTO) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) ItemTO(org.apache.syncope.common.lib.to.ItemTO) ConnInstance(org.apache.syncope.core.persistence.api.entity.ConnInstance)

Example 8 with VirSchema

use of org.apache.syncope.core.persistence.api.entity.VirSchema in project syncope by apache.

the class SchemaLogic method resolveReference.

@Override
protected SchemaTO resolveReference(final Method method, final Object... args) throws UnresolvedReferenceException {
    String key = null;
    if (ArrayUtils.isNotEmpty(args)) {
        for (int i = 0; key == null && i < args.length; i++) {
            if (args[i] instanceof String) {
                key = (String) args[i];
            } else if (args[i] instanceof SchemaTO) {
                key = ((SchemaTO) args[i]).getKey();
            }
        }
    }
    if (key != null) {
        try {
            SchemaTO result = null;
            PlainSchema plainSchema = plainSchemaDAO.find(key);
            if (plainSchema == null) {
                DerSchema derSchema = derSchemaDAO.find(key);
                if (derSchema == null) {
                    VirSchema virSchema = virSchemaDAO.find(key);
                    if (virSchema != null) {
                        result = binder.getVirSchemaTO(virSchema);
                    }
                } else {
                    result = binder.getDerSchemaTO(derSchema);
                }
            } else {
                result = binder.getPlainSchemaTO(plainSchema);
            }
            return result;
        } catch (Throwable ignore) {
            LOG.debug("Unresolved reference", ignore);
            throw new UnresolvedReferenceException(ignore);
        }
    }
    throw new UnresolvedReferenceException();
}
Also used : DerSchema(org.apache.syncope.core.persistence.api.entity.DerSchema) VirSchema(org.apache.syncope.core.persistence.api.entity.VirSchema) PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO) DerSchemaTO(org.apache.syncope.common.lib.to.DerSchemaTO) SchemaTO(org.apache.syncope.common.lib.to.SchemaTO) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema)

Example 9 with VirSchema

use of org.apache.syncope.core.persistence.api.entity.VirSchema in project syncope by apache.

the class SchemaLogic method update.

@PreAuthorize("hasRole('" + StandardEntitlement.SCHEMA_UPDATE + "')")
public <T extends SchemaTO> void update(final SchemaType schemaType, final T schemaTO) {
    if (!doesSchemaExist(schemaType, schemaTO.getKey())) {
        throw new NotFoundException(schemaType + "/" + schemaTO.getKey());
    }
    switch(schemaType) {
        case VIRTUAL:
            VirSchema virSchema = virSchemaDAO.find(schemaTO.getKey());
            if (virSchema == null) {
                throw new NotFoundException("Virtual Schema '" + schemaTO.getKey() + "'");
            }
            virSchemaDAO.save(binder.update((VirSchemaTO) schemaTO, virSchema));
            break;
        case DERIVED:
            DerSchema derSchema = derSchemaDAO.find(schemaTO.getKey());
            if (derSchema == null) {
                throw new NotFoundException("Derived schema '" + schemaTO.getKey() + "'");
            }
            derSchemaDAO.save(binder.update((DerSchemaTO) schemaTO, derSchema));
            break;
        case PLAIN:
        default:
            PlainSchema plainSchema = plainSchemaDAO.find(schemaTO.getKey());
            if (plainSchema == null) {
                throw new NotFoundException("Schema '" + schemaTO.getKey() + "'");
            }
            plainSchemaDAO.save(binder.update((PlainSchemaTO) schemaTO, plainSchema));
    }
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) DerSchema(org.apache.syncope.core.persistence.api.entity.DerSchema) VirSchema(org.apache.syncope.core.persistence.api.entity.VirSchema) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO) DerSchemaTO(org.apache.syncope.common.lib.to.DerSchemaTO) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 10 with VirSchema

use of org.apache.syncope.core.persistence.api.entity.VirSchema in project syncope by apache.

the class SchemaLogic method read.

@PreAuthorize("isAuthenticated()")
@SuppressWarnings("unchecked")
public <T extends SchemaTO> T read(final SchemaType schemaType, final String schemaKey) {
    T read;
    switch(schemaType) {
        case VIRTUAL:
            VirSchema virSchema = virSchemaDAO.find(schemaKey);
            if (virSchema == null) {
                throw new NotFoundException("Virtual Schema '" + schemaKey + "'");
            }
            read = (T) binder.getVirSchemaTO(virSchema);
            break;
        case DERIVED:
            DerSchema derSchema = derSchemaDAO.find(schemaKey);
            if (derSchema == null) {
                throw new NotFoundException("Derived schema '" + schemaKey + "'");
            }
            read = (T) binder.getDerSchemaTO(derSchema);
            break;
        case PLAIN:
        default:
            PlainSchema schema = plainSchemaDAO.find(schemaKey);
            if (schema == null) {
                throw new NotFoundException("Schema '" + schemaKey + "'");
            }
            read = (T) binder.getPlainSchemaTO(schema);
    }
    return read;
}
Also used : DerSchema(org.apache.syncope.core.persistence.api.entity.DerSchema) VirSchema(org.apache.syncope.core.persistence.api.entity.VirSchema) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

VirSchema (org.apache.syncope.core.persistence.api.entity.VirSchema)26 DerSchema (org.apache.syncope.core.persistence.api.entity.DerSchema)10 Provision (org.apache.syncope.core.persistence.api.entity.resource.Provision)10 List (java.util.List)9 PlainSchema (org.apache.syncope.core.persistence.api.entity.PlainSchema)9 HashSet (java.util.HashSet)6 AnyTypeClass (org.apache.syncope.core.persistence.api.entity.AnyTypeClass)6 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)6 ArrayList (java.util.ArrayList)5 Collections (java.util.Collections)5 Date (java.util.Date)5 OrgUnit (org.apache.syncope.core.persistence.api.entity.resource.OrgUnit)5 ParseException (java.text.ParseException)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)4 AnyTypeDAO (org.apache.syncope.core.persistence.api.dao.AnyTypeDAO)4 SyncopeClientCompositeException (org.apache.syncope.common.lib.SyncopeClientCompositeException)3 VirSchemaDAO (org.apache.syncope.core.persistence.api.dao.VirSchemaDAO)3 AnyType (org.apache.syncope.core.persistence.api.entity.AnyType)3