Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 912 → Rev 913

/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/SystemUser.java
7,7 → 7,7
* @hibernate.class table="systemusers"
*/
public class SystemUser
implements ModelObject
extends GeneralModelObject
{
private Long id;
 
96,8 → 96,13
return ak.hostcaptain.core.CoreResources.TYPE_SYSTEM_USER;
}
 
public String getIdentificationString()
public String getIdentKey()
{
return getName() + " (" + getUid() + ")"; // FIXME: is it really so good style?
return ak.hostcaptain.core.CoreResources.IDENT_SYSTEM_USER;
}
 
public Object[] getIdentParams()
{
return new Object[] { getName(), getUid() };
}
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/GeneralModelObject.java
0,0 → 1,36
package ak.hostcaptain.core.model;
 
public abstract class GeneralModelObject
implements ModelObject
{
private Boolean enabled;
private String comment;
 
/**
*
* @hibernate.property
*/
public Boolean getEnabled()
{
return enabled;
}
 
public void setEnabled(Boolean enabled)
{
this.enabled = enabled;
}
 
/**
*
* @hibernate.property
*/
public String getComment()
{
return comment;
}
 
public void setComment(String comment)
{
this.comment = comment;
}
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/InetDomain.java
7,7 → 7,7
* @hibernate.class table="domains"
*/
public class InetDomain
implements ModelObject
extends GeneralModelObject
{
private Long id;
private String name;
79,8 → 79,13
return ak.hostcaptain.core.CoreResources.TYPE_DOMAIN;
}
 
public String getIdentificationString()
public String getIdentKey()
{
return getName();
return ak.hostcaptain.core.CoreResources.IDENT_DOMAIN;
}
 
public Object[] getIdentParams()
{
return new Object[] { getName() };
}
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/ModelObject.java
4,5 → 4,7
{
public String getTypeKey();
 
public String getIdentificationString();
public String getIdentKey();
 
public Object[] getIdentParams();
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/UserManager.java
55,7 → 55,7
{
try {
List list = HibernateUtil.currentSession().find(
"from User where login=?", login, Hibernate.STRING);
"from User where login=? and enabled='1'", login, Hibernate.STRING);
 
if(list.size() == 0)
return null;
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/Mailbox.java
8,7 → 8,7
* @hibernate.class table="mailboxes"
*/
public class Mailbox
implements ModelObject
extends GeneralModelObject
{
private Long id;
private String login;
163,8 → 163,13
return ak.hostcaptain.core.CoreResources.TYPE_MAILBOX;
}
 
public String getIdentificationString()
public String getIdentKey()
{
return getLogin() + "@" + getDomain().getName();
return ak.hostcaptain.core.CoreResources.IDENT_MAILBOX;
}
 
public Object[] getIdentParams()
{
return new Object[] { getLogin(), getDomain().getName() };
}
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/MailAlias.java
8,7 → 8,7
* @hibernate.class table="mailaliases"
*/
public class MailAlias
implements ModelObject
extends GeneralModelObject
{
private Long id;
private String address;
116,8 → 116,13
return ak.hostcaptain.core.CoreResources.TYPE_MAIL_ALIAS;
}
 
public String getIdentificationString()
public String getIdentKey()
{
return getAddress() + "@" + getDomain().getName();
return ak.hostcaptain.core.CoreResources.IDENT_MAIL_ALIAS;
}
 
public Object[] getIdentParams()
{
return new Object[] { getAddress(), getDomain().getName() };
}
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/MailAliasDestination.java
7,7 → 7,7
* @hibernate.class table="mailaliasdests"
*/
public class MailAliasDestination
implements ModelObject
extends GeneralModelObject
{
private Long id;
private MailAlias alias;
94,8 → 94,19
return ak.hostcaptain.core.CoreResources.TYPE_MAIL_ALIAS_DESTINATION;
}
 
public String getIdentificationString()
public String getIdentKey()
{
return (getMailbox() == null) ? getEmail() : getMailbox().getIdentificationString();
if(getMailbox() == null)
return ak.hostcaptain.core.CoreResources.IDENT_MAIL_ALIAS_DESTINATION_EXTERNAL;
else
return ak.hostcaptain.core.CoreResources.IDENT_MAIL_ALIAS_DESTINATION_INTERNAL;
}
 
public Object[] getIdentParams()
{
if(getMailbox() == null)
return new Object[] { getEmail() };
else
return new Object[] { getMailbox().getLogin(), getMailbox().getDomain().getName() };
}
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/User.java
8,7 → 8,7
* @hibernate.class table="users"
*/
public class User
implements ModelObject
extends GeneralModelObject
{
private Long id;
private String login;
147,8 → 147,13
return ak.hostcaptain.core.CoreResources.TYPE_USER;
}
 
public String getIdentificationString()
public String getIdentKey()
{
return getLogin();
return ak.hostcaptain.core.CoreResources.IDENT_USER;
}
 
public Object[] getIdentParams()
{
return new Object[] { getLogin() };
}
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/taglib/ModelObjectOptionsTag.java
0,0 → 1,71
// based on jakarta struts taglib
package ak.hostcaptain.core.taglib;
 
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
 
import javax.servlet.jsp.JspException;
 
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.struts.taglib.html.Constants;
import org.apache.struts.taglib.html.SelectTag;
import org.apache.struts.taglib.html.OptionsTag;
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.ResponseUtils;
 
import ak.hostcaptain.core.model.ModelObject;
 
public class ModelObjectOptionsTag extends OptionsTag
{
protected static MessageResources coreMessages =
MessageResources.getMessageResources("ak.hostcaptain.core.CoreResources");
 
public int doEndTag() throws JspException
{
SelectTag selectTag = (SelectTag) pageContext.getAttribute(Constants.SELECT_KEY);
if (selectTag == null) {
throw new JspException(messages.getMessage("optionsTag.select"));
}
StringBuffer sb = new StringBuffer();
 
if (collection != null) {
Iterator collIterator = getIterator(collection, null);
while (collIterator.hasNext()) {
Object bean = collIterator.next();
Object value = null;
 
if(!(bean instanceof ModelObject))
throw new JspException("Not a ModelObject");
 
ModelObject model = (ModelObject)bean;
 
try {
value = PropertyUtils.getProperty(bean, property);
if (value == null) {
value = "";
}
} catch (IllegalAccessException e) {
throw new JspException(
messages.getMessage("getter.access", property, collection));
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
throw new JspException(
messages.getMessage("getter.result", property, t.toString()));
} catch (NoSuchMethodException e) {
throw new JspException(
messages.getMessage("getter.method", property, collection));
}
 
String identKey = model.getIdentKey();
Object[] identParams = model.getIdentParams();
String label = coreMessages.getMessage(identKey, identParams);
String stringValue = value.toString();
 
addOption(sb, stringValue, label, selectTag.isMatched(stringValue));
}
}
 
ResponseUtils.write(pageContext, sb.toString());
return EVAL_PAGE;
}
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/CoreResources.java
15,4 → 15,14
public static final String TYPE_MAIL_ALIAS = "ak.hostcaptain.core.type.mailAlias";
public static final String TYPE_MAIL_ALIAS_DESTINATION
= "ak.hostcaptain.core.type.mailAliasDestination";
 
public static final String IDENT_USER = "ak.hostcaptain.core.ident.user";
public static final String IDENT_SYSTEM_USER = "ak.hostcaptain.core.ident.systemUser";
public static final String IDENT_DOMAIN = "ak.hostcaptain.core.ident.domain";
public static final String IDENT_MAILBOX = "ak.hostcaptain.core.ident.mailbox";
public static final String IDENT_MAIL_ALIAS = "ak.hostcaptain.core.ident.mailAlias";
public static final String IDENT_MAIL_ALIAS_DESTINATION_EXTERNAL
= "ak.hostcaptain.core.ident.mailAliasDestination.external";
public static final String IDENT_MAIL_ALIAS_DESTINATION_INTERNAL
= "ak.hostcaptain.core.ident.mailAliasDestination.internal";
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/MailAliasAction.java
69,7 → 69,7
this, request, "ak.hostcaptain.core.form.MailAliasEditForm");
 
if(aliasId == null) {
 
showForm.set("enabled", new Boolean(true));
}
else {
MailAlias alias = MailAliasManager.getInstance().get(aliasId);
86,11 → 86,11
 
showForm.set("address", alias.getAddress());
if(alias.getDomain() != null)
showForm.set("domain",
StringConverter.toString(alias.getDomain().getId()));
showForm.set("domain", StringConverter.toString(alias.getDomain().getId()));
if(alias.getOwner() != null)
showForm.set("owner",
StringConverter.toString(alias.getOwner().getId()));
showForm.set("owner", StringConverter.toString(alias.getOwner().getId()));
showForm.set("enabled", alias.getEnabled());
showForm.set("comment", alias.getComment());
}
 
initLists(request, user);
155,6 → 155,8
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"));
 
// update alias
MailAliasManager.getInstance().save(alias);
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/UserAction.java
59,7 → 59,7
this, request, "ak.hostcaptain.core.form.UserEditForm");
 
if(userId == null) {
 
showForm.set("enabled", new Boolean(true));
}
else {
User u = UserManager.getInstance().get(userId);
67,6 → 67,8
if(u.getBoss() != null)
showForm.set("boss", StringConverter.toString(u.getBoss().getId()));
showForm.set("superuser", u.getSuperuser());
showForm.set("enabled", u.getEnabled());
showForm.set("comment", u.getComment());
}
 
initUserList(request);
107,6 → 109,8
 
Long bossId = StringConverter.parseLong(theForm.get("boss"));
if(bossId == null)
u.setBoss(null);
else
u.setBoss(UserManager.getInstance().get(bossId));
 
if(!user.equals(u)) // do not allow user to change own superuser status
115,6 → 119,9
if(password != null && !password.equals(""))
u.setNewPassword(password);
 
u.setEnabled((Boolean)theForm.get("enabled"));
u.setComment((String)theForm.get("comment"));
 
UserManager.getInstance().save(u);
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl());
return null;
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/SystemUserAction.java
59,7 → 59,7
this, request, "ak.hostcaptain.core.form.SystemUserEditForm");
 
