syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [07/17] syncope git commit: Further refactoring as per SYNCOPE-620
Date Wed, 09 Mar 2016 11:52:43 GMT
http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/LDAPMembershipSyncActions.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/LDAPMembershipSyncActions.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/LDAPMembershipSyncActions.java
deleted file mode 100644
index 9c6294a..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/LDAPMembershipSyncActions.java
+++ /dev/null
@@ -1,335 +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.core.provisioning.java.sync;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.collections4.IterableUtils;
-import org.apache.commons.collections4.Predicate;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.syncope.common.lib.patch.AnyPatch;
-import org.apache.syncope.common.lib.patch.MembershipPatch;
-import org.apache.syncope.common.lib.patch.UserPatch;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.common.lib.to.GroupTO;
-import org.apache.syncope.common.lib.to.MembershipTO;
-import org.apache.syncope.common.lib.types.AuditElements;
-import org.apache.syncope.common.lib.types.AuditElements.Result;
-import org.apache.syncope.common.lib.types.ConnConfProperty;
-import org.apache.syncope.common.lib.types.PatchOperation;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
-import org.apache.syncope.core.persistence.api.entity.task.ProvisioningTask;
-import org.apache.syncope.core.persistence.api.entity.task.SyncTask;
-import org.apache.syncope.core.provisioning.api.Connector;
-import org.apache.syncope.core.provisioning.api.WorkflowResult;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationException;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationManager;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskExecutor;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningProfile;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningReport;
-import org.apache.syncope.core.misc.AuditManager;
-import org.apache.syncope.core.persistence.api.dao.AnyTypeDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
-import org.apache.syncope.core.persistence.api.entity.user.UMembership;
-import org.apache.syncope.core.provisioning.api.notification.NotificationManager;
-import org.apache.syncope.core.workflow.api.UserWorkflowAdapter;
-import org.identityconnectors.framework.common.objects.Attribute;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
-import org.identityconnectors.framework.common.objects.SyncDelta;
-import org.quartz.JobExecutionException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * Simple action for synchronizing LDAP groups memberships to Syncope group memberships, when the same resource is
- * configured for both users and groups.
- *
- * @see org.apache.syncope.core.provisioning.java.propagation.LDAPMembershipPropagationActions
- */
-public class LDAPMembershipSyncActions extends DefaultSyncActions {
-
-    protected static final Logger LOG = LoggerFactory.getLogger(LDAPMembershipSyncActions.class);
-
-    @Autowired
-    protected AnyTypeDAO anyTypeDAO;
-
-    @Autowired
-    protected UserDAO userDAO;
-
-    @Autowired
-    protected GroupDAO groupDAO;
-
-    @Autowired
-    protected UserWorkflowAdapter uwfAdapter;
-
-    @Autowired
-    protected PropagationManager propagationManager;
-
-    @Autowired
-    private PropagationTaskExecutor taskExecutor;
-
-    @Autowired
-    private NotificationManager notificationManager;
-
-    @Autowired
-    private AuditManager auditManager;
-
-    @Autowired
-    private SyncUtils syncUtils;
-
-    protected Map<Long, Long> membersBeforeGroupUpdate = Collections.<Long, Long>emptyMap();
-
-    /**
-     * Allows easy subclassing for the ConnId AD connector bundle.
-     *
-     * @param connector A Connector instance to query for the groupMemberAttribute property name
-     * @return the name of the attribute used to keep track of group memberships
-     */
-    protected String getGroupMembershipAttrName(final Connector connector) {
-        ConnConfProperty groupMembership = IterableUtils.find(connector.getConnInstance().getConf(),
-                new Predicate<ConnConfProperty>() {
-
-                    @Override
-                    public boolean evaluate(final ConnConfProperty property) {
-                        return "groupMemberAttribute".equals(property.getSchema().getName())
-                        && property.getValues() != null && !property.getValues().isEmpty();
-                    }
-                });
-
-        return groupMembership == null
-                ? "uniquemember"
-                : (String) groupMembership.getValues().get(0);
-    }
-
-    /**
-     * Keep track of members of the group being updated <b>before</b> actual update takes place. This is not needed on
-     * <ul> <li>beforeProvision() - because the synchronizing group does not exist yet on Syncope</li>
-     * <li>beforeDelete() - because group delete cascades as membership removal for all users involved</li> </ul>
-     *
-     * {@inheritDoc}
-     */
-    @Override
-    public <A extends AnyTO, M extends AnyPatch> SyncDelta beforeUpdate(
-            final ProvisioningProfile<?, ?> profile,
-            final SyncDelta delta, final A any, final M anyPatch) throws JobExecutionException {
-
-        if (any instanceof GroupTO) {
-            // search for all users assigned to given group
-            Group group = groupDAO.find(any.getKey());
-            if (group != null) {
-                List<UMembership> membs = groupDAO.findUMemberships(group);
-                // save memberships before group update takes place
-                membersBeforeGroupUpdate = new HashMap<>(membs.size());
-                for (UMembership memb : membs) {
-                    membersBeforeGroupUpdate.put(memb.getLeftEnd().getKey(), memb.getKey());
-                }
-            }
-        }
-
-        return super.beforeUpdate(profile, delta, any, anyPatch);
-    }
-
-    /**
-     * Build UserPatch for adding membership to given user, for given group.
-     *
-     * @param userKey user to be assigned membership to given group
-     * @param groupTO group for adding membership
-     * @return UserPatch for user update
-     */
-    protected UserPatch getUserPatch(final Long userKey, final GroupTO groupTO) {
-        UserPatch userPatch = new UserPatch();
-        // no actual modification takes place when user has already the group assigned
-        if (membersBeforeGroupUpdate.containsKey(userKey)) {
-            membersBeforeGroupUpdate.remove(userKey);
-        } else {
-            userPatch.setKey(userKey);
-
-            userPatch.getMemberships().add(
-                    new MembershipPatch.Builder().
-                    operation(PatchOperation.ADD_REPLACE).
-                    membershipTO(new MembershipTO.Builder().group(groupTO.getKey(), null).build()).
-                    build());
-        }
-
-        return userPatch;
-    }
-
-    /**
-     * Read values of attribute returned by getGroupMembershipAttrName(); if not present in the given delta, perform an
-     * additional read on the underlying connector.
-     *
-     * @param delta representing the synchronizing group
-     * @param connector associated to the current resource
-     * @return value of attribute returned by
-     * {@link #getGroupMembershipAttrName}
-     */
-    protected List<Object> getMembAttrValues(final SyncDelta delta, final Connector connector) {
-        List<Object> result = Collections.<Object>emptyList();
-        String groupMemberName = getGroupMembershipAttrName(connector);
-
-        // first, try to read the configured attribute from delta, returned by the ongoing synchronization
-        Attribute membAttr = delta.getObject().getAttributeByName(groupMemberName);
-        // if not found, perform an additional read on the underlying connector for the same connector object
-        if (membAttr == null) {
-            OperationOptionsBuilder oob = new OperationOptionsBuilder();
-            oob.setAttributesToGet(groupMemberName);
-            ConnectorObject remoteObj = connector.getObject(ObjectClass.GROUP, delta.getUid(), oob.build());
-            if (remoteObj == null) {
-                LOG.debug("Object for '{}' not found", delta.getUid().getUidValue());
-            } else {
-                membAttr = remoteObj.getAttributeByName(groupMemberName);
-            }
-        }
-        if (membAttr != null && membAttr.getValue() != null) {
-            result = membAttr.getValue();
-        }
-
-        return result;
-    }
-
-    /**
-     * Perform actual modifications (i.e. membership add / remove) for the given group on the given resource.
-     *
-     * @param userPatch modifications to perform on the user
-     * @param resourceName resource to be propagated for changes
-     */
-    protected void userUpdate(final UserPatch userPatch, final String resourceName) {
-        if (userPatch.getKey() == 0) {
-            return;
-        }
-
-        Result result;
-
-        WorkflowResult<Pair<UserPatch, Boolean>> updated = null;
-
-        try {
-            updated = uwfAdapter.update(userPatch);
-
-            List<PropagationTask> tasks = propagationManager.getUserUpdateTasks(
-                    updated, false, Collections.singleton(resourceName));
-
-            taskExecutor.execute(tasks);
-            result = Result.SUCCESS;
-        } catch (PropagationException e) {
-            result = Result.FAILURE;
-            LOG.error("Could not propagate {}", userPatch, e);
-        } catch (Exception e) {
-            result = Result.FAILURE;
-            LOG.error("Could not perform update {}", userPatch, e);
-        }
-
-        notificationManager.createTasks(
-                AuditElements.EventCategoryType.SYNCHRONIZATION,
-                this.getClass().getSimpleName(),
-                null,
-                "update",
-                result,
-                null, // searching for before object is too much expensive ... 
-                updated == null ? null : updated.getResult().getKey(),
-                userPatch,
-                resourceName);
-
-        auditManager.audit(
-                AuditElements.EventCategoryType.SYNCHRONIZATION,
-                this.getClass().getSimpleName(),
-                null,
-                "update",
-                result,
-                null, // searching for before object is too much expensive ... 
-                updated == null ? null : updated.getResult().getKey(),
-                userPatch,
-                resourceName);
-    }
-
-    /**
-     * Synchronize Syncope memberships with the situation read on the external resource's group.
-     *
-     * @param profile sync profile
-     * @param delta representing the synchronizing group
-     * @param groupTO group after modification performed by the handler
-     * @throws JobExecutionException if anything goes wrong
-     */
-    protected void synchronizeMemberships(
-            final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final GroupTO groupTO)
-            throws JobExecutionException {
-
-        ProvisioningTask task = profile.getTask();
-        ExternalResource resource = task.getResource();
-        Connector connector = profile.getConnector();
-
-        for (Object membValue : getMembAttrValues(delta, connector)) {
-            Long userKey = syncUtils.findMatchingAnyKey(
-                    anyTypeDAO.findUser(),
-                    membValue.toString(),
-                    profile.getTask().getResource(),
-                    profile.getConnector());
-            if (userKey != null) {
-                UserPatch userPatch = getUserPatch(userKey, groupTO);
-                userUpdate(userPatch, resource.getKey());
-            }
-        }
-
-        // finally remove any residual membership that was present before group update but not any more
-        for (Map.Entry<Long, Long> member : membersBeforeGroupUpdate.entrySet()) {
-            UserPatch userPatch = new UserPatch();
-            userPatch.setKey(member.getKey());
-
-            userPatch.getMemberships().add(
-                    new MembershipPatch.Builder().
-                    operation(PatchOperation.DELETE).
-                    membershipTO(new MembershipTO.Builder().group(groupTO.getKey(), null).build()).
-                    build());
-
-            userUpdate(userPatch, resource.getKey());
-        }
-    }
-
-    /**
-     * Synchronize membership at group synchronization time (because SyncJob first synchronize users then groups).
-     * {@inheritDoc}
-     */
-    @Override
-    public <A extends AnyTO> void after(
-            final ProvisioningProfile<?, ?> profile,
-            final SyncDelta delta,
-            final A any,
-            final ProvisioningReport result) throws JobExecutionException {
-
-        if (!(profile.getTask() instanceof SyncTask)) {
-            return;
-        }
-
-        if (!(any instanceof GroupTO)
-                || profile.getTask().getResource().getProvision(anyTypeDAO.findUser()) == null
-                || profile.getTask().getResource().getProvision(anyTypeDAO.findUser()).getMapping() == null) {
-
-            super.after(profile, delta, any, result);
-        } else {
-            synchronizeMemberships(profile, delta, (GroupTO) any);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/LDAPPasswordSyncActions.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/LDAPPasswordSyncActions.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/LDAPPasswordSyncActions.java
deleted file mode 100644
index 3f08704..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/LDAPPasswordSyncActions.java
+++ /dev/null
@@ -1,124 +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.core.provisioning.java.sync;
-
-import org.apache.syncope.common.lib.patch.AnyPatch;
-import org.apache.syncope.common.lib.patch.PasswordPatch;
-import org.apache.syncope.common.lib.patch.UserPatch;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.common.lib.types.CipherAlgorithm;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningProfile;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningReport;
-import org.identityconnectors.framework.common.objects.SyncDelta;
-import org.quartz.JobExecutionException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.crypto.codec.Base64;
-import org.springframework.security.crypto.codec.Hex;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * A SyncActions implementation which allows the ability to import passwords from an LDAP backend
- * that are hashed.
- */
-public class LDAPPasswordSyncActions extends DefaultSyncActions {
-
-    protected static final Logger LOG = LoggerFactory.getLogger(LDAPPasswordSyncActions.class);
-
-    @Autowired
-    private UserDAO userDAO;
-
-    private String encodedPassword;
-
-    private CipherAlgorithm cipher;
-
-    @Transactional(readOnly = true)
-    @Override
-    public <A extends AnyTO> SyncDelta beforeProvision(
-            final ProvisioningProfile<?, ?> profile,
-            final SyncDelta delta,
-            final A any) throws JobExecutionException {
-
-        if (any instanceof UserTO) {
-            String password = ((UserTO) any).getPassword();
-            parseEncodedPassword(password);
-        }
-
-        return delta;
-    }
-
-    @Transactional(readOnly = true)
-    @Override
-    public <A extends AnyTO, M extends AnyPatch> SyncDelta beforeUpdate(
-            final ProvisioningProfile<?, ?> profile,
-            final SyncDelta delta,
-            final A any,
-            final M anyPatch) throws JobExecutionException {
-
-        if (anyPatch instanceof UserPatch) {
-            PasswordPatch modPassword = ((UserPatch) anyPatch).getPassword();
-            parseEncodedPassword(modPassword == null ? null : modPassword.getValue());
-        }
-
-        return delta;
-    }
-
-    private void parseEncodedPassword(final String password) {
-        if (password != null && password.startsWith("{")) {
-            int closingBracketIndex = password.indexOf('}');
-            String digest = password.substring(1, password.indexOf('}'));
-            if (digest != null) {
-                digest = digest.toUpperCase();
-            }
-            try {
-                encodedPassword = password.substring(closingBracketIndex + 1);
-                cipher = CipherAlgorithm.valueOf(digest);
-            } catch (IllegalArgumentException e) {
-                LOG.error("Cipher algorithm not allowed: {}", digest, e);
-                encodedPassword = null;
-            }
-        }
-    }
-
-    @Transactional(readOnly = true)
-    @Override
-    public <A extends AnyTO> void after(
-            final ProvisioningProfile<?, ?> profile,
-            final SyncDelta delta,
-            final A any,
-            final ProvisioningReport result) throws JobExecutionException {
-
-        if (any instanceof UserTO && encodedPassword != null && cipher != null) {
-            User syncopeUser = userDAO.find(any.getKey());
-            if (syncopeUser != null) {
-                byte[] encodedPasswordBytes = Base64.decode(encodedPassword.getBytes());
-                char[] encodedHex = Hex.encode(encodedPasswordBytes);
-                String encodedHexStr = new String(encodedHex).toUpperCase();
-
-                syncopeUser.setEncodedPassword(encodedHexStr, cipher);
-            }
-            encodedPassword = null;
-            cipher = null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PlainAttrsSyncCorrelationRule.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PlainAttrsSyncCorrelationRule.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PlainAttrsSyncCorrelationRule.java
deleted file mode 100644
index 14ba28e..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PlainAttrsSyncCorrelationRule.java
+++ /dev/null
@@ -1,115 +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.core.provisioning.java.sync;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.syncope.core.misc.utils.MappingUtils;
-import org.apache.syncope.core.persistence.api.dao.search.AnyCond;
-import org.apache.syncope.core.persistence.api.dao.search.AttributeCond;
-import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
-import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
-import org.apache.syncope.core.persistence.api.entity.resource.Provision;
-import org.apache.syncope.core.provisioning.api.data.MappingItemTransformer;
-import org.apache.syncope.core.provisioning.api.sync.SyncCorrelationRule;
-import org.identityconnectors.framework.common.objects.Attribute;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
-
-public class PlainAttrsSyncCorrelationRule implements SyncCorrelationRule {
-
-    private final List<String> plainSchemaNames;
-
-    private final Provision provision;
-
-    public PlainAttrsSyncCorrelationRule(final String[] plainSchemaNames, final Provision provision) {
-        this.plainSchemaNames = Arrays.asList(plainSchemaNames);
-        this.provision = provision;
-    }
-
-    @Override
-    public SearchCond getSearchCond(final ConnectorObject connObj) {
-        Map<String, MappingItem> mappingItems = new HashMap<>();
-        for (MappingItem item : MappingUtils.getSyncMappingItems(provision)) {
-            mappingItems.put(item.getIntAttrName(), item);
-        }
-
-        // search for anys by attribute(s) specified in the policy
-        SearchCond searchCond = null;
-
-        for (String schema : plainSchemaNames) {
-            Attribute attr = mappingItems.get(schema) == null
-                    ? null
-                    : connObj.getAttributeByName(mappingItems.get(schema).getExtAttrName());
-            if (attr == null) {
-                throw new IllegalArgumentException(
-                        "Connector object does not contains the attributes to perform the search: " + schema);
-            }
-
-            List<Object> values = attr.getValue();
-            for (MappingItemTransformer transformer
-                    : MappingUtils.getMappingItemTransformers(mappingItems.get(schema))) {
-
-                values = transformer.beforeSync(values);
-            }
-
-            AttributeCond.Type type;
-            String expression = null;
-
-            if (values == null || values.isEmpty() || (values.size() == 1 && values.get(0) == null)) {
-                type = AttributeCond.Type.ISNULL;
-            } else {
-                type = AttributeCond.Type.EQ;
-                expression = values.size() > 1
-                        ? values.toString()
-                        : values.get(0).toString();
-            }
-
-            SearchCond nodeCond;
-            // users: just key or username can be selected
-            // groups: just key or name can be selected
-            // any objects: just key can be selected
-            if ("key".equalsIgnoreCase(schema)
-                    || "username".equalsIgnoreCase(schema) || "name".equalsIgnoreCase(schema)) {
-
-                AnyCond cond = new AnyCond();
-                cond.setSchema(schema);
-                cond.setType(type);
-                cond.setExpression(expression);
-
-                nodeCond = SearchCond.getLeafCond(cond);
-            } else {
-                AttributeCond cond = new AttributeCond();
-                cond.setSchema(schema);
-                cond.setType(type);
-                cond.setExpression(expression);
-
-                nodeCond = SearchCond.getLeafCond(cond);
-            }
-
-            searchCond = searchCond == null
-                    ? nodeCond
-                    : SearchCond.getAndCond(searchCond, nodeCond);
-        }
-
-        return searchCond;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
deleted file mode 100644
index ba70634..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
+++ /dev/null
@@ -1,206 +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.core.provisioning.java.sync;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.core.misc.search.SearchCondConverter;
-import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
-import org.apache.syncope.core.persistence.api.dao.AnyDAO;
-import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
-import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
-import org.apache.syncope.core.persistence.api.entity.resource.Provision;
-import org.apache.syncope.core.persistence.api.entity.task.PushTask;
-import org.apache.syncope.core.provisioning.api.Connector;
-import org.apache.syncope.core.provisioning.api.sync.AnyObjectPushResultHandler;
-import org.apache.syncope.core.provisioning.api.sync.GroupPushResultHandler;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningProfile;
-import org.apache.syncope.core.provisioning.api.sync.PushActions;
-import org.apache.syncope.core.provisioning.api.sync.SyncopePushResultHandler;
-import org.apache.syncope.core.provisioning.api.sync.UserPushResultHandler;
-import org.quartz.JobExecutionException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-
-public class PushJobDelegate extends AbstractProvisioningJobDelegate<PushTask> {
-
-    private static final int PAGE_SIZE = 1000;
-
-    /**
-     * User DAO.
-     */
-    @Autowired
-    private UserDAO userDAO;
-
-    /**
-     * Search DAO.
-     */
-    @Autowired
-    private AnySearchDAO searchDAO;
-
-    /**
-     * Group DAO.
-     */
-    @Autowired
-    private GroupDAO groupDAO;
-
-    @Autowired
-    private AnyObjectDAO anyObjectDAO;
-
-    private AnyDAO<?> getAnyDAO(final AnyTypeKind anyTypeKind) {
-        AnyDAO<?> result;
-        switch (anyTypeKind) {
-            case USER:
-                result = userDAO;
-                break;
-
-            case GROUP:
-                result = groupDAO;
-                break;
-
-            case ANY_OBJECT:
-            default:
-                result = anyObjectDAO;
-        }
-
-        return result;
-    }
-
-    protected void handle(
-            final List<? extends Any<?>> anys,
-            final SyncopePushResultHandler handler,
-            final ExternalResource resource)
-            throws JobExecutionException {
-
-        for (Any<?> any : anys) {
-            try {
-                handler.handle(any.getKey());
-            } catch (Exception e) {
-                LOG.warn("Failure pushing '{}' on '{}'", any, resource, e);
-                throw new JobExecutionException("While pushing " + any + " on " + resource, e);
-            }
-        }
-    }
-
-    @Override
-    protected String doExecuteProvisioning(
-            final PushTask pushTask,
-            final Connector connector,
-            final boolean dryRun) throws JobExecutionException {
-
-        LOG.debug("Executing push on {}", pushTask.getResource());
-
-        List<PushActions> actions = new ArrayList<>();
-        for (String className : pushTask.getActionsClassNames()) {
-            try {
-                Class<?> actionsClass = Class.forName(className);
-
-                PushActions syncActions = (PushActions) ApplicationContextProvider.getBeanFactory().
-                        createBean(actionsClass, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, true);
-                actions.add(syncActions);
-            } catch (Exception e) {
-                LOG.info("Class '{}' not found", className, e);
-            }
-        }
-
-        ProvisioningProfile<PushTask, PushActions> profile = new ProvisioningProfile<>(connector, pushTask);
-        profile.setDryRun(dryRun);
-        profile.setResAct(null);
-
-        AnyObjectPushResultHandler ahandler =
-                (AnyObjectPushResultHandler) ApplicationContextProvider.getBeanFactory().
-                createBean(AnyObjectPushResultHandlerImpl.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
-        ahandler.setProfile(profile);
-
-        UserPushResultHandler uhandler =
-                (UserPushResultHandler) ApplicationContextProvider.getBeanFactory().
-                createBean(UserPushResultHandlerImpl.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
-        uhandler.setProfile(profile);
-
-        GroupPushResultHandler ghandler =
-                (GroupPushResultHandler) ApplicationContextProvider.getBeanFactory().
-                createBean(GroupPushResultHandlerImpl.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
-        ghandler.setProfile(profile);
-
-        if (!profile.isDryRun()) {
-            for (PushActions action : actions) {
-                action.beforeAll(profile);
-            }
-        }
-
-        for (Provision provision : pushTask.getResource().getProvisions()) {
-            if (provision.getMapping() != null) {
-                AnyDAO<?> anyDAO = getAnyDAO(provision.getAnyType().getKind());
-
-                SyncopePushResultHandler handler;
-                switch (provision.getAnyType().getKind()) {
-                    case USER:
-                        handler = uhandler;
-                        break;
-
-                    case GROUP:
-                        handler = ghandler;
-                        break;
-
-                    case ANY_OBJECT:
-                    default:
-                        handler = ahandler;
-                }
-
-                String filter = pushTask.getFilter(provision.getAnyType()) == null
-                        ? null
-                        : pushTask.getFilter(provision.getAnyType()).getFIQLCond();
-                if (StringUtils.isBlank(filter)) {
-                    handle(anyDAO.findAll(), handler, pushTask.getResource());
-                } else {
-                    int count = anyDAO.count(SyncopeConstants.FULL_ADMIN_REALMS);
-                    for (int page = 1; page <= (count / PAGE_SIZE) + 1; page++) {
-                        List<? extends Any<?>> anys = searchDAO.search(
-                                SyncopeConstants.FULL_ADMIN_REALMS,
-                                SearchCondConverter.convert(filter),
-                                page,
-                                PAGE_SIZE,
-                                Collections.<OrderByClause>emptyList(),
-                                provision.getAnyType().getKind());
-                        handle(anys, handler, pushTask.getResource());
-                    }
-                }
-            }
-        }
-
-        if (!profile.isDryRun()) {
-            for (PushActions action : actions) {
-                action.afterAll(profile);
-            }
-        }
-
-        String result = createReport(profile.getResults(), pushTask.getResource().getSyncTraceLevel(), dryRun);
-        LOG.debug("Sync result: {}", result);
-        return result;
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncJobDelegate.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncJobDelegate.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncJobDelegate.java
deleted file mode 100644
index cf0f020..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncJobDelegate.java
+++ /dev/null
@@ -1,251 +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.core.provisioning.java.sync;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.commons.collections4.IteratorUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.common.lib.policy.SyncPolicySpec;
-import org.apache.syncope.core.misc.utils.MappingUtils;
-import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.NotFoundException;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
-import org.apache.syncope.core.persistence.api.entity.VirSchema;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
-import org.apache.syncope.core.persistence.api.entity.resource.Provision;
-import org.apache.syncope.core.persistence.api.entity.task.ProvisioningTask;
-import org.apache.syncope.core.persistence.api.entity.task.SyncTask;
-import org.apache.syncope.core.provisioning.api.Connector;
-import org.apache.syncope.core.provisioning.api.sync.AnyObjectSyncResultHandler;
-import org.apache.syncope.core.provisioning.api.sync.GroupSyncResultHandler;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningProfile;
-import org.apache.syncope.core.provisioning.api.sync.SyncActions;
-import org.apache.syncope.core.provisioning.api.sync.UserSyncResultHandler;
-import org.identityconnectors.framework.common.objects.SyncResultsHandler;
-import org.identityconnectors.framework.common.objects.SyncToken;
-import org.quartz.JobExecutionException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.apache.syncope.core.provisioning.api.sync.ReconciliationFilterBuilder;
-
-public class SyncJobDelegate extends AbstractProvisioningJobDelegate<SyncTask> {
-
-    @Autowired
-    private UserDAO userDAO;
-
-    @Autowired
-    private GroupDAO groupDAO;
-
-    @Autowired
-    private VirSchemaDAO virSchemaDAO;
-
-    @Autowired
-    protected SyncUtils syncUtils;
-
-    protected void setGroupOwners(final GroupSyncResultHandler ghandler) {
-        for (Map.Entry<Long, String> entry : ghandler.getGroupOwnerMap().entrySet()) {
-            Group group = groupDAO.find(entry.getKey());
-            if (group == null) {
-                throw new NotFoundException("Group " + entry.getKey());
-            }
-
-            if (StringUtils.isBlank(entry.getValue())) {
-                group.setGroupOwner(null);
-                group.setUserOwner(null);
-            } else {
-                Long userKey = syncUtils.findMatchingAnyKey(
-                        anyTypeDAO.findUser(),
-                        entry.getValue(),
-                        ghandler.getProfile().getTask().getResource(),
-                        ghandler.getProfile().getConnector());
-
-                if (userKey == null) {
-                    Long groupKey = syncUtils.findMatchingAnyKey(
-                            anyTypeDAO.findGroup(),
-                            entry.getValue(),
-                            ghandler.getProfile().getTask().getResource(),
-                            ghandler.getProfile().getConnector());
-
-                    if (groupKey != null) {
-                        group.setGroupOwner(groupDAO.find(groupKey));
-                    }
-                } else {
-                    group.setUserOwner(userDAO.find(userKey));
-                }
-            }
-
-            groupDAO.save(group);
-        }
-    }
-
-    @Override
-    protected String doExecuteProvisioning(
-            final SyncTask syncTask,
-            final Connector connector,
-            final boolean dryRun) throws JobExecutionException {
-
-        LOG.debug("Executing sync on {}", syncTask.getResource());
-
-        List<SyncActions> actions = new ArrayList<>();
-        for (String className : syncTask.getActionsClassNames()) {
-            try {
-                Class<?> actionsClass = Class.forName(className);
-                SyncActions syncActions = (SyncActions) ApplicationContextProvider.getBeanFactory().
-                        createBean(actionsClass, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, true);
-
-                actions.add(syncActions);
-            } catch (Exception e) {
-                LOG.warn("Class '{}' not found", className, e);
-            }
-        }
-
-        ProvisioningProfile<SyncTask, SyncActions> profile = new ProvisioningProfile<>(connector, syncTask);
-        profile.getActions().addAll(actions);
-        profile.setDryRun(dryRun);
-        profile.setResAct(getSyncPolicySpec(syncTask).getConflictResolutionAction());
-
-        // Prepare handler for SyncDelta objects (any objects)
-        AnyObjectSyncResultHandler ahandler = (AnyObjectSyncResultHandler) ApplicationContextProvider.getBeanFactory().
-                createBean(AnyObjectSyncResultHandlerImpl.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
-        ahandler.setProfile(profile);
-
-        // Prepare handler for SyncDelta objects (users)
-        UserSyncResultHandler uhandler = (UserSyncResultHandler) ApplicationContextProvider.getBeanFactory().
-                createBean(UserSyncResultHandlerImpl.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
-        uhandler.setProfile(profile);
-
-        // Prepare handler for SyncDelta objects (groups)
-        GroupSyncResultHandler ghandler = (GroupSyncResultHandler) ApplicationContextProvider.getBeanFactory().
-                createBean(GroupSyncResultHandlerImpl.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
-        ghandler.setProfile(profile);
-
-        if (!profile.isDryRun()) {
-            for (SyncActions action : actions) {
-                action.beforeAll(profile);
-            }
-        }
-
-        for (Provision provision : syncTask.getResource().getProvisions()) {
-            if (provision.getMapping() != null) {
-                SyncResultsHandler handler;
-                switch (provision.getAnyType().getKind()) {
-                    case USER:
-                        handler = uhandler;
-                        break;
-
-                    case GROUP:
-                        handler = ghandler;
-                        break;
-
-                    case ANY_OBJECT:
-                    default:
-                        handler = ahandler;
-                }
-
-                try {
-                    Set<MappingItem> linkinMappingItems = new HashSet<>();
-                    for (VirSchema virSchema : virSchemaDAO.findByProvision(provision)) {
-                        linkinMappingItems.add(virSchema.asLinkingMappingItem());
-                    }
-                    Iterator<MappingItem> mapItems = IteratorUtils.chainedIterator(
-                            provision.getMapping().getItems().iterator(),
-                            linkinMappingItems.iterator());
-
-                    switch (syncTask.getSyncMode()) {
-                        case INCREMENTAL:
-                            SyncToken latestSyncToken = connector.getLatestSyncToken(provision.getObjectClass());
-                            connector.sync(
-                                    provision.getObjectClass(),
-                                    provision.getSyncToken(),
-                                    handler,
-                                    MappingUtils.buildOperationOptions(mapItems));
-                            if (!dryRun) {
-                                provision.setSyncToken(latestSyncToken);
-                                resourceDAO.save(provision.getResource());
-                            }
-                            break;
-
-                        case FILTERED_RECONCILIATION:
-                            ReconciliationFilterBuilder filterBuilder =
-                                    (ReconciliationFilterBuilder) ApplicationContextProvider.getBeanFactory().
-                                    createBean(Class.forName(syncTask.getReconciliationFilterBuilderClassName()),
-                                            AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
-                            connector.filteredReconciliation(
-                                    provision.getObjectClass(),
-                                    filterBuilder,
-                                    handler,
-                                    MappingUtils.buildOperationOptions(mapItems));
-                            break;
-
-                        case FULL_RECONCILIATION:
-                        default:
-                            connector.fullReconciliation(
-                                    provision.getObjectClass(),
-                                    handler,
-                                    MappingUtils.buildOperationOptions(mapItems));
-                            break;
-                    }
-                } catch (Throwable t) {
-                    throw new JobExecutionException("While syncing from connector", t);
-                }
-            }
-        }
-
-        try {
-            setGroupOwners(ghandler);
-        } catch (Exception e) {
-            LOG.error("While setting group owners", e);
-        }
-
-        if (!profile.isDryRun()) {
-            for (SyncActions action : actions) {
-                action.afterAll(profile);
-            }
-        }
-
-        String result = createReport(profile.getResults(), syncTask.getResource().getSyncTraceLevel(), dryRun);
-
-        LOG.debug("Sync result: {}", result);
-
-        return result;
-    }
-
-    private SyncPolicySpec getSyncPolicySpec(final ProvisioningTask task) {
-        SyncPolicySpec syncPolicySpec;
-
-        if (task instanceof SyncTask) {
-            syncPolicySpec = task.getResource().getSyncPolicy() == null
-                    ? null
-                    : task.getResource().getSyncPolicy().getSpecification();
-        } else {
-            syncPolicySpec = null;
-        }
-
-        // step required because the call <policy>.getSpecification() could return a null value
-        return syncPolicySpec == null ? new SyncPolicySpec() : syncPolicySpec;
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java
deleted file mode 100644
index 17749d1..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncUtils.java
+++ /dev/null
@@ -1,318 +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.core.provisioning.java.sync;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.policy.SyncPolicySpec;
-import org.apache.syncope.core.misc.utils.MappingUtils;
-import org.apache.syncope.core.misc.serialization.POJOHelper;
-import org.apache.syncope.core.persistence.api.attrvalue.validation.ParsingValidationException;
-import org.apache.syncope.core.persistence.api.dao.AnyDAO;
-import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
-import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
-import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.AnyType;
-import org.apache.syncope.core.persistence.api.entity.AnyUtils;
-import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
-import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.PlainSchema;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
-import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
-import org.apache.syncope.core.persistence.api.entity.resource.Provision;
-import org.apache.syncope.core.persistence.api.entity.task.ProvisioningTask;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.provisioning.api.Connector;
-import org.apache.syncope.core.provisioning.api.data.MappingItemTransformer;
-import org.apache.syncope.core.provisioning.api.sync.SyncCorrelationRule;
-import org.identityconnectors.framework.common.objects.Attribute;
-import org.identityconnectors.framework.common.objects.AttributeUtil;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
-import org.identityconnectors.framework.common.objects.Name;
-import org.identityconnectors.framework.common.objects.OperationalAttributes;
-import org.identityconnectors.framework.common.objects.ResultsHandler;
-import org.identityconnectors.framework.common.objects.filter.EqualsFilter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional(readOnly = true)
-@Component
-public class SyncUtils {
-
-    private static final Logger LOG = LoggerFactory.getLogger(SyncUtils.class);
-
-    /**
-     * Schema DAO.
-     */
-    @Autowired
-    private PlainSchemaDAO plainSchemaDAO;
-
-    /**
-     * Any Object DAO.
-     */
-    @Autowired
-    private AnyObjectDAO anyObjectDAO;
-
-    /**
-     * User DAO.
-     */
-    @Autowired
-    private UserDAO userDAO;
-
-    /**
-     * Group DAO.
-     */
-    @Autowired
-    private GroupDAO groupDAO;
-
-    /**
-     * Search DAO.
-     */
-    @Autowired
-    private AnySearchDAO searchDAO;
-
-    @Autowired
-    private AnyUtilsFactory anyUtilsFactory;
-
-    public Long findMatchingAnyKey(
-            final AnyType anyType,
-            final String name,
-            final ExternalResource resource,
-            final Connector connector) {
-
-        Provision provision = resource.getProvision(anyType);
-        if (provision == null) {
-            return null;
-        }
-
-        Long result = null;
-
-        AnyUtils anyUtils = anyUtilsFactory.getInstance(anyType.getKind());
-
-        final List<ConnectorObject> found = new ArrayList<>();
-        connector.search(
-                provision.getObjectClass(),
-                new EqualsFilter(new Name(name)),
-                new ResultsHandler() {
-
-            @Override
-            public boolean handle(final ConnectorObject obj) {
-                return found.add(obj);
-            }
-        },
-                MappingUtils.buildOperationOptions(MappingUtils.getSyncMappingItems(provision).iterator()));
-
-        if (found.isEmpty()) {
-            LOG.debug("No {} found on {} with __NAME__ {}", provision.getObjectClass(), resource, name);
-        } else {
-            if (found.size() > 1) {
-                LOG.warn("More than one {} found on {} with __NAME__ {} - taking first only",
-                        provision.getObjectClass(), resource, name);
-            }
-
-            ConnectorObject connObj = found.iterator().next();
-            try {
-                List<Long> anyKeys = findExisting(connObj.getUid().getUidValue(), connObj, provision, anyUtils);
-                if (anyKeys.isEmpty()) {
-                    LOG.debug("No matching {} found for {}, aborting", anyUtils.getAnyTypeKind(), connObj);
-                } else {
-                    if (anyKeys.size() > 1) {
-                        LOG.warn("More than one {} found {} - taking first only", anyUtils.getAnyTypeKind(), anyKeys);
-                    }
-
-                    result = anyKeys.iterator().next();
-                }
-            } catch (IllegalArgumentException e) {
-                LOG.warn(e.getMessage());
-            }
-        }
-
-        return result;
-    }
-
-    private AnyDAO<?> getAnyDAO(final MappingItem connObjectKeyItem) {
-        return AnyTypeKind.USER == connObjectKeyItem.getIntMappingType().getAnyTypeKind()
-                ? userDAO
-                : AnyTypeKind.ANY_OBJECT == connObjectKeyItem.getIntMappingType().getAnyTypeKind()
-                        ? anyObjectDAO
-                        : groupDAO;
-    }
-
-    private List<Long> findByConnObjectKeyItem(
-            final String uid, final Provision provision, final AnyUtils anyUtils) {
-
-        List<Long> result = new ArrayList<>();
-
-        MappingItem connObjectKeyItem = MappingUtils.getConnObjectKeyItem(provision);
-
-        String transfUid = uid;
-        for (MappingItemTransformer transformer : MappingUtils.getMappingItemTransformers(connObjectKeyItem)) {
-            List<Object> output = transformer.beforeSync(Collections.<Object>singletonList(transfUid));
-            if (output != null && !output.isEmpty()) {
-                transfUid = output.get(0).toString();
-            }
-        }
-
-        switch (connObjectKeyItem.getIntMappingType()) {
-            case UserPlainSchema:
-            case GroupPlainSchema:
-            case AnyObjectPlainSchema:
-                PlainAttrValue value = anyUtils.newPlainAttrValue();
-
-                PlainSchema schema = plainSchemaDAO.find(connObjectKeyItem.getIntAttrName());
-                if (schema == null) {
-                    value.setStringValue(transfUid);
-                } else {
-                    try {
-                        value.parseValue(schema, transfUid);
-                    } catch (ParsingValidationException e) {
-                        LOG.error("While parsing provided __UID__ {}", transfUid, e);
-                        value.setStringValue(transfUid);
-                    }
-                }
-
-                List<? extends Any<?>> anys =
-                        getAnyDAO(connObjectKeyItem).findByAttrValue(connObjectKeyItem.getIntAttrName(), value);
-                for (Any<?> any : anys) {
-                    result.add(any.getKey());
-                }
-                break;
-
-            case UserDerivedSchema:
-            case GroupDerivedSchema:
-            case AnyObjectDerivedSchema:
-                anys = getAnyDAO(connObjectKeyItem).findByDerAttrValue(connObjectKeyItem.getIntAttrName(), transfUid);
-                for (Any<?> any : anys) {
-                    result.add(any.getKey());
-                }
-                break;
-
-            case UserKey:
-            case GroupKey:
-            case AnyObjectKey:
-                Any<?> any = getAnyDAO(connObjectKeyItem).find(Long.parseLong(transfUid));
-                if (any != null) {
-                    result.add(any.getKey());
-                }
-                break;
-
-            case Username:
-                User user = userDAO.find(transfUid);
-                if (user != null) {
-                    result.add(user.getKey());
-                }
-                break;
-
-            case GroupName:
-                Group group = groupDAO.find(transfUid);
-                if (group != null) {
-                    result.add(group.getKey());
-                }
-                break;
-
-            default:
-                LOG.error("Invalid connObjectKey type '{}'", connObjectKeyItem.getIntMappingType());
-        }
-
-        return result;
-    }
-
-    private List<Long> findByCorrelationRule(
-            final ConnectorObject connObj, final SyncCorrelationRule rule, final AnyTypeKind type) {
-
-        List<Long> result = new ArrayList<>();
-        for (Any<?> any : searchDAO.search(rule.getSearchCond(connObj), type)) {
-            result.add(any.getKey());
-        }
-
-        return result;
-    }
-
-    private SyncCorrelationRule getCorrelationRule(final Provision provision, final SyncPolicySpec policySpec) {
-        SyncCorrelationRule result = null;
-
-        String syncCorrelationRule = policySpec.getCorrelationRules().get(provision.getAnyType().getKey());
-        if (StringUtils.isNotBlank(syncCorrelationRule)) {
-            if (syncCorrelationRule.charAt(0) == '[') {
-                result = new PlainAttrsSyncCorrelationRule(
-                        POJOHelper.deserialize(syncCorrelationRule, String[].class), provision);
-            } else {
-                try {
-                    result = (SyncCorrelationRule) Class.forName(syncCorrelationRule).newInstance();
-                } catch (Exception e) {
-                    LOG.error("Failure instantiating correlation rule class '{}'", syncCorrelationRule, e);
-                }
-            }
-        }
-
-        return result;
-    }
-
-    /**
-     * Find any objects based on mapped uid value (or previous uid value, if updated).
-     *
-     * @param uid for finding by connObjectKey
-     * @param connObj for finding by attribute value
-     * @param provision external resource
-     * @param anyUtils any util
-     * @return list of matching users / groups
-     */
-    public List<Long> findExisting(
-            final String uid,
-            final ConnectorObject connObj,
-            final Provision provision,
-            final AnyUtils anyUtils) {
-
-        SyncPolicySpec syncPolicySpec = null;
-        if (provision.getResource().getSyncPolicy() != null) {
-            syncPolicySpec = provision.getResource().getSyncPolicy().getSpecification();
-        }
-
-        SyncCorrelationRule syncRule = null;
-        if (syncPolicySpec != null) {
-            syncRule = getCorrelationRule(provision, syncPolicySpec);
-        }
-
-        return syncRule == null
-                ? findByConnObjectKeyItem(uid, provision, anyUtils)
-                : findByCorrelationRule(connObj, syncRule, anyUtils.getAnyTypeKind());
-    }
-
-    public Boolean readEnabled(final ConnectorObject connectorObject, final ProvisioningTask task) {
-        Boolean enabled = null;
-        if (task.isSyncStatus()) {
-            Attribute status = AttributeUtil.find(OperationalAttributes.ENABLE_NAME, connectorObject.getAttributes());
-            if (status != null && status.getValue() != null && !status.getValue().isEmpty()) {
-                enabled = (Boolean) status.getValue().get(0);
-            }
-        }
-
-        return enabled;
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserPushResultHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserPushResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserPushResultHandlerImpl.java
deleted file mode 100644
index 03865d7..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserPushResultHandlerImpl.java
+++ /dev/null
@@ -1,96 +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.core.provisioning.java.sync;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.syncope.common.lib.patch.AnyPatch;
-import org.apache.syncope.common.lib.patch.UserPatch;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.PropagationByResource;
-import org.apache.syncope.common.lib.types.ResourceOperation;
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.AnyUtils;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.provisioning.api.WorkflowResult;
-import org.apache.syncope.core.provisioning.api.sync.UserPushResultHandler;
-
-public class UserPushResultHandlerImpl extends AbstractPushResultHandler implements UserPushResultHandler {
-
-    @Override
-    protected AnyUtils getAnyUtils() {
-        return anyUtilsFactory.getInstance(AnyTypeKind.USER);
-    }
-
-    @Override
-    protected void provision(final Any<?> any, final Boolean enabled) {
-        AnyTO before = getAnyTO(any.getKey());
-
-        List<String> noPropResources = new ArrayList<>(before.getResources());
-        noPropResources.remove(profile.getTask().getResource().getKey());
-
-        PropagationByResource propByRes = new PropagationByResource();
-        propByRes.add(ResourceOperation.CREATE, profile.getTask().getResource().getKey());
-
-        taskExecutor.execute(propagationManager.getUserCreateTasks(
-                before.getKey(),
-                null,
-                enabled,
-                propByRes,
-                before.getVirAttrs(),
-                noPropResources));
-    }
-
-    @Override
-    protected String getName(final Any<?> any) {
-        return User.class.cast(any).getUsername();
-    }
-
-    @Override
-    protected Any<?> getAny(final long key) {
-        try {
-            return userDAO.authFind(key);
-        } catch (Exception e) {
-            LOG.warn("Error retrieving user {}", key, e);
-            return null;
-        }
-    }
-
-    @Override
-    protected AnyTO getAnyTO(final long key) {
-        return userDataBinder.getUserTO(key);
-    }
-
-    @Override
-    protected AnyPatch newPatch(final long key) {
-        UserPatch patch = new UserPatch();
-        patch.setKey(key);
-        return patch;
-    }
-
-    @Override
-    protected WorkflowResult<Long> update(final AnyPatch patch) {
-        WorkflowResult<Pair<UserPatch, Boolean>> update = uwfAdapter.update((UserPatch) patch);
-        return new WorkflowResult<>(
-                update.getResult().getLeft().getKey(), update.getPropByRes(), update.getPerformedTasks());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserSyncResultHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserSyncResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserSyncResultHandlerImpl.java
deleted file mode 100644
index 2a222d0..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/UserSyncResultHandlerImpl.java
+++ /dev/null
@@ -1,133 +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.core.provisioning.java.sync;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.syncope.common.lib.patch.AnyPatch;
-import org.apache.syncope.common.lib.patch.UserPatch;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.common.lib.to.PropagationStatus;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.AnyUtils;
-import org.apache.syncope.core.provisioning.api.ProvisioningManager;
-import org.apache.syncope.core.provisioning.api.WorkflowResult;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningReport;
-import org.apache.syncope.core.provisioning.api.sync.UserSyncResultHandler;
-import org.identityconnectors.framework.common.objects.SyncDelta;
-
-public class UserSyncResultHandlerImpl extends AbstractSyncResultHandler implements UserSyncResultHandler {
-
-    @Override
-    protected AnyUtils getAnyUtils() {
-        return anyUtilsFactory.getInstance(AnyTypeKind.USER);
-    }
-
-    @Override
-    protected String getName(final AnyTO anyTO) {
-        return UserTO.class.cast(anyTO).getUsername();
-    }
-
-    @Override
-    protected ProvisioningManager<?, ?> getProvisioningManager() {
-        return userProvisioningManager;
-    }
-
-    @Override
-    protected Any<?> getAny(final long key) {
-        try {
-            return userDAO.authFind(key);
-        } catch (Exception e) {
-            LOG.warn("Error retrieving user {}", key, e);
-            return null;
-        }
-    }
-
-    @Override
-    protected AnyTO getAnyTO(final long key) {
-        return userDataBinder.getUserTO(key);
-    }
-
-    @Override
-    protected AnyPatch newPatch(final long key) {
-        UserPatch patch = new UserPatch();
-        patch.setKey(key);
-        return patch;
-    }
-
-    @Override
-    protected WorkflowResult<Long> update(final AnyPatch patch) {
-        WorkflowResult<Pair<UserPatch, Boolean>> update = uwfAdapter.update((UserPatch) patch);
-        return new WorkflowResult<>(
-                update.getResult().getLeft().getKey(), update.getPropByRes(), update.getPerformedTasks());
-    }
-
-    @Override
-    protected AnyTO doCreate(final AnyTO anyTO, final SyncDelta delta, final ProvisioningReport result) {
-        UserTO userTO = UserTO.class.cast(anyTO);
-
-        Boolean enabled = syncUtilities.readEnabled(delta.getObject(), profile.getTask());
-        Map.Entry<Long, List<PropagationStatus>> created =
-                userProvisioningManager.create(userTO, true, true, enabled,
-                        Collections.singleton(profile.getTask().getResource().getKey()), true);
-
-        result.setKey(created.getKey());
-        result.setName(getName(anyTO));
-
-        return getAnyTO(created.getKey());
-    }
-
-    @Override
-    protected AnyTO doUpdate(
-            final AnyTO before,
-            final AnyPatch anyPatch,
-            final SyncDelta delta,
-            final ProvisioningReport result) {
-
-        UserPatch userPatch = UserPatch.class.cast(anyPatch);
-        Boolean enabled = syncUtilities.readEnabled(delta.getObject(), profile.getTask());
-
-        Map.Entry<Long, List<PropagationStatus>> updated = userProvisioningManager.update(
-                userPatch,
-                result,
-                enabled,
-                Collections.singleton(profile.getTask().getResource().getKey()),
-                true);
-
-        return getAnyTO(updated.getKey());
-    }
-
-    @Override
-    protected void doDelete(final AnyTypeKind kind, final Long key) {
-        try {
-            userProvisioningManager.delete(
-                    key, Collections.<String>singleton(profile.getTask().getResource().getKey()), true);
-        } catch (Exception e) {
-            // A propagation failure doesn't imply a synchronization failure.
-            // The propagation exception status will be reported into the propagation task execution.
-            LOG.error("Could not propagate user " + key, e);
-        }
-
-        uwfAdapter.delete(key);
-    }
-}


Mime
View raw message