org.sakaiproject.component.legacy.site
Class BaseGroup

java.lang.Object
  extended byorg.sakaiproject.component.legacy.site.BaseGroup
All Implemented Interfaces:
AuthzGroup, Comparable, Edit, Entity, Group, Identifiable, Serializable

public class BaseGroup
extends Object
implements Group, Identifiable

BaseGroup is an implementation of the Site API Group.

Author:
Sakai Software Development Team
See Also:
Serialized Form

Field Summary
protected  AuthzGroup m_azg
          The azg from the AuthzGroupService that is my AuthzGroup impl.
protected  boolean m_azgChanged
          Set to true if we have changed our azg, so it need to be written back on save.
protected  String m_description
          The description.
protected  String m_id
          The site id.
protected  ResourcePropertiesEdit m_properties
          The properties.
protected  Site m_site
          The site I belong to.
protected  String m_title
          The title.
 
Fields inherited from interface org.sakaiproject.service.legacy.entity.Entity
SEPARATOR
 
Constructor Summary
protected BaseGroup(Group other, Site site, boolean exact)
          Construct as a copy of another.
protected BaseGroup(Site site)
          Construct.
protected BaseGroup(String id, String title, String description, Site site)
           
 
Method Summary
 void addMember(String userId, String roleId, boolean active, boolean provided)
          Add a member to the AuthzGroup.
 Role addRole(String id)
          Create a new Role within this AuthzGroup.
 Role addRole(String id, Role other)
          Create a new Role within this AuthzGroup, as a copy of this other role
 int compareTo(Object obj)
           
 boolean equals(Object obj)
           
protected  AuthzGroup getAzg()
          Access (find if needed) the azg from the AuthzGroupService that implements my grouping.
 Site getContainingSite()
          Access the site in which this group lives.
 User getCreatedBy()
           
 Time getCreatedTime()
           
 String getDescription()
           
 String getId()
          Access the id.
 String getMaintainRole()
          Access the name of the role to use for giving a user membership with "maintain" access.
 Member getMember(String userId)
          Access the user's membership record for this AuthzGroup; the role, and status flags.
 Set getMembers()
          Access all Membership records defined for this AuthzGroup.
 User getModifiedBy()
           
 Time getModifiedTime()
           
 ResourceProperties getProperties()
          Access the entity's properties.
 ResourcePropertiesEdit getPropertiesEdit()
          Access the resource's properties for modification
 String getProviderGroupId()
          Access the group id for the GroupProvider for this AuthzGroup.
 String getReference()
          Access the internal reference which can be used to access the entity from within the system.
 String getReference(String rootProperty)
          Access the alternate internal reference which can be used to access the entity from within the system.
 Role getRole(String id)
          Access a Role defined in this AuthzGroup.
 Set getRoles()
          Access all Roles defined for this AuthzGroup.
 Set getRolesIsAllowed(String function)
          Access all roles that have been granted permission to this function.
 String getTitle()
           
 String getUrl()
          Access the URL which can be used to access the entity.
 String getUrl(String rootProperty)
          Access the alternate URL which can be used to access the entity.
 Role getUserRole(String userId)
          Access the active role for this user's membership.
 Set getUsers()
          Access all users who have active role membership in the AuthzGroup.
 Set getUsersHasRole(String role)
          Access all users who have an active role membership with this role.
 Set getUsersIsAllowed(String function)
          Access all users who have an active role membership to a role that is allowed this function.
 int hashCode()
           
 boolean hasRole(String userId, String role)
          Test if this user has a membership in this AuthzGroup that has this role and is active.
 boolean isActiveEdit()
          Check to see if the edit is still active, or has already been closed.
 boolean isAllowed(String userId, String function)
          Test if this user is allowed to perform the function in this AuthzGroup.
 boolean isEmpty()
          Is this AuthzGroup empty of any roles or membership?
 boolean keepIntersection(AuthzGroup other)
          Adjust membership so that active members are all active in other, and inactive members are all defined in other
 void removeMember(String userId)
          Remove membership for for this user from the AuthzGroup.
 void removeMembers()
          Remove all membership from this AuthzGroup.
 void removeRole(String role)
          Remove this Role from this AuthzGroup.
 void removeRoles()
          Remove all Roles from this AuthzGroup.
 void setDescription(String description)
          Set the text describing this group.
 void setMaintainRole(String role)
          Set the role name to use for "maintain" access.
 void setProviderGroupId(String id)
          Set the external group id for the GroupProvider for this AuthzGroup (set to null to have none).
 void setTitle(String title)
          Set the human readable short title of this group.
 String toString()
           
 Element toXml(Document doc, Stack stack)
          Serialize the entity into XML, adding an element to the doc under the top of the stack element.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m_title

