uPortal 2.4.1
API Documentation

org.jasig.portal.groups
Class EntityGroupImpl

java.lang.Object
  extended byorg.jasig.portal.groups.GroupMemberImpl
      extended byorg.jasig.portal.groups.EntityGroupImpl
All Implemented Interfaces:
IBasicEntity, IEntityGroup, IGroupMember
Direct Known Subclasses:
LockableEntityGroupImpl

public class EntityGroupImpl
extends GroupMemberImpl
implements IEntityGroup

Reference implementation for IEntityGroup.

Groups do not keep references to their members but instead cache member keys. The members are cached externally. The rules for controlling access to the key caches are a bit obscure, but you should understand them before writing code that updates groups. Access to the caches themselves is synchronized via the cache getters and setters. All requests to get group members and to add or remove group members ultimately go through these methods. The mutating methods, addMember() and removeMember() however, do a copy-on-write. That is, they first make a copy of the cache, add or remove the member key, and then replace the original cache with the copy. This permits multiple read and write threads to run concurrently without throwing ConcurrentModificationExceptions. But it still leaves open the danger of data races because nothing in this class guarantees serialized write access. You must impose this from without, either via explicit locking (GroupService.getLockableGroup()) or by synchronizing access from the caller.

Version:
$Revision: 1.21 $
Author:
Dan Ellentuck
See Also:
IEntityGroup

Constructor Summary
EntityGroupImpl(java.lang.String groupKey, java.lang.Class entityType)
          EntityGroupImpl
 
Method Summary
 void addMember(IGroupMember gm)
          Adds IGroupMember gm to our member Map and conversely, adds this to gm's group Map, after checking that the addition does not violate group rules.
 boolean contains(IGroupMember gm)
          Checks if GroupMember gm is a member of this.
 boolean deepContains(IGroupMember gm)
          Checks recursively if GroupMember gm is a member of this.
 void delete()
          Delegates to the factory.
 boolean equals(java.lang.Object obj)
          Answers if Object o is an IGroupMember that refers to the same underlying entity(ies) as this.
 java.util.HashMap getAddedMembers()
           
 java.util.Iterator getAllEntities()
          Returns an Iterator over the Set of this IEntityGroup's recursively-retrieved members that are IEntities.
 java.util.Iterator getAllMembers()
          Returns an Iterator over the Set of recursively-retrieved IGroupMembers that are members of this IEntityGroup.
 java.lang.String getCreatorID()
          Returns the name of the group creator.
 java.lang.String getDescription()
          Returns the group description, which may be null.
 java.util.Iterator getEntities()
          Returns an Iterator over this IEntityGroup's members that are IEntities.
 EntityIdentifier getEntityIdentifier()
           
 java.lang.String getEntityKey()
          Returns the key of the underyling entity.
 java.lang.Class getEntityType()
          Returns the entity type of this groups's leaf members.
 java.lang.String getGroupID()
           
 java.lang.Class getLeafType()
          Returns the entity type of this groups's members.
 java.lang.String getLocalKey()
          Returns the key from the group service of origin.
 IEntityGroup getMemberGroupNamed(java.lang.String name)
          Returns the named member IEntityGroup.
 java.util.Iterator getMembers()
          Returns an Iterator over the GroupMembers in our member Collection.
 java.lang.String getName()
          Returns the group name.
 java.util.HashMap getRemovedMembers()
           
 javax.naming.Name getServiceName()
          Returns the Name of the group service of origin.
 java.lang.Class getType()
          Returns this object's type for purposes of caching and locking, as opposed to the underlying entity type.
 boolean hasAdds()
          Answers if there are any added memberships not yet committed to the database.
 boolean hasDeletes()
          Answers if there are any deleted memberships not yet committed to the database.
 int hashCode()
          Generates a hash code for the receiver.
 boolean hasMembers()
          Answers if this IGroupMember has any members.
 boolean isDirty()
          Answers if there are any added or deleted memberships not yet committed to the database.
 boolean isEditable()
          Answers if this IEntityGroup can be changed or deleted.
 boolean isGroup()
           
 void primSetName(java.lang.String newName)
           
 void removeMember(IGroupMember gm)
          Removes IGroupMember gm from our member Map and, conversely, remove this from gm's group Map.
 void setCreatorID(java.lang.String newCreatorID)
           
 void setDescription(java.lang.String newDescription)
           
 void setLocalGroupService(IIndividualGroupService newIndividualGroupService)
          Sets the group service of origin.
 void setName(java.lang.String newName)
          We used to check duplicate sibling names but no longer do.
 void setServiceName(javax.naming.Name newServiceName)
          Sets the service Name of the group service of origin.
 java.lang.String toString()
          Returns a String that represents the value of this object.
 void update()
          Delegate to the factory.
 void updateMembers()
          Delegate to the factory.
 
