You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by fm...@apache.org on 2012/06/21 10:24:35 UTC

svn commit: r1352448 [1/2] - in /incubator/syncope/trunk/console/src/main: java/org/apache/syncope/console/ java/org/apache/syncope/console/commons/ java/org/apache/syncope/console/pages/ java/org/apache/syncope/console/rest/ resources/

Author: fmartelli
Date: Thu Jun 21 08:24:33 2012
New Revision: 1352448

URL: http://svn.apache.org/viewvc?rev=1352448&view=rev
Log:
SYNCOPE-97 #comment RestTemplate and HttpClientFactory with scope prototype

Modified:
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/HttpResourceStream.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Configuration.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Logout.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportModalPage.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/WelcomePage.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AbstractBaseRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/EntitlementRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/LoggerRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ReportRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/TaskRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRequestRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java
    incubator/syncope/trunk/console/src/main/resources/applicationContext.xml

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java Thu Jun 21 08:24:33 2012
@@ -18,6 +18,18 @@
  */
 package org.apache.syncope.console;
 
+import org.apache.syncope.console.commons.XMLRolesReader;
+import org.apache.syncope.console.pages.Configuration;
+import org.apache.syncope.console.pages.Login;
+import org.apache.syncope.console.pages.Logout;
+import org.apache.syncope.console.pages.Reports;
+import org.apache.syncope.console.pages.Resources;
+import org.apache.syncope.console.pages.Roles;
+import org.apache.syncope.console.pages.Schema;
+import org.apache.syncope.console.pages.Tasks;
+import org.apache.syncope.console.pages.Todo;
+import org.apache.syncope.console.pages.Users;
+import org.apache.syncope.console.pages.WelcomePage;
 import org.apache.wicket.Component;
 import org.apache.wicket.Page;
 import org.apache.wicket.RestartResponseAtInterceptPageException;
@@ -36,18 +48,9 @@ import org.apache.wicket.request.Request
 import org.apache.wicket.request.Response;
 import org.apache.wicket.request.resource.ContextRelativeResource;
 import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
