directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1534985 - in /directory/escimo/trunk: client/src/main/java/org/apache/directory/scim/ common/src/main/java/org/apache/directory/scim/ ldap/src/main/java/org/apache/directory/scim/ldap/ server/src/main/java/org/apache/directory/scim/rest/ t...
Date Wed, 23 Oct 2013 11:05:52 GMT
Author: kayyagari
Date: Wed Oct 23 11:05:52 2013
New Revision: 1534985

URL: http://svn.apache.org/r1534985
Log:
fixed the path names for PUT and PATCH

Modified:
    directory/escimo/trunk/client/src/main/java/org/apache/directory/scim/EscimoClient.java
    directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java
    directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/GroupService.java
    directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java
    directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/UserResourceTest.java

Modified: directory/escimo/trunk/client/src/main/java/org/apache/directory/scim/EscimoClient.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/client/src/main/java/org/apache/directory/scim/EscimoClient.java?rev=1534985&r1=1534984&r2=1534985&view=diff
==============================================================================
--- directory/escimo/trunk/client/src/main/java/org/apache/directory/scim/EscimoClient.java
(original)
+++ directory/escimo/trunk/client/src/main/java/org/apache/directory/scim/EscimoClient.java
Wed Oct 23 11:05:52 2013
@@ -113,26 +113,26 @@ public class EscimoClient
         return deleteResource( id, GROUPS_URI );
     }
 
-    public CoreResource putUser( CoreResource resource ) throws Exception
+    public CoreResource putUser( String userId, CoreResource resource ) throws Exception
     {
-        return putResource( resource, USERS_URI );
+        return putResource( userId, resource, USERS_URI );
     }
 
     
-    public CoreResource putGroup( CoreResource resource ) throws Exception
+    public CoreResource putGroup( String groupId, CoreResource resource ) throws Exception
     {
-        return putResource( resource, GROUPS_URI );
+        return putResource( groupId, resource, GROUPS_URI );
     }
 
-    public CoreResource patchUser( CoreResource resource ) throws Exception
+    public CoreResource patchUser( String userId, CoreResource resource ) throws Exception
     {
-        return patchResource( resource, USERS_URI );
+        return patchResource( userId, resource, USERS_URI );
     }
 
     
-    public CoreResource patchGroup( CoreResource resource ) throws Exception
+    public CoreResource patchGroup( String groupId, CoreResource resource ) throws Exception
     {
-        return patchResource( resource, GROUPS_URI );
+        return patchResource( groupId, resource, GROUPS_URI );
     }
 
     
@@ -244,13 +244,15 @@ public class EscimoClient
     }
 
 
-    private CoreResource putResource( CoreResource resource, String uri ) throws Exception
+    private CoreResource putResource( String resourceId, CoreResource resource, String uri
) throws Exception
     {
         if ( resource == null )
         {
             throw new IllegalArgumentException( "resource cannot be null" );
         }
 
+        uri = uri + "/" + resourceId;
+        
         HttpPut put = new HttpPut( providerUrl + uri );
 
         String payload = serialize( resource ).toString();
@@ -283,13 +285,15 @@ public class EscimoClient
     }
 
     
-    private CoreResource patchResource( CoreResource resource, String uri ) throws Exception
+    private CoreResource patchResource( String resourceId, CoreResource resource, String
uri ) throws Exception
     {
         if ( resource == null )
         {
             throw new IllegalArgumentException( "resource cannot be null" );
         }
 
+        uri = uri + "/" + resourceId;
+        
         HttpPatch put = new HttpPatch( providerUrl + uri );
 
         String payload = serialize( resource ).toString();

Modified: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java?rev=1534985&r1=1534984&r2=1534985&view=diff
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
(original)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
Wed Oct 23 11:05:52 2013
@@ -48,11 +48,11 @@ public interface ProviderService 
     
     void deleteGroup( String id ) throws Exception;
     
-    UserResource putUser( String jsonData, RequestContext ctx ) throws Exception;
+    UserResource putUser( String userId, String jsonData, RequestContext ctx ) throws Exception;
     
-    GroupResource putGroup( String jsonData, RequestContext ctx ) throws Exception;
+    GroupResource putGroup( String groupId, String jsonData, RequestContext ctx ) throws
Exception;
 
-    UserResource patchUser( String jsonData, RequestContext ctx ) throws Exception;
+    UserResource patchUser( String userId, String jsonData, RequestContext ctx ) throws Exception;
     
-    GroupResource patchGroup( String jsonData, RequestContext ctx ) throws Exception;
+    GroupResource patchGroup( String groupId, String jsonData, RequestContext ctx ) throws
Exception;
 }

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=1534985&r1=1534984&r2=1534985&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
Wed Oct 23 11:05:52 2013
@@ -239,27 +239,27 @@ public class LdapResourceProvider implem
     }
 
 
