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 [2/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/

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java Thu Jun 21 08:24:33 2012
@@ -25,6 +25,7 @@ import org.apache.syncope.client.search.
 import org.apache.syncope.client.to.ConnObjectTO;
 import org.apache.syncope.client.to.UserTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.console.SyncopeSession;
 import org.springframework.stereotype.Component;
 import org.apache.syncope.console.commons.StatusBean;
 
@@ -35,7 +36,7 @@ import org.apache.syncope.console.common
 public class UserRestClient extends AbstractBaseRestClient {
 
     public Integer count() {
-        return restTemplate.getForObject(baseURL + "user/count.json", Integer.class);
+        return SyncopeSession.get().getRestTemplate().getForObject(baseURL + "user/count.json", Integer.class);
     }
 
     /**
@@ -46,8 +47,8 @@ public class UserRestClient extends Abst
      * @return list of TaskTO objects
      */
     public List<UserTO> list(final int page, final int size) {
-        return Arrays.asList(restTemplate.getForObject(baseURL + "user/list/{page}/{size}.json", UserTO[].class, page,
-                size));
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "user/list/{page}/{size}.json", UserTO[].class, page, size));
     }
 
     /**
@@ -56,9 +57,10 @@ public class UserRestClient extends Abst
      * @param userTO instance
      * @throws SyncopeClientCompositeErrorException
      */
-    public UserTO create(final UserTO userTO) throws SyncopeClientCompositeErrorException {
+    public UserTO create(final UserTO userTO)
+            throws SyncopeClientCompositeErrorException {
 
-        return restTemplate.postForObject(baseURL + "user/create", userTO, UserTO.class);
+        return SyncopeSession.get().getRestTemplate().postForObject(baseURL + "user/create", userTO, UserTO.class);
     }
 
     /**
@@ -67,20 +69,23 @@ public class UserRestClient extends Abst
      * @param userTO
      * @return true is the operation ends successfully, false otherwise
      */
-    public UserTO update(UserMod userModTO) throws SyncopeClientCompositeErrorException {
+    public UserTO update(UserMod userModTO)
+            throws SyncopeClientCompositeErrorException {
 
-        return restTemplate.postForObject(baseURL + "user/update", userModTO, UserTO.class);
+        return SyncopeSession.get().getRestTemplate().postForObject(baseURL + "user/update", userModTO, UserTO.class);
     }
 
-    public UserTO delete(Long id) throws SyncopeClientCompositeErrorException {
+    public UserTO delete(Long id)
+            throws SyncopeClientCompositeErrorException {
 
-        return restTemplate.getForObject(baseURL + "user/delete/{userId}", UserTO.class, id);
+        return SyncopeSession.get().getRestTemplate().getForObject(baseURL + "user/delete/{userId}", UserTO.class, id);
     }
 
     public UserTO read(Long id) {
         UserTO userTO = null;
         try {
-            userTO = restTemplate.getForObject(baseURL + "user/read/{userId}.json", UserTO.class, id);
+            userTO = SyncopeSession.get().getRestTemplate().getForObject(
+                    baseURL + "user/read/{userId}.json", UserTO.class, id);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While reading a user", e);
         }
@@ -88,7 +93,8 @@ public class UserRestClient extends Abst
     }
 
     public Integer searchCount(final NodeCond searchCond) {
-        return restTemplate.postForObject(baseURL + "user/search/count.json", searchCond, Integer.class);
+        return SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "user/search/count.json", searchCond, Integer.class);
     }
 
     /**
@@ -97,30 +103,34 @@ public class UserRestClient extends Abst
      * @param userTO
      * @return UserTOs
      */
-    public List<UserTO> search(final NodeCond searchCond) throws SyncopeClientCompositeErrorException {
+    public List<UserTO> search(final NodeCond searchCond)
+            throws SyncopeClientCompositeErrorException {
 
-        return Arrays.asList(restTemplate.postForObject(baseURL + "user/search", searchCond, UserTO[].class));
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "user/search", searchCond, UserTO[].class));
     }
 
     public List<UserTO> search(final NodeCond searchCond, final int page, final int size)
             throws SyncopeClientCompositeErrorException {
 
-        return Arrays.asList(restTemplate.postForObject(baseURL + "user/search/{page}/{size}", searchCond,
-                UserTO[].class, page, size));
+        return Arrays.asList(SyncopeSession.get().getRestTemplate().postForObject(
+                baseURL + "user/search/{page}/{size}", searchCond, UserTO[].class, page, size));
     }
 
     public ConnObjectTO getRemoteObject(final String resourceName, final String objectId)
             throws SyncopeClientCompositeErrorException {
-        return restTemplate.getForObject(baseURL + "/resource/{resourceName}/read/{objectId}.json", ConnObjectTO.class,
-                resourceName, objectId);
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "/resource/{resourceName}/read/{objectId}.json", ConnObjectTO.class, resourceName, objectId);
     }
 
