pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.accesscontrol
Class Role

java.lang.Object
  extended by org.torweg.pulse.util.entity.AbstractBasicEntity
      extended by org.torweg.pulse.util.entity.AbstractNamedEntity
          extended by org.torweg.pulse.util.entity.AbstractNamableEntity
              extended by org.torweg.pulse.accesscontrol.AbstractAccessControlObject
                  extended by org.torweg.pulse.accesscontrol.Role
All Implemented Interfaces:
java.io.Serializable, JDOMable, INameable, INamed

@Entity
public class Role
extends AbstractAccessControlObject
implements INameable, JDOMable

A Role is an entity used to combine Groups and Permissions, in order to reduce the number of Group s and Permissions, that have to be assigned to a certain User.

Version:
$Revision: 1479 $
Author:
Christian Schatt, Daniel Dietz
See Also:
Serialized Form

Constructor Summary
protected Role()
          Deprecated. 
  Role(java.lang.String nam)
          The constructor that sets the name of the Role.
 
Method Summary
 boolean addGroup(Group group)
          Adds a Group to the Role's Set of Groups.
 boolean addPermission(Permission perm)
          Adds a Permission to the Role's Set of Permissions.
 org.jdom.Element deserializeToJDOM()
          Returns the state of the Role as a JDOM Element .
 java.lang.String getDescription()
          returns the description.
 java.util.Set<Group> getGroups()
          Returns a shallow copy of the Role's Collection of Groups.
 java.util.Set<Permission> getPermissions()
          Returns a shallow copy of the Role's Collection of Permissions.
 java.util.List<User> getUsers(org.hibernate.Session s)
          Returns the Users associated with the Role ordered by name.
 boolean removeGroup(Group grp)
          Removes a Group from the Role's Set of Groups if it is part of it.
 boolean removePermission(Permission perm)
          Removes a Permission from the Role's Set of Permissions if it is part of it.
 void setDescription(java.lang.String d)
          sets the description.
 net.sf.json.JSONObject toJSON()
          Serializes the state of the Role as a JSONObject.
 net.sf.json.JSONObject toJSON(org.hibernate.Session s)
          Returns the state of the Role as a JSONObject.
 
Methods inherited from class org.torweg.pulse.accesscontrol.AbstractAccessControlObject
getAssociatedAbstractAccessControlObjects, getLoadCriteriaForClassWithAlias
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractNamableEntity
setName
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractNamedEntity
getName
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractBasicEntity
compareTo, equals, getFullQualifiedClassNameJAXB, getId, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.torweg.pulse.util.INameable
setName
 
Methods inherited from interface org.torweg.pulse.util.INamed
getName
 

Constructor Detail

Role

@Deprecated
protected Role()
Deprecated. 

The constructor used by HibernateTM.


Role

public Role(java.lang.String nam)
The constructor that sets the name of the Role.

Parameters:
nam - the name of the Role.
Method Detail

getDescription

public final java.lang.String getDescription()
returns the description.

Returns:
the description.

setDescription

public final void setDescription(java.lang.String d)
sets the description.

Parameters:
d - the description to set

getGroups

public final java.util.Set<Group> getGroups()
Returns a shallow copy of the Role's Collection of Groups.

Returns:
the Groups associated with the Role.

addGroup

public final boolean addGroup(Group group)
Adds a Group to the Role's Set of Groups.

If it already is part of the Set, it will not be added.

Parameters:
group - the Group to be added.
Returns:
true if the Set changed as a result of the call.

removeGroup

public final boolean removeGroup(Group grp)
Removes a Group from the Role's Set of Groups if it is part of it.

Parameters:
grp - the Group to be removed.
Returns:
true if the Set changed as a result of the call.

getPermissions

public final java.util.Set<Permission> getPermissions()
Returns a shallow copy of the Role's Collection of Permissions.

Returns:
the Permissions associated with the Role.

addPermission

public final boolean addPermission(Permission perm)
Adds a Permission to the Role's Set of Permissions.

If it already is part of the Set, it will not be added.

Parameters:
perm - the Permission to be added.
Returns:
true if the Set changed as a result of the call.

removePermission

public final boolean removePermission(Permission perm)
Removes a Permission from the Role's Set of Permissions if it is part of it.

Parameters:
perm - the Permission to be removed.
Returns:
true if the Set changed as a result of the call.

getUsers

public final java.util.List<User> getUsers(org.hibernate.Session s)
Returns the Users associated with the Role ordered by name.

Parameters:
s - the hibernateTM-Session
Returns:
the Users associated with the Role.

deserializeToJDOM

public final org.jdom.Element deserializeToJDOM()
Returns the state of the Role as a JDOM Element .

Specified by:
deserializeToJDOM in interface JDOMable
Returns:
the state of the Role as a JDOM Element .

toJSON

public final net.sf.json.JSONObject toJSON()
Serializes the state of the Role as a JSONObject.

Overrides:
toJSON in class AbstractAccessControlObject
Returns:
the state of the Role as a JSONObject

toJSON

public final net.sf.json.JSONObject toJSON(org.hibernate.Session s)
Returns the state of the Role as a JSONObject.

If a Session is given the number of Users, associated with the Role will be added to the JSON.

Parameters:
s - the hibernateTM-Session
Returns:
the state of the Role as a JSONObject.