Author: fmartelli
Date: Tue Jan  8 11:10:34 2013
New Revision: 1430209

URL: http://svn.apache.org/viewvc?rev=1430209&view=rev
Log:
SYNCOPE-267 Fix on the branch

Modified:
    
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttrValue.java
    
syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
    syncope/branches/1_0_X/core/src/test/resources/content.xml

Modified: 
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttrValue.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttrValue.java?rev=1430209&r1=1430208&r2=1430209&view=diff
==============================================================================
--- 
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttrValue.java
 (original)
+++ 
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttrValue.java
 Tue Jan  8 11:10:34 2013
@@ -37,6 +37,7 @@ import org.apache.commons.lang.time.Date
 import org.apache.syncope.client.SyncopeConstants;
 import 
org.apache.syncope.core.persistence.validation.attrvalue.ParsingValidationException;
 import org.apache.syncope.core.persistence.validation.entity.AttrValueCheck;
+import org.apache.syncope.types.SchemaType;
 
 @MappedSuperclass
 @AttrValueCheck
@@ -185,7 +186,12 @@ public abstract class AbstractAttrValue 
     public String getValueAsString() {
         String result = null;
 
-        switch (getAttribute().getSchema().getType()) {
+        final SchemaType type = getAttribute() == null || 
getAttribute().getSchema() == null
+                || getAttribute().getSchema().getType() == null
+                ? SchemaType.String
+                : getAttribute().getSchema().getType();
+
+        switch (type) {
 
             case Boolean:
                 result = getBooleanValue().toString();

Modified: 
syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1430209&r1=1430208&r2=1430209&view=diff
==============================================================================
--- 
syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
 (original)
+++ 
syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
 Tue Jan  8 11:10:34 2013
@@ -2040,6 +2040,7 @@ public class UserTestITCase extends Abst
         // create user and check virtual attribute value propagation
         // ----------------------------------
         UserTO userTO = getSampleTO("[email protected]");
+        userTO.getResources().clear();
         userTO.addResource("ws-target-resource-2");
 
         userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, 
UserTO.class);
@@ -2093,10 +2094,10 @@ public class UserTestITCase extends Abst
         assertNotNull(connObjectTO);
         
assertFalse(connObjectTO.getAttributeMap().get("NAME").getValues().isEmpty());
         assertEquals("virtualvalue2", 
connObjectTO.getAttributeMap().get("NAME").getValues().get(0));
-        
+
         userTO = restTemplate.getForObject(BASE_URL + "user/reactivate/" + 
userTO.getId(), UserTO.class);
         assertEquals("active", userTO.getStatus());
-        
+
         connObjectTO = restTemplate.getForObject(
                 BASE_URL + "/resource/{resourceName}/read/{objectId}.json",
                 ConnObjectTO.class, "ws-target-resource-2", 
userTO.getUsername());
@@ -2159,4 +2160,33 @@ public class UserTestITCase extends Abst
                 || 
connObjectTO.getAttributeMap().get("NAME").getValues().isEmpty());
         // ----------------------------------
     }
+
+    @Test
+    public void issueSYNCOPE267() {
+        // ----------------------------------
+        // create user and check virtual attribute value propagation
+        // ----------------------------------
+        UserTO userTO = getSampleTO("[email protected]");
+        userTO.getResources().clear();
+        userTO.addResource("resource-db-virattr");
+
+        userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, 
UserTO.class);
+        assertNotNull(userTO);
+        assertFalse(userTO.getPropagationTOs().isEmpty());
+        assertEquals("resource-db-virattr", 
userTO.getPropagationTOs().get(0).getResourceName());
+        assertEquals(PropagationTaskExecStatus.SUBMITTED, 
userTO.getPropagationTOs().get(0).getStatus());
+
+        ConnObjectTO connObjectTO = restTemplate.getForObject(
+                BASE_URL + "/resource/{resourceName}/read/{objectId}.json",
+                ConnObjectTO.class, "resource-db-virattr", userTO.getId());
+        assertNotNull(connObjectTO);
+        assertEquals("virtualvalue", 
connObjectTO.getAttributeMap().get("USERNAME").getValues().get(0));
+        // ----------------------------------
+
+        userTO = restTemplate.getForObject(BASE_URL + 
"user/read/{userId}.json", UserTO.class, userTO.getId());
+
+        assertNotNull(userTO);
+        assertEquals(1, userTO.getVirtualAttributes().size());
+        assertEquals("virtualvalue", 
userTO.getVirtualAttributes().get(0).getValues().get(0));
+    }
 }

Modified: syncope/branches/1_0_X/core/src/test/resources/content.xml
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/test/resources/content.xml?rev=1430209&r1=1430208&r2=1430209&view=diff
==============================================================================
--- syncope/branches/1_0_X/core/src/test/resources/content.xml (original)
+++ syncope/branches/1_0_X/core/src/test/resources/content.xml Tue Jan  8 
11:10:34 2013
@@ -370,6 +370,12 @@ under the License.
                     createTraceLevel="ALL" deleteTraceLevel="ALL" 
syncTraceLevel="ALL" updateTraceLevel="ALL"
                     forceMandatoryConstraint="0" 
                     propagationMode="TWO_PHASES" propagationPrimary="0" 
