You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by cs...@apache.org on 2013/01/28 15:44:09 UTC
svn commit: r1439430 - in /syncope/trunk/core/src/main:
java/org/apache/syncope/core/persistence/dao/
java/org/apache/syncope/core/rest/controller/
java/org/apache/syncope/core/services/ resources/
Author: cschneider
Date: Mon Jan 28 14:44:09 2013
New Revision: 1439430
URL: http://svn.apache.org/viewvc?rev=1439430&view=rev
Log:
SYNCOPE-231 Adding UserServiceImpl for CXF
Added:
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserServiceImpl.java (with props)
Modified:
syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/InvalidSearchConditionException.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java
syncope/trunk/core/src/main/resources/restContext.xml
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/InvalidSearchConditionException.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/InvalidSearchConditionException.java?rev=1439430&r1=1439429&r2=1439430&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/InvalidSearchConditionException.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/InvalidSearchConditionException.java Mon Jan 28 14:44:09 2013
@@ -18,7 +18,9 @@
*/
package org.apache.syncope.core.persistence.dao;
-public class InvalidSearchConditionException extends Exception {
+public class InvalidSearchConditionException extends RuntimeException {
+
+ private static final long serialVersionUID = 1785286543933086849L;
public InvalidSearchConditionException() {
super();
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java?rev=1439430&r1=1439429&r2=1439430&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java Mon Jan 28 14:44:09 2013
@@ -123,20 +123,27 @@ public class UserController {
public ModelAndView verifyPassword(@PathVariable("username") String username,
@RequestParam("password") final String password)
throws NotFoundException, UnauthorizedRoleException {
+ return new ModelAndView().addObject(verifyPasswordInternal(username, password));
+ }
+ public Boolean verifyPasswordInternal(String username,
+ final String password) {
auditManager.audit(Category.user, UserSubCategory.create, Result.success,
"Verified password for: " + username);
-
- return new ModelAndView().addObject(dataBinder.verifyPassword(username, password));
+ return dataBinder.verifyPassword(username, password);
}
@PreAuthorize("hasRole('USER_LIST')")
@RequestMapping(method = RequestMethod.GET, value = "/count")
@Transactional(readOnly = true, rollbackFor = {Throwable.class})
public ModelAndView count() {
+ return new ModelAndView().addObject(countInternal());
+ }
+
+ @Transactional(readOnly = true, rollbackFor = {Throwable.class})
+ public int countInternal() {
Set<Long> adminRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
-
- return new ModelAndView().addObject(userDAO.count(adminRoleIds));
+ return userDAO.count(adminRoleIds);
}
@PreAuthorize("hasRole('USER_READ')")
@@ -144,15 +151,16 @@ public class UserController {
@Transactional(readOnly = true, rollbackFor = {Throwable.class})
public ModelAndView searchCount(@RequestBody final NodeCond searchCondition)
throws InvalidSearchConditionException {
+ return new ModelAndView().addObject(searchCountInternal(searchCondition));
+ }
+ public int searchCountInternal(final NodeCond searchCondition) {
if (!searchCondition.isValid()) {
LOG.error("Invalid search condition: {}", searchCondition);
throw new InvalidSearchConditionException();
}
-
final Set<Long> adminRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
- return new ModelAndView().addObject(searchDAO.count(adminRoleIds, searchCondition,
- AttributableUtil.getInstance(AttributableType.USER)));
+ return searchDAO.count(adminRoleIds, searchCondition, AttributableUtil.getInstance(AttributableType.USER));
}
@PreAuthorize("hasRole('USER_LIST')")
@@ -273,7 +281,12 @@ public class UserController {
@RequestMapping(method = RequestMethod.POST, value = "/create")
public UserTO create(final HttpServletResponse response, @RequestBody final UserTO userTO)
throws PropagationException, UnauthorizedRoleException, WorkflowException, NotFoundException {
-
+ UserTO savedTO = createInternal(userTO);
+ response.setStatus(HttpServletResponse.SC_CREATED);
+ return savedTO;
+ }
+
+ public UserTO createInternal(final UserTO userTO) {
LOG.debug("User create called with {}", userTO);
Set<Long> requestRoleIds = new HashSet<Long>(userTO.getMemberships().size());
@@ -305,7 +318,6 @@ public class UserController {
auditManager.audit(Category.user, UserSubCategory.create, Result.success,
"Successfully created user: " + savedTO.getUsername());
- response.setStatus(HttpServletResponse.SC_CREATED);
return savedTO;
}
Added: 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=1439430&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserServiceImpl.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserServiceImpl.java Mon Jan 28 14:44:09 2013
@@ -0,0 +1,197 @@
+/*
+ * 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 javax.ws.rs.MatrixParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PathParam;
+
+import org.apache.syncope.common.mod.UserMod;
+import org.apache.syncope.common.search.NodeCond;
+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;
+
+@Service
+public class UserServiceImpl implements UserService {
+ @Autowired
+ UserController userController;
+
+ @Override
+ public UserTO activate(@PathParam("userId") long userId, String token) {
+ return userController.activate(userId, token);
+ }
+
+ @Override
+ public UserTO activate(long userId, String token,
+ PropagationRequestTO propagationRequestTO) {
+ return userController.activate(userId, token, propagationRequestTO);
+ }
+
+ @Override
+ public UserTO activateByUsername(String username,
+ @MatrixParam("token") String token) {
+ return userController.activate(username, token);
+ }
+
+ @Override
+ public UserTO activateByUsername(String username, String token,
+ PropagationRequestTO propagationRequestTO) {
+ return userController.activate(username, token, propagationRequestTO);
+ }
+
+ @Override
+ public WorkflowFormTO claimForm(String taskId) {
+ return userController.claimForm(taskId);
+ }
+
+ @Override
+ public int count() {
+ return userController.countInternal();
+ }
+
+ @Override
+ public UserTO create(UserTO userTO) {
+ return userController.createInternal(userTO);
+ }
+
+ @Override
+ public UserTO delete(Long userId) {
+ return userController.delete(userId);
+ }
+
+ @Override
+ @POST
+ public UserTO executeWorkflow(String taskId, UserTO userTO) {
+ return userController.executeWorkflow(userTO, taskId);
+ }
+
+ @Override
+ public WorkflowFormTO getFormForUser(Long userId) {
+ return userController.getFormForUser(userId);
+ }
+
+ @Override
+ public List<WorkflowFormTO> getForms() {
+ return userController.getForms();
+ }
+
+ @Override
+ public List<UserTO> list() {
+ return userController.list();
+ }
+
+ @Override
+ public List<UserTO> list(int page, int size) {
+ return userController.list(page, size);
+ }
+
+ @Override
+ public UserTO reactivate(long userId) {
+ return userController.reactivate(userId);
+ }
+
+ @Override
+ public UserTO reactivate(long userId, PropagationRequestTO propagationRequestTO) {
+ return userController.reactivate(userId, propagationRequestTO);
+ }
+
+ @Override
+ public UserTO reactivateByUsername(String username) {
+ return userController.reactivate(username);
+ }
+
+ @Override
+ public UserTO reactivateByUsername(String username,
+ PropagationRequestTO propagationRequestTO) {
+ return userController.reactivate(username, propagationRequestTO);
+ }
+
+ @Override
+ public UserTO read(Long userId) {
+ return userController.read(userId);
+ }
+
+ @Override
+ public UserTO read(String username) {
+ return userController.read(username);
+ }
+
+ @Override
+ public UserTO readSelf() {
+ return userController.read();
+ }
+
+ @Override
+ public List<UserTO> search(NodeCond searchCondition) {
+ return userController.search(searchCondition);
+ }
+
+ @Override
+ public List<UserTO> search(NodeCond searchCondition, int page, int size) {
+ return userController.search(searchCondition, page, size);
+ }
+
+ @Override
+ public int searchCount(NodeCond searchCondition) {
+ return userController.searchCountInternal(searchCondition);
+ }
+
+ @Override
+ public UserTO submitForm(WorkflowFormTO form) {
+ return userController.submitForm(form);
+ }
+
+ @Override
+ public UserTO suspend(long userId) {
+ return userController.suspend(userId);
+ }
+
+ @Override
+ public UserTO suspend(long userId, PropagationRequestTO propagationRequestTO) {
+ return userController.suspend(userId, propagationRequestTO);
+ }
+
+ @Override
+ public UserTO suspendByUsername(String username) {
+ return userController.suspend(username);
+ }
+
+ @Override
+ public UserTO suspendByUsername(String username, PropagationRequestTO propagationRequestTO) {
+ return userController.suspend(username, propagationRequestTO);
+ }
+
+ @Override
+ public UserTO update(Long userId, UserMod userMod) {
+ return userController.update(userMod);
+ }
+
+ @Override
+ public Boolean verifyPassword(String username, String password) {
+ return userController.verifyPasswordInternal(username, password);
+ }
+
+}
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserServiceImpl.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=1439430&r1=1439429&r2=1439430&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/restContext.xml (original)
+++ syncope/trunk/core/src/main/resources/restContext.xml Mon Jan 28 14:44:09 2013
@@ -77,6 +77,7 @@ under the License.
<ref bean="roleServiceImpl"/>
<ref bean="schemaServiceImpl"/>
<ref bean="userRequestServiceImpl"/>
+ <ref bean="userServiceImpl"/>
</jaxrs:serviceBeans>
<jaxrs:resourceComparator>
<bean id="myServiceComparator" class="org.apache.syncope.core.rest.utils.QueryResourceInfoComperator"/>