Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 920 → Rev 921

/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/SystemUserAction.java
98,17 → 98,17
u = SystemUserManager.getInstance().get(user, userId);
}
 
u.setUid(StringConverter.parseInteger(theForm.get("uid")));
u.setName((String)theForm.get("name"));
u.setUid(user, StringConverter.parseInteger(theForm.get("uid")));
u.setName(user, (String)theForm.get("name"));
 
Long ownerId = StringConverter.parseLong(theForm.get("owner"));
if(ownerId == null)
u.setOwner(null);
u.setOwner(user, null);
else
u.setOwner(UserManager.getInstance().get(user, ownerId));
u.setOwner(user, UserManager.getInstance().get(user, ownerId));
 
u.setEnabled((Boolean)theForm.get("enabled"));
u.setComment((String)theForm.get("comment"));
u.setEnabled(user, (Boolean)theForm.get("enabled"));
u.setComment(user, (String)theForm.get("comment"));
 
SystemUserManager.getInstance().save(user, u);
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl());
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/InetDomainAction.java
97,12 → 97,12
domain = InetDomainManager.getInstance().get(user, domainId);
}
 
domain.setName((String)theForm.get("name"));
domain.setOwner(UserManager.getInstance().get(user,
domain.setName(user, (String)theForm.get("name"));
domain.setOwner(user, UserManager.getInstance().get(user,
StringConverter.parseLong(theForm.get("owner"))));
 
domain.setEnabled((Boolean)theForm.get("enabled"));
domain.setComment((String)theForm.get("comment"));
domain.setEnabled(user, (Boolean)theForm.get("enabled"));
domain.setComment(user, (String)theForm.get("comment"));
 
InetDomainManager.getInstance().save(user, domain);
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl());
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/MailboxAction.java
114,27 → 114,27
mailbox = MailboxManager.getInstance().get(user, boxId);
}
 
