/sun/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailboxManager.java |
---|
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 |
{ |
/sun/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAliasManager.java |
---|
70,6 → 70,33 |
return alias; |
} |
public boolean addressExists(User editor, MailAlias alias, String address) |
throws ModelException |
{ |
if(alias.getDomain() == null) |
throw new ModelException("Cannot check unique address for mail alias without domain"); |
try { |
if(alias.getId() == null) |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from MailAlias where address = ? and domain = ?", |
new Object[] { address, alias.getDomain() }, |
new Type[] { Hibernate.STRING, Hibernate.entity(InetDomain.class) } ) |
.next()).intValue() > 0; |
else |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from MailAlias a where address = ? and domain = ? and a != ?", |
new Object[] { address, alias.getDomain(), alias }, |
new Type[] { Hibernate.STRING, Hibernate.entity(InetDomain.class), |
Hibernate.entity(MailAlias.class) } ) |
.next()).intValue() > 0; |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
protected MailAlias findForName(String name) |
throws ModelException |
{ |