0,0 → 1,139 |
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 String name; |
private User owner; |
private InetDomain origin; // save original object state before any changes |
|
protected InetDomain() |
{ |
} |
|
protected InetDomain(InetDomain origin) |
{ |
super(origin); |
this.name = origin.name; |
this.owner = origin.owner; |
} |
|
protected InetDomain getOrigin() |
{ |
return origin; |
} |
|
protected void backupMe() |
{ |
if(origin == null) |
origin = new InetDomain(this); |
} |
|
protected void resetOrigin() |
{ |
origin = null; |
} |
|
/** |
* |
* @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(); |
|
backupMe(); |
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(); |
|
backupMe(); |
this.owner = owner; |
} |
|
public String getTypeKey() |
{ |
return ak.hostadmiral.core.resources.CoreResources.TYPE_DOMAIN; |
} |
|
public String getIdentKey() |
{ |
return ak.hostadmiral.core.resources.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(); |
} |
|
protected static InetDomain createLimitedCopy(InetDomain origin) |
{ |
InetDomain d = new InetDomain(); |
d.setName(origin.getName()); |
return d; |
} |
|
public String toString() |
{ |
return "InetDomain id=[" + getId() + "] name=[" + name + "]"; |
} |
} |