Author: cschneider Date: Fri Feb 15 15:35:34 2013 New Revision: 1446632 URL: http://svn.apache.org/r1446632 Log: SYNCOPE-312 Moving workflow related methods from UserService to UserWorkflowService
Added: syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserWorkflowServiceProxy.java (with props) syncope/trunk/common/src/main/java/org/apache/syncope/common/services/UserWorkflowService.java (with props) syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserWorkflowServiceImpl.java (with props) Modified: syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserServiceProxy.java syncope/trunk/common/src/main/java/org/apache/syncope/common/services/UserService.java syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserServiceImpl.java syncope/trunk/core/src/main/resources/restContext.xml syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Modified: syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserServiceProxy.java URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserServiceProxy.java?rev=1446632&r1=1446631&r2=1446632&view=diff ============================================================================== --- syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserServiceProxy.java (original) +++ syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserServiceProxy.java Fri Feb 15 15:35:34 2013 @@ -30,7 +30,6 @@ import org.apache.syncope.common.search. import org.apache.syncope.common.services.UserService; import org.apache.syncope.common.to.PropagationRequestTO; import org.apache.syncope.common.to.UserTO; -import org.apache.syncope.common.to.WorkflowFormTO; import org.springframework.web.client.RestTemplate; public class UserServiceProxy extends SpringServiceProxy implements UserService { @@ -94,34 +93,6 @@ public class UserServiceProxy extends Sp } @Override - public UserTO executeWorkflow(final String taskId, final UserTO userTO) { - return null; - } - - @Override - public List<WorkflowFormTO> getForms() { - return Arrays.asList(getRestTemplate().getForObject(baseUrl + "user/workflow/form/list", - WorkflowFormTO[].class)); - } - - @Override - public WorkflowFormTO getFormForUser(final Long userId) { - return getRestTemplate().getForObject(baseUrl + "user/workflow/form/{userId}", WorkflowFormTO.class, - userId); - } - - @Override - public WorkflowFormTO claimForm(final String taskId) { - return getRestTemplate().getForObject(baseUrl + "user/workflow/form/claim/{taskId}", - WorkflowFormTO.class, taskId); - } - - @Override - public UserTO submitForm(final WorkflowFormTO form) { - return getRestTemplate().postForObject(baseUrl + "user/workflow/form/submit", form, UserTO.class); - } - - @Override public UserTO activate(final long userId, final String token) { return getRestTemplate().getForObject(baseUrl + "user/activate/{userId}?token=" + token, UserTO.class, userId); } Added: syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserWorkflowServiceProxy.java URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserWorkflowServiceProxy.java?rev=1446632&view=auto ============================================================================== --- syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserWorkflowServiceProxy.java (added) +++ syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserWorkflowServiceProxy.java Fri Feb 15 15:35:34 2013 @@ -0,0 +1,63 @@ +/* + * 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.client.services.proxy; + +import java.util.Arrays; +import java.util.List; + +import org.apache.syncope.common.services.UserWorkflowService; +import org.apache.syncope.common.to.UserTO; +import org.apache.syncope.common.to.WorkflowFormTO; +import org.springframework.web.client.RestTemplate; + +public class UserWorkflowServiceProxy extends SpringServiceProxy implements UserWorkflowService { + + public UserWorkflowServiceProxy(String baseUrl, RestTemplate restTemplate) { + super(baseUrl, restTemplate); + } + + @Override + public UserTO executeWorkflow(final String taskId, final UserTO userTO) { + return null; + } + + @Override + public List<WorkflowFormTO> getForms() { + return Arrays.asList(getRestTemplate().getForObject(baseUrl + "user/workflow/form/list", + WorkflowFormTO[].class)); + } + + @Override + public WorkflowFormTO getFormForUser(final Long userId) { + return getRestTemplate().getForObject(baseUrl + "user/workflow/form/{userId}", WorkflowFormTO.class, + userId); + } + + @Override + public WorkflowFormTO claimForm(final String taskId) { + return getRestTemplate().getForObject(baseUrl + "user/workflow/form/claim/{taskId}", + WorkflowFormTO.class, taskId); + } + + @Override + public UserTO submitForm(final WorkflowFormTO form) { + return getRestTemplate().postForObject(baseUrl + "user/workflow/form/submit", form, UserTO.class); + } + +} Propchange: syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/UserWorkflowServiceProxy.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/services/UserService.java URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/services/UserService.java?rev=1446632&r1=1446631&r2=1446632&view=diff ============================================================================== --- syncope/trunk/common/src/main/java/org/apache/syncope/common/services/UserService.java (original) +++ syncope/trunk/common/src/main/java/org/apache/syncope/common/services/UserService.java Fri Feb 15 15:35:34 2013 @@ -33,7 +33,6 @@ import org.apache.syncope.common.mod.Use import org.apache.syncope.common.search.NodeCond; import org.apache.syncope.common.to.PropagationRequestTO; import org.apache.syncope.common.to.UserTO; -import org.apache.syncope.common.to.WorkflowFormTO; @Path("users") public interface UserService { @@ -56,10 +55,6 @@ public interface UserService { UserTO activateByUsername(@PathParam("username") String username, @QueryParam("token") String token, PropagationRequestTO propagationRequestTO); - @POST - @Path("workflow/tasks/{taskId}/claim") - WorkflowFormTO claimForm(@PathParam("taskId") String taskId); - @GET @Path("count") int count(); @@ -71,19 +66,7 @@ public interface UserService { @Path("{userId}") UserTO delete(@PathParam("userId") Long userId); - @POST - @Path("workflow/tasks/{taskId}/execute") - UserTO executeWorkflow(@PathParam("taskId") String taskId, UserTO userTO); - - @GET - @Path("{userId}/workflow/form") - WorkflowFormTO getFormForUser(@PathParam("userId") Long userId); - - @GET - @Path("workflow/form") - List<WorkflowFormTO> getForms(); - - @GET + @GET List<UserTO> list(); @GET @@ -130,10 +113,6 @@ public interface UserService { int searchCount(NodeCond searchCondition) throws InvalidSearchConditionException; @POST - @Path("workflow/form") - UserTO submitForm(WorkflowFormTO form); - - @POST @Path("{userId}/status/suspend") UserTO suspend(@PathParam("userId") long userId); @@ -156,4 +135,4 @@ public interface UserService { @GET Boolean verifyPassword(@QueryParam("username") String username, @QueryParam("pwd") String password); -} + } Added: syncope/trunk/common/src/main/java/org/apache/syncope/common/services/UserWorkflowService.java URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/services/UserWorkflowService.java?rev=1446632&view=auto ============================================================================== --- syncope/trunk/common/src/main/java/org/apache/syncope/common/services/UserWorkflowService.java (added) +++ syncope/trunk/common/src/main/java/org/apache/syncope/common/services/UserWorkflowService.java Fri Feb 15 15:35:34 2013 @@ -0,0 +1,52 @@ +/* + * 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.common.services; + +import java.util.List; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +import org.apache.syncope.common.to.UserTO; +import org.apache.syncope.common.to.WorkflowFormTO; + +@Path("userworkflow") +public interface UserWorkflowService { + @POST + @Path("forms") + UserTO submitForm(WorkflowFormTO form); + + @GET + @Path("forms") + List<WorkflowFormTO> getForms(); + + @GET + @Path("forms/{userId}") + WorkflowFormTO getFormForUser(@PathParam("userId") Long userId); + + @POST + @Path("tasks/{taskId}/claim") + WorkflowFormTO claimForm(@PathParam("taskId") String taskId); + + @POST + @Path("tasks/{taskId}/execute") + UserTO executeWorkflow(@PathParam("taskId") String taskId, UserTO userTO); +} Propchange: syncope/trunk/common/src/main/java/org/apache/syncope/common/services/UserWorkflowService.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java?rev=1446632&r1=1446631&r2=1446632&view=diff ============================================================================== --- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java (original) +++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java Fri Feb 15 15:35:34 2013 @@ -20,7 +20,7 @@ package org.apache.syncope.console.rest; import java.util.List; -import org.apache.syncope.common.services.UserService; +import org.apache.syncope.common.services.UserWorkflowService; import org.apache.syncope.common.to.WorkflowFormTO; import org.springframework.stereotype.Component; @@ -33,14 +33,14 @@ public class ApprovalRestClient extends private static final long serialVersionUID = -4785231164900813921L; public List<WorkflowFormTO> getForms() { - return getService(UserService.class).getForms(); + return getService(UserWorkflowService.class).getForms(); } public WorkflowFormTO claimForm(final String taskId) { - return getService(UserService.class).claimForm(taskId); + return getService(UserWorkflowService.class).claimForm(taskId); } public void submitForm(final WorkflowFormTO form) { - getService(UserService.class).submitForm(form); + getService(UserWorkflowService.class).submitForm(form); } } Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserServiceImpl.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserServiceImpl.java?rev=1446632&r1=1446631&r2=1446632&view=diff ============================================================================== --- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserServiceImpl.java (original) +++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserServiceImpl.java Fri Feb 15 15:35:34 2013 @@ -20,7 +20,6 @@ package org.apache.syncope.core.services import java.net.URI; import java.util.List; -import javax.ws.rs.POST; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.syncope.common.SyncopeConstants; @@ -30,7 +29,6 @@ import org.apache.syncope.common.service import org.apache.syncope.common.services.UserService; import org.apache.syncope.common.to.PropagationRequestTO; import org.apache.syncope.common.to.UserTO; -import org.apache.syncope.common.to.WorkflowFormTO; import org.apache.syncope.core.rest.controller.UserController; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -65,11 +63,6 @@ public class UserServiceImpl implements } @Override - public WorkflowFormTO claimForm(final String taskId) { - return userController.claimForm(taskId); - } - - @Override public int count() { return userController.countInternal(); } @@ -90,22 +83,6 @@ public class UserServiceImpl implements } @Override - @POST - public UserTO executeWorkflow(final String taskId, final UserTO userTO) { - return userController.executeWorkflow(userTO, taskId); - } - - @Override - public WorkflowFormTO getFormForUser(final Long userId) { - return userController.getFormForUser(userId); - } - - @Override - public List<WorkflowFormTO> getForms() { - return userController.getForms(); - } - - @Override public List<UserTO> list() { return userController.list(); } @@ -166,11 +143,6 @@ public class UserServiceImpl implements } @Override - public UserTO submitForm(final WorkflowFormTO form) { - return userController.submitForm(form); - } - - @Override public UserTO suspend(final long userId) { return userController.suspend(userId); } Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserWorkflowServiceImpl.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserWorkflowServiceImpl.java?rev=1446632&view=auto ============================================================================== --- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserWorkflowServiceImpl.java (added) +++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserWorkflowServiceImpl.java Fri Feb 15 15:35:34 2013 @@ -0,0 +1,63 @@ +/* + * 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.core.services; + +import java.util.List; + +import org.apache.syncope.common.services.UserWorkflowService; +import org.apache.syncope.common.to.UserTO; +import org.apache.syncope.common.to.WorkflowFormTO; +import org.apache.syncope.core.rest.controller.UserController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class UserWorkflowServiceImpl implements UserWorkflowService { + + @Autowired + private UserController userController; + + @Override + public WorkflowFormTO claimForm(final String taskId) { + return userController.claimForm(taskId); + } + + + @Override + public UserTO executeWorkflow(final String taskId, final UserTO userTO) { + return userController.executeWorkflow(userTO, taskId); + } + + @Override + public WorkflowFormTO getFormForUser(final Long userId) { + return userController.getFormForUser(userId); + } + + @Override + public List<WorkflowFormTO> getForms() { + return userController.getForms(); + } + + + @Override + public UserTO submitForm(final WorkflowFormTO form) { + return userController.submitForm(form); + } + +} Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserWorkflowServiceImpl.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: syncope/trunk/core/src/main/resources/restContext.xml URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/restContext.xml?rev=1446632&r1=1446631&r2=1446632&view=diff ============================================================================== --- syncope/trunk/core/src/main/resources/restContext.xml (original) +++ syncope/trunk/core/src/main/resources/restContext.xml Fri Feb 15 15:35:34 2013 @@ -80,6 +80,7 @@ under the License. <ref bean="userRequestServiceImpl"/> <ref bean="userServiceImpl"/> <ref bean="workflowServiceImpl"/> + <ref bean="userWorkflowServiceImpl"/> </jaxrs:serviceBeans> <jaxrs:resourceComparator> <bean id="myServiceComparator" class="org.apache.syncope.core.rest.utils.QueryResourceInfoComperator"/> 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=1446632&r1=1446631&r2=1446632&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 Fri Feb 15 15:35:34 2013 @@ -51,6 +51,7 @@ import org.apache.syncope.client.service import org.apache.syncope.client.services.proxy.TaskServiceProxy; import org.apache.syncope.client.services.proxy.UserRequestServiceProxy; import org.apache.syncope.client.services.proxy.UserServiceProxy; +import org.apache.syncope.client.services.proxy.UserWorkflowServiceProxy; import org.apache.syncope.client.services.proxy.WorkflowServiceProxy; import org.apache.syncope.common.mod.AttributeMod; import org.apache.syncope.common.services.ConfigurationService; @@ -66,6 +67,7 @@ import org.apache.syncope.common.service import org.apache.syncope.common.services.TaskService; import org.apache.syncope.common.services.UserRequestService; import org.apache.syncope.common.services.UserService; +import org.apache.syncope.common.services.UserWorkflowService; import org.apache.syncope.common.services.WorkflowService; import org.apache.syncope.common.to.AbstractSchemaTO; import org.apache.syncope.common.to.AttributeTO; @@ -131,6 +133,8 @@ public abstract class AbstractTest { private String contentType; protected UserService userService; + + protected UserWorkflowService userWorkflowService; protected RoleService roleService; @@ -191,6 +195,7 @@ public abstract class AbstractTest { protected void resetRestTemplate() { setupRestTemplate(ADMIN_UID, ADMIN_PWD); userService = new UserServiceProxy(BASE_URL, restTemplate); + userWorkflowService = new UserWorkflowServiceProxy(BASE_URL, restTemplate); roleService = new RoleServiceProxy(BASE_URL, restTemplate); resourceService = new ResourceServiceProxy(BASE_URL, restTemplate); entitlementService = new EntitlementServiceProxy(BASE_URL, restTemplate); @@ -210,6 +215,7 @@ public abstract class AbstractTest { // BEGIN CXF Initialization public void setupCXFServices() throws Exception { userService = createServiceInstance(UserService.class); + userWorkflowService = createServiceInstance(UserWorkflowService.class); roleService = createServiceInstance(RoleService.class); resourceService = createServiceInstance(ResourceService.class); entitlementService = createServiceInstance(EntitlementService.class); Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1446632&r1=1446631&r2=1446632&view=diff ============================================================================== --- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original) +++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Fri Feb 15 15:35:34 2013 @@ -38,6 +38,7 @@ import org.apache.syncope.common.mod.Att import org.apache.syncope.common.mod.MembershipMod; import org.apache.syncope.common.mod.UserMod; import org.apache.syncope.common.services.UserService; +import org.apache.syncope.common.services.UserWorkflowService; import org.apache.syncope.common.to.AttributeTO; import org.apache.syncope.common.to.ConfigurationTO; import org.apache.syncope.common.to.ConnObjectTO; @@ -555,7 +556,7 @@ public class UserTestITCase extends Abst assertEquals("createApproval", userTO.getStatus()); // 2. request if there is any pending task for user just created - WorkflowFormTO form = userService.getFormForUser(userTO.getId()); + WorkflowFormTO form = userWorkflowService.getFormForUser(userTO.getId()); assertNotNull(form); assertNotNull(form.getUserId()); @@ -564,7 +565,7 @@ public class UserTestITCase extends Abst assertNull(form.getOwner()); // 3. claim task from user1, not in role 7 (designated for approval in workflow definition): fail - UserService userService2 = setupCredentials(userService, UserService.class, "user1", ADMIN_PWD); + UserWorkflowService userService2 = setupCredentials(userWorkflowService, UserWorkflowService.class, "user1", ADMIN_PWD); try { userService2.claimForm(form.getTaskId()); @@ -574,7 +575,7 @@ public class UserTestITCase extends Abst } // 4. claim task from user4, in role 7 - UserService userService3 = setupCredentials(userService, UserService.class, "user4", ADMIN_PWD); + UserWorkflowService userService3 = setupCredentials(userWorkflowService, UserWorkflowService.class, "user4", ADMIN_PWD); form = userService3.claimForm(form.getTaskId()); assertNotNull(form); @@ -627,17 +628,17 @@ public class UserTestITCase extends Abst assertNotNull(exception); // 2. request if there is any pending form for user just created - List<WorkflowFormTO> forms = userService.getForms(); + List<WorkflowFormTO> forms = userWorkflowService.getForms(); assertNotNull(forms); assertEquals(1, forms.size()); - WorkflowFormTO form = userService.getFormForUser(userTO.getId()); + WorkflowFormTO form = userWorkflowService.getFormForUser(userTO.getId()); assertNotNull(form); assertNotNull(form.getTaskId()); assertNull(form.getOwner()); // 4. claim task (from admin) - form = userService.claimForm(form.getTaskId()); + form = userWorkflowService.claimForm(form.getTaskId()); assertNotNull(form); assertNotNull(form.getTaskId()); assertNotNull(form.getOwner()); @@ -646,7 +647,7 @@ public class UserTestITCase extends Abst Map<String, WorkflowFormPropertyTO> props = form.getPropertyMap(); props.get("approve").setValue(Boolean.TRUE.toString()); form.setProperties(props.values()); - userTO = userService.submitForm(form); + userTO = userWorkflowService.submitForm(form); assertNotNull(userTO); assertEquals("active", userTO.getStatus()); assertEquals(Collections.singleton(RESOURCE_NAME_TESTDB), userTO.getResources());