Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 922 → Rev 923

/sun/hostcaptain/trunk/sql/00.tables.sql
1,6 → 1,7
--
-- hostcaptain sql tables
--
-- FIXME: which values has boolean in hibernate - '1':' ' or '1':'0'?
 
create sequence hibernate_sequence;
 
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/SystemUserAction.java
21,6 → 21,8
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.SystemUser;
58,14 → 60,16
else if("edit".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
Long userId = StringConverter.parseLong(theForm.get("id"));
SystemUser u;
DynaActionForm showForm = (DynaActionForm)RequestUtilsX.populateActionForm(
this, request, "ak.hostcaptain.core.form.SystemUserEditForm");
 
if(userId == null) {
u = SystemUserManager.getInstance().create(user);
showForm.set("enabled", new Boolean(true));
}
else {
SystemUser u = SystemUserManager.getInstance().get(user, userId);
u = SystemUserManager.getInstance().get(user, userId);
showForm.set("uid", StringConverter.toString(u.getUid()));
showForm.set("name", u.getName());
if(u.getOwner() != null)
75,7 → 79,11
}
 
initUserList(request, user);
return mapping.findForward("default");
request.setAttribute("u", u);
if(u.editableBy(user))
return mapping.findForward("default");
else
return mapping.findForward("view");
}
else if("delete".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
98,9 → 106,20
u = SystemUserManager.getInstance().get(user, userId);
}
 
u.setUid(user, StringConverter.parseInteger(theForm.get("uid")));
u.setName(user, (String)theForm.get("name"));
Integer uid = StringConverter.parseInteger(theForm.get("uid"));
if(SystemUserManager.getInstance().uidExists(user, u, uid)) {
handleErrors(mapping, form, request, response);
throw new UserException(CoreResources.NONUNIQUE_SYSTEM_USER_UID);
}
u.setUid(user, uid);
 
String name = (String)theForm.get("name");
if(SystemUserManager.getInstance().nameExists(user, u, name)) {
handleErrors(mapping, form, request, response);
throw new UserException(CoreResources.NONUNIQUE_SYSTEM_USER_NAME);
}
u.setName(user, name);
 
Long ownerId = StringConverter.parseLong(theForm.get("owner"));
if(ownerId == null)
u.setOwner(user, null);
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/InetDomainAction.java
21,6 → 21,8
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.InetDomain;
58,14 → 60,16
else if("edit".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
Long domainId = StringConverter.parseLong(theForm.get("id"));
InetDomain domain;
DynaActionForm showForm = (DynaActionForm)RequestUtilsX.populateActionForm(
this, request, "ak.hostcaptain.core.form.InetDomainEditForm");
 
if(domainId == null) {
domain = InetDomainManager.getInstance().create(user);
showForm.set("enabled", new Boolean(true));
}
else {
InetDomain domain = InetDomainManager.getInstance().get(user, domainId);
domain = InetDomainManager.getInstance().get(user, domainId);
showForm.set("name", domain.getName());
if(domain.getOwner() != null)
showForm.set("owner", StringConverter.toString(domain.getOwner().getId()));
74,7 → 78,11
}
 
initUserList(request, user);
return mapping.findForward("default");
request.setAttribute("domain", domain);
if(domain.editableBy(user))
return mapping.findForward("default");
else
return mapping.findForward("view");
}
else if("delete".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
97,7 → 105,13
domain = InetDomainManager.getInstance().get(user, domainId);
}
 
domain.setName(user, (String)theForm.get("name"));
String name = (String)theForm.get("name");
if(InetDomainManager.getInstance().nameExists(user, domain, name)) {
handleErrors(mapping, form, request, response);
throw new UserException(CoreResources.NONUNIQUE_DOMAIN_NAME);
}
domain.setName(user, name);
 
