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 2013/02/18 17:20:18 UTC

svn commit: r1447376 - in /syncope/trunk/core/src/main/java/org/apache/syncope/core: connid/ConnObjectUtil.java rest/controller/TaskController.java

Author: ilgrosso
Date: Mon Feb 18 16:20:17 2013
New Revision: 1447376

URL: http://svn.apache.org/r1447376
Log:
[SYNCOPE-257] Filtering out template attributes with no values

Modified:
    syncope/trunk/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java

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=1447376&r1=1447375&r2=1447376&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 Mon Feb 18 16:20:17 2013
@@ -562,7 +562,7 @@ public class ConnObjectUtil {
                             }
                         }
                     }
-                    
+
                     LOG.debug("Retrieved values {}", virAttr.getValues());
                 } catch (Exception e) {
                     LOG.error("Error reading connector object from {}", resource.getName(), e);
@@ -595,23 +595,27 @@ public class ConnObjectUtil {
 
     private void fillFromTemplate(final AbstractAttributableTO attributableTO, final AbstractAttributableTO template) {
         Map<String, AttributeTO> currentAttrMap = attributableTO.getAttributeMap();
-        for (AttributeTO attrTO : template.getAttributes()) {
-            if (!currentAttrMap.containsKey(attrTO.getSchema())) {
-                attributableTO.addAttribute(evaluateAttrTemplate(attributableTO, attrTO));
+        for (AttributeTO templateAttr : template.getAttributes()) {
+            if (!currentAttrMap.containsKey(templateAttr.getSchema())
+                    || currentAttrMap.get(templateAttr.getSchema()).getValues().isEmpty()) {
+
+                attributableTO.addAttribute(evaluateAttrTemplate(attributableTO, templateAttr));
             }
         }
 
         currentAttrMap = attributableTO.getDerivedAttributeMap();
-        for (AttributeTO attrTO : template.getDerivedAttributes()) {
-            if (!currentAttrMap.containsKey(attrTO.getSchema())) {
-                attributableTO.addDerivedAttribute(attrTO);
+        for (AttributeTO templateDerAttr : template.getDerivedAttributes()) {
+            if (!currentAttrMap.containsKey(templateDerAttr.getSchema())) {
+                attributableTO.addDerivedAttribute(templateDerAttr);
             }
         }
 
         currentAttrMap = attributableTO.getVirtualAttributeMap();
-        for (AttributeTO attrTO : template.getDerivedAttributes()) {
-            if (!currentAttrMap.containsKey(attrTO.getSchema())) {
-                attributableTO.addVirtualAttribute(evaluateAttrTemplate(attributableTO, attrTO));
+        for (AttributeTO templateVirAttr : template.getDerivedAttributes()) {
+            if (!currentAttrMap.containsKey(templateVirAttr.getSchema())
+                    || currentAttrMap.get(templateVirAttr.getSchema()).getValues().isEmpty()) {
+
+                attributableTO.addVirtualAttribute(evaluateAttrTemplate(attributableTO, templateVirAttr));
             }
         }
     }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java?rev=1447376&r1=1447375&r2=1447376&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java Mon Feb 18 16:20:17 2013
@@ -22,9 +22,7 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Set;
-
 import javax.servlet.http.HttpServletResponse;
-
 import org.apache.syncope.common.to.SchedTaskTO;
 import org.apache.syncope.common.to.SyncTaskTO;
 import org.apache.syncope.common.to.TaskExecTO;
@@ -158,7 +156,7 @@ public class TaskController extends Abst
 
         SchedTask task = taskDAO.find(taskTO.getId());
         if (task == null) {
-            throw new NotFoundException("Task " + String.valueOf(taskTO.getId()));
+            throw new NotFoundException("Task " + taskTO.getId());
         }
 
         TaskUtil taskUtil = getTaskUtil(task);