protected String m_title
The title.


m_description

protected String m_description
The description.


m_id

protected String m_id
The site id.


m_properties

protected ResourcePropertiesEdit m_properties
The properties.


m_site

protected Site m_site
The site I belong to.


m_azg

protected AuthzGroup m_azg
The azg from the AuthzGroupService that is my AuthzGroup impl.


m_azgChanged

protected boolean m_azgChanged
Set to true if we have changed our azg, so it need to be written back on save.

Constructor Detail

BaseGroup

protected BaseGroup(Site site)
Construct. Auto-generate the id.

Parameters:
site - The site in which this page lives.

BaseGroup

protected BaseGroup(String id,
                    String title,
                    String description,
                    Site site)

BaseGroup

protected BaseGroup(Group other,
                    Site site,
                    boolean exact)
Construct as a copy of another.

Parameters:
other - The other to copy.
site - The site in which this group lives.
exact - If true, we copy id - else we generate a new one.
Method Detail

getTitle

public String getTitle()
Specified by:
getTitle in interface Group
Returns:
a human readable short title of this group.

getDescription

public String getDescription()
Specified by:
getDescription in interface Group
Returns:
a text describing the group.

getContainingSite

public Site getContainingSite()
Description copied from interface: Group
Access the site in which this group lives.

Specified by:
getContainingSite in interface Group
Returns:
the site in which this group lives.

setTitle

public void setTitle(String title)
Description copied from interface: Group
Set the human readable short title of this group.

Specified by:
setTitle in interface Group
Parameters:
title - The new title.

setDescription

public void setDescription(String description)
Description copied from interface: Group
Set the text describing this group.

Specified by:
setDescription in interface Group
Parameters:
description - The new description.

getUrl

public String getUrl()
Description copied from interface: Entity
Access the URL which can be used to access the entity.

Specified by:
getUrl in interface Entity
Returns:
The URL which can be used to access the entity.

getReference

public String getReference()
Description copied from interface: Entity
Access the internal reference which can be used to access the entity from within the system.

Specified by:
getReference in interface Entity
Returns:
The the internal reference which can be used to access the entity from within the system.

getReference

public String getReference(String rootProperty)
Description copied from interface: Entity
Access the alternate internal reference which can be used to access the entity from within the system.

Specified by:
getReference in interface Entity
Parameters:
rootProperty - The name of the entity property whose value controls which alternate reference is requested. If null, the native 'raw' reference is requested.
Returns:
The the alternate internal reference which can be used to access the entity from within the system.

getUrl

public String getUrl(String rootProperty)
Description copied from interface: Entity
Access the alternate URL which can be used to access the entity.

Specified by:
getUrl in interface Entity
Parameters:
rootProperty - The name of the entity property whose value controls which alternate reference URL is requested. If null, the native 'raw' URL is requested.
Returns:
The alternate URL which can be used to access the entity.

getId

public String getId()
Description copied from interface: Identifiable
Access the id.

Specified by:
getId in interface Entity
Returns:
The id.

getProperties

public ResourceProperties getProperties()
Description copied from interface: Entity
Access the entity's properties.

Specified by:
getProperties in interface Entity
Returns:
The entity's properties.

toXml

public Element toXml(Document doc,
                     Stack stack)
Description copied from interface: Entity
Serialize the entity into XML, adding an element to the doc under the top of the stack element.

Specified by:
toXml in interface Entity
Parameters:
doc - The DOM doc to contain the XML (or null for a string return).
stack - The DOM elements, the top of which is the containing element of the new "entity" element.
Returns:
The newly added element.

