org.jasig.portal.groups
Class GroupMemberImpl

java.lang.Object
  extended by org.jasig.portal.groups.GroupMemberImpl
All Implemented Interfaces:
IGroupMember, IBasicEntity
Direct Known Subclasses:
EntityGroupImpl, EntityImpl

public abstract class GroupMemberImpl
extends java.lang.Object
implements IGroupMember

GroupMemberImpl summary first sentence goes here.

Version:
$Revision: 1.20.2.1 $
Author:
Dan Ellentuck
See Also:
IGroupMember

Field Summary
private static java.lang.Class defaultEntityType
           
private  java.util.Set groupKeys
           
private  boolean groupKeysInitialized
           
private  EntityIdentifier underlyingEntityIdentifier
           
 
Constructor Summary
GroupMemberImpl(EntityIdentifier newEntityIdentifier)
          GroupMemberImpl constructor
GroupMemberImpl(java.lang.String key, java.lang.Class type)
          GroupMemberImpl constructor
 
Method Summary
 void addGroup(IEntityGroup eg)
          Adds the key of the IEntityGroup to our Set of group keys by copying the keys, updating the copy, and replacing the old keys with the copy.
private  boolean areGroupKeysInitialized()
           
protected  java.util.Set castAndCopyHashSet(java.util.Set s)
          Cast a Set to a HashSet, clone it, and down cast back to Set.
 boolean contains(IGroupMember gm)
          Default implementation, overridden on EntityGroupImpl.
private  java.util.Set copyGroupKeys()
          Clone the group keys.
 boolean deepContains(IGroupMember gm)
          Default implementation, overridden on EntityGroupImpl.
 java.util.Iterator getAllContainingGroups()
          Returns an Iterator over the Set of this IGroupMember's recursively-retrieved parent groups.
 java.util.Iterator getAllEntities()
          Default implementation, overridden on EntityGroupImpl.
 java.util.Iterator getAllMembers()
          Default implementation, overridden on EntityGroupImpl.
protected  java.lang.String getCacheKey()
           
protected  ICompositeGroupService getCompositeGroupService()
          Returns the composite group service.
 java.util.Iterator getContainingGroups()
          Returns an Iterator over this IGroupMember's parent groups.
private  java.lang.Class getDefaultEntityType()
           
private  java.util.Iterator getEmptyIterator()
           
 java.util.Iterator getEntities()
          Default implementation, overridden on EntityGroupImpl.
private  java.util.Set getGroupKeys()
           
 java.lang.String getKey()
          Returns the key of the underlying entity.
 IEntityGroup getMemberGroupNamed(java.lang.String name)
          Default implementation, overridden on EntityGroupImpl.
 java.util.Iterator getMembers()
          Default implementation, overridden on EntityGroupImpl.
 java.lang.Class getType()
          Returns the type of the underlying entity.
 EntityIdentifier getUnderlyingEntityIdentifier()
          Returns EntityIdentifier for this IGroupMember's underlying entity.
 int hashCode()
           
 boolean hasMembers()
          Default implementation, overridden on EntityGroupImpl.
private  void initializeContainingGroupKeys()
          Cache the keys for IEntityGroups that contain this IGroupMember.
 boolean isDeepMemberOf(IGroupMember gm)
          Answers if this IGroupMember is, recursively, a member of IGroupMember gm.
 boolean isEntity()
           
 boolean isGroup()
           
protected  boolean isKnownEntityType(java.lang.Class anEntityType)
           
 boolean isMemberOf(IGroupMember gm)
          Answers if this IGroupMember is a member of IGroupMember gm.
protected  java.util.Set primGetAllContainingGroups(java.util.Set s)
          Returns the Set of groups in our member Collection and, recursively, in the Collections of our members.
 void removeGroup(IEntityGroup eg)
          Removes the key of the IEntityGroup from our Set of group keys by copying the keys, updating the copy, and replacing the old keys with the copy.
private  void setGroupKeys(java.util.Set newGroupKeys)
           
protected  void setGroupKeysInitialized(boolean newGroupKeysInitialized)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jasig.portal.groups.IGroupMember
equals, getEntityType, getLeafType
 
Methods inherited from interface org.jasig.portal.IBasicEntity
getEntityIdentifier
 

Field Detail

underlyingEntityIdentifier

private EntityIdentifier underlyingEntityIdentifier

defaultEntityType

private static java.lang.Class defaultEntityType

groupKeys

private java.util.Set groupKeys

groupKeysInitialized

private boolean groupKeysInitialized
Constructor Detail

GroupMemberImpl

public GroupMemberImpl(java.lang.String key,
                       java.lang.Class type)
                throws GroupsException
GroupMemberImpl constructor

Throws:
GroupsException

GroupMemberImpl

public GroupMemberImpl(EntityIdentifier newEntityIdentifier)
                throws GroupsException
GroupMemberImpl constructor

Throws:
GroupsException
Method Detail

addGroup

public void addGroup(IEntityGroup eg)
              throws GroupsException
Adds the key of the IEntityGroup to our Set of group keys by copying the keys, updating the copy, and replacing the old keys with the copy. This lets us confine synchronization to the getter and setter methods for the keys.

Parameters:
eg - org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

areGroupKeysInitialized

private boolean areGroupKeysInitialized()
Returns:
boolean

contains

public boolean contains(IGroupMember gm)
                 throws GroupsException
Default implementation, overridden on EntityGroupImpl.

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

copyGroupKeys

private java.util.Set copyGroupKeys()
                             throws GroupsException
Clone the group keys.

Returns:
Set
Throws:
GroupsException

castAndCopyHashSet