domain.setOwner(user, UserManager.getInstance().get(user,
StringConverter.parseLong(theForm.get("owner"))));
 
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/MailboxAction.java
61,16 → 61,18
else if("edit".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
Long boxId = StringConverter.parseLong(theForm.get("id"));
Mailbox mailbox;
DynaActionForm showForm = (DynaActionForm)RequestUtilsX.populateActionForm(
this, request, "ak.hostcaptain.core.form.MailboxEditForm");
 
if(boxId == null) {
mailbox = MailboxManager.getInstance().create(user);
showForm.set("enabled", new Boolean(true));
showForm.set("viruscheck", new Boolean(true));
showForm.set("spamcheck", new Boolean(true));
}
else {
Mailbox mailbox = MailboxManager.getInstance().get(user, boxId);
mailbox = MailboxManager.getInstance().get(user, boxId);
showForm.set("login", mailbox.getLogin());
if(mailbox.getDomain() != null)
showForm.set("domain", StringConverter.toString(mailbox.getDomain().getId()));
85,7 → 87,11
}
 
initLists(request, user);
return mapping.findForward("default");
request.setAttribute("mailbox", mailbox);
if(mailbox.editableBy(user))
return mapping.findForward("default");
else
return mapping.findForward("view");
}
else if("delete".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
103,8 → 109,10
String password = (String)theForm.get("password");
 
if(boxId == null) {
if(password == null || password.equals(""))
if(password == null || password.equals("")) {
handleErrors(mapping, form, request, response);
throw new UserException(CoreResources.PASSWORD_REQUIRED);
}
 
mailbox = MailboxManager.getInstance().create(user);
 
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/MailAliasAction.java
66,18 → 66,22
}
else if("edit".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
MailAlias alias;
Long aliasId = StringConverter.parseLong(theForm.get("id"));
List dests;
 
DynaActionForm showForm = (DynaActionForm)RequestUtilsX.populateActionForm(
this, request, "ak.hostcaptain.core.form.MailAliasEditForm");
 
if(aliasId == null) {
alias = MailAliasManager.getInstance().create(user);
dests = new ArrayList();
showForm.set("enabled", new Boolean(true));
}
else {
MailAlias alias = MailAliasManager.getInstance().get(user, aliasId);
List dests = new ArrayList(MailAliasDestinationManager.getInstance()
.listMailAliasesDestination(alias));
alias = MailAliasManager.getInstance().get(user, aliasId);
dests = new ArrayList(MailAliasDestinationManager.getInstance()
.listMailAliasesDestination(alias));
MailAliasDestBean[] d = new MailAliasDestBean[dests.size()];
 
// FIXME: sort dests here
97,7 → 101,14
}
 
initLists(request, user);
return mapping.findForward("default");
request.setAttribute("alias", alias);
request.setAttribute("dests", dests);
if(alias.editableBy(user))
return mapping.findForward("default");
else if(alias.mayChangeDestinations(user))
return mapping.findForward("editdests");
else
return mapping.findForward("view");
}
else if("delete".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
111,7 → 122,8
else if("submit".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
Long aliasId = StringConverter.parseLong(theForm.get("id"));
MailAlias alias = (aliasId == null) ? null
MailAlias alias = (aliasId == null)
? MailAliasManager.getInstance().create(user)
: MailAliasManager.getInstance().get(user, aliasId);
MailAliasDestBean[] dests = (MailAliasDestBean[])theForm.get("dests");
 
121,16 → 133,19
// by submit
 
// validate required fields, because it cannot be done in general case
if(StringConverter.isEmpty(theForm.get("address")))
if(StringConverter.isEmpty(theForm.get("address"))) {
handleErrors(mapping, form, request, response);
throw new UserException("ak.hostcaptain.core.mail.alias.edit.address.empty");
if(StringConverter.isEmpty(theForm.get("domain")))
}
if(StringConverter.isEmpty(theForm.get("domain"))) {
handleErrors(mapping, form, request, response);
throw new UserException("ak.hostcaptain.core.mail.alias.edit.domain.wrong");
if(StringConverter.isEmpty(theForm.get("owner")))
}
if(StringConverter.isEmpty(theForm.get("owner"))) {
handleErrors(mapping, form, request, response);
throw new UserException("ak.hostcaptain.core.mail.alias.edit.owner.wrong");
}
 
if(alias == null)
alias = MailAliasManager.getInstance().create(user);
 
alias.getDestinations(user).clear();
for(int i = 0; i < dests.length; i++) {
// FIXME: validate dest id, mailbox id, email
149,6 → 164,10
else
dest = MailAliasDestinationManager.getInstance().get(user, destId);
 
// connect
dest.setAlias(user, alias);
alias.getDestinations(user).add(dest);
 
// set mailbox or email
if(mailboxId != null) {
dest.setMailbox(user, MailboxManager.getInstance().get(user, mailboxId));
161,10 → 180,6
 
dest.setEnabled(user, dests[i].getEnabled());
dest.setComment(user, dests[i].getComment());
 
// connect
dest.setAlias(user, alias);
alias.getDestinations(user).add(dest);
}
 
alias.setAddress(user, (String)theForm.get("address"));
194,7 → 209,14
theForm.set("dests", newDests);
 
initLists(request, user);
return mapping.findForward("back");
request.setAttribute("alias", alias);
request.setAttribute("dests", newDests);
if(alias.editableBy(user))
return mapping.findForward("default");
else if(alias.mayChangeDestinations(user))
return mapping.findForward("editdests");
else
return mapping.findForward("view");
}
 
// delete
218,6 → 240,7
System.arraycopy(dests, n+1, newDests,
n, dests.length-n-1);
theForm.set("dests", newDests);
request.setAttribute("dests", newDests);
break;
}
catch(NumberFormatException ex) {
227,7 → 250,13
}
 
initLists(request, user);
return mapping.findForward("back");
request.setAttribute("alias", alias);
if(alias.editableBy(user))
return mapping.findForward("default");
else if(alias.mayChangeDestinations(user))
return mapping.findForward("editdests");
else
return mapping.findForward("view");
}
}
else {
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/UserAction.java
94,7 → 94,10
 
initUserList(request, user);
request.setAttribute("u", u);
return mapping.findForward("default");
if(u.editableBy(user))
return mapping.findForward("default");
else
return mapping.findForward("view");
}
else if("delete".equals(mapping.getParameter())) {
DynaActionForm theForm = (DynaActionForm)form;
102,8 → 105,10
User u = UserManager.getInstance().get(user, userId);
request.setAttribute("u", u);
 
if(u.equals(user))
if(u.equals(user)) {
handleErrors(mapping, form, request, response);
throw new UserException(CoreResources.DELETE_ME_SELF);
}
 
// FIXME: invalidate session of deleted user if it is logged in
// FIXME: if two admins delete each other at the same time
119,8 → 124,10
String password = (String)theForm.get("password");
 
if(userId == null) {
if(password == null || password.equals(""))
if(password == null || password.equals("")) {
handleErrors(mapping, form, request, response);
throw new UserException(CoreResources.PASSWORD_REQUIRED);
}
 
u = UserManager.getInstance().create(user);
}
129,7 → 136,12
}
request.setAttribute("u", u);
 