if(userId == null) {
 
showForm.set("enabled", new Boolean(true));
}
else {
SystemUser u = SystemUserManager.getInstance().get(userId);
67,6 → 67,8
showForm.set("name", u.getName());
if(u.getOwner() != null)
showForm.set("owner", StringConverter.toString(u.getOwner().getId()));
showForm.set("enabled", u.getEnabled());
showForm.set("comment", u.getComment());
}
 
initUserList(request);
95,7 → 97,7
 
u.setUid(StringConverter.parseInteger(theForm.get("uid")));
u.setName((String)theForm.get("name"));
 
 
Long ownerId = StringConverter.parseLong(theForm.get("owner"));
if(ownerId == null)
u.setOwner(null);
102,6 → 104,9
else
u.setOwner(UserManager.getInstance().get(ownerId));
 
u.setEnabled((Boolean)theForm.get("enabled"));
u.setComment((String)theForm.get("comment"));
 
SystemUserManager.getInstance().save(u);
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl());
return null;
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/InetDomainAction.java
59,7 → 59,7
this, request, "ak.hostcaptain.core.form.InetDomainEditForm");
 
if(domainId == null) {
 
showForm.set("enabled", new Boolean(true));
}
else {
InetDomain domain = InetDomainManager.getInstance().get(domainId);
66,6 → 66,8
showForm.set("name", domain.getName());
if(domain.getOwner() != null)
showForm.set("owner", StringConverter.toString(domain.getOwner().getId()));
showForm.set("enabled", domain.getEnabled());
showForm.set("comment", domain.getComment());
}
 
