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/15 16:32:45 UTC

svn commit: r1433457 [1/2] - in /syncope/trunk: client/src/main/java/org/apache/syncope/services/proxy/ console/src/main/java/org/apache/syncope/console/ console/src/main/java/org/apache/syncope/console/rest/ core/src/test/java/org/apache/syncope/core/...

Author: jbernhardt
Date: Tue Jan 15 15:32:45 2013
New Revision: 1433457

URL: http://svn.apache.org/viewvc?rev=1433457&view=rev
Log:
[SYNCOPE-259]
Switching console to use Spring REST Proxies

Modified:
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConfigurationServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConnectorServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/EntitlementServiceProxy.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/NotificationServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ReportServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ResourceServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/RoleServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SchemaServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SpringServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserRequestServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/WorkflowServiceProxy.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AbstractAttributableRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AuthRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/BaseRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/LoggerRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ReportRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/TaskRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRequestRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConfigurationServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConfigurationServiceProxy.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConfigurationServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConfigurationServiceProxy.java Tue Jan 15 15:32:45 2013
@@ -26,11 +26,12 @@ import javax.ws.rs.core.Response;
 
 import org.apache.syncope.client.to.ConfigurationTO;
 import org.apache.syncope.services.ConfigurationService;
