syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmarte...@apache.org
Subject svn commit: r1295610 [1/2] - in /incubator/syncope/trunk/core/src: main/java/org/syncope/core/persistence/beans/ main/java/org/syncope/core/persistence/beans/user/ main/java/org/syncope/core/persistence/dao/impl/ main/java/org/syncope/core/propagation/...
Date Thu, 01 Mar 2012 15:09:24 GMT
Author: fmartelli
Date: Thu Mar  1 15:09:24 2012
New Revision: 1295610

URL: http://svn.apache.org/viewvc?rev=1295610&view=rev
Log:
SYNCOPE-16 #comment fixed issue

Modified:
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/AbstractAttributable.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/AbstractVirAttr.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/user/SyncopeUser.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/user/UVirAttr.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/dao/impl/UserDAOImpl.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/propagation/ConnectorFacadeProxy.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/propagation/PropagationManager.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/UserController.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/AbstractAttributableDataBinder.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/UserDataBinder.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/workflow/activiti/Create.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/workflow/activiti/Update.java
    incubator/syncope/trunk/core/src/test/java/org/syncope/core/rest/UserTestITCase.java

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/AbstractAttributable.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/AbstractAttributable.java?rev=1295610&r1=1295609&r2=1295610&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/AbstractAttributable.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/AbstractAttributable.java Thu Mar  1 15:09:24 2012
@@ -47,8 +47,7 @@ public abstract class AbstractAttributab
         return result;
     }
 
