Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 921 → Rev 920

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