initUserList(request);
96,6 → 98,9
domain.setOwner(UserManager.getInstance().get(
StringConverter.parseLong(theForm.get("owner"))));
 
domain.setEnabled((Boolean)theForm.get("enabled"));
domain.setComment((String)theForm.get("comment"));
 
InetDomainManager.getInstance().save(domain);
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl());
return null;
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/MailboxAction.java
60,7 → 60,7
this, request, "ak.hostcaptain.core.form.MailboxEditForm");
 
if(boxId == null) {
 
showForm.set("enabled", new Boolean(true));
}
else {
Mailbox mailbox = MailboxManager.getInstance().get(boxId);
73,6 → 73,8
showForm.set("spamcheck", mailbox.getSpamCheck());
if(mailbox.getSystemUser() != null)
showForm.set("systemuser", StringConverter.toString(mailbox.getSystemUser().getId()));
showForm.set("enabled", mailbox.getEnabled());
showForm.set("comment", mailbox.getComment());
}
 
initLists(request);
124,6 → 126,9
if(password != null && !password.equals(""))
mailbox.setNewPassword(password);
 
mailbox.setEnabled((Boolean)theForm.get("enabled"));
mailbox.setComment((String)theForm.get("comment"));
 
MailboxManager.getInstance().save(mailbox);
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl());
return null;
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/CoreResources.properties
5,7 → 5,15
ak.hostcaptain.core.type.mailAlias=mail alias
ak.hostcaptain.core.type.mailAliasDestination=mail alias destination
 