isActiveEdit

public boolean isActiveEdit()
Description copied from interface: Edit
Check to see if the edit is still active, or has already been closed.

Specified by:
isActiveEdit in interface Edit
Returns:
true if the edit is active, false if it's been closed.

getPropertiesEdit

public ResourcePropertiesEdit getPropertiesEdit()
Description copied from interface: Edit
Access the resource's properties for modification

Specified by:
getPropertiesEdit in interface Edit
Returns:
The resource's properties.

toString

public String toString()

equals

public boolean equals(Object obj)

hashCode

public int hashCode()

compareTo

public int compareTo(Object obj)
Specified by:
compareTo in interface Comparable

getAzg

protected AuthzGroup getAzg()
Access (find if needed) the azg from the AuthzGroupService that implements my grouping.

Returns:
My azg.

addMember

public void addMember(String userId,
                      String roleId,
                      boolean active,
                      boolean provided)
Description copied from interface: AuthzGroup
Add a member to the AuthzGroup.

Specified by:
addMember in interface AuthzGroup
Parameters:
userId - The user.
active - The active flag.
provided - If true, from an external provider.

addRole

public Role addRole(String id)
             throws IdUsedException
Description copied from interface: AuthzGroup
Create a new Role within this AuthzGroup.

Specified by:
addRole in interface AuthzGroup
Parameters:
id - The role id.
Returns:
the new Role.
Throws:
IdUsedException - if the id is already a Role in this AuthzGroup.

addRole

public Role addRole(String id,
                    Role other)
             throws IdUsedException
Description copied from interface: AuthzGroup
Create a new Role within this AuthzGroup, as a copy of this other role

Specified by:
addRole in interface AuthzGroup
Parameters:
id - The role id.
other - The role to copy.
Returns:
the new Role.
Throws:
IdUsedException - if the id is already a Role in this AuthzGroup.

getCreatedBy

public User getCreatedBy()
Specified by:
getCreatedBy in interface AuthzGroup
Returns:
the user who created this.

getCreatedTime

public Time getCreatedTime()
Specified by:
getCreatedTime in interface AuthzGroup
Returns:
the time created.

getMaintainRole

public String getMaintainRole()
Description copied from interface: AuthzGroup
Access the name of the role to use for giving a user membership with "maintain" access.

Specified by:
getMaintainRole in interface AuthzGroup
Returns:
The name of the "maintain" role.

getMember

public Member getMember(String userId)
Description copied from interface: AuthzGroup
Access the user's membership record for this AuthzGroup; the role, and status flags.

Specified by:
getMember in interface AuthzGroup
Parameters:
userId - The user id.
Returns:
The Membership record for the user in this AuthzGroup, or null if the use is not a member.

getMembers

public Set getMembers()
Description copied from interface: AuthzGroup
Access all Membership records defined for this AuthzGroup.

Specified by:
getMembers in interface AuthzGroup
Returns:
The set of Membership records (Membership) defined for this AuthzGroup.

getModifiedBy

public User getModifiedBy()
Specified by:
getModifiedBy in interface AuthzGroup
Returns:
the user who last modified this.

getModifiedTime

public Time getModifiedTime()
Specified by:
getModifiedTime in interface AuthzGroup
Returns:
the time last modified.

getProviderGroupId

public String getProviderGroupId()
Description copied from interface: AuthzGroup
Access the group id for the GroupProvider for this AuthzGroup.

Specified by:
getProviderGroupId in interface AuthzGroup
Returns:
The the group id for the GroupProvider for this AuthzGroup, or null if none defined.

getRole

public Role getRole(String id)
Description copied from interface: AuthzGroup
Access a Role defined in this AuthzGroup.

Specified by:
getRole in interface AuthzGroup
Parameters:
id - The role id.
Returns:
The Role, if found, or null, if not.

getRoles

public Set getRoles()
Description copied from interface: AuthzGroup
Access all Roles defined for this AuthzGroup.

Specified by:
getRoles in interface AuthzGroup
Returns:
The set of roles (Role) defined for this AuthzGroup.

getRolesIsAllowed

