You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by jb...@apache.org on 2013/01/10 11:21:14 UTC

svn commit: r1431255 - in /syncope/trunk: client/src/main/java/org/apache/syncope/services/ client/src/main/java/org/apache/syncope/services/proxy/ client/src/main/java/org/apache/syncope/types/ core/src/test/java/org/apache/syncope/core/rest/

Author: jbernhardt
Date: Thu Jan 10 10:21:14 2013
New Revision: 1431255

URL: http://svn.apache.org/viewvc?rev=1431255&view=rev
Log:
[SYNCOPE-259]
* Service Cleanup (removed deprecated annotations, removed obsolete comments)
* SchemaService refactoring to use new SchemaType instead of SchemaTO classes in method signature

Modified:
    syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerService.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/NotificationService.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/PolicyService.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/SchemaService.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/TaskService.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/UserRequestService.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/WorkflowService.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/LoggerServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SchemaServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/types/AuditLoggerName.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerService.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerService.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerService.java Thu Jan 10 10:21:14 2013
@@ -36,6 +36,7 @@ import ch.qos.logback.classic.Level;
 @Path("logger")
 public interface LoggerService {
 
+    //TODO use list(LoggerType) signature for both normal logger and audit logger instead of two different methods
     @GET
     @RequestMapping(method = RequestMethod.GET, value = "/log/list")
     List<LoggerTO> listLogs();
@@ -48,25 +49,17 @@ public interface LoggerService {
     @PUT
     @Path("{name}/level")
     @RequestMapping(method = RequestMethod.POST, value = "/log/{name}/{level}")
-    LoggerTO setLogLevel(@PathParam("name") final String name, final Level level);
+    LoggerTO update(@PathParam("name") final String name, final Level level);
 
     @DELETE
     @Path("{name}")
     @RequestMapping(method = RequestMethod.GET, value = "/log/delete/{name}")
-    LoggerTO deleteLog(@PathParam("name") final String name);
+    LoggerTO delete(@PathParam("name") final String name);
 
-    /**
-     * @deprecated Refactoring needed here. Use {@link #setLogLevel(String, Level)} after refactoring is done.
-     */
-    @Deprecated
-    @RequestMapping(method = RequestMethod.PUT, value = "/audit/enable")
-    void enableAudit(final AuditLoggerName auditLoggerName);
-
-    /**
-     * @deprecated Refactoring needed here. Use {@link #deleteLog(String)} after refactoring is done.
-     */
-    @Deprecated
-    @RequestMapping(method = RequestMethod.PUT, value = "/audit/disable")
-    void disableAudit(final AuditLoggerName auditLoggerName);
+    // TODO refactor this method to use update()
+    void enableAudit(AuditLoggerName auditLoggerName);
+
+    // TODO refactor this method to use delete()
+    void disableAudit(AuditLoggerName auditLoggerName);
 
 }
\ No newline at end of file

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/NotificationService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/NotificationService.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/NotificationService.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/NotificationService.java Thu Jan 10 10:21:14 2013
@@ -34,25 +34,20 @@ public interface NotificationService {
 
     @GET
     @Path("{notificationId}")
-//    @RequestMapping(method = RequestMethod.GET, value = "/read/{notificationId}")
     NotificationTO read(@PathParam("notificationId") final Long notificationId);
 
     @GET
-//    @RequestMapping(method = RequestMethod.GET, value = "/list")
     List<NotificationTO> list();
 
     @POST
-//    @RequestMapping(method = RequestMethod.POST, value = "/create")
     NotificationTO create(final NotificationTO notificationTO);
 
     @PUT
     @Path("{notificationId}")
-//    @RequestMapping(method = RequestMethod.POST, value = "/update")
     NotificationTO update(@PathParam("notificationId") final Long notificationId, final NotificationTO notificationTO);
 
     @DELETE
     @Path("{notificationId}")
-//    @RequestMapping(method = RequestMethod.GET, value = "/delete/{notificationId}")
     NotificationTO delete(@PathParam("notificationId") final Long notificationId);
 
 }
\ No newline at end of file

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/PolicyService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/PolicyService.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/PolicyService.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/PolicyService.java Thu Jan 10 10:21:14 2013
@@ -36,18 +36,14 @@ public interface PolicyService {
 	@POST
     <T extends PolicyTO> T create(final T policyTO);
 
-	@PUT
+	// TODO: policyClass is required only for Spring RestTemplate mock. Must be removed for CXF
+	@DELETE
 	@Path("{policyId}")
-    <T extends PolicyTO> T update(@PathParam("policyId") final Long policyId, final T policyTO);
-
-	@GET
-	@Path("{type}")
-	<T extends PolicyTO> List<T> listByType(@PathParam("type") final PolicyType type);
+	<T extends PolicyTO> T delete(@PathParam("policyId") final Long policyId, Class<T> policyClass);
 
-	// TODO: policyClass is required only for Spring RestTemplate mock. Must be removed for CXF
 	@GET
-	@Path("global/{type}")
-	<T extends PolicyTO> T readGlobal(@PathParam("type") final PolicyType type, Class<T> policyClass);
+	@Path("{kind}")
+	<T extends PolicyTO> List<T> listByType(@PathParam("kind") final PolicyType type);
 
 	// TODO: policyClass is required only for Spring RestTemplate mock. Must be removed for CXF
 	@GET
@@ -55,8 +51,12 @@ public interface PolicyService {
 	<T extends PolicyTO> T read(@PathParam("policyId") final Long policyId, Class<T> policyClass);
 
 	// TODO: policyClass is required only for Spring RestTemplate mock. Must be removed for CXF
-	@DELETE
+	@GET
+	@Path("global/{kind}")
+	<T extends PolicyTO> T readGlobal(@PathParam("kind") final PolicyType type, Class<T> policyClass);
+
+	@PUT
 	@Path("{policyId}")
-	<T extends PolicyTO> T delete(@PathParam("policyId") final Long policyId, Class<T> policyClass);
+    <T extends PolicyTO> T update(@PathParam("policyId") final Long policyId, final T policyTO);
 
 }
\ No newline at end of file

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java Thu Jan 10 10:21:14 2013
@@ -35,49 +35,48 @@ import org.apache.syncope.client.to.Role
 @Path("roles")
 public interface RoleService {
 
-	@GET
+    @GET
     @Path("{roleId}/children")
-	List<RoleTO> children(@PathParam("roleId") final Long roleId);
+    List<RoleTO> children(@PathParam("roleId") final Long roleId);
 
-	@POST
-	RoleTO create(final RoleTO roleTO);
+    @POST
+    RoleTO create(final RoleTO roleTO);
 
-	@DELETE
+    @DELETE
     @Path("{roleId}")
-	RoleTO delete(@PathParam("roleId") final Long roleId);
+    RoleTO delete(@PathParam("roleId") final Long roleId);
 
-	@GET
-	List<RoleTO> list();
+    @GET
+    List<RoleTO> list();
 
-	@GET
+    @GET
     @Path("{roleId}/parent")
-	RoleTO parent(@PathParam("roleId") final Long roleId);
+    RoleTO parent(@PathParam("roleId") final Long roleId);
 
-	@GET
-	@Path("{roleId}")
-	RoleTO read(@PathParam("roleId") final Long roleId);
-
-	@POST
-	@Path("search")
-	List<RoleTO> search(final NodeCond searchCondition);
-
-	@POST
-	@Path("search")
-	List<RoleTO> search(final NodeCond searchCondition,
-			@QueryParam("page") final int page,
-			@QueryParam("size") @DefaultValue("25") final int size);
-
-	@POST
-	@Path("search/count")
-	int searchCount(final NodeCond searchCondition);
-
-	/**
-	 * @deprecated Authentication checks should not depend on the method called
-	 */
-	@Deprecated
-	RoleTO selfRead(final Long roleId);
+    @GET
+    @Path("{roleId}")
+    RoleTO read(@PathParam("roleId") final Long roleId);
+
+    @POST
+    @Path("search")
+    List<RoleTO> search(final NodeCond searchCondition);
+
+    @POST
+    @Path("search")
+    List<RoleTO> search(final NodeCond searchCondition,
+            @QueryParam("page") final int page,
+            @QueryParam("size") @DefaultValue("25") final int size);
+
+    @POST
+    @Path("search/count")
+    int searchCount(final NodeCond searchCondition);
+
+    /**
+     * deprecated Authentication checks should not depend on the method called
+     */
+    RoleTO selfRead(final Long roleId);
 
-	@POST
+    @POST
     @Path("{roleId}")
-	RoleTO update(@PathParam("roleId") final Long roleId, final RoleMod roleMod);
+    RoleTO update(@PathParam("roleId") final Long roleId, final RoleMod roleMod);
 }
\ No newline at end of file

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/SchemaService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/SchemaService.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/SchemaService.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/SchemaService.java Thu Jan 10 10:21:14 2013
@@ -29,34 +29,52 @@ import javax.ws.rs.PathParam;
 
 import org.apache.syncope.client.to.AbstractSchemaTO;
 
-@Path("schemas")
+@Path("schemas/{kind}/{type}")
 public interface SchemaService {
 
+    //TODO refactoring needed here. SchemaType exists already in org.apache.syncope.types.
+    // Maybe that (other) type can be renamed to SchemaElementType ?
+    enum SchemaType {
+        NORMAL("schema"), DERIVED("derivedSchema"), VIRTUAL("virtualSchema");
+
+        private final String name;
+
+        private SchemaType(String name) {
+            this.name = name;
+        }
+
+        @Override
+        public String toString() {
+            return name;
+        }
+    }
+
     @POST
-    //    @RequestMapping(method = RequestMethod.POST, value = "/{kind}/create")
-    <T extends AbstractSchemaTO> T create(@PathParam("kind") final String kind, final T schemaTO);
+    <T extends AbstractSchemaTO> T create(@PathParam("kind") final String kind,
+            @PathParam("type") final SchemaType type,
+            final T schemaTO);
 
     @DELETE
-    @Path("{kind}/{schema}")
-    //    @RequestMapping(method = RequestMethod.GET, value = "/{kind}/delete/{schema}")
+    @Path("{name}")
     <T extends AbstractSchemaTO> T delete(@PathParam("kind") final String kind,
-            @PathParam("schema") final String schemaName, final Class<T> type);
+            @PathParam("type") final SchemaType type,
+            @PathParam("name") final String schemaName);
 
     @GET
-    @Path("{kind}")
-    //    @RequestMapping(method = RequestMethod.GET, value = "/{kind}/list")
-    <T extends AbstractSchemaTO> List<T> list(@PathParam("kind") final String kind, final Class<T[]> type);
+    <T extends AbstractSchemaTO> List<T> list(@PathParam("kind") final String kind,
+            @PathParam("type") final SchemaType type);
 
     @GET
-    @Path("{kind}/{schema}")
-    //    @RequestMapping(method = RequestMethod.GET, value = "/{kind}/read/{schema}")
+    @Path("{name}")
     <T extends AbstractSchemaTO> T read(@PathParam("kind") final String kind,
-            @PathParam("schema") final String schemaName, final Class<T> type);
+            @PathParam("type") final SchemaType type,
+            @PathParam("name") final String schemaName);
 
     @PUT
-    @Path("{kind}/{schema}")
-    //    @RequestMapping(method = RequestMethod.POST, value = "/{kind}/update")
+    @Path("{name}")
     <T extends AbstractSchemaTO> T update(@PathParam("kind") final String kind,
-            @PathParam("schema") final String schemaName, final T schemaTO);
+            @PathParam("type") final SchemaType type,
+            @PathParam("name") final String schemaName,
+            final T schemaTO);
 
 }