Methods inherited from class org.jasig.portal.groups.GroupMemberImpl
addGroup, getAllContainingGroups, getContainingGroups, getKey, getUnderlyingEntityIdentifier, isDeepMemberOf, isEntity, isMemberOf, removeGroup
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jasig.portal.groups.IGroupMember
getAllContainingGroups, getContainingGroups, getKey, getUnderlyingEntityIdentifier, isDeepMemberOf, isEntity, isMemberOf
 

Constructor Detail

EntityGroupImpl

public EntityGroupImpl(java.lang.String groupKey,
                       java.lang.Class entityType)
                throws GroupsException
EntityGroupImpl

Method Detail

addMember

public void addMember(IGroupMember gm)
               throws GroupsException
Adds IGroupMember gm to our member Map and conversely, adds this to gm's group Map, after checking that the addition does not violate group rules. Remember that we have added it so we can update the database if necessary.

Specified by:
addMember in interface IEntityGroup
Parameters:
gm - org.jasig.portal.groups.IGroupMember
Throws:
GroupsException - is thrown if the member is a group and this group already has a group with the same name or if the addition of the group creates a circular reference.

contains

public boolean contains(IGroupMember gm)
                 throws GroupsException
Checks if GroupMember gm is a member of this.

Specified by:
contains in interface IGroupMember
Overrides:
contains in class GroupMemberImpl
Parameters:
gm - org.jasig.portal.groups.IGroupMember
Returns:
boolean
Throws:
GroupsException

deepContains

public boolean deepContains(IGroupMember gm)
                     throws GroupsException
Checks recursively if GroupMember gm is a member of this.

Specified by:
deepContains in interface IGroupMember
Overrides:
deepContains in class GroupMemberImpl
Parameters:
gm - org.jasig.portal.groups.IGroupMember
Returns:
boolean
Throws:
GroupsException

delete

public void delete()
            throws GroupsException
Delegates to the factory.

Specified by:
delete in interface IEntityGroup
Throws:
GroupsException - if the delete cannot be performed.

equals

public boolean equals(java.lang.Object obj)
Description copied from interface: IGroupMember
Answers if Object o is an IGroupMember that refers to the same underlying entity(ies) as this.

Specified by:
equals in interface IGroupMember
Parameters:
obj - the Object to compare with
Returns:
true if these Objects are equal; false otherwise.
See Also:
Hashtable

getAddedMembers

public java.util.HashMap getAddedMembers()
Returns:
java.util.HashMap

getAllEntities

public java.util.Iterator getAllEntities()
                                  throws GroupsException
Returns an Iterator over the Set of this IEntityGroup's recursively-retrieved members that are IEntities.

Specified by:
getAllEntities in interface IGroupMember
Overrides:
getAllEntities in class GroupMemberImpl
Returns:
java.util.Iterator
Throws:
GroupsException

getAllMembers

public java.util.Iterator getAllMembers()
                                 throws GroupsException
Returns an Iterator over the Set of recursively-retrieved IGroupMembers that are members of this IEntityGroup.

Specified by:
getAllMembers in interface IGroupMember
Overrides:
getAllMembers in class GroupMemberImpl
Returns:
java.util.Iterator
Throws:
GroupsException

getCreatorID

public java.lang.String getCreatorID()
Description copied from interface: IEntityGroup
Returns the name of the group creator. May be null.

Specified by:
getCreatorID in interface IEntityGroup
Returns:
java.lang.String

getDescription

public java.lang.String getDescription()
Description copied from interface: IEntityGroup
Returns the group description, which may be null.

Specified by:
getDescription in interface IEntityGroup
Returns:
java.lang.String

getEntities

public java.util.Iterator getEntities()
                               throws GroupsException
Returns an Iterator over this IEntityGroup's members that are IEntities.

Specified by:
getEntities in interface IGroupMember
Overrides:
getEntities in class GroupMemberImpl
Returns:
java.util.Iterator
Throws:
GroupsException

getEntityIdentifier

public EntityIdentifier getEntityIdentifier()
Specified by:
getEntityIdentifier in interface IBasicEntity
Returns:
EntityIdentifier

getEntityKey

public java.lang.String getEntityKey()
Returns the key of the underyling entity.

Returns:
java.lang.String

getEntityType

public java.lang.Class getEntityType()
Returns the entity type of this groups's leaf members.

Specified by:
getEntityType in interface IGroupMember
Returns:
java.lang.Class
See Also:
EntityTypes

getGroupID

public java.lang.String getGroupID()
Returns:
String

getLeafType

public java.lang.Class getLeafType()
Returns the entity type of this groups's members.

Specified by:
getLeafType in interface IGroupMember
Returns:
java.lang.Class
See Also:
EntityTypes

getLocalKey

public java.lang.String getLocalKey()
Returns the key from the group service of origin.

Specified by:
getLocalKey in interface IEntityGroup
Returns:
String