+import org.springframework.web.client.RestTemplate;
 
 public class ConfigurationServiceProxy extends SpringServiceProxy implements ConfigurationService {
 
-    public ConfigurationServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public ConfigurationServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConnectorServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConnectorServiceProxy.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConnectorServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConnectorServiceProxy.java Tue Jan 15 15:32:45 2013
@@ -25,11 +25,12 @@ import org.apache.syncope.client.to.Conn
 import org.apache.syncope.client.to.ConnInstanceTO;
 import org.apache.syncope.services.ConnectorService;
 import org.apache.syncope.types.ConnConfProperty;
+import org.springframework.web.client.RestTemplate;
 
 public class ConnectorServiceProxy extends SpringServiceProxy implements ConnectorService {
 
-    public ConnectorServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public ConnectorServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/EntitlementServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/EntitlementServiceProxy.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/EntitlementServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/EntitlementServiceProxy.java Tue Jan 15 15:32:45 2013
@@ -27,8 +27,8 @@ import org.springframework.web.client.Re
 
 public class EntitlementServiceProxy extends SpringServiceProxy implements EntitlementService {
 
-    public EntitlementServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public EntitlementServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

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=1433457&r1=1433456&r2=1433457&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 Tue Jan 15 15:32:45 2013
@@ -24,13 +24,14 @@ import java.util.List;
 import org.apache.syncope.client.to.LoggerTO;
 import org.apache.syncope.services.LoggerService;
 import org.apache.syncope.types.AuditLoggerName;
+import org.springframework.web.client.RestTemplate;
 
 import ch.qos.logback.classic.Level;
 
 public class LoggerServiceProxy extends SpringServiceProxy implements LoggerService {
 
-    public LoggerServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public LoggerServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/NotificationServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/NotificationServiceProxy.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/NotificationServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/NotificationServiceProxy.java Tue Jan 15 15:32:45 2013
@@ -23,11 +23,12 @@ import java.util.List;
 
 import org.apache.syncope.client.to.NotificationTO;
 import org.apache.syncope.services.NotificationService;
+import org.springframework.web.client.RestTemplate;
 
 public class NotificationServiceProxy extends SpringServiceProxy implements NotificationService {
 
-    public NotificationServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public NotificationServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java Tue Jan 15 15:32:45 2013
@@ -27,11 +27,12 @@ import org.apache.syncope.client.to.Poli
 import org.apache.syncope.client.to.SyncPolicyTO;
 import org.apache.syncope.services.PolicyService;
 import org.apache.syncope.types.PolicyType;
+import org.springframework.web.client.RestTemplate;
 
 public class PolicyServiceProxy extends SpringServiceProxy implements PolicyService {
 
-    public PolicyServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public PolicyServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ReportServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ReportServiceProxy.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ReportServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ReportServiceProxy.java Tue Jan 15 15:32:45 2013
@@ -25,11 +25,12 @@ import org.apache.syncope.client.to.Repo
 import org.apache.syncope.client.to.ReportTO;
 import org.apache.syncope.services.ReportService;
 import org.apache.syncope.types.ReportExecExportFormat;
+import org.springframework.web.client.RestTemplate;
 
 public class ReportServiceProxy extends SpringServiceProxy implements ReportService {
 
-    public ReportServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public ReportServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ResourceServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ResourceServiceProxy.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ResourceServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ResourceServiceProxy.java Tue Jan 15 15:32:45 2013
@@ -28,11 +28,12 @@ import org.apache.syncope.client.to.Conn
 import org.apache.syncope.client.to.ResourceTO;
 import org.apache.syncope.services.ResourceService;
 import org.apache.syncope.types.AttributableType;
+import org.springframework.web.client.RestTemplate;
 
 public class ResourceServiceProxy extends SpringServiceProxy implements ResourceService {
 
-    public ResourceServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public ResourceServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/RoleServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/RoleServiceProxy.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/RoleServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/RoleServiceProxy.java Tue Jan 15 15:32:45 2013
@@ -25,11 +25,12 @@ import org.apache.syncope.client.mod.Rol
 import org.apache.syncope.client.search.NodeCond;
 import org.apache.syncope.client.to.RoleTO;
 import org.apache.syncope.services.RoleService;
+import org.springframework.web.client.RestTemplate;
 
 public class RoleServiceProxy extends SpringServiceProxy implements RoleService {
 
-    public RoleServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public RoleServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

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=1433457&r1=1433456&r2=1433457&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 Tue Jan 15 15:32:45 2013
@@ -27,12 +27,13 @@ import org.apache.syncope.client.to.Sche
 import org.apache.syncope.client.to.VirtualSchemaTO;
 import org.apache.syncope.services.SchemaService;
 import org.apache.syncope.types.AttributableType;
+import org.springframework.web.client.RestTemplate;
 
 @SuppressWarnings("unchecked")
 public class SchemaServiceProxy extends SpringServiceProxy implements SchemaService {
 
-    public SchemaServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public SchemaServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SpringServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SpringServiceProxy.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SpringServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SpringServiceProxy.java Tue Jan 15 15:32:45 2013
@@ -24,14 +24,19 @@ public abstract class SpringServiceProxy
 
 	protected String baseUrl;
 
-	private final SpringRestTemplate callback;
+	private RestTemplate restTemplate;
 
-	public SpringServiceProxy(String baseUrl, SpringRestTemplate callback) {
+	public SpringServiceProxy(String baseUrl, RestTemplate restTemplate) {
 		this.baseUrl = baseUrl;
-		this.callback = callback;
+		this.restTemplate = restTemplate;
 	}
 
+	public void setRestTemplate(RestTemplate restTemplate) {
+        this.restTemplate = restTemplate;
+    }
+
     public RestTemplate getRestTemplate() {
-        return callback.getRestTemplate();
+        //return callback.getRestTemplate();
+        return restTemplate;
     }
 }

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java Tue Jan 15 15:32:45 2013
@@ -32,12 +32,13 @@ import org.apache.syncope.client.to.Task
 import org.apache.syncope.services.TaskService;
 import org.apache.syncope.types.PropagationTaskExecStatus;
 import org.apache.syncope.types.TaskType;
+import org.springframework.web.client.RestTemplate;
 
 @SuppressWarnings("unchecked")
 public class TaskServiceProxy extends SpringServiceProxy implements TaskService {
 
-    public TaskServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public TaskServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserRequestServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserRequestServiceProxy.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserRequestServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserRequestServiceProxy.java Tue Jan 15 15:32:45 2013
@@ -24,11 +24,12 @@ import org.apache.syncope.client.mod.Use
 import org.apache.syncope.client.to.UserRequestTO;
 import org.apache.syncope.client.to.UserTO;
 import org.apache.syncope.services.UserRequestService;
+import org.springframework.web.client.RestTemplate;
 
 public class UserRequestServiceProxy extends SpringServiceProxy implements UserRequestService {
 
-    public UserRequestServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public UserRequestServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserServiceProxy.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserServiceProxy.java Tue Jan 15 15:32:45 2013
@@ -27,11 +27,12 @@ import org.apache.syncope.client.search.
 import org.apache.syncope.client.to.UserTO;
 import org.apache.syncope.client.to.WorkflowFormTO;
 import org.apache.syncope.services.UserService;
+import org.springframework.web.client.RestTemplate;
 
 public class UserServiceProxy extends SpringServiceProxy implements UserService {
 
-    public UserServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public UserServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/WorkflowServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/WorkflowServiceProxy.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/WorkflowServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/WorkflowServiceProxy.java Tue Jan 15 15:32:45 2013
@@ -23,11 +23,12 @@ import java.util.List;
 
 import org.apache.syncope.client.to.WorkflowDefinitionTO;
 import org.apache.syncope.services.WorkflowService;
+import org.springframework.web.client.RestTemplate;
 
 public class WorkflowServiceProxy extends SpringServiceProxy implements WorkflowService {
 
-    public WorkflowServiceProxy(String baseUrl, SpringRestTemplate callback) {
-        super(baseUrl, callback);
+    public WorkflowServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
     }
 
     @Override

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java Tue Jan 15 15:32:45 2013
@@ -170,7 +170,6 @@ public class SyncopeApplication extends 
 
     @Override
     public boolean hasAnyRole(final org.apache.wicket.authroles.authorization.strategies.role.Roles roles) {
-
         return SyncopeSession.get().hasAnyRole(roles);
     }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java Tue Jan 15 15:32:45 2013
@@ -19,7 +19,38 @@
 package org.apache.syncope.console;
 
 import java.text.SimpleDateFormat;
+import java.util.HashMap;
+
 import org.apache.syncope.console.commons.Constants;
+import org.apache.syncope.services.ConfigurationService;
+import org.apache.syncope.services.ConnectorService;
+import org.apache.syncope.services.EntitlementService;
+import org.apache.syncope.services.LoggerService;
+import org.apache.syncope.services.NotificationService;
+import org.apache.syncope.services.PolicyService;
+import org.apache.syncope.services.ReportService;
+import org.apache.syncope.services.ResourceService;
+import org.apache.syncope.services.RoleService;
+import org.apache.syncope.services.SchemaService;
+import org.apache.syncope.services.TaskService;
+import org.apache.syncope.services.UserRequestService;
+import org.apache.syncope.services.UserService;
+import org.apache.syncope.services.WorkflowService;
+import org.apache.syncope.services.proxy.ConfigurationServiceProxy;
+import org.apache.syncope.services.proxy.ConnectorServiceProxy;
+import org.apache.syncope.services.proxy.EntitlementServiceProxy;
+import org.apache.syncope.services.proxy.LoggerServiceProxy;
+import org.apache.syncope.services.proxy.NotificationServiceProxy;
+import org.apache.syncope.services.proxy.PolicyServiceProxy;
+import org.apache.syncope.services.proxy.ReportServiceProxy;
+import org.apache.syncope.services.proxy.ResourceServiceProxy;
+import org.apache.syncope.services.proxy.RoleServiceProxy;
+import org.apache.syncope.services.proxy.SchemaServiceProxy;
+import org.apache.syncope.services.proxy.SpringServiceProxy;
+import org.apache.syncope.services.proxy.TaskServiceProxy;
+import org.apache.syncope.services.proxy.UserRequestServiceProxy;
+import org.apache.syncope.services.proxy.UserServiceProxy;
+import org.apache.syncope.services.proxy.WorkflowServiceProxy;
 import org.apache.wicket.Session;
 import org.apache.wicket.authroles.authorization.strategies.role.Roles;
 import org.apache.wicket.protocol.http.WebApplication;
@@ -42,7 +73,11 @@ public class SyncopeSession extends WebS
 
     private Roles roles = new Roles();
 
-    private RestTemplate restTemplate;
+    protected String baseURL;
+
+    private final RestTemplate restTemplate;
+
+    private final HashMap<Class<?>, SpringServiceProxy> services = new HashMap<Class<?>, SpringServiceProxy>();
 
     public static SyncopeSession get() {
         return (SyncopeSession) Session.get();
@@ -55,6 +90,27 @@ public class SyncopeSession extends WebS
                 WebApplicationContextUtils.getWebApplicationContext(WebApplication.get().getServletContext());
 
         restTemplate = applicationContext.getBean(RestTemplate.class);
+        baseURL = applicationContext.getBean("baseURL", String.class);
+
+        services.put(ConfigurationService.class, new ConfigurationServiceProxy(baseURL, restTemplate));
+        services.put(ConnectorService.class, new ConnectorServiceProxy(baseURL, restTemplate));
+        services.put(EntitlementService.class, new EntitlementServiceProxy(baseURL, restTemplate));
+        services.put(LoggerService.class, new LoggerServiceProxy(baseURL, restTemplate));
+        services.put(NotificationService.class, new NotificationServiceProxy(baseURL, restTemplate));
+        services.put(PolicyService.class, new PolicyServiceProxy(baseURL, restTemplate));
+        services.put(ReportService.class, new ReportServiceProxy(baseURL, restTemplate));
+        services.put(ResourceService.class, new ResourceServiceProxy(baseURL, restTemplate));
+        services.put(RoleService.class, new RoleServiceProxy(baseURL, restTemplate));
+        services.put(SchemaService.class, new SchemaServiceProxy(baseURL, restTemplate));
+        services.put(TaskService.class, new TaskServiceProxy(baseURL, restTemplate));
+        services.put(UserRequestService.class, new UserRequestServiceProxy(baseURL, restTemplate));
+        services.put(UserService.class, new UserServiceProxy(baseURL, restTemplate));
+        services.put(WorkflowService.class, new WorkflowServiceProxy(baseURL, restTemplate));
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T> T getService(Class<T> service) {
+        return (T) services.get(service);
     }
 
     public RestTemplate getRestTemplate() {

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AbstractAttributableRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AbstractAttributableRestClient.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AbstractAttributableRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AbstractAttributableRestClient.java Tue Jan 15 15:32:45 2013
@@ -25,6 +25,8 @@ import org.apache.syncope.client.to.Conn
 
 public abstract class AbstractAttributableRestClient extends BaseRestClient {
 
+    private static final long serialVersionUID = 1962529678091410544L;
+
     public abstract Integer count();
 
     public abstract List<? extends AbstractAttributableTO> list(int page, int size);

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java Tue Jan 15 15:32:45 2013
@@ -18,11 +18,10 @@
  */
 package org.apache.syncope.console.rest;
 
-import java.util.Arrays;
 import java.util.List;
-import org.apache.syncope.client.to.UserTO;
+
 import org.apache.syncope.client.to.WorkflowFormTO;
-import org.apache.syncope.console.SyncopeSession;
+import org.apache.syncope.services.UserService;
 import org.springframework.stereotype.Component;
 
 /**
@@ -31,18 +30,17 @@ import org.springframework.stereotype.Co
 @Component
 public class ApprovalRestClient extends BaseRestClient {
 
+    private static final long serialVersionUID = -4785231164900813921L;
+
     public List<WorkflowFormTO> getForms() {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "user/workflow/form/list", WorkflowFormTO[].class));
+        return getService(UserService.class).getForms();
     }
 
     public WorkflowFormTO claimForm(final String taskId) {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "user/workflow/form/claim/{taskId}", WorkflowFormTO.class, taskId);
+        return getService(UserService.class).claimForm(taskId);
     }
 
     public void submitForm(final WorkflowFormTO form) {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "user/workflow/form/submit", form, UserTO.class);
+        getService(UserService.class).submitForm(form);
     }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AuthRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AuthRestClient.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AuthRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AuthRestClient.java Tue Jan 15 15:32:45 2013
@@ -18,9 +18,10 @@
  */
 package org.apache.syncope.console.rest;
 
-import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.List;
-import org.apache.syncope.console.SyncopeSession;
+
+import org.apache.syncope.services.EntitlementService;
 import org.springframework.stereotype.Component;
 
 /**
@@ -37,8 +38,7 @@ public class AuthRestClient extends Base
      * @return List<String>
      */
     public List<String> getAllEntitlements() {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "auth/allentitlements.json", String[].class));
+        return new ArrayList<String>(getService(EntitlementService.class).getAllEntitlements());
     }
 
     /**
@@ -47,7 +47,6 @@ public class AuthRestClient extends Base
      * @return List<String>
      */
     public List<String> getOwnedEntitlements() {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "auth/entitlements.json", String[].class));
+        return new ArrayList<String>(getService(EntitlementService.class).getMyEntitlements());
     }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/BaseRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/BaseRestClient.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/BaseRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/BaseRestClient.java Tue Jan 15 15:32:45 2013
@@ -19,11 +19,12 @@
 package org.apache.syncope.console.rest;
 
 import java.io.Serializable;
+
+import org.apache.syncope.console.SyncopeSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 
-public class BaseRestClient implements Serializable {
+public abstract class BaseRestClient implements Serializable {
 
     /**
      * Logger.
@@ -32,10 +33,7 @@ public class BaseRestClient implements S
 
     private static final long serialVersionUID = 1523999867826481989L;
 
-    @Autowired
-    protected String baseURL;
-
-    protected BaseRestClient() {
-        // Empty, only to prevent direct instantiation
+    protected <T> T getService(Class<T> serviceClass) {
+        return SyncopeSession.get().getService(serviceClass);
     }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java Tue Jan 15 15:32:45 2013
@@ -18,28 +18,28 @@
  */
 package org.apache.syncope.console.rest;
 
-import java.util.Arrays;
 import java.util.List;
-import org.springframework.stereotype.Component;
+
 import org.apache.syncope.client.to.ConfigurationTO;
-import org.apache.syncope.console.SyncopeSession;
+import org.apache.syncope.services.ConfigurationService;
+import org.springframework.stereotype.Component;
 
 @Component
 public class ConfigurationRestClient extends BaseRestClient {
 
+    private static final long serialVersionUID = 7692363064029538722L;
+
     /**
      * Get all stored configurations.
      *
      * @return ConfigurationTOs
      */
     public List<ConfigurationTO> getAllConfigurations() {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "configuration/list.json", ConfigurationTO[].class));
+        return getService(ConfigurationService.class).list();
     }
 
     public ConfigurationTO readConfiguration(final String key) {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "configuration/read/{key}.json", ConfigurationTO.class, key);
+        return getService(ConfigurationService.class).read(key);
     }
 
     /**
@@ -48,8 +48,7 @@ public class ConfigurationRestClient ext
      * @param configurationTO
      */
     public void createConfiguration(ConfigurationTO configurationTO) {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "configuration/create", configurationTO, ConfigurationTO.class);
+        getService(ConfigurationService.class).create(configurationTO);
     }
 
     /**
@@ -58,15 +57,13 @@ public class ConfigurationRestClient ext
      * @param configurationTO
      */
     public void updateConfiguration(final ConfigurationTO configurationTO) {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "configuration/update", configurationTO, ConfigurationTO.class);
+        getService(ConfigurationService.class).update(configurationTO.getKey(), configurationTO);
     }
 
     /**
      * Delete a configuration by key.
      */
     public ConfigurationTO deleteConfiguration(final String key) {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "configuration/delete/{key}.json", ConfigurationTO.class, key);
+        return getService(ConfigurationService.class).delete(key);
     }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java Tue Jan 15 15:32:45 2013
@@ -19,19 +19,21 @@
 package org.apache.syncope.console.rest;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import org.springframework.beans.BeanUtils;
-import org.springframework.stereotype.Component;
+
 import org.apache.syncope.client.to.ConnBundleTO;
 import org.apache.syncope.client.to.ConnInstanceTO;
 import org.apache.syncope.client.to.ResourceTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
 import org.apache.syncope.console.SyncopeSession;
+import org.apache.syncope.services.ConnectorService;
+import org.apache.syncope.services.ResourceService;
 import org.apache.syncope.types.ConnConfProperty;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Component;
 
 /**
  * Console client for invoking Rest Connectors services.
@@ -39,25 +41,25 @@ import org.apache.syncope.types.ConnConf
 @Component
 public class ConnectorRestClient extends BaseRestClient {
 
+    private static final long serialVersionUID = -6870366819966266617L;
+
     /**
      * Get all connectors.
      *
      * @return ConnectorInstanceTOs
      */
     public List<ConnInstanceTO> getAllConnectors() {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "connector/list.json?lang=" + SyncopeSession.get().getLocale(), ConnInstanceTO[].class));
+        return getService(ConnectorService.class).list(SyncopeSession.get().getLocale().toString());
     }
 
     /**
      * Create new connector.
      *
-     * @param schemaTO
+     * @param connectorTO
      */
     public void create(final ConnInstanceTO connectorTO) {
         connectorTO.setConfiguration(filterProperties(connectorTO.getConfiguration()));
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "connector/create.json", connectorTO, ConnInstanceTO.class);
+        getService(ConnectorService.class).create(connectorTO);
     }
 
     /**
@@ -70,8 +72,7 @@ public class ConnectorRestClient extends
         ConnInstanceTO connectorTO = null;
 
         try {
-            connectorTO = SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "connector/read/" + connectorInstanceId, ConnInstanceTO.class);
+            connectorTO = getService(ConnectorService.class).read(connectorInstanceId);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While reading a connector", e);
         }
@@ -81,21 +82,18 @@ public class ConnectorRestClient extends
 
     public void update(final ConnInstanceTO connectorTO) {
         connectorTO.setConfiguration(filterProperties(connectorTO.getConfiguration()));
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "connector/update.json", connectorTO, ConnInstanceTO.class);
+        getService(ConnectorService.class).update(connectorTO.getId(), connectorTO);
     }
 
     public ConnInstanceTO delete(Long id) {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "connector/delete/{connectorId}.json", ConnInstanceTO.class, id.toString());
+        return getService(ConnectorService.class).delete(id);
     }
 
     public List<ConnBundleTO> getAllBundles() {
         List<ConnBundleTO> bundles = null;
 
         try {
-            bundles = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "connector/bundle/list?lang=" + SyncopeSession.get().getLocale(), ConnBundleTO[].class));
+            bundles = getService(ConnectorService.class).getBundles(SyncopeSession.get().getLocale().toString());
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting connector bundles", e);
         }
@@ -113,8 +111,7 @@ public class ConnectorRestClient extends
         List<ConnConfProperty> properties = null;
 
         try {
-            properties = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(baseURL
-                    + "connector/{connectorId}/configurationProperty/list", ConnConfProperty[].class, connectorId));
+            properties = getService(ConnectorService.class).getConfigurationProperties(connectorId);
 
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting connector configuration properties", e);
@@ -131,7 +128,7 @@ public class ConnectorRestClient extends
             prop.setSchema(property.getSchema());
             prop.setOverridable(property.isOverridable());
 
-            final List parsed = new ArrayList();
+            final List<Object> parsed = new ArrayList<Object>();
 
             for (Object obj : property.getValues()) {
                 if (obj != null && !obj.toString().isEmpty()) {
@@ -158,8 +155,7 @@ public class ConnectorRestClient extends
         connector.setConfiguration(filterProperties(connector.getConfiguration()));
 
         try {
-            return SyncopeSession.get().getRestTemplate().postForObject(
-                    baseURL + "connector/check.json", connector, Boolean.class);
+            return getService(ConnectorService.class).validate(connectorTO);
         } catch (Exception e) {
             LOG.error("Connector not found {}", connector, e);
             return false;
@@ -169,14 +165,13 @@ public class ConnectorRestClient extends
     /**
      * Test resource connection.
      *
-     * @param connectorTO connector.
+     * @param resourceTO
      * @return Connection status.
      */
     public Boolean check(final ResourceTO resourceTO) {
 
         try {
-            return SyncopeSession.get().getRestTemplate().postForObject(
-                    baseURL + "resource/check.json", resourceTO, Boolean.class);
+            return getService(ResourceService.class).check(resourceTO);
         } catch (Exception e) {
             LOG.error("Connector not found {}", resourceTO.getConnectorId(), e);
             return false;
@@ -187,8 +182,7 @@ public class ConnectorRestClient extends
         List<String> schemaNames = null;
 
         try {
-            schemaNames = Arrays.asList(SyncopeSession.get().getRestTemplate().postForObject(
-                    baseURL + "connector/schema/list", connectorTO, String[].class));
+            schemaNames = getService(ConnectorService.class).getSchemaNames(connectorTO.getId(), connectorTO, false);
 
             // re-order schema names list
             Collections.sort(schemaNames);

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/LoggerRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/LoggerRestClient.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/LoggerRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/LoggerRestClient.java Tue Jan 15 15:32:45 2013
@@ -18,31 +18,31 @@
  */
 package org.apache.syncope.console.rest;
 
-import java.util.Arrays;
 import java.util.EnumMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import org.springframework.stereotype.Component;
+
 import org.apache.syncope.client.to.LoggerTO;
-import org.apache.syncope.console.SyncopeSession;
+import org.apache.syncope.services.LoggerService;
 import org.apache.syncope.types.AuditElements;
 import org.apache.syncope.types.AuditElements.Category;
 import org.apache.syncope.types.AuditLoggerName;
 import org.apache.syncope.types.SyncopeLoggerLevel;
+import org.springframework.stereotype.Component;
 
 @Component
 public class LoggerRestClient extends BaseRestClient {
 
+    private static final long serialVersionUID = 4579786978763032240L;
+
     public List<LoggerTO> listLogs() {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "logger/log/list", LoggerTO[].class));
+        return getService(LoggerService.class).listLogs();
     }
 
     public List<AuditLoggerName> listAudits() {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "logger/audit/list", AuditLoggerName[].class));
+        return getService(LoggerService.class).listAudits();
     }
 
     public Map<AuditElements.Category, Set<AuditLoggerName>> listAuditsByCategory() {
@@ -59,22 +59,18 @@ public class LoggerRestClient extends Ba
     }
 
     public void setLogLevel(final String name, final SyncopeLoggerLevel level) {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "logger/log/{name}/{level}", null, LoggerTO.class, name, level);
+        getService(LoggerService.class).update(name, level.getLevel());
     }
 
     public void enableAudit(final AuditLoggerName auditLoggerName) {
-        SyncopeSession.get().getRestTemplate().put(
-                baseURL + "logger/audit/enable", auditLoggerName);
+        getService(LoggerService.class).enableAudit(auditLoggerName);
     }
 
     public LoggerTO deleteLog(final String name) {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "logger/log/delete/{name}", LoggerTO.class, name);
+        return getService(LoggerService.class).delete(name);
     }
 
     public void disableAudit(final AuditLoggerName auditLoggerName) {
-        SyncopeSession.get().getRestTemplate().put(
-                baseURL + "logger/audit/disable", auditLoggerName);
+        getService(LoggerService.class).disableAudit(auditLoggerName);
     }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java Tue Jan 15 15:32:45 2013
@@ -18,55 +18,46 @@
  */
 package org.apache.syncope.console.rest;
 
-import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.List;
+
 import org.apache.syncope.client.to.NotificationTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
-import org.apache.syncope.console.SyncopeSession;
+import org.apache.syncope.services.ConfigurationService;
+import org.apache.syncope.services.NotificationService;
+import org.apache.syncope.services.WorkflowService;
 import org.springframework.stereotype.Component;
 
 @Component
 public class NotificationRestClient extends BaseRestClient {
 
-    public List<NotificationTO> getAllNotifications()
-            throws SyncopeClientCompositeErrorException {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "notification/list.json", NotificationTO[].class));
+    private static final long serialVersionUID = 6328933265096511690L;
+
+    public List<NotificationTO> getAllNotifications() throws SyncopeClientCompositeErrorException {
+        return getService(NotificationService.class).list();
     }
 
-    public NotificationTO readNotification(final Long id)
-            throws SyncopeClientCompositeErrorException {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "notification/read/{notificationId}.json", NotificationTO.class, id);
+    public NotificationTO readNotification(final Long id) throws SyncopeClientCompositeErrorException {
+        return getService(NotificationService.class).read(id);
     }
 
-    public void createNotification(final NotificationTO notificationTO)
-            throws SyncopeClientCompositeErrorException {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "notification/create.json", notificationTO, NotificationTO.class);
+    public void createNotification(final NotificationTO notificationTO) throws SyncopeClientCompositeErrorException {
+        getService(NotificationService.class).create(notificationTO);
     }
 
-    public void updateNotification(final NotificationTO notificationTO)
-            throws SyncopeClientCompositeErrorException {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "notification/update.json", notificationTO, NotificationTO.class);
+    public void updateNotification(final NotificationTO notificationTO) throws SyncopeClientCompositeErrorException {
+        getService(NotificationService.class).update(notificationTO.getId(), notificationTO);
     }
 
-    public void deleteNotification(final Long id)
-            throws SyncopeClientCompositeErrorException {
-        SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "notification/delete/{notificationId}.json", NotificationTO.class, id);
+    public void deleteNotification(final Long id) throws SyncopeClientCompositeErrorException {
+        getService(NotificationService.class).delete(id);
     }
 
-    public List<String> getMailTemplates()
-            throws SyncopeClientCompositeErrorException {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "configuration/mailTemplates.json", String[].class));
+    public List<String> getMailTemplates() throws SyncopeClientCompositeErrorException {
+        return new ArrayList<String>(getService(ConfigurationService.class).getMailTemplates());
     }
 
-    public List<String> getEvents()
-            throws SyncopeClientCompositeErrorException {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "workflow/tasks/user.json", String[].class));
+    public List<String> getEvents() throws SyncopeClientCompositeErrorException {
+        return getService(WorkflowService.class).getDefinedTasks("user");
     }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java Tue Jan 15 15:32:45 2013
@@ -19,15 +19,15 @@
 package org.apache.syncope.console.rest;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
-import org.springframework.stereotype.Component;
+
 import org.apache.syncope.client.to.AccountPolicyTO;
 import org.apache.syncope.client.to.PasswordPolicyTO;
 import org.apache.syncope.client.to.PolicyTO;
 import org.apache.syncope.client.to.SyncPolicyTO;
-import org.apache.syncope.console.SyncopeSession;
+import org.apache.syncope.services.PolicyService;
 import org.apache.syncope.types.PolicyType;
+import org.springframework.stereotype.Component;
 
 /**
  * Console client for invoking Rest Policy services.
@@ -35,157 +35,78 @@ import org.apache.syncope.types.PolicyTy
 @Component
 public class PolicyRestClient extends BaseRestClient {
 
+    private static final long serialVersionUID = -1392090291817187902L;
+
+    @SuppressWarnings("unchecked")
     public <T extends PolicyTO> T getGlobalPolicy(final PolicyType type) {
 
         T policy = null;
 
         try {
+            policy = getService(PolicyService.class).readGlobal(type);
+        } catch (Exception e) {
+            LOG.warn("No global " + type + " policy found", e);
             switch (type) {
-                case GLOBAL_ACCOUNT:
-                    try {
-                        policy = (T) SyncopeSession.get().getRestTemplate().getForObject(
-                                baseURL + "policy/account/global/read", AccountPolicyTO.class);
-                    } catch (Exception e) {
-                        LOG.debug("No account policy found", e);
-                        policy = (T) new AccountPolicyTO();
-                    }
-                    break;
-                case GLOBAL_PASSWORD:
-                    try {
-                        policy = (T) SyncopeSession.get().getRestTemplate().getForObject(
-                                baseURL + "policy/password/global/read", PasswordPolicyTO.class);
-                    } catch (Exception e) {
-                        LOG.debug("No password policy found", e);
-                        policy = (T) new PasswordPolicyTO();
-                    }
-                    break;
-                case GLOBAL_SYNC:
-                    try {
-                        policy = (T) SyncopeSession.get().getRestTemplate().getForObject(
-                                baseURL + "policy/sync/global/read", SyncPolicyTO.class);
-                    } catch (Exception e) {
-                        LOG.debug("No password policy found", e);
-                        policy = (T) new SyncPolicyTO();
-                    }
-                    break;
-                default:
-                    throw new Exception("Invalid policy type");
+            case GLOBAL_ACCOUNT:
+                policy = (T) new AccountPolicyTO();
+                break;
+            case GLOBAL_PASSWORD:
+                policy = (T) new PasswordPolicyTO();
+                break;
+            case GLOBAL_SYNC:
+                policy = (T) new SyncPolicyTO();
+                break;
+            default:
+                LOG.warn("Invalid policy type");
             }
-        } catch (Exception ignore) {
-            LOG.error("Invalid policy type", ignore);
         }
-
         return policy;
     }
 
+    @SuppressWarnings("unchecked")
     public <T extends PolicyTO> List<T> getPolicies(final PolicyType type, final boolean includeGlobal) {
         final List<T> res = new ArrayList<T>();
-
-        T[] policies = null;
-
-        final Class reference;
-        final Class globalReference;
-        final String policy;
+        List<T> policies = new ArrayList<T>();
 
         try {
+            policies = (List<T>) getService(PolicyService.class).listByType(type);
+            res.addAll(policies);
+        } catch (Exception ignore) {
+            LOG.debug("No policy found", ignore);
+        }
 
-            switch (type) {
-                case ACCOUNT:
-                    reference = AccountPolicyTO[].class;
-                    globalReference = AccountPolicyTO.class;
-                    policy = "account";
-                    break;
-                case PASSWORD:
-                    reference = PasswordPolicyTO[].class;
-                    globalReference = PasswordPolicyTO.class;
-                    policy = "password";
-                    break;
-                case SYNC:
-                    reference = SyncPolicyTO[].class;
-                    globalReference = SyncPolicyTO.class;
-                    policy = "sync";
-                    break;
-                default:
-                    throw new Exception("Invalid policy type");
-            }
-
+        if (includeGlobal) {
             try {
-                policies = (T[]) SyncopeSession.get().getRestTemplate().getForObject(
-                        baseURL + "policy/" + policy + "/list", reference);
+                PolicyTO globalPolicy = getGlobalPolicy(type);
+                res.add(0, (T) globalPolicy);
             } catch (Exception ignore) {
-                LOG.debug("No policy found", ignore);
-            }
-
-            if (policies != null) {
-                res.addAll(Arrays.asList(policies));
+                LOG.warn("No global policy found", ignore);
             }
-
-            if (includeGlobal) {
-                PolicyTO globalPolicy = null;
-
-                try {
-                    globalPolicy = (T) SyncopeSession.get().getRestTemplate().getForObject(
-                            baseURL + "policy/" + policy + "/global/read", globalReference);
-                } catch (Exception ignore) {
-                    LOG.warn("No global policy found", ignore);
-                }
-
-                if (globalPolicy != null) {
-                    res.add(0, (T) globalPolicy);
-                }
-            }
-
-        } catch (Exception ignore) {
-            LOG.error("No policy found", ignore);
         }
 
         return res;
     }
 
-    public <T extends PolicyTO> T createPolicy(final T policy)
-            throws InvalidPolicyType {
-
-        switch (policy.getType()) {
-            case GLOBAL_ACCOUNT:
-            case ACCOUNT:
-                return (T) SyncopeSession.get().getRestTemplate().postForObject(
-                        baseURL + "policy/account/create", policy, AccountPolicyTO.class);
-            case GLOBAL_PASSWORD:
-            case PASSWORD:
-                return (T) SyncopeSession.get().getRestTemplate().postForObject(
-                        baseURL + "policy/password/create", policy,
-                        PasswordPolicyTO.class);
-            case GLOBAL_SYNC:
-            case SYNC:
-                return (T) SyncopeSession.get().getRestTemplate().postForObject(
-                        baseURL + "policy/sync/create", policy, SyncPolicyTO.class);
-            default:
-                throw new InvalidPolicyType("Invalid type " + policy.getType());
-        }
+    public <T extends PolicyTO> T createPolicy(final T policy) throws InvalidPolicyType {
+        return getService(PolicyService.class).create(policy.getType(), policy);
     }
 
-    public <T extends PolicyTO> T updatePolicy(final T policy)
-            throws InvalidPolicyType {
-
-        switch (policy.getType()) {
-            case GLOBAL_ACCOUNT:
-            case ACCOUNT:
-                return (T) SyncopeSession.get().getRestTemplate().postForObject(
-                        baseURL + "policy/account/update", policy, AccountPolicyTO.class);
-            case GLOBAL_PASSWORD:
-            case PASSWORD:
-                return (T) SyncopeSession.get().getRestTemplate().postForObject(
-                        baseURL + "policy/password/update", policy, PasswordPolicyTO.class);
-            case GLOBAL_SYNC:
-            case SYNC:
-                return (T) SyncopeSession.get().getRestTemplate().postForObject(
-                        baseURL + "policy/sync/update", policy, SyncPolicyTO.class);
-            default:
-                throw new InvalidPolicyType("Invalid type " + policy.getType());
-        }
+    public <T extends PolicyTO> T updatePolicy(final T policy) throws InvalidPolicyType {
+        return getService(PolicyService.class).update(policy.getType(), policy.getId(), policy);
     }
 
     public PolicyTO delete(final Long id, Class<? extends PolicyTO> policyClass) {
-        return SyncopeSession.get().getRestTemplate().getForObject(baseURL + "policy/delete/" + id, policyClass);
+        return getService(PolicyService.class).delete(getPolicyType(policyClass), id);
+    }
+
+    private PolicyType getPolicyType(Class<? extends PolicyTO> clazz) {
+        if (AccountPolicyTO.class.equals(clazz))
+            return PolicyType.ACCOUNT;
+        else if (PasswordPolicyTO.class.equals(clazz))
+            return PolicyType.PASSWORD;
+        else if (SyncPolicyTO.class.equals(clazz))
+            return PolicyType.SYNC;
+        else
+            throw new IllegalArgumentException("Policy Type not supported");
     }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ReportRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ReportRestClient.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ReportRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ReportRestClient.java Tue Jan 15 15:32:45 2013
@@ -18,57 +18,52 @@
  */
 package org.apache.syncope.console.rest;
 
-import java.util.Arrays;
 import java.util.List;
+
 import org.apache.syncope.client.to.ReportExecTO;
 import org.apache.syncope.client.to.ReportTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
-import org.apache.syncope.console.SyncopeSession;
+import org.apache.syncope.services.ReportService;
 import org.springframework.stereotype.Component;
 
 @Component
 public class ReportRestClient extends BaseRestClient implements ExecutionRestClient {
 
+    private static final long serialVersionUID = 1644689667998953604L;
+
     public List<String> getReportletConfClasses() {
         List<String> reportletClasses = null;
 
         try {
-            reportletClasses = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "report/reportletConfClasses.json", String[].class));
+            reportletClasses = getService(ReportService.class).getReportletConfClasses();
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting available reportlet classes", e);
         }
         return reportletClasses;
     }
-    
+
     public ReportTO read(final Long reportId) {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "report/read/{taskId}", ReportTO.class, reportId);
+        return getService(ReportService.class).read(reportId);
     }
 
     public List<ReportTO> list() {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "report/list", ReportTO[].class));
