| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
package org.demosys.web.user.action; |
| 7 |
|
import java.lang.reflect.InvocationTargetException; |
| 8 |
|
import javax.servlet.http.HttpServletRequest; |
| 9 |
|
import javax.servlet.http.HttpServletResponse; |
| 10 |
|
import org.apache.commons.beanutils.BeanUtils; |
| 11 |
|
import org.apache.commons.lang.StringUtils; |
| 12 |
|
import org.apache.struts.action.*; |
| 13 |
|
import org.demosys.web.ServiceLocator; |
| 14 |
|
import org.demosys.web.user.InvalidUserException; |
| 15 |
|
import org.demosys.web.user.UnknownUserException; |
| 16 |
|
import org.demosys.web.user.UserService; |
| 17 |
|
import org.demosys.web.user.UserView; |
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
8 |
public class SelectUserAction extends Action { |
| 22 |
|
public ActionForward execute(ActionMapping mapping, ActionForm objForm, |
| 23 |
|
HttpServletRequest request, HttpServletResponse res) |
| 24 |
|
throws IllegalAccessException, InvocationTargetException { |
| 25 |
|
|
| 26 |
8 |
String id = request.getParameter("id"); |
| 27 |
|
|
| 28 |
|
try { |
| 29 |
8 |
UserService userService = ServiceLocator.getServiceLocator().getUserService(); |
| 30 |
8 |
UserView user = userService.getUser(id); |
| 31 |
4 |
BeanUtils.copyProperties(objForm, user); |
| 32 |
4 |
return mapping.findForward("success"); |
| 33 |
|
} |
| 34 |
|
catch (UnknownUserException e) { |
| 35 |
4 |
ActionErrors errors = new ActionErrors(); |
| 36 |
4 |
errors.add("id", new ActionError("user.edit.unknown.user")); |
| 37 |
4 |
saveErrors(request, errors); |
| 38 |
4 |
return mapping.findForward("failure"); |
| 39 |
|
} |
| 40 |
|
} |
| 41 |
|
} |