directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1512812 - in /directory/escimo/trunk: common/src/main/java/org/apache/directory/scim/ common/src/main/java/org/apache/directory/scim/util/ ldap/src/main/java/org/apache/directory/scim/ldap/ ldap/src/main/resources/ server/src/main/java/org...
Date Sat, 10 Aug 2013 18:13:46 GMT
Author: kayyagari
Date: Sat Aug 10 18:13:46 2013
New Revision: 1512812

URL: http://svn.apache.org/r1512812
Log:
o added meta attribute handler
o added support for deriving the location

Added:
    directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/util/
    directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/util/ResourceUtil.java
Modified:
    directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java
    directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/User.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java
    directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml
    directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java

Modified: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java?rev=1512812&r1=1512811&r2=1512812&view=diff
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java
(original)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java
Sat Aug 10 18:13:46 2013
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.scim;
 
+import javax.ws.rs.core.UriInfo;
+
 /**
  * TODO RequestContext.
  *
@@ -27,7 +29,7 @@ package org.apache.directory.scim;
 public class RequestContext
 {
     private Object resourceConnection;
-    //private Uri
+    private UriInfo uriInfo;
     
     private User user;
 
@@ -50,5 +52,15 @@ public class RequestContext
     {
         this.user = user;
     }
+
+    public UriInfo getUriInfo()
+    {
+        return uriInfo;
+    }
+
+    public void setUriInfo( UriInfo uriInfo )
+    {
+        this.uriInfo = uriInfo;
+    }
     
 }

Modified: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/User.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/User.java?rev=1512812&r1=1512811&r2=1512812&view=diff
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/User.java (original)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/User.java Sat Aug
10 18:13:46 2013
@@ -33,6 +33,8 @@ public class User
 {
     private Map<String,List<AbstractAttribute>> uriAtMap = new HashMap<String,
List<AbstractAttribute>>();
     
+    private String id;
+    
     public void addAttribute( String uri, AbstractAttribute at )
     {
         List<AbstractAttribute> atList = uriAtMap.get( uri );
@@ -51,6 +53,16 @@ public class User
         return uriAtMap;
     }
 
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+
+    public String getId()
+    {
+        return id;
+    }
+
     @Override
     public String toString()
     {

Added: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/util/ResourceUtil.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/util/ResourceUtil.java?rev=1512812&view=auto
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/util/ResourceUtil.java
(added)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/util/ResourceUtil.java
Sat Aug 10 18:13:46 2013
@@ -0,0 +1,70 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.scim.util;
+
+
+/**
+ * TODO ResourceUtil.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ResourceUtil
+{
+    public static String formatDate( String zTime )
+    {
+        //parse a value like 20120302164134Z to 2012-03-02T16:41:34Z 
+        StringBuilder sb = new StringBuilder();
+        int start = 0;
+        int end = 4;
+        sb.append( zTime.substring( start, end ) )
+            .append( "-" );
+
+        start = end;
+        end += 2;
+        sb.append( zTime.substring( start, end ) )
+            .append( "-" );
+
+        start = end;
+        end += 2;
+        sb.append( zTime.substring( start, end ) )
+            .append( "-" );
+
+        sb.append( "T" );
+
+        start = end;
+        end += 2;
+        sb.append( zTime.substring( start, end ) )
+            .append( ":" );
+
+        start = end;
+        end += 2;
+        sb.append( zTime.substring( start, end ) )
+            .append( ":" );
+
+        start = end;
+        end += 2;
+        sb.append( zTime.substring( start, end ) );
+
+        sb.append( "Z" );
+
+        return sb.toString();
+    }
+
+}

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java?rev=1512812&r1=1512811&r2=1512812&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java
Sat Aug 10 18:13:46 2013
@@ -62,9 +62,9 @@ import org.apache.directory.ldap.client.
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.scim.AttributeHandler;
 import org.apache.directory.scim.ComplexAttribute;
-import org.apache.directory.scim.RequestContext;
 import org.apache.directory.scim.MultiValAttribute;
 import org.apache.directory.scim.ProviderService;
+import org.apache.directory.scim.RequestContext;
 import org.apache.directory.scim.ResourceNotFoundException;
 import org.apache.directory.scim.SimpleAttribute;
 import org.apache.directory.scim.SimpleAttributeGroup;
@@ -77,6 +77,7 @@ import org.apache.directory.scim.ldap.sc
 import org.apache.directory.scim.ldap.schema.TypedType;
 import org.apache.directory.scim.ldap.schema.UserSchema;
 import org.apache.directory.scim.schema.BaseType;
+import org.apache.directory.scim.util.ResourceUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -222,6 +223,13 @@ public class LdapResourceProvider implem
 
         ctx.setUser( user );
         
+        // first fill in the id, we need this for deriving location
+        SimpleType idType = ( SimpleType ) userSchema.getCoreAttribute( "id" );
+        SimpleAttribute idAttribute = getValueForSimpleType( idType, entry, ctx );
+        user.addAttribute( idType.getUri(), idAttribute );
+        
+        user.setId( ( String ) idAttribute.getValue() );
+        
         for ( BaseType bt : coreTypes )
         {
             if ( bt instanceof SimpleType )
@@ -233,6 +241,12 @@ public class LdapResourceProvider implem
                     continue;
                 }
 
+                // skip id attribute, it was already added above
+                if( st == idType )
+                {
+                    continue;
+                }
+                
                 SimpleAttribute at = getValueForSimpleType( st, entry, ctx );
                 if ( at != null )
                 {
@@ -511,7 +525,7 @@ public class LdapResourceProvider implem
             }
             else if ( sc instanceof GeneralizedTimeSyntaxChecker )
             {
-                return formatDate( ldapValue.getString() );
+                return ResourceUtil.formatDate( ldapValue.getString() );
             }
         }
 
@@ -519,46 +533,6 @@ public class LdapResourceProvider implem
     }
 
 
-    public String formatDate( String zTime )
-    {
-        //parse a value like 20120302164134Z to 2012-03-02T16:41:34Z 
-        StringBuilder sb = new StringBuilder();
-        int start = 0;
-        int end = 4;
-        sb.append( zTime.substring( start, end ) )
-            .append( "-" );
-
-        start = end;
-        end += 2;
-        sb.append( zTime.substring( start, end ) )
-            .append( "-" );
-
-        start = end;
-        end += 2;
-        sb.append( zTime.substring( start, end ) )
-            .append( "-" );
-
-        sb.append( "T" );
-
-        start = end;
-        end += 2;
-        sb.append( zTime.substring( start, end ) )
-            .append( ":" );
-
-        start = end;
-        end += 2;
-        sb.append( zTime.substring( start, end ) )
-            .append( ":" );
-
-        start = end;
-        end += 2;
-        sb.append( zTime.substring( start, end ) );
-
-        sb.append( "Z" );
-
-        return sb.toString();
-    }
-
 
 //    public List<SimpleAttribute> getValuesInto( SimpleTypeGroup stg, RequestContext
ctx ) throws LdapException
 //    {

Modified: directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml?rev=1512812&r1=1512811&r2=1512812&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml (original)
+++ directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml Sat Aug 10 18:13:46
2013
@@ -76,12 +76,7 @@
             </at-group>
         </multival-attribute>
 
-        <complex-attribute name="meta">
-            <at-group>
-                <attribute name="created" mappedTo="createTimestamp" />
-                <attribute name="lastModified" mappedTo="lastModifiedTimestamp" />
-            </at-group>
-        </complex-attribute>
+        <complex-attribute name="meta" handlerRef="metaHandler" />
 
     </schema>
 
@@ -112,5 +107,7 @@
     <atHandlers>
         <handler name="activeHandler"
             class="org.apache.directory.scim.ldap.handlers.ActiveAttributeHandler" />
+        <handler name="metaHandler"
+            class="org.apache.directory.scim.ldap.handlers.MetaAttributeHandler" />
     </atHandlers>
 </entities>
\ No newline at end of file

Modified: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java?rev=1512812&r1=1512811&r2=1512812&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java
(original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java
Sat Aug 10 18:13:46 2013
@@ -55,6 +55,7 @@ public class UserService
         try
         {
             RequestContext ctx = new RequestContext();
+            ctx.setUriInfo( uriInfo );
             
             User user = provider.getUser( ctx, userId );
             String json = ResourceSerializer.serialize( user );



Mime
View raw message