/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/SystemUserManager.java |
---|
2,6 → 2,7 |
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; |
67,6 → 68,50 |
return user; |
} |
public boolean nameExists(User editor, SystemUser user, String name) |
throws ModelException |
{ |
try { |
if(user.getId() == null) |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from SystemUser u where name = ?", |
name, Hibernate.STRING) |
.next()).intValue() > 0; |
else |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from SystemUser u where name = ? and u != ?", |
new Object[] { name, user }, |
new Type[] { Hibernate.STRING, Hibernate.entity(SystemUser.class) } ) |
.next()).intValue() > 0; |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public boolean uidExists(User editor, SystemUser user, Integer uid) |
throws ModelException |
{ |
try { |
if(user.getId() == null) |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from SystemUser u where uid = ?", |
uid, Hibernate.INTEGER) |
.next()).intValue() > 0; |
else |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from SystemUser u where uid = ? and u != ?", |
new Object[] { uid, user }, |
new Type[] { Hibernate.INTEGER, Hibernate.entity(SystemUser.class) } ) |
.next()).intValue() > 0; |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
protected SystemUser findForName(String name) |
throws ModelException |
{ |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/InetDomainManager.java |
---|
2,6 → 2,7 |
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; |
68,6 → 69,28 |
return domain; |
} |
public boolean nameExists(User editor, InetDomain domain, String name) |
throws ModelException |
{ |
try { |
if(domain.getId() == null) |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from InetDomain d where name = ?", |
name, Hibernate.STRING) |
.next()).intValue() > 0; |
else |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from InetDomain d where name = ? and d != ?", |
new Object[] { name, domain }, |
new Type[] { Hibernate.STRING, Hibernate.entity(InetDomain.class) } ) |
.next()).intValue() > 0; |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
protected InetDomain findForName(String name) |
throws ModelException |
{ |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/MailAliasDestinationManager.java |
---|
75,6 → 75,7 |
throw new ModelSecurityException(); |
mailAliasDestination.setModUser(editor); |
// FIXME: the mod_user is not set when changing a destination as element of collection |
try { |
HibernateUtil.currentSession().saveOrUpdate(mailAliasDestination); |
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/UserManager.java |
---|
68,6 → 68,28 |
return user; |
} |
public boolean loginExists(User editor, User user, String login) |
throws ModelException |
{ |
try { |
if(user.getId() == null) |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from User u where login = ?", |
login, Hibernate.STRING) |
.next()).intValue() > 0; |
else |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from User u where login = ? and u != ?", |
new Object[] { login, user }, |
new Type[] { Hibernate.STRING, Hibernate.entity(User.class) } ) |
.next()).intValue() > 0; |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public User findForLogin(String login) |
throws ModelException |
{ |
141,7 → 163,7 |
} |
} |
public boolean areSystemUsersAvailable(User editor) |
public boolean areUsersAvailable(User editor) |
throws ModelException |
{ |
try { |
150,7 → 172,7 |
} |
else { |
return ((Integer)HibernateUtil.currentSession().iterate( |
"from User u where u = ? or u.boss = ?", |
"select count(*) 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; |