ak.hostcaptain.core.login.failed=Wrong login or password
ak.hostcaptain.core.ident.user={0}
ak.hostcaptain.core.ident.systemUser={0} ({1})
ak.hostcaptain.core.ident.domain={0}
ak.hostcaptain.core.ident.mailbox={0}@{1}
ak.hostcaptain.core.ident.mailAlias={0}@{1}
ak.hostcaptain.core.ident.mailAliasDestination.external={0}
ak.hostcaptain.core.ident.mailAliasDestination.internal={0}@{1}
 
ak.hostcaptain.core.login.failed=Wrong login or password or the user is disabled
ak.hostcaptain.core.login.required=You have to enter the login
ak.hostcaptain.core.password.required=You have to enter the password
ak.hostcaptain.core.oldpassword.required=You have to enter the old password
79,6 → 87,9
 
ak.hostcaptain.page.user.list.title=hostcaptain - users - list
ak.hostcaptain.page.user.list.login=Login
ak.hostcaptain.page.user.list.boss=Boss
ak.hostcaptain.page.user.list.superuser=Superuser
ak.hostcaptain.page.user.list.enabled=Enabled
ak.hostcaptain.page.user.list.delete=delete
ak.hostcaptain.page.user.list.edit=edit
ak.hostcaptain.page.user.list.add=add new user
90,7 → 101,9
ak.hostcaptain.page.user.edit.password_again=Password again
ak.hostcaptain.page.user.edit.boss=Boss
ak.hostcaptain.page.user.edit.boss.empty=-- no boss --
ak.hostcaptain.page.user.edit.superuser=
ak.hostcaptain.page.user.edit.superuser=Superuser
ak.hostcaptain.page.user.edit.enabled=Enabled
ak.hostcaptain.page.user.edit.comment=Comment
ak.hostcaptain.page.user.edit.submit=submit
ak.hostcaptain.page.user.edit.back=back
 
97,6 → 110,8
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
ak.hostcaptain.page.user.system.list.owner=Owner
ak.hostcaptain.page.user.system.list.enabled=Enabled
ak.hostcaptain.page.user.system.list.delete=delete
ak.hostcaptain.page.user.system.list.edit=edit
ak.hostcaptain.page.user.system.list.add=add new user
107,6 → 122,8
ak.hostcaptain.page.user.system.edit.name=User name
ak.hostcaptain.page.user.system.edit.owner=Owner
ak.hostcaptain.page.user.system.edit.owner.empty=-- common user --
ak.hostcaptain.page.user.system.edit.enabled=Enabled
ak.hostcaptain.page.user.system.edit.comment=Comment
ak.hostcaptain.page.user.system.edit.submit=submit
ak.hostcaptain.page.user.system.edit.back=back
 
113,6 → 130,7
ak.hostcaptain.page.domain.list.title=hostcaptain - domains - list
ak.hostcaptain.page.domain.list.name=Name
ak.hostcaptain.page.domain.list.owner=Owner
ak.hostcaptain.page.domain.list.enabled=Enabled
ak.hostcaptain.page.domain.list.delete=delete
ak.hostcaptain.page.domain.list.edit=edit
ak.hostcaptain.page.domain.list.add=add new domain
122,11 → 140,14
ak.hostcaptain.page.domain.edit.name=Name
ak.hostcaptain.page.domain.edit.owner=Owner
ak.hostcaptain.page.domain.edit.owner.empty=-- please select --
ak.hostcaptain.page.domain.edit.enabled=Enabled
ak.hostcaptain.page.domain.edit.comment=Comment
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.enabled=Enabled
ak.hostcaptain.page.mail.alias.list.edit=edit
ak.hostcaptain.page.mail.alias.list.delete=delete
ak.hostcaptain.page.mail.alias.list.back=back
138,6 → 159,8
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
150,6 → 173,7
ak.hostcaptain.page.mail.box.list.login=Box
ak.hostcaptain.page.mail.box.list.domain=Domain
ak.hostcaptain.page.mail.box.list.owner=Owner
ak.hostcaptain.page.mail.box.list.enabled=Enabled
ak.hostcaptain.page.mail.box.list.edit=edit
ak.hostcaptain.page.mail.box.list.delete=delete
ak.hostcaptain.page.mail.box.list.add=add new mail box
167,5 → 191,7
ak.hostcaptain.page.mail.box.edit.systemuser.empty=-- please select --
ak.hostcaptain.page.mail.box.edit.viruscheck=check mails for viruses
ak.hostcaptain.page.mail.box.edit.spamcheck=check mails for spam
ak.hostcaptain.page.mail.box.edit.enabled=Enabled
ak.hostcaptain.page.mail.box.edit.comment=Comment
ak.hostcaptain.page.mail.box.edit.submit=submit
ak.hostcaptain.page.mail.box.edit.back=back