protected java.util.Set castAndCopyHashSet(java.util.Set s)
Cast a Set to a HashSet, clone it, and down cast back to Set.

Returns:
HashSet

deepContains

public boolean deepContains(IGroupMember gm)
                     throws GroupsException
Default implementation, overridden on EntityGroupImpl.

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

getAllContainingGroups

public java.util.Iterator getAllContainingGroups()
                                          throws GroupsException
Returns an Iterator over the Set of this IGroupMember's recursively-retrieved parent groups.

Specified by:
getAllContainingGroups in interface IGroupMember
Returns:
java.util.Iterator
Throws:
GroupsException

getAllEntities

public java.util.Iterator getAllEntities()
                                  throws GroupsException
Default implementation, overridden on EntityGroupImpl.

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

getAllMembers

public java.util.Iterator getAllMembers()
                                 throws GroupsException
Default implementation, overridden on EntityGroupImpl.

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

getCacheKey

protected java.lang.String getCacheKey()
Returns:
java.lang.String

getCompositeGroupService

protected ICompositeGroupService getCompositeGroupService()
                                                   throws GroupsException
Returns the composite group service.

Throws:
GroupsException

getContainingGroups

public java.util.Iterator getContainingGroups()
                                       throws GroupsException
Returns an Iterator over this IGroupMember's parent groups. Synchronize the collection of keys with adds and removes.

Specified by:
getContainingGroups in interface IGroupMember
Returns:
java.util.Iterator
Throws:
GroupsException

getDefaultEntityType

private java.lang.Class getDefaultEntityType()
Returns:
java.lang.Class

getEmptyIterator

private java.util.Iterator getEmptyIterator()
Returns:
java.util.Iterator

getEntities

public java.util.Iterator getEntities()
                               throws GroupsException
Default implementation, overridden on EntityGroupImpl.

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

getGroupKeys

private java.util.Set getGroupKeys()
                            throws GroupsException
Returns:
java.util.Set
Throws:
GroupsException

getKey

public java.lang.String getKey()
Description copied from interface: IGroupMember
Returns the key of the underlying entity.

Specified by:
getKey in interface IGroupMember
Returns:
java.lang.String

getMemberGroupNamed

public IEntityGroup getMemberGroupNamed(java.lang.String name)
                                 throws GroupsException
Default implementation, overridden on EntityGroupImpl.

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

getMembers

public java.util.Iterator getMembers()
                              throws GroupsException
Default implementation, overridden on EntityGroupImpl.

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

getType

public java.lang.Class getType()
Description copied from interface: IGroupMember
Returns the type of the underlying entity. For a group this will be IEntityGroup. For an entity, it will be the type of the underlying EntityIdentifier.

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

getUnderlyingEntityIdentifier

public EntityIdentifier getUnderlyingEntityIdentifier()
Description copied from interface: IGroupMember
Returns EntityIdentifier for this IGroupMember's underlying entity. In the case of an IEntityGroup, it will be the EntityIdentifier for this. In the case of an IEntity, it will be the EntityIdentifier that identifies the underlying IPerson, ChannelDefinition, etc.

Specified by:
getUnderlyingEntityIdentifier in interface IGroupMember
Returns:
EntityIdentifier

hashCode

public int hashCode()
Specified by:
hashCode in interface IGroupMember
Overrides:
hashCode in class java.lang.Object
Returns:
int

hasMembers

public boolean hasMembers()
                   throws GroupsException
Default implementation, overridden on EntityGroupImpl.

Specified by:
hasMembers in interface IGroupMember
Returns:
boolean
Throws:
GroupsException

initializeContainingGroupKeys

private void initializeContainingGroupKeys()
                                    throws GroupsException
Cache the keys for IEntityGroups that contain this IGroupMember.

Throws:
GroupsException

isDeepMemberOf

public boolean isDeepMemberOf(IGroupMember gm)
                       throws GroupsException
Answers if this IGroupMember is, recursively, a member of IGroupMember gm.

Specified by:
isDeepMemberOf in interface IGroupMember
Parameters:
gm - org.jasig.portal.groups.IGroupMember
Returns:
boolean
Throws:
GroupsException

isEntity

public boolean isEntity()
Specified by:
isEntity in interface IGroupMember
Returns:
boolean

isGroup

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

isKnownEntityType

protected boolean isKnownEntityType(java.lang.Class anEntityType)
                             throws GroupsException
Returns:
boolean.
Throws:
GroupsException

isMemberOf

public boolean isMemberOf(IGroupMember gm)
                   throws GroupsException
Answers if this IGroupMember is a member of IGroupMember gm.

Specified by:
isMemberOf in interface IGroupMember
Parameters:
gm - org.jasig.portal.groups.IGroupMember
Returns:
boolean
Throws:
GroupsException

primGetAllContainingGroups

protected java.util.Set primGetAllContainingGroups(java.util.Set s)
                                            throws GroupsException
Returns the Set of groups in our member Collection and, recursively, in the Collections of our members.

Parameters:
s - java.lang.Set - A Set that groups are added to.
Returns:
java.util.Set
Throws:
GroupsException

removeGroup

public void removeGroup(IEntityGroup eg)
                 throws GroupsException
Removes the key of the IEntityGroup from our Set of group keys by copying the keys, updating the copy, and replacing the old keys with the copy. This lets us confine synchronization to the getter and setter methods for the keys.

Parameters:
eg - org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

setGroupKeys

private void setGroupKeys(java.util.Set newGroupKeys)
Parameters:
newGroupKeys - Set

setGroupKeysInitialized

protected void setGroupKeysInitialized(boolean newGroupKeysInitialized)
Parameters:
newGroupKeysInitialized - boolean