-import org.apache.syncope.console.commons.XMLRolesReader;
-import org.apache.syncope.console.pages.Configuration;
-import org.apache.syncope.console.pages.Login;
-import org.apache.syncope.console.pages.Logout;
-import org.apache.syncope.console.pages.Reports;
-import org.apache.syncope.console.pages.Resources;
-import org.apache.syncope.console.pages.Roles;
-import org.apache.syncope.console.pages.Schema;
-import org.apache.syncope.console.pages.Tasks;
-import org.apache.syncope.console.pages.Todo;
-import org.apache.syncope.console.pages.Users;
-import org.apache.syncope.console.pages.WelcomePage;
+import org.springframework.context.ApplicationContext;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.context.support.WebApplicationContextUtils;
 
 /**
  * SyncopeApplication class.
@@ -75,7 +78,7 @@ public class SyncopeApplication extends 
         getRequestCycleListeners().add(new SyncopeRequestCycleListener());
     }
 
-    public void setupNavigationPane(final WebPage page, final XMLRolesReader xmlRolesReader, final boolean notsel,
+    public void setupNavigationPanel(final WebPage page, final XMLRolesReader xmlRolesReader, final boolean notsel,
             final String version) {
 
         page.add(new Label("version", "Console: " + version + "; Core: " + SyncopeSession.get().getCoreVersion()));
@@ -151,9 +154,7 @@ public class SyncopeApplication extends 
 
     @Override
     public Class getHomePage() {
-        return SyncopeSession.get().isAuthenticated()
-                ? WelcomePage.class
-                : Login.class;
+        return SyncopeSession.get().isAuthenticated() ? WelcomePage.class : Login.class;
     }
 
     @Override

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java Thu Jun 21 08:24:33 2012
@@ -19,11 +19,15 @@
 package org.apache.syncope.console;
 
 import java.text.SimpleDateFormat;
+import org.apache.syncope.console.commons.Constants;
 import org.apache.wicket.Session;
 import org.apache.wicket.authroles.authorization.strategies.role.Roles;
+import org.apache.wicket.protocol.http.WebApplication;
 import org.apache.wicket.protocol.http.WebSession;
 import org.apache.wicket.request.Request;
-import org.apache.syncope.console.commons.Constants;
+import org.springframework.context.ApplicationContext;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.context.support.WebApplicationContextUtils;
 
 /**
  * Custom Syncope Session class.
@@ -38,12 +42,23 @@ public class SyncopeSession extends WebS
 
     private Roles roles = new Roles();
 
+    private RestTemplate restTemplate;
+
     public static SyncopeSession get() {
         return (SyncopeSession) Session.get();
     }
 
     public SyncopeSession(final Request request) {
         super(request);
+
+        final ApplicationContext applicationContext =
+                WebApplicationContextUtils.getWebApplicationContext(WebApplication.get().getServletContext());
+
+        restTemplate = applicationContext.getBean(RestTemplate.class);
+    }
+
+    public RestTemplate getRestTemplate() {
+        return restTemplate;
     }
 
     public String getUserId() {

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/HttpResourceStream.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/HttpResourceStream.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/HttpResourceStream.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/HttpResourceStream.java Thu Jun 21 08:24:33 2012
@@ -31,6 +31,7 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.entity.BasicHttpEntity;
 import org.apache.http.message.BasicHttpResponse;
 import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
+import org.apache.syncope.console.SyncopeSession;
 import org.apache.wicket.util.lang.Args;
 import org.apache.wicket.util.resource.AbstractResourceStream;
 import org.apache.wicket.util.resource.IFixedLocationResourceStream;
@@ -38,7 +39,6 @@ import org.apache.wicket.util.resource.R
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.http.MediaType;
-import org.springframework.web.client.RestTemplate;
 
 public class HttpResourceStream extends AbstractResourceStream implements IFixedLocationResourceStream {
 
@@ -48,18 +48,15 @@ public class HttpResourceStream extends 
 
     private final URI uri;
 
-    private final RestTemplate restTemplate;
-
     private transient HttpEntity responseEntity;
 
     private transient String contentType;
 
     private transient String filename;
 
-    public HttpResourceStream(final String uri, final RestTemplate restTemplate) throws URISyntaxException {
-
+    public HttpResourceStream(final String uri)
+            throws URISyntaxException {
         this.uri = new URI(Args.notNull(uri, "uri"));
-        this.restTemplate = Args.notNull(restTemplate, "restTemplate");
     }
 
     private HttpResponse buildFakeResponse(final String errorMessage) {
@@ -85,9 +82,10 @@ public class HttpResourceStream extends 
 
         HttpGet getMethod = new HttpGet(this.uri);
         HttpResponse response;
+
         try {
-            response = ((PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory()).getHttpClient().execute(
-                    getMethod);
+            response = ((PreemptiveAuthHttpRequestFactory) SyncopeSession.get().getRestTemplate().getRequestFactory()).
+                    getHttpClient().execute(getMethod);
         } catch (Exception e) {
             LOG.error("Unexpected exception while executing HTTP method to {}", this.uri, e);
             response = buildFakeResponse(e.getMessage());
@@ -114,7 +112,8 @@ public class HttpResourceStream extends 
     }
 
     @Override
-    public InputStream getInputStream() throws ResourceStreamNotFoundException {
+    public InputStream getInputStream()
+            throws ResourceStreamNotFoundException {
 
         try {
             execute();
@@ -125,7 +124,8 @@ public class HttpResourceStream extends 
     }
 
     @Override
-    public void close() throws IOException {
+    public void close()
+            throws IOException {
         // Nothing needed here, because we are using HttpComponents HttpClient
     }
 

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java Thu Jun 21 08:24:33 2012
@@ -96,7 +96,7 @@ public class BasePage extends WebPage im
     }
 
     private void pageSetup() {
-        ((SyncopeApplication) getApplication()).setupNavigationPane(this, xmlRolesReader, true, version);
+        ((SyncopeApplication) getApplication()).setupNavigationPanel(this, xmlRolesReader, true, version);
 
         feedbackPanel = new FeedbackPanel("feedback");
         feedbackPanel.setOutputMarkupId(true);

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Configuration.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Configuration.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Configuration.java Thu Jun 21 08:24:33 2012
@@ -60,7 +60,6 @@ import org.apache.wicket.request.mapper.
 import org.apache.wicket.request.resource.ContentDisposition;
 import org.apache.wicket.spring.injection.annot.SpringBean;
 import org.slf4j.LoggerFactory;
-import org.springframework.web.client.RestTemplate;
 import org.apache.syncope.client.to.ConfigurationTO;
 import org.apache.syncope.client.to.LoggerTO;
 import org.apache.syncope.client.to.NotificationTO;
@@ -99,9 +98,6 @@ public class Configuration extends BaseP
     @SpringBean
     private WorkflowRestClient wfRestClient;
 
-    @SpringBean
-    private RestTemplate restTemplate;
-
     @SpringBean(name = "baseURL")
     protected String baseURL;
 
@@ -341,12 +337,10 @@ public class Configuration extends BaseP
             @Override
             public void onClick() {
                 try {
-                    HttpResourceStream stream = new HttpResourceStream(baseURL + "configuration/dbexport", restTemplate);
+                    HttpResourceStream stream = new HttpResourceStream(baseURL + "configuration/dbexport");
 
                     ResourceStreamRequestHandler rsrh = new ResourceStreamRequestHandler(stream);
-                    rsrh.setFileName(stream.getFilename() == null
-                            ? "content.xml"
-                            : stream.getFilename());
+                    rsrh.setFileName(stream.getFilename() == null ? "content.xml" : stream.getFilename());
                     rsrh.setContentDisposition(ContentDisposition.ATTACHMENT);
 
                     getRequestCycle().scheduleRequestHandlerAfterCurrent(rsrh);

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java Thu Jun 21 08:24:33 2012
@@ -72,9 +72,6 @@ public class Login extends WebPage {
 
     private final static int SELF_REG_WIN_WIDTH = 800;
 
-    @SpringBean
-    private RestTemplate restTemplate;
-
     @SpringBean(name = "baseURL")
     private String baseURL;
 
@@ -119,9 +116,9 @@ public class Login extends WebPage {
                     setResponsePage(WelcomePage.class, parameters);
                 } catch (HttpClientErrorException e) {
                     error(getString("login-error"));
-                    
-                    PreemptiveAuthHttpRequestFactory requestFactory =
-                            ((PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory());
+
+                    PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) SyncopeSession.
+                            get().getRestTemplate().getRequestFactory());
 
                     ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().clear();
                 }
@@ -178,6 +175,8 @@ public class Login extends WebPage {
     }
 
     private String[] authenticate(final String userId, final String password) {
+        final RestTemplate restTemplate = SyncopeSession.get().getRestTemplate();
+
         // 1. Set provided credentials to check
         PreemptiveAuthHttpRequestFactory requestFactory =
                 ((PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory());
@@ -192,6 +191,7 @@ public class Login extends WebPage {
     private boolean isSelfRegistrationAllowed() {
         Boolean result = null;
         try {
+            final RestTemplate restTemplate = SyncopeSession.get().getRestTemplate();
             result = restTemplate.getForObject(baseURL + "user/request/create/allowed", Boolean.class);
         } catch (HttpClientErrorException e) {
             LOG.error("While seeking if self registration is allowed", e);
@@ -203,6 +203,8 @@ public class Login extends WebPage {
     }
 
     private String getCoreVersion() {
+        final RestTemplate restTemplate = SyncopeSession.get().getRestTemplate();
+
         PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate.
                 getRequestFactory());
 

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Logout.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Logout.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Logout.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Logout.java Thu Jun 21 08:24:33 2012
@@ -22,8 +22,6 @@ import org.apache.http.impl.client.Defau
 import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
 import org.apache.syncope.console.SyncopeSession;
-import org.apache.wicket.spring.injection.annot.SpringBean;
-import org.springframework.web.client.RestTemplate;
 
 /**
  * Syncope Logout.
@@ -32,9 +30,6 @@ public class Logout extends BasePage {
 
     private static final long serialVersionUID = -2143007520243939450L;
 
-    @SpringBean
-    private RestTemplate restTemplate;
-
     public Logout(final PageParameters parameters) {
         super(parameters);
 
@@ -46,7 +41,7 @@ public class Logout extends BasePage {
         setResponsePage(getApplication().getHomePage());
 
         PreemptiveAuthHttpRequestFactory requestFactory =
-                ((PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory());
+                ((PreemptiveAuthHttpRequestFactory) SyncopeSession.get().getRestTemplate().getRequestFactory());
 
         ((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().clear();
     }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportModalPage.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportModalPage.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportModalPage.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportModalPage.java Thu Jun 21 08:24:33 2012
@@ -57,7 +57,6 @@ import org.apache.wicket.model.ResourceM
 import org.apache.wicket.spring.injection.annot.SpringBean;
 import org.apache.wicket.util.resource.IResourceStream;
 import org.springframework.util.StringUtils;
-import org.springframework.web.client.RestTemplate;
 import org.apache.syncope.console.commons.DateFormatROModel;
 import org.apache.syncope.console.commons.HttpResourceStream;
 import org.apache.syncope.console.commons.SortableDataProviderComparator;
@@ -91,9 +90,6 @@ public class ReportModalPage extends Bas
     @SpringBean
     private ReportRestClient restClient;
 
-    @SpringBean
-    protected RestTemplate restTemplate;
-
     @SpringBean(name = "baseURL")
     protected String baseURL;
 
@@ -296,8 +292,8 @@ public class ReportModalPage extends Bas
                     public Page createPage() {
                         modalReportletConfOldName = null;
                         modalReportletConf = null;
-                        return new ReportletConfModalPage(null, reportletConfWin, ReportModalPage.this
-                                .getPageReference());
+                        return new ReportletConfModalPage(null, reportletConfWin,
+                                ReportModalPage.this.getPageReference());
                     }
                 });
                 reportletConfWin.show(target);
@@ -432,8 +428,8 @@ public class ReportModalPage extends Bas
                             @Override
                             public Page createPage() {
                                 ReportModalPage.this.exportExecId = model.getObject().getId();
-                                return new ReportExecResultDownloadModalPage(reportExecExportWin, ReportModalPage.this
-                                        .getPageReference());
+                                return new ReportExecResultDownloadModalPage(reportExecExportWin, ReportModalPage.this.
+                                        getPageReference());
                             }
                         });
                         reportExecExportWin.show(target);
@@ -553,7 +549,7 @@ public class ReportModalPage extends Bas
             this.url = urlBuilder.toString();
 
             try {
-                stream = new HttpResourceStream(this.url, restTemplate);
+                stream = new HttpResourceStream(this.url);
             } catch (Exception e) {
                 LOG.error("While contacting target URL", e);
             }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/WelcomePage.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/WelcomePage.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/WelcomePage.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/WelcomePage.java Thu Jun 21 08:24:33 2012
@@ -40,6 +40,6 @@ public class WelcomePage extends WebPage
     public WelcomePage(final PageParameters parameters) {
         super(parameters);
 
-        ((SyncopeApplication) getApplication()).setupNavigationPane(this, xmlRolesReader, false, version);
+        ((SyncopeApplication) getApplication()).setupNavigationPanel(this, xmlRolesReader, false, version);
     }
 }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AbstractBaseRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AbstractBaseRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AbstractBaseRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AbstractBaseRestClient.java Thu Jun 21 08:24:33 2012
@@ -21,7 +21,6 @@ package org.apache.syncope.console.rest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.client.RestTemplate;
 
 public abstract class AbstractBaseRestClient {
 
@@ -31,9 +30,5 @@ public abstract class AbstractBaseRestCl
     protected static final Logger LOG = LoggerFactory.getLogger(AbstractBaseRestClient.class);
 
     @Autowired
-    protected RestTemplate restTemplate;
-
-    @Autowired
     protected String baseURL;
-
 }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java Thu Jun 21 08:24:33 2012
@@ -23,6 +23,7 @@ import java.util.List;
 import org.springframework.stereotype.Component;
 import org.apache.syncope.client.to.UserTO;
 import org.apache.syncope.client.to.WorkflowFormTO;
+import org.apache.syncope.console.SyncopeSession;
 
 /**
  * Console client for invoking Rest Todo services.
@@ -31,14 +32,17 @@ import org.apache.syncope.client.to.Work
 public class ApprovalRestClient extends AbstractBaseRestClient {
 
     public List<WorkflowFormTO> getForms() {
-        return Arrays.asList(restTemplate.getForObject(baseURL + "user/workflow/form/list", WorkflowFormTO[].class));
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "user/workflow/form/list", WorkflowFormTO[].class));
     }
 
     public WorkflowFormTO claimForm(final String taskId) {
-        return restTemplate.getForObject(baseURL + "user/workflow/form/claim/{taskId}", WorkflowFormTO.class, taskId);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "user/workflow/form/claim/{taskId}", WorkflowFormTO.class, taskId);
     }
 
     public void submitForm(final WorkflowFormTO form) {
-        restTemplate.postForObject(baseURL + "user/workflow/form/submit", form, UserTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "user/workflow/form/submit", form, UserTO.class);
     }
 }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java Thu Jun 21 08:24:33 2012
@@ -22,6 +22,7 @@ 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;
 
 @Component
 public class ConfigurationRestClient extends AbstractBaseRestClient {
@@ -32,11 +33,13 @@ public class ConfigurationRestClient ext
      * @return ConfigurationTOs
      */
     public List<ConfigurationTO> getAllConfigurations() {
-        return Arrays.asList(restTemplate.getForObject(baseURL + "configuration/list.json", ConfigurationTO[].class));
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "configuration/list.json", ConfigurationTO[].class));
     }
 
     public ConfigurationTO readConfiguration(final String key) {
-        return restTemplate.getForObject(baseURL + "configuration/read/{key}.json", ConfigurationTO.class, key);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "configuration/read/{key}.json", ConfigurationTO.class, key);
     }
 
     /**
@@ -45,7 +48,8 @@ public class ConfigurationRestClient ext
      * @param configurationTO
      */
     public void createConfiguration(ConfigurationTO configurationTO) {
-        restTemplate.postForObject(baseURL + "configuration/create", configurationTO, ConfigurationTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "configuration/create", configurationTO, ConfigurationTO.class);
     }
 
     /**
@@ -54,13 +58,15 @@ public class ConfigurationRestClient ext
      * @param configurationTO
      */
     public void updateConfiguration(final ConfigurationTO configurationTO) {
-        restTemplate.postForObject(baseURL + "configuration/update", configurationTO, ConfigurationTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "configuration/update", configurationTO, ConfigurationTO.class);
     }
 
     /**
      * Delete a configuration by key.
      */
     public ConfigurationTO deleteConfiguration(final String key) {
-        return restTemplate.getForObject(baseURL + "configuration/delete/{key}.json", ConfigurationTO.class, key);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "configuration/delete/{key}.json", ConfigurationTO.class, key);
     }
 }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java Thu Jun 21 08:24:33 2012
