Author: jbernhardt
Date: Thu Jan  3 11:01:43 2013
New Revision: 1428273

URL: http://svn.apache.org/viewvc?rev=1428273&view=rev
Log:
[SYNCOPE-259]
Introduces ConfigurationService Interface

Added:
    
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationServiceProxy.java
Modified:
    
syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementService.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementServiceProxy.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleServiceProxy.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/services/SpringServiceProxy.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserServiceProxy.java
    
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java
    
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
    
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java

Added: 
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java?rev=1428273&view=auto
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java
 (added)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java
 Thu Jan  3 11:01:43 2013
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.services;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.syncope.client.to.ConfigurationTO;
+
+@Path("configuration")
+public interface ConfigurationService {
+
+       @POST
+       ConfigurationTO create(final ConfigurationTO configurationTO);
+
+       @DELETE
+       @Path("{key}")
+       ConfigurationTO delete(@PathParam("key") final String key);
+
+       @GET
+       List<ConfigurationTO> list();
+
+       @GET
+       @Path("{key}")
+       ConfigurationTO read(@PathParam("key") final String key);
+
+       @PUT
+       @Path("{key}")
+       ConfigurationTO update(final ConfigurationTO configurationTO);
+
+       @GET
+       @Path("validators")
+       Set<String> getValidators();
+
+       @GET
+       @Path("mailTemplates")
+       Set<String> getMailTemplates();
+
+       @GET
+       @Produces(MediaType.APPLICATION_OCTET_STREAM)
+       Response dbExport();
+
+}
\ No newline at end of file

Added: 
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationServiceProxy.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationServiceProxy.java?rev=1428273&view=auto
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationServiceProxy.java
 (added)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationServiceProxy.java
 Thu Jan  3 11:01:43 2013
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.services;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.syncope.client.to.ConfigurationTO;
+import org.springframework.web.client.RestTemplate;
+
+public class ConfigurationServiceProxy extends SpringServiceProxy implements
+               ConfigurationService {
+
+       public ConfigurationServiceProxy(String baseUrl, RestTemplate 
restTemplate) {
+               super(baseUrl, restTemplate);
+       }
+
+       @Override
+       public ConfigurationTO create(ConfigurationTO configurationTO) {
+               return restTemplate.postForObject(BASE_URL + 
"configuration/create",
+                               configurationTO, ConfigurationTO.class);
+       }
+
+       @Override
+       public ConfigurationTO delete(String key) {
+               return restTemplate
+                               .getForObject(BASE_URL + 
"configuration/delete/{key}.json",
+                                               ConfigurationTO.class, key);
+       }
+
+       @Override
+       public List<ConfigurationTO> list() {
+               return Arrays.asList(restTemplate.getForObject(BASE_URL
+                               + "configuration/list.json", 
ConfigurationTO[].class));
+       }
+
+       @Override
+       public ConfigurationTO read(String key) {
+               return restTemplate.getForObject(BASE_URL
+                               + "configuration/read/{key}.json", 
ConfigurationTO.class, key);
+       }
+
+       @Override
+       public ConfigurationTO update(ConfigurationTO configurationTO) {
+               return restTemplate.postForObject(BASE_URL + 
"configuration/update",
+                               configurationTO, ConfigurationTO.class);
+       }
+
+       @Override
+       public Set<String> getValidators() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public Set<String> getMailTemplates() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public Response dbExport() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+}

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementService.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementService.java?rev=1428273&r1=1428272&r2=1428273&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementService.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementService.java
 Thu Jan  3 11:01:43 2013
@@ -23,20 +23,14 @@ import java.util.Set;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-@Path("/entitlements")
-@RequestMapping("/auth")
+@Path("entitlements")
 public interface EntitlementService {
 
     @GET
-    @RequestMapping(method = RequestMethod.GET, value = "/allentitlements")
     public abstract Set<String> getAllEntitlements();
 
     @GET
-    @Path("/own")
-    @RequestMapping(method = RequestMethod.GET, value = "/entitlements")
+    @Path("own")
     public abstract Set<String> getMyEntitlements();
 
 }
