Rev 924 | Rev 945 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package ak.hostadmiral.core.model;
import ak.hostadmiral.util.ModelException;
import ak.hostadmiral.util.ModelSecurityException;
/**
*
* @hibernate.class table="mailaliasdests"
*/
public class MailAliasDestination
extends GeneralModelObject
{
private Long id;
private MailAlias alias;
private Mailbox mailbox;
private String email;
protected MailAliasDestination()
{
}
/**
*
* @hibernate.id generator-class="native"
*/
public Long getId()
{
return id;
}
protected void setId(Long id)
{
this.id = id;
}
/**
*
* @hibernate.many-to-one
*/
public MailAlias getAlias()
{
return alias;
}
protected void setAlias(MailAlias alias)
{
this.alias = alias;
}
public void setAlias(User editor, MailAlias alias)
throws ModelException
{
if(this.alias != null && !editableBy(editor))
throw new ModelSecurityException();
this.alias = alias;
}
/**
*
* @hibernate.many-to-one
*/
public Mailbox getMailbox()
{
return mailbox;
}
protected void setMailbox(Mailbox mailbox)
{
this.mailbox = mailbox;
}
public void setMailbox(User editor, Mailbox mailbox)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
this.mailbox = mailbox;
}
/**
*
* @hibernate.property
*/
public String getEmail()
{
return email;
}
protected void setEmail(String email)
{
this.email = email;
}
public void setEmail(User editor, String email)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
this.email = email;
}
public String getTypeKey()
{
return ak.hostadmiral.core.CoreResources.TYPE_MAIL_ALIAS_DESTINATION;
}
public String getIdentKey()
{
if(getMailbox() == null)
return ak.hostadmiral.core.CoreResources.IDENT_MAIL_ALIAS_DESTINATION_EXTERNAL;
else
return ak.hostadmiral.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() };
}
public boolean viewableBy(User user)
{
return alias.viewableBy(user);
}
public boolean editableBy(User user)
{
return alias.mayChangeDestinations(user);
}
public boolean deleteableBy(User user)
{
return alias.mayChangeDestinations(user);
}
protected static boolean allowedToCreate(MailAliasDestinationManager manager, User editor)
throws ModelException
{
return true;
}
}