+        return getService(ReportService.class).list();
     }
 
     public List<ReportTO> list(final int page, final int size) {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "report/list/{page}/{size}.json", ReportTO[].class, page, size));
+        return getService(ReportService.class).list(page, size);
     }
 
     public int count() {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "report/count.json", Integer.class);
+        return getService(ReportService.class).count();
     }
 
     public ReportTO create(final ReportTO reportTO) {
-        return SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "report/create", reportTO, ReportTO.class);
+        return getService(ReportService.class).create(reportTO);
     }
 
     public ReportTO update(final ReportTO reportTO) {
-        return SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "report/update", reportTO, ReportTO.class);
+        return getService(ReportService.class).update(reportTO.getId(), reportTO);
     }
 
     /**
@@ -77,8 +72,7 @@ public class ReportRestClient extends Ba
      * @param reportId report to delete
      */
     public ReportTO delete(final Long reportId) {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "report/delete/{reportId}", ReportTO.class, reportId);
+        return getService(ReportService.class).delete(reportId);
     }
 
     /**
@@ -88,8 +82,7 @@ public class ReportRestClient extends Ba
      */
     @Override
     public void startExecution(final Long reportId) {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "report/execute/{reportId}", null, ReportExecTO.class, reportId);
+        getService(ReportService.class).execute(reportId);
     }
 
     /**
@@ -99,8 +92,7 @@ public class ReportRestClient extends Ba
      */
     @Override
     public void deleteExecution(final Long reportExecId) {
-        SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "report/execution/delete/{execId}", ReportExecTO.class, reportExecId);
+        getService(ReportService.class).deleteExecution(reportExecId);
     }
 
     /**
@@ -110,7 +102,6 @@ public class ReportRestClient extends Ba
      */
     @Override
     public List<ReportExecTO> listExecutions() {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "report/execution/list", ReportExecTO[].class));