-    public UserTO reactivate(long userId, List<StatusBean> statuses) throws SyncopeClientCompositeErrorException {
+    public UserTO reactivate(long userId, List<StatusBean> statuses)
+            throws SyncopeClientCompositeErrorException {
 
         return enable(userId, statuses, true);
     }
 
-    public UserTO suspend(long userId, List<StatusBean> statuses) throws SyncopeClientCompositeErrorException {
+    public UserTO suspend(long userId, List<StatusBean> statuses)
+            throws SyncopeClientCompositeErrorException {
 
         return enable(userId, statuses, false);
     }
@@ -133,7 +143,7 @@ public class UserRestClient extends Abst
         query.append(baseURL).append("user/").append(enable
                 ? "reactivate/"
                 : "suspend/").append(userId).append("?").
-        // perform on resource if and only if resources have been speciofied
+                // perform on resource if and only if resources have been speciofied
                 append("performRemotely=").append(!statuses.isEmpty()).append("&");
 
         boolean performLoacal = false;
@@ -152,6 +162,6 @@ public class UserRestClient extends Abst
         // perform on syncope if and only if it has been requested
         query.append("performLocally=").append(performLoacal);
 
-        return restTemplate.getForObject(query.toString(), UserTO.class);
+        return SyncopeSession.get().getRestTemplate().getForObject(query.toString(), UserTO.class);
     }
 }

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/WorkflowRestClient.java Thu Jun 21 08:24:33 2012
@@ -21,17 +21,19 @@ package org.apache.syncope.console.rest;
 import org.springframework.stereotype.Component;
 import org.apache.syncope.client.to.WorkflowDefinitionTO;
 import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.console.SyncopeSession;
 
 @Component
 public class WorkflowRestClient extends AbstractBaseRestClient {
 
-    public WorkflowDefinitionTO getDefinition() throws SyncopeClientCompositeErrorException {
-
-        return restTemplate.getForObject(baseURL + "workflow/definition.json", WorkflowDefinitionTO.class);
+    public WorkflowDefinitionTO getDefinition()
+            throws SyncopeClientCompositeErrorException {
+        return SyncopeSession.get().getRestTemplate().getForObject(
+                baseURL + "workflow/definition.json", WorkflowDefinitionTO.class);
     }
 
-    public void updateDefinition(final WorkflowDefinitionTO workflowDef) throws SyncopeClientCompositeErrorException {
-
-        restTemplate.put(baseURL + "/workflow/definition.json", workflowDef);
+    public void updateDefinition(final WorkflowDefinitionTO workflowDef)
+            throws SyncopeClientCompositeErrorException {
+        SyncopeSession.get().getRestTemplate().put(baseURL + "/workflow/definition.json", workflowDef);
     }
 }

Modified: incubator/syncope/trunk/console/src/main/resources/applicationContext.xml
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/resources/applicationContext.xml?rev=1352448&r1=1352447&r2=1352448&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/resources/applicationContext.xml (original)
+++ incubator/syncope/trunk/console/src/main/resources/applicationContext.xml Thu Jun 21 08:24:33 2012
@@ -85,14 +85,15 @@ under the License.
     </property>
   </bean>
   
-  <bean id="httpClientFactory" class="org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory">
+  <bean id="httpClientFactory" class="org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory" scope="prototype">
     <constructor-arg value="${host}"/>
     <constructor-arg value="${port}"/>
     <constructor-arg value="${scheme}"/>
     <constructor-arg ref="httpClientConnManager"/>
     <constructor-arg ref="httpClientParams"/>
   </bean>
-  <bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
+  
+  <bean id="restTemplate" class="org.springframework.web.client.RestTemplate" scope="prototype">
     <constructor-arg ref="httpClientFactory"/>
 
     <property name="errorHandler">