/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/InetDomainAction.java |
---|
35,8 → 35,7 |
throws Exception |
{ |
if("submit".equals(mapping.getParameter())) { |
User user = (User)request.getSession().getAttribute("user"); |
initUserList(request, user); |
initUserList(request); |
} |
} |
73,7 → 72,7 |
showForm.set("comment", domain.getComment()); |
} |
initUserList(request, user); |
initUserList(request); |
return mapping.findForward("default"); |
} |
else if("delete".equals(mapping.getParameter())) { |
98,7 → 97,7 |
} |
domain.setName((String)theForm.get("name")); |
domain.setOwner(UserManager.getInstance().get(user, |
domain.setOwner(UserManager.getInstance().get( |
StringConverter.parseLong(theForm.get("owner")))); |
domain.setEnabled((Boolean)theForm.get("enabled")); |
113,10 → 112,10 |
} |
} |
private void initUserList(HttpServletRequest request, User user) |
private void initUserList(HttpServletRequest request) |
throws Exception |
{ |
List list = new ArrayList(UserManager.getInstance().listUsers(user)); |
List list = new ArrayList(UserManager.getInstance().listUsers()); |
Collections.sort(list, UserManager.LOGIN_COMPARATOR); |
request.setAttribute("users", list); |
} |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/MailboxAction.java |
---|
21,8 → 21,6 |
import ak.backpath.BackPath; |
import ak.hostcaptain.util.StringConverter; |
import ak.hostcaptain.util.UserException; |
import ak.hostcaptain.core.CoreResources; |
import ak.hostcaptain.core.model.User; |
import ak.hostcaptain.core.model.UserManager; |
import ak.hostcaptain.core.model.Mailbox; |
65,9 → 63,7 |
this, request, "ak.hostcaptain.core.form.MailboxEditForm"); |
if(boxId == null) { |
showForm.set("enabled", new Boolean(true)); |
showForm.set("viruscheck", new Boolean(true)); |
showForm.set("spamcheck", new Boolean(true)); |
showForm.set("enabled", new Boolean(true)); |
} |
else { |
Mailbox mailbox = MailboxManager.getInstance().get(user, boxId); |
104,7 → 100,7 |
if(boxId == null) { |
if(password == null || password.equals("")) |
throw new UserException(CoreResources.PASSWORD_REQUIRED); |
throw new Exception("empty password"); // FIXME: exception type and message? |
mailbox = MailboxManager.getInstance().create(user); |
117,7 → 113,7 |
mailbox.setLogin((String)theForm.get("login")); |
mailbox.setDomain(InetDomainManager.getInstance().get(user, |
StringConverter.parseLong(theForm.get("domain")))); |
mailbox.setOwner(UserManager.getInstance().get(user, |
mailbox.setOwner(UserManager.getInstance().get( |
StringConverter.parseLong(theForm.get("owner")))); |
mailbox.setVirusCheck((Boolean)theForm.get("viruscheck")); |
mailbox.setSpamCheck((Boolean)theForm.get("spamcheck")); |
148,7 → 144,7 |
private void initLists(HttpServletRequest request, User user) |
throws Exception |
{ |
List users = new ArrayList(UserManager.getInstance().listUsers(user)); |
List users = new ArrayList(UserManager.getInstance().listUsers()); |
Collections.sort(users, UserManager.LOGIN_COMPARATOR); |
request.setAttribute("users", users); |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/MailAliasAction.java |
---|
24,7 → 24,6 |
import ak.backpath.BackPath; |
import ak.hostcaptain.util.StringConverter; |
import ak.hostcaptain.util.UserException; |
import ak.hostcaptain.core.model.User; |
import ak.hostcaptain.core.model.UserManager; |
import ak.hostcaptain.core.model.Mailbox; |
76,11 → 75,11 |
} |
else { |
MailAlias alias = MailAliasManager.getInstance().get(user, aliasId); |
List dests = new ArrayList(MailAliasDestinationManager.getInstance() |
.listMailAliasesDestination(alias)); |
List dests = new ArrayList(MailAliasDestinationManager.getInstance() |
.listMailAliasesDestination(alias)); |
MailAliasDestBean[] d = new MailAliasDestBean[dests.size()]; |
// FIXME: sort dests here |
// FIXME: sort dests here |
for(int i = 0; i < dests.size(); i++) { |
d[i] = new MailAliasDestBean((MailAliasDestination)dests.get(i)); |
87,11 → 86,11 |
} |
showForm.set("dests", d); |
showForm.set("address", alias.getAddress()); |
if(alias.getDomain() != null) |
showForm.set("domain", StringConverter.toString(alias.getDomain().getId())); |
if(alias.getOwner() != null) |
showForm.set("owner", StringConverter.toString(alias.getOwner().getId())); |
showForm.set("address", alias.getAddress()); |
if(alias.getDomain() != null) |
showForm.set("domain", StringConverter.toString(alias.getDomain().getId())); |
if(alias.getOwner() != null) |
showForm.set("owner", StringConverter.toString(alias.getOwner().getId())); |
showForm.set("enabled", alias.getEnabled()); |
showForm.set("comment", alias.getComment()); |
} |
112,22 → 111,11 |
DynaActionForm theForm = (DynaActionForm)form; |
Long aliasId = StringConverter.parseLong(theForm.get("id")); |
MailAlias alias = (aliasId == null) ? null |
: MailAliasManager.getInstance().get(user, aliasId); |
: MailAliasManager.getInstance().get(user, aliasId); |
MailAliasDestBean[] dests = (MailAliasDestBean[])theForm.get("dests"); |
// submit |
// submit |
if(request.getParameter("submit") != null) { |
// FIXME: if empty element of select box is active, it will be changed |
// by submit |
// validate required fields, because it cannot be done in general case |
if(StringConverter.isEmpty(theForm.get("address"))) |
throw new UserException("ak.hostcaptain.core.mail.alias.edit.address.empty"); |
if(StringConverter.isEmpty(theForm.get("domain"))) |
throw new UserException("ak.hostcaptain.core.mail.alias.edit.domain.wrong"); |
if(StringConverter.isEmpty(theForm.get("owner"))) |
throw new UserException("ak.hostcaptain.core.mail.alias.edit.owner.wrong"); |
if(alias == null) |
alias = MailAliasManager.getInstance().create(user); |
140,38 → 128,35 |
&& (dests[i].getEmail() == null || dests[i].getEmail().equals(""))) |
continue; |
// get bean |
Long destId = StringConverter.parseLong(dests[i].getId()); |
Long mailboxId = StringConverter.parseLong(dests[i].getMailbox()); |
// get bean |
Long destId = StringConverter.parseLong(dests[i].getId()); |
Long mailboxId = StringConverter.parseLong(dests[i].getMailbox()); |
MailAliasDestination dest; |
if(destId == null) |
dest = MailAliasDestinationManager.getInstance().create(user); |
else |
dest = MailAliasDestinationManager.getInstance().get(user, destId); |
dest = MailAliasDestinationManager.getInstance().create(); |
else |
dest = MailAliasDestinationManager.getInstance().get(destId); |
// set mailbox or email |
// set mailbox or email |
if(mailboxId != null) { |
dest.setMailbox(MailboxManager.getInstance().get(user, mailboxId)); |
dest.setEmail(null); |
} |
else if(dests[i].getEmail() != null && !dests[i].getEmail().equals("")) { |
else if(dests[i].getEmail() != null && !dests[i].getEmail().equals("")) { |
dest.setMailbox(null); |
dest.setEmail(dests[i].getEmail()); |
} |
dest.setEnabled(dests[i].getEnabled()); |
dest.setComment(dests[i].getComment()); |
// connect |
dest.setAlias(alias); |
// connect |
dest.setAlias(alias); |
alias.getDestinations().add(dest); |
} |
alias.setAddress((String)theForm.get("address")); |
alias.setDomain(InetDomainManager.getInstance().get(user, |
StringConverter.parseLong(theForm.get("domain")))); |
alias.setOwner(UserManager.getInstance().get(user, |
StringConverter.parseLong(theForm.get("owner")))); |
alias.setAddress((String)theForm.get("address")); |
alias.setDomain(InetDomainManager.getInstance().get(user, |
StringConverter.parseLong(theForm.get("domain")))); |
alias.setOwner(UserManager.getInstance().get( |
StringConverter.parseLong(theForm.get("owner")))); |
alias.setEnabled((Boolean)theForm.get("enabled")); |
alias.setComment((String)theForm.get("comment")); |
184,13 → 169,9 |
// add |
else if(request.getParameter("add") != null) { |
// FIXME: if called when no entries defined two rows are created |
MailAliasDestBean[] newDests = new MailAliasDestBean[dests.length+1]; |
if(dests.length > 0) |
System.arraycopy(dests, 0, newDests, 0, dests.length); |
System.arraycopy(dests, 0, newDests, 0, dests.length); |
newDests[dests.length] = new MailAliasDestBean(); |
newDests[dests.length].setEnabled(new Boolean(true)); |
theForm.set("dests", newDests); |
initLists(request, user); |
211,13 → 192,20 |
if(n < 0 || n >= dests.length) break; |
MailAliasDestBean[] newDests; |
newDests = new MailAliasDestBean[dests.length-1]; |
if(n > 0) |
System.arraycopy(dests, 0, newDests, 0, n); |
if(n < dests.length-1) |
System.arraycopy(dests, n+1, newDests, |
n, dests.length-n-1); |
if(dests.length <= 1) { |
newDests = new MailAliasDestBean[1]; |
newDests[0] = new MailAliasDestBean(); |
} |
else { |
newDests = new MailAliasDestBean[dests.length-1]; |
if(n > 0) |
System.arraycopy(dests, 0, newDests, 0, n); |
if(n < dests.length-1) |
System.arraycopy(dests, n+1, newDests, |
n, dests.length-n-1); |
} |
theForm.set("dests", newDests); |
break; |
} |
catch(NumberFormatException ex) { |
238,12 → 226,12 |
private void initLists(HttpServletRequest request, User user) |
throws Exception |
{ |
// list of mailboxes to redirect to |
// list of mailboxes to redirect to |
List mailboxes = new ArrayList(MailboxManager.getInstance().listMailboxes(user)); |
Collections.sort(mailboxes, MailboxManager.LOGIN_COMPARATOR); |
request.setAttribute("mailboxes", mailboxes); |
List users = new ArrayList(UserManager.getInstance().listUsers(user)); |
List users = new ArrayList(UserManager.getInstance().listUsers()); |
Collections.sort(users, UserManager.LOGIN_COMPARATOR); |
request.setAttribute("users", users); |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/SystemUserAction.java |
---|
35,8 → 35,7 |
throws Exception |
{ |
if("submit".equals(mapping.getParameter())) { |
User user = (User)request.getSession().getAttribute("user"); |
initUserList(request, user); |
initUserList(request); |
} |
} |
74,7 → 73,7 |
showForm.set("comment", u.getComment()); |
} |
initUserList(request, user); |
initUserList(request); |
return mapping.findForward("default"); |
} |
else if("delete".equals(mapping.getParameter())) { |
105,7 → 104,7 |
if(ownerId == null) |
u.setOwner(null); |
else |
u.setOwner(UserManager.getInstance().get(user, ownerId)); |
u.setOwner(UserManager.getInstance().get(ownerId)); |
u.setEnabled((Boolean)theForm.get("enabled")); |
u.setComment((String)theForm.get("comment")); |
119,10 → 118,10 |
} |
} |
private void initUserList(HttpServletRequest request, User user) |
private void initUserList(HttpServletRequest request) |
throws Exception |
{ |
List list = new ArrayList(UserManager.getInstance().listUsers(user)); |
List list = new ArrayList(UserManager.getInstance().listUsers()); |
Collections.sort(list, UserManager.LOGIN_COMPARATOR); |
request.setAttribute("users", list); |
} |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/UserAction.java |
---|
35,8 → 35,7 |
throws Exception |
{ |
if("submit".equals(mapping.getParameter())) { |
User user = (User)request.getSession().getAttribute("user"); |
initUserList(request, user); |
initUserList(request); |
} |
} |
47,7 → 46,7 |
User user = (User)request.getSession().getAttribute("user"); |
if("list".equals(mapping.getParameter())) { |
List list = new ArrayList(UserManager.getInstance().listUsers(user)); |
List list = new ArrayList(UserManager.getInstance().listUsers()); |
Collections.sort(list, UserManager.LOGIN_COMPARATOR); |
request.setAttribute("users", list); |
63,7 → 62,7 |
showForm.set("enabled", new Boolean(true)); |
} |
else { |
User u = UserManager.getInstance().get(user, userId); |
User u = UserManager.getInstance().get(userId); |
showForm.set("login", u.getLogin()); |
if(u.getBoss() != null) |
showForm.set("boss", StringConverter.toString(u.getBoss().getId())); |
72,13 → 71,13 |
showForm.set("comment", u.getComment()); |
} |
initUserList(request, user); |
initUserList(request); |
return mapping.findForward("default"); |
} |
else if("delete".equals(mapping.getParameter())) { |
DynaActionForm theForm = (DynaActionForm)form; |
Long userId = StringConverter.parseLong(theForm.get("id")); |
User u = UserManager.getInstance().get(user, userId); |
User u = UserManager.getInstance().get(userId); |
if(u.equals(user)) |
throw new UserException(CoreResources.DELETE_ME_SELF); |
86,7 → 85,7 |
// FIXME: invalidate session of deleted user if it is logged in |
// FIXME: if two admins delete each other at the same time |
UserManager.getInstance().delete(user, u); |
UserManager.getInstance().delete(u); |
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl()); |
return null; |
} |
100,10 → 99,10 |
if(password == null || password.equals("")) |
throw new UserException(CoreResources.PASSWORD_REQUIRED); |
u = UserManager.getInstance().create(user); |
u = UserManager.getInstance().create(); |
} |
else { |
u = UserManager.getInstance().get(user, userId); |
u = UserManager.getInstance().get(userId); |
} |
u.setLogin((String)theForm.get("login")); |
112,7 → 111,7 |
if(bossId == null) |
u.setBoss(null); |
else |
u.setBoss(UserManager.getInstance().get(user, bossId)); |
u.setBoss(UserManager.getInstance().get(bossId)); |
if(!user.equals(u)) // do not allow user to change own superuser status |
u.setSuperuser((Boolean)theForm.get("superuser")); |
123,7 → 122,7 |
u.setEnabled((Boolean)theForm.get("enabled")); |
u.setComment((String)theForm.get("comment")); |
UserManager.getInstance().save(user, u); |
UserManager.getInstance().save(u); |
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl()); |
return null; |
} |
132,10 → 131,10 |
} |
} |
private void initUserList(HttpServletRequest request, User user) |
private void initUserList(HttpServletRequest request) |
throws Exception |
{ |
List list = new ArrayList(UserManager.getInstance().listUsers(user)); |
List list = new ArrayList(UserManager.getInstance().listUsers()); |
Collections.sort(list, UserManager.LOGIN_COMPARATOR); |
request.setAttribute("users", list); |
} |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/ChangePasswordAction.java |
---|
35,7 → 35,7 |
if(user.checkPassword((String)theForm.get("oldpassword"))) { |
user.setNewPassword((String)theForm.get("password")); |
UserManager.getInstance().save(user, user); // FIXME: allow user to change own password |
UserManager.getInstance().save(user); |
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl()); |
return null; |
} |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/CoreResources.properties |
---|
83,8 → 83,8 |
ak.hostcaptain.page.user.password.change.old_password=Old password |
ak.hostcaptain.page.user.password.change.new_password=New password |
ak.hostcaptain.page.user.password.change.new_password_again=New password again |
ak.hostcaptain.page.user.password.change.submit=submit |
ak.hostcaptain.page.user.password.change.back=back |
ak.hostcaptain.page.user.password.change.submit=Change |
ak.hostcaptain.page.user.password.change.cancel=Cancel |
ak.hostcaptain.page.user.list.title=hostcaptain - users - list |
ak.hostcaptain.page.user.list.login=Login |
149,6 → 149,33 |
ak.hostcaptain.page.domain.edit.submit=submit |
ak.hostcaptain.page.domain.edit.back=back |
ak.hostcaptain.page.mail.alias.list.title=hostcaptain - mail aliases - list |
ak.hostcaptain.page.mail.alias.list.alias=Alias |
ak.hostcaptain.page.mail.alias.list.domain=Domain |
ak.hostcaptain.page.mail.alias.list.owner=Owner |
ak.hostcaptain.page.mail.alias.list.enabled=Enabled |
ak.hostcaptain.page.mail.alias.list.edit=edit |
ak.hostcaptain.page.mail.alias.list.view=view |
ak.hostcaptain.page.mail.alias.list.delete=delete |
ak.hostcaptain.page.mail.alias.list.back=back |
ak.hostcaptain.page.mail.alias.list.add=add new mail alias |
ak.hostcaptain.page.mail.alias.edit.title=hostcaptain - mail alias - edit |
ak.hostcaptain.page.mail.alias.edit.address=Address |
ak.hostcaptain.page.mail.alias.edit.domain=Domain |
ak.hostcaptain.page.mail.alias.edit.domain.empty=-- please select -- |
ak.hostcaptain.page.mail.alias.edit.owner=Owner |
ak.hostcaptain.page.mail.alias.edit.owner.empty=-- please select -- |
ak.hostcaptain.page.mail.alias.edit.enabled=Enabled |
ak.hostcaptain.page.mail.alias.edit.comment=Comment |
ak.hostcaptain.page.mail.alias.edit.header.tomailbox=To mailbox |
ak.hostcaptain.page.mail.alias.edit.header.toexternal=or to external email |
ak.hostcaptain.page.mail.alias.edit.external=external redirect |
ak.hostcaptain.page.mail.alias.edit.add=add new destination |
ak.hostcaptain.page.mail.alias.edit.delete=delete |
ak.hostcaptain.page.mail.alias.edit.submit=submit |
ak.hostcaptain.page.mail.alias.edit.cancel=cancel |
ak.hostcaptain.page.mail.box.list.title=hostcaptain - mail boxes - list |
ak.hostcaptain.page.mail.box.list.login=Box |
ak.hostcaptain.page.mail.box.list.domain=Domain |
167,7 → 194,7 |
ak.hostcaptain.page.mail.box.edit.domain=Domain |
ak.hostcaptain.page.mail.box.edit.domain.empty=-- please select -- |
ak.hostcaptain.page.mail.box.edit.owner=Owner |
ak.hostcaptain.page.mail.box.edit.owner.empty=-- create an user -- |
ak.hostcaptain.page.mail.box.edit.owner.empty=-- please select -- |
ak.hostcaptain.page.mail.box.edit.systemuser=System user |
ak.hostcaptain.page.mail.box.edit.systemuser.empty=-- please select -- |
ak.hostcaptain.page.mail.box.edit.viruscheck=check mails for viruses |
176,32 → 203,3 |
ak.hostcaptain.page.mail.box.edit.comment=Comment |
ak.hostcaptain.page.mail.box.edit.submit=submit |
ak.hostcaptain.page.mail.box.edit.back=back |
ak.hostcaptain.page.mail.alias.list.title=hostcaptain - mail aliases - list |
ak.hostcaptain.page.mail.alias.list.alias=Alias |
ak.hostcaptain.page.mail.alias.list.domain=Domain |
ak.hostcaptain.page.mail.alias.list.owner=Owner |
ak.hostcaptain.page.mail.alias.list.enabled=Enabled |
ak.hostcaptain.page.mail.alias.list.edit=edit |
ak.hostcaptain.page.mail.alias.list.view=view |
ak.hostcaptain.page.mail.alias.list.delete=delete |
ak.hostcaptain.page.mail.alias.list.back=back |
ak.hostcaptain.page.mail.alias.list.add=add new mail alias |
ak.hostcaptain.page.mail.alias.edit.title=hostcaptain - mail alias - edit |
ak.hostcaptain.page.mail.alias.edit.address=Address |
ak.hostcaptain.page.mail.alias.edit.domain=Domain |
ak.hostcaptain.page.mail.alias.edit.domain.empty=-- please select -- |
ak.hostcaptain.page.mail.alias.edit.owner=Owner |
ak.hostcaptain.page.mail.alias.edit.owner.empty=-- please select -- |
ak.hostcaptain.page.mail.alias.edit.enabled=Enabled |
ak.hostcaptain.page.mail.alias.edit.comment=Comment |
ak.hostcaptain.page.mail.alias.edit.header.tomailbox=To mailbox |
ak.hostcaptain.page.mail.alias.edit.header.toexternal=or to external email |
ak.hostcaptain.page.mail.alias.edit.header.enabled=Enabled |
ak.hostcaptain.page.mail.alias.edit.header.comment=Comment |
ak.hostcaptain.page.mail.alias.edit.external=external redirect |
ak.hostcaptain.page.mail.alias.edit.add=add new destination |
ak.hostcaptain.page.mail.alias.edit.delete=delete |
ak.hostcaptain.page.mail.alias.edit.submit=submit |
ak.hostcaptain.page.mail.alias.edit.back=back |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/SystemUserManager.java |
---|
137,14 → 137,12 |
throws ModelException |
{ |
try { |
if(editor.isSuperuser()) { |
if(editor.isSuperuser()) |
return HibernateUtil.currentSession().find("from SystemUser"); |
} |
else { |
else |
return HibernateUtil.currentSession().find( |
"select u from SystemUser u left join u.owner o where o is null or o=?", |
editor, Hibernate.entity(User.class)); |
} |
} |
catch(HibernateException ex) |
{ |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/User.java |
---|
164,12 → 164,12 |
public boolean viewableBy(User user) |
{ |
return user.isSuperuser() || user.equals(boss) || user.equals(this); |
return user.isSuperuser() || user.equals(boss); |
} |
public boolean editableBy(User user) |
{ |
return user.isSuperuser() || user.equals(boss); |
return user.isSuperuser(); |
} |
public boolean deleteableBy(User user) |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/UserManager.java |
---|
2,10 → 2,8 |
import java.util.*; |
import net.sf.hibernate.*; |
import net.sf.hibernate.type.Type; |
import ak.hostcaptain.util.HibernateUtil; |
import ak.hostcaptain.util.ModelException; |
import ak.hostcaptain.util.ModelSecurityException; |
public class UserManager |
{ |
35,37 → 33,21 |
{ |
} |
public User create(User editor) |
throws ModelException |
public User create() |
{ |
if(!allowedToCreate(editor)) throw new ModelSecurityException(); |
return new User(); |
} |
public boolean allowedToCreate(User editor) |
public User get(Long id) |
throws ModelException |
{ |
return editor.isSuperuser(); |
} |
public User get(User editor, Long id) |
throws ModelException |
{ |
User user; |
try { |
user = (User)HibernateUtil.currentSession().load(User.class, id); |
return (User)HibernateUtil.currentSession().load(User.class, id); |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
if(!user.viewableBy(editor)) |
throw new ModelSecurityException(); |
return user; |
} |
public User findForLogin(String login) |
86,12 → 68,9 |
} |
} |
public void save(User editor, User user) |
public void save(User user) |
throws ModelException |
{ |
if(!user.editableBy(editor)) |
throw new ModelSecurityException(); |
try { |
HibernateUtil.currentSession().saveOrUpdate(user); |
} |
101,12 → 80,9 |
} |
} |
public void delete(User editor, User user) |
public void delete(User user) |
throws ModelException |
{ |
if(!user.deleteableBy(editor)) |
throw new ModelSecurityException(); |
try { |
HibernateUtil.currentSession().delete(user); |
} |
116,19 → 92,11 |
} |
} |
public Collection listUsers(User editor) |
public Collection listUsers() |
throws ModelException |
{ |
try { |
if(editor.isSuperuser()) { |
return HibernateUtil.currentSession().find("from User"); |
} |
else { |
return HibernateUtil.currentSession().find( |
"from User u where u = ? or u.boss = ?", |
new Object[] { editor, editor}, |
new Type[] { Hibernate.entity(User.class), Hibernate.entity(User.class) } ); |
} |
return HibernateUtil.currentSession().find("from User"); |
} |
catch(HibernateException ex) |
{ |
136,27 → 104,6 |
} |
} |
public boolean areSystemUsersAvailable(User editor) |
throws ModelException |
{ |
try { |
if(editor.isSuperuser()) { |
return true; |
} |
else { |
return ((Integer)HibernateUtil.currentSession().iterate( |
"from User u where u = ? or u.boss = ?", |
new Object[] { editor, editor}, |
new Type[] { Hibernate.entity(User.class), Hibernate.entity(User.class) } ) |
.next()).intValue() > 0; |
} |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public User loginUser(String login, String password) |
throws ModelException |
{ |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/MailAliasDestinationManager.java |
---|
4,7 → 4,6 |
import net.sf.hibernate.*; |
import ak.hostcaptain.util.HibernateUtil; |
import ak.hostcaptain.util.ModelException; |
import ak.hostcaptain.util.ModelSecurityException; |
public class MailAliasDestinationManager |
{ |
34,27 → 33,16 |
{ |
} |
public MailAliasDestination create(User editor) |
throws ModelException |
public MailAliasDestination create() |
{ |
if(!allowedToCreate(editor)) throw new ModelSecurityException(); |
return new MailAliasDestination(); |
} |
public boolean allowedToCreate(User editor) |
public MailAliasDestination get(Long id) |
throws ModelException |
{ |
return true; |
} |
public MailAliasDestination get(User editor, Long id) |
throws ModelException |
{ |
MailAliasDestination dest; |
try { |
dest = (MailAliasDestination)HibernateUtil.currentSession() |
return (MailAliasDestination)HibernateUtil.currentSession() |
.load(MailAliasDestination.class, id); |
} |
catch(HibernateException ex) |
61,19 → 49,11 |
{ |
throw new ModelException(ex); |
} |
if(!dest.viewableBy(editor)) |
throw new ModelSecurityException(); |
return dest; |
} |
public void save(User editor, MailAliasDestination mailAliasDestination) |
public void save(MailAliasDestination mailAliasDestination) |
throws ModelException |
{ |
if(!mailAliasDestination.editableBy(editor)) |
throw new ModelSecurityException(); |
try { |
HibernateUtil.currentSession().saveOrUpdate(mailAliasDestination); |
} |
83,12 → 63,9 |
} |
} |
public void delete(User editor, MailAliasDestination mailAliasDestination) |
public void delete(MailAliasDestination mailAliasDestination) |
throws ModelException |
{ |
if(!mailAliasDestination.deleteableBy(editor)) |
throw new ModelSecurityException(); |
try { |
HibernateUtil.currentSession().delete(mailAliasDestination); |
} |
98,6 → 75,11 |
} |
} |
public Collection listMailAliasesDestination() |
{ |
return null; |
} |
public Collection listMailAliasesDestination(MailAlias alias) |
throws ModelException |
{ |
112,12 → 94,6 |
} |
} |
public boolean areMailAliasesDestinationsAvailable(User editor) |
throws ModelException |
{ |
return true; |
} |
private static MailAliasDestinationManager mailAliasDestinationManager = null; |
public static MailAliasDestinationManager getInstance() |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/taglib/WriteTag.java |
---|
File deleted |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/form/MailAliasDestBean.java |
---|
5,11 → 5,9 |
public final class MailAliasDestBean |
{ |
private String id; |
private String mailbox; |
private String email; |
private Boolean enabled; |
private String comment; |
private String id; |
private String mailbox; |
private String email; |
public MailAliasDestBean() |
{ |
21,8 → 19,6 |
this.mailbox = (dest.getMailbox() == null) |
? null : StringConverter.toString(dest.getMailbox().getId()); |
this.email = dest.getEmail(); |
this.enabled = dest.getEnabled(); |
this.comment = dest.getComment(); |
} |
public String getId() |
54,24 → 50,4 |
{ |
this.email = email; |
} |
public Boolean getEnabled() |
{ |
return enabled; |
} |
public void setEnabled(Boolean enabled) |
{ |
this.enabled = enabled; |
} |
public String getComment() |
{ |
return comment; |
} |
public void setComment(String comment) |
{ |
this.comment = comment; |
} |
} |
/sun/hostcaptain/trunk/src/ak/hostcaptain/util/StringConverter.java |
---|
2,16 → 2,6 |
public abstract class StringConverter |
{ |
public static boolean isEmpty(Object o) |
{ |
if(o == null) |
return true; |
else if((o instanceof String) && ((String)o).equals("")) |
return true; |
else |
return false; |
} |
public static Long parseLong(Object o) |
throws NumberFormatException |
{ |