directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1510872 - in /directory/escimo/trunk: common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java ldap/src/main/java/org/apache/directory/scim/ldap/schema/BaseType.java
Date Tue, 06 Aug 2013 07:29:54 GMT
Author: kayyagari
Date: Tue Aug  6 07:29:54 2013
New Revision: 1510872

URL: http://svn.apache.org/r1510872
Log:
o moved the core URI constant
o included schemas attribute in the resource

Modified:
    directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/BaseType.java

Modified: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java?rev=1510872&r1=1510871&r2=1510872&view=diff
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java
(original)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java
Tue Aug  6 07:29:54 2013
@@ -20,7 +20,6 @@
 package org.apache.directory.scim.json;
 
 
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -31,9 +30,12 @@ import org.apache.directory.scim.SimpleA
 import org.apache.directory.scim.SimpleAttributeGroup;
 import org.apache.directory.scim.User;
 
+import sun.reflect.generics.tree.BaseType;
+
 import com.google.gson.Gson;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
 
 
 /**
@@ -45,17 +47,33 @@ public class ResourceSerializer
 {
     private Gson gson = new Gson();
 
+    public static final String CORE_URI = "urn:scim:schemas:core:1.0";
+    
     public static String serialize( User user )
     {
-        JsonObject json = new JsonObject();
+        JsonObject root = new JsonObject();
 
         Map<String, List<AbstractAttribute>> attributes = user.getAttributes();
+        
+        JsonArray schemas = new JsonArray();
+        root.add( "schemas", schemas );
+        
         for ( String uri : attributes.keySet() )
         {
-            serialize( json, attributes.get( uri ) );
+            schemas.add( new JsonPrimitive( uri ) );
+            
+            JsonObject parent = root;
+            
+            if( !uri.equals( CORE_URI ) )
+            {
+                parent = new JsonObject();
+                root.add( uri, parent );
+            }
+            
+            serialize( parent, attributes.get( uri ) );
         }
         
-        return json.toString();
+        return root.toString();
     }
 
 

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/BaseType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/BaseType.java?rev=1510872&r1=1510871&r2=1510872&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/BaseType.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/BaseType.java
Tue Aug  6 07:29:54 2013
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.scim.ldap.schema;
 
+import org.apache.directory.scim.json.ResourceSerializer;
+
 
 /**
  * TODO BaseType.
@@ -29,8 +31,6 @@ public abstract class BaseType
 {
     private String uri;
 
-    public static final String CORE_URI = "urn:scim:schemas:core:1.0";
-
     public BaseType( String uri )
     {
         this.uri = uri;
@@ -56,7 +56,7 @@ public abstract class BaseType
 
     public boolean isCoreAttribute()
     {
-        return CORE_URI.equals( uri );
+        return ResourceSerializer.CORE_URI.equals( uri );
     }
 
     /**



Mime
View raw message