Rev 921 | Rev 925 | 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="domains"
*/
public class InetDomain
extends GeneralModelObject
{
private Long id;
private String name;
private User owner;
protected InetDomain()
{
}
/**
*
* @hibernate.id generator-class="native"
*/
public Long getId()
{
return id;
}
protected void setId(Long id)
{
this.id = id;
}
/**
*
* @hibernate.property
*/
public String getName()
{
return 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
*/
public User getOwner()
{
return 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.hostadmiral.core.CoreResources.TYPE_DOMAIN;
}
public String getIdentKey()
{
return ak.hostadmiral.core.CoreResources.IDENT_DOMAIN;
}
public Object[] getIdentParams()
{
return new Object[] { getName() };
}
public boolean viewableBy(User user)
{
return user.isSuperuser() || user.equals(owner);
}
public boolean editableBy(User user)
{
return user.isSuperuser();
}
public boolean deleteableBy(User user)
{
return user.isSuperuser();
}
protected static boolean allowedToCreate(InetDomainManager manager, User editor)
throws ModelException
{
return editor.isSuperuser();
}
}