@@ -44,8 +44,8 @@ public class ConnectorRestClient extends
      * @return ConnectorInstanceTOs
      */
     public List<ConnInstanceTO> getAllConnectors() {
-        return Arrays.asList(restTemplate.getForObject(baseURL + "connector/list.json?lang="
-                + SyncopeSession.get().getLocale(), ConnInstanceTO[].class));
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "connector/list.json?lang=" + SyncopeSession.get().getLocale(), ConnInstanceTO[].class));
     }
 
     /**
@@ -55,7 +55,8 @@ public class ConnectorRestClient extends
      */
     public void create(final ConnInstanceTO connectorTO) {
         connectorTO.setConfiguration(filterProperties(connectorTO.getConfiguration()));
-        restTemplate.postForObject(baseURL + "connector/create.json", connectorTO, ConnInstanceTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "connector/create.json", connectorTO, ConnInstanceTO.class);
     }
 
     /**
@@ -68,8 +69,8 @@ public class ConnectorRestClient extends
         ConnInstanceTO connectorTO = null;
 
         try {
-            connectorTO = restTemplate.getForObject(baseURL + "connector/read/" + connectorInstanceId,
-                    ConnInstanceTO.class);
+            connectorTO = SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "connector/read/" + connectorInstanceId, ConnInstanceTO.class);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While reading a connector", e);
         }
@@ -79,20 +80,21 @@ public class ConnectorRestClient extends
 
     public void update(final ConnInstanceTO connectorTO) {
         connectorTO.setConfiguration(filterProperties(connectorTO.getConfiguration()));
-        restTemplate.postForObject(baseURL + "connector/update.json", connectorTO, ConnInstanceTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "connector/update.json", connectorTO, ConnInstanceTO.class);
     }
 
     public ConnInstanceTO delete(Long id) {
-        return restTemplate.getForObject(baseURL + "connector/delete/{connectorId}.json",
-                ConnInstanceTO.class, id.toString());
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "connector/delete/{connectorId}.json", ConnInstanceTO.class, id.toString());
     }
 
     public List<ConnBundleTO> getAllBundles() {
         List<ConnBundleTO> bundles = null;
 
         try {
-            bundles = Arrays.asList(restTemplate.getForObject(baseURL + "connector/bundle/list?lang="
-                    + SyncopeSession.get().getLocale(), ConnBundleTO[].class));
+            bundles = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "connector/bundle/list?lang=" + SyncopeSession.get().getLocale(), ConnBundleTO[].class));
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting connector bundles", e);
         }
@@ -110,7 +112,7 @@ public class ConnectorRestClient extends
         List<ConnConfProperty> properties = null;
 
         try {
-            properties = Arrays.asList(restTemplate.getForObject(baseURL
+            properties = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(baseURL
                     + "connector/{connectorId}/configurationProperty/list", ConnConfProperty[].class, connectorId));
 
         } catch (SyncopeClientCompositeErrorException e) {
@@ -155,7 +157,8 @@ public class ConnectorRestClient extends
         connector.setConfiguration(filterProperties(connector.getConfiguration()));
 
         try {
-            return restTemplate.postForObject(baseURL + "connector/check.json", connector, Boolean.class);
+            return SyncopeSession.get().getRestTemplate().postForObject(
+                    baseURL + "connector/check.json", connector, Boolean.class);
         } catch (Exception e) {
             LOG.error("Connector not found {}", connector, e);
             return false;
@@ -166,8 +169,8 @@ public class ConnectorRestClient extends
         List<String> schemaNames = null;
 
         try {
-            schemaNames = Arrays.asList(restTemplate.postForObject(baseURL + "connector/schema/list", connectorTO,
-                    String[].class));
+            schemaNames = Arrays.asList(SyncopeSession.get().getRestTemplate().postForObject(
+                    baseURL + "connector/schema/list", connectorTO, String[].class));
 
             // re-order schema names list
             Collections.sort(schemaNames);

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/EntitlementRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/EntitlementRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/EntitlementRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/EntitlementRestClient.java Thu Jun 21 08:24:33 2012
@@ -22,6 +22,7 @@ import java.util.Arrays;
 import java.util.List;
 import org.springframework.stereotype.Component;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.console.SyncopeSession;
 
 /**
  * Console client for invoking Rest Resources services.
@@ -31,14 +32,15 @@ public class EntitlementRestClient exten
 
     /**
      * Get all Entitlements.
+     *
      * @return List<String>
      */
     public List<String> getAllEntitlements() {
         List<String> entitlements = null;
 
         try {
-            entitlements = Arrays.asList(restTemplate.getForObject(baseURL + "auth/allentitlements.json",
-                    String[].class));
+            entitlements = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "auth/allentitlements.json", String[].class));
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While reading all the entitlements", e);
         }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/LoggerRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/LoggerRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/LoggerRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/LoggerRestClient.java Thu Jun 21 08:24:33 2012