+        return getService(ReportService.class).listExecutions();
     }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java Tue Jan 15 15:32:45 2013
@@ -18,11 +18,12 @@
  */
 package org.apache.syncope.console.rest;
 
-import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.List;
+
 import org.apache.syncope.client.to.ResourceTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
-import org.apache.syncope.console.SyncopeSession;
+import org.apache.syncope.services.ResourceService;
 import org.springframework.stereotype.Component;
 
 /**
@@ -31,12 +32,13 @@ import org.springframework.stereotype.Co
 @Component
 public class ResourceRestClient extends BaseRestClient {
 
+    private static final long serialVersionUID = -6898907679835668987L;
+
     public List<String> getPropagationActionsClasses() {
         List<String> actions = null;
 
         try {
-            actions = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "resource/propagationActionsClasses.json", String[].class));
+            actions = new ArrayList<String>(getService(ResourceService.class).getPropagationActionsClasses());
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting all propagation actions classes", e);
         }
@@ -47,8 +49,7 @@ public class ResourceRestClient extends 
         List<ResourceTO> resources = null;
 
         try {
-            resources = Arrays.asList(SyncopeSession.get().getRestTemplate().
-                    getForObject(baseURL + "resource/list.json", ResourceTO[].class));
+            resources = getService(ResourceService.class).list();
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While reading all resources", e);
         }
@@ -57,15 +58,14 @@ public class ResourceRestClient extends 
     }
 
     public void create(final ResourceTO resourceTO) {
-        SyncopeSession.get().getRestTemplate().postForObject(baseURL + "resource/create", resourceTO, ResourceTO.class);
+        getService(ResourceService.class).create(resourceTO);
     }
 
     public ResourceTO read(final String name) {
         ResourceTO resourceTO = null;
 
         try {
-            resourceTO = SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "resource/read/" + name + ".json", ResourceTO.class);
+            resourceTO = getService(ResourceService.class).read(name);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While reading a resource", e);
         }
@@ -73,12 +73,10 @@ public class ResourceRestClient extends 
     }
 
     public void update(final ResourceTO resourceTO) {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "resource/update.json", resourceTO, ResourceTO.class);
+        getService(ResourceService.class).update(resourceTO.getName(), resourceTO);
     }
 
     public ResourceTO delete(final String name) {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "resource/delete/{resourceName}.json", ResourceTO.class, name);
+        return getService(ResourceService.class).delete(name);
     }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java Tue Jan 15 15:32:45 2013
@@ -18,14 +18,16 @@
  */
 package org.apache.syncope.console.rest;
 
