You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2013/01/25 17:57:08 UTC
svn commit: r1438587 -
/syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserRequestServiceProxy.java
Author: ilgrosso
Date: Fri Jan 25 16:57:08 2013
New Revision: 1438587
URL: http://svn.apache.org/viewvc?rev=1438587&view=rev
Log:
Minor cleanup
Modified:
syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserRequestServiceProxy.java
Modified: syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserRequestServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserRequestServiceProxy.java?rev=1438587&r1=1438586&r2=1438587&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserRequestServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserRequestServiceProxy.java Fri Jan 25 16:57:08 2013
@@ -21,13 +21,9 @@ package org.apache.syncope.client.servic
import java.net.URI;
import java.util.Arrays;
import java.util.List;
-
-import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
-
import org.apache.syncope.common.services.UserRequestService;
import org.apache.syncope.common.to.UserRequestTO;
-import org.apache.syncope.common.types.UserRequestType;
import org.springframework.web.client.RestTemplate;
public class UserRequestServiceProxy extends SpringServiceProxy implements UserRequestService {
@@ -35,7 +31,7 @@ public class UserRequestServiceProxy ext
public UserRequestServiceProxy(final String baseUrl, final RestTemplate restTemplate) {
super(baseUrl, restTemplate);
}
-
+
@Override
public Response getOptions() {
return Response.ok().allow("GET", "POST", "DELETE").header(SYNCOPE_CREATE_ALLOWED, isCreateAllowed()).build();
@@ -47,14 +43,24 @@ public class UserRequestServiceProxy ext
@Override
public Response create(final UserRequestTO userRequestTO) {
- UserRequestTO created = null;
- if (userRequestTO.getType() == UserRequestType.CREATE) {
- created = getRestTemplate().postForObject(baseUrl + "user/request/create", userRequestTO.getUserTO(), UserRequestTO.class);
- } else if (userRequestTO.getType() == UserRequestType.UPDATE) {
- created = getRestTemplate().postForObject(baseUrl + "user/request/update", userRequestTO.getUserMod(), UserRequestTO.class);
- } else if (userRequestTO.getType() == UserRequestType.DELETE) {
- created = getRestTemplate().getForObject(baseUrl + "user/request/delete/{userId}", UserRequestTO.class, userRequestTO.getUserId());
+ UserRequestTO created;
+ switch (userRequestTO.getType()) {
+ case UPDATE:
+ created = getRestTemplate().postForObject(baseUrl + "user/request/update", userRequestTO.getUserMod(),
+ UserRequestTO.class);
+ break;
+
+ case DELETE:
+ created = getRestTemplate().getForObject(baseUrl + "user/request/delete/{userId}", UserRequestTO.class,
+ userRequestTO.getUserId());
+ break;
+
+ case CREATE:
+ default:
+ created = getRestTemplate().postForObject(baseUrl + "user/request/create", userRequestTO.getUserTO(),
+ UserRequestTO.class);
}
+
URI location = URI.create(baseUrl + "user/request/read/" + created.getId());
return Response.created(location).entity(created.getId()).build();
}
@@ -71,7 +77,7 @@ public class UserRequestServiceProxy ext
}
@Override
- public void delete(@PathParam("requestId") Long requestId) {
+ public void delete(final Long requestId) {
getRestTemplate().getForObject(
baseUrl + "user/request/deleteRequest/{requestId}", UserRequestTO.class, requestId);
}