@@ -26,6 +26,7 @@ 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.types.AuditElements;
 import org.apache.syncope.types.AuditElements.Category;
 import org.apache.syncope.types.AuditLoggerName;
@@ -35,11 +36,13 @@ import org.apache.syncope.types.SyncopeL
 public class LoggerRestClient extends AbstractBaseRestClient {
 
     public List<LoggerTO> listLogs() {
-        return Arrays.asList(restTemplate.getForObject(baseURL + "logger/log/list", LoggerTO[].class));
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "logger/log/list", LoggerTO[].class));
     }
 
     public List<AuditLoggerName> listAudits() {
-        return Arrays.asList(restTemplate.getForObject(baseURL + "logger/audit/list", AuditLoggerName[].class));
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "logger/audit/list", AuditLoggerName[].class));
     }
 
     public Map<AuditElements.Category, Set<AuditLoggerName>> listAuditsByCategory() {
@@ -56,18 +59,22 @@ public class LoggerRestClient extends Ab
     }
 
     public void setLogLevel(final String name, final SyncopeLoggerLevel level) {
-        restTemplate.postForObject(baseURL + "logger/log/{name}/{level}", null, LoggerTO.class, name, level);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "logger/log/{name}/{level}", null, LoggerTO.class, name, level);
     }
 
     public void enableAudit(final AuditLoggerName auditLoggerName) {
-        restTemplate.put(baseURL + "logger/audit/enable", auditLoggerName);
+        SyncopeSession.get().getRestTemplate().put(
+                baseURL + "logger/audit/enable", auditLoggerName);
     }
 
     public LoggerTO deleteLog(final String name) {
-        return restTemplate.getForObject(baseURL + "logger/log/delete/{name}", LoggerTO.class, name);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "logger/log/delete/{name}", LoggerTO.class, name);
     }
 
     public void disableAudit(final AuditLoggerName auditLoggerName) {
-        restTemplate.put(baseURL + "logger/audit/disable", auditLoggerName);
+        SyncopeSession.get().getRestTemplate().put(
+                baseURL + "logger/audit/disable", auditLoggerName);
     }
 }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java Thu Jun 21 08:24:33 2012
@@ -22,43 +22,51 @@ import java.util.Arrays;
 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.springframework.stereotype.Component;
 
 @Component
 public class NotificationRestClient extends AbstractBaseRestClient {
 
-    public List<NotificationTO> getAllNotifications() throws SyncopeClientCompositeErrorException {
-
-        return Arrays.asList(restTemplate.getForObject(baseURL + "notification/list.json", NotificationTO[].class));
+    public List<NotificationTO> getAllNotifications()
+            throws SyncopeClientCompositeErrorException {
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "notification/list.json", NotificationTO[].class));
     }
 
-    public NotificationTO readNotification(final Long id) throws SyncopeClientCompositeErrorException {
-
-        return restTemplate.getForObject(baseURL + "notification/read/{notificationId}.json", NotificationTO.class, id);
+    public NotificationTO readNotification(final Long id)
+            throws SyncopeClientCompositeErrorException {
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "notification/read/{notificationId}.json", NotificationTO.class, id);
     }
 
-    public void createNotification(final NotificationTO notificationTO) throws SyncopeClientCompositeErrorException {
-
-        restTemplate.postForObject(baseURL + "notification/create.json", notificationTO, NotificationTO.class);
+    public void createNotification(final NotificationTO notificationTO)
+            throws SyncopeClientCompositeErrorException {
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "notification/create.json", notificationTO, NotificationTO.class);
     }
 
-    public void updateNotification(final NotificationTO notificationTO) throws SyncopeClientCompositeErrorException {
-
-        restTemplate.postForObject(baseURL + "notification/update.json", notificationTO, NotificationTO.class);
+    public void updateNotification(final NotificationTO notificationTO)
+            throws SyncopeClientCompositeErrorException {
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "notification/update.json", notificationTO, NotificationTO.class);
     }
 
-    public void deleteNotification(final Long id) throws SyncopeClientCompositeErrorException {
-
-        restTemplate.getForObject(baseURL + "notification/delete/{notificationId}.json", NotificationTO.class, id);
+    public void deleteNotification(final Long id)
+            throws SyncopeClientCompositeErrorException {
+        SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "notification/delete/{notificationId}.json", NotificationTO.class, id);
     }
 
-    public List<String> getMailTemplates() throws SyncopeClientCompositeErrorException {
-
-        return Arrays.asList(restTemplate.getForObject(baseURL + "configuration/mailTemplates.json", String[].class));
+    public List<String> getMailTemplates()
+            throws SyncopeClientCompositeErrorException {
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "configuration/mailTemplates.json", String[].class));
     }
 
-    public List<String> getEvents() throws SyncopeClientCompositeErrorException {
-
-        return Arrays.asList(restTemplate.getForObject(baseURL + "workflow/tasks.json", String[].class));
+    public List<String> getEvents()
+            throws SyncopeClientCompositeErrorException {
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "workflow/tasks.json", String[].class));
     }
 }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/PolicyRestClient.java Thu Jun 21 08:24:33 2012
