68,6 → 68,33 |
return mailbox; |
} |
|
public boolean loginExists(User editor, Mailbox mailbox, String login) |
throws ModelException |
{ |
if(mailbox.getDomain() == null) |
throw new ModelException("Cannot check unique login for mailbox without domain"); |
|
try { |
if(mailbox.getId() == null) |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from Mailbox where login = ? and domain = ?", |
new Object[] { login, mailbox.getDomain() }, |
new Type[] { Hibernate.STRING, Hibernate.entity(InetDomain.class) } ) |
.next()).intValue() > 0; |
else |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from Mailbox b where login = ? and domain = ? and b != ?", |
new Object[] { login, mailbox.getDomain(), mailbox }, |
new Type[] { Hibernate.STRING, Hibernate.entity(InetDomain.class), |
Hibernate.entity(Mailbox.class) } ) |
.next()).intValue() > 0; |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
|
protected Mailbox findForLogin(String login) |
throws ModelException |
{ |