public Set getRolesIsAllowed(String function)
Description copied from interface: AuthzGroup
Access all roles that have been granted permission to this function.

Specified by:
getRolesIsAllowed in interface AuthzGroup
Parameters:
function - The function to check.
Returns:
The Set of role names (String) that have been granted permission to this function.

getUserRole

public Role getUserRole(String userId)
Description copied from interface: AuthzGroup
Access the active role for this user's membership.

Specified by:
getUserRole in interface AuthzGroup
Parameters:
userId - The user id.
Returns:
The Role for this user's membership, or null if the user has no active membership.

getUsers

public Set getUsers()
Description copied from interface: AuthzGroup
Access all users who have active role membership in the AuthzGroup.

Specified by:
getUsers in interface AuthzGroup
Returns:
The Set of users ids (String) who have active role membership in the AuthzGroup.

getUsersHasRole

public Set getUsersHasRole(String role)
Description copied from interface: AuthzGroup
Access all users who have an active role membership with this role.

Specified by:
getUsersHasRole in interface AuthzGroup
Returns:
The Set of user ids (String) who have an active role membership with this role.

getUsersIsAllowed

public Set getUsersIsAllowed(String function)
Description copied from interface: AuthzGroup
Access all users who have an active role membership to a role that is allowed this function.

Specified by:
getUsersIsAllowed in interface AuthzGroup
Parameters:
function - The function to check.
Returns:
The Set of user ids (String) who have an active role membership to a role that is allowed this function.

hasRole

public boolean hasRole(String userId,
                       String role)
Description copied from interface: AuthzGroup
Test if this user has a membership in this AuthzGroup that has this role and is active.

Specified by:
hasRole in interface AuthzGroup
Parameters:
userId - The user id.
role - The role name.
Returns:
true if the User has has a membership in this AuthzGroup that has this role and is active.

isAllowed

public boolean isAllowed(String userId,
                         String function)
Description copied from interface: AuthzGroup
Test if this user is allowed to perform the function in this AuthzGroup.

Specified by:
isAllowed in interface AuthzGroup
Parameters:
userId - The user id.
function - The function to open.
Returns:
true if this user is allowed to perform the function in this AuthzGroup, false if not.

isEmpty

public boolean isEmpty()
Description copied from interface: AuthzGroup
Is this AuthzGroup empty of any roles or membership?

Specified by:
isEmpty in interface AuthzGroup
Returns:
true if the AuthzGroup is empty, false if not.

removeMember

public void removeMember(String userId)
Description copied from interface: AuthzGroup
Remove membership for for this user from the AuthzGroup.

Specified by:
removeMember in interface AuthzGroup
Parameters:
userId - The user.

removeMembers

public void removeMembers()
Description copied from interface: AuthzGroup
Remove all membership from this AuthzGroup.

Specified by:
removeMembers in interface AuthzGroup

removeRole

public void removeRole(String role)
Description copied from interface: AuthzGroup
Remove this Role from this AuthzGroup. Any grants of this Role in the AuthzGroup are also removed.

Specified by:
removeRole in interface AuthzGroup
Parameters:
role - The role name.

removeRoles

public void removeRoles()
Description copied from interface: AuthzGroup
Remove all Roles from this AuthzGroup.

Specified by:
removeRoles in interface AuthzGroup

setMaintainRole

public void setMaintainRole(String role)
Description copied from interface: AuthzGroup
Set the role name to use for "maintain" access.

Specified by:
setMaintainRole in interface AuthzGroup
Parameters:
role - The name of the "maintain" role.

setProviderGroupId

public void setProviderGroupId(String id)
Description copied from interface: AuthzGroup
Set the external group id for the GroupProvider for this AuthzGroup (set to null to have none).

Specified by:
setProviderGroupId in interface AuthzGroup
Parameters:
id - The external group id for the GroupProvider, or null if there is to be none.

keepIntersection

public boolean keepIntersection(AuthzGroup other)
Description copied from interface: AuthzGroup
Adjust membership so that active members are all active in other, and inactive members are all defined in other

Specified by:
keepIntersection in interface AuthzGroup
Parameters:
other - The other azg to adjust to.
Returns:
true if any changes were made, false if not.