-import java.util.Arrays;
 import java.util.List;
+
 import org.apache.syncope.client.mod.RoleMod;
 import org.apache.syncope.client.search.NodeCond;
 import org.apache.syncope.client.to.ConnObjectTO;
 import org.apache.syncope.client.to.RoleTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
-import org.apache.syncope.console.SyncopeSession;
+import org.apache.syncope.services.ResourceService;
+import org.apache.syncope.services.RoleService;
+import org.apache.syncope.types.AttributableType;
 import org.springframework.stereotype.Component;
 
 /**
@@ -34,62 +36,53 @@ import org.springframework.stereotype.Co
 @Component
 public class RoleRestClient extends AbstractAttributableRestClient {
 
+    private static final long serialVersionUID = -8549081557283519638L;
+
     @Override
     public Integer count() {
-        return SyncopeSession.get().getRestTemplate().getForObject(baseURL + "role/count.json", Integer.class);
+        return getService(RoleService.class).count();
     }
 
     public List<RoleTO> list() {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "role/list.json", RoleTO[].class));
+        return getService(RoleService.class).list();
     }
 
     @Override
     public List<RoleTO> list(final int page, final int size) {
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "role/list.json", RoleTO[].class, page, size));
+        return getService(RoleService.class).list(page, size);
     }
 
     @Override
     public Integer searchCount(final NodeCond searchCond) {
-        return SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "role/search/count.json", searchCond, Integer.class);
+        return getService(RoleService.class).searchCount(searchCond);
     }
 
     @Override
     public List<RoleTO> search(final NodeCond searchCond, final int page, final int size)
             throws SyncopeClientCompositeErrorException {
-
-        return Arrays.asList(SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "role/search/{page}/{size}", searchCond, RoleTO[].class, page, size));
+        return getService(RoleService.class).search(searchCond, page, size);
     }
 
     @Override
     public ConnObjectTO getRemoteObject(final String resourceName, final String objectId)
             throws SyncopeClientCompositeErrorException {
-
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "/resource/{resourceName}/read/ROLE/{objectId}.json",
-                ConnObjectTO.class, resourceName, objectId);
+        return getService(ResourceService.class).getConnector(resourceName, AttributableType.ROLE, objectId);
     }
 
     public RoleTO create(final RoleTO roleTO) {
-        return SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "role/create", roleTO, RoleTO.class);
+        return getService(RoleService.class).create(roleTO);
     }
 
     public RoleTO read(final Long id) {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "role/read/{roleId}.json", RoleTO.class, id);
+        return getService(RoleService.class).read(id);
     }
 
     public RoleTO update(final RoleMod roleMod) {
-        return SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "role/update", roleMod, RoleTO.class);
+        return getService(RoleService.class).update(roleMod.getId(), roleMod);
     }
 
     @Override
     public RoleTO delete(final Long id) {
-        return SyncopeSession.get().getRestTemplate().getForObject(baseURL + "role/delete/{roleId}", RoleTO.class, id);
+        return getService(RoleService.class).delete(id);
     }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java?rev=1433457&r1=1433456&r2=1433457&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java Tue Jan 15 15:32:45 2013
@@ -19,15 +19,17 @@
 package org.apache.syncope.console.rest;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
-import org.springframework.stereotype.Component;
+
 import org.apache.syncope.client.to.DerivedSchemaTO;
 import org.apache.syncope.client.to.SchemaTO;
 import org.apache.syncope.client.to.VirtualSchemaTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
-import org.apache.syncope.console.SyncopeSession;
+import org.apache.syncope.services.ConfigurationService;
+import org.apache.syncope.services.SchemaService;
+import org.apache.syncope.services.SchemaService.SchemaType;
 import org.apache.syncope.types.AttributableType;
+import org.springframework.stereotype.Component;
 
 /**
  * Console client for invoking rest schema services.
@@ -35,6 +37,8 @@ import org.apache.syncope.types.Attribut
 @Component
 public class SchemaRestClient extends BaseRestClient {
 
+    private static final long serialVersionUID = -2479730152700312373L;
+
     /**
      * Get schemas.
      *
@@ -44,8 +48,7 @@ public class SchemaRestClient extends Ba
         List<SchemaTO> schemas = null;
 
         try {
-            schemas = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "schema/" + type.name().toLowerCase() + "/list.json", SchemaTO[].class));
+            schemas = getService(SchemaService.class).list(type, SchemaType.NORMAL);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting all schemas", e);
         }
@@ -62,9 +65,7 @@ public class SchemaRestClient extends Ba
         final List<String> schemaNames = new ArrayList<String>();
 
         try {
-            final List<SchemaTO> schemas = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "schema/" + type.name().toLowerCase() + "/list.json", SchemaTO[].class));
-
+            final List<SchemaTO> schemas = getService(SchemaService.class).list(type, SchemaType.NORMAL);
             for (SchemaTO schemaTO : schemas) {
                 schemaNames.add(schemaTO.getName());
             }
@@ -85,8 +86,7 @@ public class SchemaRestClient extends Ba
         List<DerivedSchemaTO> userDerivedSchemas = null;
 
         try {
-            userDerivedSchemas = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "derivedSchema/" + type.name().toLowerCase() + "/list.json", DerivedSchemaTO[].class));
+            userDerivedSchemas = getService(SchemaService.class).list(type, SchemaType.DERIVED);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting all user derived schemas", e);
         }
@@ -104,9 +104,7 @@ public class SchemaRestClient extends Ba
         final List<String> userDerivedSchemasNames = new ArrayList<String>();
 
         try {
-            final List<DerivedSchemaTO> userDerivedSchemas =
-                    Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "derivedSchema/" + type.name().toLowerCase() + "/list.json", DerivedSchemaTO[].class));
+            final List<DerivedSchemaTO> userDerivedSchemas = getService(SchemaService.class).list(type, SchemaType.DERIVED);
 
             for (DerivedSchemaTO schemaTO : userDerivedSchemas) {
                 userDerivedSchemasNames.add(schemaTO.getName());
@@ -128,8 +126,7 @@ public class SchemaRestClient extends Ba
         List<VirtualSchemaTO> userVirtualSchemas = null;
 
         try {
-            userVirtualSchemas = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "virtualSchema/" + type.name().toLowerCase() + "/list.json", VirtualSchemaTO[].class));
+            userVirtualSchemas = getService(SchemaService.class).list(type, SchemaType.VIRTUAL);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting all user derived schemas", e);
         }
@@ -146,10 +143,7 @@ public class SchemaRestClient extends Ba
         final List<String> userVirtualSchemasNames = new ArrayList<String>();
 
         try {
-            final List<VirtualSchemaTO> userVirtualSchemas =
-                    Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "virtualSchema/" + type.name().toLowerCase() + "/list.json", VirtualSchemaTO[].class));
-
+            final List<VirtualSchemaTO> userVirtualSchemas = getService(SchemaService.class).list(type, SchemaType.VIRTUAL);
             for (VirtualSchemaTO schemaTO : userVirtualSchemas) {
                 userVirtualSchemasNames.add(schemaTO.getName());
             }
@@ -166,8 +160,7 @@ public class SchemaRestClient extends Ba
      * @param schemaTO
      */
     public void createSchema(final AttributableType type, final SchemaTO schemaTO) {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "schema/" + type.name().toLowerCase() + "/create", schemaTO, SchemaTO.class);
