Author: fmartelli
Date: Thu Feb 14 14:16:35 2013
New Revision: 1446195

URL: http://svn.apache.org/r1446195
Log:
SYNCOPE-307: virtual attribute values must be retrieved before the propByRes 
purge

Modified:
    
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationManager.java

Modified: 
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationManager.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationManager.java?rev=1446195&r1=1446194&r2=1446195&view=diff
==============================================================================
--- 
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationManager.java
 (original)
+++ 
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationManager.java
 Thu Feb 14 14:16:35 2013
@@ -556,14 +556,28 @@ public class PropagationManager {
 
         LOG.debug("Provisioning with user {}:\n{}", user, propByRes);
 
+        if (!propByRes.get(PropagationOperation.CREATE).isEmpty()
+                && vAttrsToBeRemoved != null && vAttrsToBeUpdated != null) {
+            connObjectUtil.retrieveVirAttrValues(user);
+
+            // update vAttrsToBeUpdated as well
+            for (AbstractVirAttr virAttr : user.getVirtualAttributes()) {
+                final String schema = virAttr.getVirtualSchema().getName();
+
+                final AttributeMod attributeMod = new AttributeMod();
+                attributeMod.setSchema(schema);
+                attributeMod.setValuesToBeAdded(virAttr.getValues());
+
+                vAttrsToBeUpdated.put(schema, attributeMod);
+            }
+        }
+
         // Avoid duplicates - see javadoc
         propByRes.purge();
         LOG.debug("After purge: {}", propByRes);
 
         List<PropagationTask> tasks = new ArrayList<PropagationTask>();
 
-        boolean virAttrRerieved = false;
-
         for (PropagationOperation operation : PropagationOperation.values()) {
             List<ExternalResource> resourcesByPriority = new 
ArrayList<ExternalResource>();
             for (ExternalResource resource : resourceDAO.findAllByPriority()) {
@@ -582,23 +596,6 @@ public class PropagationManager {
                 task.setPropagationMode(resource.getPropagationMode());
                 
task.setOldAccountId(propByRes.getOldAccountId(resource.getName()));
 
-                if (operation == PropagationOperation.CREATE && 
!virAttrRerieved
-                        && vAttrsToBeRemoved != null && vAttrsToBeUpdated != 
null) {
-                    connObjectUtil.retrieveVirAttrValues(user);
-                    virAttrRerieved = true;
-
-                    // update vAttrsToBeUpdated as well
-                    for (AbstractVirAttr virAttr : 
user.getVirtualAttributes()) {
-                        final String schema = 
virAttr.getVirtualSchema().getName();
-
-                        final AttributeMod attributeMod = new AttributeMod();
-                        attributeMod.setSchema(schema);
-                        attributeMod.setValuesToBeAdded(virAttr.getValues());
-
-                        vAttrsToBeUpdated.put(schema, attributeMod);
-                    }
-                }
-
                 final Map.Entry<String, Set<Attribute>> preparedAttrs =
                         prepareAttributes(user, password, vAttrsToBeRemoved, 
vAttrsToBeUpdated, enable, resource);
                 task.setAccountId(preparedAttrs.getKey());


Reply via email to