1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
package org.demosys.web.user.action; |
7 |
|
import javax.servlet.http.HttpServletRequest; |
8 |
|
import javax.servlet.http.HttpServletResponse; |
9 |
|
import org.apache.struts.action.*; |
10 |
|
import org.demosys.web.ServiceLocator; |
11 |
|
import org.demosys.web.user.UnknownUserException; |
12 |
|
import org.demosys.web.user.UserService; |
13 |
|
|
14 |
|
|
15 |
|
|
16 |
8 |
public class DeleteUserAction extends Action { |
17 |
|
public ActionForward execute(ActionMapping mapping, ActionForm objForm, |
18 |
|
HttpServletRequest request, HttpServletResponse res) { |
19 |
|
|
20 |
8 |
String id = request.getParameter("id"); |
21 |
|
|
22 |
|
try { |
23 |
8 |
UserService userService = ServiceLocator.getServiceLocator().getUserService(); |
24 |
8 |
userService.deleteUser(id); |
25 |
4 |
return mapping.findForward("success"); |
26 |
|
} |
27 |
|
catch (UnknownUserException e) { |
28 |
4 |
ActionErrors errors = new ActionErrors(); |
29 |
4 |
errors.add("id", new ActionError("user.delete.unknown.user")); |
30 |
4 |
saveErrors(request, errors); |
31 |
4 |
return mapping.findForward("failure"); |
32 |
|
} |
33 |
|
} |
34 |
|
} |