@@ -26,6 +26,7 @@ import org.apache.syncope.client.to.Acco
 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.types.PolicyType;
 
 /**
@@ -43,8 +44,8 @@ public class PolicyRestClient extends Ab
             switch (type) {
                 case GLOBAL_ACCOUNT:
                     try {
-                        policy = (T) restTemplate.getForObject(baseURL + "policy/account/global/read",
-                                AccountPolicyTO.class);
+                        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();
@@ -52,8 +53,8 @@ public class PolicyRestClient extends Ab
                     break;
                 case GLOBAL_PASSWORD:
                     try {
-                        policy = (T) restTemplate.getForObject(baseURL + "policy/password/global/read",
-                                PasswordPolicyTO.class);
+                        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();
@@ -61,7 +62,8 @@ public class PolicyRestClient extends Ab
                     break;
                 case GLOBAL_SYNC:
                     try {
-                        policy = (T) restTemplate.getForObject(baseURL + "policy/sync/global/read", SyncPolicyTO.class);
+                        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();
@@ -110,7 +112,8 @@ public class PolicyRestClient extends Ab
             }
 
             try {
-                policies = (T[]) restTemplate.getForObject(baseURL + "policy/" + policy + "/list", reference);
+                policies = (T[]) SyncopeSession.get().getRestTemplate().getForObject(
+                        baseURL + "policy/" + policy + "/list", reference);
             } catch (Exception ignore) {
                 LOG.debug("No policy found", ignore);
             }
@@ -122,8 +125,8 @@ public class PolicyRestClient extends Ab
             PolicyTO globalPolicy = null;
 
             try {
-                globalPolicy = (T) restTemplate.getForObject(baseURL + "policy/" + policy + "/global/read",
-                        globalReference);
+                globalPolicy = (T) SyncopeSession.get().getRestTemplate().getForObject(
+                        baseURL + "policy/" + policy + "/global/read", globalReference);
             } catch (Exception ignore) {
                 LOG.warn("No global policy found", ignore);
             }
@@ -139,43 +142,50 @@ public class PolicyRestClient extends Ab
         return res;
     }
 
-    public <T extends PolicyTO> T createPolicy(final T policy) throws InvalidPolicyType {
+    public <T extends PolicyTO> T createPolicy(final T policy)
+            throws InvalidPolicyType {
 
         switch (policy.getType()) {
             case GLOBAL_ACCOUNT:
             case ACCOUNT:
-                return (T) restTemplate.postForObject(baseURL + "policy/account/create", policy, AccountPolicyTO.class);
+                return (T) SyncopeSession.get().getRestTemplate().postForObject(
+                        baseURL + "policy/account/create", policy, AccountPolicyTO.class);
             case GLOBAL_PASSWORD:
             case PASSWORD:
-                return (T) restTemplate.postForObject(baseURL + "policy/password/create", policy,
+                return (T) SyncopeSession.get().getRestTemplate().postForObject(
+                        baseURL + "policy/password/create", policy,
                         PasswordPolicyTO.class);
             case GLOBAL_SYNC:
             case SYNC:
-                return (T) restTemplate.postForObject(baseURL + "policy/sync/create", policy, SyncPolicyTO.class);
+                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 updatePolicy(final T policy) throws InvalidPolicyType {
+    public <T extends PolicyTO> T updatePolicy(final T policy)
+            throws InvalidPolicyType {
 
         switch (policy.getType()) {
             case GLOBAL_ACCOUNT:
             case ACCOUNT:
-                return (T) restTemplate.postForObject(baseURL + "policy/account/update", policy, AccountPolicyTO.class);
+                return (T) SyncopeSession.get().getRestTemplate().postForObject(
+                        baseURL + "policy/account/update", policy, AccountPolicyTO.class);
             case GLOBAL_PASSWORD:
             case PASSWORD:
-                return (T) restTemplate.postForObject(baseURL + "policy/password/update", policy,
-                        PasswordPolicyTO.class);
+                return (T) SyncopeSession.get().getRestTemplate().postForObject(
+                        baseURL + "policy/password/update", policy, PasswordPolicyTO.class);
             case GLOBAL_SYNC:
             case SYNC:
-                return (T) restTemplate.postForObject(baseURL + "policy/sync/update", policy, SyncPolicyTO.class);
+                return (T) SyncopeSession.get().getRestTemplate().postForObject(
+                        baseURL + "policy/sync/update", policy, SyncPolicyTO.class);
             default:
                 throw new InvalidPolicyType("Invalid type " + policy.getType());
         }
     }
 
     public PolicyTO delete(final Long id, Class<? extends PolicyTO> policyClass) {
-        return restTemplate.getForObject(baseURL + "policy/delete/" + id, policyClass);
+        return SyncopeSession.get().getRestTemplate().getForObject(baseURL + "policy/delete/" + id, policyClass);
     }
 }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ReportRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ReportRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ReportRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ReportRestClient.java Thu Jun 21 08:24:33 2012
@@ -23,6 +23,7 @@ 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.springframework.stereotype.Component;
 
 @Component
@@ -32,8 +33,8 @@ public class ReportRestClient extends Ab
         List<String> reportletClasses = null;
 
         try {
-            reportletClasses = Arrays.asList(restTemplate.getForObject(baseURL + "report/reportletConfClasses.json",
-                    String[].class));
+            reportletClasses = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "report/reportletConfClasses.json", String[].class));
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting available reportlet classes", e);
         }
@@ -41,24 +42,28 @@ public class ReportRestClient extends Ab
     }
 
     public List<ReportTO> list() {
-        return Arrays.asList(restTemplate.getForObject(baseURL + "report/list", ReportTO[].class));
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "report/list", ReportTO[].class));
     }
 
     public List<ReportTO> list(final int page, final int size) {
-        return Arrays.asList(restTemplate.getForObject(baseURL + "report/list/{page}/{size}.json", ReportTO[].class,
-                page, size));
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "report/list/{page}/{size}.json", ReportTO[].class, page, size));
     }
 
     public int count() {
-        return restTemplate.getForObject(baseURL + "report/count.json", Integer.class);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "report/count.json", Integer.class);
     }
 
     public ReportTO create(final ReportTO reportTO) {
-        return restTemplate.postForObject(baseURL + "report/create", reportTO, ReportTO.class);
+        return SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "report/create", reportTO, ReportTO.class);
     }
 
     public ReportTO update(final ReportTO reportTO) {
-        return restTemplate.postForObject(baseURL + "report/update", reportTO, ReportTO.class);
+        return SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "report/update", reportTO, ReportTO.class);
     }
 
     /**
@@ -67,7 +72,8 @@ public class ReportRestClient extends Ab
      * @param reportId report to delete
      */
     public ReportTO delete(final Long reportId) {
-        return restTemplate.getForObject(baseURL + "report/delete/{reportId}", ReportTO.class, reportId);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "report/delete/{reportId}", ReportTO.class, reportId);
     }
 
     /**
@@ -77,7 +83,8 @@ public class ReportRestClient extends Ab
      */
     @Override
     public void startExecution(final Long reportId) {
-        restTemplate.postForObject(baseURL + "report/execute/{reportId}", null, ReportExecTO.class, reportId);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "report/execute/{reportId}", null, ReportExecTO.class, reportId);
     }
 
     /**
@@ -87,7 +94,8 @@ public class ReportRestClient extends Ab
      */
     @Override
     public void deleteExecution(final Long reportExecId) {
-        restTemplate.getForObject(baseURL + "report/execution/delete/{execId}", ReportExecTO.class, reportExecId);
+        SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "report/execution/delete/{execId}", ReportExecTO.class, reportExecId);
     }
 
     /**
@@ -97,6 +105,7 @@ public class ReportRestClient extends Ab
      */
     @Override
     public List<ReportExecTO> listExecutions() {
-        return Arrays.asList(restTemplate.getForObject(baseURL + "report/execution/list", ReportExecTO[].class));
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "report/execution/list", ReportExecTO[].class));
     }
 }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java Thu Jun 21 08:24:33 2012