-    public <T extends AbstractDerAttr> T getDerivedAttribute(
-            final String derivedSchemaName) {
+    public <T extends AbstractDerAttr> T getDerivedAttribute(final String derivedSchemaName) {
 
         T result = null;
         T derivedAttribute;
@@ -58,8 +57,7 @@ public abstract class AbstractAttributab
 
             derivedAttribute = (T) itor.next();
             if (derivedAttribute.getDerivedSchema() != null
-                    && derivedSchemaName.equals(
-                    derivedAttribute.getDerivedSchema().getName())) {
+                    && derivedSchemaName.equals(derivedAttribute.getDerivedSchema().getName())) {
 
                 result = derivedAttribute;
             }
@@ -68,19 +66,17 @@ public abstract class AbstractAttributab
         return result;
     }
 
-    public <T extends AbstractVirAttr> T getVirtualAttribute(
-            final String virtualSchemaName) {
+    public <T extends AbstractVirAttr> T getVirtualAttribute(final String virtualSchemaName) {
 
         T result = null;
         T virtualAttribute;
-        for (Iterator<? extends AbstractVirAttr> itor =
-                getVirtualAttributes().iterator();
+        for (Iterator<? extends AbstractVirAttr> itor = getVirtualAttributes().iterator();
                 result == null && itor.hasNext();) {
 
             virtualAttribute = (T) itor.next();
+
             if (virtualAttribute.getVirtualSchema() != null
-                    && virtualSchemaName.equals(
-                    virtualAttribute.getVirtualSchema().getName())) {
+                    && virtualSchemaName.equals(virtualAttribute.getVirtualSchema().getName())) {
 
                 result = virtualAttribute;
             }
@@ -90,8 +86,7 @@ public abstract class AbstractAttributab
     }
 
     protected Map<AbstractSchema, AbstractAttr> getAttrMap() {
-        final Map<AbstractSchema, AbstractAttr> map =
-                new HashMap<AbstractSchema, AbstractAttr>();
+        final Map<AbstractSchema, AbstractAttr> map = new HashMap<AbstractSchema, AbstractAttr>();
 
         for (AbstractAttr attr : getAttributes()) {
             map.put((AbstractSchema) attr.getSchema(), attr);
@@ -101,8 +96,7 @@ public abstract class AbstractAttributab
     }
 
     protected Map<AbstractDerSchema, AbstractDerAttr> getDerAttrMap() {
-        final Map<AbstractDerSchema, AbstractDerAttr> map =
-                new HashMap<AbstractDerSchema, AbstractDerAttr>();
+        final Map<AbstractDerSchema, AbstractDerAttr> map = new HashMap<AbstractDerSchema, AbstractDerAttr>();
 
         for (AbstractDerAttr attr : getDerivedAttributes()) {
             map.put((AbstractDerSchema) attr.getDerivedSchema(), attr);
@@ -112,8 +106,7 @@ public abstract class AbstractAttributab
     }
 
     protected Map<AbstractVirSchema, AbstractVirAttr> getVirAttrMap() {
-        final Map<AbstractVirSchema, AbstractVirAttr> map =
-                new HashMap<AbstractVirSchema, AbstractVirAttr>();
+        final Map<AbstractVirSchema, AbstractVirAttr> map = new HashMap<AbstractVirSchema, AbstractVirAttr>();
 
         for (AbstractVirAttr attr : getVirtualAttributes()) {
             map.put((AbstractVirSchema) attr.getVirtualSchema(), attr);

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/AbstractVirAttr.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/AbstractVirAttr.java?rev=1295610&r1=1295609&r2=1295610&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/AbstractVirAttr.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/AbstractVirAttr.java Thu Mar  1 15:09:24 2012
@@ -29,6 +29,7 @@ import javax.persistence.MappedSuperclas
 import javax.persistence.Transient;
 import org.identityconnectors.framework.common.objects.Attribute;
 import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
 import org.identityconnectors.framework.common.objects.Uid;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.syncope.core.init.ConnInstanceLoader;
@@ -57,23 +58,25 @@ public abstract class AbstractVirAttr ex
     }
 
     protected <T extends AbstractAttributable> List<Object> retrieveValues(
-            final T attributable, final String attributeName,
-            final IntMappingType intMappingType) {
+            final T attributable, final String attributeName, final IntMappingType intMappingType) {
 
-        LOG.debug("{}: retrieving external values for {}",
-                new Object[]{attributable, attributeName});
+        LOG.debug("{}: retrieving external values for {}", new Object[]{attributable, attributeName});
+
+        List<Object> virAttrValues = new ArrayList<Object>();
+
+        // if attributable is not defined it won't be possible to retrieve values from external resources.
+        if (attributable == null) {
+            return virAttrValues;
+        }
+
+        ConfigurableApplicationContext context = ApplicationContextManager.getApplicationContext();
+        ConnInstanceLoader connInstanceLoader = context.getBean(ConnInstanceLoader.class);
 
-        ConfigurableApplicationContext context =
-                ApplicationContextManager.getApplicationContext();
-        ConnInstanceLoader connInstanceLoader =
-                context.getBean(ConnInstanceLoader.class);
         if (connInstanceLoader == null) {
             LOG.error("Could not get to ConnInstanceLoader");
             return null;
         }
 
-        List<Object> virAttrValues = new ArrayList<Object>();
-
         for (ExternalResource resource : attributable.getResources()) {
             LOG.debug("Retrieving attribute mapped on {}", resource);
 
@@ -88,23 +91,18 @@ public abstract class AbstractVirAttr ex
                             + "\n\tSource: " + mapping.getIntAttrName()
                             + "\n\tDestination: " + mapping.getExtAttrName()
                             + "\n\tType: " + mapping.getIntMappingType()
-                            + "\n\tMandatory condition: "
-                            + mapping.getMandatoryCondition()
+                            + "\n\tMandatory condition: " + mapping.getMandatoryCondition()
                             + "\n\tAccountId: " + mapping.isAccountid()
                             + "\n\tPassword: " + mapping.isPassword());
                 }
 
-                if (attributeName.equals(mapping.getIntAttrName())
-                        && mapping.getIntMappingType() == intMappingType) {
-
+                if (attributeName.equals(mapping.getIntAttrName()) && mapping.getIntMappingType() == intMappingType) {
                     attributeNames.add(mapping.getExtAttrName());
                 }
 
                 if (mapping.isAccountid()) {
                     try {
-                        accountId = attributable.getAttribute(
-                                mapping.getIntAttrName()).
-                                getValuesAsStrings().get(0);
+                        accountId = attributable.getAttribute(mapping.getIntAttrName()).getValuesAsStrings().get(0);
                     } catch (NullPointerException e) {
                         // ignore exception
                         LOG.debug("Invalid accountId specified", e);
@@ -116,13 +114,14 @@ public abstract class AbstractVirAttr ex
                 LOG.debug("Get object attribute for entry {}", accountId);
 
                 try {
-                    ConnectorFacadeProxy connector =
-                            connInstanceLoader.getConnector(resource);
+
+                    final OperationOptionsBuilder oob = new OperationOptionsBuilder();
+                    oob.setAttributesToGet(attributeNames);
+
+                    final ConnectorFacadeProxy connector = connInstanceLoader.getConnector(resource);
+
                     Set<Attribute> attributes = connector.getObjectAttributes(
-                            ObjectClass.ACCOUNT,
-                            new Uid(accountId),
-                            null,
-                            attributeNames);
+                            ObjectClass.ACCOUNT, new Uid(accountId), oob.build(), attributeNames);
 
                     LOG.debug("Retrieved {}", attributes);
 

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/user/SyncopeUser.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/user/SyncopeUser.java?rev=1295610&r1=1295609&r2=1295610&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/user/SyncopeUser.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/user/SyncopeUser.java Thu Mar  1 15:09:24 2012
@@ -342,9 +342,7 @@ public class SyncopeUser extends Abstrac
     }
 
     @Override
-    public void setDerivedAttributes(
-            final List<? extends AbstractDerAttr> derivedAttributes) {
-
+    public void setDerivedAttributes(final List<? extends AbstractDerAttr> derivedAttributes) {
         this.derivedAttributes.clear();
         if (derivedAttributes != null && !derivedAttributes.isEmpty()) {
             this.derivedAttributes.addAll((List<UDerAttr>) derivedAttributes);
@@ -352,16 +350,12 @@ public class SyncopeUser extends Abstrac
     }
 
     @Override
-    public <T extends AbstractVirAttr> boolean addVirtualAttribute(
-            final T virtualAttribute) {
-
+    public <T extends AbstractVirAttr> boolean addVirtualAttribute(final T virtualAttribute) {
         return virtualAttributes.add((UVirAttr) virtualAttribute);
     }
 
     @Override
-    public <T extends AbstractVirAttr> boolean removeVirtualAttribute(
-            final T virtualAttribute) {
-
+    public <T extends AbstractVirAttr> boolean removeVirtualAttribute(final T virtualAttribute) {
         return virtualAttributes.remove((UVirAttr) virtualAttribute);
     }
 
@@ -371,9 +365,7 @@ public class SyncopeUser extends Abstrac
     }
 
     @Override
-    public void setVirtualAttributes(
-            final List<? extends AbstractVirAttr> virtualAttributes) {
-
+    public void setVirtualAttributes(final List<? extends AbstractVirAttr> virtualAttributes) {
         this.virtualAttributes.clear();
         if (virtualAttributes != null && !virtualAttributes.isEmpty()) {
             this.virtualAttributes.addAll((List<UVirAttr>) virtualAttributes);

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/user/UVirAttr.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/user/UVirAttr.java?rev=1295610&r1=1295609&r2=1295610&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/user/UVirAttr.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/beans/user/UVirAttr.java Thu Mar  1 15:09:24 2012
@@ -63,17 +63,14 @@ public class UVirAttr extends AbstractVi
 
     @Override
     public List<String> getValues() {
-        LOG.debug("{}: retrieve value for attribute {}",
-                new Object[]{getOwner(), getVirtualSchema().getName()});
+        LOG.debug("{}: retrieve value for attribute {}", new Object[]{getOwner(), getVirtualSchema().getName()});
 
         if (values != null) {
             return values;
         }
 
         final List<Object> retrievedValues =
-                retrieveValues(getOwner(),
-                getVirtualSchema().getName(),
-                IntMappingType.UserVirtualSchema);
+                retrieveValues(getOwner(), getVirtualSchema().getName(), IntMappingType.UserVirtualSchema);
 
         LOG.debug("Retrieved external values {}", retrievedValues);
 

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/dao/impl/UserDAOImpl.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/dao/impl/UserDAOImpl.java?rev=1295610&r1=1295609&r2=1295610&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/dao/impl/UserDAOImpl.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/persistence/dao/impl/UserDAOImpl.java Thu Mar  1 15:09:24 2012
@@ -112,18 +112,16 @@ public class UserDAOImpl extends Abstrac
     }
 
     /**
-     * Find users by derived attribute value. This method could fail if one or
-     * more string literals contained into the derived attribute value provided
-     * derive from identifier (schema name) replacement. When you are going to
-     * specify a derived attribute expression you must be quite sure that string
-     * literals used to build the expression cannot be found into the attribute
-     * values used to replace attribute schema names used as identifiers.
+     * Find users by derived attribute value. This method could fail if one or more string literals contained into the
+     * derived attribute value provided derive from identifier (schema name) replacement. When you are going to specify
+     * a derived attribute expression you must be quite sure that string literals used to build the expression cannot be
+     * found into the attribute values used to replace attribute schema names used as identifiers.
      *
      * @param schemaName derived schema name.
      * @param value derived attribute value.
      * @return list of users.
-     * @throws InvalidSearchConditionException in case of errors retrieving
-     * schema names used to buid the derived schema expression.
+     * @throws InvalidSearchConditionException in case of errors retrieving schema names used to buid the derived schema
+     * expression.
      */
     @Override
     public List<SyncopeUser> findByDerAttrValue(
@@ -356,8 +354,7 @@ public class UserDAOImpl extends Abstrac
         SyncopeUser merged = entityManager.merge(user);
 
         for (AbstractVirAttr virtual : merged.getVirtualAttributes()) {
-            virtual.setValues(user.getVirtualAttribute(
-                    virtual.getVirtualSchema().getName()).getValues());
+            virtual.setValues(user.getVirtualAttribute(virtual.getVirtualSchema().getName()).getValues());
         }
 
         return merged;
@@ -396,14 +393,12 @@ public class UserDAOImpl extends Abstrac
     }
 
     /**
-     * Generate one where clause for each different attribute schema into the
-     * derived schema expression provided.
+     * Generate one where clause for each different attribute schema into the derived schema expression provided.
      *
      * @param expression derived schema expression.
      * @param value derived attribute value.
      * @return where clauses to use to build the query.
-     * @throws InvalidSearchConditionException in case of errors retrieving
-     * identifiers.
+     * @throws InvalidSearchConditionException in case of errors retrieving identifiers.
      */
     private Set<String> getWhereClause(
             final String expression, final String value)

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/propagation/ConnectorFacadeProxy.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/propagation/ConnectorFacadeProxy.java?rev=1295610&r1=1295609&r2=1295610&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/propagation/ConnectorFacadeProxy.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/propagation/ConnectorFacadeProxy.java Thu Mar  1 15:09:24 2012
@@ -571,8 +571,7 @@ public class ConnectorFacadeProxy {
         final Set<Attribute> attributes = new HashSet<Attribute>();
 
         try {
-            final ConnectorObject object =
-                    connector.getObject(objectClass, uid, options);
+            final ConnectorObject object = connector.getObject(objectClass, uid, options);
 
             for (String attribute : attributeNames) {
                 attributes.add(object.getAttributeByName(attribute));

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/propagation/PropagationManager.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/propagation/PropagationManager.java?rev=1295610&r1=1295609&r2=1295610&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/propagation/PropagationManager.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/propagation/PropagationManager.java Thu Mar  1 15:09:24 2012
@@ -163,8 +163,7 @@ public class PropagationManager {
     /**
      * Create the user on every associated resource.
      *
-     * @param wfResult user to be propagated (and info associated), as per
-     * result from workflow
+     * @param wfResult user to be propagated (and info associated), as per result from workflow
      * @param password to be set
      * @param vAttrs virtual attributes to be set
      * @return list of propagation tasks
@@ -181,12 +180,10 @@ public class PropagationManager {
     /**
      * Create the user on every associated resource.
      *
-     * @param wfResult user to be propagated (and info associated), as per
-     * result from workflow.
+     * @param wfResult user to be propagated (and info associated), as per result from workflow.
      * @param password to be set.
      * @param vAttrs virtual attributes to be set.
-     * @param syncResourceNames external resources performing sync, hence not to
-     * be considered for propagation.
+     * @param syncResourceNames external resources performing sync, hence not to be considered for propagation.
      * @return list of propagation tasks.
      * @throws NotFoundException if userId is not found.
      */
@@ -217,14 +214,12 @@ public class PropagationManager {
     }
 
     /**
-     * Performs update on each resource associated to the user excluding the
-     * specified into 'resourceNames' parameter.
+     * Performs update on each resource associated to the user excluding the specified into 'resourceNames' parameter.
      *
      * @param user to be propagated.
      * @param enable wether user must be enabled or not.
-     * @param syncResourceNames external resource names not to be considered for
-     * propagation. Use this during sync and disable/enable actions limited to
-     * the external resources only.
+     * @param syncResourceNames external resource names not to be considered for propagation. Use this during sync and
+     * disable/enable actions limited to the external resources only.
      * @return list of propagation tasks
      * @throws NotFoundException if userId is not found
      */
@@ -247,8 +242,7 @@ public class PropagationManager {
     /**
      * Performs update on each resource associated to the user.
      *
-     * @param wfResult user to be propagated (and info associated), as per
-     * result from workflow.
+     * @param wfResult user to be propagated (and info associated), as per result from workflow.
      * @param enable wether user must be enabled or not.
      * @return list of propagation tasks
      * @throws NotFoundException if userId is not found
@@ -265,8 +259,7 @@ public class PropagationManager {
     /**
      * Performs update on each resource associated to the user.
      *
-     * @param wfResult user to be propagated (and info associated), as per
-     * result from workflow
+     * @param wfResult user to be propagated (and info associated), as per result from workflow
      * @param password to be updated
      * @param vAttrsToBeRemoved virtual attributes to be removed
      * @param vAttrsToBeUpdated virtual attributes to be added
@@ -282,22 +275,19 @@ public class PropagationManager {
             final Boolean enable)
             throws NotFoundException {
 
-        return getUpdateTaskIds(wfResult, password, vAttrsToBeRemoved,
-                vAttrsToBeUpdated, enable, null);
+        return getUpdateTaskIds(wfResult, password, vAttrsToBeRemoved, vAttrsToBeUpdated, enable, null);
     }
 
     /**
      * Performs update on each resource associated to the user.
      *
-     * @param wfResult user to be propagated (and info associated), as per
-     * result from workflow
+     * @param wfResult user to be propagated (and info associated), as per result from workflow
      * @param password to be updated
      * @param vAttrsToBeRemoved virtual attributes to be removed
      * @param vAttrsToBeUpdated virtual attributes to be added
      * @param enable wether user must be enabled or not
-     * @param syncResourceNames external resource names not to be considered for
-     * propagation. Use this during sync and disable/enable actions limited to
-     * the external resources only.
+     * @param syncResourceNames external resource names not to be considered for propagation. Use this during sync and
+     * disable/enable actions limited to the external resources only.
      * @return list of propagation tasks
      * @throws NotFoundException if userId is not found
      */
@@ -334,10 +324,8 @@ public class PropagationManager {
 
         PropagationByResource localPropByRes = userDataBinder.fillVirtual(
                 user,
-                vAttrsToBeRemoved == null
-                ? Collections.EMPTY_SET : vAttrsToBeRemoved,
-                vAttrsToBeUpdated == null
-                ? Collections.EMPTY_SET : vAttrsToBeUpdated,
+                vAttrsToBeRemoved == null ? Collections.EMPTY_SET : vAttrsToBeRemoved,
+                vAttrsToBeUpdated == null ? Collections.EMPTY_SET : vAttrsToBeUpdated, 
                 AttributableUtil.USER);
 
         if (propByRes != null && !propByRes.isEmpty()) {
@@ -360,10 +348,9 @@ public class PropagationManager {
     }
 
     /**
-     * Perform delete on each resource associated to the user. It is possible to
-     * ask for a mandatory provisioning for some resources specifying a set of
-     * resource names. Exceptions won't be ignored and the process will be
-     * stopped if the creation fails onto a mandatory resource.
+     * Perform delete on each resource associated to the user. It is possible to ask for a mandatory provisioning for
+     * some resources specifying a set of resource names. Exceptions won't be ignored and the process will be stopped if
+     * the creation fails onto a mandatory resource.
      *
      * @param userId to be deleted
      * @return list of propagation tasks
@@ -376,14 +363,12 @@ public class PropagationManager {
     }
 
     /**
-     * Perform delete on each resource associated to the user. It is possible to
-     * ask for a mandatory provisioning for some resources specifying a set of
-     * resource names. Exceptions won't be ignored and the process will be
-     * stopped if the creation fails onto a mandatory resource.
+     * Perform delete on each resource associated to the user. It is possible to ask for a mandatory provisioning for
+     * some resources specifying a set of resource names. Exceptions won't be ignored and the process will be stopped if
+     * the creation fails onto a mandatory resource.
      *
      * @param userId to be deleted
-     * @param syncResourceName name of external resource performing sync, hence
-     * not to be considered for propagation
+     * @param syncResourceName name of external resource performing sync, hence not to be considered for propagation
      * @return list of propagation tasks
      * @throws NotFoundException if user is not found
      */
@@ -458,8 +443,7 @@ public class PropagationManager {
      * @param user given user
      * @param password clear-text password
      * @return account link + prepare attributes
-     * @throws ClassNotFoundException if schema type for given mapping does not
-     * exists in current class loader
+     * @throws ClassNotFoundException if schema type for given mapping does not exists in current class loader
      */
     private Map.Entry<String, Attribute> prepareAttribute(
             final SchemaMapping mapping,
@@ -467,8 +451,7 @@ public class PropagationManager {
             final String password)
             throws ClassNotFoundException {
 
-        final List<AbstractAttributable> attributables =
-                new ArrayList<AbstractAttributable>();
+        final List<AbstractAttributable> attributables = new ArrayList<AbstractAttributable>();
 
         switch (mapping.getIntMappingType().getEntity()) {
             case USER:
@@ -491,8 +474,7 @@ public class PropagationManager {
 
         final List<AbstractAttrValue> values = entry.getValue();
         final AbstractSchema schema = entry.getKey();
-        final SchemaType schemaType =
-                schema == null ? SchemaType.String : schema.getType();
+        final SchemaType schemaType = schema == null ? SchemaType.String : schema.getType();
 
         LOG.debug("Define mapping for: "
                 + "\n* ExtAttrName " + mapping.getExtAttrName()
@@ -510,8 +492,7 @@ public class PropagationManager {
 
         List<Object> objValues = new ArrayList<Object>();
         for (AbstractAttrValue value : values) {
-            if (FrameworkUtil.isSupportedAttributeType(
-                    Class.forName(schemaType.getClassName()))) {
+            if (FrameworkUtil.isSupportedAttributeType(Class.forName(schemaType.getClassName()))) {
                 objValues.add(value.getValue());
             } else {
                 objValues.add(value.getValueAsString());
@@ -522,20 +503,16 @@ public class PropagationManager {
 
         if (mapping.isAccountid()) {
 
-            res = new DefaultMapEntry(
-                    objValues.iterator().next().toString(), null);
+            res = new DefaultMapEntry(objValues.iterator().next().toString(), null);
 
         } else if (mapping.isPassword()) {
 
-            res = new DefaultMapEntry(null,
-                    AttributeBuilder.buildPassword(
-                    objValues.iterator().next().toString().toCharArray()));
+            res = new DefaultMapEntry(
+                    null, AttributeBuilder.buildPassword(objValues.iterator().next().toString().toCharArray()));
 
         } else {
             if (schema != null && schema.isMultivalue()) {
-                res = new DefaultMapEntry(null,
-                        AttributeBuilder.build(mapping.getExtAttrName(),
-                        objValues));
+                res = new DefaultMapEntry(null, AttributeBuilder.build(mapping.getExtAttrName(), objValues));
 
             } else {
                 res = new DefaultMapEntry(null,
@@ -604,8 +581,7 @@ public class PropagationManager {
             case MembershipVirtualSchema:
 
                 for (AbstractAttributable attributable : attributables) {
-                    AbstractVirAttr virAttr = attributable.getVirtualAttribute(
-                            mapping.getIntAttrName());
+                    AbstractVirAttr virAttr = attributable.getVirtualAttribute(mapping.getIntAttrName());
 
                     if (virAttr != null && virAttr.getValues() != null) {
                         for (String value : virAttr.getValues()) {
@@ -619,8 +595,7 @@ public class PropagationManager {
                             + "\n* IntAttrName {}"
                             + "\n* IntMappingType {}"
                             + "\n* Attribute values {}",
-                            new Object[]{virAttr, mapping.getIntAttrName(),
-                                mapping.getIntMappingType(), values});
+                            new Object[]{virAttr, mapping.getIntAttrName(), mapping.getIntMappingType(), values});
                 }
                 break;
 
@@ -837,9 +812,8 @@ public class PropagationManager {
      * Execute a list of PropagationTask, in given order.
      *
      * @param tasks to be execute, in given order
-     * @throws PropagationException if propagation goes wrong: propagation is
-     * interrupted as soon as the result of the communication with a primary
-     * resource is in error
+     * @throws PropagationException if propagation goes wrong: propagation is interrupted as soon as the result of the
+     * communication with a primary resource is in error
      */
     public void execute(
             final List<PropagationTask> tasks,
@@ -1153,7 +1127,7 @@ public class PropagationManager {
                     ? task.getAccountId()
                     : task.getOldAccountId()),
                     connector.getOperationOptions(task.getResource()));
-            
+
         } catch (RuntimeException ignore) {
             LOG.debug("Resolving username", ignore);
             return null;

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/UserController.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/UserController.java?rev=1295610&r1=1295609&r2=1295610&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/UserController.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/UserController.java Thu Mar  1 15:09:24 2012
@@ -62,8 +62,8 @@ import org.syncope.core.workflow.Workflo
 import org.syncope.types.PropagationTaskExecStatus;
 
 /**
- * Note that this controller does not extend AbstractController, hence does not
- * provide any Spring's @Transactional logic at class level.
+ * Note that this controller does not extend AbstractController, hence does not provide any Spring's @Transactional
+ * logic at class level.
  *
  * @see AbstractController
  */
@@ -210,8 +210,7 @@ public class UserController {
         }
 
         List<SyncopeUser> matchingUsers = searchDAO.search(
-                EntitlementUtil.getRoleIds(EntitlementUtil.
-                getOwnedEntitlementNames()), searchCondition);
+                EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames()), searchCondition);
         List<UserTO> result = new ArrayList<UserTO>(matchingUsers.size());
         for (SyncopeUser user : matchingUsers) {
             result.add(userDataBinder.getUserTO(user));
@@ -253,30 +252,26 @@ public class UserController {
     @PreAuthorize("hasRole('USER_CREATE')")
     @RequestMapping(method = RequestMethod.POST,
     value = "/create")
-    public UserTO create(final HttpServletResponse response,
-            @RequestBody final UserTO userTO)
-            throws PropagationException, UnauthorizedRoleException,
-            WorkflowException, NotFoundException {
+    public UserTO create(final HttpServletResponse response, @RequestBody final UserTO userTO)
+            throws PropagationException, UnauthorizedRoleException, WorkflowException, NotFoundException {
 
         LOG.debug("User create called with {}", userTO);
 
-        Set<Long> requestRoleIds =
-                new HashSet<Long>(userTO.getMemberships().size());
+        Set<Long> requestRoleIds = new HashSet<Long>(userTO.getMemberships().size());
         for (MembershipTO membership : userTO.getMemberships()) {
             requestRoleIds.add(membership.getRoleId());
         }
-        Set<Long> adminRoleIds = EntitlementUtil.getRoleIds(
-                EntitlementUtil.getOwnedEntitlementNames());
+
+        Set<Long> adminRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
         requestRoleIds.removeAll(adminRoleIds);
         if (!requestRoleIds.isEmpty()) {
             throw new UnauthorizedRoleException(requestRoleIds);
         }
 
-        WorkflowResult<Map.Entry<Long, Boolean>> created =
-                wfAdapter.create(userTO);
+        WorkflowResult<Map.Entry<Long, Boolean>> created = wfAdapter.create(userTO);
 
-        List<PropagationTask> tasks = propagationManager.getCreateTaskIds(
-                created, userTO.getPassword(), userTO.getVirtualAttributes());
+        List<PropagationTask> tasks =
+                propagationManager.getCreateTaskIds(created, userTO.getPassword(), userTO.getVirtualAttributes());
 
         final List<PropagationTO> propagations = new ArrayList<PropagationTO>();
 
@@ -308,12 +303,9 @@ public class UserController {
         });
 
         notificationManager.createTasks(new WorkflowResult<Long>(
-                created.getResult().getKey(),
-                created.getPropByRes(),
-                created.getPerformedTasks()));
+                created.getResult().getKey(), created.getPropByRes(), created.getPerformedTasks()));
 
-        final UserTO savedTO = userDataBinder.getUserTO(
-                created.getResult().getKey());
+        final UserTO savedTO = userDataBinder.getUserTO(created.getResult().getKey());
 
         savedTO.setPropagationTOs(propagations);
 
@@ -337,7 +329,8 @@ public class UserController {
         List<PropagationTask> tasks = propagationManager.getUpdateTaskIds(
                 updated, userMod.getPassword(),
                 userMod.getVirtualAttributesToBeRemoved(),
-                userMod.getVirtualAttributesToBeUpdated(), null);
+                userMod.getVirtualAttributesToBeUpdated(), 
+                null);
 
         final List<PropagationTO> propagations = new ArrayList<PropagationTO>();
 

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/AbstractAttributableDataBinder.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/AbstractAttributableDataBinder.java?rev=1295610&r1=1295609&r2=1295610&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/AbstractAttributableDataBinder.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/AbstractAttributableDataBinder.java Thu Mar  1 15:09:24 2012
@@ -18,6 +18,7 @@
  */
 package org.syncope.core.rest.data;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
@@ -310,39 +311,32 @@ public abstract class AbstractAttributab
 
         // 1. virtual attributes to be removed
         for (String vAttrToBeRemoved : vAttrsToBeRemoved) {
-            AbstractVirSchema virtualSchema = getVirtualSchema(
-                    vAttrToBeRemoved, attributableUtil.virtualSchemaClass());
+            AbstractVirSchema virtualSchema = getVirtualSchema(vAttrToBeRemoved, attributableUtil.virtualSchemaClass());
 
             if (virtualSchema != null) {
-                AbstractVirAttr virtualAttribute =
-                        attributable.getVirtualAttribute(
-                        virtualSchema.getName());
+                AbstractVirAttr virtualAttribute = attributable.getVirtualAttribute(virtualSchema.getName());
 
                 if (virtualAttribute == null) {
-                    LOG.debug("No virtual attribute found for schema {}",
-                            virtualSchema.getName());
+                    LOG.debug("No virtual attribute found for schema {}", virtualSchema.getName());
                 } else {
+                    attributable.removeVirtualAttribute(virtualAttribute);
                     virAttrDAO.delete(virtualAttribute);
                 }
 
                 for (SchemaMapping mapping : resourceDAO.findAllMappings()) {
-                    if (virtualSchema.getName().equals(
-                            mapping.getIntAttrName())
-                            && mapping.getIntMappingType()
-                            == attributableUtil.virtualIntMappingType()
+                    if (virtualSchema.getName().equals(mapping.getIntAttrName())
+                            && mapping.getIntMappingType() == attributableUtil.virtualIntMappingType()
                             && mapping.getResource() != null
-                            && attributable.getResources().
-                            contains(mapping.getResource())) {
+                            && attributable.getResources().contains(mapping.getResource())) {
 
-                        propByRes.add(PropagationOperation.UPDATE,
-                                mapping.getResource().getName());
+                        propByRes.add(PropagationOperation.UPDATE, mapping.getResource().getName());
 
-                        if (mapping.isAccountid() && virtualAttribute != null
-                                && !virtualAttribute.getValues().isEmpty()) {
+                        // TODO: must be avoided to use virtual attribute as AccountId
+                        if (mapping.isAccountid()
+                                && virtualAttribute != null && !virtualAttribute.getValues().isEmpty()) {
 
                             propByRes.addOldAccountId(
-                                    mapping.getResource().getName(),
-                                    virtualAttribute.getValues().get(0));
+                                    mapping.getResource().getName(), virtualAttribute.getValues().get(0));
                         }
                     }
                 }
@@ -353,40 +347,36 @@ public abstract class AbstractAttributab
 
         // 2. virtual attributes to be updated
         for (AttributeMod vAttrToBeUpdated : vAttrsToBeUpdated) {
-            AbstractVirSchema virtualSchema = getVirtualSchema(
-                    vAttrToBeUpdated.getSchema(),
-                    attributableUtil.virtualSchemaClass());
+            AbstractVirSchema virtualSchema =
+                    getVirtualSchema(vAttrToBeUpdated.getSchema(), attributableUtil.virtualSchemaClass());
 
             if (virtualSchema != null) {
                 for (SchemaMapping mapping : resourceDAO.findAllMappings()) {
-                    if (virtualSchema.getName().equals(
-                            mapping.getIntAttrName())
-                            && mapping.getIntMappingType()
-                            == attributableUtil.virtualIntMappingType()
+                    if (virtualSchema.getName().equals(mapping.getIntAttrName())
+                            && mapping.getIntMappingType() == attributableUtil.virtualIntMappingType()
                             && mapping.getResource() != null
-                            && attributable.getResources().
-                            contains(mapping.getResource())) {
+                            && attributable.getResources().contains(mapping.getResource())) {
 
-                        propByRes.add(PropagationOperation.UPDATE,
-                                mapping.getResource().getName());
+                        propByRes.add(PropagationOperation.UPDATE, mapping.getResource().getName());
                     }
                 }
 
-                AbstractVirAttr virtualAttribute =
-                        attributable.getVirtualAttribute(
-                        virtualSchema.getName());
+                AbstractVirAttr virtualAttribute = attributable.getVirtualAttribute(virtualSchema.getName());
+
                 if (virtualAttribute == null) {
-                    virtualAttribute =
-                            attributableUtil.newVirtualAttribute();
+                    virtualAttribute = attributableUtil.newVirtualAttribute();
                     virtualAttribute.setVirtualSchema(virtualSchema);
-                    virtualAttribute.setOwner(attributable);
-
                     attributable.addVirtualAttribute(virtualAttribute);
                 }
-                virtualAttribute.getValues().removeAll(
-                        vAttrToBeUpdated.getValuesToBeRemoved());
-                virtualAttribute.getValues().addAll(
-                        vAttrToBeUpdated.getValuesToBeAdded());
+
+                final List<String> values = new ArrayList<String>(virtualAttribute.getValues());
+                values.removeAll(vAttrToBeUpdated.getValuesToBeRemoved());
+                values.addAll(vAttrToBeUpdated.getValuesToBeAdded());
+
+                virtualAttribute.setValues(values);
+
+                // Owner cannot be specified before otherwise a virtual attribute remove will be invalidated.
+                virtualAttribute.setOwner(attributable);
             }
         }
 
@@ -444,49 +434,40 @@ public abstract class AbstractAttributab
         AbstractDerAttr derivedAttribute;
 
         // 3. attributes to be removed
-        for (String attributeToBeRemoved :
-                attributableMod.getAttributesToBeRemoved()) {
+        for (String attributeToBeRemoved : attributableMod.getAttributesToBeRemoved()) {
 
-            schema = getSchema(
-                    attributeToBeRemoved, attributableUtil.schemaClass());
+            schema = getSchema(attributeToBeRemoved, attributableUtil.schemaClass());
 
             if (schema != null) {
                 attribute = attributable.getAttribute(schema.getName());
+
                 if (attribute == null) {
                     LOG.debug("No attribute found for schema {}", schema);
                 } else {
                     String newValue = null;
-                    for (AttributeMod mod : attributableMod.
-                            getAttributesToBeUpdated()) {
-
+                    for (AttributeMod mod : attributableMod.getAttributesToBeUpdated()) {
                         if (schema.getName().equals(mod.getSchema())) {
                             newValue = mod.getValuesToBeAdded().get(0);
                         }
                     }
 
                     if (!schema.isUniqueConstraint()
-                            || (!attribute.getUniqueValue().getStringValue().
-                            equals(newValue))) {
+                            || (!attribute.getUniqueValue().getStringValue().equals(newValue))) {
 
                         attributable.removeAttribute(attribute);
-                        attributeDAO.delete(attribute.getId(),
-                                attributableUtil.attributeClass());
+                        attributeDAO.delete(attribute.getId(), attributableUtil.attributeClass());
                     }
                 }
 
                 for (SchemaMapping mapping : resourceDAO.findAllMappings()) {
                     if (schema.getName().equals(mapping.getIntAttrName())
-                            && mapping.getIntMappingType()
-                            == attributableUtil.intMappingType()
+                            && mapping.getIntMappingType() == attributableUtil.intMappingType()
                             && mapping.getResource() != null
-                            && attributable.getResources().
-                            contains(mapping.getResource())) {
+                            && attributable.getResources().contains(mapping.getResource())) {
 
-                        propByRes.add(PropagationOperation.UPDATE,
-                                mapping.getResource().getName());
+                        propByRes.add(PropagationOperation.UPDATE, mapping.getResource().getName());
 
-                        if (mapping.isAccountid() && attribute != null
-                                && !attribute.getValuesAsStrings().isEmpty()) {
+                        if (mapping.isAccountid() && attribute != null && !attribute.getValuesAsStrings().isEmpty()) {
 
                             propByRes.addOldAccountId(
                                     mapping.getResource().getName(),
@@ -503,23 +484,18 @@ public abstract class AbstractAttributab
         // 4. attributes to be updated
         Set<Long> valuesToBeRemoved;
         List<String> valuesToBeAdded;
-        for (AttributeMod attributeMod :
-                attributableMod.getAttributesToBeUpdated()) {
+        for (AttributeMod attributeMod : attributableMod.getAttributesToBeUpdated()) {
 
-            schema = getSchema(attributeMod.getSchema(),
-                    attributableUtil.schemaClass());
+            schema = getSchema(attributeMod.getSchema(), attributableUtil.schemaClass());
 
             if (schema != null) {
                 for (SchemaMapping mapping : resourceDAO.findAllMappings()) {
                     if (schema.getName().equals(mapping.getIntAttrName())
-                            && mapping.getIntMappingType()
-                            == attributableUtil.intMappingType()
+                            && mapping.getIntMappingType() == attributableUtil.intMappingType()
                             && mapping.getResource() != null
-                            && attributable.getResources().
-                            contains(mapping.getResource())) {
+                            && attributable.getResources().contains(mapping.getResource())) {
 
-                        propByRes.add(PropagationOperation.UPDATE,
-                                mapping.getResource().getName());
+                        propByRes.add(PropagationOperation.UPDATE, mapping.getResource().getName());
                     }
                 }
 
@@ -534,31 +510,24 @@ public abstract class AbstractAttributab
 
                 // 1.1 remove values
                 valuesToBeRemoved = new HashSet<Long>();
-                for (String valueToBeRemoved :
-                        attributeMod.getValuesToBeRemoved()) {
+                for (String valueToBeRemoved : attributeMod.getValuesToBeRemoved()) {
 
                     if (attribute.getSchema().isUniqueConstraint()) {
                         if (attribute.getUniqueValue() != null
-                                && valueToBeRemoved.equals(
-                                attribute.getUniqueValue().
-                                getValueAsString())) {
+                                && valueToBeRemoved.equals(attribute.getUniqueValue().getValueAsString())) {
 
-                            valuesToBeRemoved.add(
-                                    attribute.getUniqueValue().getId());
+                            valuesToBeRemoved.add(attribute.getUniqueValue().getId());
                         }
                     } else {
                         for (AbstractAttrValue mav : attribute.getValues()) {
-                            if (valueToBeRemoved.equals(
-                                    mav.getValueAsString())) {
-
+                            if (valueToBeRemoved.equals(mav.getValueAsString())) {
                                 valuesToBeRemoved.add(mav.getId());
                             }
                         }
                     }
                 }
                 for (Long attributeValueId : valuesToBeRemoved) {
-                    attributeValueDAO.delete(attributeValueId,
-                            attributableUtil.attributeValueClass());
+                    attributeValueDAO.delete(attributeValueId, attributableUtil.attributeValueClass());
                 }
 
                 // 1.2 add values
@@ -566,12 +535,9 @@ public abstract class AbstractAttributab
                 if (valuesToBeAdded != null && !valuesToBeAdded.isEmpty()
                         && (!schema.isUniqueConstraint()
                         || attribute.getUniqueValue() == null
-                        || !valuesToBeAdded.iterator().next().equals(
-                        attribute.getUniqueValue().getValueAsString()))) {
+                        || !valuesToBeAdded.iterator().next().equals(attribute.getUniqueValue().getValueAsString()))) {
 
-                    fillAttribute(attributeMod.getValuesToBeAdded(),
-                            attributableUtil, schema, attribute,
-                            invalidValues);
+                    fillAttribute(attributeMod.getValuesToBeAdded(), attributableUtil, schema, attribute, invalidValues);
                 }
 
                 // if no values are in, the attribute can be safely removed
@@ -588,8 +554,7 @@ public abstract class AbstractAttributab
         LOG.debug("Attributes to be updated:\n{}", propByRes);
 
         // 5. derived attributes to be removed
-        for (String derivedAttributeToBeRemoved :
-                attributableMod.getDerivedAttributesToBeRemoved()) {
+        for (String derivedAttributeToBeRemoved : attributableMod.getDerivedAttributesToBeRemoved()) {
 
             derivedSchema = getDerivedSchema(derivedAttributeToBeRemoved,
                     attributableUtil.derivedSchemaClass());
@@ -606,50 +571,40 @@ public abstract class AbstractAttributab
                 }
 
                 for (SchemaMapping mapping : resourceDAO.findAllMappings()) {
-                    if (derivedSchema.getName().equals(
-                            mapping.getIntAttrName())
-                            && mapping.getIntMappingType()
-                            == attributableUtil.derivedIntMappingType()
+                    if (derivedSchema.getName().equals(mapping.getIntAttrName())
+                            && mapping.getIntMappingType() == attributableUtil.derivedIntMappingType()
                             && mapping.getResource() != null
                             && attributable.getResources().
                             contains(mapping.getResource())) {
 
-                        propByRes.add(PropagationOperation.UPDATE,
-                                mapping.getResource().getName());
+                        propByRes.add(PropagationOperation.UPDATE, mapping.getResource().getName());
 
                         if (mapping.isAccountid() && derivedAttribute != null
-                                && !derivedAttribute.getValue(
-                                attributable.getAttributes()).isEmpty()) {
+                                && !derivedAttribute.getValue(attributable.getAttributes()).isEmpty()) {
 
                             propByRes.addOldAccountId(
                                     mapping.getResource().getName(),
-                                    derivedAttribute.getValue(
-                                    attributable.getAttributes()));
+                                    derivedAttribute.getValue(attributable.getAttributes()));
                         }
                     }
                 }
             }
         }
 
-        LOG.debug("Derived attributes to be removed:\n{}",
-                propByRes);
+        LOG.debug("Derived attributes to be removed:\n{}", propByRes);
 
         // 6. derived attributes to be added
-        for (String derivedAttributeToBeAdded :
-                attributableMod.getDerivedAttributesToBeAdded()) {
+        for (String derivedAttributeToBeAdded : attributableMod.getDerivedAttributesToBeAdded()) {
 
-            derivedSchema = getDerivedSchema(derivedAttributeToBeAdded,
-                    attributableUtil.derivedSchemaClass());
+            derivedSchema = getDerivedSchema(derivedAttributeToBeAdded, attributableUtil.derivedSchemaClass());
 
             if (derivedSchema != null) {
                 for (SchemaMapping mapping : resourceDAO.findAllMappings()) {
                     if (derivedSchema.getName().equals(
                             mapping.getIntAttrName())
-                            && mapping.getIntMappingType()
-                            == attributableUtil.derivedIntMappingType()
+                            && mapping.getIntMappingType() == attributableUtil.derivedIntMappingType()
                             && mapping.getResource() != null
-                            && attributable.getResources().
-                            contains(mapping.getResource())) {
+                            && attributable.getResources().contains(mapping.getResource())) {
 
                         propByRes.add(PropagationOperation.UPDATE,
                                 mapping.getResource().getName());
@@ -663,11 +618,9 @@ public abstract class AbstractAttributab
             }
         }
 
-        LOG.debug("Derived attributes to be added:\n{}",
-                propByRes);
+        LOG.debug("Derived attributes to be added:\n{}", propByRes);
 
-        // 7. virtual attributes: for users this is delegated to 
-        // PropagationManager
+        // 7. virtual attributes: for users this is delegated to  PropagationManager
         if (AttributableUtil.USER != attributableUtil) {
             fillVirtual(attributable,
                     attributableMod.getVirtualAttributesToBeRemoved(),
@@ -676,8 +629,7 @@ public abstract class AbstractAttributab
         }
 
         // Finally, check if mandatory values are missing
-        SyncopeClientException requiredValuesMissing =
-                checkMandatory(attributableUtil, attributable);
+        SyncopeClientException requiredValuesMissing = checkMandatory(attributableUtil, attributable);
         if (!requiredValuesMissing.isEmpty()) {
             compositeErrorException.addException(requiredValuesMissing);
         }
@@ -697,13 +649,11 @@ public abstract class AbstractAttributab
             final AttributableUtil attributableUtil) {
 
         for (AttributeTO attributeTO : vAttrs) {
-            AbstractVirSchema virtualSchema = getVirtualSchema(
-                    attributeTO.getSchema(),
-                    attributableUtil.virtualSchemaClass());
+            AbstractVirSchema virtualSchema =
+                    getVirtualSchema(attributeTO.getSchema(), attributableUtil.virtualSchemaClass());
 
             if (virtualSchema != null) {
-                AbstractVirAttr virtualAttribute =
-                        attributableUtil.newVirtualAttribute();
+                AbstractVirAttr virtualAttribute = attributableUtil.newVirtualAttribute();
                 virtualAttribute.setVirtualSchema(virtualSchema);
                 virtualAttribute.setOwner(attributable);
                 virtualAttribute.setValues(attributeTO.getValues());
@@ -720,8 +670,7 @@ public abstract class AbstractAttributab
             throws SyncopeClientCompositeErrorException {
 
         // 1. attributes
-        SyncopeClientException invalidValues = new SyncopeClientException(
-                SyncopeClientExceptionType.InvalidValues);
+        SyncopeClientException invalidValues = new SyncopeClientException(SyncopeClientExceptionType.InvalidValues);
 
         AbstractSchema schema;
         AbstractAttr attribute;
@@ -781,11 +730,9 @@ public abstract class AbstractAttributab
             }
         }
 
-        // 3. virtual attributes: for users this is delegated to 
-        // PropagationManager
+        // 3. virtual attributes: for users this is delegated to PropagationManager
         if (AttributableUtil.USER != attributableUtil) {
-            fillVirtual(attributable, attributableTO.getVirtualAttributes(),
-                    attributableUtil);
+            fillVirtual(attributable, attributableTO.getVirtualAttributes(), attributableUtil);
         }
 
         // 4. resources

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/UserDataBinder.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/UserDataBinder.java?rev=1295610&r1=1295609&r2=1295610&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/UserDataBinder.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/UserDataBinder.java Thu Mar  1 15:09:24 2012
@@ -40,9 +40,7 @@ import org.syncope.core.persistence.bean
 import org.syncope.core.persistence.beans.AbstractVirAttr;
 import org.syncope.core.persistence.beans.Policy;
 import org.syncope.core.persistence.beans.ExternalResource;
-import org.syncope.core.persistence.beans.PropagationTask;
 import org.syncope.core.persistence.beans.SchemaMapping;
-import org.syncope.core.persistence.beans.TaskExec;
 import org.syncope.core.persistence.beans.membership.Membership;
 import org.syncope.core.persistence.beans.membership.MAttr;
 import org.syncope.core.persistence.beans.membership.MDerAttr;
@@ -58,7 +56,6 @@ import org.syncope.types.CipherAlgorithm
 import org.syncope.types.IntMappingType;
 import org.syncope.types.PasswordPolicySpec;
 import org.syncope.types.PropagationOperation;
-import org.syncope.types.PropagationTaskExecStatus;
 import org.syncope.types.SyncopeClientExceptionType;
 
 @Component
@@ -149,9 +146,7 @@ public class UserDataBinder extends Abst
     public void create(final SyncopeUser user, final UserTO userTO)
             throws SyncopeClientCompositeErrorException {
 
-        SyncopeClientCompositeErrorException scce =
-                new SyncopeClientCompositeErrorException(
-                HttpStatus.BAD_REQUEST);
+        SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
 
         // memberships
         SyncopeRole role;
@@ -160,8 +155,7 @@ public class UserDataBinder extends Abst
 
             if (role == null) {
                 if (LOG.isDebugEnabled()) {
-                    LOG.debug("Ignoring invalid role "
-                            + membershipTO.getRoleName());
+                    LOG.debug("Ignoring invalid role " + membershipTO.getRoleName());
                 }
             } else {
                 Membership membership = null;
@@ -226,9 +220,7 @@ public class UserDataBinder extends Abst
 
         PropagationByResource propByRes = new PropagationByResource();
 
-        SyncopeClientCompositeErrorException scce =
-                new SyncopeClientCompositeErrorException(
-                HttpStatus.BAD_REQUEST);
+        SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
 
         // when requesting to add user to new resources, either directly or
         // through role subscription, password is mandatory (issue 147)
@@ -246,13 +238,11 @@ public class UserDataBinder extends Abst
                 // ignore exceptions
             }
 
-            user.setPassword(userMod.getPassword(), getCipherAlgoritm(),
-                    passwordHistorySize);
+            user.setPassword(userMod.getPassword(), getCipherAlgoritm(), passwordHistorySize);
 
             user.setChangePwdDate(new Date());
 
-            propByRes.addAll(PropagationOperation.UPDATE,
-                    user.getResourceNames());
+            propByRes.addAll(PropagationOperation.UPDATE, user.getResourceNames());
         }
 
         // username
@@ -293,17 +283,14 @@ public class UserDataBinder extends Abst
 
             membership = membershipDAO.find(membershipId);
             if (membership == null) {
-                LOG.debug("Invalid membership id specified to be removed: {}",
-                        membershipId);
+                LOG.debug("Invalid membership id specified to be removed: {}", membershipId);
             } else {
                 for (ExternalResource resource :
                         membership.getSyncopeRole().getResources()) {
 
-                    if (!membershipToBeAddedRoleIds.contains(
-                            membership.getSyncopeRole().getId())) {
+                    if (!membershipToBeAddedRoleIds.contains(membership.getSyncopeRole().getId())) {
 
-                        propByRes.add(PropagationOperation.DELETE,
-                                resource.getName());
+                        propByRes.add(PropagationOperation.DELETE, resource.getName());
                     }
                 }
 
@@ -311,13 +298,11 @@ public class UserDataBinder extends Abst
                 // we need to be sure to take exactly the same membership
                 // of the user object currently in memory (which has potentially
                 // some modifications compared to the one stored in the DB
-                membership = user.getMembership(
-                        membership.getSyncopeRole().getId());
+                membership = user.getMembership(membership.getSyncopeRole().getId());
                 if (membershipToBeAddedRoleIds.contains(
                         membership.getSyncopeRole().getId())) {
 
-                    Set<Long> attributeIds = new HashSet<Long>(
-                            membership.getAttributes().size());
+                    Set<Long> attributeIds = new HashSet<Long>(membership.getAttributes().size());
                     for (AbstractAttr attribute : membership.getAttributes()) {
                         attributeIds.add(attribute.getId());
                     }
@@ -327,8 +312,7 @@ public class UserDataBinder extends Abst
                     attributeIds.clear();
 
                     // remove derived attributes
-                    for (AbstractDerAttr derAttr :
-                            membership.getDerivedAttributes()) {
+                    for (AbstractDerAttr derAttr : membership.getDerivedAttributes()) {
 
                         attributeIds.add(derAttr.getId());
                     }
@@ -338,8 +322,7 @@ public class UserDataBinder extends Abst
                     attributeIds.clear();
 
                     // remove virtual attributes
-                    for (AbstractVirAttr virAttr :
-                            membership.getVirtualAttributes()) {
+                    for (AbstractVirAttr virAttr : membership.getVirtualAttributes()) {
 
                         attributeIds.add(virAttr.getId());
                     }
@@ -357,8 +340,7 @@ public class UserDataBinder extends Abst
 
         // memberships to be added
         for (MembershipMod membershipMod : userMod.getMembershipsToBeAdded()) {
-            LOG.debug("Membership to be added: role({})",
-                    membershipMod.getRole());
+            LOG.debug("Membership to be added: role({})", membershipMod.getRole());
 
             SyncopeRole role = roleDAO.find(membershipMod.getRole());
             if (role == null) {
@@ -372,12 +354,10 @@ public class UserDataBinder extends Abst
 
                     user.addMembership(membership);
 
-                    propByRes.addAll(PropagationOperation.UPDATE,
-                            role.getResourceNames());
+                    propByRes.addAll(PropagationOperation.UPDATE, role.getResourceNames());
                 }
 
-                propByRes.merge(fill(membership, membershipMod,
-                        AttributableUtil.MEMBERSHIP, scce));
+                propByRes.merge(fill(membership, membershipMod, AttributableUtil.MEMBERSHIP, scce));
             }
         }
 
@@ -385,13 +365,10 @@ public class UserDataBinder extends Abst
         // providing password
         Set<String> updatedResources = user.getResourceNames();
         updatedResources.removeAll(currentResources);
-        if (!updatedResources.isEmpty()
-                && StringUtils.isBlank(userMod.getPassword())) {
+        if (!updatedResources.isEmpty() && StringUtils.isBlank(userMod.getPassword())) {
 
-            SyncopeClientException sce = new SyncopeClientException(
-                    SyncopeClientExceptionType.RequiredValuesMissing);
-            sce.addElement("password cannot be empty "
-                    + "when subscribing to new resources");
+            SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.RequiredValuesMissing);
+            sce.addElement("password cannot be empty " + "when subscribing to new resources");
             scce.addException(sce);
 
             throw scce;

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/workflow/activiti/Create.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/workflow/activiti/Create.java?rev=1295610&r1=1295609&r2=1295610&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/workflow/activiti/Create.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/workflow/activiti/Create.java Thu Mar  1 15:09:24 2012
@@ -29,8 +29,7 @@ public class Create extends AbstractActi
     protected void doExecute(final DelegateExecution execution)
             throws Exception {
 
-        UserTO userTO = (UserTO) execution.getVariable(
-                ActivitiUserWorkflowAdapter.USER_TO);
+        UserTO userTO = (UserTO) execution.getVariable(ActivitiUserWorkflowAdapter.USER_TO);
 
         // create and set workflow id
         SyncopeUser user = new SyncopeUser();
@@ -38,7 +37,6 @@ public class Create extends AbstractActi
         user.setWorkflowId(execution.getProcessInstanceId());
 
         // report SyncopeUser as result
-        execution.setVariable(
-                ActivitiUserWorkflowAdapter.SYNCOPE_USER, user);
+        execution.setVariable(ActivitiUserWorkflowAdapter.SYNCOPE_USER, user);
     }
 }

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/workflow/activiti/Update.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/workflow/activiti/Update.java?rev=1295610&r1=1295609&r2=1295610&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/workflow/activiti/Update.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/workflow/activiti/Update.java Thu Mar  1 15:09:24 2012
@@ -30,18 +30,14 @@ public class Update extends AbstractActi
     protected void doExecute(final DelegateExecution execution)
             throws Exception {
 
-        SyncopeUser user = (SyncopeUser) execution.getVariable(
-                ActivitiUserWorkflowAdapter.SYNCOPE_USER);
-        UserMod userMod = (UserMod) execution.getVariable(
-                ActivitiUserWorkflowAdapter.USER_MOD);
+        SyncopeUser user = (SyncopeUser) execution.getVariable(ActivitiUserWorkflowAdapter.SYNCOPE_USER);
+        UserMod userMod = (UserMod) execution.getVariable(ActivitiUserWorkflowAdapter.USER_MOD);
 
         // update SyncopeUser
         PropagationByResource propByRes = dataBinder.update(user, userMod);
 
         // report updated user and propagation by resource as result
-        execution.setVariable(ActivitiUserWorkflowAdapter.SYNCOPE_USER,
-                user);
-        execution.setVariable(ActivitiUserWorkflowAdapter.PROP_BY_RESOURCE,
-                propByRes);
+        execution.setVariable(ActivitiUserWorkflowAdapter.SYNCOPE_USER, user);
+        execution.setVariable(ActivitiUserWorkflowAdapter.PROP_BY_RESOURCE, propByRes);
     }
 }



Mime
View raw message