u.setLogin(user, (String)theForm.get("login"));
String login = (String)theForm.get("login");
if(UserManager.getInstance().loginExists(user, u, login)) {
handleErrors(mapping, form, request, response);
throw new UserException(CoreResources.NONUNIQUE_USER_LOGIN);
}
u.setLogin(user, login);
 
if(u.editableBy(user)) {
Long bossId = StringConverter.parseLong(theForm.get("boss"));
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/CoreResources.properties
21,9 → 21,13
ak.hostcaptain.core.oldpassword.wrong=Wrong old password
ak.hostcaptain.core.password.dontMatch=The passwords you entered doesn't match
 
ak.hostcaptain.core.user.login.nonunique=The user login already exists
ak.hostcaptain.core.user.password.change.id.wrong=Please select an user from the list
ak.hostcaptain.core.user.deletemeself=Can not delete the user you are logged in
ak.hostcaptain.core.user.boss.id.wrong=Please select a boss from the list
ak.hostcaptain.core.user.system.uid.nonunique=The UID already exists
ak.hostcaptain.core.user.system.name.nonunique=The user name already exists
ak.hostcaptain.core.domain.name.nonunique=The domain name already exists
 
ak.hostcaptain.core.mailbox.edit.id.wrong=Please select a mailbox from the list
ak.hostcaptain.core.mailbox.edit.login.empty=You have to enter the login
111,6 → 115,19
ak.hostcaptain.page.user.edit.submit=submit
ak.hostcaptain.page.user.edit.back=back
 
ak.hostcaptain.page.user.view.title=hostcaptain - user - view
ak.hostcaptain.page.user.view.login=Login
ak.hostcaptain.page.user.view.boss=Boss
ak.hostcaptain.page.user.view.boss.empty=[no boss]
ak.hostcaptain.page.user.view.superuser=Superuser
ak.hostcaptain.page.user.view.superuser.true=yes
ak.hostcaptain.page.user.view.superuser.false=no
ak.hostcaptain.page.user.view.enabled=Enabled
ak.hostcaptain.page.user.view.enabled.true=yes
ak.hostcaptain.page.user.view.enabled.false=no
ak.hostcaptain.page.user.view.comment=Comment
ak.hostcaptain.page.user.view.back=back
 
ak.hostcaptain.page.user.system.list.title=hostcaptain - system users - list
ak.hostcaptain.page.user.system.list.uid=System ID
ak.hostcaptain.page.user.system.list.name=User name
132,6 → 149,17
ak.hostcaptain.page.user.system.edit.submit=submit
ak.hostcaptain.page.user.system.edit.back=back
 
ak.hostcaptain.page.user.system.view.title=hostcaptain - system user - view
ak.hostcaptain.page.user.system.view.uid=System ID
ak.hostcaptain.page.user.system.view.name=User name
ak.hostcaptain.page.user.system.view.owner=Owner
ak.hostcaptain.page.user.system.view.owner.empty=[common user]
ak.hostcaptain.page.user.system.view.enabled=Enabled
ak.hostcaptain.page.user.system.view.enabled.true=yes
ak.hostcaptain.page.user.system.view.enabled.false=no
ak.hostcaptain.page.user.system.view.comment=Comment
ak.hostcaptain.page.user.system.view.back=back
 
ak.hostcaptain.page.domain.list.title=hostcaptain - domains - list
ak.hostcaptain.page.domain.list.name=Name
ak.hostcaptain.page.domain.list.owner=Owner
151,6 → 179,15
ak.hostcaptain.page.domain.edit.submit=submit
ak.hostcaptain.page.domain.edit.back=back
 
ak.hostcaptain.page.domain.view.title=hostcaptain - domain - view
ak.hostcaptain.page.domain.view.name=Name
ak.hostcaptain.page.domain.view.owner=Owner
ak.hostcaptain.page.domain.view.enabled=Enabled
ak.hostcaptain.page.domain.view.enabled.true=yes
ak.hostcaptain.page.domain.view.enabled.false=no
ak.hostcaptain.page.domain.view.comment=Comment
ak.hostcaptain.page.domain.view.back=back
 
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
179,6 → 216,24
ak.hostcaptain.page.mail.box.edit.submit=submit
ak.hostcaptain.page.mail.box.edit.back=back
 
ak.hostcaptain.page.mail.box.view.title=hostcaptain - mail box - view
ak.hostcaptain.page.mail.box.view.login=Box
ak.hostcaptain.page.mail.box.view.domain=Domain
ak.hostcaptain.page.mail.box.view.owner=Owner
ak.hostcaptain.page.mail.box.view.systemuser=System user
ak.hostcaptain.page.mail.box.view.systemuser.empty=[default user]
ak.hostcaptain.page.mail.box.view.viruscheck=check mails for viruses
ak.hostcaptain.page.mail.box.view.viruscheck.true=yes
ak.hostcaptain.page.mail.box.view.viruscheck.false=no
ak.hostcaptain.page.mail.box.view.spamcheck=check mails for spam
ak.hostcaptain.page.mail.box.view.spamcheck.true=yes
ak.hostcaptain.page.mail.box.view.spamcheck.false=no
ak.hostcaptain.page.mail.box.view.enabled=Enabled
ak.hostcaptain.page.mail.box.view.enabled.true=yes
ak.hostcaptain.page.mail.box.view.enabled.false=no
ak.hostcaptain.page.mail.box.view.comment=Comment
ak.hostcaptain.page.mail.box.view.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
185,6 → 240,7
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.editdests=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
207,3 → 263,38
ak.hostcaptain.page.mail.alias.edit.delete=delete
ak.hostcaptain.page.mail.alias.edit.submit=submit
ak.hostcaptain.page.mail.alias.edit.back=back
 
ak.hostcaptain.page.mail.alias.editdest.title=hostcaptain - mail alias - edit
ak.hostcaptain.page.mail.alias.editdest.address=Address
ak.hostcaptain.page.mail.alias.editdest.domain=Domain
ak.hostcaptain.page.mail.alias.editdest.owner=Owner
ak.hostcaptain.page.mail.alias.editdest.enabled=Enabled
ak.hostcaptain.page.mail.alias.editdest.enabled.true=yes
ak.hostcaptain.page.mail.alias.editdest.enabled.false=no
ak.hostcaptain.page.mail.alias.editdest.comment=Comment
ak.hostcaptain.page.mail.alias.editdest.header.tomailbox=To mailbox
ak.hostcaptain.page.mail.alias.editdest.header.toexternal=or to external email
ak.hostcaptain.page.mail.alias.editdest.header.enabled=Enabled
ak.hostcaptain.page.mail.alias.editdest.header.comment=Comment
ak.hostcaptain.page.mail.alias.editdest.external=external redirect
ak.hostcaptain.page.mail.alias.editdest.add=add new destination
ak.hostcaptain.page.mail.alias.editdest.delete=delete
ak.hostcaptain.page.mail.alias.editdest.submit=submit
ak.hostcaptain.page.mail.alias.editdest.back=back
 
ak.hostcaptain.page.mail.alias.view.title=hostcaptain - mail alias - view
ak.hostcaptain.page.mail.alias.view.address=Address
ak.hostcaptain.page.mail.alias.view.domain=Domain
ak.hostcaptain.page.mail.alias.view.owner=Owner
ak.hostcaptain.page.mail.alias.view.enabled=Enabled
ak.hostcaptain.page.mail.alias.view.enabled.true=yes
ak.hostcaptain.page.mail.alias.view.enabled.false=no
ak.hostcaptain.page.mail.alias.view.comment=Comment
ak.hostcaptain.page.mail.alias.view.header.tomailbox=To mailbox
ak.hostcaptain.page.mail.alias.view.header.toexternal=or to external email
ak.hostcaptain.page.mail.alias.view.header.enabled=Enabled
ak.hostcaptain.page.mail.alias.view.dest.enabled.true=yes
ak.hostcaptain.page.mail.alias.view.dest.enabled.false=no
ak.hostcaptain.page.mail.alias.view.header.comment=Comment
ak.hostcaptain.page.mail.alias.view.external=external redirect
ak.hostcaptain.page.mail.alias.view.back=back
/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;
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/CoreResources.java
4,10 → 4,18
{
public static final String LOGIN_FAILED = "ak.hostcaptain.core.login.failed";
public static final String OLD_PASSWORD_WRONG = "ak.hostcaptain.core.oldpassword.wrong";
public static final String DELETE_ME_SELF = "ak.hostcaptain.core.user.deletemeself";
public static final String PASSWORD_REQUIRED = "ak.hostcaptain.core.password.required";
public static final String PASSWORDS_DONT_MATCH = "ak.hostcaptain.core.password.dontMatch";
 
public static final String DELETE_ME_SELF = "ak.hostcaptain.core.user.deletemeself";
public static final String NONUNIQUE_USER_LOGIN = "ak.hostcaptain.core.user.login.nonunique";
public static final String NONUNIQUE_SYSTEM_USER_UID
= "ak.hostcaptain.core.user.system.uid.nonunique";
public static final String NONUNIQUE_SYSTEM_USER_NAME
= "ak.hostcaptain.core.user.system.name.nonunique";
public static final String NONUNIQUE_DOMAIN_NAME
= "ak.hostcaptain.core.domain.name.nonunique";
 
public static final String TYPE_USER = "ak.hostcaptain.core.type.user";
public static final String TYPE_SYSTEM_USER = "ak.hostcaptain.core.type.systemUser";
public static final String TYPE_DOMAIN = "ak.hostcaptain.core.type.domain";
/sun/hostcaptain/trunk/webapp/WEB-INF/struts-config.xml
217,6 → 217,7
scope="request"
>
<forward name="default" path="/user/edit.jsp" />
<forward name="view" path="/user/view.jsp" />
</action>
 
<action
259,6 → 260,7
scope="request"
>
<forward name="default" path="/user/system/edit.jsp" />
<forward name="view" path="/user/system/view.jsp" />
</action>
 
<action
301,6 → 303,7
scope="request"
>
<forward name="default" path="/domain/edit.jsp" />
<forward name="view" path="/domain/view.jsp" />
</action>
 
<action
343,6 → 346,7
scope="request"
>
<forward name="default" path="/mail/box/edit.jsp" />
<forward name="view" path="/mail/box/view.jsp" />
</action>
 
<action
384,7 → 388,9
validate="true"
scope="request"
>
<forward name="default" path="/mail/alias/edit.jsp" />
<forward name="default" path="/mail/alias/edit.jsp" />
<forward name="editdests" path="/mail/alias/editdests.jsp" />
<forward name="view" path="/mail/alias/view.jsp" />
</action>
 
<action
396,7 → 402,9
scope="request"
input="/mail/alias/edit.do"
>
<forward name="back" path="/mail/alias/edit.jsp" />
<forward name="default" path="/mail/alias/edit.jsp" />
<forward name="editdests" path="/mail/alias/editdests.jsp" />
<forward name="view" path="/mail/alias/view.jsp" />
</action>
 
</action-mappings>
/sun/hostcaptain/trunk/webapp/domain/view.jsp
0,0 → 1,53
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/ak-backpath.tld" prefix="backpath" %>
<%@ taglib uri="/WEB-INF/hostcaptain-core.tld" prefix="core" %>
<html>
 
<head>
<meta http-equiv="expires" content="0">
<title><bean:message key="ak.hostcaptain.page.domain.view.title" /></title>
</head>
 
<body>
 
<h1><bean:message key="ak.hostcaptain.page.domain.view.title" /></h1>
 
<html:errors/>
 
<table border=1>
<tr>
<th><bean:message key="ak.hostcaptain.page.domain.view.name" /></th>
<td><bean:write name="domain" property="name" /></td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.domain.view.owner" /></th>
<td><bean:write name="domain" property="owner.login" /></td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.domain.view.enabled" /></th>
<td>
<logic:equal name="domain" property="enabled" value="true">
<bean:message key="ak.hostcaptain.page.domain.view.enabled.true" />
</logic:equal>
<logic:notEqual name="domain" property="enabled" value="true">
<bean:message key="ak.hostcaptain.page.domain.view.enabled.false" />
</logic:notEqual>
</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.domain.view.comment" /></th>
<td><bean:write name="domain" property="comment" />&nbsp;</td>
</tr>
<tr>
<td colspan=2>
<backpath:backlink><bean:message key="ak.hostcaptain.page.domain.view.back" /></backpath:backlink>
</td>
</tr>
</table>
 
</body>
 
</html>
/sun/hostcaptain/trunk/webapp/user/system/view.jsp
0,0 → 1,64
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/ak-backpath.tld" prefix="backpath" %>
<%@ taglib uri="/WEB-INF/hostcaptain-core.tld" prefix="core" %>
<html>
 
<head>
<meta http-equiv="expires" content="0">
<title><bean:message key="ak.hostcaptain.page.user.system.view.title" /></title>
</head>
 
<body>
 
<h1><bean:message key="ak.hostcaptain.page.user.system.view.title" /></h1>
 
<html:errors/>
 
<table border=1>
<tr>
<th><bean:message key="ak.hostcaptain.page.user.system.view.uid" /></th>
<td><bean:write name="u" property="uid" /></td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.user.system.view.name" /></th>
<td><bean:write name="u" property="name" /></td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.user.system.view.owner" /></th>
<td>
<logic:present name="u" property="owner">
<bean:write name="u" property="owner.login" />
</logic:present>
<logic:notPresent name="u" property="owner">
<bean:message key="ak.hostcaptain.page.user.system.view.owner.empty" />
</logic:notPresent>
</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.user.system.view.enabled" /></th>
<td>
<logic:equal name="u" property="enabled" value="true">
<bean:message key="ak.hostcaptain.page.user.system.view.enabled.true" />
</logic:equal>
<logic:notEqual name="u" property="enabled" value="true">
<bean:message key="ak.hostcaptain.page.user.system.view.enabled.false" />
</logic:notEqual>
</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.user.system.view.comment" /></th>
<td><bean:write name="u" property="comment" />&nbsp;</td>
</tr>
<tr>
<td colspan=2>
<backpath:backlink><bean:message key="ak.hostcaptain.page.user.system.view.back" /></backpath:backlink>
</td>
</tr>
</table>
 
</body>
 
</html>
/sun/hostcaptain/trunk/webapp/user/view.jsp
0,0 → 1,71
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/ak-backpath.tld" prefix="backpath" %>
<%@ taglib uri="/WEB-INF/hostcaptain-core.tld" prefix="core" %>
<html>
 
<head>
<meta http-equiv="expires" content="0">
<title><bean:message key="ak.hostcaptain.page.user.view.title" /></title>
</head>
 
<body>
 
<h1><bean:message key="ak.hostcaptain.page.user.view.title" /></h1>
 
<html:errors/>
 
<table border=1>
<tr>
<th><bean:message key="ak.hostcaptain.page.user.view.login" /></th>
<td><bean:write name="u" property="login" /></td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.user.view.boss" /></th>
<td>
<logic:present name="u" property="boss">
<bean:write name="u" property="boss.login" />
</logic:present>
<logic:notPresent name="u" property="boss">
<bean:message key="ak.hostcaptain.page.user.view.boss.empty" />
</logic:notPresent>
</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.user.view.superuser" /></th>
<td>
<logic:equal name="u" property="superuser" value="true">
<bean:message key="ak.hostcaptain.page.user.view.superuser.true" />
</logic:equal>
<logic:notEqual name="u" property="superuser" value="true">
<bean:message key="ak.hostcaptain.page.user.view.superuser.false" />
</logic:notEqual>
</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.user.view.enabled" /></th>
<td>
<logic:equal name="u" property="enabled" value="true">
<bean:message key="ak.hostcaptain.page.user.view.enabled.true" />
</logic:equal>
<logic:notEqual name="u" property="enabled" value="true">
<bean:message key="ak.hostcaptain.page.user.view.enabled.false" />
</logic:notEqual>
</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.user.view.comment" /></th>
<td><bean:write name="u" property="comment" />&nbsp;</td>
</tr>
<tr>
<td colspan=2>
<backpath:backlink><bean:message key="ak.hostcaptain.page.user.view.back" /></backpath:backlink>
</td>
</tr>
</table>
 
</body>
 
</html>
/sun/hostcaptain/trunk/webapp/mail/box/view.jsp
0,0 → 1,93
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/ak-backpath.tld" prefix="backpath" %>
<%@ taglib uri="/WEB-INF/hostcaptain-core.tld" prefix="core" %>
<html>
 
<head>
<meta http-equiv="expires" content="0">
<title><bean:message key="ak.hostcaptain.page.mail.box.view.title" /></title>
</head>
 
<body>
 
<h1><bean:message key="ak.hostcaptain.page.mail.box.view.title" /></h1>
 
<html:errors/>
 
<table border=1>
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.box.view.login" /></th>
<td><bean:write name="mailbox" property="login" /></td>
</tr>
<tr>
<td colspan=2>FIXME: show if password is get from owner</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.box.view.domain" /></th>
<td><bean:write name="mailbox" property="domain.name" /></td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.box.view.owner" /></th>
<td><bean:write name="mailbox" property="owner.login" /></td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.box.view.systemuser" /></th>
<td>
<logic:present name="mailbox" property="systemUser">
<bean:write name="mailbox" property="systemUser.name" /> (<bean:write name="mailbox" property="systemUser.uid" />)
</logic:present>
<logic:notPresent name="mailbox" property="systemUser">
<bean:message key="ak.hostcaptain.page.mail.box.view.systemuser.empty" />
</logic:notPresent>
</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.box.view.viruscheck" /></th>
<td>
<logic:equal name="mailbox" property="virusCheck" value="true">
<bean:message key="ak.hostcaptain.page.mail.box.view.viruscheck.true" />
</logic:equal>
<logic:notEqual name="mailbox" property="virusCheck" value="true">
<bean:message key="ak.hostcaptain.page.mail.box.view.viruscheck.false" />
</logic:notEqual>
</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.box.view.spamcheck" /></th>
<td>
<logic:equal name="mailbox" property="spamCheck" value="true">
<bean:message key="ak.hostcaptain.page.mail.box.view.spamcheck.true" />
</logic:equal>
<logic:notEqual name="mailbox" property="spamCheck" value="true">
<bean:message key="ak.hostcaptain.page.mail.box.view.spamcheck.false" />
</logic:notEqual>
</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.box.view.enabled" /></th>
<td>
<logic:equal name="mailbox" property="enabled" value="true">
<bean:message key="ak.hostcaptain.page.mail.box.view.enabled.true" />
</logic:equal>
<logic:notEqual name="mailbox" property="enabled" value="true">
<bean:message key="ak.hostcaptain.page.mail.box.view.enabled.false" />
</logic:notEqual>
</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.box.view.comment" /></th>
<td><bean:write name="mailbox" property="comment" />&nbsp;</td>
</tr>
<tr>
<td colspan=2>
<backpath:backlink><bean:message key="ak.hostcaptain.page.mail.box.view.back" /></backpath:backlink>
</td>
</tr>
</table>
 
</body>
 
</html>
/sun/hostcaptain/trunk/webapp/mail/alias/list.jsp
41,12 → 41,17
<backpath:link action="/mail/alias/edit" paramId="id" paramName="alias" paramProperty="id"><bean:message key="ak.hostcaptain.page.mail.alias.list.edit" /></backpath:link>
</core:editable>
<core:notEditable name="alias">
<core:viewable name="alias">
<backpath:link action="/mail/alias/edit" paramId="id" paramName="alias" paramProperty="id"><bean:message key="ak.hostcaptain.page.mail.alias.list.edit" /></backpath:link>
</core:viewable>
<core:notViewable name="alias">
&nbsp;
</core:notViewable>
<core:rights name="alias" method="mayChangeDestinations">
<backpath:link action="/mail/alias/edit" paramId="id" paramName="alias" paramProperty="id"><bean:message key="ak.hostcaptain.page.mail.alias.list.editdests" /></backpath:link>
</core:rights>
<core:noRights name="alias" method="mayChangeDestinations">
<core:viewable name="alias">
<backpath:link action="/mail/alias/edit" paramId="id" paramName="alias" paramProperty="id"><bean:message key="ak.hostcaptain.page.mail.alias.list.view" /></backpath:link>
</core:viewable>
<core:notViewable name="alias">
&nbsp;
</core:notViewable>
</core:noRights>
</core:notEditable>
</td>
<td>
/sun/hostcaptain/trunk/webapp/mail/alias/editdests.jsp
0,0 → 1,154
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/ak-backpath.tld" prefix="backpath" %>
<%@ taglib uri="/WEB-INF/hostcaptain-core.tld" prefix="core" %>
<html>
 
<head>
<meta http-equiv="expires" content="0">
<title><bean:message key="ak.hostcaptain.page.mail.alias.editdest.title" /></title>
<script>
function submitForm()
{
idx = 0;
while(true) {
var t = document.forms[0].elements["dests[" + (idx++) + "].email"];
if(t) t.disabled = false;
else break;
}
}
 
function loadForm()
{
idx = 0;
while(true) {
var s = document.forms[0].elements["dests[" + (idx++) + "].mailbox"];
if(s) mailboxChanged(s);
else break;
}
}
 
function mailboxChanged(s)
{
// extract index
var name = s.name;
var i1 = name.indexOf("[");
var i2 = name.indexOf("]");
 
if(i1 < 0 || i2 < 0) return;
 
var idx = name.substring(i1+1, i2);
 
// find text field
var t = document.forms[0].elements["dests[" + idx + "].email"];
 
// change status
if(t) {
if(s.options[s.selectedIndex] && s.options[s.selectedIndex].value != '') {
t.disabled = true;
}
else {
t.disabled = false;
}
}
}
</script>
</head>
 
<body>
 
<h1><bean:message key="ak.hostcaptain.page.mail.alias.editdest.title" /></h1>
 
<html:errors/>
 
<html:form action="/mail/alias/submit" onsubmit="submitForm()">
<backpath:current/>
<html:hidden property="id" />
 
<table border=1>
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.alias.editdest.address" /></th>
<td><bean:write name="alias" property="address" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.alias.editdest.domain" /></th>
<td><bean:write name="alias" property="domain.name" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.alias.editdest.owner" /></th>
<td><bean:write name="alias" property="owner.login" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.alias.editdest.enabled" /></th>
<td>
<logic:equal name="alias" property="enabled" value="true">
<bean:message key="ak.hostcaptain.page.mail.box.view.enabled.true" />
</logic:equal>
<logic:notEqual name="alias" property="enabled" value="true">
<bean:message key="ak.hostcaptain.page.mail.box.view.enabled.false" />
</logic:notEqual>
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.alias.editdest.comment" /></th>
<td><bean:write name="alias" property="comment" />&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
 
<tr>
<th><bean:message key="ak.hostcaptain.page.mail.alias.editdest.header.tomailbox" /></th>
<th><bean:message key="ak.hostcaptain.page.mail.alias.editdest.header.toexternal" /></th>
<th><bean:message key="ak.hostcaptain.page.mail.alias.editdest.header.enabled" /></th>
<th><bean:message key="ak.hostcaptain.page.mail.alias.editdest.header.comment" /></th>
<th>&nbsp;</th>
</tr>
 
<logic:iterate name="ak.hostcaptain.core.form.MailAliasEditForm" property="dests" id="dests" indexId="iid">
<tr>
<td>
<html:hidden name="dests" property="id" indexed="true" />
<html:select name="dests" property="mailbox" indexed="true" onchange="mailboxChanged(this)">
<html:option value="" key="ak.hostcaptain.page.mail.alias.editdest.external"/>
<html:options collection="mailboxes" property="id" labelProperty="login" />
</html:select>
</td>
<td><html:text name="dests" property="email" indexed="true" /></td>
<td><html:checkbox name="dests" property="enabled" indexed="true" /></td>
<td><html:text name="dests" property="comment" indexed="true" /></td>
<td><html:submit property="delete.dests" indexed="true"><bean:message key="ak.hostcaptain.page.mail.alias.editdest.delete" /></html:submit></td>
</tr>
</logic:iterate>
 
<tr>
<td colspan=5><html:submit property="add"><bean:message key="ak.hostcaptain.page.mail.alias.editdest.add" /></html:submit></td>
<tr>
</tr>
<td colspan=5>
<html:submit property="submit"><bean:message key="ak.hostcaptain.page.mail.alias.editdest.submit" /></html:submit>
<backpath:backlink><bean:message key="ak.hostcaptain.page.mail.alias.editdest.back" /></backpath:backlink>
</td>
</tr>
</table>
 
</html:form>
<script>loadForm();</script>
 
</body>
 
</html>
/sun/hostcaptain/trunk/webapp/mail/alias/view.jsp
0,0 → 1,32
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/ak-backpath.tld" prefix="backpath" %>
<%@ taglib uri="/WEB-INF/hostcaptain-core.tld" prefix="core" %>
<html>
 
<head>
<meta http-equiv="expires" content="0">
<title><bean:message key="ak.hostcaptain.page.mail.alias.view.title" /></title>
</head>
 
<body>
 
<h1><bean:message key="ak.hostcaptain.page.mail.alias.view.title" /></h1>
 
<h2>FIXME: NOT IMPLEMENTED. DO WE REALLY NEED IT?</h2>
 
<html:errors/>
 
<table border=1>
</tr>
<td colspan=5>
<backpath:backlink><bean:message key="ak.hostcaptain.page.mail.alias.view.back" /></backpath:backlink>
</td>
</tr>
</table>
 
</body>
 
</html>