@@ -23,6 +23,7 @@ import java.util.List;
 import org.springframework.stereotype.Component;
 import org.apache.syncope.client.to.ResourceTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.console.SyncopeSession;
 
 /**
  * Console client for invoking Rest Resources services.
@@ -34,7 +35,8 @@ public class ResourceRestClient extends 
         List<ResourceTO> resources = null;
 
         try {
-            resources = Arrays.asList(restTemplate.getForObject(baseURL + "resource/list.json", ResourceTO[].class));
+            resources = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject
+                    (baseURL + "resource/list.json", ResourceTO[].class));
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While reading all resources", e);
         }
@@ -43,14 +45,15 @@ public class ResourceRestClient extends 
     }
 
     public void create(final ResourceTO resourceTO) {
-        restTemplate.postForObject(baseURL + "resource/create", resourceTO, ResourceTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(baseURL + "resource/create", resourceTO, ResourceTO.class);
     }
 
     public ResourceTO read(final String name) {
         ResourceTO resourceTO = null;
 
         try {
-            resourceTO = restTemplate.getForObject(baseURL + "resource/read/" + name + ".json", ResourceTO.class);
+            resourceTO = SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "resource/read/" + name + ".json", ResourceTO.class);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While reading a resource", e);
         }
@@ -58,11 +61,12 @@ public class ResourceRestClient extends 
     }
 
     public void update(final ResourceTO resourceTO) {
-        restTemplate.postForObject(baseURL + "resource/update.json", resourceTO, ResourceTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "resource/update.json", resourceTO, ResourceTO.class);
     }
 
     public ResourceTO delete(final String name) {
-        return restTemplate.getForObject(baseURL + "resource/delete/{resourceName}.json", 
-                                         ResourceTO.class, name);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "resource/delete/{resourceName}.json", ResourceTO.class, name);
     }
 }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/RoleRestClient.java Thu Jun 21 08:24:33 2012
@@ -23,6 +23,7 @@ import java.util.List;
 import org.apache.syncope.client.mod.RoleMod;
 import org.apache.syncope.client.to.RoleTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.console.SyncopeSession;
 import org.springframework.stereotype.Component;
 
 /**
@@ -33,14 +34,17 @@ public class RoleRestClient extends Abst
 
     /**
      * Get all Roles.
+     *
      * @return SchemaTOs
      */
-    public List<RoleTO> getAllRoles() throws SyncopeClientCompositeErrorException {
+    public List<RoleTO> getAllRoles()
+            throws SyncopeClientCompositeErrorException {
 
         List<RoleTO> roles = null;
 
         try {
-            roles = Arrays.asList(restTemplate.getForObject(baseURL + "role/list.json", RoleTO[].class));
+            roles = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "role/list.json", RoleTO[].class));
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While listing all roles", e);
         }
@@ -50,14 +54,17 @@ public class RoleRestClient extends Abst
 
     /**
      * Create new role.
+     *
      * @param roleTO
      */
     public void createRole(RoleTO roleTO) {
-        restTemplate.postForObject(baseURL + "role/create", roleTO, RoleTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "role/create", roleTO, RoleTO.class);
     }
 
     /**
      * Load an already existent role by its name.
+     *
      * @param name (e.g.:surname)
      * @return schemaTO
      */
@@ -65,7 +72,8 @@ public class RoleRestClient extends Abst
         RoleTO roleTO = null;
 
         try {
-            roleTO = restTemplate.getForObject(baseURL + "role/read/{roleId}.json", RoleTO.class, id);
+            roleTO = SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "role/read/{roleId}.json", RoleTO.class, id);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While reading a role", e);
         }
@@ -74,19 +82,23 @@ public class RoleRestClient extends Abst
 
     /**
      * Update an already existent role.
+     *
      * @param roleTO updated
      * @return true is the operation ends successfully, false otherwise
      */
     public void updateRole(RoleMod roleMod) {
-        restTemplate.postForObject(baseURL + "role/update", roleMod, RoleTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "role/update", roleMod, RoleTO.class);
     }
 
     /**
      * Delete an already existent role by its id.
+     *
      * @param name (e.g.:rolename)
      * @return roleTO
      */
     public RoleTO deleteRole(Long id) {
-        return restTemplate.getForObject(baseURL + "role/delete/{roleId}.json", RoleTO.class, id);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "role/delete/{roleId}.json", RoleTO.class, id);
     }
 }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java Thu Jun 21 08:24:33 2012