+        getService(SchemaService.class).create(type, SchemaType.NORMAL, schemaTO);
     }
 
     /**
@@ -180,8 +173,7 @@ public class SchemaRestClient extends Ba
         SchemaTO schema = null;
 
         try {
-            schema = SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "schema/" + type.name().toLowerCase() + "/read/" + name + ".json", SchemaTO.class);
+            schema = getService(SchemaService.class).read(type, SchemaType.NORMAL, name);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While reading a user schema", e);
         }
@@ -194,8 +186,7 @@ public class SchemaRestClient extends Ba
      * @param schemaTO updated
      */
     public void updateSchema(final AttributableType type, SchemaTO schemaTO) {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "schema/" + type.name().toLowerCase() + "/update", schemaTO, SchemaTO.class);
+        getService(SchemaService.class).update(type, SchemaType.NORMAL, schemaTO.getName(), schemaTO);
     }
 
     /**
@@ -205,8 +196,7 @@ public class SchemaRestClient extends Ba
      * @return schemaTO
      */
     public SchemaTO deleteSchema(final AttributableType type, String name) {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "schema/" + type.name().toLowerCase() + "/delete/" + name + ".json", SchemaTO.class);
+        return getService(SchemaService.class).delete(type, SchemaType.NORMAL, name);
     }
 
     /**
@@ -215,8 +205,7 @@ public class SchemaRestClient extends Ba
      * @param schemaTO
      */
     public void createDerivedSchema(final AttributableType type, final DerivedSchemaTO schemaTO) {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "derivedSchema/" + type.name().toLowerCase() + "/create", schemaTO, DerivedSchemaTO.class);