-    public UserResource putUser( String jsonData, RequestContext ctx ) throws Exception
+    public UserResource putUser( String userId, String jsonData, RequestContext ctx ) throws
Exception
     {
-        return ( UserResource ) replaceResource( jsonData, ctx, userSchema );
+        return ( UserResource ) replaceResource( userId, jsonData, ctx, userSchema );
     }
 
 
-    public GroupResource putGroup( String jsonData, RequestContext ctx ) throws Exception
+    public GroupResource putGroup( String groupId, String jsonData, RequestContext ctx )
throws Exception
     {
-        return ( GroupResource ) replaceResource( jsonData, ctx, groupSchema );
+        return ( GroupResource ) replaceResource( groupId, jsonData, ctx, groupSchema );
     }
 
 
-    public UserResource patchUser( String jsonData, RequestContext ctx ) throws Exception
+    public UserResource patchUser( String userId, String jsonData, RequestContext ctx ) throws
Exception
     {
-        return ( UserResource ) patchResource( jsonData, ctx, userSchema );
+        return ( UserResource ) patchResource( userId, jsonData, ctx, userSchema );
     }
 
 
-    public GroupResource patchGroup( String jsonData, RequestContext ctx ) throws Exception
+    public GroupResource patchGroup( String groupId, String jsonData, RequestContext ctx
) throws Exception
     {
-        return ( GroupResource ) patchResource( jsonData, ctx, groupSchema );
+        return ( GroupResource ) patchResource( groupId, jsonData, ctx, groupSchema );
     }
 
     
@@ -487,13 +487,11 @@ public class LdapResourceProvider implem
     
     
     // TODO can userName be changed for a user?? likewise displayName for a Group
-    public ServerResource replaceResource( String jsonData, RequestContext ctx, ResourceSchema
resourceSchema ) throws Exception
+    public ServerResource replaceResource( String resourceId, String jsonData, RequestContext
ctx, ResourceSchema resourceSchema ) throws Exception
     {
         JsonParser parser = new JsonParser();
         JsonObject obj = ( JsonObject ) parser.parse( jsonData );
         
-        String resourceId = obj.get( "id" ).getAsString();
-        
         Entry entry = new DefaultEntry( ldapSchema );
         
         _resourceToEntry( entry, obj, ctx, resourceSchema );
@@ -627,13 +625,11 @@ public class LdapResourceProvider implem
     }
     
     
