17,16 → 17,28 |
import org.apache.struts.action.ActionError; |
|
import ak.strutsx.RequestUtilsX; |
import ak.strutsx.ErrorHandlerX; |
import ak.backpath.BackPath; |
|
import ak.hostcaptain.util.StringConverter; |
import ak.hostcaptain.core.model.User; |
import ak.hostcaptain.core.model.UserManager; |
import ak.hostcaptain.core.model.SystemUser; |
import ak.hostcaptain.core.model.SystemUserManager; |
|
public final class SystemUserAction |
extends Action |
implements ErrorHandlerX |
{ |
public void handleErrors(ActionMapping mapping, ActionForm form, |
HttpServletRequest request, HttpServletResponse response) |
throws Exception |
{ |
if("submit".equals(mapping.getParameter())) { |
initUserList(request); |
} |
} |
|
public ActionForward execute(ActionMapping mapping, ActionForm form, |
HttpServletRequest request, HttpServletResponse response) |
throws Exception |
51,10 → 63,13 |
} |
else { |
SystemUser u = SystemUserManager.getInstance().get(userId); |
showForm.set("uid", StringConverter.toString(u.getUid())); |
showForm.set("name", u.getName()); |
showForm.set("uid", StringConverter.toString(u.getUid())); |
showForm.set("name", u.getName()); |
if(u.getOwner() != null) |
showForm.set("owner", StringConverter.toString(u.getOwner().getId())); |
} |
|
initUserList(request); |
return mapping.findForward("default"); |
} |
else if("delete".equals(mapping.getParameter())) { |
80,6 → 95,12 |
|
u.setUid(StringConverter.parseInteger(theForm.get("uid"))); |
u.setName((String)theForm.get("name")); |
|
Long ownerId = StringConverter.parseLong(theForm.get("owner")); |
if(ownerId == null) |
u.setOwner(null); |
else |
u.setOwner(UserManager.getInstance().get(ownerId)); |
|
SystemUserManager.getInstance().save(u); |
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl()); |
89,4 → 110,12 |
throw new Exception("unknown mapping parameter"); |
} |
} |
|
private void initUserList(HttpServletRequest request) |
throws Exception |
{ |
List list = new ArrayList(UserManager.getInstance().listUsers()); |
Collections.sort(list, UserManager.LOGIN_COMPARATOR); |
request.setAttribute("users", list); |
} |
} |