@@ -26,6 +26,7 @@ import org.apache.syncope.client.to.Deri
 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.types.AttributableType;
 
 /**
@@ -43,8 +44,8 @@ public class SchemaRestClient extends Ab
         List<SchemaTO> schemas = null;
 
         try {
-            schemas = Arrays.asList(restTemplate.getForObject(baseURL + "schema/" + type.name().toLowerCase()
-                    + "/list.json", SchemaTO[].class));
+            schemas = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "schema/" + type.name().toLowerCase() + "/list.json", SchemaTO[].class));
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting all schemas", e);
         }
@@ -61,8 +62,8 @@ public class SchemaRestClient extends Ab
         final List<String> schemaNames = new ArrayList<String>();
 
         try {
-            final List<SchemaTO> userSchemas = Arrays.asList(restTemplate.getForObject(baseURL + "schema/"
-                    + type.name().toLowerCase() + "/list.json", SchemaTO[].class));
+            final List<SchemaTO> userSchemas = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "schema/" + type.name().toLowerCase() + "/list.json", SchemaTO[].class));
 
             for (SchemaTO schemaTO : userSchemas) {
                 schemaNames.add(schemaTO.getName());
@@ -84,8 +85,8 @@ public class SchemaRestClient extends Ab
         List<DerivedSchemaTO> userDerivedSchemas = null;
 
         try {
-            userDerivedSchemas = Arrays.asList(restTemplate.getForObject(baseURL + "derivedSchema/"
-                    + type.name().toLowerCase() + "/list.json", DerivedSchemaTO[].class));
+            userDerivedSchemas = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "derivedSchema/" + type.name().toLowerCase() + "/list.json", DerivedSchemaTO[].class));
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting all user derived schemas", e);
         }
@@ -103,8 +104,9 @@ public class SchemaRestClient extends Ab
         final List<String> userDerivedSchemasNames = new ArrayList<String>();
 
         try {
-            final List<DerivedSchemaTO> userDerivedSchemas = Arrays.asList(restTemplate.getForObject(baseURL
-                    + "derivedSchema/" + type.name().toLowerCase() + "/list.json", DerivedSchemaTO[].class));
+            final List<DerivedSchemaTO> userDerivedSchemas =
+                    Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "derivedSchema/" + type.name().toLowerCase() + "/list.json", DerivedSchemaTO[].class));
 
             for (DerivedSchemaTO schemaTO : userDerivedSchemas) {
                 userDerivedSchemasNames.add(schemaTO.getName());
@@ -126,8 +128,8 @@ public class SchemaRestClient extends Ab
         List<VirtualSchemaTO> userVirtualSchemas = null;
 
         try {
-            userVirtualSchemas = Arrays.asList(restTemplate.getForObject(baseURL + "virtualSchema/"
-                    + type.name().toLowerCase() + "/list.json", VirtualSchemaTO[].class));
+            userVirtualSchemas = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "virtualSchema/" + type.name().toLowerCase() + "/list.json", VirtualSchemaTO[].class));
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting all user derived schemas", e);
         }
@@ -144,8 +146,9 @@ public class SchemaRestClient extends Ab
         final List<String> userVirtualSchemasNames = new ArrayList<String>();
 
         try {
-            final List<VirtualSchemaTO> userVirtualSchemas = Arrays.asList(restTemplate.getForObject(baseURL
-                    + "virtualSchema/" + type.name().toLowerCase() + "/list.json", VirtualSchemaTO[].class));
+            final List<VirtualSchemaTO> userVirtualSchemas =
+                    Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "virtualSchema/" + type.name().toLowerCase() + "/list.json", VirtualSchemaTO[].class));
 
             for (VirtualSchemaTO schemaTO : userVirtualSchemas) {
                 userVirtualSchemasNames.add(schemaTO.getName());
@@ -163,8 +166,8 @@ public class SchemaRestClient extends Ab
      * @param schemaTO
      */
     public void createSchema(final AttributableType type, final SchemaTO schemaTO) {
-        restTemplate.postForObject(baseURL + "schema/" + type.name().toLowerCase() + "/create", schemaTO,
-                SchemaTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "schema/" + type.name().toLowerCase() + "/create", schemaTO, SchemaTO.class);
     }
 
     /**
@@ -177,8 +180,8 @@ public class SchemaRestClient extends Ab
         SchemaTO schema = null;
 
         try {
-            schema = restTemplate.getForObject(baseURL + "schema/" + type.name().toLowerCase() + "/read/" + name
-                    + ".json", SchemaTO.class);
+            schema = SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "schema/" + type.name().toLowerCase() + "/read/" + name + ".json", SchemaTO.class);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While reading a user schema", e);
         }
@@ -191,8 +194,8 @@ public class SchemaRestClient extends Ab
      * @param schemaTO updated
      */
     public void updateSchema(final AttributableType type, SchemaTO schemaTO) {
-        restTemplate.postForObject(baseURL + "schema/" + type.name().toLowerCase() + "/update", schemaTO,
-                SchemaTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "schema/" + type.name().toLowerCase() + "/update", schemaTO, SchemaTO.class);
     }
 
     /**
@@ -202,8 +205,8 @@ public class SchemaRestClient extends Ab
      * @return schemaTO
      */
     public SchemaTO deleteSchema(final AttributableType type, String name) {
-        return restTemplate.getForObject(baseURL + "schema/" + type.name().toLowerCase() + "/delete/" 
-                + name + ".json", SchemaTO.class);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "schema/" + type.name().toLowerCase() + "/delete/" + name + ".json", SchemaTO.class);
     }
 
     /**
@@ -212,8 +215,8 @@ public class SchemaRestClient extends Ab
      * @param schemaTO
      */
     public void createDerivedSchema(final AttributableType type, final DerivedSchemaTO schemaTO) {
-        restTemplate.postForObject(baseURL + "derivedSchema/" + type.name().toLowerCase() + "/create", schemaTO,
-                DerivedSchemaTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "derivedSchema/" + type.name().toLowerCase() + "/create", schemaTO, DerivedSchemaTO.class);
     }
 
     /**
@@ -222,8 +225,8 @@ public class SchemaRestClient extends Ab
      * @param schemaTO
      */
     public void createVirtualSchema(final AttributableType type, final VirtualSchemaTO schemaTO) {
-        restTemplate.postForObject(baseURL + "virtualSchema/" + type.name().toLowerCase() + "/create", schemaTO,
-                VirtualSchemaTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "virtualSchema/" + type.name().toLowerCase() + "/create", schemaTO, VirtualSchemaTO.class);
     }
 
     /**
@@ -235,8 +238,9 @@ public class SchemaRestClient extends Ab
     public DerivedSchemaTO readDerivedSchema(final AttributableType type, final String name) {
         DerivedSchemaTO derivedSchemaTO = null;
         try {
-            derivedSchemaTO = restTemplate.getForObject(baseURL + "derivedSchema/" + type.name().toLowerCase()
-                    + "/read/" + name + ".json", DerivedSchemaTO.class);
+            derivedSchemaTO = SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "derivedSchema/" + type.name().toLowerCase() + "/read/" + name + ".json",
+                    DerivedSchemaTO.class);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While reading a derived user schema", e);
         }
@@ -249,8 +253,8 @@ public class SchemaRestClient extends Ab
      * @param schemaTO updated
      */
     public void updateDerivedSchema(final AttributableType type, final DerivedSchemaTO schemaTO) {
-        restTemplate.postForObject(baseURL + "derivedSchema/" + type.name().toLowerCase() + "/update", schemaTO,
-                DerivedSchemaTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "derivedSchema/" + type.name().toLowerCase() + "/update", schemaTO, DerivedSchemaTO.class);
     }
 
     /**
@@ -259,8 +263,8 @@ public class SchemaRestClient extends Ab
      * @param schemaTO updated
      */
     public void updateVirtualSchema(final AttributableType type, final VirtualSchemaTO schemaTO) {
-        restTemplate.postForObject(baseURL + "virtualSchema/" + type.name().toLowerCase() + "/update", schemaTO,
-                VirtualSchemaTO.class);
+        SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "virtualSchema/" + type.name().toLowerCase() + "/update", schemaTO, VirtualSchemaTO.class);
     }
 
     /**
@@ -269,8 +273,9 @@ public class SchemaRestClient extends Ab
      * @param name (e.g.:surname)
      */
     public DerivedSchemaTO deleteDerivedSchema(final AttributableType type, String name) {
-        return restTemplate.getForObject(baseURL + "derivedSchema/" + type.name().toLowerCase() + "/delete/" + name 
-                                         + ".json", DerivedSchemaTO.class);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "derivedSchema/" + type.name().toLowerCase() + "/delete/" + name + ".json",
+                DerivedSchemaTO.class);
     }
 
     /**
@@ -279,8 +284,9 @@ public class SchemaRestClient extends Ab
      * @param name (e.g.:surname)
      */
     public VirtualSchemaTO deleteVirtualSchema(final AttributableType type, final String name) {
-        return restTemplate.getForObject(baseURL + "virtualSchema/" + type.name().toLowerCase() + "/delete/" + name 
-                                         + ".json", VirtualSchemaTO.class);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "virtualSchema/" + type.name().toLowerCase() + "/delete/" + name + ".json",
+                VirtualSchemaTO.class);
     }
 
     /**
@@ -290,8 +296,8 @@ public class SchemaRestClient extends Ab
         List<String> validators = null;
 
         try {
-            validators = Arrays.asList(restTemplate.getForObject(baseURL + "configuration/validators.json",
-                    String[].class));
+            validators = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "configuration/validators.json", String[].class));
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting all validators", e);
         }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/TaskRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/TaskRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/TaskRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/TaskRestClient.java Thu Jun 21 08:24:33 2012
@@ -29,6 +29,7 @@ import org.apache.syncope.client.to.Sync
 import org.apache.syncope.client.to.TaskExecTO;
 import org.apache.syncope.client.to.TaskTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.console.SyncopeSession;
 
 /**
  * Console client for invoking Rest Tasks services.
@@ -45,7 +46,8 @@ public class TaskRestClient extends Abst
         List<String> jobClasses = null;
 
         try {
-            jobClasses = Arrays.asList(restTemplate.getForObject(baseURL + "task/jobClasses.json", String[].class));
+            jobClasses = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "task/jobClasses.json", String[].class));
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting all job classes", e);
         }
@@ -56,7 +58,8 @@ public class TaskRestClient extends Abst
         List<String> actions = null;
 
         try {
-            actions = Arrays.asList(restTemplate.getForObject(baseURL + "task/jobActionsClasses.json", String[].class));
+            actions = Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "task/jobActionsClasses.json", String[].class));
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting all job actions classes", e);
         }
@@ -70,7 +73,8 @@ public class TaskRestClient extends Abst
      * @return number of stored tasks.
      */
     public Integer count(final String kind) {
-        return restTemplate.getForObject(baseURL + "task/{kind}/count.json", Integer.class, kind);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "task/{kind}/count.json", Integer.class, kind);
     }
 
     /**
@@ -84,35 +88,39 @@ public class TaskRestClient extends Abst
         List<T> result = Collections.EMPTY_LIST;
 
         if (PropagationTaskTO.class == reference) {
-            result = (List<T>) Arrays.asList(restTemplate.getForObject(baseURL
-                    + "task/propagation/list/{page}/{size}.json", PropagationTaskTO[].class, page, size));
+            result = (List<T>) Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "task/propagation/list/{page}/{size}.json", PropagationTaskTO[].class, page, size));
         } else if (NotificationTaskTO.class == reference) {
-            result = (List<T>) Arrays.asList(restTemplate.getForObject(baseURL
-                    + "task/notification/list/{page}/{size}.json", NotificationTaskTO[].class, page, size));
+            result = (List<T>) Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "task/notification/list/{page}/{size}.json", NotificationTaskTO[].class, page, size));
         } else if (SchedTaskTO.class == reference) {
-            result = (List<T>) Arrays.asList(restTemplate.getForObject(baseURL
-                    + "task/sched/list/{page}/{size}.json", SchedTaskTO[].class, page, size));
+            result = (List<T>) Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "task/sched/list/{page}/{size}.json", SchedTaskTO[].class, page, size));
         } else if (SyncTaskTO.class == reference) {
-            result = (List<T>) Arrays.asList(restTemplate.getForObject(baseURL
-                    + "task/sync/list/{page}/{size}.json", SyncTaskTO[].class, page, size));
+            result = (List<T>) Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "task/sync/list/{page}/{size}.json", SyncTaskTO[].class, page, size));
         }
 
         return result;
     }
 
     public PropagationTaskTO readPropagationTask(final Long taskId) {
-        return restTemplate.getForObject(baseURL + "task/read/{taskId}", PropagationTaskTO.class, taskId);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "task/read/{taskId}", PropagationTaskTO.class, taskId);
     }
 
     public NotificationTaskTO readNotificationTask(final Long taskId) {
-        return restTemplate.getForObject(baseURL + "task/read/{taskId}", NotificationTaskTO.class, taskId);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "task/read/{taskId}", NotificationTaskTO.class, taskId);
     }
 
     public <T extends SchedTaskTO> T readSchedTask(final Class<T> reference, final Long taskId) {
         if (SyncTaskTO.class.getName().equals(reference.getName())) {
-            return (T) restTemplate.getForObject(baseURL + "task/read/{taskId}", SyncTaskTO.class, taskId);
+            return (T) SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "task/read/{taskId}", SyncTaskTO.class, taskId);
         } else {
-            return (T) restTemplate.getForObject(baseURL + "task/read/{taskId}", SchedTaskTO.class, taskId);
+            return (T) SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "task/read/{taskId}", SchedTaskTO.class, taskId);
         }
     }
 
@@ -123,7 +131,8 @@ public class TaskRestClient extends Abst
      */
     @Override
     public List<TaskExecTO> listExecutions() {
-        return Arrays.asList(restTemplate.getForObject(baseURL + "task/execution/list", TaskExecTO[].class));
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "task/execution/list", TaskExecTO[].class));
     }
 
     /**
@@ -132,7 +141,8 @@ public class TaskRestClient extends Abst
      * @param taskId task to delete
      */
     public TaskTO delete(final Long taskId, final Class<? extends TaskTO> taskToClass) {
-        return restTemplate.getForObject(baseURL + "task/delete/{taskId}", taskToClass, taskId);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "task/delete/{taskId}", taskToClass, taskId);
     }
 
     @Override