-    public ServerResource patchResource( String jsonData, RequestContext ctx, ResourceSchema
resourceSchema ) throws Exception
+    public ServerResource patchResource( String resourceId, String jsonData, RequestContext
ctx, ResourceSchema resourceSchema ) throws Exception
     {
         JsonParser parser = new JsonParser();
         JsonObject obj = ( JsonObject ) parser.parse( jsonData );
 
-        String resourceId = obj.get( "id" ).getAsString();
-        
         Entry existingEntry = fetchEntryById( resourceId, resourceSchema );
         
         if( existingEntry == null )

Modified: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/GroupService.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/GroupService.java?rev=1534985&r1=1534984&r2=1534985&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/GroupService.java
(original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/GroupService.java
Wed Oct 23 11:05:52 2013
@@ -87,13 +87,13 @@ public class GroupService
     
     @DELETE
     @Path("{id}")
-    public Response deleteGroup( @PathParam("id") String userId, @Context UriInfo uriInfo,
@Context HttpHeaders headers )
+    public Response deleteGroup( @PathParam("id") String groupId, @Context UriInfo uriInfo,
@Context HttpHeaders headers )
     {
         ResponseBuilder rb = Response.ok();
         
         try
         {
-            provider.deleteGroup( userId );
+            provider.deleteGroup( groupId );
         }
         catch( Exception e )
         {
@@ -142,8 +142,9 @@ public class GroupService
 
     
     @PUT
+    @Path("{id}")
     @Produces({MediaType.APPLICATION_JSON})
-    public Response putGroup( String jsonData, @Context UriInfo uriInfo, @Context HttpHeaders
headers )
+    public Response putGroup( @PathParam("id") String groupId, String jsonData, @Context
UriInfo uriInfo, @Context HttpHeaders headers )
     {
         ResponseBuilder rb = null;
 
@@ -159,7 +160,7 @@ public class GroupService
         {
             RequestContext ctx = new RequestContext( provider, uriInfo, headers );
             
-            ServerResource res = provider.putGroup( jsonData, ctx );
+            ServerResource res = provider.putGroup( groupId, jsonData, ctx );
             
             String json = ResourceSerializer.serialize( res );
             
@@ -176,8 +177,9 @@ public class GroupService
     }
 
     @PATCH
+    @Path("{id}")
     @Produces({MediaType.APPLICATION_JSON})
-    public Response patchGroup( String jsonData, @Context UriInfo uriInfo, @Context HttpHeaders
headers )
+    public Response patchGroup( @PathParam("id") String groupId, String jsonData, @Context
UriInfo uriInfo, @Context HttpHeaders headers )
     {
         ResponseBuilder rb = null;
 
@@ -193,7 +195,7 @@ public class GroupService
         {
             RequestContext ctx = new RequestContext( provider, uriInfo, headers );
             
-            ServerResource resource = provider.patchGroup( jsonData, ctx );
+            ServerResource resource = provider.patchGroup( groupId, jsonData, ctx );
             
             if( resource == null )
             {

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=1534985&r1=1534984&r2=1534985&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
Wed Oct 23 11:05:52 2013
@@ -147,8 +147,9 @@ public class UserService
 
     
     @PUT
+    @Path("{id}")
     @Produces({MediaType.APPLICATION_JSON})
-    public Response putUser( String jsonData, @Context UriInfo uriInfo, @Context HttpHeaders
headers )
+    public Response putUser( @PathParam("id") String userId, String jsonData, @Context UriInfo
uriInfo, @Context HttpHeaders headers )
     {
         ResponseBuilder rb = null;
 
@@ -164,7 +165,7 @@ public class UserService
         {
             RequestContext ctx = new RequestContext( provider, uriInfo, headers );
             
-            ServerResource res = provider.putUser( jsonData, ctx );
+            ServerResource res = provider.putUser( userId, jsonData, ctx );
             
             String json = ResourceSerializer.serialize( res );
             
@@ -182,8 +183,9 @@ public class UserService
 
     
     @PATCH
+    @Path("{id}")
     @Produces({MediaType.APPLICATION_JSON})
-    public Response patchUser( String jsonData, @Context UriInfo uriInfo, @Context HttpHeaders
headers )
+    public Response patchUser( @PathParam("id") String userId, String jsonData, @Context
UriInfo uriInfo, @Context HttpHeaders headers )
     {
         ResponseBuilder rb = null;
 
@@ -199,7 +201,7 @@ public class UserService
         {
             RequestContext ctx = new RequestContext( provider, uriInfo, headers );
             
-            ServerResource resource = provider.patchUser( jsonData, ctx );
+            ServerResource resource = provider.patchUser( userId, jsonData, ctx );
             
             if( resource == null )
             {

Modified: directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/UserResourceTest.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/UserResourceTest.java?rev=1534985&r1=1534984&r2=1534985&view=diff
==============================================================================
--- directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/UserResourceTest.java
(original)
+++ directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/UserResourceTest.java
Wed Oct 23 11:05:52 2013
@@ -138,7 +138,7 @@ public class UserResourceTest
         newEmail.setValue( "newemail@example.com" );
         addedUser.getEmails().add( newEmail );
         
-        User replacedUser = ( User ) client.putUser( addedUser );
+        User replacedUser = ( User ) client.putUser( addedUser.getId(), addedUser );
 
         assertNotNull( replacedUser );
         assertEquals( 1, replacedUser.getEmails().size() );
@@ -181,7 +181,7 @@ public class UserResourceTest
             addedUser.getEmails().add( newEmail );
         }
         
-        User patchedUser = ( User ) client.patchUser( addedUser );
+        User patchedUser = ( User ) client.patchUser( addedUser.getId(), addedUser );
 
         assertNull( patchedUser );
         
@@ -237,7 +237,6 @@ public class UserResourceTest
         Group.Member deletedMember = members.get( 0 );
         
         Group tobePatchedGroup = new Group();
-        tobePatchedGroup.setId( addedGroup.getId() );
         
         List<Group.Member> patchedMembers = new ArrayList<Group.Member>();
         tobePatchedGroup.setMembers( patchedMembers );
@@ -245,7 +244,7 @@ public class UserResourceTest
         deletedMember.setOperation( "delete" );
         patchedMembers.add( deletedMember );
         
-        client.patchGroup( tobePatchedGroup );
+        client.patchGroup( addedGroup.getId(), tobePatchedGroup );
         Group patchedGroup = ( Group ) client.getGroup( addedGroup.getId() );
         assertEquals( ( count - 1 ), patchedGroup.getMembers().size() );
         



Mime
View raw message