getMemberGroupNamed

public IEntityGroup getMemberGroupNamed(java.lang.String name)
                                 throws GroupsException
Returns the named member IEntityGroup.

Specified by:
getMemberGroupNamed in interface IGroupMember
Overrides:
getMemberGroupNamed in class GroupMemberImpl
Parameters:
name - java.lang.String
Returns:
org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

getMembers

public java.util.Iterator getMembers()
                              throws GroupsException
Returns an Iterator over the GroupMembers in our member Collection.

Specified by:
getMembers in interface IGroupMember
Overrides:
getMembers in class GroupMemberImpl
Returns:
java.util.Iterator
Throws:
GroupsException

getName

public java.lang.String getName()
Description copied from interface: IEntityGroup
Returns the group name.

Specified by:
getName in interface IEntityGroup
Returns:
java.lang.String

getRemovedMembers

public java.util.HashMap getRemovedMembers()
Returns:
java.util.HashMap

getServiceName

public javax.naming.Name getServiceName()
Returns the Name of the group service of origin.

Specified by:
getServiceName in interface IEntityGroup
Returns:
javax.naming.Nme

getType

public java.lang.Class getType()
Returns this object's type for purposes of caching and locking, as opposed to the underlying entity type.

Specified by:
getType in interface IGroupMember
Overrides:
getType in class GroupMemberImpl
Returns:
java.lang.Class

hasAdds

public boolean hasAdds()
Answers if there are any added memberships not yet committed to the database.

Returns:
boolean

hasDeletes

public boolean hasDeletes()
Answers if there are any deleted memberships not yet committed to the database.

Returns:
boolean

hashCode

public int hashCode()
Generates a hash code for the receiver. This method is supported primarily for hash tables, such as those provided in java.util.

Specified by:
hashCode in interface IGroupMember
Overrides:
hashCode in class GroupMemberImpl
Returns:
an integer hash code for the receiver
See Also:
Hashtable

hasMembers

public boolean hasMembers()
                   throws GroupsException
Description copied from interface: IGroupMember
Answers if this IGroupMember has any members.

Specified by:
hasMembers in interface IGroupMember
Overrides:
hasMembers in class GroupMemberImpl
Returns:
boolean
Throws:
GroupsException

isDirty

public boolean isDirty()
Answers if there are any added or deleted memberships not yet committed to the database.

Returns:
boolean

isEditable

public boolean isEditable()
                   throws GroupsException
Answers if this IEntityGroup can be changed or deleted.

Specified by:
isEditable in interface IEntityGroup
Returns:
boolean
Throws:
GroupsException

isGroup

public boolean isGroup()
Specified by:
isGroup in interface IGroupMember
Overrides:
isGroup in class GroupMemberImpl
Returns:
boolean

primSetName

public void primSetName(java.lang.String newName)
Parameters:
newName - java.lang.String

removeMember

public void removeMember(IGroupMember gm)
                  throws GroupsException
Removes IGroupMember gm from our member Map and, conversely, remove this from gm's group Map. Remember that we have removed it so we can update the database, if necessary.

Specified by:
removeMember in interface IEntityGroup
Parameters:
gm - org.jasig.portal.groups.IGroupMember
Throws:
GroupsException

setCreatorID

public void setCreatorID(java.lang.String newCreatorID)
Specified by:
setCreatorID in interface IEntityGroup
Parameters:
newCreatorID - java.lang.String

setDescription

public void setDescription(java.lang.String newDescription)
Specified by:
setDescription in interface IEntityGroup
Parameters:
newDescription - java.lang.String

setLocalGroupService

public void setLocalGroupService(IIndividualGroupService newIndividualGroupService)
                          throws GroupsException
Description copied from interface: IEntityGroup
Sets the group service of origin.

Specified by:
setLocalGroupService in interface IEntityGroup
Parameters:
newIndividualGroupService - IIndividualGroupService
Throws:
GroupsException

setName

public void setName(java.lang.String newName)
             throws GroupsException
We used to check duplicate sibling names but no longer do.

Specified by:
setName in interface IEntityGroup
Parameters:
newName - java.lang.String
Throws:
GroupsException

setServiceName

public void setServiceName(javax.naming.Name newServiceName)
                    throws GroupsException
Sets the service Name of the group service of origin.

Throws:
GroupsException

toString

public java.lang.String toString()
Returns a String that represents the value of this object.

Returns:
a string representation of the receiver

update

public void update()
            throws GroupsException
Delegate to the factory.

Specified by:
update in interface IEntityGroup
Throws:
GroupsException - if the update cannot be performed.

updateMembers

public void updateMembers()
                   throws GroupsException
Delegate to the factory.

Specified by:
updateMembers in interface IEntityGroup
Throws:
GroupsException - if the update cannot be performed.

uPortal 2.4.1
API Documentation