@@ -146,7 +156,7 @@ public class TaskRestClient extends Abst
      * @param taskId task id
      */
     public void startExecution(final Long taskId, boolean dryRun) {
-        restTemplate.postForObject(
+        SyncopeSession.get().getRestTemplate().postForObject(
                 baseURL + "task/execute/{taskId}?dryRun={dryRun}", null, TaskExecTO.class, taskId, dryRun);
     }
 
@@ -157,22 +167,27 @@ public class TaskRestClient extends Abst
      */
     @Override
     public void deleteExecution(final Long taskExecId) {
-        restTemplate.getForObject(baseURL + "task/execution/delete/{execId}", TaskExecTO.class, taskExecId);
+        SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "task/execution/delete/{execId}", TaskExecTO.class, taskExecId);
     }
 
     public SyncTaskTO createSyncTask(final SyncTaskTO taskTO) {
-        return restTemplate.postForObject(baseURL + "task/create/sync", taskTO, SyncTaskTO.class);
+        return SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "task/create/sync", taskTO, SyncTaskTO.class);
     }
 
     public SchedTaskTO createSchedTask(final SchedTaskTO taskTO) {
-        return restTemplate.postForObject(baseURL + "task/create/sched", taskTO, SchedTaskTO.class);
+        return SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "task/create/sched", taskTO, SchedTaskTO.class);
     }
 
     public SchedTaskTO updateSchedTask(final SchedTaskTO taskTO) {
-        return restTemplate.postForObject(baseURL + "task/update/sched", taskTO, SchedTaskTO.class);
+        return SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "task/update/sched", taskTO, SchedTaskTO.class);
     }
 
     public SyncTaskTO updateSyncTask(final SyncTaskTO taskTO) {
-        return restTemplate.postForObject(baseURL + "task/update/sync", taskTO, SyncTaskTO.class);
+        return SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "task/update/sync", taskTO, SyncTaskTO.class);
     }
 }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRequestRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRequestRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRequestRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRequestRestClient.java Thu Jun 21 08:24:33 2012
@@ -23,33 +23,38 @@ import java.util.List;
 import org.apache.syncope.client.mod.UserMod;
 import org.apache.syncope.client.to.UserRequestTO;
 import org.apache.syncope.client.to.UserTO;
+import org.apache.syncope.console.SyncopeSession;
 import org.springframework.stereotype.Component;
 
 @Component
 public class UserRequestRestClient extends AbstractBaseRestClient {
 
     public UserTO readProfile() {
-        return restTemplate.getForObject(baseURL + "user/request/read/self", UserTO.class);
+        return SyncopeSession.get().getRestTemplate().getForObject(baseURL + "user/request/read/self", UserTO.class);
     }
 
     public List<UserRequestTO> list() {
-        return Arrays.asList(restTemplate.getForObject(baseURL + "user/request/list", UserRequestTO[].class));
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "user/request/list", UserRequestTO[].class));
     }
 
     public UserRequestTO delete(final Long requestId) {
-        return restTemplate.getForObject(baseURL + "user/request/deleteRequest/{requestId}",
-                UserRequestTO.class, requestId);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "user/request/deleteRequest/{requestId}", UserRequestTO.class, requestId);
     }
 
     public UserRequestTO requestCreate(final UserTO userTO) {
-        return restTemplate.postForObject(baseURL + "user/request/create", userTO, UserRequestTO.class);
+        return SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "user/request/create", userTO, UserRequestTO.class);
     }
 
     public UserRequestTO requestUpdate(final UserMod userMod) {
-        return restTemplate.postForObject(baseURL + "user/request/update", userMod, UserRequestTO.class);
+        return SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "user/request/update", userMod, UserRequestTO.class);
     }
 
     public UserRequestTO requestDelete(final Long userId) {
-        return restTemplate.postForObject(baseURL + "user/request/delete/", userId, UserRequestTO.class);
+        return SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "user/request/delete/", userId, UserRequestTO.class);
     }
 }