syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [04/70] syncope git commit: [SYNCOPE-666] Initial commit, Travis CI builds disabled
Date Thu, 11 Jun 2015 14:16:54 GMT
http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/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
index fe1a8aa..992507b 100644
--- 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
@@ -18,9 +18,9 @@
  */
 package org.apache.syncope.core.provisioning.java.sync;
 
-import org.apache.syncope.common.lib.mod.AbstractSubjectMod;
+import org.apache.syncope.common.lib.mod.AnyMod;
 import org.apache.syncope.common.lib.mod.UserMod;
-import org.apache.syncope.common.lib.to.AbstractSubjectTO;
+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;
@@ -53,7 +53,7 @@ public class LDAPPasswordSyncActions extends DefaultSyncActions {
 
     @Transactional(readOnly = true)
     @Override
-    public <T extends AbstractSubjectTO> SyncDelta beforeProvision(
+    public <T extends AnyTO> SyncDelta beforeProvision(
             final ProvisioningProfile<?, ?> profile,
             final SyncDelta delta,
             final T subject) throws JobExecutionException {
@@ -68,7 +68,7 @@ public class LDAPPasswordSyncActions extends DefaultSyncActions {
 
     @Transactional(readOnly = true)
     @Override
-    public <T extends AbstractSubjectTO, K extends AbstractSubjectMod> SyncDelta beforeUpdate(
+    public <T extends AnyTO, K extends AnyMod> SyncDelta beforeUpdate(
             final ProvisioningProfile<?, ?> profile,
             final SyncDelta delta,
             final T subject,
@@ -101,7 +101,7 @@ public class LDAPPasswordSyncActions extends DefaultSyncActions {
 
     @Transactional(readOnly = true)
     @Override
-    public <T extends AbstractSubjectTO> void after(
+    public <T extends AnyTO> void after(
             final ProvisioningProfile<?, ?> profile,
             final SyncDelta delta,
             final T subject,

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobImpl.java
index 7acc2ae..b13213a 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobImpl.java
@@ -22,21 +22,22 @@ 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.SubjectType;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.SubjectSearchDAO;
 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.group.GMapping;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
 import org.apache.syncope.core.persistence.api.entity.task.PushTask;
-import org.apache.syncope.core.persistence.api.entity.user.UMapping;
 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.sync.ProvisioningProfile;
 import org.apache.syncope.core.provisioning.api.sync.PushActions;
 import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
 import org.apache.syncope.core.misc.search.SearchCondConverter;
+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.entity.Any;
+import org.apache.syncope.core.persistence.api.entity.resource.Provision;
 import org.apache.syncope.core.provisioning.api.job.PushJob;
 import org.apache.syncope.core.provisioning.api.sync.GroupPushResultHandler;
 import org.apache.syncope.core.provisioning.api.sync.UserPushResultHandler;
@@ -65,7 +66,7 @@ public class PushJobImpl extends AbstractProvisioningJob<PushTask, PushActions>
      * Search DAO.
      */
     @Autowired
-    private SubjectSearchDAO searchDAO;
+    private AnySearchDAO searchDAO;
 
     /**
      * Group DAO.
@@ -73,28 +74,49 @@ public class PushJobImpl extends AbstractProvisioningJob<PushTask, PushActions>
     @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;
+    }
+
     @Override
     protected String executeWithSecurityContext(
             final PushTask pushTask,
             final Connector connector,
-            final UMapping uMapping,
-            final GMapping rMapping,
             final boolean dryRun) throws JobExecutionException {
-        LOG.debug("Execute synchronization (push) with resource {}", pushTask.getResource());
 
-        final ProvisioningProfile<PushTask, PushActions> profile = new ProvisioningProfile<>(connector, pushTask);
+        LOG.debug("Executing push on {}", pushTask.getResource());
+
+        ProvisioningProfile<PushTask, PushActions> profile = new ProvisioningProfile<>(connector, pushTask);
         if (actions != null) {
             profile.getActions().addAll(actions);
         }
         profile.setDryRun(dryRun);
         profile.setResAct(null);
 
-        final UserPushResultHandler uhandler =
+        UserPushResultHandler uhandler =
                 (UserPushResultHandler) ApplicationContextProvider.getApplicationContext().getBeanFactory().
                 createBean(UserPushResultHandlerImpl.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
         uhandler.setProfile(profile);
 
-        final GroupPushResultHandler rhandler =
+        GroupPushResultHandler rhandler =
                 (GroupPushResultHandler) ApplicationContextProvider.getApplicationContext().getBeanFactory().
                 createBean(GroupPushResultHandlerImpl.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
         rhandler.setProfile(profile);
@@ -105,43 +127,28 @@ public class PushJobImpl extends AbstractProvisioningJob<PushTask, PushActions>
             }
         }
 
-        if (uMapping != null) {
-            final int count = userDAO.count(SyncopeConstants.FULL_ADMIN_REALMS);
-            for (int page = 1; page <= (count / PAGE_SIZE) + 1; page++) {
-                final List<User> localUsers = StringUtils.isBlank(pushTask.getUserFilter())
-                        ? userDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, page, PAGE_SIZE)
-                        : searchDAO.<User>search(SyncopeConstants.FULL_ADMIN_REALMS,
-                                SearchCondConverter.convert(pushTask.getUserFilter()),
-                                Collections.<OrderByClause>emptyList(), SubjectType.USER);
-
-                for (User localUser : localUsers) {
-                    try {
-                        // user propagation
-                        uhandler.handle(localUser.getKey());
-                    } catch (Exception e) {
-                        LOG.warn("Failure pushing user '{}' on '{}'", localUser, pushTask.getResource(), e);
-                        throw new JobExecutionException("While pushing users on connector", e);
-                    }
-                }
-            }
-        }
-
-        if (rMapping != null) {
-            final int count = groupDAO.count(SyncopeConstants.FULL_ADMIN_REALMS);
-            for (int page = 1; page <= (count / PAGE_SIZE) + 1; page++) {
-                final List<Group> localGroups = StringUtils.isBlank(pushTask.getGroupFilter())
-                        ? groupDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, page, PAGE_SIZE)
-                        : searchDAO.<Group>search(SyncopeConstants.FULL_ADMIN_REALMS,
-                                SearchCondConverter.convert(pushTask.getGroupFilter()),
-                                Collections.<OrderByClause>emptyList(), SubjectType.GROUP);
-
-                for (Group localGroup : localGroups) {
-                    try {
-                        // group propagation
-                        rhandler.handle(localGroup.getKey());
-                    } catch (Exception e) {
-                        LOG.warn("Failure pushing group '{}' on '{}'", localGroup, pushTask.getResource(), e);
-                        throw new JobExecutionException("While pushing groups on connector", e);
+        for (Provision provision : pushTask.getResource().getProvisions()) {
+            if (provision.getMapping() != null) {
+                AnyDAO<?> anyDAO = getAnyDAO(provision.getAnyType().getKind());
+                String filter = pushTask.getFilter(provision.getAnyType()) == null
+                        ? null
+                        : pushTask.getFilter(provision.getAnyType()).get();
+
+                int count = anyDAO.count(SyncopeConstants.FULL_ADMIN_REALMS);
+                for (int page = 1; page <= (count / PAGE_SIZE) + 1; page++) {
+                    List<? extends Any<?, ?, ?>> localAnys = StringUtils.isBlank(filter)
+                            ? anyDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, page, PAGE_SIZE)
+                            : searchDAO.<User>search(SyncopeConstants.FULL_ADMIN_REALMS,
+                                    SearchCondConverter.convert(filter),
+                                    Collections.<OrderByClause>emptyList(), provision.getAnyType().getKind());
+
+                    for (Any<?, ?, ?> any : localAnys) {
+                        try {
+                            uhandler.handle(any.getKey());
+                        } catch (Exception e) {
+                            LOG.warn("Failure pushing user '{}' on '{}'", any, pushTask.getResource(), e);
+                            throw new JobExecutionException("While pushing users on connector", e);
+                        }
                     }
                 }
             }
@@ -153,10 +160,8 @@ public class PushJobImpl extends AbstractProvisioningJob<PushTask, PushActions>
             }
         }
 
-        final String result = createReport(profile.getResults(), pushTask.getResource().getSyncTraceLevel(), dryRun);
-
+        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/081d9a04/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncJobImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncJobImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncJobImpl.java
index 54e5115..1e19d02 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncJobImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/SyncJobImpl.java
@@ -23,20 +23,21 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.common.lib.mod.ReferenceMod;
 import org.apache.syncope.common.lib.mod.GroupMod;
 import org.apache.syncope.common.lib.types.SyncPolicySpec;
-import org.apache.syncope.core.persistence.api.entity.ExternalResource;
-import org.apache.syncope.core.persistence.api.entity.group.GMapping;
 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.persistence.api.entity.user.UMapping;
 import org.apache.syncope.core.provisioning.api.Connector;
 import org.apache.syncope.core.provisioning.api.sync.ProvisioningProfile;
 import org.apache.syncope.core.provisioning.api.sync.SyncActions;
 import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
+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.provisioning.api.job.SyncJob;
+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.UserSyncResultHandler;
 import org.apache.syncope.core.workflow.api.GroupWorkflowAdapter;
 import org.identityconnectors.framework.common.objects.ObjectClass;
+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;
@@ -57,7 +58,7 @@ public class SyncJobImpl extends AbstractProvisioningJob<SyncTask, SyncActions>
     private GroupWorkflowAdapter gwfAdapter;
 
     @Autowired
-    protected SyncUtils syncUtilities;
+    protected SyncUtils syncUtils;
 
     protected void setGroupOwners(final GroupSyncResultHandler rhandler) {
         for (Map.Entry<Long, String> entry : rhandler.getGroupOwnerMap().entrySet()) {
@@ -68,24 +69,24 @@ public class SyncJobImpl extends AbstractProvisioningJob<SyncTask, SyncActions>
                 groupMod.setGroupOwner(null);
                 groupMod.setUserOwner(null);
             } else {
-                Long userId = syncUtilities.findMatchingAttributableKey(
-                        ObjectClass.ACCOUNT,
+                Long userKey = syncUtils.findMatchingAnyKey(
+                        anyTypeDAO.findUser(),
                         entry.getValue(),
                         rhandler.getProfile().getTask().getResource(),
                         rhandler.getProfile().getConnector());
 
-                if (userId == null) {
-                    Long groupId = syncUtilities.findMatchingAttributableKey(
-                            ObjectClass.GROUP,
+                if (userKey == null) {
+                    Long groupKey = syncUtils.findMatchingAnyKey(
+                            anyTypeDAO.findGroup(),
                             entry.getValue(),
                             rhandler.getProfile().getTask().getResource(),
                             rhandler.getProfile().getConnector());
 
-                    if (groupId != null) {
-                        groupMod.setGroupOwner(new ReferenceMod(groupId));
+                    if (groupKey != null) {
+                        groupMod.setGroupOwner(new ReferenceMod(groupKey));
                     }
                 } else {
-                    groupMod.setUserOwner(new ReferenceMod(userId));
+                    groupMod.setUserOwner(new ReferenceMod(userKey));
                 }
             }
 
@@ -97,11 +98,9 @@ public class SyncJobImpl extends AbstractProvisioningJob<SyncTask, SyncActions>
     protected String executeWithSecurityContext(
             final SyncTask syncTask,
             final Connector connector,
-            final UMapping uMapping,
-            final GMapping rMapping,
             final boolean dryRun) throws JobExecutionException {
 
-        LOG.debug("Execute synchronization with token {}", syncTask.getResource().getUsyncToken());
+        LOG.debug("Executing sync on {}", syncTask.getResource());
 
         ProvisioningProfile<SyncTask, SyncActions> profile = new ProvisioningProfile<>(connector, syncTask);
         if (actions != null) {
@@ -110,6 +109,12 @@ public class SyncJobImpl extends AbstractProvisioningJob<SyncTask, SyncActions>
         profile.setDryRun(dryRun);
         profile.setResAct(getSyncPolicySpec(syncTask).getConflictResolutionAction());
 
+        // Prepare handler for SyncDelta objects (any objects)
+        AnyObjectSyncResultHandler ahandler =
+                (AnyObjectSyncResultHandler) ApplicationContextProvider.getApplicationContext().getBeanFactory().
+                createBean(AnyObjectSyncResultHandlerImpl.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
+        ahandler.setProfile(profile);
+
         // Prepare handler for SyncDelta objects (users)
         UserSyncResultHandler uhandler =
                 (UserSyncResultHandler) ApplicationContextProvider.getApplicationContext().getBeanFactory().
@@ -117,10 +122,10 @@ public class SyncJobImpl extends AbstractProvisioningJob<SyncTask, SyncActions>
         uhandler.setProfile(profile);
 
         // Prepare handler for SyncDelta objects (groups)
-        GroupSyncResultHandler rhandler =
+        GroupSyncResultHandler ghandler =
                 (GroupSyncResultHandler) ApplicationContextProvider.getApplicationContext().getBeanFactory().
                 createBean(GroupSyncResultHandlerImpl.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
-        rhandler.setProfile(profile);
+        ghandler.setProfile(profile);
 
         if (actions != null && !profile.isDryRun()) {
             for (SyncActions action : actions) {
@@ -129,47 +134,49 @@ public class SyncJobImpl extends AbstractProvisioningJob<SyncTask, SyncActions>
         }
 
         try {
-            SyncToken latestUSyncToken = null;
-            if (uMapping != null && !syncTask.isFullReconciliation()) {
-                latestUSyncToken = connector.getLatestSyncToken(ObjectClass.ACCOUNT);
-            }
-            SyncToken latestRSyncToken = null;
-            if (rMapping != null && !syncTask.isFullReconciliation()) {
-                latestRSyncToken = connector.getLatestSyncToken(ObjectClass.GROUP);
-            }
-
-            if (syncTask.isFullReconciliation()) {
-                if (uMapping != null) {
-                    connector.getAllObjects(ObjectClass.ACCOUNT, uhandler,
-                            connector.getOperationOptions(uMapping.getItems()));
-                }
-                if (rMapping != null) {
-                    connector.getAllObjects(ObjectClass.GROUP, rhandler,
-                            connector.getOperationOptions(rMapping.getItems()));
-                }
-            } else {
-                if (uMapping != null) {
-                    connector.sync(ObjectClass.ACCOUNT, syncTask.getResource().getUsyncToken(), uhandler,
-                            connector.getOperationOptions(uMapping.getItems()));
+            for (Provision provision : syncTask.getResource().getProvisions()) {
+                SyncResultsHandler handler;
+                switch (provision.getAnyType().getKind()) {
+                    case USER:
+                        handler = uhandler;
+                        break;
+
+                    case GROUP:
+                        handler = ghandler;
+                        break;
+
+                    case ANY_OBJECT:
+                    default:
+                        handler = ahandler;
                 }
-                if (rMapping != null) {
-                    connector.sync(ObjectClass.GROUP, syncTask.getResource().getRsyncToken(), rhandler,
-                            connector.getOperationOptions(rMapping.getItems()));
+
+                SyncToken latestSyncToken = null;
+                if (provision.getMapping() != null && !syncTask.isFullReconciliation()) {
+                    latestSyncToken = connector.getLatestSyncToken(ObjectClass.ACCOUNT);
                 }
-            }
 
-            if (!dryRun && !syncTask.isFullReconciliation()) {
-                try {
-                    ExternalResource resource = resourceDAO.find(syncTask.getResource().getKey());
-                    if (uMapping != null) {
-                        resource.setUsyncToken(latestUSyncToken);
+                if (syncTask.isFullReconciliation()) {
+                    if (provision.getMapping() != null) {
+                        connector.getAllObjects(provision.getObjectClass(), handler,
+                                connector.getOperationOptions(provision.getMapping().getItems()));
+                    }
+                } else {
+                    if (provision.getMapping() != null) {
+                        connector.sync(provision.getObjectClass(), provision.getSyncToken(), handler,
+                                connector.getOperationOptions(provision.getMapping().getItems()));
                     }
-                    if (rMapping != null) {
-                        resource.setRsyncToken(latestRSyncToken);
+                }
+
+                if (!dryRun && !syncTask.isFullReconciliation()) {
+                    try {
+                        ExternalResource resource = resourceDAO.find(syncTask.getResource().getKey());
+                        if (provision.getMapping() != null) {
+                            provision.setSyncToken(latestSyncToken);
+                        }
+                        resourceDAO.save(resource);
+                    } catch (Exception e) {
+                        throw new JobExecutionException("While updating SyncToken", e);
                     }
-                    resourceDAO.save(resource);
-                } catch (Exception e) {
-                    throw new JobExecutionException("While updating SyncToken", e);
                 }
             }
         } catch (Throwable t) {
@@ -177,7 +184,7 @@ public class SyncJobImpl extends AbstractProvisioningJob<SyncTask, SyncActions>
         }
 
         try {
-            setGroupOwners(rhandler);
+            setGroupOwners(ghandler);
         } catch (Exception e) {
             LOG.error("While setting group owners", e);
         }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/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
index 7dabe8f..e751522 100644
--- 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
@@ -25,29 +25,32 @@ import java.util.List;
 import java.util.Map;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.common.lib.types.AttributableType;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.MappingPurpose;
-import org.apache.syncope.common.lib.types.SubjectType;
 import org.apache.syncope.common.lib.types.SyncPolicySpec;
 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.AnyTypeDAO;
 import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
 import org.apache.syncope.core.persistence.api.dao.PolicyDAO;
 import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.SubjectDAO;
-import org.apache.syncope.core.persistence.api.dao.SubjectSearchDAO;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
+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.OrderByClause;
 import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
-import org.apache.syncope.core.persistence.api.dao.search.SubjectCond;
-import org.apache.syncope.core.persistence.api.entity.AttributableUtils;
-import org.apache.syncope.core.persistence.api.entity.AttributableUtilsFactory;
-import org.apache.syncope.core.persistence.api.entity.ExternalResource;
-import org.apache.syncope.core.persistence.api.entity.MappingItem;
+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.Subject;
 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;
@@ -56,7 +59,6 @@ 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.ObjectClass;
 import org.identityconnectors.framework.common.objects.OperationalAttributes;
 import org.identityconnectors.framework.common.objects.filter.EqualsFilter;
 import org.slf4j.Logger;
@@ -84,6 +86,15 @@ public class SyncUtils {
     @Autowired
     protected PlainSchemaDAO plainSchemaDAO;
 
+    @Autowired
+    protected AnyTypeDAO anyTypeDAO;
+
+    /**
+     * Any Object DAO.
+     */
+    @Autowired
+    protected AnyObjectDAO anyObjectDAO;
+
     /**
      * User DAO.
      */
@@ -100,43 +111,49 @@ public class SyncUtils {
      * Search DAO.
      */
     @Autowired
-    protected SubjectSearchDAO searchDAO;
+    protected AnySearchDAO searchDAO;
 
     @Autowired
-    protected AttributableUtilsFactory attrUtilsFactory;
+    protected AnyUtilsFactory anyUtilsFactory;
 
-    public Long findMatchingAttributableKey(
-            final ObjectClass oclass,
+    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;
 
-        final AttributableUtils attrUtils = attrUtilsFactory.getInstance(oclass);
+        AnyUtils anyUtils = anyUtilsFactory.getInstance(anyType.getKind());
 
-        final List<ConnectorObject> found = connector.search(oclass,
+        List<ConnectorObject> found = connector.search(provision.getObjectClass(),
                 new EqualsFilter(new Name(name)), connector.getOperationOptions(
-                        attrUtils.getMappingItems(resource, MappingPurpose.SYNCHRONIZATION)));
+                        anyUtils.getMappingItems(provision, MappingPurpose.SYNCHRONIZATION)));
 
         if (found.isEmpty()) {
-            LOG.debug("No {} found on {} with __NAME__ {}", oclass, resource, name);
+            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", oclass, resource, name);
+                LOG.warn("More than one {} found on {} with __NAME__ {} - taking first only",
+                        provision.getObjectClass(), resource, name);
             }
 
             ConnectorObject connObj = found.iterator().next();
             try {
-                List<Long> subjectKeys = findExisting(connObj.getUid().getUidValue(), connObj, resource, attrUtils);
-                if (subjectKeys.isEmpty()) {
-                    LOG.debug("No matching {} found for {}, aborting", attrUtils.getType(), connObj);
+                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 (subjectKeys.size() > 1) {
-                        LOG.warn("More than one {} found {} - taking first only", attrUtils.getType(), subjectKeys);
+                    if (anyKeys.size() > 1) {
+                        LOG.warn("More than one {} found {} - taking first only", anyUtils.getAnyTypeKind(), anyKeys);
                     }
 
-                    result = subjectKeys.iterator().next();
+                    result = anyKeys.iterator().next();
                 }
             } catch (IllegalArgumentException e) {
                 LOG.warn(e.getMessage());
@@ -146,21 +163,26 @@ public class SyncUtils {
         return result;
     }
 
-    private SubjectDAO<?, ?, ?> getSubjectDAO(final MappingItem accountIdItem) {
-        return AttributableType.USER == accountIdItem.getIntMappingType().getAttributableType() ? userDAO : groupDAO;
+    private AnyDAO<?> getAnyDAO(final MappingItem accountIdItem) {
+        return AnyTypeKind.USER == accountIdItem.getIntMappingType().getAnyTypeKind()
+                ? userDAO
+                : AnyTypeKind.ANY_OBJECT == accountIdItem.getIntMappingType().getAnyTypeKind()
+                        ? anyObjectDAO
+                        : groupDAO;
     }
 
-    private List<Long> findByAccountIdItem(
-            final String uid, final ExternalResource resource, final AttributableUtils attrUtils) {
-        final List<Long> result = new ArrayList<>();
+    private List<Long> findByConnObjectKeyItem(
+            final String uid, final Provision provision, final AnyUtils anyUtils) {
 
-        final MappingItem accountIdItem = attrUtils.getAccountIdItem(resource);
-        switch (accountIdItem.getIntMappingType()) {
+        List<Long> result = new ArrayList<>();
+
+        MappingItem connObjectKeyItem = anyUtils.getConnObjectKeyItem(provision);
+        switch (connObjectKeyItem.getIntMappingType()) {
             case UserPlainSchema:
             case GroupPlainSchema:
-                final PlainAttrValue value = attrUtils.newPlainAttrValue();
+                final PlainAttrValue value = anyUtils.newPlainAttrValue();
 
-                PlainSchema schema = plainSchemaDAO.find(accountIdItem.getIntAttrName(), attrUtils.plainSchemaClass());
+                PlainSchema schema = plainSchemaDAO.find(connObjectKeyItem.getIntAttrName());
                 if (schema == null) {
                     value.setStringValue(uid);
                 } else {
@@ -172,19 +194,18 @@ public class SyncUtils {
                     }
                 }
 
-                List<? extends Subject<?, ?, ?>> subjects =
-                        getSubjectDAO(accountIdItem).findByAttrValue(accountIdItem.getIntAttrName(), value, attrUtils);
-                for (Subject<?, ?, ?> subject : subjects) {
-                    result.add(subject.getKey());
+                List<? extends Any<?, ?, ?>> anys =
+                        getAnyDAO(connObjectKeyItem).findByAttrValue(connObjectKeyItem.getIntAttrName(), value);
+                for (Any<?, ?, ?> any : anys) {
+                    result.add(any.getKey());
                 }
                 break;
 
             case UserDerivedSchema:
             case GroupDerivedSchema:
-                subjects = getSubjectDAO(accountIdItem).
-                        findByDerAttrValue(accountIdItem.getIntAttrName(), uid, attrUtils);
-                for (Subject<?, ?, ?> subject : subjects) {
-                    result.add(subject.getKey());
+                anys = getAnyDAO(connObjectKeyItem).findByDerAttrValue(connObjectKeyItem.getIntAttrName(), uid);
+                for (Any<?, ?, ?> any : anys) {
+                    result.add(any.getKey());
                 }
                 break;
 
@@ -217,40 +238,40 @@ public class SyncUtils {
                 break;
 
             default:
-                LOG.error("Invalid accountId type '{}'", accountIdItem.getIntMappingType());
+                LOG.error("Invalid accountId type '{}'", connObjectKeyItem.getIntMappingType());
         }
 
         return result;
     }
 
-    private List<Long> search(final SearchCond searchCond, final SubjectType type) {
+    private List<Long> search(final SearchCond searchCond, final AnyTypeKind type) {
         final List<Long> result = new ArrayList<>();
 
-        List<Subject<?, ?, ?>> subjects = searchDAO.search(
+        List<Any<?, ?, ?>> anys = searchDAO.search(
                 SyncopeConstants.FULL_ADMIN_REALMS, searchCond, Collections.<OrderByClause>emptyList(), type);
-        for (Subject<?, ?, ?> subject : subjects) {
-            result.add(subject.getKey());
+        for (Any<?, ?, ?> any : anys) {
+            result.add(any.getKey());
         }
 
         return result;
     }
 
     private List<Long> findByCorrelationRule(
-            final ConnectorObject connObj, final SyncCorrelationRule rule, final SubjectType type) {
+            final ConnectorObject connObj, final SyncCorrelationRule rule, final AnyTypeKind type) {
 
         return search(rule.getSearchCond(connObj), type);
     }
 
-    private List<Long> findByAttributableSearch(
+    private List<Long> findByAnySearch(
             final ConnectorObject connObj,
             final List<String> altSearchSchemas,
-            final ExternalResource resource,
-            final AttributableUtils attrUtils) {
+            final Provision provision,
+            final AnyUtils anyUtils) {
 
         // search for external attribute's name/value of each specified name
-        final Map<String, Attribute> extValues = new HashMap<>();
+        Map<String, Attribute> extValues = new HashMap<>();
 
-        for (MappingItem item : attrUtils.getMappingItems(resource, MappingPurpose.SYNCHRONIZATION)) {
+        for (MappingItem item : anyUtils.getMappingItems(provision, MappingPurpose.SYNCHRONIZATION)) {
             extValues.put(item.getIntAttrName(), connObj.getAttributeByName(item.getExtAttrName()));
         }
 
@@ -285,7 +306,7 @@ public class SyncUtils {
             if ("key".equalsIgnoreCase(schema)
                     || "username".equalsIgnoreCase(schema) || "name".equalsIgnoreCase(schema)) {
 
-                SubjectCond cond = new SubjectCond();
+                AnyCond cond = new AnyCond();
                 cond.setSchema(schema);
                 cond.setType(type);
                 cond.setExpression(expression);
@@ -305,24 +326,13 @@ public class SyncUtils {
                     : SearchCond.getAndCond(searchCond, nodeCond);
         }
 
-        return search(searchCond, SubjectType.valueOf(attrUtils.getType().name()));
+        return search(searchCond, anyUtils.getAnyTypeKind());
     }
 
-    private SyncCorrelationRule getCorrelationRule(final AttributableType type, final SyncPolicySpec policySpec) {
-        String clazz;
-
-        switch (type) {
-            case USER:
-                clazz = policySpec.getUserJavaRule();
-                break;
-            case GROUP:
-                clazz = policySpec.getGroupJavaRule();
-                break;
-            case MEMBERSHIP:
-            case CONFIGURATION:
-            default:
-                clazz = null;
-        }
+    private SyncCorrelationRule getCorrelationRule(final Provision provision, final SyncPolicySpec policySpec) {
+        String clazz = policySpec.getItem(provision.getAnyType().getKey()) == null
+                ? null
+                : policySpec.getItem(provision.getAnyType().getKey()).getJavaRule();
 
         SyncCorrelationRule res = null;
 
@@ -337,22 +347,10 @@ public class SyncUtils {
         return res;
     }
 
-    private List<String> getAltSearchSchemas(final AttributableType type, final SyncPolicySpec policySpec) {
-        List<String> result = Collections.emptyList();
-
-        switch (type) {
-            case USER:
-                result = policySpec.getuAltSearchSchemas();
-                break;
-            case GROUP:
-                result = policySpec.getrAltSearchSchemas();
-                break;
-            case MEMBERSHIP:
-            case CONFIGURATION:
-            default:
-        }
-
-        return result;
+    private List<String> getAltSearchSchemas(final Provision provision, final SyncPolicySpec policySpec) {
+        return policySpec.getItem(provision.getAnyType().getKey()) == null
+                ? Collections.<String>emptyList()
+                : policySpec.getItem(provision.getAnyType().getKey()).getAltSearchSchemas();
     }
 
     /**
@@ -360,33 +358,33 @@ public class SyncUtils {
      *
      * @param uid for finding by account id
      * @param connObj for finding by attribute value
-     * @param resource external resource
-     * @param attrUtils attributable util
+     * @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 ExternalResource resource,
-            final AttributableUtils attrUtils) {
+            final Provision provision,
+            final AnyUtils anyUtils) {
 
         SyncPolicySpec syncPolicySpec = null;
-        if (resource.getSyncPolicy() != null) {
-            syncPolicySpec = resource.getSyncPolicy().getSpecification(SyncPolicySpec.class);
+        if (provision.getResource().getSyncPolicy() != null) {
+            syncPolicySpec = provision.getResource().getSyncPolicy().getSpecification(SyncPolicySpec.class);
         }
 
         SyncCorrelationRule syncRule = null;
         List<String> altSearchSchemas = null;
 
         if (syncPolicySpec != null) {
-            syncRule = getCorrelationRule(attrUtils.getType(), syncPolicySpec);
-            altSearchSchemas = getAltSearchSchemas(attrUtils.getType(), syncPolicySpec);
+            syncRule = getCorrelationRule(provision, syncPolicySpec);
+            altSearchSchemas = getAltSearchSchemas(provision, syncPolicySpec);
         }
 
         return syncRule == null ? altSearchSchemas == null || altSearchSchemas.isEmpty()
-                ? findByAccountIdItem(uid, resource, attrUtils)
-                : findByAttributableSearch(connObj, altSearchSchemas, resource, attrUtils)
-                : findByCorrelationRule(connObj, syncRule, SubjectType.valueOf(attrUtils.getType().name()));
+                ? findByConnObjectKeyItem(uid, provision, anyUtils)
+                : findByAnySearch(connObj, altSearchSchemas, provision, anyUtils)
+                : findByCorrelationRule(connObj, syncRule, anyUtils.getAnyTypeKind());
     }
 
     public Boolean readEnabled(final ConnectorObject connectorObject, final ProvisioningTask task) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/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
index 87d72e6..dc1ea5a 100644
--- 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
@@ -22,15 +22,14 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import org.apache.syncope.common.lib.mod.UserMod;
-import org.apache.syncope.common.lib.to.AbstractSubjectTO;
+import org.apache.syncope.common.lib.to.AnyTO;
 import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.common.lib.types.AttributableType;
+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.AttributableUtils;
-import org.apache.syncope.core.persistence.api.entity.Mapping;
-import org.apache.syncope.core.persistence.api.entity.MappingItem;
-import org.apache.syncope.core.persistence.api.entity.Subject;
+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.resource.MappingItem;
 import org.apache.syncope.core.persistence.api.entity.user.User;
 import org.apache.syncope.core.provisioning.api.TimeoutException;
 import org.apache.syncope.core.provisioning.api.sync.UserPushResultHandler;
@@ -41,31 +40,31 @@ import org.identityconnectors.framework.common.objects.Uid;
 public class UserPushResultHandlerImpl extends AbstractPushResultHandler implements UserPushResultHandler {
 
     @Override
-    protected AttributableUtils getAttributableUtils() {
-        return attrUtilsFactory.getInstance(AttributableType.USER);
+    protected AnyUtils getAnyUtils() {
+        return anyUtilsFactory.getInstance(AnyTypeKind.USER);
     }
 
     @Override
-    protected Subject<?, ?, ?> deprovision(final Subject<?, ?, ?> sbj) {
-        final UserTO before = userDataBinder.getUserTO(sbj.getKey());
+    protected Any<?, ?, ?> deprovision(final Any<?, ?, ?> sbj) {
+        UserTO before = userDataBinder.getUserTO(sbj.getKey());
 
-        final List<String> noPropResources = new ArrayList<>(before.getResources());
+        List<String> noPropResources = new ArrayList<>(before.getResources());
         noPropResources.remove(profile.getTask().getResource().getKey());
 
         taskExecutor.execute(propagationManager.getUserDeleteTasks(before.getKey(),
                 Collections.singleton(profile.getTask().getResource().getKey()), noPropResources));
 
-        return userDAO.authFetch(before.getKey());
+        return userDAO.authFind(before.getKey());
     }
 
     @Override
-    protected Subject<?, ?, ?> provision(final Subject<?, ?, ?> sbj, final Boolean enabled) {
-        final UserTO before = userDataBinder.getUserTO(sbj.getKey());
+    protected Any<?, ?, ?> provision(final Any<?, ?, ?> sbj, final Boolean enabled) {
+        UserTO before = userDataBinder.getUserTO(sbj.getKey());
 
-        final List<String> noPropResources = new ArrayList<>(before.getResources());
+        List<String> noPropResources = new ArrayList<>(before.getResources());
         noPropResources.remove(profile.getTask().getResource().getKey());
 
-        final PropagationByResource propByRes = new PropagationByResource();
+        PropagationByResource propByRes = new PropagationByResource();
         propByRes.add(ResourceOperation.CREATE, profile.getTask().getResource().getKey());
 
         taskExecutor.execute(propagationManager.getUserCreateTasks(
@@ -74,15 +73,14 @@ public class UserPushResultHandlerImpl extends AbstractPushResultHandler impleme
                 propByRes,
                 null,
                 Collections.unmodifiableCollection(before.getVirAttrs()),
-                Collections.unmodifiableCollection(before.getMemberships()),
                 noPropResources));
 
-        return userDAO.authFetch(before.getKey());
+        return userDAO.authFind(before.getKey());
     }
 
     @Override
-    protected Subject<?, ?, ?> link(final Subject<?, ?, ?> sbj, final Boolean unlink) {
-        final UserMod userMod = new UserMod();
+    protected Any<?, ?, ?> link(final Any<?, ?, ?> sbj, final Boolean unlink) {
+        UserMod userMod = new UserMod();
         userMod.setKey(sbj.getKey());
 
         if (unlink) {
@@ -93,12 +91,12 @@ public class UserPushResultHandlerImpl extends AbstractPushResultHandler impleme
 
         uwfAdapter.update(userMod);
 
-        return userDAO.authFetch(userMod.getKey());
+        return userDAO.authFind(userMod.getKey());
     }
 
     @Override
-    protected Subject<?, ?, ?> unassign(final Subject<?, ?, ?> sbj) {
-        final UserMod userMod = new UserMod();
+    protected Any<?, ?, ?> unassign(final Any<?, ?, ?> sbj) {
+        UserMod userMod = new UserMod();
         userMod.setKey(sbj.getKey());
         userMod.getResourcesToRemove().add(profile.getTask().getResource().getKey());
         uwfAdapter.update(userMod);
@@ -106,8 +104,8 @@ public class UserPushResultHandlerImpl extends AbstractPushResultHandler impleme
     }
 
     @Override
-    protected Subject<?, ?, ?> assign(final Subject<?, ?, ?> sbj, final Boolean enabled) {
-        final UserMod userMod = new UserMod();
+    protected Any<?, ?, ?> assign(final Any<?, ?, ?> sbj, final Boolean enabled) {
+        UserMod userMod = new UserMod();
         userMod.setKey(sbj.getKey());
         userMod.getResourcesToAdd().add(profile.getTask().getResource().getKey());
         uwfAdapter.update(userMod);
@@ -115,12 +113,12 @@ public class UserPushResultHandlerImpl extends AbstractPushResultHandler impleme
     }
 
     @Override
-    protected String getName(final Subject<?, ?, ?> subject) {
+    protected String getName(final Any<?, ?, ?> subject) {
         return User.class.cast(subject).getUsername();
     }
 
     @Override
-    protected AbstractSubjectTO getSubjectTO(final long key) {
+    protected AnyTO getAnyTO(final long key) {
         try {
             return userDataBinder.getUserTO(key);
         } catch (Exception e) {
@@ -130,9 +128,9 @@ public class UserPushResultHandlerImpl extends AbstractPushResultHandler impleme
     }
 
     @Override
-    protected Subject<?, ?, ?> getSubject(final long key) {
+    protected Any<?, ?, ?> getAny(final long key) {
         try {
-            return userDAO.authFetch(key);
+            return userDAO.authFind(key);
         } catch (Exception e) {
             LOG.warn("Error retrieving user {}", key, e);
             return null;
@@ -140,14 +138,13 @@ public class UserPushResultHandlerImpl extends AbstractPushResultHandler impleme
     }
 
     @Override
-    protected ConnectorObject getRemoteObject(final String accountId) {
+    protected ConnectorObject getRemoteObject(final String connObjectKey, final ObjectClass objectClass) {
         ConnectorObject obj = null;
-
         try {
-            final Uid uid = new Uid(accountId);
+            Uid uid = new Uid(connObjectKey);
 
             obj = profile.getConnector().getObject(
-                    ObjectClass.ACCOUNT,
+                    objectClass,
                     uid,
                     profile.getConnector().getOperationOptions(Collections.<MappingItem>emptySet()));
 
@@ -155,13 +152,9 @@ public class UserPushResultHandlerImpl extends AbstractPushResultHandler impleme
             LOG.debug("Request timeout", toe);
             throw toe;
         } catch (RuntimeException ignore) {
-            LOG.debug("While resolving {}", accountId, ignore);
+            LOG.debug("While resolving {}", connObjectKey, ignore);
         }
-        return obj;
-    }
 
-    @Override
-    protected Mapping<?> getMapping() {
-        return profile.getTask().getResource().getUmapping();
+        return obj;
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/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
index d32a855..3e99286 100644
--- 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
@@ -21,13 +21,13 @@ package org.apache.syncope.core.provisioning.java.sync;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
-import org.apache.syncope.common.lib.mod.AbstractSubjectMod;
+import org.apache.syncope.common.lib.mod.AnyMod;
 import org.apache.syncope.common.lib.mod.UserMod;
-import org.apache.syncope.common.lib.to.AbstractSubjectTO;
+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.AttributableType;
-import org.apache.syncope.core.persistence.api.entity.AttributableUtils;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.core.persistence.api.entity.AnyUtils;
 import org.apache.syncope.core.provisioning.api.sync.ProvisioningResult;
 import org.apache.syncope.core.provisioning.api.sync.UserSyncResultHandler;
 import org.identityconnectors.framework.common.objects.SyncDelta;
@@ -35,17 +35,17 @@ import org.identityconnectors.framework.common.objects.SyncDelta;
 public class UserSyncResultHandlerImpl extends AbstractSyncResultHandler implements UserSyncResultHandler {
 
     @Override
-    protected AttributableUtils getAttributableUtils() {
-        return attrUtilsFactory.getInstance(AttributableType.USER);
+    protected AnyUtils getAnyUtils() {
+        return anyUtilsFactory.getInstance(AnyTypeKind.USER);
     }
 
     @Override
-    protected String getName(final AbstractSubjectTO subjectTO) {
+    protected String getName(final AnyTO subjectTO) {
         return UserTO.class.cast(subjectTO).getUsername();
     }
 
     @Override
-    protected AbstractSubjectTO getSubjectTO(final long key) {
+    protected AnyTO getAnyTO(final long key) {
         try {
             return userDataBinder.getUserTO(key);
         } catch (Exception e) {
@@ -55,20 +55,7 @@ public class UserSyncResultHandlerImpl extends AbstractSyncResultHandler impleme
     }
 
     @Override
-    protected AbstractSubjectMod getSubjectMod(
-            final AbstractSubjectTO subjectTO, final SyncDelta delta) {
-
-        return connObjectUtils.getAttributableMod(subjectTO.getKey(),
-                delta.getObject(),
-                subjectTO,
-                profile.getTask(),
-                getAttributableUtils());
-    }
-
-    @Override
-    protected AbstractSubjectTO doCreate(
-            final AbstractSubjectTO subjectTO, final SyncDelta delta, final ProvisioningResult result) {
-
+    protected AnyTO doCreate(final AnyTO subjectTO, final SyncDelta delta, final ProvisioningResult result) {
         UserTO userTO = UserTO.class.cast(subjectTO);
 
         Boolean enabled = syncUtilities.readEnabled(delta.getObject(), profile.getTask());
@@ -81,8 +68,8 @@ public class UserSyncResultHandlerImpl extends AbstractSyncResultHandler impleme
     }
 
     @Override
-    protected AbstractSubjectTO doLink(
-            final AbstractSubjectTO before,
+    protected AnyTO doLink(
+            final AnyTO before,
             final ProvisioningResult result,
             final boolean unlink) {
 
@@ -99,13 +86,13 @@ public class UserSyncResultHandlerImpl extends AbstractSyncResultHandler impleme
     }
 
     @Override
-    protected AbstractSubjectTO doUpdate(
-            final AbstractSubjectTO before,
-            final AbstractSubjectMod subjectMod,
+    protected AnyTO doUpdate(
+            final AnyTO before,
+            final AnyMod anyMod,
             final SyncDelta delta,
             final ProvisioningResult result) {
 
-        final UserMod userMod = UserMod.class.cast(subjectMod);
+        final UserMod userMod = UserMod.class.cast(anyMod);
         final Boolean enabled = syncUtilities.readEnabled(delta.getObject(), profile.getTask());
 
         Map.Entry<Long, List<PropagationStatus>> updated = userProvisioningManager.update(userMod, before.getKey(),

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/ConnectorManagerTest.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/ConnectorManagerTest.java b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/ConnectorManagerTest.java
index 9ddc91d..138fee3 100644
--- a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/ConnectorManagerTest.java
+++ b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/ConnectorManagerTest.java
@@ -18,12 +18,10 @@
  */
 package org.apache.syncope.core.provisioning.java;
 
-import org.apache.syncope.core.provisioning.java.ConnectorManager;
-
 import static org.junit.Assert.assertEquals;
 
 import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
-import org.apache.syncope.core.persistence.api.entity.ExternalResource;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.provisioning.api.ConnIdBundleManager;
 import org.apache.syncope.core.provisioning.api.Connector;
 import org.apache.syncope.core.misc.spring.ApplicationContextProvider;

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderTest.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderTest.java b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderTest.java
index a8305a6..51245e4 100644
--- a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderTest.java
+++ b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderTest.java
@@ -27,15 +27,17 @@ import java.util.HashSet;
 import java.util.Set;
 import org.apache.syncope.common.lib.to.MappingItemTO;
 import org.apache.syncope.common.lib.to.MappingTO;
+import org.apache.syncope.common.lib.to.ProvisionTO;
 import org.apache.syncope.common.lib.to.ResourceTO;
 import org.apache.syncope.common.lib.types.IntMappingType;
 import org.apache.syncope.common.lib.types.MappingPurpose;
 import org.apache.syncope.common.lib.types.PropagationMode;
+import org.apache.syncope.core.persistence.api.dao.AnyTypeDAO;
 import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
 import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
-import org.apache.syncope.core.persistence.api.entity.ExternalResource;
-import org.apache.syncope.core.persistence.api.entity.MappingItem;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainSchema;
+import org.apache.syncope.core.persistence.api.entity.PlainSchema;
+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.provisioning.api.data.ResourceDataBinder;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -45,6 +47,9 @@ import org.springframework.transaction.annotation.Transactional;
 public class ResourceDataBinderTest extends AbstractTest {
 
     @Autowired
+    private AnyTypeDAO anyTypeDAO;
+
+    @Autowired
     private ExternalResourceDAO resourceDAO;
 
     @Autowired
@@ -55,12 +60,14 @@ public class ResourceDataBinderTest extends AbstractTest {
 
     @Test
     public void issue42() {
-        UPlainSchema userId = plainSchemaDAO.find("userId", UPlainSchema.class);
+        PlainSchema userId = plainSchemaDAO.find("userId");
 
         Set<MappingItem> beforeUserIdMappings = new HashSet<>();
         for (ExternalResource res : resourceDAO.findAll()) {
-            if (res.getUmapping() != null) {
-                for (MappingItem mapItem : res.getUmapping().getItems()) {
+            if (res.getProvision(anyTypeDAO.findUser()) != null
+                    && res.getProvision(anyTypeDAO.findUser()).getMapping() != null) {
+
+                for (MappingItem mapItem : res.getProvision(anyTypeDAO.findUser()).getMapping().getItems()) {
                     if (userId.getKey().equals(mapItem.getIntAttrName())) {
                         beforeUserIdMappings.add(mapItem);
                     }
@@ -74,8 +81,12 @@ public class ResourceDataBinderTest extends AbstractTest {
         resourceTO.setPropagationMode(PropagationMode.ONE_PHASE);
         resourceTO.setEnforceMandatoryCondition(true);
 
+        ProvisionTO provisionTO = new ProvisionTO();
+        provisionTO.setAnyType("user");
+        resourceTO.getProvisions().add(provisionTO);
+
         MappingTO mapping = new MappingTO();
-        resourceTO.setUmapping(mapping);
+        provisionTO.setMapping(mapping);
 
         MappingItemTO item = new MappingItemTO();
         item.setIntAttrName("userId");
@@ -84,13 +95,13 @@ public class ResourceDataBinderTest extends AbstractTest {
         item.setAccountid(true);
         item.setMandatoryCondition("false");
         item.setPurpose(MappingPurpose.BOTH);
-        mapping.setAccountIdItem(item);
+        mapping.setConnObjectKeyItem(item);
 
         ExternalResource resource = resourceDataBinder.create(resourceTO);
         resource = resourceDAO.save(resource);
         assertNotNull(resource);
-        assertNotNull(resource.getUmapping());
-        assertEquals(1, resource.getUmapping().getItems().size());
+        assertNotNull(resource.getProvision(anyTypeDAO.findUser()).getMapping());
+        assertEquals(1, resource.getProvision(anyTypeDAO.findUser()).getMapping().getItems().size());
 
         resourceDAO.flush();
 
@@ -98,12 +109,14 @@ public class ResourceDataBinderTest extends AbstractTest {
         assertNotNull(actual);
         assertEquals(resource, actual);
 
-        userId = plainSchemaDAO.find("userId", UPlainSchema.class);
+        userId = plainSchemaDAO.find("userId");
 
         Set<MappingItem> afterUserIdMappings = new HashSet<>();
         for (ExternalResource res : resourceDAO.findAll()) {
-            if (res.getUmapping() != null) {
-                for (MappingItem mapItem : res.getUmapping().getItems()) {
+            if (res.getProvision(anyTypeDAO.findUser()) != null
+                    && res.getProvision(anyTypeDAO.findUser()).getMapping() != null) {
+
+                for (MappingItem mapItem : res.getProvision(anyTypeDAO.findUser()).getMapping().getItems()) {
                     if (userId.getKey().equals(mapItem.getIntAttrName())) {
                         afterUserIdMappings.add(mapItem);
                     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/GroupServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/GroupServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/GroupServiceImpl.java
index ee4825e..c8e42a1 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/GroupServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/GroupServiceImpl.java
@@ -34,8 +34,8 @@ import org.apache.syncope.common.lib.types.ResourceAssociationActionType;
 import org.apache.syncope.common.lib.types.ResourceDeassociationActionType;
 import org.apache.syncope.common.lib.wrap.ResourceName;
 import org.apache.syncope.common.rest.api.CollectionWrapper;
-import org.apache.syncope.common.rest.api.beans.SubjectListQuery;
-import org.apache.syncope.common.rest.api.beans.SubjectSearchQuery;
+import org.apache.syncope.common.rest.api.beans.AnyListQuery;
+import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
 import org.apache.syncope.common.rest.api.service.GroupService;
 import org.apache.syncope.core.logic.GroupLogic;
 import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
@@ -65,7 +65,7 @@ public class GroupServiceImpl extends AbstractServiceImpl implements GroupServic
     }
 
     @Override
-    public PagedResult<GroupTO> list(final SubjectListQuery listQuery) {
+    public PagedResult<GroupTO> list(final AnyListQuery listQuery) {
         CollectionUtils.transform(listQuery.getRealms(), new Transformer<String, String>() {
 
             @Override
@@ -91,7 +91,7 @@ public class GroupServiceImpl extends AbstractServiceImpl implements GroupServic
     }
 
     @Override
-    public PagedResult<GroupTO> search(final SubjectSearchQuery searchQuery) {
+    public PagedResult<GroupTO> search(final AnySearchQuery searchQuery) {
         CollectionUtils.transform(searchQuery.getRealms(), new Transformer<String, String>() {
 
             @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ResourceServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ResourceServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ResourceServiceImpl.java
index dfc4391..7ace502 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ResourceServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ResourceServiceImpl.java
@@ -23,17 +23,18 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import javax.ws.rs.core.Response;
-import org.apache.syncope.common.lib.to.AbstractAttributableTO;
+import org.apache.syncope.common.lib.to.AnyTO;
 import org.apache.syncope.common.lib.to.BulkAction;
 import org.apache.syncope.common.lib.to.BulkActionResult;
 import org.apache.syncope.common.lib.to.ConnObjectTO;
 import org.apache.syncope.common.lib.to.ResourceTO;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.ResourceDeassociationActionType;
-import org.apache.syncope.common.lib.types.SubjectType;
-import org.apache.syncope.common.lib.wrap.SubjectKey;
+import org.apache.syncope.common.lib.wrap.AnyKey;
 import org.apache.syncope.common.rest.api.RESTHeaders;
 import org.apache.syncope.common.rest.api.service.ResourceService;
 import org.apache.syncope.core.logic.AbstractResourceAssociator;
+import org.apache.syncope.core.logic.AnyObjectLogic;
 import org.apache.syncope.core.logic.ResourceLogic;
 import org.apache.syncope.core.logic.GroupLogic;
 import org.apache.syncope.core.logic.UserLogic;
@@ -47,6 +48,9 @@ public class ResourceServiceImpl extends AbstractServiceImpl implements Resource
     private ResourceLogic logic;
 
     @Autowired
+    private AnyObjectLogic anyObjectLogic;
+
+    @Autowired
     private UserLogic userLogic;
 
     @Autowired
@@ -83,8 +87,8 @@ public class ResourceServiceImpl extends AbstractServiceImpl implements Resource
     }
 
     @Override
-    public ConnObjectTO getConnectorObject(final String resourceKey, final SubjectType type, final Long key) {
-        return logic.getConnectorObject(resourceKey, type, key);
+    public ConnObjectTO readConnObject(final String resourceKey, final String anyTypeKey, final Long key) {
+        return logic.readConnObject(resourceKey, anyTypeKey, key);
     }
 
     @Override
@@ -93,17 +97,20 @@ public class ResourceServiceImpl extends AbstractServiceImpl implements Resource
     }
 
     @Override
-    public BulkActionResult bulkDeassociation(final String resourceKey, final SubjectType subjectType,
-            final ResourceDeassociationActionType type, final List<SubjectKey> subjectKeys) {
+    public BulkActionResult bulkDeassociation(
+            final String resourceKey, final String anyTypeKey, final ResourceDeassociationActionType type,
+            final List<AnyKey> keys) {
 
-        AbstractResourceAssociator<? extends AbstractAttributableTO> associator = subjectType == SubjectType.USER
+        AbstractResourceAssociator<? extends AnyTO> associator = anyTypeKey.equalsIgnoreCase(AnyTypeKind.USER.name())
                 ? userLogic
-                : groupLogic;
+                : anyTypeKey.equalsIgnoreCase(AnyTypeKind.GROUP.name())
+                        ? groupLogic
+                        : anyObjectLogic;
 
-        final BulkActionResult res = new BulkActionResult();
+        BulkActionResult res = new BulkActionResult();
 
-        for (SubjectKey key : subjectKeys) {
-            final Set<String> resources = Collections.singleton(resourceKey);
+        for (AnyKey key : keys) {
+            Set<String> resources = Collections.singleton(resourceKey);
             try {
                 switch (type) {
                     case DEPROVISION:
@@ -123,7 +130,7 @@ public class ResourceServiceImpl extends AbstractServiceImpl implements Resource
 
                 res.add(key, BulkActionResult.Status.SUCCESS);
             } catch (Exception e) {
-                LOG.warn("While executing {} on {} {}", type, subjectType, key.getElement(), e);
+                LOG.warn("While executing {} on {} {}", type, anyTypeKey, key.getElement(), e);
                 res.add(key, BulkActionResult.Status.FAILURE);
             }
         }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SchemaServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SchemaServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SchemaServiceImpl.java
index 3082c94..c8d2f26 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SchemaServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SchemaServiceImpl.java
@@ -22,7 +22,6 @@ import java.net.URI;
 import java.util.List;
 import javax.ws.rs.core.Response;
 import org.apache.syncope.common.lib.to.AbstractSchemaTO;
-import org.apache.syncope.common.lib.types.AttributableType;
 import org.apache.syncope.common.lib.types.SchemaType;
 import org.apache.syncope.common.rest.api.RESTHeaders;
 import org.apache.syncope.common.rest.api.service.SchemaService;
@@ -37,10 +36,8 @@ public class SchemaServiceImpl extends AbstractServiceImpl implements SchemaServ
     private SchemaLogic logic;
 
     @Override
-    public <T extends AbstractSchemaTO> Response create(final AttributableType attrType, final SchemaType schemaType,
-            final T schemaTO) {
-
-        T created = logic.create(attrType, schemaType, schemaTO);
+    public <T extends AbstractSchemaTO> Response create(final SchemaType schemaType, final T schemaTO) {
+        T created = logic.create(schemaType, schemaTO);
 
         URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
         return Response.created(location).
@@ -49,27 +46,25 @@ public class SchemaServiceImpl extends AbstractServiceImpl implements SchemaServ
     }
 
     @Override
-    public void delete(final AttributableType attrType, final SchemaType schemaType, final String schemaKey) {
-        logic.delete(attrType, schemaType, schemaKey);
+    public void delete(final SchemaType schemaType, final String schemaKey) {
+        logic.delete(schemaType, schemaKey);
     }
 
     @Override
-    public <T extends AbstractSchemaTO> List<T> list(final AttributableType attrType, final SchemaType schemaType) {
-        return logic.list(attrType, schemaType);
+    public <T extends AbstractSchemaTO> List<T> list(final SchemaType schemaType) {
+        return logic.list(schemaType);
     }
 
     @Override
-    public <T extends AbstractSchemaTO> T read(final AttributableType attrType, final SchemaType schemaType,
-            final String schemaKey) {
-
-        return logic.read(attrType, schemaType, schemaKey);
+    public <T extends AbstractSchemaTO> T read(final SchemaType schemaType, final String schemaKey) {
+        return logic.read(schemaType, schemaKey);
     }
 
     @Override
-    public <T extends AbstractSchemaTO> void update(final AttributableType attrType, final SchemaType schemaType,
-            final String schemaKey, final T schemaTO) {
+    public <T extends AbstractSchemaTO> void update(
+            final SchemaType schemaType, final String schemaKey, final T schemaTO) {
 
         schemaTO.setKey(schemaKey);
-        logic.update(attrType, schemaType, schemaTO);
+        logic.update(schemaType, schemaTO);
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserServiceImpl.java
index a758993..919cb0a 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserServiceImpl.java
@@ -38,8 +38,8 @@ import org.apache.syncope.common.lib.types.ResourceDeassociationActionType;
 import org.apache.syncope.common.lib.wrap.ResourceName;
 import org.apache.syncope.common.rest.api.CollectionWrapper;
 import org.apache.syncope.common.rest.api.RESTHeaders;
-import org.apache.syncope.common.rest.api.beans.SubjectListQuery;
-import org.apache.syncope.common.rest.api.beans.SubjectSearchQuery;
+import org.apache.syncope.common.rest.api.beans.AnyListQuery;
+import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
 import org.apache.syncope.common.rest.api.service.UserService;
 import org.apache.syncope.core.logic.UserLogic;
 import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
@@ -83,7 +83,7 @@ public class UserServiceImpl extends AbstractServiceImpl implements UserService
     }
 
     @Override
-    public PagedResult<UserTO> list(final SubjectListQuery listQuery) {
+    public PagedResult<UserTO> list(final AnyListQuery listQuery) {
         CollectionUtils.transform(listQuery.getRealms(), new Transformer<String, String>() {
 
             @Override
@@ -109,7 +109,7 @@ public class UserServiceImpl extends AbstractServiceImpl implements UserService
     }
 
     @Override
-    public PagedResult<UserTO> search(final SubjectSearchQuery searchQuery) {
+    public PagedResult<UserTO> search(final AnySearchQuery searchQuery) {
         CollectionUtils.transform(searchQuery.getRealms(), new Transformer<String, String>() {
 
             @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/WorkflowServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/WorkflowServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/WorkflowServiceImpl.java
index 30229a6..5b82db0 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/WorkflowServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/WorkflowServiceImpl.java
@@ -23,7 +23,7 @@ import java.io.OutputStream;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.StreamingOutput;
-import org.apache.syncope.common.lib.types.SubjectType;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.rest.api.RESTHeaders;
 import org.apache.syncope.common.rest.api.service.WorkflowService;
 import org.apache.syncope.core.logic.WorkflowLogic;
@@ -37,7 +37,7 @@ public class WorkflowServiceImpl extends AbstractServiceImpl implements Workflow
     private WorkflowLogic logic;
 
     @Override
-    public Response exportDefinition(final SubjectType kind) {
+    public Response exportDefinition(final AnyTypeKind kind) {
         final MediaType accept =
                 messageContext.getHttpHeaders().getAcceptableMediaTypes().contains(MediaType.APPLICATION_JSON_TYPE)
                         ? MediaType.APPLICATION_JSON_TYPE
@@ -47,8 +47,10 @@ public class WorkflowServiceImpl extends AbstractServiceImpl implements Workflow
 
             @Override
             public void write(final OutputStream os) throws IOException {
-                if (kind == SubjectType.USER) {
+                if (kind == AnyTypeKind.USER) {
                     logic.exportUserDefinition(accept, os);
+                } else if (kind == AnyTypeKind.ANY_OBJECT) {
+                    logic.exportAnyObjectDefinition(accept, os);
                 } else {
                     logic.exportGroupDefinition(accept, os);
                 }
@@ -61,13 +63,15 @@ public class WorkflowServiceImpl extends AbstractServiceImpl implements Workflow
     }
 
     @Override
-    public Response exportDiagram(final SubjectType kind) {
+    public Response exportDiagram(final AnyTypeKind kind) {
         StreamingOutput sout = new StreamingOutput() {
 
             @Override
             public void write(final OutputStream os) throws IOException {
-                if (kind == SubjectType.USER) {
+                if (kind == AnyTypeKind.USER) {
                     logic.exportUserDiagram(os);
+                } else if (kind == AnyTypeKind.ANY_OBJECT) {
+                    logic.exportAnyObjectDiagram(os);
                 } else {
                     logic.exportGroupDiagram(os);
                 }
@@ -80,14 +84,16 @@ public class WorkflowServiceImpl extends AbstractServiceImpl implements Workflow
     }
 
     @Override
-    public void importDefinition(final SubjectType kind, final String definition) {
+    public void importDefinition(final AnyTypeKind kind, final String definition) {
         final MediaType contentType =
                 messageContext.getHttpHeaders().getMediaType().equals(MediaType.APPLICATION_JSON_TYPE)
                         ? MediaType.APPLICATION_JSON_TYPE
                         : MediaType.APPLICATION_XML_TYPE;
 
-        if (kind == SubjectType.USER) {
+        if (kind == AnyTypeKind.USER) {
             logic.importUserDefinition(contentType, definition);
+        } else if (kind == AnyTypeKind.ANY_OBJECT) {
+            logic.importAnyObjectDefinition(contentType, definition);
         } else {
             logic.importGroupDefinition(contentType, definition);
         }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java
index 4c89caf..938081f 100644
--- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java
+++ b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java
@@ -439,7 +439,7 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter {
 
     @Override
     public WorkflowResult<Long> execute(final UserTO userTO, final String taskId) {
-        User user = userDAO.authFetch(userTO.getKey());
+        User user = userDAO.authFind(userTO.getKey());
 
         final Map<String, Object> variables = new HashMap<>();
         variables.put(USER_TO, userTO);

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeUserQueryImpl.java
----------------------------------------------------------------------
diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeUserQueryImpl.java b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeUserQueryImpl.java
index 506455f..caa8a05 100644
--- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeUserQueryImpl.java
+++ b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/SyncopeUserQueryImpl.java
@@ -30,8 +30,8 @@ import org.apache.commons.collections4.Transformer;
 import org.apache.syncope.common.lib.SyncopeConstants;
 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.membership.Membership;
 import org.apache.syncope.core.persistence.api.entity.group.Group;
+import org.apache.syncope.core.persistence.api.entity.user.UMembership;
 
 public class SyncopeUserQueryImpl implements UserQuery {
 
@@ -152,10 +152,9 @@ public class SyncopeUserQueryImpl implements UserQuery {
                 result = Collections.<User>emptyList();
             } else {
                 result = new ArrayList<>();
-                List<Membership> memberships = groupDAO.findMemberships(group);
-                User user;
-                for (Membership membership : memberships) {
-                    user = fromSyncopeUser(membership.getUser());
+                List<UMembership> memberships = groupDAO.findUMemberships(group);
+                for (UMembership membership : memberships) {
+                    User user = fromSyncopeUser(membership.getLeftEnd());
                     if (!result.contains(user)) {
                         result.add(user);
                     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/AnyObjectWorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/AnyObjectWorkflowAdapter.java b/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/AnyObjectWorkflowAdapter.java
new file mode 100644
index 0000000..4927388
--- /dev/null
+++ b/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/AnyObjectWorkflowAdapter.java
@@ -0,0 +1,61 @@
+/*
+ * 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.workflow.api;
+
+import org.apache.syncope.core.provisioning.api.WorkflowResult;
+import org.apache.syncope.common.lib.mod.AnyObjectMod;
+import org.apache.syncope.common.lib.to.AnyObjectTO;
+
+/**
+ * Interface for calling underlying workflow implementations.
+ */
+public interface AnyObjectWorkflowAdapter extends WorkflowAdapter {
+
+    /**
+     * Create a anyObject.
+     *
+     * @param anyObjectTO anyObject to be created and whether to propagate it as active
+     * @return anyObject just created
+     */
+    WorkflowResult<Long> create(AnyObjectTO anyObjectTO);
+
+    /**
+     * Execute a task on a anyObject.
+     *
+     * @param anyObjectTO anyObject to be subject to task
+     * @param taskId to be executed
+     * @return anyObject just updated
+     */
+    WorkflowResult<Long> execute(AnyObjectTO anyObjectTO, String taskId);
+
+    /**
+     * Update a anyObject.
+     *
+     * @param anyObjectMod modification set to be performed
+     * @return anyObject just updated and propagations to be performed
+     */
+    WorkflowResult<Long> update(AnyObjectMod anyObjectMod);
+
+    /**
+     * Delete a anyObject.
+     *
+     * @param anyObjectKey anyObject to be deleted
+     */
+    void delete(Long anyObjectKey);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/WorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/WorkflowAdapter.java b/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/WorkflowAdapter.java
index 0c92d66..faf954a 100644
--- a/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/WorkflowAdapter.java
+++ b/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/WorkflowAdapter.java
@@ -21,7 +21,7 @@ package org.apache.syncope.core.workflow.api;
 import org.apache.syncope.core.provisioning.api.WorkflowResult;
 import java.io.OutputStream;
 import java.util.List;
-import org.apache.syncope.common.lib.mod.AbstractAttributableMod;
+import org.apache.syncope.common.lib.mod.AnyMod;
 import org.apache.syncope.common.lib.to.WorkflowFormTO;
 
 public interface WorkflowAdapter {
@@ -79,7 +79,7 @@ public interface WorkflowAdapter {
     WorkflowFormTO getForm(String workflowId);
 
     /**
-     * Claim a form for a given user.
+     * Claim a form for a given object.
      *
      * @param taskId Workflow task to which the form is associated
      * @return updated form
@@ -90,7 +90,7 @@ public interface WorkflowAdapter {
      * Submit a form.
      *
      * @param form to be submitted
-     * @return user updated by this form submit
+     * @return object updated by this form submit
      */
-    WorkflowResult<? extends AbstractAttributableMod> submitForm(WorkflowFormTO form);
+    WorkflowResult<? extends AnyMod> submitForm(WorkflowFormTO form);
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/AbstractGroupWorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/AbstractGroupWorkflowAdapter.java b/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/AbstractGroupWorkflowAdapter.java
index 30bfae6..97a8b1f 100644
--- a/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/AbstractGroupWorkflowAdapter.java
+++ b/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/AbstractGroupWorkflowAdapter.java
@@ -49,13 +49,13 @@ public abstract class AbstractGroupWorkflowAdapter implements GroupWorkflowAdapt
 
     @Override
     public WorkflowResult<Long> update(final GroupMod groupMod) {
-        return doUpdate(groupDAO.authFetch(groupMod.getKey()), groupMod);
+        return doUpdate(groupDAO.authFind(groupMod.getKey()), groupMod);
     }
 
     protected abstract void doDelete(Group group);
 
     @Override
     public void delete(final Long groupKey) {
-        doDelete(groupDAO.authFetch(groupKey));
+        doDelete(groupDAO.authFind(groupKey));
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/AbstractUserWorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/AbstractUserWorkflowAdapter.java b/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/AbstractUserWorkflowAdapter.java
index b1c3b4a..fc75987 100644
--- a/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/AbstractUserWorkflowAdapter.java
+++ b/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/AbstractUserWorkflowAdapter.java
@@ -62,21 +62,21 @@ public abstract class AbstractUserWorkflowAdapter implements UserWorkflowAdapter
 
     @Override
     public WorkflowResult<Long> activate(final Long userKey, final String token) {
-        return doActivate(userDAO.authFetch(userKey), token);
+        return doActivate(userDAO.authFind(userKey), token);
     }
 
     protected abstract WorkflowResult<Pair<UserMod, Boolean>> doUpdate(User user, UserMod userMod);
 
     @Override
     public WorkflowResult<Pair<UserMod, Boolean>> update(final UserMod userMod) {
-        return doUpdate(userDAO.authFetch(userMod.getKey()), userMod);
+        return doUpdate(userDAO.authFind(userMod.getKey()), userMod);
     }
 
     protected abstract WorkflowResult<Long> doSuspend(User user);
 
     @Override
     public WorkflowResult<Long> suspend(final Long userKey) {
-        return suspend(userDAO.authFetch(userKey));
+        return suspend(userDAO.authFind(userKey));
     }
 
     @Override
@@ -91,7 +91,7 @@ public abstract class AbstractUserWorkflowAdapter implements UserWorkflowAdapter
 
     @Override
     public WorkflowResult<Long> reactivate(final Long userKey) {
-        final User user = userDAO.authFetch(userKey);
+        final User user = userDAO.authFind(userKey);
 
         // reset failed logins
         user.setFailedLogins(0);
@@ -106,20 +106,20 @@ public abstract class AbstractUserWorkflowAdapter implements UserWorkflowAdapter
 
     @Override
     public void requestPasswordReset(final Long userKey) {
-        doRequestPasswordReset(userDAO.authFetch(userKey));
+        doRequestPasswordReset(userDAO.authFind(userKey));
     }
 
     protected abstract void doConfirmPasswordReset(User user, String token, String password);
 
     @Override
     public void confirmPasswordReset(final Long userKey, final String token, final String password) {
-        doConfirmPasswordReset(userDAO.authFetch(userKey), token, password);
+        doConfirmPasswordReset(userDAO.authFind(userKey), token, password);
     }
 
     protected abstract void doDelete(User user);
 
     @Override
     public void delete(final Long userKey) {
-        doDelete(userDAO.authFetch(userKey));
+        doDelete(userDAO.authFind(userKey));
     }
 }


Mime
View raw message