\ No newline at end of file

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/TaskService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/TaskService.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/TaskService.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/TaskService.java Thu Jan 10 10:21:14 2013
@@ -34,90 +34,65 @@ import javax.ws.rs.QueryParam;
 import org.apache.syncope.client.to.TaskExecTO;
 import org.apache.syncope.client.to.TaskTO;
 import org.apache.syncope.types.PropagationTaskExecStatus;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
 
 @Path("tasks")
 public interface TaskService {
 
     @GET
     @Path("{kind}/count")
-    @RequestMapping(method = RequestMethod.GET, value = "/{kind}/count")
     int count(@PathParam("kind") final String kind);
 
-    //    @RequestMapping(method = RequestMethod.POST, value = "/create/sync")
-    //    TaskTO createSyncTask(  final SyncTaskTO taskTO);
-    //
-    //    @RequestMapping(method = RequestMethod.POST, value = "/create/sched")
-    //    TaskTO createSchedTask( final SchedTaskTO taskTO);
-
     @POST
     <T extends TaskTO> T create(T taskTO);
 
     @DELETE
     @Path("{taskId}")
-    @RequestMapping(method = RequestMethod.GET, value = "/delete/{taskId}")
     <T extends TaskTO> T delete(@PathParam("taskId") final Long taskId, Class<T> type);
 
     @DELETE
     @Path("executions/{executionId}")
-    @RequestMapping(method = RequestMethod.GET, value = "/execution/delete/{executionId}")
     TaskExecTO deleteExecution(@PathParam("executionId") final Long executionId);
 
     @POST
     @Path("{taskId}/execute")
-    @RequestMapping(method = RequestMethod.POST, value = "/execute/{taskId}")
     TaskExecTO execute(@PathParam("taskId") final Long taskId,
             @QueryParam("dryRun") @DefaultValue("false") final boolean dryRun);
 
     @GET
     @Path("jobClasses")
-    @RequestMapping(method = RequestMethod.GET, value = "/jobClasses")
     Set<String> getJobClasses();
 
     @GET
     @Path("syncActionsClasses")
-    @RequestMapping(method = RequestMethod.GET, value = "/syncActionsClasses")
     Set<String> getSyncActionsClasses();
 
     @GET
     @Path("{kind}")
-    @RequestMapping(method = RequestMethod.GET, value = "/{kind}/list")
     <T extends TaskTO> List<T> list(@PathParam("kind") final String kind, Class<T[]> type);
 
     @GET
     @Path("{kind}")
-    @RequestMapping(method = RequestMethod.GET, value = "/{kind}/list/{page}/{size}")
     <T extends TaskTO> List<T> list(@PathParam("kind") final String kind, @QueryParam("page") final int page,
             @QueryParam("size") @DefaultValue("25") final int size, Class<T[]> type);
 
     @GET
     @Path("{kind}/executions")
-    @RequestMapping(method = RequestMethod.GET, value = "/{kind}/execution/list")
     List<TaskExecTO> listExecutions(@PathParam("kind") final String kind);
 
     @GET
     @Path("{taskId}")
-    @RequestMapping(method = RequestMethod.GET, value = "/read/{taskId}")
     <T extends TaskTO> T read(@PathParam("taskId") final Long taskId, Class<T> type);
 
     @GET
     @Path("executions/{executionId}")
-    @RequestMapping(method = RequestMethod.GET, value = "/execution/read/{executionId}")
     TaskExecTO readExecution(@PathParam("executionId") final Long executionId);
 
     @POST
     @Path("executions/{executionId}/report")
-    @RequestMapping(method = RequestMethod.GET, value = "/execution/report/{executionId}")
+    //TODO create new TaskExecutionReportTO object which contains status and message
     TaskExecTO report(@PathParam("executionId") final Long executionId,
             @HeaderParam("Execution-Status") final PropagationTaskExecStatus status, final String message);
 
-    //    @RequestMapping(method = RequestMethod.POST, value = "/update/sync")
-    //    TaskTO updateSync(final SyncTaskTO taskTO);
-    //
-    //    @RequestMapping(method = RequestMethod.POST, value = "/update/sched")
-    //    TaskTO updateSched(final SchedTaskTO taskTO);
-
     @PUT
     @Path("{taskId}")
     <T extends TaskTO> T update(@PathParam("taskId") final Long taskId, T taskTO);

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/UserRequestService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/UserRequestService.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/UserRequestService.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/UserRequestService.java Thu Jan 10 10:21:14 2013
@@ -30,7 +30,7 @@ import org.apache.syncope.client.mod.Use
 import org.apache.syncope.client.to.UserRequestTO;
 import org.apache.syncope.client.to.UserTO;
 
-@Path("requests/users")
+@Path("requests/user")
 public interface UserRequestService {
 
     @GET
@@ -40,31 +40,25 @@ public interface UserRequestService {
 
     @POST
     @Path("create")
-    //    @RequestMapping(method = RequestMethod.POST, value = "/create")
     UserRequestTO create(final UserTO userTO);
 
     @POST
     @Path("update")
-    //    @RequestMapping(method = RequestMethod.POST, value = "/update")
     UserRequestTO update(final UserMod userMod);
 
     @POST
     @Path("delete")
-    //    @RequestMapping(method = RequestMethod.GET, value = "/delete/{userId}")
     UserRequestTO delete(final Long userId);
 
     @GET
-    //    @RequestMapping(method = RequestMethod.GET, value = "/list")
     List<UserRequestTO> list();
 
     @GET
     @Path("{requestId}")
-    //    @RequestMapping(method = RequestMethod.GET, value = "/read/{requestId}")
     UserRequestTO read(@PathParam("requestId") final Long requestId);
 
     @DELETE
     @Path("{requestId}")
-    //    @RequestMapping(method = RequestMethod.GET, value = "/deleteRequest/{requestId}")
     UserRequestTO deleteRequest(@PathParam("requestId") final Long requestId);
 
 }
\ No newline at end of file

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java Thu Jan 10 10:21:14 2013
@@ -39,23 +39,18 @@ import org.apache.syncope.client.to.Work
 public interface UserService {
 
     /**
-     * @deprecated As of release 1.2.0, replaced by
-     *             {@link #setStatus(Long, StatusMod)}
+     * deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
      */
-    @Deprecated
     UserTO activate(long userId, String token);
 
     /**
-     * @deprecated As of release 1.2.0, replaced by
-     *             {@link #setStatus(Long, StatusMod)}
+     * deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
      */
-    @Deprecated
     UserTO activateByUsername(String username, String token);
 
     /**
-     * @deprecated This method needs to be moved to a new workflow service.
+     * deprecated This method needs to be moved to a new workflow service.
      */
-    @Deprecated
     @POST
     @Path("workflow/task/{taskId}/claim")
     WorkflowFormTO claimForm(@PathParam("taskId") final String taskId);
@@ -72,24 +67,21 @@ public interface UserService {
     UserTO delete(@PathParam("userId") final Long userId);
 
     /**
-     * @deprecated This method needs to be moved to a new workflow service.
+     * deprecated This method needs to be moved to workflow service.
      */
-    @Deprecated
     @POST
     UserTO executeWorkflow(@PathParam("taskId") final String taskId, final UserTO userTO);
 
     /**
-     * @deprecated This method needs to be moved to a new workflow service.
+     * deprecated This method needs to be moved to workflow service.
      */
-    @Deprecated
     @GET
     @Path("{userId}/workflow/form")
     WorkflowFormTO getFormForUser(@PathParam("userId") final Long userId);
 
     /**
-     * @deprecated This method needs to be moved to a new workflow service.
+     * deprecated This method needs to be moved to workflow service.
      */
-    @Deprecated
     @GET
     @Path("workflow/form")
     List<WorkflowFormTO> getForms();
@@ -102,24 +94,18 @@ public interface UserService {
             @QueryParam("size") @DefaultValue("25") final int size);
 
     /**
-     * @deprecated As of release 1.2.0, replaced by
-     *             {@link #setStatus(Long, StatusMod)}
+     * deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
      */
-    @Deprecated
     UserTO reactivate(long userId);
 
     /**
-     * @deprecated As of release 1.2.0, replaced by
-     *             {@link #setStatus(Long, StatusMod)}
+     * deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
      */
-    @Deprecated
     UserTO reactivate(long userId, String query);
 
     /**
-     * @deprecated As of release 1.2.0, replaced by
-     *             {@link #setStatus(Long, StatusMod)}
+     * deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
      */
-    @Deprecated
     UserTO reactivateByUsername(String username);
 
     @GET
@@ -130,10 +116,8 @@ public interface UserService {
     UserTO read(@MatrixParam("uname") final String username);
 
     /**
-     * @deprecated As of release 1.2.0, use {@link #read(Long)} or
-     *             {@link #read(String)} instead.
+     * deprecated As of release 1.2.0, use {@link #read(Long)} or {@link #read(String)} instead.
      */
-    @Deprecated
     UserTO readSelf();
 
     @POST
@@ -154,32 +138,25 @@ public interface UserService {
     public abstract UserTO setStatus(@PathParam("userId") final Long userId, final StatusMod statusUpdate);
 
     /**
-     * @deprecated This method needs to be moved to a new workflow service.
+     * deprecated This method needs to be moved to a new workflow service.
      */
-    @Deprecated
     @POST
     @Path("workflow/form")
     UserTO submitForm(final WorkflowFormTO form);
 
     /**
-     * @deprecated As of release 1.2.0, replaced by
-     *             {@link #setStatus(Long, StatusMod)}
+     * deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
      */
-    @Deprecated
     UserTO suspend(long userId);
 
     /**
-     * @deprecated As of release 1.2.0, replaced by
-     *             {@link #setStatus(Long, StatusMod)}
+     * deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
      */
-    @Deprecated
     UserTO suspend(long userId, String query);
 
     /**
-     * @deprecated As of release 1.2.0, replaced by
-     *             {@link #setStatus(Long, StatusMod)}
+     * deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
      */
-    @Deprecated
     UserTO suspendByUsername(String username);
 
     @POST

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/WorkflowService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/WorkflowService.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/WorkflowService.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/WorkflowService.java Thu Jan 10 10:21:14 2013
@@ -32,20 +32,15 @@ public interface WorkflowService {
 
     @GET
     @Path("{kind}")
-    //    @RequestMapping(method = RequestMethod.GET, value = "/definition/user")
-    //    @RequestMapping(method = RequestMethod.GET, value = "/definition/role")
     WorkflowDefinitionTO getDefinition(@PathParam("kind") final String kind);
 
 
 
     @PUT
     @Path("{kind}")
-//    @RequestMapping(method = RequestMethod.PUT, value = "/definition/user")
-//    @RequestMapping(method = RequestMethod.PUT, value = "/definition/role")
     void updateDefinition(@PathParam("kind") final String kind, final WorkflowDefinitionTO definition);
 
     @GET
     @Path("{kind}/tasks")
-//    @RequestMapping(method = RequestMethod.GET, value = "/tasks/user")
     List<String> getDefinedTasks(@PathParam("kind") final String kind);
 }
\ No newline at end of file

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/LoggerServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/LoggerServiceProxy.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/LoggerServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/LoggerServiceProxy.java Thu Jan 10 10:21:14 2013
@@ -46,13 +46,13 @@ public class LoggerServiceProxy extends 
     }
 
     @Override
-    public LoggerTO setLogLevel(String name, Level level) {
+    public LoggerTO update(String name, Level level) {
         return restTemplate.postForObject(baseUrl + "logger/log/{name}/{level}", null, LoggerTO.class, name,
                 level);
     }
 
     @Override
-    public LoggerTO deleteLog(String name) {
+    public LoggerTO delete(String name) {
         return restTemplate.getForObject(baseUrl + "logger/log/delete/{name}", LoggerTO.class, name);
     }
 

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SchemaServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SchemaServiceProxy.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SchemaServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SchemaServiceProxy.java Thu Jan 10 10:21:14 2013
@@ -28,67 +28,62 @@ import org.apache.syncope.client.to.Virt
 import org.apache.syncope.services.SchemaService;
 import org.springframework.web.client.RestTemplate;
 
+@SuppressWarnings("unchecked")
 public class SchemaServiceProxy extends SpringServiceProxy implements SchemaService {
 
     public SchemaServiceProxy(String baseUrl, RestTemplate restTemplate) {
         super(baseUrl, restTemplate);
     }
 
-    @SuppressWarnings("unchecked")
     @Override
-    public <T extends AbstractSchemaTO> T create(String kind, T schemaTO) {
-        String schemaType = getSchemaType(schemaTO.getClass());
-
-        return (T) restTemplate.postForObject(baseUrl + schemaType + "/{kind}/create", schemaTO,
-                schemaTO.getClass(), kind);
+    public <T extends AbstractSchemaTO> T create(String kind, SchemaType type, T schemaTO) {
+        return (T) restTemplate.postForObject(baseUrl + type + "/{kind}/create", schemaTO, getTOClass(type), kind);
     }
 
     @Override
-    public <T extends AbstractSchemaTO> T delete(String kind, String schemaName, Class<T> type) {
-        String schemaType = getSchemaType(type);
-        return restTemplate.getForObject(baseUrl + schemaType + "/{kind}/delete/{name}.json", type, kind,
+    public <T extends AbstractSchemaTO> T delete(String kind, SchemaType type, String schemaName) {
+        return (T) restTemplate.getForObject(baseUrl + type + "/{kind}/delete/{name}.json", getTOClass(type), kind,
                 schemaName);
     }
 
     @Override
-    public <T extends AbstractSchemaTO> List<T> list(String kind, Class<T[]> type) {
-        String schemaType = getSchemaTypeArray(type);
-        return Arrays.asList(restTemplate.getForObject(baseUrl + schemaType + "/{kind}/list.json", type,
-                kind));
+    public <T extends AbstractSchemaTO> List<T> list(String kind, SchemaType type) {
+        switch (type) {
+        case NORMAL:
+            return (List<T>) Arrays.asList(restTemplate.getForObject(baseUrl + type + "/{kind}/list.json",
+                    SchemaTO[].class, kind));
+        case DERIVED:
+            return (List<T>) Arrays.asList(restTemplate.getForObject(baseUrl + type + "/{kind}/list.json",
+                    DerivedSchemaTO[].class, kind));
+        case VIRTUAL:
+            return (List<T>) Arrays.asList(restTemplate.getForObject(baseUrl + type + "/{kind}/list.json",
+                    VirtualSchemaTO[].class, kind));
+        default:
+            throw new IllegalArgumentException("SchemaType is not supported.");
+        }
+    }
+
+    private Class<? extends AbstractSchemaTO> getTOClass(SchemaType type) {
+        switch (type) {
+        case NORMAL:
+            return SchemaTO.class;
+        case DERIVED:
+            return DerivedSchemaTO.class;
+        case VIRTUAL:
+            return VirtualSchemaTO.class;
+        default:
+            throw new IllegalArgumentException("SchemaType is not supported.");
+        }
     }
 
     @Override
-    public <T extends AbstractSchemaTO> T read(String kind, String schemaName, Class<T> type) {
-        String schemaType = getSchemaType(type);
-        return restTemplate.getForObject(baseUrl + schemaType + "/{kind}/read/{name}.json", type, kind,
+    public <T extends AbstractSchemaTO> T read(String kind, SchemaType type, String schemaName) {
+        return (T) restTemplate.getForObject(baseUrl + type + "/{kind}/read/{name}.json", getTOClass(type), kind,
                 schemaName);
     }
 
-    @SuppressWarnings("unchecked")
     @Override
-    public <T extends AbstractSchemaTO> T update(String kind, String schemaName, T schemaTO) {
-        String schemaType = getSchemaType(schemaTO.getClass());
-        return (T) restTemplate.postForObject(baseUrl + schemaType + "/{kind}/update", schemaTO,
-                schemaTO.getClass(), kind);
-    }
-
-    private String getSchemaType(Class<? extends AbstractSchemaTO> type) {
-        return (type.isAssignableFrom(SchemaTO.class))
-                ? "schema"
-                : (type.isAssignableFrom(DerivedSchemaTO.class))
-                        ? "derivedSchema"
-                        : (type.isAssignableFrom(VirtualSchemaTO.class))
-                                ? "virtualSchema"
-                                : "";
-    }
-
-    private <T extends AbstractSchemaTO> String getSchemaTypeArray(Class<T[]> type) {
-        return (type.isAssignableFrom(SchemaTO[].class))
-                ? "schema"
-                : (type.isAssignableFrom(DerivedSchemaTO[].class))
-                        ? "derivedSchema"
-                        : (type.isAssignableFrom(VirtualSchemaTO[].class))
-                                ? "virtualSchema"
-                                : "";
+    public <T extends AbstractSchemaTO> T update(String kind, SchemaType type, String schemaName, T schemaTO) {
+        return (T) restTemplate.postForObject(baseUrl + type + "/{kind}/update", schemaTO, getTOClass(type), kind);
     }
 }

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/types/AuditLoggerName.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/types/AuditLoggerName.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/types/AuditLoggerName.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/types/AuditLoggerName.java Thu Jan 10 10:21:14 2013
@@ -29,12 +29,14 @@ import org.codehaus.jackson.annotate.Jso
 
 public class AuditLoggerName extends AbstractBaseBean {
 
-    private Category category;
+    private static final long serialVersionUID = -647989486671786839L;
+
+    private final Category category;
 
     @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
-    private Enum<?> subcategory;
+    private final Enum<?> subcategory;
 
-    private Result result;
+    private final Result result;
 
     @JsonCreator
     public AuditLoggerName(@JsonProperty("category") final Category category,

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java Thu Jan 10 10:21:14 2013
@@ -37,6 +37,7 @@ import org.apache.syncope.client.to.Sche
 import org.apache.syncope.client.to.UserTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
 import org.apache.syncope.client.validation.SyncopeClientException;
+import org.apache.syncope.services.SchemaService;
 import org.apache.syncope.types.SchemaType;
 import org.apache.syncope.types.SyncopeClientExceptionType;
 import org.junit.FixMethodOrder;
@@ -48,395 +49,395 @@ import org.springframework.web.client.Ht
 @FixMethodOrder(MethodSorters.JVM)
 public class AuthenticationTestITCase extends AbstractTest {
 
-	@Test
-	public void testAdminEntitlements() {
-		// 1. as anonymous, read all available entitlements
-		Set<String> allEntitlements = entitlementService.getAllEntitlements();
-		assertNotNull(allEntitlements);
-		assertFalse(allEntitlements.isEmpty());
-
-		// 2. as admin, read own entitlements
-		super.resetRestTemplate();
-
-		Set<String> adminEntitlements = entitlementService.getMyEntitlements();
-
-		assertEquals(allEntitlements, adminEntitlements);
-	}
-
-	@Test
-	public void testUserSchemaAuthorization() {
-		// 0. create a role that can only read schemas
-		RoleTO authRoleTO = new RoleTO();
-		authRoleTO.setName("authRole");
-		authRoleTO.setParent(8L);
-		authRoleTO.addEntitlement("SCHEMA_READ");
-
-		authRoleTO = roleService.create(authRoleTO);
-		assertNotNull(authRoleTO);
-
-		// 1. create a schema (as admin)
-		SchemaTO schemaTO = new SchemaTO();
-		schemaTO.setName("authTestSchema");
-		schemaTO.setMandatoryCondition("false");
-		schemaTO.setType(SchemaType.String);
-
-		SchemaTO newSchemaTO = schemaService.create("user", schemaTO);
-		assertEquals(schemaTO, newSchemaTO);
-
-		// 2. create an user with the role created above (as admin)
-		UserTO userTO = UserTestITCase.getSampleTO("auth@test.org");
-
-		MembershipTO membershipTO = new MembershipTO();
-		membershipTO.setRoleId(authRoleTO.getId());
-		AttributeTO testAttributeTO = new AttributeTO();
-		testAttributeTO.setSchema("testAttribute");
-		testAttributeTO.addValue("a value");
-		membershipTO.addAttribute(testAttributeTO);
-		userTO.addMembership(membershipTO);
-
-		userTO = userService.create(userTO);
-		assertNotNull(userTO);
-
-		// 3. read the schema created above (as admin) - success
-		schemaTO = schemaService.read("user", "authTestSchema", SchemaTO.class);
-		assertNotNull(schemaTO);
-
-		// 4. read the schema created above (as user) - success
-		super.setupRestTemplate(userTO.getUsername(), "password123");
-
-		schemaTO = schemaService.read("user", "authTestSchema", SchemaTO.class);
-		assertNotNull(schemaTO);
-
-		// 5. update the schema create above (as user) - failure
-		HttpClientErrorException exception = null;
-		try {
-		    schemaService.update("role", schemaTO.getName(), schemaTO);
-		} catch (HttpClientErrorException e) {
-			exception = e;
-		}
-		assertNotNull(exception);
-		assertEquals(HttpStatus.FORBIDDEN, exception.getStatusCode());
-
-		// reset admin credentials for restTemplate
-		super.resetRestTemplate();
-
-		userTO = userService.read(userTO.getId());
-
-		assertNotNull(userTO);
-		assertNotNull(userTO.getLastLoginDate());
-		assertEquals(Integer.valueOf(0), userTO.getFailedLogins());
-	}
-
-	@Test
-	public void testUserRead() {
-		UserTO userTO = UserTestITCase.getSampleTO("testuserread@test.org");
-
-		MembershipTO membershipTO = new MembershipTO();
-		membershipTO.setRoleId(7L);
-		AttributeTO testAttributeTO = new AttributeTO();
-		testAttributeTO.setSchema("testAttribute");
-		testAttributeTO.addValue("a value");
-		membershipTO.addAttribute(testAttributeTO);
-		userTO.addMembership(membershipTO);
-
-		userTO = userService.create(userTO);
-		assertNotNull(userTO);
-
-		super.setupRestTemplate(userTO.getUsername(), "password123");
-
-		UserTO readUserTO = userService.read(1L);
-		assertNotNull(readUserTO);
-
-		super.setupRestTemplate("user2", "password");
-
-		SyncopeClientException exception = null;
-		try {
-			userService.read(1L);
-			fail();
-		} catch (SyncopeClientCompositeErrorException e) {
-			exception = e
-					.getException(SyncopeClientExceptionType.UnauthorizedRole);
-		}
-		assertNotNull(exception);
-
-		// reset admin credentials for restTemplate
-		super.resetRestTemplate();
-	}
-
-	@Test
-	public void testUserSearch() {
-		UserTO userTO = UserTestITCase.getSampleTO("testusersearch@test.org");
-
-		MembershipTO membershipTO = new MembershipTO();
-		membershipTO.setRoleId(7L);
-		AttributeTO testAttributeTO = new AttributeTO();
-		testAttributeTO.setSchema("testAttribute");
-		testAttributeTO.addValue("a value");
-		membershipTO.addAttribute(testAttributeTO);
-		userTO.addMembership(membershipTO);
-
-		userTO = userService.create(userTO);
-		assertNotNull(userTO);
-
-		super.setupRestTemplate(userTO.getUsername(), "password123");
-
-		AttributeCond isNullCond = new AttributeCond(
-				AttributeCond.Type.ISNOTNULL);
-		isNullCond.setSchema("loginDate");
-		NodeCond searchCondition = NodeCond.getLeafCond(isNullCond);
-
-		List<UserTO> matchedUsers = userService.search(searchCondition);
-		assertNotNull(matchedUsers);
-		assertFalse(matchedUsers.isEmpty());
-		Set<Long> userIds = new HashSet<Long>(matchedUsers.size());
-		for (UserTO user : matchedUsers) {
-			userIds.add(user.getId());
-		}
-		assertTrue(userIds.contains(1L));
-
-		super.setupRestTemplate("user2", "password");
-
-		matchedUsers = userService.search(searchCondition);
-
-		assertNotNull(matchedUsers);
-
-		userIds = new HashSet<Long>(matchedUsers.size());
-
-		for (UserTO user : matchedUsers) {
-			userIds.add(user.getId());
-		}
-		assertFalse(userIds.contains(1L));
-
-		// reset admin credentials for restTemplate
-		super.resetRestTemplate();
-	}
-
-	@Test
-	public void checkFailedLogins() {
-		UserTO userTO = UserTestITCase
-				.getSampleTO("checkFailedLogin@syncope.apache.org");
-
-		MembershipTO membershipTO = new MembershipTO();
-		membershipTO.setRoleId(7L);
-		AttributeTO testAttributeTO = new AttributeTO();
-		testAttributeTO.setSchema("testAttribute");
-		testAttributeTO.addValue("a value");
-		membershipTO.addAttribute(testAttributeTO);
-		userTO.addMembership(membershipTO);
-
-		userTO = userService.create(userTO);
-		assertNotNull(userTO);
-
-		super.setupRestTemplate(userTO.getUsername(), "password123");
-
-		UserTO readUserTO = userService.read(userTO.getId());
-
-		assertNotNull(readUserTO);
-		assertNotNull(readUserTO.getFailedLogins());
-		assertEquals(Integer.valueOf(0), readUserTO.getFailedLogins());
-
-		// authentications failed ...
-
-		super.setupRestTemplate(userTO.getUsername(), "wrongpwd1");
-
-		Throwable t = null;
-
-		try {
-			userService.read(userTO.getId());
-			assertNotNull(readUserTO);
-		} catch (Exception e) {
-			t = e;
-		}
-
-		assertNotNull(t);
-		t = null;
-
-		try {
-			userService.read(userTO.getId());
-			assertNotNull(readUserTO);
-		} catch (Exception e) {
-			t = e;
-		}
-
-		// reset admin credentials for restTemplate
-		super.resetRestTemplate();
-
-		readUserTO = userService.read(userTO.getId());
-		assertNotNull(readUserTO);
-		assertNotNull(readUserTO.getFailedLogins());
-		assertEquals(Integer.valueOf(2), readUserTO.getFailedLogins());
-
-		super.setupRestTemplate(userTO.getUsername(), "password123");
-
-		readUserTO = userService.read(userTO.getId());
-		assertNotNull(readUserTO);
-		assertNotNull(readUserTO.getFailedLogins());
-		assertEquals(Integer.valueOf(0), readUserTO.getFailedLogins());
-	}
-
-	@Test
-	public void checkUserSuspension() {
-		UserTO userTO = UserTestITCase
-				.getSampleTO("checkSuspension@syncope.apache.org");
-
-		MembershipTO membershipTO = new MembershipTO();
-		membershipTO.setRoleId(7L);
-		AttributeTO testAttributeTO = new AttributeTO();
-		testAttributeTO.setSchema("testAttribute");
-		testAttributeTO.addValue("a value");
-		membershipTO.addAttribute(testAttributeTO);
-		userTO.addMembership(membershipTO);
-
-		userTO = userService.create(userTO);
-		assertNotNull(userTO);
-
-		super.setupRestTemplate(userTO.getUsername(), "password123");
-
-		userTO = userService.read(userTO.getId());
-
-		assertNotNull(userTO);
-		assertNotNull(userTO.getFailedLogins());
-		assertEquals(Integer.valueOf(0), userTO.getFailedLogins());
-
-		// authentications failed ...
-
-		super.setupRestTemplate(userTO.getUsername(), "wrongpwd1");
-
-		Throwable t = null;
-
-		try {
-			userService.read(userTO.getId());
-			fail();
-		} catch (Exception e) {
-			t = e;
-		}
-
-		assertNotNull(t);
-		t = null;
-
-		try {
-			userService.read(userTO.getId());
-		} catch (Exception e) {
-			t = e;
-		}
-
-		assertNotNull(t);
-		t = null;
-
-		try {
-			userService.read(userTO.getId());
-		} catch (Exception e) {
-			t = e;
-		}
-
-		assertNotNull(t);
-		t = null;
-
-		// reset admin credentials for restTemplate
-		super.resetRestTemplate();
-
-		userTO = userService.read(userTO.getId());
-
-		assertNotNull(userTO);
-		assertNotNull(userTO.getFailedLogins());
-		assertEquals(Integer.valueOf(3), userTO.getFailedLogins());
-
-		// last authentication before suspension
-		super.setupRestTemplate(userTO.getUsername(), "wrongpwd1");
-
-		try {
-			userService.read(userTO.getId());
-		} catch (Exception e) {
-			t = e;
-		}
-
-		assertNotNull(t);
-		t = null;
-
-		// reset admin credentials for restTemplate
-		super.resetRestTemplate();
-
-		userTO = userService.read(userTO.getId());
-
-		assertNotNull(userTO);
-		assertNotNull(userTO.getFailedLogins());
-		assertEquals(Integer.valueOf(3), userTO.getFailedLogins());
-		assertEquals("suspended", userTO.getStatus());
-
-		// check for authentication
-
-		super.setupRestTemplate(userTO.getUsername(), "password123");
-
-		try {
-			userService.read(userTO.getId());
-			assertNotNull(userTO);
-		} catch (Exception e) {
-			t = e;
-		}
-
-		assertNotNull(t);
-		t = null;
-
-		// reset admin credentials for restTemplate
-		super.resetRestTemplate();
-
-		userTO = userService.reactivate(userTO.getId());
-
-		assertNotNull(userTO);
-		assertEquals("active", userTO.getStatus());
-
-		super.setupRestTemplate(userTO.getUsername(), "password123");
-
-		userTO = userService.read(userTO.getId());
-
-		assertNotNull(userTO);
-		assertEquals(Integer.valueOf(0), userTO.getFailedLogins());
-	}
-
-	@Test
-	public void issueSYNCOPE48() {
-		// Parent role, able to create users with role 1
-		RoleTO parentRole = new RoleTO();
-		parentRole.setName("parentAdminRole");
-		parentRole.addEntitlement("USER_CREATE");
-		parentRole.addEntitlement("ROLE_1");
-		parentRole.setParent(1L);
-
-		parentRole = roleService.create(parentRole);
-		assertNotNull(parentRole);
-
-		// Child role, with no entitlements
-		RoleTO childRole = new RoleTO();
-		childRole.setName("childAdminRole");
-		childRole.setParent(parentRole.getId());
-
-		childRole = roleService.create(childRole);
-		assertNotNull(childRole);
-
-		// User with child role, created by admin
-		UserTO role1Admin = UserTestITCase
-				.getSampleTO("syncope48admin@apache.org");
-		role1Admin.setPassword("password");
-		MembershipTO membershipTO = new MembershipTO();
-		membershipTO.setRoleId(childRole.getId());
-		role1Admin.addMembership(membershipTO);
-
-		role1Admin = userService.create(role1Admin);
-		assertNotNull(role1Admin);
-
-		super.setupRestTemplate(role1Admin.getUsername(), "password");
-
-		// User with role 1, created by user with child role created above
-		UserTO role1User = UserTestITCase
-				.getSampleTO("syncope48user@apache.org");
-		membershipTO = new MembershipTO();
-		membershipTO.setRoleId(1L);
-		role1User.addMembership(membershipTO);
-
-		role1User = userService.create(role1User);
-		assertNotNull(role1User);
-
-		// reset admin credentials for restTemplate
-		super.resetRestTemplate();
-	}
+    @Test
+    public void testAdminEntitlements() {
+        // 1. as anonymous, read all available entitlements
+        Set<String> allEntitlements = entitlementService.getAllEntitlements();
+        assertNotNull(allEntitlements);
+        assertFalse(allEntitlements.isEmpty());
+
+        // 2. as admin, read own entitlements
+        super.resetRestTemplate();
+
+        Set<String> adminEntitlements = entitlementService.getMyEntitlements();
+
+        assertEquals(allEntitlements, adminEntitlements);
+    }
+
+    @Test
+    public void testUserSchemaAuthorization() {
+        // 0. create a role that can only read schemas
+        RoleTO authRoleTO = new RoleTO();
+        authRoleTO.setName("authRole");
+        authRoleTO.setParent(8L);
+        authRoleTO.addEntitlement("SCHEMA_READ");
+
+        authRoleTO = roleService.create(authRoleTO);
+        assertNotNull(authRoleTO);
+
+        // 1. create a schema (as admin)
+        SchemaTO schemaTO = new SchemaTO();
+        schemaTO.setName("authTestSchema");
+        schemaTO.setMandatoryCondition("false");
+        schemaTO.setType(SchemaType.String);
+
+        SchemaTO newSchemaTO = schemaService.create("user", SchemaService.SchemaType.NORMAL, schemaTO);
+        assertEquals(schemaTO, newSchemaTO);
+
+        // 2. create an user with the role created above (as admin)
+        UserTO userTO = UserTestITCase.getSampleTO("auth@test.org");
+
+        MembershipTO membershipTO = new MembershipTO();
+        membershipTO.setRoleId(authRoleTO.getId());
+        AttributeTO testAttributeTO = new AttributeTO();
+        testAttributeTO.setSchema("testAttribute");
+        testAttributeTO.addValue("a value");
+        membershipTO.addAttribute(testAttributeTO);
+        userTO.addMembership(membershipTO);
+
+        userTO = userService.create(userTO);
+        assertNotNull(userTO);
+
+        // 3. read the schema created above (as admin) - success
+        schemaTO = schemaService.read("user", SchemaService.SchemaType.NORMAL, "authTestSchema");
+        assertNotNull(schemaTO);
+
+        // 4. read the schema created above (as user) - success
+        super.setupRestTemplate(userTO.getUsername(), "password123");
+
+        schemaTO = schemaService.read("user", SchemaService.SchemaType.NORMAL, "authTestSchema");
+        assertNotNull(schemaTO);
+
+        // 5. update the schema create above (as user) - failure
+        HttpClientErrorException exception = null;
+        try {
+            schemaService.update("role", SchemaService.SchemaType.NORMAL, schemaTO.getName(), schemaTO);
+        } catch (HttpClientErrorException e) {
+            exception = e;
+        }
+        assertNotNull(exception);
+        assertEquals(HttpStatus.FORBIDDEN, exception.getStatusCode());
+
+        // reset admin credentials for restTemplate
+        super.resetRestTemplate();
+
+        userTO = userService.read(userTO.getId());
+
+        assertNotNull(userTO);
+        assertNotNull(userTO.getLastLoginDate());
+        assertEquals(Integer.valueOf(0), userTO.getFailedLogins());
+    }
+
+    @Test
+    public void testUserRead() {
+        UserTO userTO = UserTestITCase.getSampleTO("testuserread@test.org");
+
+        MembershipTO membershipTO = new MembershipTO();
+        membershipTO.setRoleId(7L);
+        AttributeTO testAttributeTO = new AttributeTO();
+        testAttributeTO.setSchema("testAttribute");
+        testAttributeTO.addValue("a value");
+        membershipTO.addAttribute(testAttributeTO);
+        userTO.addMembership(membershipTO);
+
+        userTO = userService.create(userTO);
+        assertNotNull(userTO);
+
+        super.setupRestTemplate(userTO.getUsername(), "password123");
+
+        UserTO readUserTO = userService.read(1L);
+        assertNotNull(readUserTO);
+
+        super.setupRestTemplate("user2", "password");
+
+        SyncopeClientException exception = null;
+        try {
+            userService.read(1L);
+            fail();
+        } catch (SyncopeClientCompositeErrorException e) {
+            exception = e
+                    .getException(SyncopeClientExceptionType.UnauthorizedRole);
+        }
+        assertNotNull(exception);
+
+        // reset admin credentials for restTemplate
+        super.resetRestTemplate();
+    }
+
+    @Test
+    public void testUserSearch() {
+        UserTO userTO = UserTestITCase.getSampleTO("testusersearch@test.org");
+
+        MembershipTO membershipTO = new MembershipTO();
+        membershipTO.setRoleId(7L);
+        AttributeTO testAttributeTO = new AttributeTO();
+        testAttributeTO.setSchema("testAttribute");
+        testAttributeTO.addValue("a value");
+        membershipTO.addAttribute(testAttributeTO);
+        userTO.addMembership(membershipTO);
+
+        userTO = userService.create(userTO);
+        assertNotNull(userTO);
+
+        super.setupRestTemplate(userTO.getUsername(), "password123");
+
+        AttributeCond isNullCond = new AttributeCond(
+                AttributeCond.Type.ISNOTNULL);
+        isNullCond.setSchema("loginDate");
+        NodeCond searchCondition = NodeCond.getLeafCond(isNullCond);
+
+        List<UserTO> matchedUsers = userService.search(searchCondition);
+        assertNotNull(matchedUsers);
+        assertFalse(matchedUsers.isEmpty());
+        Set<Long> userIds = new HashSet<Long>(matchedUsers.size());
+        for (UserTO user : matchedUsers) {
+            userIds.add(user.getId());
+        }
+        assertTrue(userIds.contains(1L));
+
+        super.setupRestTemplate("user2", "password");
+
+        matchedUsers = userService.search(searchCondition);
+
+        assertNotNull(matchedUsers);
+
+        userIds = new HashSet<Long>(matchedUsers.size());
+
+        for (UserTO user : matchedUsers) {
+            userIds.add(user.getId());
+        }
+        assertFalse(userIds.contains(1L));
+
+        // reset admin credentials for restTemplate
+        super.resetRestTemplate();
+    }
+
+    @Test
+    public void checkFailedLogins() {
+        UserTO userTO = UserTestITCase
+                .getSampleTO("checkFailedLogin@syncope.apache.org");
+
+        MembershipTO membershipTO = new MembershipTO();
+        membershipTO.setRoleId(7L);
+        AttributeTO testAttributeTO = new AttributeTO();
+        testAttributeTO.setSchema("testAttribute");
+        testAttributeTO.addValue("a value");
+        membershipTO.addAttribute(testAttributeTO);
+        userTO.addMembership(membershipTO);
+
+        userTO = userService.create(userTO);
+        assertNotNull(userTO);
+
+        super.setupRestTemplate(userTO.getUsername(), "password123");
+
+        UserTO readUserTO = userService.read(userTO.getId());
+
+        assertNotNull(readUserTO);
+        assertNotNull(readUserTO.getFailedLogins());
+        assertEquals(Integer.valueOf(0), readUserTO.getFailedLogins());
+
+        // authentications failed ...
+
+        super.setupRestTemplate(userTO.getUsername(), "wrongpwd1");
+
+        Throwable t = null;
+
+        try {
+            userService.read(userTO.getId());
+            assertNotNull(readUserTO);
+        } catch (Exception e) {
+            t = e;
+        }
+
+        assertNotNull(t);
+        t = null;
+
+        try {
+            userService.read(userTO.getId());
+            assertNotNull(readUserTO);
+        } catch (Exception e) {
+            t = e;
+        }
+
+        // reset admin credentials for restTemplate
+        super.resetRestTemplate();
+
+        readUserTO = userService.read(userTO.getId());
+        assertNotNull(readUserTO);
+        assertNotNull(readUserTO.getFailedLogins());
+        assertEquals(Integer.valueOf(2), readUserTO.getFailedLogins());
+
+        super.setupRestTemplate(userTO.getUsername(), "password123");
+
+        readUserTO = userService.read(userTO.getId());
+        assertNotNull(readUserTO);
+        assertNotNull(readUserTO.getFailedLogins());
+        assertEquals(Integer.valueOf(0), readUserTO.getFailedLogins());
+    }
+
+    @Test
+    public void checkUserSuspension() {
+        UserTO userTO = UserTestITCase
+                .getSampleTO("checkSuspension@syncope.apache.org");
+
+        MembershipTO membershipTO = new MembershipTO();
+        membershipTO.setRoleId(7L);
+        AttributeTO testAttributeTO = new AttributeTO();
+        testAttributeTO.setSchema("testAttribute");
+        testAttributeTO.addValue("a value");
+        membershipTO.addAttribute(testAttributeTO);
+        userTO.addMembership(membershipTO);
+
+        userTO = userService.create(userTO);
+        assertNotNull(userTO);
+
+        super.setupRestTemplate(userTO.getUsername(), "password123");
+
+        userTO = userService.read(userTO.getId());
+
+        assertNotNull(userTO);
+        assertNotNull(userTO.getFailedLogins());
+        assertEquals(Integer.valueOf(0), userTO.getFailedLogins());
+
+        // authentications failed ...
+
+        super.setupRestTemplate(userTO.getUsername(), "wrongpwd1");
+
+        Throwable t = null;
+
+        try {
+            userService.read(userTO.getId());
+            fail();
+        } catch (Exception e) {
+            t = e;
+        }
+
+        assertNotNull(t);
+        t = null;
+
+        try {
+            userService.read(userTO.getId());
+        } catch (Exception e) {
+            t = e;
+        }
+
+        assertNotNull(t);
+        t = null;
+
+        try {
+            userService.read(userTO.getId());
+        } catch (Exception e) {
+            t = e;
+        }
+
+        assertNotNull(t);
+        t = null;
+
+        // reset admin credentials for restTemplate
+        super.resetRestTemplate();
+
+        userTO = userService.read(userTO.getId());
+
+        assertNotNull(userTO);
+        assertNotNull(userTO.getFailedLogins());
+        assertEquals(Integer.valueOf(3), userTO.getFailedLogins());
+
+        // last authentication before suspension
+        super.setupRestTemplate(userTO.getUsername(), "wrongpwd1");
+
+        try {
+            userService.read(userTO.getId());
+        } catch (Exception e) {
+            t = e;
+        }
+
+        assertNotNull(t);
+        t = null;
+
+        // reset admin credentials for restTemplate
+        super.resetRestTemplate();
+
+        userTO = userService.read(userTO.getId());
+
+        assertNotNull(userTO);
+        assertNotNull(userTO.getFailedLogins());
+        assertEquals(Integer.valueOf(3), userTO.getFailedLogins());
+        assertEquals("suspended", userTO.getStatus());
+
+        // check for authentication
+
+        super.setupRestTemplate(userTO.getUsername(), "password123");
+
+        try {
+            userService.read(userTO.getId());
+            assertNotNull(userTO);
+        } catch (Exception e) {
+            t = e;
+        }
+
+        assertNotNull(t);
+        t = null;
+
+        // reset admin credentials for restTemplate
+        super.resetRestTemplate();
+
+        userTO = userService.reactivate(userTO.getId());
+
+        assertNotNull(userTO);
+        assertEquals("active", userTO.getStatus());
+
+        super.setupRestTemplate(userTO.getUsername(), "password123");
+
+        userTO = userService.read(userTO.getId());
+
+        assertNotNull(userTO);
+        assertEquals(Integer.valueOf(0), userTO.getFailedLogins());
+    }
+
+    @Test
+    public void issueSYNCOPE48() {
+        // Parent role, able to create users with role 1
+        RoleTO parentRole = new RoleTO();
+        parentRole.setName("parentAdminRole");
+        parentRole.addEntitlement("USER_CREATE");
+        parentRole.addEntitlement("ROLE_1");
+        parentRole.setParent(1L);
+
+        parentRole = roleService.create(parentRole);
+        assertNotNull(parentRole);
+
+        // Child role, with no entitlements
+        RoleTO childRole = new RoleTO();
+        childRole.setName("childAdminRole");
+        childRole.setParent(parentRole.getId());
+
+        childRole = roleService.create(childRole);
+        assertNotNull(childRole);
+
+        // User with child role, created by admin
+        UserTO role1Admin = UserTestITCase
+                .getSampleTO("syncope48admin@apache.org");
+        role1Admin.setPassword("password");
+        MembershipTO membershipTO = new MembershipTO();
+        membershipTO.setRoleId(childRole.getId());
+        role1Admin.addMembership(membershipTO);
+
+        role1Admin = userService.create(role1Admin);
+        assertNotNull(role1Admin);
+
+        super.setupRestTemplate(role1Admin.getUsername(), "password");
+
+        // User with role 1, created by user with child role created above
+        UserTO role1User = UserTestITCase
+                .getSampleTO("syncope48user@apache.org");
+        membershipTO = new MembershipTO();
+        membershipTO.setRoleId(1L);
+        role1User.addMembership(membershipTO);
+
+        role1User = userService.create(role1User);
+        assertNotNull(role1User);
+
+        // reset admin credentials for restTemplate
+        super.resetRestTemplate();
+    }
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java Thu Jan 10 10:21:14 2013
@@ -26,6 +26,7 @@ import java.util.List;
 
 import org.apache.syncope.client.to.DerivedSchemaTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.services.SchemaService;
 import org.apache.syncope.types.SyncopeClientExceptionType;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
@@ -40,7 +41,7 @@ public class DerivedSchemaTestITCase ext
 
     @Test
     public void list() {
-        List<DerivedSchemaTO> derivedSchemas = schemaService.list(USER, DerivedSchemaTO[].class);
+        List<DerivedSchemaTO> derivedSchemas = schemaService.list(USER, SchemaService.SchemaType.DERIVED);
         assertFalse(derivedSchemas.isEmpty());
         for (DerivedSchemaTO derivedSchemaTO : derivedSchemas) {
             assertNotNull(derivedSchemaTO);
@@ -49,7 +50,7 @@ public class DerivedSchemaTestITCase ext
 
     @Test
     public void read() {
-        DerivedSchemaTO derivedSchemaTO = schemaService.read(USER, "cn", DerivedSchemaTO.class);
+        DerivedSchemaTO derivedSchemaTO = schemaService.read(USER, SchemaService.SchemaType.DERIVED, "cn");
         assertNotNull(derivedSchemaTO);
     }
 
@@ -59,25 +60,25 @@ public class DerivedSchemaTestITCase ext
         schema.setName("derived");
         schema.setExpression("derived_sx + '_' + derived_dx");
 
-        DerivedSchemaTO actual = schemaService.create(USER, schema);
+        DerivedSchemaTO actual = schemaService.create(USER, SchemaService.SchemaType.DERIVED, schema);
         assertNotNull(actual);
 
-        actual = schemaService.read(USER, actual.getName(), DerivedSchemaTO.class);
+        actual = schemaService.read(USER, SchemaService.SchemaType.DERIVED, actual.getName());
         assertNotNull(actual);
         assertEquals(actual.getExpression(), "derived_sx + '_' + derived_dx");
     }
 
     @Test
     public void delete() {
-        DerivedSchemaTO schema = schemaService.read(ROLE, "rderiveddata", DerivedSchemaTO.class);
+        DerivedSchemaTO schema = schemaService.read(ROLE, SchemaService.SchemaType.DERIVED, "rderiveddata");
         assertNotNull(schema);
 
-        DerivedSchemaTO schemaToDelete = schemaService.delete(ROLE, schema.getName(), DerivedSchemaTO.class);
+        DerivedSchemaTO schemaToDelete = schemaService.delete(ROLE, SchemaService.SchemaType.DERIVED, schema.getName());
         assertNotNull(schemaToDelete);
 
         Throwable t = null;
         try {
-            schemaService.read(ROLE, "rderiveddata", DerivedSchemaTO.class);
+            schemaService.read(ROLE, SchemaService.SchemaType.DERIVED, "rderiveddata");
         } catch (SyncopeClientCompositeErrorException e) {
             t = e;
             assertNotNull(e.getException(SyncopeClientExceptionType.NotFound));
@@ -87,16 +88,16 @@ public class DerivedSchemaTestITCase ext
 
     @Test
     public void update() {
-        DerivedSchemaTO schema = schemaService.read(MEMBERSHIP, "mderiveddata", DerivedSchemaTO.class);
+        DerivedSchemaTO schema = schemaService.read(MEMBERSHIP, SchemaService.SchemaType.DERIVED, "mderiveddata");
         assertNotNull(schema);
         assertEquals("mderived_sx + '-' + mderived_dx", schema.getExpression());
 
         schema.setExpression("mderived_sx + '.' + mderived_dx");
 
-        schema = schemaService.update(MEMBERSHIP, schema.getName(), schema);
+        schema = schemaService.update(MEMBERSHIP, SchemaService.SchemaType.DERIVED, schema.getName(), schema);
         assertNotNull(schema);
 
-        schema = schemaService.read(MEMBERSHIP, "mderiveddata", DerivedSchemaTO.class);
+        schema = schemaService.read(MEMBERSHIP, SchemaService.SchemaType.DERIVED, "mderiveddata");
         assertNotNull(schema);
         assertEquals("mderived_sx + '.' + mderived_dx", schema.getExpression());
     }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java Thu Jan 10 10:21:14 2013
@@ -65,7 +65,7 @@ public class LoggerTestITCase extends Ab
         assertNotNull(loggers);
         int startSize = loggers.size();
 
-        LoggerTO logger = loggerService.setLogLevel("TEST", Level.INFO);
+        LoggerTO logger = loggerService.update("TEST", Level.INFO);
         assertNotNull(logger);
         assertEquals(SyncopeLoggerLevel.INFO, logger.getLevel());
 
@@ -74,7 +74,7 @@ public class LoggerTestITCase extends Ab
         assertEquals(startSize + 1, loggers.size());
 
         // TEST Delete
-        loggerService.deleteLog("TEST");
+        loggerService.delete("TEST");
         loggers = loggerService.listLogs();
         assertNotNull(loggers);
         assertEquals(startSize, loggers.size());

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java Thu Jan 10 10:21:14 2013
@@ -44,7 +44,7 @@ public class PolicyTestITCase extends Ab
     @Test
     public void listByType() {
         List<SyncPolicyTO> policyTOs = policyService.listByType(PolicyType.SYNC);
-        
+
         assertNotNull(policyTOs);
         assertFalse(policyTOs.isEmpty());
     }
@@ -62,7 +62,7 @@ public class PolicyTestITCase extends Ab
 
         assertNotNull(policyTO);
         assertEquals(PolicyType.GLOBAL_PASSWORD, policyTO.getType());
-        assertEquals(8, ((PasswordPolicySpec) policyTO.getSpecification()).getMinLength());
+        assertEquals(8, policyTO.getSpecification().getMinLength());
     }
 
     @Test
@@ -134,7 +134,7 @@ public class PolicyTestITCase extends Ab
 
         assertNotNull("find to update did not work", policy);
 
-        PasswordPolicySpec policySpec = ((PasswordPolicyTO) policy).getSpecification();
+        PasswordPolicySpec policySpec = policy.getSpecification();
         policySpec.setMaxLength(22);
         policy.setSpecification(policySpec);
 
@@ -143,8 +143,8 @@ public class PolicyTestITCase extends Ab
 
         assertNotNull(policy);
         assertEquals(PolicyType.PASSWORD, policy.getType());
-        assertEquals(22, ((PasswordPolicyTO) policy).getSpecification().getMaxLength());
-        assertEquals(8, ((PasswordPolicyTO) policy).getSpecification().getMinLength());
+        assertEquals(22, policy.getSpecification().getMaxLength());
+        assertEquals(8, policy.getSpecification().getMinLength());
     }
 
     @Test
@@ -166,5 +166,5 @@ public class PolicyTestITCase extends Ab
 
         assertNotNull(t);
     }
-    
+
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java Thu Jan 10 10:21:14 2013
@@ -28,13 +28,9 @@ import static org.junit.Assert.fail;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
 import org.apache.syncope.client.mod.RoleMod;
 import org.apache.syncope.client.to.ConnObjectTO;
 import org.apache.syncope.client.to.RoleTO;
-import org.apache.syncope.client.to.SchemaTO;
 import org.apache.syncope.client.to.UserTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
 import org.apache.syncope.client.validation.SyncopeClientException;

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java Thu Jan 10 10:21:14 2013
@@ -34,6 +34,7 @@ import org.apache.syncope.client.to.User
 import org.apache.syncope.client.util.AttributableOperations;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
 import org.apache.syncope.client.validation.SyncopeClientException;
+import org.apache.syncope.services.SchemaService;
 import org.apache.syncope.types.EntityViolationType;
 import org.apache.syncope.types.SchemaType;
 import org.apache.syncope.types.SyncopeClientExceptionType;
@@ -57,10 +58,10 @@ public class SchemaTestITCase extends Ab
         schemaTO.setMandatoryCondition("false");
         schemaTO.setType(SchemaType.String);
 
-        SchemaTO newSchemaTO = schemaService.create(USER, schemaTO);
+        SchemaTO newSchemaTO = schemaService.create(USER, SchemaService.SchemaType.NORMAL, schemaTO);
         assertEquals(schemaTO, newSchemaTO);
 
-        newSchemaTO = schemaService.create(MEMBERSHIP, schemaTO);
+        newSchemaTO = schemaService.create(MEMBERSHIP, SchemaService.SchemaType.NORMAL, schemaTO);
         assertEquals(schemaTO, newSchemaTO);
     }
 
@@ -71,7 +72,7 @@ public class SchemaTestITCase extends Ab
         schemaTO.setType(SchemaType.String);
 
         try {
-            schemaService.create(USER, schemaTO);
+            schemaService.create(USER, SchemaService.SchemaType.NORMAL, schemaTO);
             fail("This should not be reacheable");
         } catch (SyncopeClientCompositeErrorException scce) {
             SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
@@ -90,7 +91,7 @@ public class SchemaTestITCase extends Ab
         schemaTO.setType(SchemaType.Enum);
 
         try {
-            schemaService.create(ROLE, schemaTO);
+            schemaService.create(ROLE, SchemaService.SchemaType.NORMAL, schemaTO);
             fail("This should not be reacheable");
         } catch (SyncopeClientCompositeErrorException scce) {
             SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidRSchema);
@@ -109,7 +110,7 @@ public class SchemaTestITCase extends Ab
         schemaTO.setType(SchemaType.Enum);
 
         try {
-            schemaService.create(USER, schemaTO);
+            schemaService.create(USER, SchemaService.SchemaType.NORMAL, schemaTO);
             fail("This should not be reacheable");
         } catch (SyncopeClientCompositeErrorException scce) {
             SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
@@ -123,11 +124,11 @@ public class SchemaTestITCase extends Ab
 
     @Test
     public void delete() {
-        SchemaTO deletedSchema = schemaService.delete(USER, "cool", SchemaTO.class);
+        SchemaTO deletedSchema = schemaService.delete(USER, SchemaService.SchemaType.NORMAL, "cool");
         assertNotNull(deletedSchema);
         SchemaTO firstname = null;
         try {
-            firstname = schemaService.read(USER, "cool", SchemaTO.class);
+            firstname = schemaService.read(USER, SchemaService.SchemaType.NORMAL, "cool");
         } catch (HttpClientErrorException e) {
             assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
         }
@@ -136,19 +137,19 @@ public class SchemaTestITCase extends Ab
 
     @Test
     public void list() {
-        List<SchemaTO> userSchemas = schemaService.list(USER, SchemaTO[].class);
+        List<SchemaTO> userSchemas = schemaService.list(USER, SchemaService.SchemaType.NORMAL);
         assertFalse(userSchemas.isEmpty());
         for (SchemaTO schemaTO : userSchemas) {
             assertNotNull(schemaTO);
         }
 
-        List<SchemaTO> roleSchemas = schemaService.list(ROLE, SchemaTO[].class);
+        List<SchemaTO> roleSchemas = schemaService.list(ROLE, SchemaService.SchemaType.NORMAL);
         assertFalse(roleSchemas.isEmpty());
         for (SchemaTO schemaTO : roleSchemas) {
             assertNotNull(schemaTO);
         }
 
-        List<SchemaTO> membershipSchemas = schemaService.list(MEMBERSHIP, SchemaTO[].class);
+        List<SchemaTO> membershipSchemas = schemaService.list(MEMBERSHIP, SchemaService.SchemaType.NORMAL);
         assertFalse(membershipSchemas.isEmpty());
         for (SchemaTO schemaTO : membershipSchemas) {
             assertNotNull(schemaTO);
@@ -157,15 +158,15 @@ public class SchemaTestITCase extends Ab
 
     @Test
     public void update() {
-        SchemaTO schemaTO = schemaService.read(ROLE, "icon", SchemaTO.class);
+        SchemaTO schemaTO = schemaService.read(ROLE, SchemaService.SchemaType.NORMAL, "icon");
         assertNotNull(schemaTO);
 
-        SchemaTO updatedTO = schemaService.update(ROLE, schemaTO.getName(), schemaTO);
+        SchemaTO updatedTO = schemaService.update(ROLE, SchemaService.SchemaType.NORMAL, schemaTO.getName(), schemaTO);
         assertEquals(schemaTO, updatedTO);
 
         updatedTO.setType(SchemaType.Date);
         try {
-            schemaService.update(ROLE, schemaTO.getName(), updatedTO);
+            schemaService.update(ROLE, SchemaService.SchemaType.NORMAL, schemaTO.getName(), updatedTO);
             fail("This should not be reacheable");
         } catch (SyncopeClientCompositeErrorException scce) {
             SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidRSchema);
@@ -179,7 +180,7 @@ public class SchemaTestITCase extends Ab
         schemaTO.setName("schema_issue258");
         schemaTO.setType(SchemaType.Double);
 
-        schemaTO = schemaService.create(USER, schemaTO);
+        schemaTO = schemaService.create(USER, SchemaService.SchemaType.NORMAL, schemaTO);
         assertNotNull(schemaTO);
 
         UserTO userTO = UserTestITCase.getSampleTO("issue258@syncope.apache.org");
@@ -190,7 +191,7 @@ public class SchemaTestITCase extends Ab
 
         schemaTO.setType(SchemaType.Long);
         try {
-            schemaService.update(USER, schemaTO.getName(), schemaTO);
+            schemaService.update(USER, SchemaService.SchemaType.NORMAL, schemaTO.getName(), schemaTO);
             fail("This should not be reacheable");
         } catch (SyncopeClientCompositeErrorException scce) {
             SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
@@ -205,7 +206,7 @@ public class SchemaTestITCase extends Ab
         schemaTO.setUniqueConstraint(true);
         schemaTO.setType(SchemaType.Long);
 
-        schemaTO = schemaService.create(USER, schemaTO);
+        schemaTO = schemaService.create(USER, SchemaService.SchemaType.NORMAL, schemaTO);
         assertNotNull(schemaTO);
 
         UserTO userTO = UserTestITCase.getSampleTO("issue259@syncope.apache.org");
@@ -231,7 +232,7 @@ public class SchemaTestITCase extends Ab
         schemaTO.setType(SchemaType.Double);
         schemaTO.setUniqueConstraint(true);
 
-        schemaTO = schemaService.create(USER, schemaTO);
+        schemaTO = schemaService.create(USER, SchemaService.SchemaType.NORMAL, schemaTO);
         assertNotNull(schemaTO);
 
         UserTO userTO = UserTestITCase.getSampleTO("issue260@syncope.apache.org");
@@ -241,7 +242,7 @@ public class SchemaTestITCase extends Ab
 
         schemaTO.setUniqueConstraint(false);
         try {
-            schemaService.update(USER, schemaTO.getName(), schemaTO);
+            schemaService.update(USER, SchemaService.SchemaType.NORMAL, schemaTO.getName(), schemaTO);
             fail("This should not be reacheable");
         } catch (SyncopeClientCompositeErrorException scce) {
             SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java?rev=1431255&r1=1431254&r2=1431255&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java Thu Jan 10 10:21:14 2013
@@ -25,6 +25,7 @@ import java.util.List;
 
 import org.apache.syncope.client.to.VirtualSchemaTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.services.SchemaService;
 import org.apache.syncope.types.SyncopeClientExceptionType;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
@@ -39,7 +40,7 @@ public class VirtualSchemaTestITCase ext
 
     @Test
     public void list() {
-        List<VirtualSchemaTO> VirtualSchemas = schemaService.list(USER, VirtualSchemaTO[].class);
+        List<VirtualSchemaTO> VirtualSchemas = schemaService.list(USER, SchemaService.SchemaType.VIRTUAL);
         assertFalse(VirtualSchemas.isEmpty());
         for (VirtualSchemaTO VirtualSchemaTO : VirtualSchemas) {
             assertNotNull(VirtualSchemaTO);
@@ -48,8 +49,7 @@ public class VirtualSchemaTestITCase ext
 
     @Test
     public void read() {
-        VirtualSchemaTO VirtualSchemaTO = schemaService.read(MEMBERSHIP, "mvirtualdata",
-                VirtualSchemaTO.class);
+        VirtualSchemaTO VirtualSchemaTO = schemaService.read(MEMBERSHIP, SchemaService.SchemaType.VIRTUAL, "mvirtualdata");
         assertNotNull(VirtualSchemaTO);
     }
 
@@ -58,24 +58,24 @@ public class VirtualSchemaTestITCase ext
         VirtualSchemaTO schema = new VirtualSchemaTO();
         schema.setName("virtual");
 
-        VirtualSchemaTO actual = schemaService.create(USER, schema);
+        VirtualSchemaTO actual = schemaService.create(USER, SchemaService.SchemaType.VIRTUAL, schema);
         assertNotNull(actual);
 
-        actual = schemaService.read(USER, actual.getName(), VirtualSchemaTO.class);
+        actual = schemaService.read(USER, SchemaService.SchemaType.VIRTUAL, actual.getName());
         assertNotNull(actual);
     }
 
     @Test
     public void delete() {
-        VirtualSchemaTO schema = schemaService.read(ROLE, "rvirtualdata", VirtualSchemaTO.class);
+        VirtualSchemaTO schema = schemaService.read(ROLE, SchemaService.SchemaType.VIRTUAL, "rvirtualdata");
         assertNotNull(schema);
 
-        VirtualSchemaTO deletedSchema = schemaService.delete(ROLE, schema.getName(), VirtualSchemaTO.class);
+        VirtualSchemaTO deletedSchema = schemaService.delete(ROLE, SchemaService.SchemaType.VIRTUAL, schema.getName());
         assertNotNull(deletedSchema);
 
         Throwable t = null;
         try {
-            schema = schemaService.read(ROLE, "rvirtualdata", VirtualSchemaTO.class);
+            schema = schemaService.read(ROLE, SchemaService.SchemaType.VIRTUAL, "rvirtualdata");
         } catch (SyncopeClientCompositeErrorException e) {
             t = e;
             assertNotNull(e.getException(SyncopeClientExceptionType.NotFound));