+        getService(SchemaService.class).create(type, SchemaType.DERIVED, schemaTO);
     }
 
     /**
@@ -225,8 +214,7 @@ public class SchemaRestClient extends Ba
      * @param schemaTO
      */
     public void createVirtualSchema(final AttributableType type, final VirtualSchemaTO schemaTO) {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "virtualSchema/" + type.name().toLowerCase() + "/create", schemaTO, VirtualSchemaTO.class);
+        getService(SchemaService.class).create(type, SchemaType.VIRTUAL, schemaTO);
     }
 
     /**
@@ -238,9 +226,7 @@ public class SchemaRestClient extends Ba
     public DerivedSchemaTO readDerivedSchema(final AttributableType type, final String name) {
         DerivedSchemaTO derivedSchemaTO = null;
         try {
-            derivedSchemaTO = SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "derivedSchema/" + type.name().toLowerCase() + "/read/" + name + ".json",
-                    DerivedSchemaTO.class);
+            derivedSchemaTO = getService(SchemaService.class).read(type, SchemaType.DERIVED, name);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While reading a derived user schema", e);
         }
@@ -253,8 +239,7 @@ public class SchemaRestClient extends Ba
      * @param schemaTO updated
      */
     public void updateDerivedSchema(final AttributableType type, final DerivedSchemaTO schemaTO) {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "derivedSchema/" + type.name().toLowerCase() + "/update", schemaTO, DerivedSchemaTO.class);
