Author: jbernhardt
Date: Thu Jan 31 10:16:08 2013
New Revision: 1440895

URL: http://svn.apache.org/viewvc?rev=1440895&view=rev
Log:
[SYNCOPE-231]
* adding JAVA DOC for Service Interfaces
* Fixing getOptions Bug in UserRequestService (implementations)
* Code cleanup

Modified:
    
syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserRequestServiceProxy.java
    
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ReportService.java
    
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
    
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/RoleService.java
    
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java
    
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
    
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserRequestServiceProxy.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserRequestServiceProxy.java?rev=1440895&r1=1440894&r2=1440895&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserRequestServiceProxy.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserRequestServiceProxy.java
 Thu Jan 31 10:16:08 2013
@@ -36,7 +36,10 @@ public class UserRequestServiceProxy ext
 
     @Override
     public Response getOptions() {
-        return Response.ok().allow("GET", "POST", 
"DELETE").header(SYNCOPE_CREATE_ALLOWED, isCreateAllowed()).build();
+        return Response.ok()
+                .header("Allow", "GET,POST,OPTIONS,HEAD")
+                .header(SYNCOPE_CREATE_ALLOWED, isCreateAllowed())
+                .build();
     }
 
     @Override
@@ -75,13 +78,13 @@ public class UserRequestServiceProxy ext
 
     @Override
     public UserRequestTO read(final Long requestId) {
-        return getRestTemplate().getForObject(
-                baseUrl + "user/request/read/{requestId}.json", 
UserRequestTO.class, requestId);
+        return getRestTemplate().getForObject(baseUrl + 
"user/request/read/{requestId}.json", UserRequestTO.class,
+                requestId);
     }
 
     @Override
     public void delete(final Long requestId) {
-        getRestTemplate().getForObject(
-                baseUrl + "user/request/deleteRequest/{requestId}.json", 
UserRequestTO.class, requestId);
+        getRestTemplate().getForObject(baseUrl + 
"user/request/deleteRequest/{requestId}.json", UserRequestTO.class,
+                requestId);
     }
 }

Modified: 
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ReportService.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ReportService.java?rev=1440895&r1=1440894&r2=1440895&view=diff
==============================================================================
--- 
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ReportService.java
 (original)
+++ 
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ReportService.java
 Thu Jan 31 10:16:08 2013
@@ -28,9 +28,7 @@ import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
 import org.apache.syncope.common.to.ReportExecTO;

Modified: 
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java?rev=1440895&r1=1440894&r2=1440895&view=diff
==============================================================================
--- 
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
 (original)
+++ 
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
 Thu Jan 31 10:16:08 2013
