syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [49/52] [abbrv] [partial] syncope git commit: [SYNCOPE-620] Unit tests all in
Date Mon, 12 Jan 2015 16:32:28 GMT
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/AbstractAttributableDataBinder.java
----------------------------------------------------------------------
diff --git a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/AbstractAttributableDataBinder.java b/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/AbstractAttributableDataBinder.java
deleted file mode 100644
index d84c62f..0000000
--- a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/AbstractAttributableDataBinder.java
+++ /dev/null
@@ -1,918 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.logic.data;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.common.lib.SyncopeClientCompositeException;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.mod.AbstractAttributableMod;
-import org.apache.syncope.common.lib.mod.AbstractSubjectMod;
-import org.apache.syncope.common.lib.mod.AttrMod;
-import org.apache.syncope.common.lib.to.AbstractAttributableTO;
-import org.apache.syncope.common.lib.to.AbstractSubjectTO;
-import org.apache.syncope.common.lib.to.AttrTO;
-import org.apache.syncope.common.lib.types.AttributableType;
-import org.apache.syncope.common.lib.types.ClientExceptionType;
-import org.apache.syncope.common.lib.types.IntMappingType;
-import org.apache.syncope.common.lib.types.MappingPurpose;
-import org.apache.syncope.common.lib.types.ResourceOperation;
-import org.apache.syncope.persistence.api.attrvalue.validation.InvalidPlainAttrValueException;
-import org.apache.syncope.persistence.api.dao.DerAttrDAO;
-import org.apache.syncope.persistence.api.dao.DerSchemaDAO;
-import org.apache.syncope.persistence.api.dao.ExternalResourceDAO;
-import org.apache.syncope.persistence.api.dao.MembershipDAO;
-import org.apache.syncope.persistence.api.dao.PlainAttrDAO;
-import org.apache.syncope.persistence.api.dao.PlainAttrValueDAO;
-import org.apache.syncope.persistence.api.dao.PlainSchemaDAO;
-import org.apache.syncope.persistence.api.dao.PolicyDAO;
-import org.apache.syncope.persistence.api.dao.RoleDAO;
-import org.apache.syncope.persistence.api.dao.UserDAO;
-import org.apache.syncope.persistence.api.dao.VirAttrDAO;
-import org.apache.syncope.persistence.api.dao.VirSchemaDAO;
-import org.apache.syncope.persistence.api.entity.Attributable;
-import org.apache.syncope.persistence.api.entity.AttributableUtil;
-import org.apache.syncope.persistence.api.entity.AttributableUtilFactory;
-import org.apache.syncope.persistence.api.entity.DerAttr;
-import org.apache.syncope.persistence.api.entity.DerSchema;
-import org.apache.syncope.persistence.api.entity.EntityFactory;
-import org.apache.syncope.persistence.api.entity.ExternalResource;
-import org.apache.syncope.persistence.api.entity.MappingItem;
-import org.apache.syncope.persistence.api.entity.PlainAttr;
-import org.apache.syncope.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.persistence.api.entity.PlainSchema;
-import org.apache.syncope.persistence.api.entity.Schema;
-import org.apache.syncope.persistence.api.entity.Subject;
-import org.apache.syncope.persistence.api.entity.VirAttr;
-import org.apache.syncope.persistence.api.entity.VirSchema;
-import org.apache.syncope.persistence.api.entity.membership.MDerAttr;
-import org.apache.syncope.persistence.api.entity.membership.MDerAttrTemplate;
-import org.apache.syncope.persistence.api.entity.membership.MPlainAttr;
-import org.apache.syncope.persistence.api.entity.membership.MPlainAttrTemplate;
-import org.apache.syncope.persistence.api.entity.membership.MVirAttr;
-import org.apache.syncope.persistence.api.entity.membership.MVirAttrTemplate;
-import org.apache.syncope.persistence.api.entity.membership.Membership;
-import org.apache.syncope.persistence.api.entity.role.RDerAttr;
-import org.apache.syncope.persistence.api.entity.role.RDerAttrTemplate;
-import org.apache.syncope.persistence.api.entity.role.RPlainAttr;
-import org.apache.syncope.persistence.api.entity.role.RPlainAttrTemplate;
-import org.apache.syncope.persistence.api.entity.role.RVirAttr;
-import org.apache.syncope.persistence.api.entity.role.RVirAttrTemplate;
-import org.apache.syncope.persistence.api.entity.role.Role;
-import org.apache.syncope.persistence.api.entity.user.UDerAttr;
-import org.apache.syncope.persistence.api.entity.user.UDerSchema;
-import org.apache.syncope.persistence.api.entity.user.UPlainAttr;
-import org.apache.syncope.persistence.api.entity.user.UPlainSchema;
-import org.apache.syncope.persistence.api.entity.user.UVirAttr;
-import org.apache.syncope.persistence.api.entity.user.UVirSchema;
-import org.apache.syncope.provisioning.api.propagation.PropagationByResource;
-import org.apache.syncope.server.utils.MappingUtil;
-import org.apache.syncope.server.utils.jexl.JexlUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public abstract class AbstractAttributableDataBinder {
-
-    /**
-     * Logger.
-     */
-    protected static final Logger LOG = LoggerFactory.getLogger(AbstractAttributableDataBinder.class);
-
-    @Autowired
-    protected RoleDAO roleDAO;
-
-    @Autowired
-    protected PlainSchemaDAO plainSchemaDAO;
-
-    @Autowired
-    protected DerSchemaDAO derSchemaDAO;
-
-    @Autowired
-    protected VirSchemaDAO virSchemaDAO;
-
-    @Autowired
-    protected PlainAttrDAO plainAttrDAO;
-
-    @Autowired
-    protected DerAttrDAO derAttrDAO;
-
-    @Autowired
-    protected VirAttrDAO virAttrDAO;
-
-    @Autowired
-    protected PlainAttrValueDAO plainAttrValueDAO;
-
-    @Autowired
-    protected UserDAO userDAO;
-
-    @Autowired
-    protected ExternalResourceDAO resourceDAO;
-
-    @Autowired
-    protected MembershipDAO membershipDAO;
-
-    @Autowired
-    protected PolicyDAO policyDAO;
-
-    @Autowired
-    protected EntityFactory entityFactory;
-
-    @Autowired
-    protected AttributableUtilFactory attrUtilFactory;
-
-    @SuppressWarnings("unchecked")
-    protected <T extends Schema> T getSchema(final String schemaName, final Class<T> reference) {
-        T result = null;
-
-        if (PlainSchema.class.isAssignableFrom(reference)) {
-            result = (T) getPlainSchema(schemaName, (Class<? extends PlainSchema>) reference);
-        } else if (DerSchema.class.isAssignableFrom(reference)) {
-            result = (T) getDerSchema(schemaName, (Class<? extends DerSchema>) reference);
-        } else if (VirSchema.class.isAssignableFrom(reference)) {
-            result = (T) getVirSchema(schemaName, (Class<? extends VirSchema>) reference);
-        }
-
-        return result;
-    }
-
-    protected <T extends PlainSchema> T getPlainSchema(final String schemaName, final Class<T> reference) {
-        T schema = null;
-        if (StringUtils.isNotBlank(schemaName)) {
-            schema = plainSchemaDAO.find(schemaName, reference);
-
-            // safely ignore invalid schemas from AttrTO
-            // see http://code.google.com/p/syncope/issues/detail?id=17
-            if (schema == null) {
-                LOG.debug("Ignoring invalid schema {}", schemaName);
-            } else if (schema.isReadonly()) {
-                schema = null;
-
-                LOG.debug("Ignoring readonly schema {}", schemaName);
-            }
-        }
-
-        return schema;
-    }
-
-    private <T extends DerSchema> T getDerSchema(final String derSchemaName, final Class<T> reference) {
-        T derivedSchema = null;
-        if (StringUtils.isNotBlank(derSchemaName)) {
-            derivedSchema = derSchemaDAO.find(derSchemaName, reference);
-            if (derivedSchema == null) {
-                LOG.debug("Ignoring invalid derived schema {}", derSchemaName);
-            }
-        }
-
-        return derivedSchema;
-    }
-
-    private <T extends VirSchema> T getVirSchema(final String virSchemaName, final Class<T> reference) {
-        T virtualSchema = null;
-        if (StringUtils.isNotBlank(virSchemaName)) {
-            virtualSchema = virSchemaDAO.find(virSchemaName, reference);
-
-            if (virtualSchema == null) {
-                LOG.debug("Ignoring invalid virtual schema {}", virSchemaName);
-            }
-        }
-
-        return virtualSchema;
-    }
-
-    protected void fillAttribute(final List<String> values, final AttributableUtil attributableUtil,
-            final PlainSchema schema, final PlainAttr attr, final SyncopeClientException invalidValues) {
-
-        // if schema is multivalue, all values are considered for addition;
-        // otherwise only the fist one - if provided - is considered
-        List<String> valuesProvided = schema.isMultivalue()
-                ? values
-                : (values.isEmpty()
-                        ? Collections.<String>emptyList()
-                        : Collections.singletonList(values.iterator().next()));
-
-        for (String value : valuesProvided) {
-            if (value == null || value.isEmpty()) {
-                LOG.debug("Null value for {}, ignoring", schema.getKey());
-            } else {
-                try {
-                    attr.addValue(value, attributableUtil);
-                } catch (InvalidPlainAttrValueException e) {
-                    LOG.warn("Invalid value for attribute " + schema.getKey() + ": " + value, e);
-
-                    invalidValues.getElements().add(schema.getKey() + ": " + value + " - " + e.getMessage());
-                }
-            }
-        }
-    }
-
-    private boolean evaluateMandatoryCondition(final AttributableUtil attrUtil, final ExternalResource resource,
-            final Attributable attributable, final String intAttrName, final IntMappingType intMappingType) {
-
-        boolean result = false;
-
-        final List<MappingItem> mappings = MappingUtil.getMatchingMappingItems(
-                attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION), intAttrName, intMappingType);
-        for (Iterator<MappingItem> itor = mappings.iterator(); itor.hasNext() && !result;) {
-            final MappingItem mapping = itor.next();
-            result |= JexlUtil.evaluateMandatoryCondition(mapping.getMandatoryCondition(), attributable);
-        }
-
-        return result;
-    }
-
-    private boolean evaluateMandatoryCondition(final AttributableUtil attrUtil,
-            final Attributable<?, ?, ?> attributable, final String intAttrName, final IntMappingType intMappingType) {
-
-        boolean result = false;
-
-        if (attributable instanceof Subject) {
-            for (Iterator<? extends ExternalResource> itor = ((Subject<?, ?, ?>) attributable).getResources().iterator();
-                    itor.hasNext() && !result;) {
-
-                final ExternalResource resource = itor.next();
-                if (resource.isEnforceMandatoryCondition()) {
-                    result |= evaluateMandatoryCondition(attrUtil, resource, attributable, intAttrName, intMappingType);
-                }
-            }
-        }
-
-        return result;
-    }
-
-    private SyncopeClientException checkMandatory(final AttributableUtil attrUtil,
-            final Attributable<?, ?, ?> attributable) {
-
-        SyncopeClientException reqValMissing = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
-
-        // Check if there is some mandatory schema defined for which no value has been provided
-        List<? extends PlainSchema> plainSchemas;
-        switch (attrUtil.getType()) {
-            case ROLE:
-                plainSchemas = ((Role) attributable).getAttrTemplateSchemas(RPlainAttrTemplate.class);
-                break;
-
-            case MEMBERSHIP:
-                plainSchemas = ((Membership) attributable).getRole().getAttrTemplateSchemas(MPlainAttrTemplate.class);
-                break;
-
-            case USER:
-            default:
-                plainSchemas = plainSchemaDAO.findAll(attrUtil.plainSchemaClass());
-        }
-        for (PlainSchema schema : plainSchemas) {
-            if (attributable.getPlainAttr(schema.getKey()) == null
-                    && !schema.isReadonly()
-                    && (JexlUtil.evaluateMandatoryCondition(schema.getMandatoryCondition(), attributable)
-                    || evaluateMandatoryCondition(attrUtil, attributable, schema.getKey(),
-                            attrUtil.intMappingType()))) {
-
-                LOG.error("Mandatory schema " + schema.getKey() + " not provided with values");
-
-                reqValMissing.getElements().add(schema.getKey());
-            }
-        }
-
-        List<? extends DerSchema> derSchemas;
-        switch (attrUtil.getType()) {
-            case ROLE:
-                derSchemas = ((Role) attributable).getAttrTemplateSchemas(RDerAttrTemplate.class);
-                break;
-
-            case MEMBERSHIP:
-                derSchemas = ((Membership) attributable).getRole().getAttrTemplateSchemas(MDerAttrTemplate.class);
-                break;
-
-            case USER:
-            default:
-                derSchemas = derSchemaDAO.findAll(attrUtil.derSchemaClass());
-        }
-        for (DerSchema derSchema : derSchemas) {
-            if (attributable.getDerAttr(derSchema.getKey()) == null
-                    && evaluateMandatoryCondition(attrUtil, attributable, derSchema.getKey(),
-                            attrUtil.derIntMappingType())) {
-
-                LOG.error("Mandatory derived schema " + derSchema.getKey() + " does not evaluate to any value");
-
-                reqValMissing.getElements().add(derSchema.getKey());
-            }
-        }
-
-        List<? extends VirSchema> virSchemas;
-        switch (attrUtil.getType()) {
-            case ROLE:
-                virSchemas = ((Role) attributable).getAttrTemplateSchemas(RVirAttrTemplate.class);
-                break;
-
-            case MEMBERSHIP:
-                virSchemas = ((Membership) attributable).getRole().getAttrTemplateSchemas(MVirAttrTemplate.class);
-                break;
-
-            case USER:
-            default:
-                virSchemas = virSchemaDAO.findAll(attrUtil.virSchemaClass());
-        }
-        for (VirSchema virSchema : virSchemas) {
-            if (attributable.getVirAttr(virSchema.getKey()) == null
-                    && !virSchema.isReadonly()
-                    && evaluateMandatoryCondition(attrUtil, attributable, virSchema.getKey(),
-                            attrUtil.virIntMappingType())) {
-
-                LOG.error("Mandatory virtual schema " + virSchema.getKey() + " not provided with values");
-
-                reqValMissing.getElements().add(virSchema.getKey());
-            }
-        }
-
-        return reqValMissing;
-    }
-
-    private void setPlainAttrSchema(final Attributable<?, ?, ?> attributable,
-            final PlainAttr attr, final PlainSchema schema) {
-
-        if (attr instanceof UPlainAttr) {
-            ((UPlainAttr) attr).setSchema((UPlainSchema) schema);
-        } else if (attr instanceof RPlainAttr) {
-            RPlainAttrTemplate template =
-                    ((Role) attributable).getAttrTemplate(RPlainAttrTemplate.class, schema.getKey());
-            if (template != null) {
-                ((RPlainAttr) attr).setTemplate(template);
-            }
-        } else if (attr instanceof MPlainAttr) {
-            MPlainAttrTemplate template = ((Membership) attributable).getRole().
-                    getAttrTemplate(MPlainAttrTemplate.class, schema.getKey());
-            if (template != null) {
-                ((MPlainAttr) attr).setTemplate(template);
-            }
-        }
-    }
-
-    private void setDerAttrSchema(final Attributable<?, ?, ?> attributable,
-            final DerAttr derAttr, final DerSchema derSchema) {
-
-        if (derAttr instanceof UDerAttr) {
-            ((UDerAttr) derAttr).setSchema((UDerSchema) derSchema);
-        } else if (derAttr instanceof RDerAttr) {
-            RDerAttrTemplate template = ((Role) attributable).
-                    getAttrTemplate(RDerAttrTemplate.class, derSchema.getKey());
-            if (template != null) {
-                ((RDerAttr) derAttr).setTemplate(template);
-            }
-        } else if (derAttr instanceof MDerAttr) {
-            MDerAttrTemplate template = ((Membership) attributable).getRole().
-                    getAttrTemplate(MDerAttrTemplate.class, derSchema.getKey());
-            if (template != null) {
-                ((MDerAttr) derAttr).setTemplate(template);
-            }
-        }
-    }
-
-    private void setVirAttrSchema(final Attributable<?, ?, ?> attributable,
-            final VirAttr virAttr, final VirSchema virSchema) {
-
-        if (virAttr instanceof UVirAttr) {
-            ((UVirAttr) virAttr).setSchema((UVirSchema) virSchema);
-        } else if (virAttr instanceof RVirAttr) {
-            RVirAttrTemplate template = ((Role) attributable).
-                    getAttrTemplate(RVirAttrTemplate.class, virSchema.getKey());
-            if (template != null) {
-                ((RVirAttr) virAttr).setTemplate(template);
-            }
-        } else if (virAttr instanceof MVirAttr) {
-            MVirAttrTemplate template =
-                    ((Membership) attributable).getRole().
-                    getAttrTemplate(MVirAttrTemplate.class, virSchema.getKey());
-            if (template != null) {
-                ((MVirAttr) virAttr).setTemplate(template);
-            }
-        }
-    }
-
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    public PropagationByResource fillVirtual(final Attributable attributable,
-            final Set<String> vAttrsToBeRemoved, final Set<AttrMod> vAttrsToBeUpdated,
-            final AttributableUtil attrUtil) {
-
-        PropagationByResource propByRes = new PropagationByResource();
-
-        final Set<ExternalResource> externalResources = new HashSet<>();
-        if (attributable instanceof Subject) {
-            externalResources.addAll(((Subject<?, ?, ?>) attributable).getResources());
-        }
-
-        if (attributable instanceof Membership) {
-            externalResources.clear();
-            externalResources.addAll(((Membership) attributable).getUser().getResources());
-        }
-
-        // 1. virtual attributes to be removed
-        for (String vAttrToBeRemoved : vAttrsToBeRemoved) {
-            VirSchema virSchema = getVirSchema(vAttrToBeRemoved, attrUtil.virSchemaClass());
-            if (virSchema != null) {
-                VirAttr virAttr = attributable.getVirAttr(virSchema.getKey());
-                if (virAttr == null) {
-                    LOG.debug("No virtual attribute found for schema {}", virSchema.getKey());
-                } else {
-                    attributable.removeVirAttr(virAttr);
-                    virAttrDAO.delete(virAttr);
-                }
-
-                for (ExternalResource resource : resourceDAO.findAll()) {
-                    for (MappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
-                        if (virSchema.getKey().equals(mapItem.getIntAttrName())
-                                && mapItem.getIntMappingType() == attrUtil.virIntMappingType()
-                                && externalResources.contains(resource)) {
-
-                            propByRes.add(ResourceOperation.UPDATE, resource.getKey());
-
-                            // Using virtual attribute as AccountId must be avoided
-                            if (mapItem.isAccountid() && virAttr != null && !virAttr.getValues().isEmpty()) {
-                                propByRes.addOldAccountId(resource.getKey(), virAttr.getValues().get(0));
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        LOG.debug("Virtual attributes to be removed:\n{}", propByRes);
-
-        // 2. virtual attributes to be updated
-        for (AttrMod vAttrToBeUpdated : vAttrsToBeUpdated) {
-            VirSchema virSchema = getVirSchema(vAttrToBeUpdated.getSchema(), attrUtil.virSchemaClass());
-            VirAttr virAttr = null;
-            if (virSchema != null) {
-                virAttr = attributable.getVirAttr(virSchema.getKey());
-                if (virAttr == null) {
-                    virAttr = attrUtil.newVirAttr();
-                    setVirAttrSchema(attributable, virAttr, virSchema);
-                    if (virAttr.getSchema() == null) {
-                        LOG.debug("Ignoring {} because no valid schema or template was found", vAttrToBeUpdated);
-                    } else {
-                        attributable.addVirAttr(virAttr);
-                    }
-                }
-            }
-
-            if (virSchema != null && virAttr != null && virAttr.getSchema() != null) {
-                for (ExternalResource resource : resourceDAO.findAll()) {
-                    for (MappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
-                        if (virSchema.getKey().equals(mapItem.getIntAttrName())
-                                && mapItem.getIntMappingType() == attrUtil.virIntMappingType()
-                                && externalResources.contains(resource)) {
-
-                            propByRes.add(ResourceOperation.UPDATE, resource.getKey());
-                        }
-                    }
-                }
-
-                final List<String> values = new ArrayList<>(virAttr.getValues());
-                values.removeAll(vAttrToBeUpdated.getValuesToBeRemoved());
-                values.addAll(vAttrToBeUpdated.getValuesToBeAdded());
-
-                virAttr.getValues().clear();
-                virAttr.getValues().addAll(values);
-
-                // Owner cannot be specified before otherwise a virtual attribute remove will be invalidated.
-                virAttr.setOwner(attributable);
-            }
-        }
-
-        LOG.debug("Virtual attributes to be added:\n{}", propByRes);
-
-        return propByRes;
-    }
-
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    protected PropagationByResource fill(final Attributable attributable,
-            final AbstractAttributableMod attributableMod, final AttributableUtil attrUtil,
-            final SyncopeClientCompositeException scce) {
-
-        PropagationByResource propByRes = new PropagationByResource();
-
-        SyncopeClientException invalidValues = SyncopeClientException.build(ClientExceptionType.InvalidValues);
-
-        if (attributable instanceof Subject && attributableMod instanceof AbstractSubjectMod) {
-            // 1. resources to be removed
-            for (String resourceToBeRemoved : ((AbstractSubjectMod) attributableMod).getResourcesToRemove()) {
-                ExternalResource resource = resourceDAO.find(resourceToBeRemoved);
-                if (resource != null) {
-                    propByRes.add(ResourceOperation.DELETE, resource.getKey());
-                    ((Subject<?, ?, ?>) attributable).removeResource(resource);
-                }
-            }
-
-            LOG.debug("Resources to be removed:\n{}", propByRes);
-
-            // 2. resources to be added
-            for (String resourceToBeAdded : ((AbstractSubjectMod) attributableMod).getResourcesToAdd()) {
-                ExternalResource resource = resourceDAO.find(resourceToBeAdded);
-                if (resource != null) {
-                    propByRes.add(ResourceOperation.CREATE, resource.getKey());
-                    ((Subject<?, ?, ?>) attributable).addResource(resource);
-                }
-            }
-
-            LOG.debug("Resources to be added:\n{}", propByRes);
-        }
-
-        // 3. attributes to be removed
-        for (String attributeToBeRemoved : attributableMod.getAttrsToRemove()) {
-            PlainSchema schema = getPlainSchema(attributeToBeRemoved, attrUtil.plainSchemaClass());
-            if (schema != null) {
-                PlainAttr attr = attributable.getPlainAttr(schema.getKey());
-                if (attr == null) {
-                    LOG.debug("No attribute found for schema {}", schema);
-                } else {
-                    String newValue = null;
-                    for (AttrMod mod : attributableMod.getAttrsToUpdate()) {
-                        if (schema.getKey().equals(mod.getSchema())) {
-                            newValue = mod.getValuesToBeAdded().get(0);
-                        }
-                    }
-
-                    if (!schema.isUniqueConstraint()
-                            || (!attr.getUniqueValue().getStringValue().equals(newValue))) {
-
-                        attributable.removePlainAttr(attr);
-                        plainAttrDAO.delete(attr.getKey(), attrUtil.plainAttrClass());
-                    }
-                }
-
-                if (attributable instanceof Subject) {
-                    for (ExternalResource resource : resourceDAO.findAll()) {
-                        for (MappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
-                            if (schema.getKey().equals(mapItem.getIntAttrName())
-                                    && mapItem.getIntMappingType() == attrUtil.intMappingType()
-                                    && ((Subject<?, ?, ?>) attributable).getResources().contains(resource)) {
-
-                                propByRes.add(ResourceOperation.UPDATE, resource.getKey());
-
-                                if (mapItem.isAccountid() && attr != null
-                                        && !attr.getValuesAsStrings().isEmpty()) {
-
-                                    propByRes.addOldAccountId(resource.getKey(),
-                                            attr.getValuesAsStrings().iterator().next());
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        LOG.debug("Attributes to be removed:\n{}", propByRes);
-
-        // 4. attributes to be updated
-        for (AttrMod attributeMod : attributableMod.getAttrsToUpdate()) {
-            PlainSchema schema = getPlainSchema(attributeMod.getSchema(), attrUtil.plainSchemaClass());
-            PlainAttr attr = null;
-            if (schema != null) {
-                attr = attributable.getPlainAttr(schema.getKey());
-                if (attr == null) {
-                    attr = attrUtil.newPlainAttr();
-                    setPlainAttrSchema(attributable, attr, schema);
-                    if (attr.getSchema() == null) {
-                        LOG.debug("Ignoring {} because no valid schema or template was found", attributeMod);
-                    } else {
-                        attr.setOwner(attributable);
-                        attributable.addPlainAttr(attr);
-                    }
-                }
-            }
-
-            if (schema != null && attr != null && attr.getSchema() != null) {
-                if (attributable instanceof Subject) {
-                    for (ExternalResource resource : resourceDAO.findAll()) {
-                        for (MappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
-                            if (schema.getKey().equals(mapItem.getIntAttrName())
-                                    && mapItem.getIntMappingType() == attrUtil.intMappingType()
-                                    && ((Subject<?, ?, ?>) attributable).getResources().contains(resource)) {
-
-                                propByRes.add(ResourceOperation.UPDATE, resource.getKey());
-                            }
-                        }
-                    }
-                }
-
-                // 1.1 remove values
-                Set<Long> valuesToBeRemoved = new HashSet<>();
-                for (String valueToBeRemoved : attributeMod.getValuesToBeRemoved()) {
-                    if (attr.getSchema().isUniqueConstraint()) {
-                        if (attr.getUniqueValue() != null
-                                && valueToBeRemoved.equals(attr.getUniqueValue().getValueAsString())) {
-
-                            valuesToBeRemoved.add(attr.getUniqueValue().getKey());
-                        }
-                    } else {
-                        for (PlainAttrValue mav : attr.getValues()) {
-                            if (valueToBeRemoved.equals(mav.getValueAsString())) {
-                                valuesToBeRemoved.add(mav.getKey());
-                            }
-                        }
-                    }
-                }
-                for (Long attributeValueId : valuesToBeRemoved) {
-                    plainAttrValueDAO.delete(attributeValueId, attrUtil.plainAttrValueClass());
-                }
-
-                // 1.2 add values
-                List<String> valuesToBeAdded = attributeMod.getValuesToBeAdded();
-                if (valuesToBeAdded != null && !valuesToBeAdded.isEmpty()
-                        && (!schema.isUniqueConstraint() || attr.getUniqueValue() == null
-                        || !valuesToBeAdded.iterator().next().equals(attr.getUniqueValue().getValueAsString()))) {
-
-                    fillAttribute(attributeMod.getValuesToBeAdded(), attrUtil, schema, attr, invalidValues);
-                }
-
-                // if no values are in, the attribute can be safely removed
-                if (attr.getValuesAsStrings().isEmpty()) {
-                    plainAttrDAO.delete(attr);
-                }
-            }
-        }
-
-        if (!invalidValues.isEmpty()) {
-            scce.addException(invalidValues);
-        }
-
-        LOG.debug("Attributes to be updated:\n{}", propByRes);
-
-        // 5. derived attributes to be removed
-        for (String derAttrToBeRemoved : attributableMod.getDerAttrsToRemove()) {
-            DerSchema derSchema = getDerSchema(derAttrToBeRemoved, attrUtil.derSchemaClass());
-            if (derSchema != null) {
-                DerAttr derAttr = attributable.getDerAttr(derSchema.getKey());
-                if (derAttr == null) {
-                    LOG.debug("No derived attribute found for schema {}", derSchema.getKey());
-                } else {
-                    derAttrDAO.delete(derAttr);
-                }
-
-                if (attributable instanceof Subject) {
-                    for (ExternalResource resource : resourceDAO.findAll()) {
-                        for (MappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
-                            if (derSchema.getKey().equals(mapItem.getIntAttrName())
-                                    && mapItem.getIntMappingType() == attrUtil.derIntMappingType()
-                                    && ((Subject<?, ?, ?>) attributable).getResources().contains(resource)) {
-
-                                propByRes.add(ResourceOperation.UPDATE, resource.getKey());
-
-                                if (mapItem.isAccountid() && derAttr != null
-                                        && !derAttr.getValue(attributable.getPlainAttrs()).isEmpty()) {
-
-                                    propByRes.addOldAccountId(resource.getKey(),
-                                            derAttr.getValue(attributable.getPlainAttrs()));
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        LOG.debug("Derived attributes to be removed:\n{}", propByRes);
-
-        // 6. derived attributes to be added
-        for (String derAttrToBeAdded : attributableMod.getDerAttrsToAdd()) {
-            DerSchema derSchema = getDerSchema(derAttrToBeAdded, attrUtil.derSchemaClass());
-            if (derSchema != null) {
-                if (attributable instanceof Subject) {
-                    for (ExternalResource resource : resourceDAO.findAll()) {
-                        for (MappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
-                            if (derSchema.getKey().equals(mapItem.getIntAttrName())
-                                    && mapItem.getIntMappingType() == attrUtil.derIntMappingType()
-                                    && ((Subject<?, ?, ?>) attributable).getResources().contains(resource)) {
-
-                                propByRes.add(ResourceOperation.UPDATE, resource.getKey());
-                            }
-                        }
-                    }
-                }
-
-                DerAttr derAttr = attrUtil.newDerAttr();
-                setDerAttrSchema(attributable, derAttr, derSchema);
-                if (derAttr.getSchema() == null) {
-                    LOG.debug("Ignoring {} because no valid schema or template was found", derAttrToBeAdded);
-                } else {
-                    derAttr.setOwner(attributable);
-                    attributable.addDerAttr(derAttr);
-                }
-            }
-        }
-
-        LOG.debug("Derived attributes to be added:\n{}", propByRes);
-
-        // 7. virtual attributes: for users and roles this is delegated to PropagationManager
-        if (AttributableType.USER != attrUtil.getType() && AttributableType.ROLE != attrUtil.getType()) {
-            fillVirtual(attributable, attributableMod.getVirAttrsToRemove(),
-                    attributableMod.getVirAttrsToUpdate(), attrUtil);
-        }
-
-        // Finally, check if mandatory values are missing
-        SyncopeClientException requiredValuesMissing = checkMandatory(attrUtil, attributable);
-        if (!requiredValuesMissing.isEmpty()) {
-            scce.addException(requiredValuesMissing);
-        }
-
-        // Throw composite exception if there is at least one element set in the composing exceptions
-        if (scce.hasExceptions()) {
-            throw scce;
-        }
-
-        return propByRes;
-    }
-
-    /**
-     * Add virtual attributes and specify values to be propagated.
-     *
-     * @param attributable attributable.
-     * @param vAttrs virtual attributes to be added.
-     * @param attrUtil attributable util.
-     */
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    public void fillVirtual(final Attributable attributable, final Collection<AttrTO> vAttrs,
-            final AttributableUtil attrUtil) {
-
-        for (AttrTO attributeTO : vAttrs) {
-            VirAttr virAttr = attributable.getVirAttr(attributeTO.getSchema());
-            if (virAttr == null) {
-                VirSchema virSchema = getVirSchema(attributeTO.getSchema(), attrUtil.virSchemaClass());
-                if (virSchema != null) {
-                    virAttr = attrUtil.newVirAttr();
-                    setVirAttrSchema(attributable, virAttr, virSchema);
-                    if (virAttr.getSchema() == null) {
-                        LOG.debug("Ignoring {} because no valid schema or template was found", attributeTO);
-                    } else {
-                        virAttr.setOwner(attributable);
-                        attributable.addVirAttr(virAttr);
-                        virAttr.getValues().clear();
-                        virAttr.getValues().addAll(attributeTO.getValues());
-                    }
-                }
-            } else {
-                virAttr.getValues().clear();
-                virAttr.getValues().addAll(attributeTO.getValues());
-            }
-        }
-    }
-
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    protected void fill(final Attributable attributable, final AbstractAttributableTO attributableTO,
-            final AttributableUtil attributableUtil, final SyncopeClientCompositeException scce) {
-
-        // 1. attributes
-        SyncopeClientException invalidValues = SyncopeClientException.build(ClientExceptionType.InvalidValues);
-
-        // Only consider attributeTO with values
-        for (AttrTO attributeTO : attributableTO.getPlainAttrs()) {
-            if (attributeTO.getValues() != null && !attributeTO.getValues().isEmpty()) {
-                PlainSchema schema = getPlainSchema(attributeTO.getSchema(), attributableUtil.plainSchemaClass());
-
-                if (schema != null) {
-                    PlainAttr attr = attributable.getPlainAttr(schema.getKey());
-                    if (attr == null) {
-                        attr = attributableUtil.newPlainAttr();
-                        setPlainAttrSchema(attributable, attr, schema);
-                    }
-                    if (attr.getSchema() == null) {
-                        LOG.debug("Ignoring {} because no valid schema or template was found", attributeTO);
-                    } else {
-                        fillAttribute(attributeTO.getValues(), attributableUtil, schema, attr, invalidValues);
-
-                        if (!attr.getValuesAsStrings().isEmpty()) {
-                            attributable.addPlainAttr(attr);
-                            attr.setOwner(attributable);
-                        }
-                    }
-                }
-            }
-        }
-
-        if (!invalidValues.isEmpty()) {
-            scce.addException(invalidValues);
-        }
-
-        // 2. derived attributes
-        for (AttrTO attributeTO : attributableTO.getDerAttrs()) {
-            DerSchema derSchema = getDerSchema(attributeTO.getSchema(), attributableUtil.derSchemaClass());
-
-            if (derSchema != null) {
-                DerAttr derAttr = attributableUtil.newDerAttr();
-                setDerAttrSchema(attributable, derAttr, derSchema);
-                if (derAttr.getSchema() == null) {
-                    LOG.debug("Ignoring {} because no valid schema or template was found", attributeTO);
-                } else {
-                    derAttr.setOwner(attributable);
-                    attributable.addDerAttr(derAttr);
-                }
-            }
-        }
-
-        // 3. user and role virtual attributes will be evaluated by the propagation manager only (if needed).
-        if (AttributableType.USER == attributableUtil.getType()
-                || AttributableType.ROLE == attributableUtil.getType()) {
-
-            for (AttrTO vattrTO : attributableTO.getVirAttrs()) {
-                VirSchema virSchema = getVirSchema(vattrTO.getSchema(), attributableUtil.virSchemaClass());
-
-                if (virSchema != null) {
-                    VirAttr virAttr = attributableUtil.newVirAttr();
-                    setVirAttrSchema(attributable, virAttr, virSchema);
-                    if (virAttr.getSchema() == null) {
-                        LOG.debug("Ignoring {} because no valid schema or template was found", vattrTO);
-                    } else {
-                        virAttr.setOwner(attributable);
-                        attributable.addVirAttr(virAttr);
-                    }
-                }
-            }
-        }
-
-        fillVirtual(attributable, attributableTO.getVirAttrs(), attributableUtil);
-
-        // 4. resources
-        if (attributable instanceof Subject && attributableTO instanceof AbstractSubjectTO) {
-            for (String resourceName : ((AbstractSubjectTO) attributableTO).getResources()) {
-                ExternalResource resource = resourceDAO.find(resourceName);
-
-                if (resource != null) {
-                    ((Subject<?, ?, ?>) attributable).addResource(resource);
-                }
-            }
-        }
-
-        SyncopeClientException requiredValuesMissing = checkMandatory(attributableUtil, attributable);
-        if (!requiredValuesMissing.isEmpty()) {
-            scce.addException(requiredValuesMissing);
-        }
-
-        // Throw composite exception if there is at least one element set in the composing exceptions
-        if (scce.hasExceptions()) {
-            throw scce;
-        }
-    }
-
-    protected void fillTO(final AbstractAttributableTO attributableTO,
-            final Collection<? extends PlainAttr> attrs,
-            final Collection<? extends DerAttr> derAttrs,
-            final Collection<? extends VirAttr> virAttrs,
-            final Collection<? extends ExternalResource> resources) {
-
-        AttrTO attributeTO;
-        for (PlainAttr attr : attrs) {
-            attributeTO = new AttrTO();
-            attributeTO.setSchema(attr.getSchema().getKey());
-            attributeTO.getValues().addAll(attr.getValuesAsStrings());
-            attributeTO.setReadonly(attr.getSchema().isReadonly());
-
-            attributableTO.getPlainAttrs().add(attributeTO);
-        }
-
-        for (DerAttr derAttr : derAttrs) {
-            attributeTO = new AttrTO();
-            attributeTO.setSchema(derAttr.getSchema().getKey());
-            attributeTO.getValues().add(derAttr.getValue(attrs));
-            attributeTO.setReadonly(true);
-
-            attributableTO.getDerAttrs().add(attributeTO);
-        }
-
-        for (VirAttr virAttr : virAttrs) {
-            attributeTO = new AttrTO();
-            attributeTO.setSchema(virAttr.getSchema().getKey());
-            attributeTO.getValues().addAll(virAttr.getValues());
-            attributeTO.setReadonly(virAttr.getSchema().isReadonly());
-
-            attributableTO.getVirAttrs().add(attributeTO);
-        }
-
-        if (attributableTO instanceof AbstractSubjectTO) {
-            for (ExternalResource resource : resources) {
-                ((AbstractSubjectTO) attributableTO).getResources().add(resource.getKey());
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/ConfigurationDataBinder.java
----------------------------------------------------------------------
diff --git a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/ConfigurationDataBinder.java b/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/ConfigurationDataBinder.java
deleted file mode 100644
index 64c4a4e..0000000
--- a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/ConfigurationDataBinder.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.logic.data;
-
-import java.util.Collections;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.to.AttrTO;
-import org.apache.syncope.common.lib.to.ConfTO;
-import org.apache.syncope.common.lib.types.AttributableType;
-import org.apache.syncope.common.lib.types.ClientExceptionType;
-import org.apache.syncope.persistence.api.dao.NotFoundException;
-import org.apache.syncope.persistence.api.entity.ExternalResource;
-import org.apache.syncope.persistence.api.entity.conf.CPlainAttr;
-import org.apache.syncope.persistence.api.entity.conf.CPlainSchema;
-import org.apache.syncope.persistence.api.entity.conf.Conf;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ConfigurationDataBinder extends AbstractAttributableDataBinder {
-
-    public ConfTO getConfTO(final Conf conf) {
-        final ConfTO confTO = new ConfTO();
-        confTO.setKey(conf.getKey());
-
-        fillTO(confTO, conf.getPlainAttrs(),
-                conf.getDerAttrs(), conf.getVirAttrs(), Collections.<ExternalResource>emptySet());
-
-        return confTO;
-    }
-
-    public AttrTO getAttrTO(final CPlainAttr attr) {
-        final AttrTO attributeTO = new AttrTO();
-        attributeTO.setSchema(attr.getSchema().getKey());
-        attributeTO.getValues().addAll(attr.getValuesAsStrings());
-        attributeTO.setReadonly(attr.getSchema().isReadonly());
-
-        return attributeTO;
-    }
-
-    public CPlainAttr getAttribute(final AttrTO attributeTO) {
-        CPlainSchema schema = getPlainSchema(attributeTO.getSchema(), CPlainSchema.class);
-        if (schema == null) {
-            throw new NotFoundException("Conf schema " + attributeTO.getSchema());
-        } else {
-            SyncopeClientException invalidValues = SyncopeClientException.build(ClientExceptionType.InvalidValues);
-
-            CPlainAttr attr = entityFactory.newEntity(CPlainAttr.class);
-            attr.setSchema(schema);
-            fillAttribute(attributeTO.getValues(), attrUtilFactory.getInstance(AttributableType.CONFIGURATION),
-                    schema, attr, invalidValues);
-
-            if (!invalidValues.isEmpty()) {
-                throw invalidValues;
-            }
-            return attr;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/ConnInstanceDataBinder.java
----------------------------------------------------------------------
diff --git a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/ConnInstanceDataBinder.java b/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/ConnInstanceDataBinder.java
deleted file mode 100644
index 1091be1..0000000
--- a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/ConnInstanceDataBinder.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.logic.data;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.to.ConnInstanceTO;
-import org.apache.syncope.common.lib.to.ConnPoolConfTO;
-import org.apache.syncope.common.lib.types.ClientExceptionType;
-import org.apache.syncope.common.lib.types.ConnConfPropSchema;
-import org.apache.syncope.common.lib.types.ConnConfProperty;
-import org.apache.syncope.persistence.api.dao.ConnInstanceDAO;
-import org.apache.syncope.persistence.api.entity.ConnInstance;
-import org.apache.syncope.persistence.api.entity.EntityFactory;
-import org.apache.syncope.provisioning.api.ConnIdBundleManager;
-import org.apache.syncope.provisioning.api.ConnPoolConfUtil;
-import org.identityconnectors.framework.api.ConfigurationProperties;
-import org.identityconnectors.framework.api.ConfigurationProperty;
-import org.identityconnectors.framework.impl.api.ConfigurationPropertyImpl;
-import org.apache.syncope.server.spring.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ConnInstanceDataBinder {
-
-    private static final String[] IGNORE_PROPERTIES = { "key", "poolConf" };
-
-    @Autowired
-    private ConnIdBundleManager connIdBundleManager;
-
-    @Autowired
-    private ConnInstanceDAO connInstanceDAO;
-
-    @Autowired
-    private EntityFactory entityFactory;
-
-    /**
-     * Merge connector configuration properties avoiding repetition but giving priority to primary set.
-     *
-     * @param primary primary set.
-     * @param secondary secondary set.
-     * @return merged set.
-     */
-    public Set<ConnConfProperty> mergeConnConfProperties(final Set<ConnConfProperty> primary,
-            final Set<ConnConfProperty> secondary) {
-
-        final Set<ConnConfProperty> conf = new HashSet<>();
-
-        // to be used to control managed prop (needed by overridden mechanism)
-        final Set<String> propertyNames = new HashSet<>();
-
-        // get overridden connector configuration properties
-        for (ConnConfProperty prop : primary) {
-            if (!propertyNames.contains(prop.getSchema().getName())) {
-                conf.add(prop);
-                propertyNames.add(prop.getSchema().getName());
-            }
-        }
-
-        // get connector configuration properties
-        for (ConnConfProperty prop : secondary) {
-            if (!propertyNames.contains(prop.getSchema().getName())) {
-                conf.add(prop);
-                propertyNames.add(prop.getSchema().getName());
-            }
-        }
-
-        return conf;
-    }
-
-    public ConnInstance getConnInstance(final ConnInstanceTO connInstanceTO) {
-        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
-
-        if (connInstanceTO.getLocation() == null) {
-            sce.getElements().add("location");
-        }
-
-        if (connInstanceTO.getBundleName() == null) {
-            sce.getElements().add("bundlename");
-        }
-
-        if (connInstanceTO.getVersion() == null) {
-            sce.getElements().add("bundleversion");
-        }
-
-        if (connInstanceTO.getConnectorName() == null) {
-            sce.getElements().add("connectorname");
-        }
-
-        if (connInstanceTO.getConfiguration() == null || connInstanceTO.getConfiguration().isEmpty()) {
-            sce.getElements().add("configuration");
-        }
-
-        ConnInstance connInstance = entityFactory.newEntity(ConnInstance.class);
-
-        BeanUtils.copyProperties(connInstanceTO, connInstance, IGNORE_PROPERTIES);
-        if (connInstanceTO.getLocation() != null) {
-            connInstance.setLocation(connInstanceTO.getLocation());
-        }
-        if (connInstanceTO.getPoolConf() != null) {
-            connInstance.setPoolConf(
-                    ConnPoolConfUtil.getConnPoolConf(connInstanceTO.getPoolConf(), entityFactory.newConnPoolConf()));
-        }
-
-        // Throw exception if there is at least one element set
-        if (!sce.isEmpty()) {
-            throw sce;
-        }
-
-        return connInstance;
-    }
-
-    public ConnInstance updateConnInstance(final long connInstanceId, final ConnInstanceTO connInstanceTO) {
-        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
-
-        if (connInstanceId == 0) {
-            sce.getElements().add("connector id");
-        }
-
-        ConnInstance connInstance = connInstanceDAO.find(connInstanceId);
-        connInstance.getCapabilities().clear();
-        connInstance.getCapabilities().addAll(connInstanceTO.getCapabilities());
-
-        if (connInstanceTO.getLocation() != null) {
-            connInstance.setLocation(connInstanceTO.getLocation());
-        }
-
-        if (connInstanceTO.getBundleName() != null) {
-            connInstance.setBundleName(connInstanceTO.getBundleName());
-        }
-
-        if (connInstanceTO.getVersion() != null) {
-            connInstance.setVersion(connInstanceTO.getVersion());
-        }
-
-        if (connInstanceTO.getConnectorName() != null) {
-            connInstance.setConnectorName(connInstanceTO.getConnectorName());
-        }
-
-        if (connInstanceTO.getConfiguration() != null && !connInstanceTO.getConfiguration().isEmpty()) {
-            connInstance.setConfiguration(connInstanceTO.getConfiguration());
-        }
-
-        if (connInstanceTO.getDisplayName() != null) {
-            connInstance.setDisplayName(connInstanceTO.getDisplayName());
-        }
-
-        if (connInstanceTO.getConnRequestTimeout() != null) {
-            connInstance.setConnRequestTimeout(connInstanceTO.getConnRequestTimeout());
-        }
-
-        if (connInstanceTO.getPoolConf() == null) {
-            connInstance.setPoolConf(null);
-        } else {
-            connInstance.setPoolConf(
-                    ConnPoolConfUtil.getConnPoolConf(connInstanceTO.getPoolConf(), entityFactory.newConnPoolConf()));
-        }
-
-        if (!sce.isEmpty()) {
-            throw sce;
-        }
-
-        return connInstance;
-    }
-
-    public ConnConfPropSchema buildConnConfPropSchema(final ConfigurationProperty property) {
-        ConnConfPropSchema connConfPropSchema = new ConnConfPropSchema();
-
-        connConfPropSchema.setName(property.getName());
-        connConfPropSchema.setDisplayName(property.getDisplayName(property.getName()));
-        connConfPropSchema.setHelpMessage(property.getHelpMessage(property.getName()));
-        connConfPropSchema.setRequired(property.isRequired());
-        connConfPropSchema.setType(property.getType().getName());
-        connConfPropSchema.setOrder(((ConfigurationPropertyImpl) property).getOrder());
-        connConfPropSchema.setConfidential(property.isConfidential());
-
-        if (property.getValue() != null) {
-            if (property.getValue().getClass().isArray()) {
-                connConfPropSchema.getDefaultValues().addAll(Arrays.asList((Object[]) property.getValue()));
-            } else if (property.getValue() instanceof Collection<?>) {
-                connConfPropSchema.getDefaultValues().addAll((Collection<?>) property.getValue());
-            } else {
-                connConfPropSchema.getDefaultValues().add(property.getValue());
-            }
-        }
-
-        return connConfPropSchema;
-    }
-
-    public ConnInstanceTO getConnInstanceTO(final ConnInstance connInstance) {
-        ConnInstanceTO connInstanceTO = new ConnInstanceTO();
-        connInstanceTO.setKey(connInstance.getKey() == null ? 0L : connInstance.getKey());
-
-        // retrieve the ConfigurationProperties
-        ConfigurationProperties properties = connIdBundleManager.getConfigurationProperties(
-                connIdBundleManager.getConnectorInfo(connInstance.getLocation(),
-                        connInstance.getBundleName(), connInstance.getVersion(), connInstance.getConnectorName()));
-
-        BeanUtils.copyProperties(connInstance, connInstanceTO, IGNORE_PROPERTIES);
-
-        final Map<String, ConnConfProperty> connInstanceToConfMap = connInstanceTO.getConfigurationMap();
-
-        for (String propName : properties.getPropertyNames()) {
-            ConnConfPropSchema schema = buildConnConfPropSchema(properties.getProperty(propName));
-
-            ConnConfProperty property;
-            if (connInstanceToConfMap.containsKey(propName)) {
-                property = connInstanceToConfMap.get(propName);
-            } else {
-                property = new ConnConfProperty();
-                connInstanceTO.getConfiguration().add(property);
-            }
-
-            property.setSchema(schema);
-        }
-
-        if (connInstance.getPoolConf() != null) {
-            ConnPoolConfTO poolConf = new ConnPoolConfTO();
-            BeanUtils.copyProperties(connInstance.getPoolConf(), poolConf);
-            connInstanceTO.setPoolConf(poolConf);
-        }
-
-        return connInstanceTO;
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/NotificationDataBinder.java
----------------------------------------------------------------------
diff --git a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/NotificationDataBinder.java b/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/NotificationDataBinder.java
deleted file mode 100644
index 0ddb74e..0000000
--- a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/NotificationDataBinder.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.logic.data;
-
-import org.apache.syncope.common.lib.to.NotificationTO;
-import org.apache.syncope.persistence.api.entity.EntityFactory;
-import org.apache.syncope.persistence.api.entity.Notification;
-import org.apache.syncope.server.spring.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class NotificationDataBinder {
-
-    private static final String[] IGNORE_PROPERTIES = { "key", "about", "recipients" };
-
-    @Autowired
-    private EntityFactory entityFactory;
-
-    public NotificationTO getNotificationTO(final Notification notification) {
-        NotificationTO result = new NotificationTO();
-
-        BeanUtils.copyProperties(notification, result, IGNORE_PROPERTIES);
-
-        result.setKey(notification.getKey());
-        result.setUserAbout(notification.getUserAbout());
-        result.setRoleAbout(notification.getRoleAbout());
-        result.setRecipients(notification.getRecipients());
-
-        return result;
-    }
-
-    public Notification create(final NotificationTO notificationTO) {
-        Notification result = entityFactory.newEntity(Notification.class);
-        update(result, notificationTO);
-        return result;
-    }
-
-    public void update(final Notification notification, final NotificationTO notificationTO) {
-        BeanUtils.copyProperties(notificationTO, notification, IGNORE_PROPERTIES);
-
-        notification.setUserAbout(notificationTO.getUserAbout());
-        notification.setRoleAbout(notificationTO.getRoleAbout());
-        notification.setRecipients(notificationTO.getRecipients());
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/PolicyDataBinder.java
----------------------------------------------------------------------
diff --git a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/PolicyDataBinder.java b/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/PolicyDataBinder.java
deleted file mode 100644
index 57877d2..0000000
--- a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/PolicyDataBinder.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.logic.data;
-
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.to.AbstractPolicyTO;
-import org.apache.syncope.common.lib.to.AccountPolicyTO;
-import org.apache.syncope.common.lib.to.PasswordPolicyTO;
-import org.apache.syncope.common.lib.to.SyncPolicyTO;
-import org.apache.syncope.common.lib.types.AccountPolicySpec;
-import org.apache.syncope.common.lib.types.ClientExceptionType;
-import org.apache.syncope.common.lib.types.PasswordPolicySpec;
-import org.apache.syncope.common.lib.types.SyncPolicySpec;
-import org.apache.syncope.persistence.api.dao.ExternalResourceDAO;
-import org.apache.syncope.persistence.api.dao.RoleDAO;
-import org.apache.syncope.persistence.api.entity.AccountPolicy;
-import org.apache.syncope.persistence.api.entity.EntityFactory;
-import org.apache.syncope.persistence.api.entity.ExternalResource;
-import org.apache.syncope.persistence.api.entity.PasswordPolicy;
-import org.apache.syncope.persistence.api.entity.Policy;
-import org.apache.syncope.persistence.api.entity.SyncPolicy;
-import org.apache.syncope.persistence.api.entity.role.Role;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class PolicyDataBinder {
-
-    /**
-     * Logger.
-     */
-    protected static final Logger LOG = LoggerFactory.getLogger(PolicyDataBinder.class);
-
-    @Autowired
-    private ExternalResourceDAO resourceDAO;
-
-    @Autowired
-    private RoleDAO roleDAO;
-
-    @Autowired
-    private EntityFactory entityFactory;
-
-    /**
-     * Get policy TO from policy bean.
-     *
-     * @param policy bean.
-     * @return policy TO.
-     */
-    @SuppressWarnings("unchecked")
-    public <T extends AbstractPolicyTO> T getPolicyTO(final Policy policy) {
-        final T policyTO;
-
-        switch (policy.getType()) {
-            case GLOBAL_PASSWORD:
-            case PASSWORD:
-                policyTO = (T) new PasswordPolicyTO(policy.getType().isGlobal());
-                ((PasswordPolicyTO) policyTO).setSpecification(policy.getSpecification(PasswordPolicySpec.class));
-                break;
-
-            case GLOBAL_ACCOUNT:
-            case ACCOUNT:
-                policyTO = (T) new AccountPolicyTO(policy.getType().isGlobal());
-                ((AccountPolicyTO) policyTO).setSpecification(policy.getSpecification(AccountPolicySpec.class));
-                ((AccountPolicyTO) policyTO).getResources().addAll(((AccountPolicy) policy).getResourceNames());
-                break;
-
-            case GLOBAL_SYNC:
-            case SYNC:
-            default:
-                policyTO = (T) new SyncPolicyTO(policy.getType().isGlobal());
-                ((SyncPolicyTO) policyTO).setSpecification(policy.getSpecification(SyncPolicySpec.class));
-        }
-
-        policyTO.setId(policy.getKey());
-        policyTO.setDescription(policy.getDescription());
-
-        for (ExternalResource resource : resourceDAO.findByPolicy(policy)) {
-            policyTO.getUsedByResources().add(resource.getKey());
-        }
-        if (policy.getType().isGlobal()) {
-            for (ExternalResource resource : resourceDAO.findWithoutPolicy(policy.getType())) {
-                policyTO.getUsedByResources().add(resource.getKey());
-            }
-        }
-        for (Role role : roleDAO.findByPolicy(policy)) {
-            policyTO.getUsedByRoles().add(role.getKey());
-        }
-        if (policy.getType().isGlobal()) {
-            for (Role role : roleDAO.findWithoutPolicy(policy.getType())) {
-                policyTO.getUsedByRoles().add(role.getKey());
-            }
-        }
-
-        return policyTO;
-    }
-
-    private ExternalResource getResource(final String resourceName) {
-        ExternalResource resource = resourceDAO.find(resourceName);
-        if (resource == null) {
-            LOG.debug("Ignoring invalid resource {} ", resourceName);
-        }
-
-        return resource;
-    }
-
-    @SuppressWarnings("unchecked")
-    public <T extends Policy> T getPolicy(T policy, final AbstractPolicyTO policyTO) {
-        if (policy != null && policy.getType() != policyTO.getType()) {
-            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPolicy);
-            sce.getElements().add(String.format("Cannot update %s from %s", policy.getType(), policyTO.getType()));
-            throw sce;
-        }
-
-        switch (policyTO.getType()) {
-            case GLOBAL_PASSWORD:
-            case PASSWORD:
-                if (!(policyTO instanceof PasswordPolicyTO)) {
-                    throw new ClassCastException("Expected " + PasswordPolicyTO.class.getName()
-                            + ", found " + policyTO.getClass().getName());
-                }
-                if (policy == null) {
-                    policy = (T) entityFactory.newPolicy(PasswordPolicy.class, policyTO.getType().isGlobal());
-                }
-                policy.setSpecification(((PasswordPolicyTO) policyTO).getSpecification());
-                break;
-
-            case GLOBAL_ACCOUNT:
-            case ACCOUNT:
-                if (!(policyTO instanceof AccountPolicyTO)) {
-                    throw new ClassCastException("Expected " + AccountPolicyTO.class.getName()
-                            + ", found " + policyTO.getClass().getName());
-                }
-                if (policy == null) {
-                    policy = (T) entityFactory.newPolicy(AccountPolicy.class, policyTO.getType().isGlobal());
-                }
-                policy.setSpecification(((AccountPolicyTO) policyTO).getSpecification());
-
-                if (((AccountPolicy) policy).getResources() != null
-                        && !((AccountPolicy) policy).getResources().isEmpty()) {
-                    ((AccountPolicy) policy).getResources().clear();
-                }
-                for (String resourceName : ((AccountPolicyTO) policyTO).getResources()) {
-                    ExternalResource resource = getResource(resourceName);
-
-                    if (resource != null) {
-                        ((AccountPolicy) policy).addResource(resource);
-                    }
-                }
-                break;
-
-            case GLOBAL_SYNC:
-            case SYNC:
-            default:
-                if (!(policyTO instanceof SyncPolicyTO)) {
-                    throw new ClassCastException("Expected " + SyncPolicyTO.class.getName()
-                            + ", found " + policyTO.getClass().getName());
-                }
-                if (policy == null) {
-                    policy = (T) entityFactory.newPolicy(SyncPolicy.class, policyTO.getType().isGlobal());
-                }
-                policy.setSpecification(((SyncPolicyTO) policyTO).getSpecification());
-        }
-
-        policy.setDescription(policyTO.getDescription());
-
-        return policy;
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/ReportDataBinder.java
----------------------------------------------------------------------
diff --git a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/ReportDataBinder.java b/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/ReportDataBinder.java
deleted file mode 100644
index 952de94..0000000
--- a/syncope620/server/logic/src/main/java/org/apache/syncope/server/logic/data/ReportDataBinder.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.logic.data;
-
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.syncope.common.lib.report.AbstractReportletConf;
-import org.apache.syncope.common.lib.report.ReportletConf;
-import org.apache.syncope.common.lib.to.ReportExecTO;
-import org.apache.syncope.common.lib.to.ReportTO;
-import org.apache.syncope.persistence.api.dao.ReportExecDAO;
-import org.apache.syncope.persistence.api.entity.Report;
-import org.apache.syncope.persistence.api.entity.ReportExec;
-import org.apache.syncope.server.logic.init.ImplementationClassNamesLoader;
-import org.apache.syncope.server.logic.report.Reportlet;
-import org.apache.syncope.server.logic.init.JobInstanceLoader;
-import org.apache.syncope.server.logic.report.ReportletConfClass;
-import org.apache.syncope.server.spring.BeanUtils;
-import org.quartz.Scheduler;
-import org.quartz.SchedulerException;
-import org.quartz.Trigger;
-import org.quartz.TriggerKey;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.quartz.SchedulerFactoryBean;
-import org.springframework.stereotype.Component;
-import org.springframework.util.ClassUtils;
-
-@Component
-public class ReportDataBinder {
-
-    /**
-     * Logger.
-     */
-    private static final Logger LOG = LoggerFactory.getLogger(ReportDataBinder.class);
-
-    private static final String[] IGNORE_REPORT_PROPERTIES = { "key", "reportlets", "executions" };
-
-    private static final String[] IGNORE_REPORT_EXECUTION_PROPERTIES = { "key", "report", "execResult" };
-
-    @Autowired
-    private ReportExecDAO reportExecDAO;
-
-    @Autowired
-    private SchedulerFactoryBean scheduler;
-
-    @Autowired
-    private ImplementationClassNamesLoader classNamesLoader;
-
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    public Set<Class<Reportlet>> getAllReportletClasses() {
-        Set<Class<Reportlet>> reportletClasses = new HashSet<Class<Reportlet>>();
-
-        for (String className : classNamesLoader.getClassNames(ImplementationClassNamesLoader.Type.REPORTLET)) {
-            try {
-                Class reportletClass = ClassUtils.forName(className, ClassUtils.getDefaultClassLoader());
-                reportletClasses.add(reportletClass);
-            } catch (ClassNotFoundException e) {
-                LOG.warn("Could not load class {}", className);
-            } catch (LinkageError e) {
-                LOG.warn("Could not link class {}", className);
-            }
-        }
-        return reportletClasses;
-    }
-
-    public Class<? extends ReportletConf> getReportletConfClass(final Class<Reportlet> reportletClass) {
-        Class<? extends ReportletConf> result = null;
-
-        ReportletConfClass annotation = reportletClass.getAnnotation(ReportletConfClass.class);
-        if (annotation != null) {
-            result = annotation.value();
-        }
-
-        return result;
-    }
-
-    public Class<Reportlet> findReportletClassHavingConfClass(final Class<? extends ReportletConf> reportletConfClass) {
-        Class<Reportlet> result = null;
-        for (Class<Reportlet> reportletClass : getAllReportletClasses()) {
-            Class<? extends ReportletConf> found = getReportletConfClass(reportletClass);
-            if (found != null && found.equals(reportletConfClass)) {
-                result = reportletClass;
-            }
-        }
-
-        return result;
-    }
-
-    public void getReport(final Report report, final ReportTO reportTO) {
-        BeanUtils.copyProperties(reportTO, report, IGNORE_REPORT_PROPERTIES);
-        report.getReportletConfs().clear();
-        for (ReportletConf conf : reportTO.getReportletConfs()) {
-            report.addReportletConf(conf);
-        }
-    }
-
-    public ReportTO getReportTO(final Report report) {
-        ReportTO reportTO = new ReportTO();
-        reportTO.setId(report.getKey());
-        BeanUtils.copyProperties(report, reportTO, IGNORE_REPORT_PROPERTIES);
-
-        copyReportletConfs(report, reportTO);
-
-        ReportExec latestExec = reportExecDAO.findLatestStarted(report);
-        reportTO.setLatestExecStatus(latestExec == null
-                ? ""
-                : latestExec.getStatus());
-
-        reportTO.setStartDate(latestExec == null
-                ? null
-                : latestExec.getStartDate());
-
-        reportTO.setEndDate(latestExec == null
-                ? null
-                : latestExec.getEndDate());
-
-        for (ReportExec reportExec : report.getExecs()) {
-            reportTO.getExecutions().add(getReportExecTO(reportExec));
-        }
-
-        String triggerName = JobInstanceLoader.getTriggerName(JobInstanceLoader.getJobName(report));
-
-        Trigger trigger;
-        try {
-            trigger = scheduler.getScheduler().getTrigger(new TriggerKey(triggerName, Scheduler.DEFAULT_GROUP));
-        } catch (SchedulerException e) {
-            LOG.warn("While trying to get to " + triggerName, e);
-            trigger = null;
-        }
-
-        if (trigger != null) {
-            reportTO.setLastExec(trigger.getPreviousFireTime());
-            reportTO.setNextExec(trigger.getNextFireTime());
-        }
-
-        return reportTO;
-    }
-
-    private void copyReportletConfs(final Report report, final ReportTO reportTO) {
-        reportTO.getReportletConfs().clear();
-        for (ReportletConf reportletConf : report.getReportletConfs()) {
-            reportTO.getReportletConfs().add((AbstractReportletConf) reportletConf);
-        }
-    }
-
-    public ReportExecTO getReportExecTO(final ReportExec execution) {
-        ReportExecTO executionTO = new ReportExecTO();
-        executionTO.setKey(execution.getKey());
-        BeanUtils.copyProperties(execution, executionTO, IGNORE_REPORT_EXECUTION_PROPERTIES);
-        if (execution.getKey() != null) {
-            executionTO.setKey(execution.getKey());
-        }
-        executionTO.setReport(execution.getReport().getKey());
-
-        return executionTO;
-    }
-}


Mime
View raw message