Author: fmartelli
Date: Tue Jan 29 11:58:12 2013
New Revision: 1439846

URL: http://svn.apache.org/viewvc?rev=1439846&view=rev
Log:
made more robust in respect of external resource returned values

Modified:
    
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/scheduling/SyncJob.java
    
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/util/ConnObjectUtil.java

Modified: 
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/scheduling/SyncJob.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/scheduling/SyncJob.java?rev=1439846&r1=1439845&r2=1439846&view=diff
==============================================================================
--- 
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/scheduling/SyncJob.java
 (original)
+++ 
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/scheduling/SyncJob.java
 Tue Jan 29 11:58:12 2013
@@ -207,7 +207,8 @@ public class SyncJob extends AbstractTas
                 AttributeCond.Type type;
                 String expression = null;
 
-                if (value == null || value.getValue() == null || 
value.getValue().isEmpty()) {
+                if (value == null || value.getValue() == null || 
value.getValue().isEmpty()
+                        || (value.getValue().size() == 1 && 
value.getValue().get(0) == null)) {
                     type = AttributeCond.Type.ISNULL;
                 } else {
                     type = AttributeCond.Type.EQ;

Modified: 
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/util/ConnObjectUtil.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/util/ConnObjectUtil.java?rev=1439846&r1=1439845&r2=1439846&view=diff
==============================================================================
--- 
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/util/ConnObjectUtil.java
 (original)
+++ 
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/util/ConnObjectUtil.java
 Tue Jan 29 11:58:12 2013
@@ -152,7 +152,8 @@ public class ConnObjectUtil {
                     break;
 
                 case Username:
-                    userTO.setUsername(attribute == null || 
attribute.getValue().isEmpty()
+                    userTO.setUsername(
+                            attribute == null || 
attribute.getValue().isEmpty() || attribute.getValue().get(0) == null
                             ? null
                             : attribute.getValue().get(0).toString());
                     break;
@@ -164,7 +165,9 @@ public class ConnObjectUtil {
                     for (Object value : attribute == null || 
attribute.getValue() == null
                             ? Collections.emptyList()
                             : attribute.getValue()) {
-                        attributeTO.addValue(value.toString());
+                        if (value != null) {
+                            attributeTO.addValue(value.toString());
+                        }
                     }
 
                     userTO.addAttribute(attributeTO);
@@ -183,7 +186,9 @@ public class ConnObjectUtil {
                     for (Object value : attribute == null || 
attribute.getValue() == null
                             ? Collections.emptyList()
                             : attribute.getValue()) {
-                        attributeTO.addValue(value.toString());
+                        if (value != null) {
+                            attributeTO.addValue(value.toString());
+                        }
                     }
 
                     userTO.addVirtualAttribute(attributeTO);
@@ -244,6 +249,7 @@ public class ConnObjectUtil {
 
         if (pwd instanceof GuardedString) {
             ((GuardedString) pwd).access(new GuardedString.Accessor() {
+
                 @Override
                 public void access(final char[] clearChars) {
                     result.append(clearChars);
@@ -251,6 +257,7 @@ public class ConnObjectUtil {
             });
         } else if (pwd instanceof GuardedByteArray) {
             ((GuardedByteArray) pwd).access(new GuardedByteArray.Accessor() {
+
                 @Override
                 public void access(final byte[] clearBytes) {
                     result.append(new String(clearBytes));
@@ -407,7 +414,7 @@ public class ConnObjectUtil {
             if (StringUtils.isNotBlank(evaluated)) {
                 result.addValue(evaluated);
             }
-        }   
+        }
 
         return result;
     }


Reply via email to