@@ -37,37 +37,71 @@ import org.apache.syncope.common.types.A
 @Path("resources")
 public interface ResourceService {
 
+    /**
+     * @param resourceTO Resource to be checked
+     * @return Returns true, if connection to resource could be established
+     */
     @POST
-    @Path("validate")
+    @Path("check")
     boolean check(ResourceTO resourceTO);
 
+    /**
+     * @param resourceTO Resource to be created
+     * @return Response containing URI location for created resource
+     */
     @POST
     Response create(ResourceTO resourceTO);
 
+    /**
+     * @param resourceName Name of resource to be deleted
+     */
     @DELETE
     @Path("{resourceName}")
     void delete(@PathParam("resourceName") String resourceName);
 
+    /**
+     * @param resourceName Name of resource to get connector from
+     * @param type
+     * @param objectId
+     * @return Returns connector for matching parameters
+     */
     @GET
     @Path("{resourceName}/{type}/{objectId}")
     ConnObjectTO getConnector(@PathParam("resourceName") String resourceName,
             @PathParam("type") AttributableType type, @PathParam("objectId") 
String objectId);
 
-    // TODO: is it a resource method?
+    /**
+     * @return Returns PropagationActionsClasses
+     */
     @GET
     @Path("propagationActionsClasses")
     Set<PropagationActionClassTO> getPropagationActionsClasses();
 
+    /**
+     * @return Returns list of all Resources
+     */
     @GET
     List<ResourceTO> list();
 
+    /**
+     * @param connInstanceId Connector id to filter for resources
+     * @return Returns all resources using matching connector
+     */
     @GET
-    List<ResourceTO> list(@MatrixParam("connInstanceId") Long connInstanceId);
+    List<ResourceTO> list(@MatrixParam("connectorId") Long connInstanceId);
 
+    /**
+     * @param resourceName Name of resource to be read
+     * @return Resource with matching name
+     */
     @GET
     @Path("{resourceName}")
     ResourceTO read(@PathParam("resourceName") String resourceName);
 
+    /**
+     * @param resourceName Name of resource to be updated
+     * @param resourceTO Resource to be stored
+     */
     @PUT
     @Path("{resourceName}")
     void update(@PathParam("resourceName") String resourceName, ResourceTO 
resourceTO);

Modified: 
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/RoleService.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/services/RoleService.java?rev=1440895&r1=1440894&r2=1440895&view=diff
==============================================================================
--- 
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/RoleService.java
 (original)
+++ 
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/RoleService.java
 Thu Jan 31 10:16:08 2013
@@ -35,52 +35,110 @@ import org.apache.syncope.common.to.Role
 @Path("roles")
 public interface RoleService {
 
+    /**
+     * @param roleId ID of role to get children from
+     * @return Returns list of children for selected role
+     */
     @GET
     @Path("{roleId}/children")
     List<RoleTO> children(@PathParam("roleId") Long roleId);
 
+    /**
+     * @return Returns number of known roles. (size of list)
+     */
     @GET
     @Path("count")
     int count();
 
+    /**
+     * @param roleTO Role to be created
+     * @return Response containing URI location for created role, as well as 
the role itself enriched with propagation
+     * status information
+     */
     @POST
     Response create(RoleTO roleTO);
 
+    /**
+     * @param roleId ID of role to be deleted
+     * @return Returns deleted role, enriched with propagation status 
information
+     */
     @DELETE
     @Path("{roleId}")
     RoleTO delete(@PathParam("roleId") Long roleId);
 
+    /**
+     * @return Returns list of all knwon roles
+     */
     @GET
     List<RoleTO> list();
 
+    /**
+     * @param page Page of roles in relation to size parameter
+     * @param size Number of roles to be displayed per page
+     * @return Returns paginated list of roles
+     */
     @GET
     List<RoleTO> list(@QueryParam("page") int page, @QueryParam("size") 
@DefaultValue("25") int size);
 
+    /**
+     * @param roleId Id of role to get parent role from
+     * @return Returns parent role or null if no parent exists
+     */
     @GET
     @Path("{roleId}/parent")
     RoleTO parent(@PathParam("roleId") Long roleId);
 
+    /**
+     * @param roleId ID of role to be read
+     * @return Returns role with matching id
+     */
     @GET
     @Path("{roleId}")
     RoleTO read(@PathParam("roleId") Long roleId);
 
+    /**
+     * @param searchCondition Filter condition for role list
+     * @return Returns list of roles with matching filter conditions
+     */
     @POST
     @Path("search")
     List<RoleTO> search(NodeCond searchCondition);
 
+    /**
+     * @param searchCondition Filter condition for role list
+     * @param page Page of roles in relation to size parameter
+     * @param size Number of roles to be displayed per page
+     * @return Returns paginated list of roles with matching filter conditions
+     */
     @POST
     @Path("search")
     List<RoleTO> search(NodeCond searchCondition, @QueryParam("page") int page,
             @QueryParam("size") @DefaultValue("25") int size);
 
+    /**
+     * @param searchCondition Filter condition for role list
+     * @return Returns number of roles matching provided filter conditions
+     */
     @POST
     @Path("search/count")
     int searchCount(NodeCond searchCondition);
 
+    /**
+     * This method is similar to {@link #read(Long)}, but uses different 
authentication handling to ensure that a user
+     * can read his own roles.
+     *
+     * @param roleId ID of role to be read
+     * @return Returns role with matching id
+     */
     @GET
     @Path("{roleId}/own")
     RoleTO selfRead(@PathParam("roleId") Long roleId);
 
+    /**
+     * @param roleId ID of role to be updated
+     * @param roleMod Role object containing list of changes to be applied for 
selected role
+     * @return Returns updated role, merged from existing role and provided 
roleMod
+     */
     @POST
     @Path("{roleId}")
     RoleTO update(@PathParam("roleId") Long roleId, RoleMod roleMod);

Modified: 
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java?rev=1440895&r1=1440894&r2=1440895&view=diff
==============================================================================
--- 
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java
 (original)
+++ 
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java
 Thu Jan 31 10:16:08 2013
@@ -42,7 +42,7 @@ public class UserRequestServiceImpl impl
 
     @Override
     public Response getOptions() {
-        return Response.ok().allow("GET", "POST", "DELETE")
+        return Response.ok().header("Allow", "GET,POST,OPTIONS,HEAD")
                 .header(SYNCOPE_CREATE_ALLOWED, 
userRequestController.isCreateAllowedByConf()).build();
     }
 

Modified: 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1440895&r1=1440894&r2=1440895&view=diff
==============================================================================
--- 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java 
(original)
+++ 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java 
Thu Jan 31 10:16:08 2013
@@ -345,9 +345,9 @@ public abstract class AbstractTest {
                     + builder.toString());
         }
     }
-    
-    <T extends AbstractSchemaTO> Response createSchema(@PathParam("kind") 
AttributableType kind,
-            @PathParam("type") SchemaType type, T schemaTO) {
+
+    <T extends AbstractSchemaTO> Response createSchema(final AttributableType 
kind,
+            final SchemaType type, final T schemaTO) {
         Response response = schemaService.create(kind, type, schemaTO);
         if (response.getStatus() != HttpStatus.SC_CREATED) {
             Exception ex = clientExceptionMapper.fromResponse(response);

Modified: 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java?rev=1440895&r1=1440894&r2=1440895&view=diff
==============================================================================
--- 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java
 (original)
+++ 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java
 Thu Jan 31 10:16:08 2013
@@ -121,8 +121,8 @@ public class UserRequestTestITCase exten
         }
 
         // 3. auth as user just created
-        UserRequestService userRequestService2 = 
setupCredentials(userRequestService, UserRequestService.class, 
userTO.getUsername(),
-                initialPassword);
+        UserRequestService userRequestService2 = 
setupCredentials(userRequestService, UserRequestService.class,
+                userTO.getUsername(), initialPassword);
 
         // 4. update with same password: not matching password policy
         try {
@@ -170,8 +170,8 @@ public class UserRequestTestITCase exten
         }
 
         // 3. auth as user just created
-        UserRequestService userRequestService2 = 
setupCredentials(userRequestService, UserRequestService.class, 
userTO.getUsername(),
-                initialPassword);
+        UserRequestService userRequestService2 = 
setupCredentials(userRequestService, UserRequestService.class,
+                userTO.getUsername(), initialPassword);
 
         // 4. now request user delete works
         createUserRequest(userRequestService2, new 
UserRequestTO(userTO.getId()));


Reply via email to