mailbox.setLogin((String)theForm.get("login"));
mailbox.setDomain(InetDomainManager.getInstance().get(user,
mailbox.setLogin(user, (String)theForm.get("login"));
mailbox.setDomain(user, InetDomainManager.getInstance().get(user,
StringConverter.parseLong(theForm.get("domain"))));
mailbox.setOwner(UserManager.getInstance().get(user,
mailbox.setOwner(user, UserManager.getInstance().get(user,
StringConverter.parseLong(theForm.get("owner"))));
mailbox.setVirusCheck((Boolean)theForm.get("viruscheck"));
mailbox.setSpamCheck((Boolean)theForm.get("spamcheck"));
mailbox.setVirusCheck(user, (Boolean)theForm.get("viruscheck"));
mailbox.setSpamCheck(user, (Boolean)theForm.get("spamcheck"));
 
Long systemUserId = StringConverter.parseLong(theForm.get("systemuser"));
if(systemUserId == null) {
mailbox.setSystemUser(null);
mailbox.setSystemUser(user, null);
}
else {
mailbox.setSystemUser(SystemUserManager.getInstance().get(user, systemUserId));
mailbox.setSystemUser(user, SystemUserManager.getInstance().get(user, systemUserId));
}
 
if(password != null && !password.equals(""))
mailbox.setNewPassword(password);
mailbox.setPassword(user, password);
 
mailbox.setEnabled((Boolean)theForm.get("enabled"));
mailbox.setComment((String)theForm.get("comment"));
mailbox.setEnabled(user, (Boolean)theForm.get("enabled"));
mailbox.setComment(user, (String)theForm.get("comment"));
 
MailboxManager.getInstance().save(user, mailbox);
response.sendRedirect(BackPath.findBackPath(request).getBackwardUrl());
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/action/MailAliasAction.java
131,7 → 131,7
if(alias == null)
alias = MailAliasManager.getInstance().create(user);
 
alias.getDestinations().clear();
alias.getDestinations(user).clear();
for(int i = 0; i < dests.length; i++) {
// FIXME: validate dest id, mailbox id, email
 
159,21 → 159,21
dest.setEmail(dests[i].getEmail());
}
 
dest.setEnabled(dests[i].getEnabled());
dest.setComment(dests[i].getComment());
dest.setEnabled(user, dests[i].getEnabled());
dest.setComment(user, dests[i].getComment());
 
// connect
dest.setAlias(alias);
alias.getDestinations().add(dest);
alias.getDestinations(user).add(dest);
}
 
alias.setAddress((String)theForm.get("address"));
alias.setDomain(InetDomainManager.getInstance().get(user,
alias.setAddress(user, (String)theForm.get("address"));
alias.setDomain(user, InetDomainManager.getInstance().get(user,
StringConverter.parseLong(theForm.get("domain"))));
alias.setOwner(UserManager.getInstance().get(user,
alias.setOwner(user, UserManager.getInstance().get(user,
StringConverter.parseLong(theForm.get("owner"))));
alias.setEnabled((Boolean)theForm.get("enabled"));
alias.setComment((String)theForm.get("comment"));
alias.setEnabled(user, (Boolean)theForm.get("enabled"));
alias.setComment(user, (String)theForm.get("comment"));
 
// update alias
MailAliasManager.getInstance().save(user, alias);
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/Mailbox.java
1,6 → 1,8
package ak.hostcaptain.core.model;
 
import ak.hostcaptain.util.Digest;
import ak.hostcaptain.util.ModelException;
import ak.hostcaptain.util.ModelSecurityException;
 
/**
*
31,7 → 33,7
return id;
}
 
public void setId(Long id)
protected void setId(Long id)
{
this.id = id;
}
45,26 → 47,36
return login;
}
 
public void setLogin(String login)
protected void setLogin(String login)
{
this.login = login;
}
 
public void setLogin(User editor, String login)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.login = login;
}
 
/**
*
* @hibernate.property
*/
public String getPassword()
protected String getPassword()
{
return password;
}
 
public void setPassword(String password)
protected void setPassword(String password)
{
this.password = password;
}
 
public void setNewPassword(String password)
public void setPassword(User editor, String password)
throws ModelException
{
if(password == null)
throw new NullPointerException("Null password");
81,11 → 93,20
return domain;
}
 
public void setDomain(InetDomain domain)
protected void setDomain(InetDomain domain)
{
this.domain = domain;
}
 
public void setDomain(User editor, InetDomain domain)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.domain = domain;
}
 
/**
*
* @hibernate.many-to-one
95,11 → 116,20
return owner;
}
 
public void setOwner(User owner)
protected void setOwner(User owner)
{
this.owner = owner;
}
 
public void setOwner(User editor, User owner)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.owner = owner;
}
 
/**
*
* @hibernate.property
109,11 → 139,20
return virusCheck;
}
 
public void setVirusCheck(Boolean virusCheck)
protected void setVirusCheck(Boolean virusCheck)
{
this.virusCheck = virusCheck;
}
 
public void setVirusCheck(User editor, Boolean virusCheck)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.virusCheck = virusCheck;
}
 
/**
*
* @hibernate.property
123,11 → 162,20
return spamCheck;
}
 
public void setSpamCheck(Boolean spamCheck)
protected void setSpamCheck(Boolean spamCheck)
{
this.spamCheck = spamCheck;
}
 
public void setSpamCheck(User editor, Boolean spamCheck)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.spamCheck = spamCheck;
}
 
/**
*
* @hibernate.many-to-one
137,11 → 185,20
return systemUser;
}
 
public void setSystemUser(SystemUser systemUser)
protected void setSystemUser(SystemUser systemUser)
{
this.systemUser = systemUser;
}
 
public void setSystemUser(User editor, SystemUser systemUser)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.systemUser = systemUser;
}
 
public String getTypeKey()
{
return ak.hostcaptain.core.CoreResources.TYPE_MAILBOX;
171,4 → 228,12
{
return user.isSuperuser() || user.equals(domain.getOwner());
}
 
protected static boolean allowedToCreate(MailboxManager manager, User editor)
throws ModelException
{
return editor.isSuperuser()
|| InetDomainManager.getInstance().areInetDomainsAvailable(editor);
}
}
 
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/MailAlias.java
1,6 → 1,8
package ak.hostcaptain.core.model;
 
import java.util.Collection;
import ak.hostcaptain.util.ModelException;
import ak.hostcaptain.util.ModelSecurityException;
 
/**
*
28,7 → 30,7
return id;
}
 
public void setId(Long id)
protected void setId(Long id)
{
this.id = id;
}
42,11 → 44,20
return address;
}
 
public void setAddress(String address)
protected void setAddress(String address)
{
this.address = address;
}
 
public void setAddress(User editor, String address)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.address = address;
}
 
/**
*
* @hibernate.many-to-one
56,11 → 67,20
return domain;
}
 
public void setDomain(InetDomain domain)
protected void setDomain(InetDomain domain)
{
this.domain = domain;
}
 
public void setDomain(User editor, InetDomain domain)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.domain = domain;
}
 
/**
*
* @hibernate.many-to-one
70,11 → 90,20
return owner;
}
 
public void setOwner(User owner)
protected void setOwner(User owner)
{
this.owner = owner;
}
 
public void setOwner(User editor, User owner)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.owner = owner;
}
 
/**
* @return Collection(MailAliasDestination)
*
82,11 → 111,25
* @hibernate.collection-key column="alias"
* @hibernate.collection-one-to-many class="ak.hostcaptain.core.model.MailAliasDestination"
*/
public Collection getDestinations()
protected Collection getDestinations()
{
return destinations;
}
 
/**
* @return Collection(MailAliasDestination)
*/
public Collection getDestinations(User editor)
throws ModelException
{
if(mayChangeDestinations(editor))
return destinations;
else if(viewableBy(editor))
return java.util.Collections.unmodifiableCollection(destinations);
else
throw new ModelSecurityException();
}
 
/**
* @param destinations Collection(MailAliasDestination)
*/
120,8 → 163,20
return user.isSuperuser() || user.equals(domain.getOwner());
}
 
public boolean mayChangeDestinations(User user)
{
return user.isSuperuser() || user.equals(domain.getOwner()) || user.equals(owner);
}
 
public boolean deleteableBy(User user)
{
return user.isSuperuser() || user.equals(domain.getOwner());
}
 
protected static boolean allowedToCreate(MailAliasManager manager, User editor)
throws ModelException
{
return editor.isSuperuser()
|| InetDomainManager.getInstance().areInetDomainsAvailable(editor);
}
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/SystemUserManager.java
45,7 → 45,7
public boolean allowedToCreate(User editor)
throws ModelException
{
return editor.isSuperuser();
return SystemUser.allowedToCreate(this, editor);
}
 
public SystemUser get(User editor, Long id)
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/InetDomainManager.java
45,7 → 45,7
public boolean allowedToCreate(User editor)
throws ModelException
{
return editor.isSuperuser();
return InetDomain.allowedToCreate(this, editor);
}
 
public InetDomain get(User editor, Long id)
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/SystemUser.java
1,5 → 1,8
package ak.hostcaptain.core.model;
 
import ak.hostcaptain.util.ModelException;
import ak.hostcaptain.util.ModelSecurityException;
 
/**
*
* @hibernate.class table="systemusers"
27,7 → 30,7
return id;
}
 
public void setId(Long id)
protected void setId(Long id)
{
this.id = id;
}
41,11 → 44,20
return uid;
}
 
public void setUid(Integer uid)
protected void setUid(Integer uid)
{
this.uid = uid;
}
 
public void setUid(User editor, Integer uid)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.uid = uid;
}
 
/**
*
* @hibernate.property
55,11 → 67,20
return name;
}
 
public void setName(String name)
protected void setName(String name)
{
this.name = name;
}
 
public void setName(User editor, String name)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.name = name;
}
 
/**
*
* @hibernate.many-to-one
69,11 → 90,20
return owner;
}
 
public void setOwner(User owner)
protected void setOwner(User owner)
{
this.owner = owner;
}
 
public void setOwner(User editor, User owner)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.owner = owner;
}
 
public String getTypeKey()
{
return ak.hostcaptain.core.CoreResources.TYPE_SYSTEM_USER;
103,4 → 133,10
{
return user.isSuperuser();
}
 
protected static boolean allowedToCreate(SystemUserManager manager, User editor)
throws ModelException
{
return editor.isSuperuser();
}
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/GeneralModelObject.java
21,7 → 21,7
return enabled;
}
 
public void setEnabled(Boolean enabled)
protected void setEnabled(Boolean enabled)
{
this.enabled = enabled;
}
44,7 → 44,7
return comment;
}
 
public void setComment(String comment)
protected void setComment(String comment)
{
this.comment = comment;
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/MailboxManager.java
46,8 → 46,7
public boolean allowedToCreate(User editor)
throws ModelException
{
return editor.isSuperuser()
|| InetDomainManager.getInstance().areInetDomainsAvailable(editor);
return Mailbox.allowedToCreate(this, editor);
}
 
public Mailbox get(User editor, Long id)
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/InetDomain.java
1,5 → 1,8
package ak.hostcaptain.core.model;
 
import ak.hostcaptain.util.ModelException;
import ak.hostcaptain.util.ModelSecurityException;
 
/**
*
* @hibernate.class table="domains"
24,7 → 27,7
return id;
}
 
public void setId(Long id)
protected void setId(Long id)
{
this.id = id;
}
38,11 → 41,20
return name;
}
 
public void setName(String name)
protected void setName(String name)
{
this.name = name;
}
 
public void setName(User editor, String name)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.name = name;
}
 
/**
*
* @hibernate.many-to-one
52,11 → 64,20
return owner;
}
 
public void setOwner(User owner)
protected void setOwner(User owner)
{
this.owner = owner;
}
 
public void setOwner(User editor, User owner)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
this.owner = owner;
}
 
public String getTypeKey()
{
return ak.hostcaptain.core.CoreResources.TYPE_DOMAIN;
86,4 → 107,10
{
return user.isSuperuser();
}
 
protected static boolean allowedToCreate(InetDomainManager manager, User editor)
throws ModelException
{
return editor.isSuperuser();
}
}
/sun/hostcaptain/trunk/src/ak/hostcaptain/core/model/MailAliasManager.java
48,8 → 48,7
public boolean allowedToCreate(User editor)
throws ModelException
{
return editor.isSuperuser()
|| InetDomainManager.getInstance().areInetDomainsAvailable(editor);
return MailAlias.allowedToCreate(this, editor);
}
 
public MailAlias get(User editor, Long id)