\ No newline at end of file

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementServiceProxy.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementServiceProxy.java?rev=1428273&r1=1428272&r2=1428273&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementServiceProxy.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementServiceProxy.java
 Thu Jan  3 11:01:43 2013
@@ -33,12 +33,12 @@ public class EntitlementServiceProxy ext
        @Override
        public Set<String> getAllEntitlements() {
                return new HashSet<String>(Arrays.asList(new 
RestTemplate().getForObject(
-                baseUrl + "auth/allentitlements.json", String[].class)));
+                BASE_URL + "auth/allentitlements.json", String[].class)));
        }
 
        @Override
        public Set<String> getMyEntitlements() {
-               return new 
HashSet<String>(Arrays.asList(restTemplate.getForObject(baseUrl
+               return new 
HashSet<String>(Arrays.asList(restTemplate.getForObject(BASE_URL
                 + "auth/entitlements.json", String[].class)));
        }
 

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java?rev=1428273&r1=1428272&r2=1428273&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java 
(original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleService.java 
Thu Jan  3 11:01:43 2013
@@ -21,73 +21,64 @@ package org.apache.syncope.services;
 import java.util.List;
 
 import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
 
 import org.apache.syncope.client.mod.RoleMod;
 import org.apache.syncope.client.search.NodeCond;
 import org.apache.syncope.client.to.RoleTO;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
 
-@Path("/role")
-@RequestMapping("/role")
+@Path("role")
 public interface RoleService {
 
        @GET
-    @Path("/{roleId}/children")
-       @RequestMapping(method = RequestMethod.GET, value = 
"/children/{roleId}")
-       List<RoleTO> children(@PathParam("roleId") @PathVariable("roleId") 
final Long roleId);
+    @Path("{roleId}/children")
+       List<RoleTO> children(@PathParam("roleId") final Long roleId);
 
        @POST
-    @Path("/")
-       @RequestMapping(method = RequestMethod.POST, value = "/create")
-       RoleTO create(@RequestBody final RoleTO roleTO);
+    @Path("")
+       RoleTO create(final RoleTO roleTO);
 
        @DELETE
-    @Path("/{roleId}")
-       @RequestMapping(method = RequestMethod.GET, value = "/delete/{roleId}")
-       RoleTO delete(@PathParam("roleId") @PathVariable("roleId") final Long 
roleId);
+    @Path("{roleId}")
+       RoleTO delete(@PathParam("roleId") final Long roleId);
 
        @GET
-       @RequestMapping(method = RequestMethod.GET, value = "/list")
        List<RoleTO> list();
 
        @GET
-    @Path("/{roleId}/parent")
-       @RequestMapping(method = RequestMethod.GET, value = "/parent/{roleId}")
-       RoleTO parent(@PathParam("roleId") @PathVariable("roleId") final Long 
roleId);
+    @Path("{roleId}/parent")
+       RoleTO parent(@PathParam("roleId") final Long roleId);
 
        @GET
-       @Path("/{roleId}")
-       @RequestMapping(method = RequestMethod.GET, value = "/read/{roleId}")
-       RoleTO read(@PathParam("roleId") @PathVariable("roleId") final Long 
roleId);
-
-       
-       @RequestMapping(method = RequestMethod.POST, value = "/search")
-       List<RoleTO> search(@RequestBody final NodeCond searchCondition);
-
-       @RequestMapping(method = RequestMethod.POST, value = 
"/search/{page}/{size}")
-       List<RoleTO> search(@RequestBody final NodeCond searchCondition,
-                       @PathVariable("page") final int page,
-                       @PathVariable("size") final int size);
+       @Path("{roleId}")
+       RoleTO read(@PathParam("roleId") final Long roleId);
 
-       @RequestMapping(method = RequestMethod.POST, value = "/search/count")
-       int searchCount(@RequestBody final NodeCond searchCondition);
+       @POST
+       @Path("search")
+       List<RoleTO> search(final NodeCond searchCondition);
+
+       @POST
+       @Path("search")
+       List<RoleTO> search(final NodeCond searchCondition,
+                       @QueryParam("page") final int page,
+                       @QueryParam("size") @DefaultValue("25") final int size);
+
+       @POST
+       @Path("search/count")
+       int searchCount(final NodeCond searchCondition);
 
        /**
         * @deprecated Authentication checks should not depend on the method 
called
         */
        @Deprecated
-       @RequestMapping(method = RequestMethod.GET, value = 
"/selfRead/{roleId}")
-       RoleTO selfRead(@PathVariable("roleId") final Long roleId);
+       RoleTO selfRead(final Long roleId);
 
        @POST
-    @Path("/{roleId}")
-       @RequestMapping(method = RequestMethod.POST, value = "/update")
-       RoleTO update(@PathParam("roleId") final Long roleId, @RequestBody 
final RoleMod roleMod);
+    @Path("{roleId}")
+       RoleTO update(@PathParam("roleId") final Long roleId, final RoleMod 
roleMod);
 }
\ No newline at end of file

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleServiceProxy.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleServiceProxy.java?rev=1428273&r1=1428272&r2=1428273&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleServiceProxy.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleServiceProxy.java
 Thu Jan  3 11:01:43 2013
@@ -34,67 +34,67 @@ public class RoleServiceProxy extends Sp
 
        @Override
        public List<RoleTO> children(Long roleId) {
-               return Arrays.asList(restTemplate.getForObject(baseUrl
+               return Arrays.asList(restTemplate.getForObject(BASE_URL
                                + "role/children/{roleId}.json", 
RoleTO[].class, roleId));
        }
 
        @Override
        public RoleTO create(RoleTO roleTO) {
-               return restTemplate.postForObject(baseUrl + "role/create", 
roleTO,
+               return restTemplate.postForObject(BASE_URL + "role/create", 
roleTO,
                                RoleTO.class);
        }
 
        @Override
        public RoleTO delete(Long roleId) {
-               return restTemplate.getForObject(baseUrl + 
"role/delete/{roleId}",
+               return restTemplate.getForObject(BASE_URL + 
"role/delete/{roleId}",
                                RoleTO.class, roleId);
        }
 
        @Override
        public List<RoleTO> list() {
-               return Arrays.asList(restTemplate.getForObject(baseUrl
+               return Arrays.asList(restTemplate.getForObject(BASE_URL
                                + "role/list.json", RoleTO[].class));
        }
 
        @Override
        public RoleTO parent(Long roleId) {
-               return restTemplate.getForObject(baseUrl + 
"role/parent/{roleId}.json",
+               return restTemplate.getForObject(BASE_URL + 
"role/parent/{roleId}.json",
                                RoleTO.class, roleId);
        }
 
        @Override
        public RoleTO read(Long roleId) {
-               return restTemplate.getForObject(baseUrl + 
"role/read/{roleId}.json",
+               return restTemplate.getForObject(BASE_URL + 
"role/read/{roleId}.json",
                                RoleTO.class, roleId);
        }
 
        @Override
        public List<RoleTO> search(NodeCond searchCondition) {
                return Arrays.asList(restTemplate.postForObject(
-                               baseUrl + "role/search", searchCondition, 
RoleTO[].class));
+                               BASE_URL + "role/search", searchCondition, 
RoleTO[].class));
        }
 
        @Override
        public List<RoleTO> search(NodeCond searchCondition, int page, int 
size) {
                return Arrays.asList(restTemplate.postForObject(
-                               baseUrl + "role/search/{page}/{size}", 
searchCondition, RoleTO[].class, page, size));
+                               BASE_URL + "role/search/{page}/{size}", 
searchCondition, RoleTO[].class, page, size));
        }
 
        @Override
        public int searchCount(NodeCond searchCondition) {
-               return restTemplate.postForObject(baseUrl + 
"role/search/count.json",
+               return restTemplate.postForObject(BASE_URL + 
"role/search/count.json",
                                searchCondition, Integer.class);
        }
 
        @Override
        public RoleTO selfRead(Long roleId) {
-               return restTemplate.getForObject(baseUrl + 
"role/selfRead/{roleId}",
+               return restTemplate.getForObject(BASE_URL + 
"role/selfRead/{roleId}",
                                RoleTO.class, roleId);
        }
 
        @Override
        public RoleTO update(Long roleId, RoleMod roleMod) {
-               return restTemplate.postForObject(baseUrl + "role/update", 
roleMod,
+               return restTemplate.postForObject(BASE_URL + "role/update", 
roleMod,
                                RoleTO.class);
        }
 

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/services/SpringServiceProxy.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/SpringServiceProxy.java?rev=1428273&r1=1428272&r2=1428273&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/services/SpringServiceProxy.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/services/SpringServiceProxy.java
 Thu Jan  3 11:01:43 2013
@@ -24,10 +24,10 @@ public abstract class SpringServiceProxy
 
        protected RestTemplate restTemplate;
 
-       protected String baseUrl;
+       protected String BASE_URL;
 
        public SpringServiceProxy(String baseUrl, RestTemplate restTemplate) {
                this.restTemplate = restTemplate;
-               this.baseUrl = baseUrl;
+               this.BASE_URL = baseUrl;
        }
 }

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java?rev=1428273&r1=1428272&r2=1428273&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java 
(original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java 
Thu Jan  3 11:01:43 2013
@@ -35,7 +35,7 @@ import org.apache.syncope.client.search.
 import org.apache.syncope.client.to.UserTO;
 import org.apache.syncope.client.to.WorkflowFormTO;
 
-@Path("/user")
+@Path("user")
 public interface UserService {
 
        /**
@@ -55,19 +55,19 @@ public interface UserService {
         */
        @Deprecated
        @POST
-       @Path("/workflow/task/{taskId}/claim")
+       @Path("workflow/task/{taskId}/claim")
        WorkflowFormTO claimForm(@PathParam("taskId") final String taskId);
 
        @GET
-       @Path("/count")
+       @Path("count")
        int count();
 
        @POST
-       @Path("/")
+       @Path("")
        UserTO create(final UserTO userTO);
 
        @DELETE
-       @Path("/{userId}")
+       @Path("{userId}")
        UserTO delete(@PathParam("userId") final Long userId);
 
        /**
@@ -83,7 +83,7 @@ public interface UserService {
         */
        @Deprecated
        @GET
-       @Path("/{userId}/workflow/form")
+       @Path("{userId}/workflow/form")
        WorkflowFormTO getFormForUser(@PathParam("userId") final Long userId);
 
        /**
@@ -91,7 +91,7 @@ public interface UserService {
         */
        @Deprecated
        @GET
-       @Path("/workflow/form")
+       @Path("workflow/form")
        List<WorkflowFormTO> getForms();
 
        @GET
@@ -120,7 +120,7 @@ public interface UserService {
        UserTO reactivateByUsername(String username);
 
        @GET
-       @Path("/{userId}")
+       @Path("{userId}")
        UserTO read(@PathParam("userId") final Long userId);
 
        @GET
@@ -144,11 +144,11 @@ public interface UserService {
                        @QueryParam("size") @DefaultValue("25") final int size);
 
        @POST
-       @Path("/count")
+       @Path("search/count")
        int searchCount(final NodeCond searchCondition);
 
 //     @POST
-//     @Path("/user/{userId}/status")
+//     @Path("user/{userId}/status")
 //     public abstract UserTO setStatus(@PathParam("userId") final Long userId,
 //                     final StatusMod statusUpdate);
 
@@ -157,7 +157,7 @@ public interface UserService {
         */
        @Deprecated
        @POST
-       @Path("/workflow/form")
+       @Path("workflow/form")
        UserTO submitForm(final WorkflowFormTO form);
 
        /**
@@ -179,7 +179,7 @@ public interface UserService {
        UserTO suspendByUsername(String username);
 
        @POST
-       @Path("/{userId}")
+       @Path("{userId}")
        UserTO update(@PathParam("userId") final Long userId, final UserMod 
userMod);
 
        @GET

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserServiceProxy.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/UserServiceProxy.java?rev=1428273&r1=1428272&r2=1428273&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserServiceProxy.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserServiceProxy.java
 Thu Jan  3 11:01:43 2013
@@ -45,30 +45,30 @@ public class UserServiceProxy extends Sp
        public Boolean verifyPassword(@MatrixParam("uname") String username,
                        @MatrixParam("pwd") String password) {
                return restTemplate.
-                getForObject(baseUrl + 
"user/verifyPassword/{username}.json?password={password}",
+                getForObject(BASE_URL + 
"user/verifyPassword/{username}.json?password={password}",
                 Boolean.class, username, password);
        }
 
        @Override
        public int count() {
-               return restTemplate.getForObject(baseUrl + "user/count.json", 
Integer.class);
+               return restTemplate.getForObject(BASE_URL + "user/count.json", 
Integer.class);
        }
 
        @Override
        public List<UserTO> list() {
-               return  Arrays.asList(restTemplate.getForObject(baseUrl + 
"user/list.json", UserTO[].class));
+               return  Arrays.asList(restTemplate.getForObject(BASE_URL + 
"user/list.json", UserTO[].class));
        }
 
        @Override
        public List<UserTO> list(@QueryParam("page") int page,
                        @QueryParam("size") @DefaultValue("25") int size) {
-               return Arrays.asList(restTemplate.getForObject(baseUrl + 
"user/list/{page}/{size}.json",
+               return Arrays.asList(restTemplate.getForObject(BASE_URL + 
"user/list/{page}/{size}.json",
                 UserTO[].class, page, size));
        }
 
        @Override
        public UserTO read(@PathParam("userId") Long userId) {
-               return restTemplate.getForObject(baseUrl + 
"user/read/{userId}.json", UserTO.class, userId);
+               return restTemplate.getForObject(BASE_URL + 
"user/read/{userId}.json", UserTO.class, userId);
        }
 
        @Override
@@ -80,17 +80,17 @@ public class UserServiceProxy extends Sp
        @POST
        @Path("/")
        public UserTO create(UserTO userTO) {
-               return restTemplate.postForObject(baseUrl + "user/create", 
userTO, UserTO.class);
+               return restTemplate.postForObject(BASE_URL + "user/create", 
userTO, UserTO.class);
        }
 
        @Override
        public UserTO update(@PathParam("userId") Long userId, UserMod userMod) 
{
-               return restTemplate.postForObject(baseUrl + "user/update", 
userMod, UserTO.class);
+               return restTemplate.postForObject(BASE_URL + "user/update", 
userMod, UserTO.class);
        }
 
        @Override
        public UserTO delete(@PathParam("userId") Long userId) {
-               return restTemplate.getForObject(baseUrl + 
"user/delete/{userId}", UserTO.class, userId);
+               return restTemplate.getForObject(BASE_URL + 
"user/delete/{userId}", UserTO.class, userId);
        }
 
        @Override
@@ -102,85 +102,85 @@ public class UserServiceProxy extends Sp
        @GET
        @Path("/workflow/form")
        public List<WorkflowFormTO> getForms() {
-               return  Arrays.asList(restTemplate.getForObject(baseUrl + 
"user/workflow/form/list", WorkflowFormTO[].class));
+               return  Arrays.asList(restTemplate.getForObject(BASE_URL + 
"user/workflow/form/list", WorkflowFormTO[].class));
        }
 
        @Override
        public WorkflowFormTO getFormForUser(@PathParam("userId") Long userId) {
-               return restTemplate.getForObject(baseUrl + 
"user/workflow/form/{userId}", WorkflowFormTO.class, userId);
+               return restTemplate.getForObject(BASE_URL + 
"user/workflow/form/{userId}", WorkflowFormTO.class, userId);
        }
 
        @Override
        public WorkflowFormTO claimForm(@PathParam("taskId") String taskId) {
-               return restTemplate.getForObject(baseUrl + 
"user/workflow/form/claim/{taskId}", WorkflowFormTO.class, taskId);
+               return restTemplate.getForObject(BASE_URL + 
"user/workflow/form/claim/{taskId}", WorkflowFormTO.class, taskId);
        }
 
        @Override
        public UserTO submitForm(WorkflowFormTO form) {
-               return restTemplate.postForObject(baseUrl + 
"user/workflow/form/submit", form, UserTO.class);
+               return restTemplate.postForObject(BASE_URL + 
"user/workflow/form/submit", form, UserTO.class);
        }
 
        @Override
        public UserTO activate(long userId, String token) {
-               return restTemplate.getForObject(baseUrl + 
"user/activate/{userId}?token=" + token, UserTO.class, userId);
+               return restTemplate.getForObject(BASE_URL + 
"user/activate/{userId}?token=" + token, UserTO.class, userId);
        }
 
        @Override
        public UserTO activateByUsername(String username, String token) {
-               return restTemplate.getForObject(baseUrl + 
"user/activateByUsername/{username}.json?token=" + token,
+               return restTemplate.getForObject(BASE_URL + 
"user/activateByUsername/{username}.json?token=" + token,
                 UserTO.class, username);
        }
 
        @Override
        public UserTO suspend(long userId) {
-               return restTemplate.getForObject(baseUrl + 
"user/suspend/{userId}", UserTO.class, userId);
+               return restTemplate.getForObject(BASE_URL + 
"user/suspend/{userId}", UserTO.class, userId);
        }
 
        @Override
        public UserTO reactivate(long userId) {
-               return restTemplate.getForObject(baseUrl + 
"user/reactivate/{userId}", UserTO.class, userId);
+               return restTemplate.getForObject(BASE_URL + 
"user/reactivate/{userId}", UserTO.class, userId);
        }
        
        @Override
        public UserTO reactivate(long userId, String query) {
-               return restTemplate.getForObject(baseUrl + "user/reactivate/" + 
userId + query, UserTO.class);
+               return restTemplate.getForObject(BASE_URL + "user/reactivate/" 
+ userId + query, UserTO.class);
        }
 
        @Override
        public UserTO suspendByUsername(String username) {
-               return restTemplate.getForObject(baseUrl + 
"user/suspendByUsername/{username}.json", UserTO.class, username);
+               return restTemplate.getForObject(BASE_URL + 
"user/suspendByUsername/{username}.json", UserTO.class, username);
        }
 
        @Override
        public UserTO reactivateByUsername(String username) {
-               return restTemplate.getForObject(baseUrl + 
"user/reactivateByUsername/{username}.json", UserTO.class, username);
+               return restTemplate.getForObject(BASE_URL + 
"user/reactivateByUsername/{username}.json", UserTO.class, username);
        }
 
        @Override
        public UserTO suspend(long userId, String query) {
-               return  restTemplate.getForObject(baseUrl + "user/suspend/" + 
userId + query, UserTO.class);
+               return  restTemplate.getForObject(BASE_URL + "user/suspend/" + 
userId + query, UserTO.class);
        }
 
        @Override
        public UserTO readSelf() {
-               return restTemplate.getForObject(baseUrl + "user/read/self", 
UserTO.class);
+               return restTemplate.getForObject(BASE_URL + "user/read/self", 
UserTO.class);
        }
 
        @Override
        public List<UserTO> search(NodeCond searchCondition) {
-               return Arrays.asList(restTemplate.postForObject(baseUrl + 
"user/search", searchCondition,
+               return Arrays.asList(restTemplate.postForObject(BASE_URL + 
"user/search", searchCondition,
                 UserTO[].class));
        }
 
        @Override
        public List<UserTO> search(NodeCond searchCondition, int page, int 
size) {
-               return Arrays.asList(restTemplate.postForObject(baseUrl + 
"user/search/{page}/{size}",
+               return Arrays.asList(restTemplate.postForObject(BASE_URL + 
"user/search/{page}/{size}",
                 searchCondition, UserTO[].class, page, size));
        }
 
        @Override
        public int searchCount(NodeCond searchCondition) {
-               return restTemplate.postForObject(baseUrl + 
"user/search/count.json", searchCondition, Integer.class);
+               return restTemplate.postForObject(BASE_URL + 
"user/search/count.json", searchCondition, Integer.class);
        }
 
 }

Modified: 
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java?rev=1428273&r1=1428272&r2=1428273&view=diff
==============================================================================
--- 
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java
 (original)
+++ 
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java
 Thu Jan  3 11:01:43 2013
@@ -23,20 +23,10 @@ import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.http.MediaType;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.stereotype.Controller;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.servlet.ModelAndView;
+
 import org.apache.syncope.client.to.ConfigurationTO;
 import org.apache.syncope.core.audit.AuditManager;
 import org.apache.syncope.core.init.ImplementationClassNamesLoader;
@@ -49,6 +39,18 @@ import org.apache.syncope.core.util.Impo
 import org.apache.syncope.types.AuditElements.Category;
 import org.apache.syncope.types.AuditElements.ConfigurationSubCategory;
 import org.apache.syncope.types.AuditElements.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.ResourcePatternResolver;
+import org.springframework.http.MediaType;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Controller;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.servlet.ModelAndView;
 
 @Controller
 @RequestMapping("/configuration")

Modified: 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1428273&r1=1428272&r2=1428273&view=diff
==============================================================================
--- 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java 
(original)
+++ 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java 
Thu Jan  3 11:01:43 2013
@@ -25,9 +25,9 @@ import org.apache.http.impl.client.Defau
 import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
 import org.apache.syncope.client.mod.AttributeMod;
 import org.apache.syncope.client.to.AttributeTO;
+import org.apache.syncope.services.ConfigurationServiceProxy;
 import org.apache.syncope.services.EntitlementServiceProxy;
 import org.apache.syncope.services.RoleServiceProxy;
-import org.apache.syncope.services.UserService;
 import org.apache.syncope.services.UserServiceProxy;
 import org.junit.Before;
 import org.junit.runner.RunWith;
@@ -74,11 +74,13 @@ public abstract class AbstractTest {
        @Autowired
        protected RestTemplate restTemplate;
 
-       protected UserService userService;
+       protected UserServiceProxy userService;
 
        protected RoleServiceProxy roleService;
 
        protected EntitlementServiceProxy entitlementService;
+       
+       protected ConfigurationServiceProxy configurationService;
 
        @Autowired
        protected DataSource testDataSource;
@@ -103,5 +105,6 @@ public abstract class AbstractTest {
                userService = new UserServiceProxy(BASE_URL, restTemplate);
                roleService = new RoleServiceProxy(BASE_URL, restTemplate);
                entitlementService = new EntitlementServiceProxy(BASE_URL, 
restTemplate);
+               configurationService = new ConfigurationServiceProxy(BASE_URL, 
restTemplate);
        }
 }

Modified: 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java?rev=1428273&r1=1428272&r2=1428273&view=diff
==============================================================================
--- 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java
 (original)
+++ 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java
 Thu Jan  3 11:01:43 2013
@@ -18,88 +18,87 @@
  */
 package org.apache.syncope.core.rest;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
 import java.util.List;
-import org.junit.Test;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.client.HttpStatusCodeException;
+
 import org.apache.syncope.client.to.ConfigurationTO;
 import org.junit.FixMethodOrder;
+import org.junit.Test;
 import org.junit.runners.MethodSorters;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.client.HttpStatusCodeException;
 
 @FixMethodOrder(MethodSorters.JVM)
 public class ConfigurationTestITCase extends AbstractTest {
 
-    @Test
-    public void create() {
-        ConfigurationTO configurationTO = new ConfigurationTO();
-        configurationTO.setKey("testKey");
-        configurationTO.setValue("testValue");
-
-        ConfigurationTO newConfigurationTO = 
restTemplate.postForObject(BASE_URL + "configuration/create",
-                configurationTO, ConfigurationTO.class);
-        assertEquals(configurationTO, newConfigurationTO);
-    }
-
-    @Test
-    public void delete() throws UnsupportedEncodingException {
-
-        try {
-            restTemplate.getForObject(
-                    BASE_URL + "configuration/delete/{key}.json", 
ConfigurationTO.class, "nonExistent");
-        } catch (HttpStatusCodeException e) {
-            assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
-        }
-
-        ConfigurationTO tokenLengthTO = restTemplate.getForObject(BASE_URL + 
"configuration/read/{key}.json",
-                ConfigurationTO.class, "token.length");
-
-        ConfigurationTO deletedConfig =
-                restTemplate.getForObject(
-                BASE_URL + "configuration/delete/{key}.json", 
ConfigurationTO.class, "token.length");
-        assertNotNull(deletedConfig);
-        try {
-            restTemplate
-                    .getForObject(BASE_URL + "configuration/read/{key}.json", 
ConfigurationTO.class, "token.length");
-        } catch (HttpStatusCodeException e) {
-            assertEquals(e.getStatusCode(), HttpStatus.NOT_FOUND);
-        }
-
-        ConfigurationTO newConfigurationTO = 
restTemplate.postForObject(BASE_URL + "configuration/create",
-                tokenLengthTO, ConfigurationTO.class);
-        assertEquals(tokenLengthTO, newConfigurationTO);
-    }
-
-    @Test
-    public void list() {
-        List<ConfigurationTO> configurations = 
Arrays.asList(restTemplate.getForObject(BASE_URL
-                + "configuration/list.json", ConfigurationTO[].class));
-        assertNotNull(configurations);
-        for (ConfigurationTO configuration : configurations) {
-            assertNotNull(configuration);
-        }
-    }
-
-    @Test
-    public void read() {
-        ConfigurationTO configurationTO = restTemplate.getForObject(BASE_URL + 
"configuration/read/{key}.json",
-                ConfigurationTO.class, "token.expireTime");
-
-        assertNotNull(configurationTO);
-    }
-
-    @Test
-    public void update() {
-        ConfigurationTO configurationTO = new ConfigurationTO();
-        configurationTO.setKey("token.expireTime");
-        configurationTO.setValue("61");
-
-        ConfigurationTO newConfigurationTO = 
restTemplate.postForObject(BASE_URL + "configuration/update",
-                configurationTO, ConfigurationTO.class);
-
-        assertEquals(configurationTO, newConfigurationTO);
-    }
+       @Test
+       public void create() {
+               ConfigurationTO configurationTO = new ConfigurationTO();
+               configurationTO.setKey("testKey");
+               configurationTO.setValue("testValue");
+
+               ConfigurationTO newConfigurationTO = configurationService
+                               .create(configurationTO);
+               assertEquals(configurationTO, newConfigurationTO);
+       }
+
+       @Test
+       public void delete() throws UnsupportedEncodingException {
+
+               try {
+                       configurationService.delete("nonExistent");
+               } catch (HttpStatusCodeException e) {
+                       assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
+               }
+
+               ConfigurationTO tokenLengthTO = configurationService
+                               .read("token.length");
+
+               ConfigurationTO deletedConfig = configurationService
+                               .delete("token.length");
+               assertNotNull(deletedConfig);
+               try {
+                       configurationService.read("token.length");
+               } catch (HttpStatusCodeException e) {
+                       assertEquals(e.getStatusCode(), HttpStatus.NOT_FOUND);
+               }
+
+               ConfigurationTO newConfigurationTO = configurationService
+                               .create(tokenLengthTO);
+               assertEquals(tokenLengthTO, newConfigurationTO);
+       }
+
+       @Test
+       public void list() {
+               List<ConfigurationTO> configurations = 
configurationService.list();
+               assertNotNull(configurations);
+               for (ConfigurationTO configuration : configurations) {
+                       assertNotNull(configuration);
+               }
+       }
+
+       @Test
+       public void read() {
+               ConfigurationTO configurationTO = configurationService
+                               .read("token.expireTime");
+
+               assertNotNull(configurationTO);
+       }
+
+       @Test
+       public void update() {
+               ConfigurationTO configurationTO = 
configurationService.read("token.expireTime");
+               int value = Integer.parseInt(configurationTO.getValue());
+               value++;
+               configurationTO.setValue(value + "");
+
+               ConfigurationTO newConfigurationTO = 
configurationService.update(configurationTO);
+               assertEquals(configurationTO, newConfigurationTO);
+               
+               newConfigurationTO = 
configurationService.read("token.expireTime");
+               assertEquals(configurationTO, newConfigurationTO);
+       }
 }


Reply via email to