+        getService(SchemaService.class).update(type, SchemaType.DERIVED, schemaTO.getName(), schemaTO);
     }
 
     /**
@@ -263,8 +248,7 @@ public class SchemaRestClient extends Ba
      * @param schemaTO updated
      */
     public void updateVirtualSchema(final AttributableType type, final VirtualSchemaTO schemaTO) {
-        SyncopeSession.get().getRestTemplate().postForObject(
-                baseURL + "virtualSchema/" + type.name().toLowerCase() + "/update", schemaTO, VirtualSchemaTO.class);
+        getService(SchemaService.class).update(type, SchemaType.VIRTUAL, schemaTO.getName(), schemaTO);
     }
 
     /**
@@ -273,9 +257,7 @@ public class SchemaRestClient extends Ba
      * @param name (e.g.:surname)
      */
     public DerivedSchemaTO deleteDerivedSchema(final AttributableType type, String name) {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "derivedSchema/" + type.name().toLowerCase() + "/delete/" + name + ".json",
-                DerivedSchemaTO.class);
+        return getService(SchemaService.class).delete(type, SchemaType.DERIVED, name);
     }
 
     /**
@@ -284,9 +266,7 @@ public class SchemaRestClient extends Ba
      * @param name (e.g.:surname)
      */
     public VirtualSchemaTO deleteVirtualSchema(final AttributableType type, final String name) {
-        return SyncopeSession.get().getRestTemplate().getForObject(
-                baseURL + "virtualSchema/" + type.name().toLowerCase() + "/delete/" + name + ".json",
-                VirtualSchemaTO.class);
+        return getService(SchemaService.class).delete(type, SchemaType.VIRTUAL, name);
     }
 
     /**
@@ -296,8 +276,7 @@ public class SchemaRestClient extends Ba
         List<String> validators = null;
 
         try {
-            validators = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
-                    baseURL + "configuration/validators.json", String[].class));
+            validators = new ArrayList<String>(getService(ConfigurationService.class).getValidators());
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting all validators", e);
         }