Author: fmartelli
Date: Thu Feb 14 14:24:17 2013
New Revision: 1446200

URL: http://svn.apache.org/r1446200
Log:
SYNCOPE-307: virtual attribute values must be retrieved before the propByRes 
purge - merged from branch 1_0_X

Modified:
    syncope/trunk/   (props changed)
    
syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/PropagationManager.java

Propchange: syncope/trunk/
------------------------------------------------------------------------------
  Merged /syncope/branches/1_0_X:r1445755-1446195

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=1446200&r1=1446199&r2=1446200&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 Feb 14 14:24:17 2013
@@ -518,22 +518,36 @@ public class PropagationManager {
 
         LOG.debug("Provisioning subject {}:\n{}", subject, propByRes);
 
+        final AttributableUtil attrUtil = 
AttributableUtil.getInstance(subject);
+
+        if (!propByRes.get(ResourceOperation.CREATE).isEmpty()
+                && vAttrsToBeRemoved != null && vAttrsToBeUpdated != null) {
+            connObjectUtil.retrieveVirAttrValues(subject, attrUtil);
+
+            // update vAttrsToBeUpdated as well
+            for (AbstractVirAttr virAttr : subject.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);
 
         final List<PropagationTask> tasks = new ArrayList<PropagationTask>();
 
-        boolean virAttrRerieved = false;
-
         for (ResourceOperation operation : ResourceOperation.values()) {
             for (String resourceName : propByRes.get(operation)) {
                 final ExternalResource resource = 
resourceDAO.find(resourceName);
                 if (resource == null) {
                     LOG.error("Invalid resource name specified: {}, 
ignoring...", resourceName);
                 } else {
-                    AttributableUtil attrUtil = 
AttributableUtil.getInstance(subject);
-
                     PropagationTask task = new PropagationTask();
                     task.setResource(resource);
                     
task.setObjectClassName(connObjectUtil.fromAttributable(subject).getObjectClassValue());
@@ -545,23 +559,6 @@ public class PropagationManager {
                     task.setPropagationMode(resource.getPropagationMode());
                     
task.setOldAccountId(propByRes.getOldAccountId(resource.getName()));
 
-                    if (operation == ResourceOperation.CREATE && 
!virAttrRerieved
-                            && vAttrsToBeRemoved != null && vAttrsToBeUpdated 
!= null) {
-                        connObjectUtil.retrieveVirAttrValues(subject, 
attrUtil);
-                        virAttrRerieved = true;
-
-                        // update vAttrsToBeUpdated as well
-                        for (AbstractVirAttr virAttr : 
subject.getVirtualAttributes()) {
-                            final String schema = 
virAttr.getVirtualSchema().getName();
-
-                            final AttributeMod attributeMod = new 
AttributeMod();
-                            attributeMod.setSchema(schema);
-                            
attributeMod.setValuesToBeAdded(virAttr.getValues());
-
-                            vAttrsToBeUpdated.put(schema, attributeMod);
-                        }
-                    }
-
                     Map.Entry<String, Set<Attribute>> preparedAttrs = 
prepareAttributes(subject, password,
                             vAttrsToBeRemoved, vAttrsToBeUpdated, enable, 
resource);
                     task.setAccountId(preparedAttrs.getKey());


Reply via email to