Search in sources :

Example 1 with GroupablePlainAttr

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

the class AbstractAnyDataBinder method fill.

@SuppressWarnings({ "unchecked", "rawtypes" })
protected void fill(final Any any, final Membership membership, final MembershipTO membershipTO, final AnyUtils anyUtils, final SyncopeClientCompositeException scce) {
    SyncopeClientException invalidValues = SyncopeClientException.build(ClientExceptionType.InvalidValues);
    membershipTO.getPlainAttrs().stream().filter(attrTO -> !attrTO.getValues().isEmpty()).forEach(attrTO -> {
        PlainSchema schema = getPlainSchema(attrTO.getSchema());
        if (schema != null) {
            GroupablePlainAttr attr = (GroupablePlainAttr) GroupableRelatable.class.cast(any).getPlainAttr(schema.getKey(), membership).orElse(null);
            if (attr == null) {
                attr = anyUtils.newPlainAttr();
                attr.setOwner(any);
                attr.setMembership(membership);
                attr.setSchema(schema);
            }
            fillAttr(attrTO.getValues(), anyUtils, schema, attr, invalidValues);
            if (attr.getValuesAsStrings().isEmpty()) {
                attr.setOwner(null);
            } else {
                any.add(attr);
            }
        }
    });
    if (!invalidValues.isEmpty()) {
        scce.addException(invalidValues);
    }
}
Also used : StringPatchItem(org.apache.syncope.common.lib.patch.StringPatchItem) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Realm(org.apache.syncope.core.persistence.api.entity.Realm) PlainAttr(org.apache.syncope.core.persistence.api.entity.PlainAttr) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) InvalidPlainAttrValueException(org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidPlainAttrValueException) ResourceOperation(org.apache.syncope.common.lib.types.ResourceOperation) StringUtils(org.apache.commons.lang3.StringUtils) AllowedSchemas(org.apache.syncope.core.persistence.api.dao.AllowedSchemas) JexlUtils(org.apache.syncope.core.provisioning.java.jexl.JexlUtils) GroupDAO(org.apache.syncope.core.persistence.api.dao.GroupDAO) AnyObjectDAO(org.apache.syncope.core.persistence.api.dao.AnyObjectDAO) Map(java.util.Map) SchemaDataBinder(org.apache.syncope.core.provisioning.api.data.SchemaDataBinder) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) ParseException(java.text.ParseException) AnyTypeClass(org.apache.syncope.core.persistence.api.entity.AnyTypeClass) AnyPatch(org.apache.syncope.common.lib.patch.AnyPatch) RelationshipTypeDAO(org.apache.syncope.core.persistence.api.dao.RelationshipTypeDAO) UserDAO(org.apache.syncope.core.persistence.api.dao.UserDAO) Collection(java.util.Collection) DerAttrHandler(org.apache.syncope.core.provisioning.api.DerAttrHandler) Set(java.util.Set) PlainAttrValue(org.apache.syncope.core.persistence.api.entity.PlainAttrValue) Collectors(java.util.stream.Collectors) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) MappingItem(org.apache.syncope.core.persistence.api.entity.resource.MappingItem) EntityFactory(org.apache.syncope.core.persistence.api.entity.EntityFactory) List(java.util.List) Provision(org.apache.syncope.core.persistence.api.entity.resource.Provision) AttrPatch(org.apache.syncope.common.lib.patch.AttrPatch) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) Optional(java.util.Optional) ExternalResourceDAO(org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO) IntAttrName(org.apache.syncope.core.provisioning.api.IntAttrName) AttrTO(org.apache.syncope.common.lib.to.AttrTO) AnyUtilsFactory(org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory) GroupableRelatable(org.apache.syncope.core.persistence.api.entity.GroupableRelatable) AnyTO(org.apache.syncope.common.lib.to.AnyTO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DerSchema(org.apache.syncope.core.persistence.api.entity.DerSchema) MappingManager(org.apache.syncope.core.provisioning.api.MappingManager) SyncopeClientCompositeException(org.apache.syncope.common.lib.SyncopeClientCompositeException) ClientExceptionType(org.apache.syncope.common.lib.types.ClientExceptionType) RealmDAO(org.apache.syncope.core.persistence.api.dao.RealmDAO) MembershipTO(org.apache.syncope.common.lib.to.MembershipTO) Logger(org.slf4j.Logger) PlainSchemaDAO(org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO) VirAttrHandler(org.apache.syncope.core.provisioning.api.VirAttrHandler) Membership(org.apache.syncope.core.persistence.api.entity.Membership) PlainAttrValueDAO(org.apache.syncope.core.persistence.api.dao.PlainAttrValueDAO) VirSchema(org.apache.syncope.core.persistence.api.entity.VirSchema) MappingUtils(org.apache.syncope.core.provisioning.java.utils.MappingUtils) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) RelationshipTO(org.apache.syncope.common.lib.to.RelationshipTO) PatchOperation(org.apache.syncope.common.lib.types.PatchOperation) IntAttrNameParser(org.apache.syncope.core.provisioning.java.IntAttrNameParser) AnyUtils(org.apache.syncope.core.persistence.api.entity.AnyUtils) Collections(java.util.Collections) AnyTypeClassDAO(org.apache.syncope.core.persistence.api.dao.AnyTypeClassDAO) Any(org.apache.syncope.core.persistence.api.entity.Any) PlainAttrDAO(org.apache.syncope.core.persistence.api.dao.PlainAttrDAO) GroupablePlainAttr(org.apache.syncope.core.persistence.api.entity.GroupablePlainAttr) GroupableRelatable(org.apache.syncope.core.persistence.api.entity.GroupableRelatable) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) GroupablePlainAttr(org.apache.syncope.core.persistence.api.entity.GroupablePlainAttr)

Aggregations

ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 SyncopeClientCompositeException (org.apache.syncope.common.lib.SyncopeClientCompositeException)1 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1 AnyPatch (org.apache.syncope.common.lib.patch.AnyPatch)1 AttrPatch (org.apache.syncope.common.lib.patch.AttrPatch)1 StringPatchItem (org.apache.syncope.common.lib.patch.StringPatchItem)1 AnyTO (org.apache.syncope.common.lib.to.AnyTO)1 AttrTO (org.apache.syncope.common.lib.to.AttrTO)1 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)1 RelationshipTO (org.apache.syncope.common.lib.to.RelationshipTO)1