37,7 → 37,8 |
throws Exception |
{ |
if("submit".equals(mapping.getParameter())) { |
initLists(request); |
User user = (User)request.getSession().getAttribute("user"); |
initLists(request, user); |
} |
} |
|
47,9 → 48,11 |
{ |
User user = (User)request.getSession().getAttribute("user"); |
if("list".equals(mapping.getParameter())) { |
List list = new ArrayList(MailboxManager.getInstance().listMailboxes()); |
List list = new ArrayList(MailboxManager.getInstance().listMailboxes(user)); |
Collections.sort(list, MailboxManager.LOGIN_COMPARATOR); |
request.setAttribute("mailboxes", list); |
request.setAttribute("allowedToCreate", |
new Boolean(MailboxManager.getInstance().allowedToCreate(user))); |
|
return mapping.findForward("default"); |
} |
63,7 → 66,7 |
showForm.set("enabled", new Boolean(true)); |
} |
else { |
Mailbox mailbox = MailboxManager.getInstance().get(boxId); |
Mailbox mailbox = MailboxManager.getInstance().get(user, boxId); |
showForm.set("login", mailbox.getLogin()); |
if(mailbox.getDomain() != null) |
showForm.set("domain", StringConverter.toString(mailbox.getDomain().getId())); |
77,15 → 80,15 |
showForm.set("comment", mailbox.getComment()); |
} |
|
initLists(request); |
initLists(request, user); |
return mapping.findForward("default"); |
} |
else if("delete".equals(mapping.getParameter())) { |
DynaActionForm theForm = (DynaActionForm)form; |
Long boxId = StringConverter.parseLong(theForm.get("id")); |
Mailbox mailbox = MailboxManager.getInstance().get(boxId); |
Mailbox mailbox = MailboxManager.getInstance().get(user, boxId); |
|
MailboxManager.getInstance().delete(mailbox); |
MailboxManager.getInstance().delete(user, mailbox); |
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl()); |
return null; |
} |
99,16 → 102,16 |
if(password == null || password.equals("")) |
throw new Exception("empty password"); // FIXME: exception type and message? |
|
mailbox = MailboxManager.getInstance().create(); |
mailbox = MailboxManager.getInstance().create(user); |
|
// FIXME: create an user as owner of the new mailbox here |
} |
else { |
mailbox = MailboxManager.getInstance().get(boxId); |
mailbox = MailboxManager.getInstance().get(user, boxId); |
} |
|
mailbox.setLogin((String)theForm.get("login")); |
mailbox.setDomain(InetDomainManager.getInstance().get( |
mailbox.setDomain(InetDomainManager.getInstance().get(user, |
StringConverter.parseLong(theForm.get("domain")))); |
mailbox.setOwner(UserManager.getInstance().get( |
StringConverter.parseLong(theForm.get("owner")))); |
120,7 → 123,7 |
mailbox.setSystemUser(null); |
} |
else { |
mailbox.setSystemUser(SystemUserManager.getInstance().get(systemUserId)); |
mailbox.setSystemUser(SystemUserManager.getInstance().get(user, systemUserId)); |
} |
|
if(password != null && !password.equals("")) |
129,7 → 132,7 |
mailbox.setEnabled((Boolean)theForm.get("enabled")); |
mailbox.setComment((String)theForm.get("comment")); |
|
MailboxManager.getInstance().save(mailbox); |
MailboxManager.getInstance().save(user, mailbox); |
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl()); |
return null; |
} |
138,7 → 141,7 |
} |
} |
|
private void initLists(HttpServletRequest request) |
private void initLists(HttpServletRequest request, User user) |
throws Exception |
{ |
List users = new ArrayList(UserManager.getInstance().listUsers()); |
145,11 → 148,11 |
Collections.sort(users, UserManager.LOGIN_COMPARATOR); |
request.setAttribute("users", users); |
|
List systemUsers = new ArrayList(SystemUserManager.getInstance().listSystemUsers()); |
List systemUsers = new ArrayList(SystemUserManager.getInstance().listSystemUsers(user)); |
Collections.sort(systemUsers, SystemUserManager.UID_COMPARATOR); |
request.setAttribute("systemusers", systemUsers); |
|
List domains = new ArrayList(InetDomainManager.getInstance().listInetDomains()); |
List domains = new ArrayList(InetDomainManager.getInstance().listInetDomains(user)); |
Collections.sort(domains, InetDomainManager.NAME_COMPARATOR); |
request.setAttribute("domains", domains); |
} |