You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2014/06/19 15:04:41 UTC

svn commit: r1603867 [2/3] - in /syncope/trunk: client/src/main/java/org/apache/syncope/client/ common/src/main/java/org/apache/syncope/common/mod/ common/src/main/java/org/apache/syncope/common/search/ common/src/main/java/org/apache/syncope/common/se...

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/StatusPanel.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/StatusPanel.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/StatusPanel.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/StatusPanel.java Thu Jun 19 13:04:39 2014
@@ -26,6 +26,7 @@ import java.util.Map;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.common.mod.StatusMod;
 import org.apache.syncope.common.to.AbstractAttributableTO;
+import org.apache.syncope.common.to.AbstractSubjectTO;
 import org.apache.syncope.common.to.ConnObjectTO;
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.to.UserTO;
@@ -93,7 +94,7 @@ public class StatusPanel extends Panel i
 
     public <T extends AbstractAttributableTO> StatusPanel(
             final String id,
-            final AbstractAttributableTO attributable,
+            final AbstractSubjectTO subject,
             final List<StatusBean> selectedResources,
             final PageReference pageref) {
 
@@ -106,29 +107,29 @@ public class StatusPanel extends Panel i
         connObjectWin.setCookieName("connobject-modal");
         add(connObjectWin);
 
-        statusUtils = new StatusUtils(attributable instanceof RoleTO ? roleRestClient : userRestClient);
+        statusUtils = new StatusUtils(subject instanceof RoleTO ? roleRestClient : userRestClient);
 
-        connObjects = statusUtils.getConnectorObjects(attributable);
+        connObjects = statusUtils.getConnectorObjects(subject);
 
         final List<StatusBean> statusBeans = new ArrayList<StatusBean>(connObjects.size() + 1);
         initialStatusBeanMap = new LinkedHashMap<String, StatusBean>(connObjects.size() + 1);
 
-        final StatusBean syncope = new StatusBean(attributable, "syncope");
+        final StatusBean syncope = new StatusBean(subject, "syncope");
 
-        if (attributable instanceof UserTO) {
-            syncope.setAccountLink(((UserTO) attributable).getUsername());
+        if (subject instanceof UserTO) {
+            syncope.setAccountLink(((UserTO) subject).getUsername());
 
             Status syncopeStatus = Status.UNDEFINED;
-            if (((UserTO) attributable).getStatus() != null) {
+            if (((UserTO) subject).getStatus() != null) {
                 try {
-                    syncopeStatus = Status.valueOf(((UserTO) attributable).getStatus().toUpperCase());
+                    syncopeStatus = Status.valueOf(((UserTO) subject).getStatus().toUpperCase());
                 } catch (IllegalArgumentException e) {
-                    LOG.warn("Unexpected status found: {}", ((UserTO) attributable).getStatus(), e);
+                    LOG.warn("Unexpected status found: {}", ((UserTO) subject).getStatus(), e);
                 }
             }
             syncope.setStatus(syncopeStatus);
-        } else if (attributable instanceof RoleTO) {
-            syncope.setAccountLink(((RoleTO) attributable).getDisplayName());
+        } else if (subject instanceof RoleTO) {
+            syncope.setAccountLink(((RoleTO) subject).getDisplayName());
             syncope.setStatus(Status.ACTIVE);
         }
 
@@ -140,7 +141,7 @@ public class StatusPanel extends Panel i
                     entry.getAttributable(),
                     entry.getResourceName(),
                     entry.getConnObjectTO(),
-                    attributable instanceof RoleTO);
+                    subject instanceof RoleTO);
 
             initialStatusBeanMap.put(entry.getResourceName(), statusBean);
             statusBeans.add(statusBean);
@@ -160,7 +161,7 @@ public class StatusPanel extends Panel i
         add(checkGroup);
 
         CheckGroupSelector groupSelector = new CheckGroupSelector("groupselector", checkGroup);
-        if (attributable instanceof RoleTO) {
+        if (subject instanceof RoleTO) {
             groupSelector.setVisible(false);
         }
         add(groupSelector);
@@ -174,7 +175,7 @@ public class StatusPanel extends Panel i
                 item.add(statusUtils.getStatusImage("icon", item.getModelObject().getStatus()));
 
                 final Check<StatusBean> check = new Check<StatusBean>("check", item.getModel(), checkGroup);
-                if (attributable instanceof RoleTO) {
+                if (subject instanceof RoleTO) {
                     check.setVisible(false);
                 }
                 item.add(check);

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/SyncTasks.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/SyncTasks.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/SyncTasks.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/SyncTasks.java Thu Jun 19 13:04:39 2014
@@ -94,8 +94,10 @@ public class SyncTasks extends AbstractT
 
         container.add(table);
 
+        @SuppressWarnings("rawtypes")
         Form paginatorForm = new Form("PaginatorForm");
 
+        @SuppressWarnings({ "unchecked", "rawtypes" })
         final DropDownChoice rowsChooser = new DropDownChoice("rowsChooser", new PropertyModel(this, "paginatorRows"),
                 prefMan.getPaginatorChoices());
 

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java Thu Jun 19 13:04:39 2014
@@ -25,10 +25,10 @@ import org.apache.syncope.common.reqres.
 import org.apache.syncope.common.reqres.BulkActionResult;
 import org.apache.syncope.common.to.ResourceTO;
 import org.apache.syncope.common.to.UserTO;
-import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.util.CollectionWrapper;
 import org.apache.syncope.common.SyncopeClientException;
 import org.apache.syncope.common.types.ResourceDeassociationActionType;
+import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.common.wrap.SubjectId;
 import org.springframework.stereotype.Component;
 
@@ -95,7 +95,7 @@ public class ResourceRestClient extends 
             final ResourceDeassociationActionType type, final List<SubjectId> subjtectIds) {
 
         return getService(ResourceService.class).bulkDeassociation(resourceName,
-                UserTO.class.isAssignableFrom(typeRef) ? AttributableType.USER : AttributableType.ROLE,
+                UserTO.class.isAssignableFrom(typeRef) ? SubjectType.USER : SubjectType.ROLE,
                 type, subjtectIds);
     }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java Thu Jun 19 13:04:39 2014
@@ -30,9 +30,9 @@ import org.apache.syncope.common.reqres.
 import org.apache.syncope.common.to.ConnObjectTO;
 import org.apache.syncope.common.wrap.ResourceName;
 import org.apache.syncope.common.to.RoleTO;
-import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.types.ResourceAssociationActionType;
 import org.apache.syncope.common.types.ResourceDeassociationActionType;
+import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.common.util.CollectionWrapper;
 import org.apache.syncope.console.commons.status.StatusBean;
 import org.apache.syncope.console.commons.status.StatusUtils;
@@ -73,7 +73,7 @@ public class RoleRestClient extends Abst
 
     @Override
     public ConnObjectTO getConnectorObject(final String resourceName, final Long id) {
-        return getService(ResourceService.class).getConnectorObject(resourceName, AttributableType.ROLE, id);
+        return getService(ResourceService.class).getConnectorObject(resourceName, SubjectType.ROLE, id);
     }
 
     public RoleTO create(final RoleTO roleTO) {

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java Thu Jun 19 13:04:39 2014
@@ -29,12 +29,12 @@ import org.apache.syncope.common.reqres.
 import org.apache.syncope.common.to.ConnObjectTO;
 import org.apache.syncope.common.wrap.ResourceName;
 import org.apache.syncope.common.to.UserTO;
-import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.util.CollectionWrapper;
 import org.apache.syncope.common.SyncopeClientException;
 import org.apache.syncope.common.mod.ResourceAssociationMod;
 import org.apache.syncope.common.types.ResourceAssociationActionType;
 import org.apache.syncope.common.types.ResourceDeassociationActionType;
+import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.console.commons.status.StatusBean;
 import org.apache.syncope.console.commons.status.StatusUtils;
 import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
@@ -94,7 +94,7 @@ public class UserRestClient extends Abst
 
     @Override
     public ConnObjectTO getConnectorObject(final String resourceName, final Long id) {
-        return getService(ResourceService.class).getConnectorObject(resourceName, AttributableType.USER, id);
+        return getService(ResourceService.class).getConnectorObject(resourceName, SubjectType.USER, id);
     }
 
     public void suspend(final long userId, final List<StatusBean> statuses) {

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java Thu Jun 19 13:04:39 2014
@@ -24,9 +24,9 @@ import javax.ws.rs.core.Response;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.syncope.common.services.WorkflowService;
-import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.types.RESTHeaders;
 import org.apache.syncope.common.SyncopeClientException;
+import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.console.SyncopeSession;
 import org.springframework.stereotype.Component;
 
@@ -40,7 +40,7 @@ public class WorkflowRestClient extends 
     }
 
     public InputStream getDefinition(final MediaType mediaType) {
-        Response response = getService(mediaType).exportDefinition(AttributableType.USER);
+        Response response = getService(mediaType).exportDefinition(SubjectType.USER);
 
         return (InputStream) response.getEntity();
     }
@@ -48,7 +48,7 @@ public class WorkflowRestClient extends 
     public byte[] getDiagram() {
         WorkflowService service = getService(WorkflowService.class);
         WebClient.client(service).accept(RESTHeaders.MEDIATYPE_IMAGE_PNG);
-        Response response = service.exportDiagram(AttributableType.USER);
+        Response response = service.exportDiagram(SubjectType.USER);
 
         byte[] diagram;
         try {
@@ -63,7 +63,7 @@ public class WorkflowRestClient extends 
     public boolean isActivitiEnabledForUsers() {
         Boolean result = null;
         try {
-            result = SyncopeSession.get().isActivitiEnabledFor(AttributableType.USER);
+            result = SyncopeSession.get().isActivitiEnabledFor(SubjectType.USER);
         } catch (SyncopeClientException e) {
             LOG.error("While seeking if Activiti is enabled for users", e);
         }
@@ -74,6 +74,6 @@ public class WorkflowRestClient extends 
     }
 
     public void updateDefinition(final MediaType mediaType, final String definition) {
-        getService(mediaType).importDefinition(AttributableType.USER, definition);
+        getService(mediaType).importDefinition(SubjectType.USER, definition);
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java Thu Jun 19 13:04:39 2014
@@ -29,6 +29,7 @@ import java.util.Set;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.common.mod.AbstractAttributableMod;
 import org.apache.syncope.common.to.AbstractAttributableTO;
+import org.apache.syncope.common.to.AbstractSubjectTO;
 import org.apache.syncope.common.to.AttributeTO;
 import org.apache.syncope.common.to.ConnObjectTO;
 import org.apache.syncope.common.to.MembershipTO;
@@ -44,6 +45,7 @@ import org.apache.syncope.core.persisten
 import org.apache.syncope.core.persistence.beans.AbstractAttributable;
 import org.apache.syncope.core.persistence.beans.AbstractMappingItem;
 import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
+import org.apache.syncope.core.persistence.beans.AbstractSubject;
 import org.apache.syncope.core.persistence.beans.AbstractVirAttr;
 import org.apache.syncope.core.persistence.beans.ExternalResource;
 import org.apache.syncope.core.persistence.beans.PasswordPolicy;
@@ -151,10 +153,10 @@ public class ConnObjectUtil {
      * @return UserTO for the user to be created
      */
     @Transactional(readOnly = true)
-    public <T extends AbstractAttributableTO> T getAttributableTO(final ConnectorObject obj, final SyncTask syncTask,
+    public <T extends AbstractSubjectTO> T getSubjectTO(final ConnectorObject obj, final SyncTask syncTask,
             final AttributableUtil attrUtil) {
 
-        T subjectTO = getAttributableTOFromConnObject(obj, syncTask, attrUtil);
+        T subjectTO = getSubjectTOFromConnObject(obj, syncTask, attrUtil);
 
         // (for users) if password was not set above, generate
         if (subjectTO instanceof UserTO && StringUtils.isBlank(((UserTO) subjectTO).getPassword())) {
@@ -218,7 +220,7 @@ public class ConnObjectUtil {
             final AbstractAttributableTO original, final SyncTask syncTask, final AttributableUtil attrUtil)
             throws NotFoundException, UnauthorizedRoleException {
 
-        final AbstractAttributableTO updated = getAttributableTOFromConnObject(obj, syncTask, attrUtil);
+        final AbstractAttributableTO updated = getSubjectTOFromConnObject(obj, syncTask, attrUtil);
         updated.setId(id);
 
         if (AttributableType.USER == attrUtil.getType()) {
@@ -248,10 +250,10 @@ public class ConnObjectUtil {
         return null;
     }
 
-    private <T extends AbstractAttributableTO> T getAttributableTOFromConnObject(final ConnectorObject obj,
+    private <T extends AbstractSubjectTO> T getSubjectTOFromConnObject(final ConnectorObject obj,
             final SyncTask syncTask, final AttributableUtil attrUtil) {
 
-        final T attributableTO = attrUtil.newAttributableTO();
+        final T subjectTO = attrUtil.newSubjectTO();
 
         // 1. fill with data from connector object
         for (AbstractMappingItem item : attrUtil.getMappingItems(
@@ -266,16 +268,16 @@ public class ConnObjectUtil {
                     break;
 
                 case Password:
-                    if (attributableTO instanceof UserTO && attribute != null && attribute.getValue() != null
+                    if (subjectTO instanceof UserTO && attribute != null && attribute.getValue() != null
                             && !attribute.getValue().isEmpty()) {
 
-                        ((UserTO) attributableTO).setPassword(getPassword(attribute.getValue().get(0)));
+                        ((UserTO) subjectTO).setPassword(getPassword(attribute.getValue().get(0)));
                     }
                     break;
 
                 case Username:
-                    if (attributableTO instanceof UserTO) {
-                        ((UserTO) attributableTO).setUsername(attribute == null || attribute.getValue().isEmpty()
+                    if (subjectTO instanceof UserTO) {
+                        ((UserTO) subjectTO).setUsername(attribute == null || attribute.getValue().isEmpty()
                                 || attribute.getValue().get(0) == null
                                 ? null
                                 : attribute.getValue().get(0).toString());
@@ -283,8 +285,8 @@ public class ConnObjectUtil {
                     break;
 
                 case RoleName:
-                    if (attributableTO instanceof RoleTO) {
-                        ((RoleTO) attributableTO).setName(attribute == null || attribute.getValue().isEmpty()
+                    if (subjectTO instanceof RoleTO) {
+                        ((RoleTO) subjectTO).setName(attribute == null || attribute.getValue().isEmpty()
                                 || attribute.getValue().get(0) == null
                                 ? null
                                 : attribute.getValue().get(0).toString());
@@ -292,7 +294,7 @@ public class ConnObjectUtil {
                     break;
 
                 case RoleOwnerSchema:
-                    if (attributableTO instanceof RoleTO && attribute != null) {
+                    if (subjectTO instanceof RoleTO && attribute != null) {
                         // using a special attribute (with schema "", that will be ignored) for carrying the
                         // RoleOwnerSchema value
                         attributeTO = new AttributeTO();
@@ -303,7 +305,7 @@ public class ConnObjectUtil {
                             attributeTO.getValues().add(attribute.getValue().get(0).toString());
                         }
 
-                        ((RoleTO) attributableTO).getAttrs().add(attributeTO);
+                        ((RoleTO) subjectTO).getAttrs().add(attributeTO);
                     }
                     break;
 
@@ -337,14 +339,14 @@ public class ConnObjectUtil {
                         }
                     }
 
-                    attributableTO.getAttrs().add(attributeTO);
+                    subjectTO.getAttrs().add(attributeTO);
                     break;
 
                 case UserDerivedSchema:
                 case RoleDerivedSchema:
                     attributeTO = new AttributeTO();
                     attributeTO.setSchema(item.getIntAttrName());
-                    attributableTO.getDerAttrs().add(attributeTO);
+                    subjectTO.getDerAttrs().add(attributeTO);
                     break;
 
                 case UserVirtualSchema:
@@ -361,7 +363,7 @@ public class ConnObjectUtil {
                         }
                     }
 
-                    attributableTO.getVirAttrs().add(attributeTO);
+                    subjectTO.getVirAttrs().add(attributeTO);
                     break;
 
                 default:
@@ -369,26 +371,26 @@ public class ConnObjectUtil {
         }
 
         // 2. add data from defined template (if any)
-        AbstractAttributableTO template = AttributableType.USER == attrUtil.getType()
+        AbstractSubjectTO template = AttributableType.USER == attrUtil.getType()
                 ? syncTask.getUserTemplate() : syncTask.getRoleTemplate();
 
         if (template != null) {
             if (template instanceof UserTO) {
                 if (StringUtils.isNotBlank(((UserTO) template).getUsername())) {
-                    String evaluated = JexlUtil.evaluate(((UserTO) template).getUsername(), attributableTO);
+                    String evaluated = JexlUtil.evaluate(((UserTO) template).getUsername(), subjectTO);
                     if (StringUtils.isNotBlank(evaluated)) {
-                        ((UserTO) attributableTO).setUsername(evaluated);
+                        ((UserTO) subjectTO).setUsername(evaluated);
                     }
                 }
 
                 if (StringUtils.isNotBlank(((UserTO) template).getPassword())) {
-                    String evaluated = JexlUtil.evaluate(((UserTO) template).getPassword(), attributableTO);
+                    String evaluated = JexlUtil.evaluate(((UserTO) template).getPassword(), subjectTO);
                     if (StringUtils.isNotBlank(evaluated)) {
-                        ((UserTO) attributableTO).setPassword(evaluated);
+                        ((UserTO) subjectTO).setPassword(evaluated);
                     }
                 }
 
-                Map<Long, MembershipTO> currentMembs = ((UserTO) attributableTO).getMembershipMap();
+                Map<Long, MembershipTO> currentMembs = ((UserTO) subjectTO).getMembershipMap();
                 for (MembershipTO membTO : ((UserTO) template).getMemberships()) {
                     MembershipTO membTBU;
                     if (currentMembs.containsKey(membTO.getRoleId())) {
@@ -396,68 +398,68 @@ public class ConnObjectUtil {
                     } else {
                         membTBU = new MembershipTO();
                         membTBU.setRoleId(membTO.getRoleId());
-                        ((UserTO) attributableTO).getMemberships().add(membTBU);
+                        ((UserTO) subjectTO).getMemberships().add(membTBU);
                     }
                     fillFromTemplate(membTBU, membTO);
                 }
             }
             if (template instanceof RoleTO) {
                 if (StringUtils.isNotBlank(((RoleTO) template).getName())) {
-                    String evaluated = JexlUtil.evaluate(((RoleTO) template).getName(), attributableTO);
+                    String evaluated = JexlUtil.evaluate(((RoleTO) template).getName(), subjectTO);
                     if (StringUtils.isNotBlank(evaluated)) {
-                        ((RoleTO) attributableTO).setName(evaluated);
+                        ((RoleTO) subjectTO).setName(evaluated);
                     }
                 }
 
                 if (((RoleTO) template).getParent() != 0) {
                     final SyncopeRole parentRole = roleDAO.find(((RoleTO) template).getParent());
                     if (parentRole != null) {
-                        ((RoleTO) attributableTO).setParent(parentRole.getId());
+                        ((RoleTO) subjectTO).setParent(parentRole.getId());
                     }
                 }
 
                 if (((RoleTO) template).getUserOwner() != null) {
                     final SyncopeUser userOwner = userDAO.find(((RoleTO) template).getUserOwner());
                     if (userOwner != null) {
-                        ((RoleTO) attributableTO).setUserOwner(userOwner.getId());
+                        ((RoleTO) subjectTO).setUserOwner(userOwner.getId());
                     }
                 }
                 if (((RoleTO) template).getRoleOwner() != null) {
                     final SyncopeRole roleOwner = roleDAO.find(((RoleTO) template).getRoleOwner());
                     if (roleOwner != null) {
-                        ((RoleTO) attributableTO).setRoleOwner(roleOwner.getId());
+                        ((RoleTO) subjectTO).setRoleOwner(roleOwner.getId());
                     }
                 }
 
-                ((RoleTO) attributableTO).getEntitlements().addAll(((RoleTO) template).getEntitlements());
+                ((RoleTO) subjectTO).getEntitlements().addAll(((RoleTO) template).getEntitlements());
 
-                ((RoleTO) attributableTO).getRAttrTemplates().addAll(((RoleTO) template).getRAttrTemplates());
-                ((RoleTO) attributableTO).getRDerAttrTemplates().addAll(((RoleTO) template).getRDerAttrTemplates());
-                ((RoleTO) attributableTO).getRVirAttrTemplates().addAll(((RoleTO) template).getRVirAttrTemplates());
-                ((RoleTO) attributableTO).getMAttrTemplates().addAll(((RoleTO) template).getMAttrTemplates());
-                ((RoleTO) attributableTO).getMDerAttrTemplates().addAll(((RoleTO) template).getMDerAttrTemplates());
-                ((RoleTO) attributableTO).getMVirAttrTemplates().addAll(((RoleTO) template).getMVirAttrTemplates());
+                ((RoleTO) subjectTO).getRAttrTemplates().addAll(((RoleTO) template).getRAttrTemplates());
+                ((RoleTO) subjectTO).getRDerAttrTemplates().addAll(((RoleTO) template).getRDerAttrTemplates());
+                ((RoleTO) subjectTO).getRVirAttrTemplates().addAll(((RoleTO) template).getRVirAttrTemplates());
+                ((RoleTO) subjectTO).getMAttrTemplates().addAll(((RoleTO) template).getMAttrTemplates());
+                ((RoleTO) subjectTO).getMDerAttrTemplates().addAll(((RoleTO) template).getMDerAttrTemplates());
+                ((RoleTO) subjectTO).getMVirAttrTemplates().addAll(((RoleTO) template).getMVirAttrTemplates());
 
-                ((RoleTO) attributableTO).setAccountPolicy(((RoleTO) template).getAccountPolicy());
-                ((RoleTO) attributableTO).setPasswordPolicy(((RoleTO) template).getPasswordPolicy());
+                ((RoleTO) subjectTO).setAccountPolicy(((RoleTO) template).getAccountPolicy());
+                ((RoleTO) subjectTO).setPasswordPolicy(((RoleTO) template).getPasswordPolicy());
 
-                ((RoleTO) attributableTO).setInheritOwner(((RoleTO) template).isInheritOwner());
-                ((RoleTO) attributableTO).setInheritTemplates(((RoleTO) template).isInheritTemplates());
-                ((RoleTO) attributableTO).setInheritAttrs(((RoleTO) template).isInheritAttrs());
-                ((RoleTO) attributableTO).setInheritDerAttrs(((RoleTO) template).isInheritDerAttrs());
-                ((RoleTO) attributableTO).setInheritVirAttrs(((RoleTO) template).isInheritVirAttrs());
-                ((RoleTO) attributableTO).setInheritPasswordPolicy(((RoleTO) template).isInheritPasswordPolicy());
-                ((RoleTO) attributableTO).setInheritAccountPolicy(((RoleTO) template).isInheritAccountPolicy());
+                ((RoleTO) subjectTO).setInheritOwner(((RoleTO) template).isInheritOwner());
+                ((RoleTO) subjectTO).setInheritTemplates(((RoleTO) template).isInheritTemplates());
+                ((RoleTO) subjectTO).setInheritAttrs(((RoleTO) template).isInheritAttrs());
+                ((RoleTO) subjectTO).setInheritDerAttrs(((RoleTO) template).isInheritDerAttrs());
+                ((RoleTO) subjectTO).setInheritVirAttrs(((RoleTO) template).isInheritVirAttrs());
+                ((RoleTO) subjectTO).setInheritPasswordPolicy(((RoleTO) template).isInheritPasswordPolicy());
+                ((RoleTO) subjectTO).setInheritAccountPolicy(((RoleTO) template).isInheritAccountPolicy());
             }
 
-            fillFromTemplate(attributableTO, template);
+            fillFromTemplate(subjectTO, template);
 
             for (String resource : template.getResources()) {
-                attributableTO.getResources().add(resource);
+                subjectTO.getResources().add(resource);
             }
         }
 
-        return attributableTO;
+        return subjectTO;
     }
 
     /**
@@ -580,8 +582,9 @@ public class ConnObjectUtil {
 
             // SYNCOPE-458 if virattr owner is a Membership, owner must become user involved in membership because 
             // membership mapping is contained in user mapping
-            final AbstractAttributable realOwner = owner instanceof Membership ? ((Membership) owner).getSyncopeUser()
-                    : owner;
+            final AbstractSubject realOwner = owner instanceof Membership
+                    ? ((Membership) owner).getSyncopeUser()
+                    : (AbstractSubject) owner;
 
             final Set<ExternalResource> targetResources = owner instanceof Membership ? getTargetResource(virAttr, type,
                     attrUtil, realOwner.getResources()) : getTargetResource(virAttr, type, attrUtil);
@@ -662,12 +665,14 @@ public class ConnObjectUtil {
 
         final Set<ExternalResource> resources = new HashSet<ExternalResource>();
 
-        for (ExternalResource res : attr.getOwner().getResources()) {
-            if (!MappingUtil.getMatchingMappingItems(
-                    attrUtil.getMappingItems(res, MappingPurpose.BOTH),
-                    attr.getSchema().getName(), type).isEmpty()) {
+        if (attr.getOwner() instanceof AbstractSubject) {
+            for (ExternalResource res : ((AbstractSubject) attr.getOwner()).getResources()) {
+                if (!MappingUtil.getMatchingMappingItems(
+                        attrUtil.getMappingItems(res, MappingPurpose.BOTH),
+                        attr.getSchema().getName(), type).isEmpty()) {
 
-                resources.add(res);
+                    resources.add(res);
+                }
             }
         }
 

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttributable.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttributable.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttributable.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttributable.java Thu Jun 19 13:04:39 2014
@@ -19,11 +19,9 @@
 package org.apache.syncope.core.persistence.beans;
 
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 public abstract class AbstractAttributable extends AbstractSysInfo {
 
@@ -130,36 +128,4 @@ public abstract class AbstractAttributab
     public abstract List<? extends AbstractVirAttr> getVirAttrs();
 
     public abstract void setVirAttrs(List<? extends AbstractVirAttr> virtualAttributes);
-
-    protected abstract Set<ExternalResource> internalGetResources();
-
-    public boolean addResource(final ExternalResource resource) {
-        return internalGetResources().add(resource);
-    }
-
-    public boolean removeResource(final ExternalResource resource) {
-        return internalGetResources().remove(resource);
-    }
-
-    public Set<ExternalResource> getResources() {
-        return internalGetResources();
-    }
-
-    public Set<String> getResourceNames() {
-        Set<ExternalResource> ownResources = getResources();
-
-        Set<String> result = new HashSet<String>(ownResources.size());
-        for (ExternalResource resource : ownResources) {
-            result.add(resource.getName());
-        }
-
-        return result;
-    }
-
-    public void setResources(final Set<ExternalResource> resources) {
-        internalGetResources().clear();
-        if (resources != null) {
-            internalGetResources().addAll(resources);
-        }
-    }
 }

Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractSubject.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractSubject.java?rev=1603867&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractSubject.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractSubject.java Thu Jun 19 13:04:39 2014
@@ -0,0 +1,60 @@
+/*
+ * 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.persistence.beans;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public abstract class AbstractSubject extends AbstractAttributable {
+
+    private static final long serialVersionUID = -6876467491398928855L;
+
+    protected abstract Set<ExternalResource> internalGetResources();
+
+    public boolean addResource(final ExternalResource resource) {
+        return internalGetResources().add(resource);
+    }
+
+    public boolean removeResource(final ExternalResource resource) {
+        return internalGetResources().remove(resource);
+    }
+
+    public Set<ExternalResource> getResources() {
+        return internalGetResources();
+    }
+
+    public Set<String> getResourceNames() {
+        Set<ExternalResource> ownResources = getResources();
+
+        Set<String> result = new HashSet<String>(ownResources.size());
+        for (ExternalResource resource : ownResources) {
+            result.add(resource.getName());
+        }
+
+        return result;
+    }
+
+    public void setResources(final Set<ExternalResource> resources) {
+        internalGetResources().clear();
+        if (resources != null) {
+            internalGetResources().addAll(resources);
+        }
+    }
+
+}

Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractSubject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractSubject.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractSubject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/membership/Membership.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/membership/Membership.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/membership/Membership.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/membership/Membership.java Thu Jun 19 13:04:39 2014
@@ -19,9 +19,7 @@
 package org.apache.syncope.core.persistence.beans.membership;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
-import java.util.Set;
 import javax.persistence.CascadeType;
 import javax.persistence.Entity;
 import javax.persistence.Id;
@@ -34,7 +32,6 @@ import org.apache.syncope.core.persisten
 import org.apache.syncope.core.persistence.beans.AbstractAttributable;
 import org.apache.syncope.core.persistence.beans.AbstractDerAttr;
 import org.apache.syncope.core.persistence.beans.AbstractVirAttr;
-import org.apache.syncope.core.persistence.beans.ExternalResource;
 import org.apache.syncope.core.persistence.beans.role.SyncopeRole;
 import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
 
@@ -79,11 +76,6 @@ public class Membership extends Abstract
         return id;
     }
 
-    @Override
-    protected Set<ExternalResource> internalGetResources() {
-        return Collections.emptySet();
-    }
-
     public SyncopeRole getSyncopeRole() {
         return syncopeRole;
     }
@@ -231,31 +223,6 @@ public class Membership extends Abstract
     }
 
     @Override
-    public boolean addResource(final ExternalResource resource) {
-        return false;
-    }
-
-    @Override
-    public boolean removeResource(final ExternalResource resource) {
-        return false;
-    }
-
-    @Override
-    public Set<ExternalResource> getResources() {
-        return Collections.emptySet();
-    }
-
-    @Override
-    public Set<String> getResourceNames() {
-        return Collections.emptySet();
-    }
-
-    @Override
-    public void setResources(final Set<ExternalResource> resources) {
-        // Memberships cannot be directly associated to resources.
-    }
-
-    @Override
     public String toString() {
         return "Membership[" + "id=" + id + ", " + syncopeUser + ", " + syncopeRole + ']';
     }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/SyncopeRole.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/SyncopeRole.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/SyncopeRole.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/SyncopeRole.java Thu Jun 19 13:04:39 2014
@@ -44,11 +44,11 @@ import javax.validation.constraints.Min;
 import javax.validation.constraints.NotNull;
 import org.apache.syncope.core.persistence.beans.AbstractAttr;
 import org.apache.syncope.core.persistence.beans.AbstractAttrTemplate;
-import org.apache.syncope.core.persistence.beans.AbstractAttributable;
 import org.apache.syncope.core.persistence.beans.AbstractDerAttr;
 import org.apache.syncope.core.persistence.beans.AbstractDerSchema;
 import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
 import org.apache.syncope.core.persistence.beans.AbstractSchema;
+import org.apache.syncope.core.persistence.beans.AbstractSubject;
 import org.apache.syncope.core.persistence.beans.AbstractVirAttr;
 import org.apache.syncope.core.persistence.beans.AbstractVirSchema;
 import org.apache.syncope.core.persistence.beans.AccountPolicy;
@@ -66,7 +66,7 @@ import org.apache.syncope.core.persisten
         @UniqueConstraint(columnNames = { "name", "parent_id" }))
 @Cacheable
 @SyncopeRoleCheck
-public class SyncopeRole extends AbstractAttributable {
+public class SyncopeRole extends AbstractSubject {
 
     private static final long serialVersionUID = -5281258853142421875L;
 

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/SyncopeUser.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/SyncopeUser.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/SyncopeUser.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/SyncopeUser.java Thu Jun 19 13:04:39 2014
@@ -49,8 +49,8 @@ import javax.validation.constraints.Min;
 import javax.validation.constraints.NotNull;
 import org.apache.syncope.common.types.CipherAlgorithm;
 import org.apache.syncope.core.persistence.beans.AbstractAttr;
-import org.apache.syncope.core.persistence.beans.AbstractAttributable;
 import org.apache.syncope.core.persistence.beans.AbstractDerAttr;
+import org.apache.syncope.core.persistence.beans.AbstractSubject;
 import org.apache.syncope.core.persistence.beans.AbstractVirAttr;
 import org.apache.syncope.core.persistence.beans.ExternalResource;
 import org.apache.syncope.core.persistence.beans.membership.Membership;
@@ -65,7 +65,7 @@ import org.apache.syncope.core.util.Secu
 @Entity
 @Cacheable
 @SyncopeUserCheck
-public class SyncopeUser extends AbstractAttributable {
+public class SyncopeUser extends AbstractSubject {
 
     private static final long serialVersionUID = -3905046855521446823L;
 

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java Thu Jun 19 13:04:39 2014
@@ -36,7 +36,7 @@ import org.apache.syncope.common.types.T
 import org.apache.syncope.core.audit.AuditManager;
 import org.apache.syncope.core.connid.ConnObjectUtil;
 import org.apache.syncope.core.notification.NotificationManager;
-import org.apache.syncope.core.persistence.beans.AbstractAttributable;
+import org.apache.syncope.core.persistence.beans.AbstractSubject;
 import org.apache.syncope.core.persistence.beans.ExternalResource;
 import org.apache.syncope.core.persistence.beans.PropagationTask;
 import org.apache.syncope.core.persistence.beans.TaskExec;
@@ -255,8 +255,8 @@ public abstract class AbstractPropagatio
                 connObjectUtil);
     }
 
-    protected AbstractAttributable getSubject(final PropagationTask task) {
-        AbstractAttributable subject = null;
+    protected AbstractSubject getSubject(final PropagationTask task) {
+        AbstractSubject subject = null;
 
         if (task.getSubjectId() != null) {
             switch (task.getSubjectType()) {
@@ -305,7 +305,7 @@ public abstract class AbstractPropagatio
              * update, this user / role used to have the current resource assigned by more than one mean (for example,
              * two different memberships with the same resource).
              */
-            AbstractAttributable subject = getSubject(task);
+            AbstractSubject subject = getSubject(task);
             if (subject == null || !subject.getResourceNames().contains(task.getResource().getName())) {
                 LOG.debug("Delete {} on {}", beforeObj.getUid(), task.getResource().getName());
 

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/DBPasswordPropagationActions.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/DBPasswordPropagationActions.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/DBPasswordPropagationActions.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/DBPasswordPropagationActions.java Thu Jun 19 13:04:39 2014
@@ -38,7 +38,7 @@ import org.springframework.transaction.a
 
 /**
  * Propagate a non-cleartext password out to a resource, if the PropagationManager has not already
- * added a password. 
+ * added a password.
  */
 public class DBPasswordPropagationActions extends DefaultPropagationActions {
 
@@ -49,7 +49,7 @@ public class DBPasswordPropagationAction
     @Override
     public void before(final PropagationTask task, final ConnectorObject beforeObj) {
         super.before(task, beforeObj);
-        
+
         if (AttributableType.USER == task.getSubjectType()) {
             SyncopeUser user = userDAO.find(task.getSubjectId());
             if (user != null && user.getPassword() != null) {
@@ -65,16 +65,15 @@ public class DBPasswordPropagationAction
                     Set<Attribute> attributes = new HashSet<Attribute>(task.getAttributes());
                     attributes.add(passwordAttribute);
                     attributes.remove(missing);
-                    
-                    Attribute hashedPasswordAttribute = 
-                        AttributeBuilder.build(
+
+                    Attribute hashedPasswordAttribute = AttributeBuilder.build(
                             AttributeUtil.createSpecialName("HASHED_PASSWORD"), Boolean.TRUE);
                     attributes.add(hashedPasswordAttribute);
-                    
+
                     task.setAttributes(attributes);
                 }
             }
         }
     }
-    
+
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/PropagationManager.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/PropagationManager.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/PropagationManager.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/PropagationManager.java Thu Jun 19 13:04:39 2014
@@ -37,6 +37,7 @@ import org.apache.syncope.common.types.R
 import org.apache.syncope.core.connid.ConnObjectUtil;
 import org.apache.syncope.core.persistence.beans.AbstractAttributable;
 import org.apache.syncope.core.persistence.beans.AbstractMappingItem;
+import org.apache.syncope.core.persistence.beans.AbstractSubject;
 import org.apache.syncope.core.persistence.beans.AbstractVirAttr;
 import org.apache.syncope.core.persistence.beans.ExternalResource;
 import org.apache.syncope.core.persistence.beans.PropagationTask;
@@ -333,25 +334,25 @@ public class PropagationManager {
                 Collections.<MembershipMod>emptySet());
     }
 
-    protected List<PropagationTask> getUpdateTaskIds(final AbstractAttributable attributable,
+    protected List<PropagationTask> getUpdateTaskIds(final AbstractSubject subject,
             final String password, final boolean changePwd, final Boolean enable,
             final Set<String> vAttrsToBeRemoved, final Set<AttributeMod> vAttrsToBeUpdated,
             final PropagationByResource propByRes, final Collection<String> noPropResourceNames,
             final Set<MembershipMod> membershipsToAdd)
             throws NotFoundException {
 
-        AbstractAttributableDataBinder binder = attributable instanceof SyncopeUser
+        AbstractAttributableDataBinder binder = subject instanceof SyncopeUser
                 ? userDataBinder : roleDataBinder;
 
-        PropagationByResource localPropByRes = binder.fillVirtual(attributable, vAttrsToBeRemoved == null
+        PropagationByResource localPropByRes = binder.fillVirtual(subject, vAttrsToBeRemoved == null
                 ? Collections.<String>emptySet()
                 : vAttrsToBeRemoved, vAttrsToBeUpdated == null
                 ? Collections.<AttributeMod>emptySet()
-                : vAttrsToBeUpdated, AttributableUtil.getInstance(attributable));
+                : vAttrsToBeUpdated, AttributableUtil.getInstance(subject));
 
         // SYNCOPE-458 fill membership virtual attributes
-        if (attributable instanceof SyncopeUser) {
-            final SyncopeUser user = (SyncopeUser) attributable;
+        if (subject instanceof SyncopeUser) {
+            final SyncopeUser user = (SyncopeUser) subject;
             for (Membership membership : user.getMemberships()) {
                 if (membership.getVirAttrs() != null && !membership.getVirAttrs().isEmpty()) {
                     final MembershipMod membershipMod = findMembershipMod(membership, membershipsToAdd);
@@ -368,7 +369,7 @@ public class PropagationManager {
         }
 
         if (propByRes == null || propByRes.isEmpty()) {
-            localPropByRes.addAll(ResourceOperation.UPDATE, attributable.getResourceNames());
+            localPropByRes.addAll(ResourceOperation.UPDATE, subject.getResourceNames());
         } else {
             localPropByRes.merge(propByRes);
         }
@@ -399,7 +400,7 @@ public class PropagationManager {
             membVAttrsToBeRemoved.addAll(membershipMod.getVirAttrsToRemove());
         }
 
-        return createTasks(attributable, password, changePwd,
+        return createTasks(subject, password, changePwd,
                 vAttrsToBeRemoved, vAttrsToBeUpdatedMap, membVAttrsToBeRemoved, membVAttrsToBeUpdatedMap, enable, false,
                 localPropByRes);
     }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/report/RoleReportlet.java Thu Jun 19 13:04:39 2014
@@ -26,6 +26,7 @@ import java.util.Set;
 import org.apache.syncope.common.report.RoleReportletConf;
 import org.apache.syncope.common.report.RoleReportletConf.Feature;
 import org.apache.syncope.common.to.AbstractAttributableTO;
+import org.apache.syncope.common.to.AbstractSubjectTO;
 import org.apache.syncope.common.to.AttributeTO;
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.types.AttributableType;
@@ -84,17 +85,16 @@ public class RoleReportlet extends Abstr
                         AttributableUtil.getInstance(AttributableType.ROLE));
     }
 
-    private void doExtractResources(final ContentHandler handler, final AbstractAttributableTO attributableTO)
+    private void doExtractResources(final ContentHandler handler, final AbstractSubjectTO subjectTO)
             throws SAXException {
 
-        if (attributableTO.getResources().isEmpty()) {
-            LOG.debug("No resources found for {}[{}]", attributableTO.getClass().getSimpleName(), attributableTO
-                    .getId());
+        if (subjectTO.getResources().isEmpty()) {
+            LOG.debug("No resources found for {}[{}]", subjectTO.getClass().getSimpleName(), subjectTO.getId());
         } else {
             AttributesImpl atts = new AttributesImpl();
             handler.startElement("", "", "resources", null);
 
-            for (String resourceName : attributableTO.getResources()) {
+            for (String resourceName : subjectTO.getResources()) {
                 atts.clear();
 
                 atts.addAttribute("", "", ReportXMLConst.ATTR_NAME, ReportXMLConst.XSD_STRING, resourceName);

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/report/UserReportlet.java Thu Jun 19 13:04:39 2014
@@ -23,10 +23,10 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
 import org.apache.syncope.common.report.UserReportletConf;
 import org.apache.syncope.common.report.UserReportletConf.Feature;
 import org.apache.syncope.common.to.AbstractAttributableTO;
+import org.apache.syncope.common.to.AbstractSubjectTO;
 import org.apache.syncope.common.to.AttributeTO;
 import org.apache.syncope.common.to.MembershipTO;
 import org.apache.syncope.common.to.UserTO;
@@ -38,8 +38,8 @@ import org.apache.syncope.core.persisten
 import org.apache.syncope.core.persistence.dao.UserDAO;
 import org.apache.syncope.core.persistence.dao.search.OrderByClause;
 import org.apache.syncope.core.rest.data.RoleDataBinder;
-import org.apache.syncope.core.rest.data.UserDataBinder;
 import org.apache.syncope.core.rest.data.SearchCondConverter;
+import org.apache.syncope.core.rest.data.UserDataBinder;
 import org.apache.syncope.core.util.AttributableUtil;
 import org.apache.syncope.core.util.DataFormat;
 import org.apache.syncope.core.util.EntitlementUtil;
@@ -92,17 +92,16 @@ public class UserReportlet extends Abstr
                         AttributableUtil.getInstance(AttributableType.USER));
     }
 
-    private void doExtractResources(final ContentHandler handler, final AbstractAttributableTO attributableTO)
+    private void doExtractResources(final ContentHandler handler, final AbstractSubjectTO subjectTO)
             throws SAXException {
 
-        if (attributableTO.getResources().isEmpty()) {
-            LOG.debug("No resources found for {}[{}]", attributableTO.getClass().getSimpleName(), attributableTO
-                    .getId());
+        if (subjectTO.getResources().isEmpty()) {
+            LOG.debug("No resources found for {}[{}]", subjectTO.getClass().getSimpleName(), subjectTO.getId());
         } else {
             AttributesImpl atts = new AttributesImpl();
             handler.startElement("", "", "resources", null);
 
-            for (String resourceName : attributableTO.getResources()) {
+            for (String resourceName : subjectTO.getResources()) {
                 atts.clear();
 
                 atts.addAttribute("", "", ReportXMLConst.ATTR_NAME, ReportXMLConst.XSD_STRING, resourceName);

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java Thu Jun 19 13:04:39 2014
@@ -28,10 +28,10 @@ import org.apache.syncope.common.reqres.
 import org.apache.syncope.common.reqres.BulkActionResult;
 import org.apache.syncope.common.to.ConnObjectTO;
 import org.apache.syncope.common.to.ResourceTO;
-import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.types.MappingPurpose;
 import org.apache.syncope.common.types.ClientExceptionType;
 import org.apache.syncope.common.SyncopeClientException;
+import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.core.connid.ConnObjectUtil;
 import org.apache.syncope.core.init.ImplementationClassNamesLoader;
 import org.apache.syncope.core.persistence.beans.AbstractAttributable;
@@ -169,7 +169,7 @@ public class ResourceController extends 
 
     @PreAuthorize("hasRole('RESOURCE_GETCONNECTOROBJECT')")
     @Transactional(readOnly = true)
-    public ConnObjectTO getConnectorObject(final String resourceName, final AttributableType type, final Long id) {
+    public ConnObjectTO getConnectorObject(final String resourceName, final SubjectType type, final Long id) {
         ExternalResource resource = resourceDAO.find(resourceName);
         if (resource == null) {
             throw new NotFoundException("Resource '" + resourceName + "'");
@@ -178,22 +178,19 @@ public class ResourceController extends 
         AbstractAttributable attributable = null;
         switch (type) {
             case USER:
+            default:
                 attributable = userDAO.find(id);
                 break;
 
             case ROLE:
                 attributable = roleDAO.find(id);
                 break;
-
-            case MEMBERSHIP:
-            default:
-                throw new IllegalArgumentException("Not supported for MEMBERSHIP");
         }
         if (attributable == null) {
             throw new NotFoundException(type + " " + id);
         }
 
-        final AttributableUtil attrUtil = AttributableUtil.getInstance(type);
+        final AttributableUtil attrUtil = AttributableUtil.getInstance(type.asAttributableType());
 
         AbstractMappingItem accountIdItem = attrUtil.getAccountIdItem(resource);
         if (accountIdItem == null) {
@@ -203,7 +200,7 @@ public class ResourceController extends 
         final String accountIdValue = MappingUtil.getAccountIdValue(
                 attributable, resource, attrUtil.getAccountIdItem(resource));
 
-        final ObjectClass objectClass = AttributableType.USER == type ? ObjectClass.ACCOUNT : ObjectClass.GROUP;
+        final ObjectClass objectClass = SubjectType.USER == type ? ObjectClass.ACCOUNT : ObjectClass.GROUP;
 
         final Connector connector = connFactory.getConnector(resource);
         final ConnectorObject connectorObject = connector.getObject(objectClass, new Uid(accountIdValue),

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java Thu Jun 19 13:04:39 2014
@@ -26,17 +26,19 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.common.SyncopeClientCompositeException;
+import org.apache.syncope.common.SyncopeClientException;
 import org.apache.syncope.common.mod.AbstractAttributableMod;
+import org.apache.syncope.common.mod.AbstractSubjectMod;
 import org.apache.syncope.common.mod.AttributeMod;
 import org.apache.syncope.common.to.AbstractAttributableTO;
+import org.apache.syncope.common.to.AbstractSubjectTO;
 import org.apache.syncope.common.to.AttributeTO;
 import org.apache.syncope.common.types.AttributableType;
+import org.apache.syncope.common.types.ClientExceptionType;
 import org.apache.syncope.common.types.IntMappingType;
 import org.apache.syncope.common.types.MappingPurpose;
 import org.apache.syncope.common.types.ResourceOperation;
-import org.apache.syncope.common.types.ClientExceptionType;
-import org.apache.syncope.common.SyncopeClientCompositeException;
-import org.apache.syncope.common.SyncopeClientException;
 import org.apache.syncope.core.persistence.beans.AbstractAttr;
 import org.apache.syncope.core.persistence.beans.AbstractAttrValue;
 import org.apache.syncope.core.persistence.beans.AbstractAttributable;
@@ -45,6 +47,7 @@ import org.apache.syncope.core.persisten
 import org.apache.syncope.core.persistence.beans.AbstractMappingItem;
 import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
 import org.apache.syncope.core.persistence.beans.AbstractSchema;
+import org.apache.syncope.core.persistence.beans.AbstractSubject;
 import org.apache.syncope.core.persistence.beans.AbstractVirAttr;
 import org.apache.syncope.core.persistence.beans.AbstractVirSchema;
 import org.apache.syncope.core.persistence.beans.ExternalResource;
@@ -84,8 +87,8 @@ import org.apache.syncope.core.persisten
 import org.apache.syncope.core.persistence.validation.attrvalue.InvalidAttrValueException;
 import org.apache.syncope.core.propagation.PropagationByResource;
 import org.apache.syncope.core.util.AttributableUtil;
-import org.apache.syncope.core.util.jexl.JexlUtil;
 import org.apache.syncope.core.util.MappingUtil;
+import org.apache.syncope.core.util.jexl.JexlUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -250,10 +253,14 @@ public abstract class AbstractAttributab
 
         boolean result = false;
 
-        for (Iterator<ExternalResource> itor = attributable.getResources().iterator(); itor.hasNext() && !result;) {
-            final ExternalResource resource = itor.next();
-            if (resource.isEnforceMandatoryCondition()) {
-                result |= evaluateMandatoryCondition(attrUtil, resource, attributable, intAttrName, intMappingType);
+        if (attributable instanceof AbstractSubject) {
+            for (Iterator<ExternalResource> itor = ((AbstractSubject) attributable).getResources().iterator();
+                    itor.hasNext() && !result;) {
+
+                final ExternalResource resource = itor.next();
+                if (resource.isEnforceMandatoryCondition()) {
+                    result |= evaluateMandatoryCondition(attrUtil, resource, attributable, intAttrName, intMappingType);
+                }
             }
         }
 
@@ -263,10 +270,7 @@ public abstract class AbstractAttributab
     private SyncopeClientException checkMandatory(final AttributableUtil attrUtil,
             final AbstractAttributable attributable) {
 
-        SyncopeClientException reqValMissing = SyncopeClientException.build(
-                ClientExceptionType.RequiredValuesMissing);
-
-        LOG.debug("Check mandatory constraint among resources {}", attributable.getResources());
+        SyncopeClientException reqValMissing = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
 
         // Check if there is some mandatory schema defined for which no value has been provided
         List<? extends AbstractNormalSchema> normalSchemas;
@@ -421,7 +425,9 @@ public abstract class AbstractAttributab
         PropagationByResource propByRes = new PropagationByResource();
 
         final Set<ExternalResource> externalResources = new HashSet<ExternalResource>();
-        externalResources.addAll(attributable.getResources());
+        if (attributable instanceof AbstractSubject) {
+            externalResources.addAll(((AbstractSubject) attributable).getResources());
+        }
 
         if (attributable instanceof Membership) {
             externalResources.clear();
@@ -513,27 +519,29 @@ public abstract class AbstractAttributab
 
         SyncopeClientException invalidValues = SyncopeClientException.build(ClientExceptionType.InvalidValues);
 
-        // 1. resources to be removed
-        for (String resourceToBeRemoved : attributableMod.getResourcesToRemove()) {
-            ExternalResource resource = getResource(resourceToBeRemoved);
-            if (resource != null) {
-                propByRes.add(ResourceOperation.DELETE, resource.getName());
-                attributable.removeResource(resource);
+        if (attributable instanceof AbstractSubject && attributableMod instanceof AbstractSubjectMod) {
+            // 1. resources to be removed
+            for (String resourceToBeRemoved : ((AbstractSubjectMod) attributableMod).getResourcesToRemove()) {
+                ExternalResource resource = getResource(resourceToBeRemoved);
+                if (resource != null) {
+                    propByRes.add(ResourceOperation.DELETE, resource.getName());
+                    ((AbstractSubject) attributable).removeResource(resource);
+                }
             }
-        }
 
-        LOG.debug("Resources to be removed:\n{}", propByRes);
+            LOG.debug("Resources to be removed:\n{}", propByRes);
 
-        // 2. resources to be added
-        for (String resourceToBeAdded : attributableMod.getResourcesToAdd()) {
-            ExternalResource resource = getResource(resourceToBeAdded);
-            if (resource != null) {
-                propByRes.add(ResourceOperation.CREATE, resource.getName());
-                attributable.addResource(resource);
+            // 2. resources to be added
+            for (String resourceToBeAdded : ((AbstractSubjectMod) attributableMod).getResourcesToAdd()) {
+                ExternalResource resource = getResource(resourceToBeAdded);
+                if (resource != null) {
+                    propByRes.add(ResourceOperation.CREATE, resource.getName());
+                    ((AbstractSubject) attributable).addResource(resource);
+                }
             }
-        }
 
-        LOG.debug("Resources to be added:\n{}", propByRes);
+            LOG.debug("Resources to be added:\n{}", propByRes);
+        }
 
         // 3. attributes to be removed
         for (String attributeToBeRemoved : attributableMod.getAttrsToRemove()) {
@@ -558,19 +566,22 @@ public abstract class AbstractAttributab
                     }
                 }
 
-                for (ExternalResource resource : resourceDAO.findAll()) {
-                    for (AbstractMappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
-                        if (schema.getName().equals(mapItem.getIntAttrName())
-                                && mapItem.getIntMappingType() == attrUtil.intMappingType()
-                                && attributable.getResources().contains(resource)) {
-
-                            propByRes.add(ResourceOperation.UPDATE, resource.getName());
-
-                            if (mapItem.isAccountid() && attr != null
-                                    && !attr.getValuesAsStrings().isEmpty()) {
-
-                                propByRes.addOldAccountId(resource.getName(),
-                                        attr.getValuesAsStrings().iterator().next());
+                if (attributable instanceof AbstractSubject) {
+                    for (ExternalResource resource : resourceDAO.findAll()) {
+                        for (AbstractMappingItem mapItem : attrUtil.
+                                getMappingItems(resource, MappingPurpose.PROPAGATION)) {
+                            if (schema.getName().equals(mapItem.getIntAttrName())
+                                    && mapItem.getIntMappingType() == attrUtil.intMappingType()
+                                    && ((AbstractSubject) attributable).getResources().contains(resource)) {
+
+                                propByRes.add(ResourceOperation.UPDATE, resource.getName());
+
+                                if (mapItem.isAccountid() && attr != null
+                                        && !attr.getValuesAsStrings().isEmpty()) {
+
+                                    propByRes.addOldAccountId(resource.getName(),
+                                            attr.getValuesAsStrings().iterator().next());
+                                }
                             }
                         }
                     }
@@ -599,13 +610,16 @@ public abstract class AbstractAttributab
             }
 
             if (schema != null && attr != null && attr.getSchema() != null) {
-                for (ExternalResource resource : resourceDAO.findAll()) {
-                    for (AbstractMappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
-                        if (schema.getName().equals(mapItem.getIntAttrName())
-                                && mapItem.getIntMappingType() == attrUtil.intMappingType()
-                                && attributable.getResources().contains(resource)) {
+                if (attributable instanceof AbstractSubject) {
+                    for (ExternalResource resource : resourceDAO.findAll()) {
+                        for (AbstractMappingItem mapItem : attrUtil.
+                                getMappingItems(resource, MappingPurpose.PROPAGATION)) {
+                            if (schema.getName().equals(mapItem.getIntAttrName())
+                                    && mapItem.getIntMappingType() == attrUtil.intMappingType()
+                                    && ((AbstractSubject) attributable).getResources().contains(resource)) {
 
-                            propByRes.add(ResourceOperation.UPDATE, resource.getName());
+                                propByRes.add(ResourceOperation.UPDATE, resource.getName());
+                            }
                         }
                     }
                 }
@@ -664,19 +678,22 @@ public abstract class AbstractAttributab
                     derAttrDAO.delete(derAttr);
                 }
 
-                for (ExternalResource resource : resourceDAO.findAll()) {
-                    for (AbstractMappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
-                        if (derSchema.getName().equals(mapItem.getIntAttrName())
-                                && mapItem.getIntMappingType() == attrUtil.derIntMappingType()
-                                && attributable.getResources().contains(resource)) {
-
-                            propByRes.add(ResourceOperation.UPDATE, resource.getName());
-
-                            if (mapItem.isAccountid() && derAttr != null
-                                    && !derAttr.getValue(attributable.getAttrs()).isEmpty()) {
-
-                                propByRes.addOldAccountId(resource.getName(),
-                                        derAttr.getValue(attributable.getAttrs()));
+                if (attributable instanceof AbstractSubject) {
+                    for (ExternalResource resource : resourceDAO.findAll()) {
+                        for (AbstractMappingItem mapItem : attrUtil.
+                                getMappingItems(resource, MappingPurpose.PROPAGATION)) {
+                            if (derSchema.getName().equals(mapItem.getIntAttrName())
+                                    && mapItem.getIntMappingType() == attrUtil.derIntMappingType()
+                                    && ((AbstractSubject) attributable).getResources().contains(resource)) {
+
+                                propByRes.add(ResourceOperation.UPDATE, resource.getName());
+
+                                if (mapItem.isAccountid() && derAttr != null
+                                        && !derAttr.getValue(attributable.getAttrs()).isEmpty()) {
+
+                                    propByRes.addOldAccountId(resource.getName(),
+                                            derAttr.getValue(attributable.getAttrs()));
+                                }
                             }
                         }
                     }
@@ -690,13 +707,16 @@ public abstract class AbstractAttributab
         for (String derAttrToBeAdded : attributableMod.getDerAttrsToAdd()) {
             AbstractDerSchema derSchema = getDerSchema(derAttrToBeAdded, attrUtil.derSchemaClass());
             if (derSchema != null) {
-                for (ExternalResource resource : resourceDAO.findAll()) {
-                    for (AbstractMappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
-                        if (derSchema.getName().equals(mapItem.getIntAttrName())
-                                && mapItem.getIntMappingType() == attrUtil.derIntMappingType()
-                                && attributable.getResources().contains(resource)) {
+                if (attributable instanceof AbstractSubject) {
+                    for (ExternalResource resource : resourceDAO.findAll()) {
+                        for (AbstractMappingItem mapItem : attrUtil.
+                                getMappingItems(resource, MappingPurpose.PROPAGATION)) {
+                            if (derSchema.getName().equals(mapItem.getIntAttrName())
+                                    && mapItem.getIntMappingType() == attrUtil.derIntMappingType()
+                                    && ((AbstractSubject) attributable).getResources().contains(resource)) {
 
-                            propByRes.add(ResourceOperation.UPDATE, resource.getName());
+                                propByRes.add(ResourceOperation.UPDATE, resource.getName());
+                            }
                         }
                     }
                 }
@@ -839,11 +859,13 @@ public abstract class AbstractAttributab
         fillVirtual(attributable, attributableTO.getVirAttrs(), attributableUtil);
 
         // 4. resources
-        for (String resourceName : attributableTO.getResources()) {
-            ExternalResource resource = getResource(resourceName);
+        if (attributable instanceof AbstractSubject && attributableTO instanceof AbstractSubjectTO) {
+            for (String resourceName : ((AbstractSubjectTO) attributableTO).getResources()) {
+                ExternalResource resource = getResource(resourceName);
 
-            if (resource != null) {
-                attributable.addResource(resource);
+                if (resource != null) {
+                    ((AbstractSubject) attributable).addResource(resource);
+                }
             }
         }
 
@@ -892,8 +914,10 @@ public abstract class AbstractAttributab
             attributableTO.getVirAttrs().add(attributeTO);
         }
 
-        for (ExternalResource resource : resources) {
-            attributableTO.getResources().add(resource.getName());
+        if (attributableTO instanceof AbstractSubjectTO) {
+            for (ExternalResource resource : resources) {
+                ((AbstractSubjectTO) attributableTO).getResources().add(resource.getName());
+            }
         }
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java Thu Jun 19 13:04:39 2014
@@ -435,7 +435,7 @@ public class UserDataBinder extends Abst
 
             fillTO(membershipTO,
                     membership.getAttrs(), membership.getDerAttrs(), membership.getVirAttrs(),
-                    membership.getResources());
+                    Collections.<ExternalResource>emptyList());
 
             userTO.getMemberships().add(membershipTO);
         }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java Thu Jun 19 13:04:39 2014
@@ -23,20 +23,19 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import javax.ws.rs.BadRequestException;
-
 import javax.ws.rs.core.Response;
-
-import org.apache.syncope.common.services.ResourceService;
-import org.apache.syncope.common.to.AbstractAttributableTO;
 import org.apache.syncope.common.reqres.BulkAction;
 import org.apache.syncope.common.reqres.BulkActionResult;
+import org.apache.syncope.common.services.ResourceService;
+import org.apache.syncope.common.to.AbstractAttributableTO;
 import org.apache.syncope.common.to.ConnObjectTO;
-import org.apache.syncope.common.wrap.PropagationActionClass;
 import org.apache.syncope.common.to.ResourceTO;
 import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.types.RESTHeaders;
 import org.apache.syncope.common.types.ResourceDeassociationActionType;
+import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.common.util.CollectionWrapper;
+import org.apache.syncope.common.wrap.PropagationActionClass;
 import org.apache.syncope.common.wrap.SubjectId;
 import org.apache.syncope.core.rest.controller.AbstractResourceAssociator;
 import org.apache.syncope.core.rest.controller.ResourceController;
@@ -97,7 +96,7 @@ public class ResourceServiceImpl extends
     }
 
     @Override
-    public ConnObjectTO getConnectorObject(final String resourceName, final AttributableType type, final Long id) {
+    public ConnObjectTO getConnectorObject(final String resourceName, final SubjectType type, final Long id) {
         return controller.getConnectorObject(resourceName, type, id);
     }
 
@@ -112,14 +111,10 @@ public class ResourceServiceImpl extends
     }
 
     @Override
-    public BulkActionResult bulkDeassociation(final String resourceName, final AttributableType attrType,
+    public BulkActionResult bulkDeassociation(final String resourceName, final SubjectType subjectType,
             final ResourceDeassociationActionType type, final List<SubjectId> subjectIds) {
 
-        if (attrType == AttributableType.MEMBERSHIP) {
-            throw new BadRequestException();
-        }
-
-        AbstractResourceAssociator<? extends AbstractAttributableTO> associator = attrType == AttributableType.USER
+        AbstractResourceAssociator<? extends AbstractAttributableTO> associator = subjectType == SubjectType.USER
                 ? userController
                 : roleController;
 
@@ -146,7 +141,7 @@ public class ResourceServiceImpl extends
 
                 res.add(id, BulkActionResult.Status.SUCCESS);
             } catch (Exception e) {
-                LOG.warn("While executing {} on {} {}", type, attrType, id.getElement(), e);
+                LOG.warn("While executing {} on {} {}", type, subjectType, id.getElement(), e);
                 res.add(id, BulkActionResult.Status.FAILURE);
             }
         }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java Thu Jun 19 13:04:39 2014
@@ -25,10 +25,9 @@ import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.StreamingOutput;
-
 import org.apache.syncope.common.services.WorkflowService;
-import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.types.RESTHeaders;
+import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.core.rest.controller.WorkflowController;
 import org.apache.syncope.core.workflow.ActivitiDetector;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,11 +40,12 @@ public class WorkflowServiceImpl extends
     private WorkflowController controller;
 
     @Override
-    public Response getOptions(final AttributableType kind) {
+    public Response getOptions(final SubjectType kind) {
         String key = null;
         String value = null;
         switch (kind) {
             case USER:
+            default:
                 key = RESTHeaders.ACTIVITI_USER_ENABLED;
                 value = Boolean.toString(ActivitiDetector.isActivitiEnabledForUsers());
                 break;
@@ -54,9 +54,6 @@ public class WorkflowServiceImpl extends
                 key = RESTHeaders.ACTIVITI_ROLE_ENABLED;
                 value = Boolean.toString(ActivitiDetector.isActivitiEnabledForRoles());
                 break;
-
-            case MEMBERSHIP:
-            default:
         }
 
         Response.ResponseBuilder builder = Response.ok().header(HttpHeaders.ALLOW, OPTIONS_ALLOW);
@@ -67,7 +64,7 @@ public class WorkflowServiceImpl extends
     }
 
     @Override
-    public Response exportDefinition(final AttributableType kind) {
+    public Response exportDefinition(final SubjectType kind) {
         final MediaType accept =
                 messageContext.getHttpHeaders().getAcceptableMediaTypes().contains(MediaType.APPLICATION_JSON_TYPE)
                 ? MediaType.APPLICATION_JSON_TYPE
@@ -98,22 +95,20 @@ public class WorkflowServiceImpl extends
     }
 
     @Override
-    public Response exportDiagram(final AttributableType kind) {
+    public Response exportDiagram(final SubjectType kind) {
         StreamingOutput sout = new StreamingOutput() {
 
             @Override
             public void write(final OutputStream os) throws IOException {
                 switch (kind) {
                     case USER:
+                    default:
                         controller.exportUserDiagram(os);
                         break;
 
                     case ROLE:
                         controller.exportRoleDiagram(os);
                         break;
-
-                    default:
-                        throw new BadRequestException();
                 }
             }
         };
@@ -124,7 +119,7 @@ public class WorkflowServiceImpl extends
     }
 
     @Override
-    public void importDefinition(final AttributableType kind, final String definition) {
+    public void importDefinition(final SubjectType kind, final String definition) {
         final MediaType contentType =
                 messageContext.getHttpHeaders().getMediaType().equals(MediaType.APPLICATION_JSON_TYPE)
                 ? MediaType.APPLICATION_JSON_TYPE
@@ -132,15 +127,13 @@ public class WorkflowServiceImpl extends
 
         switch (kind) {
             case USER:
+            default:
                 controller.importUserDefinition(contentType, definition);
                 break;
 
             case ROLE:
                 controller.importRoleDefinition(contentType, definition);
                 break;
-
-            default:
-                throw new BadRequestException();
         }
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java Thu Jun 19 13:04:39 2014
@@ -19,6 +19,7 @@
 package org.apache.syncope.core.sync.impl;
 
 import static org.apache.syncope.core.sync.impl.AbstractSyncopeResultHandler.LOG;
+
 import java.util.AbstractMap;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -34,6 +35,7 @@ import org.apache.syncope.core.persisten
 import org.apache.syncope.core.persistence.dao.search.AttributeCond;
 import org.apache.syncope.core.persistence.dao.search.SearchCond;
 import org.apache.syncope.common.to.AbstractAttributableTO;
+import org.apache.syncope.common.to.AbstractSubjectTO;
 import org.apache.syncope.common.to.AttributeTO;
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.to.UserTO;
@@ -392,8 +394,7 @@ public class SyncopeSyncResultHandler ex
             final SyncDelta delta, final AttributableUtil attrUtil, final boolean dryRun)
             throws JobExecutionException {
 
-        final AbstractAttributableTO subjectTO =
-                connObjectUtil.getAttributableTO(delta.getObject(), syncTask, attrUtil);
+        final AbstractSubjectTO subjectTO = connObjectUtil.getSubjectTO(delta.getObject(), syncTask, attrUtil);
 
         subjectTO.getResources().add(getSyncTask().getResource().getName());
 
@@ -410,7 +411,7 @@ public class SyncopeSyncResultHandler ex
             throws JobExecutionException {
 
         final AbstractAttributableTO subjectTO =
-                connObjectUtil.getAttributableTO(delta.getObject(), syncTask, attrUtil);
+                connObjectUtil.getSubjectTO(delta.getObject(), syncTask, attrUtil);
 
         SyncDelta _delta = delta;
         for (SyncActions action : actions) {

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java?rev=1603867&r1=1603866&r2=1603867&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java Thu Jun 19 13:04:39 2014
@@ -23,12 +23,14 @@ import java.util.Collections;
 import java.util.List;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.common.to.AbstractAttributableTO;
+import org.apache.syncope.common.to.AbstractSubjectTO;
 import org.apache.syncope.common.to.MembershipTO;
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.types.IntMappingType;
 import org.apache.syncope.common.types.MappingPurpose;
+import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.common.types.SyncPolicySpec;
 import org.apache.syncope.core.persistence.beans.AbstractAttr;
 import org.apache.syncope.core.persistence.beans.AbstractAttrTemplate;
@@ -87,7 +89,7 @@ public final class AttributableUtil {
     /**
      * Logger.
      */
-    protected static final Logger LOG = LoggerFactory.getLogger(AttributableUtil.class);
+    private static final Logger LOG = LoggerFactory.getLogger(AttributableUtil.class);
 
     private final AttributableType type;
 
@@ -235,7 +237,9 @@ public final class AttributableUtil {
         switch (purpose) {
             case SYNCHRONIZATION:
                 for (T item : items) {
-                    if (MappingPurpose.PROPAGATION != item.getPurpose() && MappingPurpose.NONE != item.getPurpose()) {
+                    if (MappingPurpose.PROPAGATION != item.getPurpose()
+                            && MappingPurpose.NONE != item.getPurpose()) {
+
                         result.add(item);
                     }
                 }
@@ -243,7 +247,9 @@ public final class AttributableUtil {
 
             case PROPAGATION:
                 for (T item : items) {
-                    if (MappingPurpose.SYNCHRONIZATION != item.getPurpose() && MappingPurpose.NONE != item.getPurpose()) {
+                    if (MappingPurpose.SYNCHRONIZATION != item.getPurpose()
+                            && MappingPurpose.NONE != item.getPurpose()) {
+
                         result.add(item);
                     }
                 }
@@ -708,7 +714,6 @@ public final class AttributableUtil {
     }
 
     public SyncCorrelationRule getCorrelationRule(final SyncPolicySpec policySpec) {
-
         String clazz;
 
         switch (type) {
@@ -753,4 +758,21 @@ public final class AttributableUtil {
 
         return result;
     }
+
+    public <T extends AbstractSubjectTO> T newSubjectTO() {
+        T result = null;
+
+        switch (type) {
+            case USER:
+                result = (T) new UserTO();
+                break;
+            case ROLE:
+                result = (T) new RoleTO();
+                break;
+            case MEMBERSHIP:
+                break;
+        }
+
+        return result;
+    }
 }