propagationPriority="0"/>
+                    
+  <!-- External resource for issue SYNCOPE-267 -->
+  <ExternalResource name="resource-db-virattr" connector_id="107"
+                    createTraceLevel="ALL" deleteTraceLevel="ALL" 
syncTraceLevel="ALL" updateTraceLevel="ALL"
+                    forceMandatoryConstraint="0" 
+                    propagationMode="TWO_PHASES" propagationPrimary="0" 
propagationPriority="0"/>
   
   <SyncopeUser_ExternalResource user_id="3" 
resource_name="ws-target-resource-delete" />
   <SyncopeRole_ExternalResource role_id="3" 
resource_name="ws-target-resource-list-mappings-1" />
@@ -585,6 +591,13 @@ under the License.
   <SchemaMapping id="326" accountid="0" extAttrName="EMAIL" 
intAttrName="userId" intMappingType="UserSchema" 
                  mandatoryCondition="false" password="0" 
resource_name="resource-db-sync"/>
   
+  <SchemaMapping id="331" resource_name="resource-db-virattr" accountid="1" 
password="0"
+                 intMappingType="SyncopeUserId" 
+                 mandatoryCondition="true"/>
+  <SchemaMapping id="332" resource_name="resource-db-virattr" accountid="0" 
password="0" 
+                 extAttrName="USERNAME" intAttrName="virtualdata" 
intMappingType="UserVirtualSchema"
+                 mandatoryCondition="false" />
+  
   <Task DTYPE="PropagationTask" id="1" propagationMode="TWO_PHASES" 
propagationOperation="UPDATE"
         resource_name="ws-target-resource-2" syncopeUser_id="1"
         
xmlAttributes="%3Cset%3E%0A++%3Corg.identityconnectors.framework.common.objects.Name%3E%0A++++%3Cname%3E__NAME__%3C%2Fname%3E%0A++++%3Cvalue+class%3D%22java.util.Collections%24UnmodifiableRandomAccessList%22+resolves-to%3D%22java.util.Collections%24UnmodifiableList%22%3E%0A++++++%3Cc+class%3D%22list%22%3E%0A++++++++%3Cstring%3EuserId%3C%2Fstring%3E%0A++++++%3C%2Fc%3E%0A++++++%3Clist+reference%3D%22..%2Fc%22%2F%3E%0A++++%3C%2Fvalue%3E%0A++%3C%2Forg.identityconnectors.framework.common.objects.Name%3E%0A++%3Corg.identityconnectors.framework.common.objects.Attribute%3E%0A++++%3Cname%3E__PASSWORD__%3C%2Fname%3E%0A++++%3Cvalue+class%3D%22java.util.Collections%24UnmodifiableRandomAccessList%22+resolves-to%3D%22java.util.Collections%24UnmodifiableList%22%3E%0A++++++%3Cc+class%3D%22list%22%3E%0A++++++++%3Corg.identityconnectors.common.security.GuardedString%3E%0A++++++++++%3C__readOnly%3Efalse%3C%2F__readOnly%3E%0A++++++++++%3C__disposed%3Efalse%3C%2F__disposed%3E%0A+++++++++
 
+%3C__encryptedBytes%3EQTOgwEhIHqtAI%2FYlgDhYc37esEF8VLDMU2IY1ciltrg%3D%3C%2F__encryptedBytes%3E%0A++++++++++%3C__base64SHA1Hash%3EW5%2FrwtdCnI8gAnIUhKcahMEnMMc%3D%3C%2F__base64SHA1Hash%3E%0A++++++++%3C%2Forg.identityconnectors.common.security.GuardedString%3E%0A++++++%3C%2Fc%3E%0A++++++%3Clist+reference%3D%22..%2Fc%22%2F%3E%0A++++%3C%2Fvalue%3E%0A++%3C%2Forg.identityconnectors.framework.common.objects.Attribute%3E%0A++%3Corg.identityconnectors.framework.common.objects.Attribute%3E%0A++++%3Cname%3Etype%3C%2Fname%3E%0A++++%3Cvalue+class%3D%22java.util.Collections%24UnmodifiableRandomAccessList%22+resolves-to%3D%22java.util.Collections%24UnmodifiableList%22%3E%0A++++++%3Cc+class%3D%22list%22%3E%0A++++++++%3Cstring%3Etype%3C%2Fstring%3E%0A++++++%3C%2Fc%3E%0A++++++%3Clist+reference%3D%22..%2Fc%22%2F%3E%0A++++%3C%2Fvalue%3E%0A++%3C%2Forg.identityconnectors.framework.common.objects.Attribute%3E%0A++%3Corg.identityconnectors.framework.common.objects.Attribute%3E%0A++++%3Cname%3Eful
 
lname%3C%2Fname%3E%0A++++%3Cvalue+class%3D%22java.util.Collections%24UnmodifiableRandomAccessList%22+resolves-to%3D%22java.util.Collections%24UnmodifiableList%22%3E%0A++++++%3Cc+class%3D%22list%22%3E%0A++++++++%3Cstring%3Efullname%3C%2Fstring%3E%0A++++++%3C%2Fc%3E%0A++++++%3Clist+reference%3D%22..%2Fc%22%2F%3E%0A++++%3C%2Fvalue%3E%0A++%3C%2Forg.identityconnectors.framework.common.objects.Attribute%3E%0A%3C%2Fset%3E%0A"/>


Reply via email to