org.jasig.portal.groups
Class ReferenceIndividualGroupService

java.lang.Object
  extended by org.jasig.portal.groups.ReferenceComponentGroupService
      extended by org.jasig.portal.groups.ReferenceCompositeGroupService
          extended by org.jasig.portal.groups.ReferenceIndividualGroupService
All Implemented Interfaces:
IComponentGroupService, ICompositeGroupService, IGroupService, IIndividualGroupService, ILockableGroupService

public class ReferenceIndividualGroupService
extends ReferenceCompositeGroupService
implements IIndividualGroupService, ILockableGroupService

Reference individual, or leaf, group service.

Version:
$Revision: 1.23 $
Author:
Dan Ellentuck

Field Summary
protected  IEntitySearcher entitySearcher
           
protected  IEntityGroupStore groupFactory
           
private static org.apache.commons.logging.Log log
           
protected  ComponentGroupServiceDescriptor serviceDescriptor
           
 
Fields inherited from class org.jasig.portal.groups.ReferenceCompositeGroupService
defaultService, entityFactory
 
Fields inherited from class org.jasig.portal.groups.ReferenceComponentGroupService
componentServices, serviceName
 
Constructor Summary
ReferenceIndividualGroupService()
          ReferenceGroupsService constructor.
ReferenceIndividualGroupService(ComponentGroupServiceDescriptor svcDescriptor)
          ReferenceGroupsService constructor.
 
Method Summary
protected  boolean cacheInUse()
          Answers if IGroupMembers are being cached.
 boolean contains(IEntityGroup group, IGroupMember member)
          Answers if group contains member.
 void deleteGroup(IEntityGroup group)
          Removes the IEntityGroup from the cache and the store.
 void deleteGroup(ILockableEntityGroup group)
          Removes the ILockableEntityGroup from the cache and the store, including both parent and child memberships.
private  EntityIdentifier[] filterEntities(EntityIdentifier[] entities, IEntityGroup ancestor)
           
 java.util.Iterator findContainingGroups(IGroupMember gm)
          Returns and caches the containing groups for the IGroupMember
 IEntityGroup findGroup(CompositeEntityIdentifier ent)
          Returns a pre-existing IEntityGroup or null if it does not exist.
 IEntityGroup findGroup(java.lang.String key)
          Returns a pre-existing IEntityGroup or null if it does not exist.
protected  IEntityGroup findGroupWithCache(CompositeEntityIdentifier ent)
          Returns a pre-existing IEntityGroup or null if it does not exist.
protected  IEntityGroup findGroupWithCache(java.lang.String key)
          Returns a pre-existing IEntityGroup or null if it does not exist.
 ILockableEntityGroup findGroupWithLock(java.lang.String key, java.lang.String owner)
          Returns a pre-existing ILockableEntityGroup or null if the group is not found.
 ILockableEntityGroup findGroupWithLock(java.lang.String key, java.lang.String owner, int secs)
          Returns a pre-existing ILockableEntityGroup or null if the group is not found.
protected  java.util.Iterator findLocalMemberGroups(IEntityGroup eg)
          Returns and caches the member groups for the IEntityGroup
 java.util.Iterator findMemberEntities(IEntityGroup group)
          Finds the IEntities that are members of group.
 java.util.Iterator findMemberGroups(IEntityGroup eg)
          Returns member groups for the IEntityGroup.
 java.util.Iterator findMembers(IEntityGroup eg)
          Returns and members for the IEntityGroup.
 IEntity getEntity(java.lang.String key, java.lang.Class type)
          Returns an IEntity representing a portal entity.
 IEntityStore getEntityFactory()
          Returns an IEntity representing a portal entity.
protected  IEntityGroup getGroupFromCache(java.lang.String key)
          Returns a cached IEntityGroup or null if it has not been cached.
 IGroupMember getGroupMember(EntityIdentifier underlyingEntityIdentifier)
          Returns an IGroupMember representing either a group or a portal entity, based on the EntityIdentifier, which refers to the UNDERLYING entity for the IGroupMember.
 IGroupMember getGroupMember(java.lang.String key, java.lang.Class type)
          Returns an IGroupMember representing either a group or a portal entity.
 IEntityGroupStore getGroupStore()
          Returns the implementation of IEntityGroupStore whose class name was retrieved by the PropertiesManager (see initialize()).
protected  ComponentGroupServiceDescriptor getServiceDescriptor()
           
private  void initialize()
           
 boolean isEditable()
          Answers if this service is updateable by the portal.
 boolean isEditable(IEntityGroup group)
          Answers if the group can be updated or deleted in the store.
protected  boolean isForeign(IGroupMember member)
          A foreign member is a group from a different service.
protected  boolean isInternallyManaged()
          Answers if this service is managed by the portal and is therefore updatable.
 boolean isLeafService()
          Answers if this service is a leaf in the composite; a service that actually operates on groups.
 IEntityGroup newGroup(java.lang.Class type)
          Returns a new IEntityGroup for the given Class with an unused key.
protected  IEntityGroup primFindGroup(java.lang.String localKey)
          Returns a pre-existing IEntityGroup or null if it does not exist.
protected  IEntity primGetEntity(java.lang.String key, java.lang.Class type)
          Returns an IEntity representing a portal entity.
private  void removeDeletedGroupFromContainingGroups(ILockableEntityGroup group)
          Removes the ILockableEntityGroup from its containing groups.
private  EntityIdentifier[] removeDuplicates(EntityIdentifier[] entities)
           
 EntityIdentifier[] searchForEntities(java.lang.String query, int method, java.lang.Class type)
          Find EntityIdentifiers for entities whose name matches the query string according to the specified method and is of the specified type
 EntityIdentifier[] searchForEntities(java.lang.String query, int method, java.lang.Class type, IEntityGroup ancestor)
          Find EntityIdentifiers for entities whose name matches the query string according to the specified method, is of the specified type and descends from the specified group
 EntityIdentifier[] searchForGroups(java.lang.String query, int method, java.lang.Class leaftype)
          Find EntityIdentifiers for groups whose name matches the query string according to the specified method and matches the provided leaf type
 EntityIdentifier[] searchForGroups(java.lang.String query, int method, java.lang.Class leaftype, IEntityGroup ancestor)
          Find EntityIdentifiers for groups whose name matches the query string according to the specified method, has the provided leaf type and descends from the specified group
protected  void synchronizeGroupMembersOnDelete(IEntityGroup group)
          Remove the back pointers of the group members of the deleted group.
protected  void synchronizeGroupMembersOnUpdate(IEntityGroup group)
          Adjust the back pointers of the updated group members to either add or remove the parent group.
protected  void throwExceptionIfNotInternallyManaged()
           
 void updateGroup(IEntityGroup group)
          Update the store and the updated members.
 void updateGroup(ILockableEntityGroup group)
          Updates the ILockableEntityGroup in the cache and the store.
 void updateGroup(ILockableEntityGroup group, boolean renewLock)
          Updates the ILockableEntityGroup in the store and removes it from the cache.
 void updateGroupMembers(IEntityGroup group)
          Update the store and the updated members.
 void updateGroupMembers(ILockableEntityGroup group)
          Updates the ILockableEntityGroup in the cache and the store.
 void updateGroupMembers(ILockableEntityGroup group, boolean renewLock)
          Updates the ILockableEntityGroup in the store and removes it from the cache.
 
Methods inherited from class org.jasig.portal.groups.ReferenceCompositeGroupService
cacheAdd, cacheRemove, cacheUpdate, getComponentService, getComponentService, getDefaultService, getEntity, getEntityFromCache, initializeComponentServices, newCompositeEntityIdentifier, newGroup, setComponentServices
 
Methods inherited from class org.jasig.portal.groups.ReferenceComponentGroupService
getComponentServices, getServiceName, setServiceName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jasig.portal.groups.ICompositeGroupService
getEntity, newGroup
 
Methods inherited from interface org.jasig.portal.groups.IComponentGroupService
getComponentServices, getServiceName, setServiceName
 

Field Detail

log

private static final org.apache.commons.logging.Log log

serviceDescriptor

protected ComponentGroupServiceDescriptor serviceDescriptor

groupFactory

protected IEntityGroupStore groupFactory

entitySearcher

protected IEntitySearcher entitySearcher
Constructor Detail

ReferenceIndividualGroupService

public ReferenceIndividualGroupService()
                                throws GroupsException
ReferenceGroupsService constructor.

Throws:
GroupsException

ReferenceIndividualGroupService

public ReferenceIndividualGroupService(ComponentGroupServiceDescriptor svcDescriptor)
                                throws GroupsException
ReferenceGroupsService constructor.

Throws:
GroupsException
Method Detail

cacheInUse

protected boolean cacheInUse()
Answers if IGroupMembers are being cached.


deleteGroup

public void deleteGroup(IEntityGroup group)
                 throws GroupsException
Removes the IEntityGroup from the cache and the store.

Specified by:
deleteGroup in interface IGroupService
Specified by:
deleteGroup in interface IIndividualGroupService
Parameters:
group - IEntityGroup
Throws:
GroupsException

removeDeletedGroupFromContainingGroups

private void removeDeletedGroupFromContainingGroups(ILockableEntityGroup group)
                                             throws GroupsException
Removes the ILockableEntityGroup from its containing groups. The finally block tries to release any groups that are still locked, which can occur if an attempt to remove the group from one of its containing groups fails and throws a GroupsException. In this event, we do not try to roll back any successful removes, since that would probably fail anyway.

Parameters:
group - ILockableEntityGroup
Throws:
GroupsException

deleteGroup

public void deleteGroup(ILockableEntityGroup group)
                 throws GroupsException
Removes the ILockableEntityGroup from the cache and the store, including both parent and child memberships.

Specified by:
deleteGroup in interface ILockableGroupService
Parameters:
group - ILockableEntityGroup
Throws:
GroupsException

filterEntities

private EntityIdentifier[] filterEntities(EntityIdentifier[] entities,
                                          IEntityGroup ancestor)
                                   throws GroupsException
Throws:
GroupsException

findContainingGroups

public java.util.Iterator findContainingGroups(IGroupMember gm)
                                        throws GroupsException
Returns and caches the containing groups for the IGroupMember

Specified by:
findContainingGroups in interface ICompositeGroupService
Specified by:
findContainingGroups in interface IGroupService
Overrides:
findContainingGroups in class ReferenceCompositeGroupService
Parameters:
gm - IGroupMember
Throws:
GroupsException

findGroup

public IEntityGroup findGroup(java.lang.String key)
                       throws GroupsException
Returns a pre-existing IEntityGroup or null if it does not exist.

Specified by:
findGroup in interface ICompositeGroupService
Specified by:
findGroup in interface IGroupService
Overrides:
findGroup in class ReferenceCompositeGroupService
Throws:
GroupsException

findGroup

public IEntityGroup findGroup(CompositeEntityIdentifier ent)
                       throws GroupsException
Returns a pre-existing IEntityGroup or null if it does not exist.

Specified by:
findGroup in interface IIndividualGroupService
Parameters:
ent - CompositeEntityIdentifier
Throws:
GroupsException

findGroupWithCache

protected IEntityGroup findGroupWithCache(java.lang.String key)
                                   throws GroupsException
Returns a pre-existing IEntityGroup or null if it does not exist.

Throws:
GroupsException

findGroupWithCache

protected IEntityGroup findGroupWithCache(CompositeEntityIdentifier ent)
                                   throws GroupsException
Returns a pre-existing IEntityGroup or null if it does not exist.

Throws:
GroupsException

findGroupWithLock

public ILockableEntityGroup findGroupWithLock(java.lang.String key,
                                              java.lang.String owner)
                                       throws GroupsException
Returns a pre-existing ILockableEntityGroup or null if the group is not found.

Specified by:
findGroupWithLock in interface ICompositeGroupService
Specified by:
findGroupWithLock in interface ILockableGroupService
Overrides:
findGroupWithLock in class ReferenceCompositeGroupService
Parameters:
key - String - the group key.
owner - String - the lock owner.
Returns:
org.jasig.portal.groups.ILockableEntityGroup
Throws:
GroupsException

findGroupWithLock

public ILockableEntityGroup findGroupWithLock(java.lang.String key,
                                              java.lang.String owner,
                                              int secs)
                                       throws GroupsException
Returns a pre-existing ILockableEntityGroup or null if the group is not found.

Specified by:
findGroupWithLock in interface ILockableGroupService
Parameters:
key - String - the group key.
owner - String - the lock owner.
secs - int - the duration of the lock in seconds.
Returns:
org.jasig.portal.groups.ILockableEntityGroup
Throws:
GroupsException

findLocalMemberGroups

protected java.util.Iterator findLocalMemberGroups(IEntityGroup eg)
                                            throws GroupsException
Returns and caches the member groups for the IEntityGroup

Parameters:
eg - IEntityGroup
Throws:
GroupsException

findMemberEntities

public java.util.Iterator findMemberEntities(IEntityGroup group)
                                      throws GroupsException
Finds the IEntities that are members of group.

Throws:
GroupsException

findMemberGroups

public java.util.Iterator findMemberGroups(IEntityGroup eg)
                                    throws GroupsException
Returns member groups for the IEntityGroup. First get the member groups that are local to this service. Then retrieve the keys of all of the member groups and ask the GroupService to find the groups we do not yet have.

Specified by:
findMemberGroups in interface IGroupService
Parameters:
eg - IEntityGroup
Throws:
GroupsException

findMembers

public java.util.Iterator findMembers(IEntityGroup eg)
                               throws GroupsException
Returns and members for the IEntityGroup.

Specified by:
findMembers in interface IIndividualGroupService
Parameters:
eg - IEntityGroup
Throws:
GroupsException

getEntity

public IEntity getEntity(java.lang.String key,
                         java.lang.Class type)
                  throws GroupsException
Returns an IEntity representing a portal entity. This does not guarantee that the underlying entity actually exists.

Specified by:
getEntity in interface ICompositeGroupService
Specified by:
getEntity in interface IGroupService
Overrides:
getEntity in class ReferenceCompositeGroupService
Throws:
GroupsException

getEntityFactory

public IEntityStore getEntityFactory()
Returns an IEntity representing a portal entity. This does not guarantee that the entity actually exists.


getGroupFromCache

protected IEntityGroup getGroupFromCache(java.lang.String key)
                                  throws CachingException
Returns a cached IEntityGroup or null if it has not been cached.

Throws:
CachingException

getGroupMember

public IGroupMember getGroupMember(java.lang.String key,
                                   java.lang.Class type)
                            throws GroupsException
Returns an IGroupMember representing either a group or a portal entity. If the parm type is the group type, the IGroupMember is an IEntityGroup else it is an IEntity.

Specified by:
getGroupMember in interface ICompositeGroupService
Specified by:
getGroupMember in interface IGroupService
Overrides:
getGroupMember in class ReferenceCompositeGroupService
Throws:
GroupsException

getGroupMember

public IGroupMember getGroupMember(EntityIdentifier underlyingEntityIdentifier)
                            throws GroupsException
Returns an IGroupMember representing either a group or a portal entity, based on the EntityIdentifier, which refers to the UNDERLYING entity for the IGroupMember.

Specified by:
getGroupMember in interface ICompositeGroupService
Specified by:
getGroupMember in interface IGroupService
Overrides:
getGroupMember in class ReferenceCompositeGroupService
Throws:
GroupsException

getGroupStore

public IEntityGroupStore getGroupStore()
                                throws GroupsException
Returns the implementation of IEntityGroupStore whose class name was retrieved by the PropertiesManager (see initialize()).

Specified by:
getGroupStore in interface IGroupService
Throws:
GroupsException

getServiceDescriptor

protected ComponentGroupServiceDescriptor getServiceDescriptor()

initialize

private void initialize()
                 throws GroupsException
Throws:
GroupsException

isEditable

public boolean isEditable(IEntityGroup group)
                   throws GroupsException
Answers if the group can be updated or deleted in the store.

Specified by:
isEditable in interface IIndividualGroupService
Parameters:
group - IEntityGroup
Throws:
GroupsException

isInternallyManaged

protected boolean isInternallyManaged()
Answers if this service is managed by the portal and is therefore updatable.


isLeafService

public boolean isLeafService()
Answers if this service is a leaf in the composite; a service that actually operates on groups.

Specified by:
isLeafService in interface IComponentGroupService
Overrides:
isLeafService in class ReferenceComponentGroupService

isEditable

public boolean isEditable()
Answers if this service is updateable by the portal.

Specified by:
isEditable in interface IIndividualGroupService

newGroup

public IEntityGroup newGroup(java.lang.Class type)
                      throws GroupsException
Returns a new IEntityGroup for the given Class with an unused key.

Specified by:
newGroup in interface IGroupService
Specified by:
newGroup in interface IIndividualGroupService
Throws:
GroupsException

primFindGroup

protected IEntityGroup primFindGroup(java.lang.String localKey)
                              throws GroupsException
Returns a pre-existing IEntityGroup or null if it does not exist.

Overrides:
primFindGroup in class ReferenceCompositeGroupService
Throws:
GroupsException

removeDuplicates

private EntityIdentifier[] removeDuplicates(EntityIdentifier[] entities)

searchForEntities

public EntityIdentifier[] searchForEntities(java.lang.String query,
                                            int method,
                                            java.lang.Class type)
                                     throws GroupsException
Description copied from class: ReferenceCompositeGroupService
Find EntityIdentifiers for entities whose name matches the query string according to the specified method and is of the specified type

Specified by:
searchForEntities in interface ICompositeGroupService
Specified by:
searchForEntities in interface IGroupService
Overrides:
searchForEntities in class ReferenceCompositeGroupService
Throws:
GroupsException

searchForEntities

public EntityIdentifier[] searchForEntities(java.lang.String query,
                                            int method,
                                            java.lang.Class type,
                                            IEntityGroup ancestor)
                                     throws GroupsException
Description copied from class: ReferenceCompositeGroupService
Find EntityIdentifiers for entities whose name matches the query string according to the specified method, is of the specified type and descends from the specified group

Specified by:
searchForEntities in interface ICompositeGroupService
Specified by:
searchForEntities in interface IGroupService
Overrides:
searchForEntities in class ReferenceCompositeGroupService
Throws:
GroupsException

searchForGroups

public EntityIdentifier[] searchForGroups(java.lang.String query,
                                          int method,
                                          java.lang.Class leaftype)
                                   throws GroupsException
Description copied from class: ReferenceCompositeGroupService
Find EntityIdentifiers for groups whose name matches the query string according to the specified method and matches the provided leaf type

Specified by:
searchForGroups in interface ICompositeGroupService
Specified by:
searchForGroups in interface IGroupService
Overrides:
searchForGroups in class ReferenceCompositeGroupService
Throws:
GroupsException

searchForGroups

public EntityIdentifier[] searchForGroups(java.lang.String query,
                                          int method,
                                          java.lang.Class leaftype,
                                          IEntityGroup ancestor)
                                   throws GroupsException
Description copied from class: ReferenceCompositeGroupService
Find EntityIdentifiers for groups whose name matches the query string according to the specified method, has the provided leaf type and descends from the specified group

Specified by:
searchForGroups in interface ICompositeGroupService
Specified by:
searchForGroups in interface IGroupService
Overrides:
searchForGroups in class ReferenceCompositeGroupService
Throws:
GroupsException

throwExceptionIfNotInternallyManaged

protected void throwExceptionIfNotInternallyManaged()
                                             throws GroupsException
Throws:
GroupsException

updateGroup

public void updateGroup(IEntityGroup group)
                 throws GroupsException
Update the store and the updated members.

Specified by:
updateGroup in interface IGroupService
Specified by:
updateGroup in interface IIndividualGroupService
Parameters:
group - IEntityGroup
Throws:
GroupsException

updateGroup

public void updateGroup(ILockableEntityGroup group)
                 throws GroupsException
Updates the ILockableEntityGroup in the cache and the store.

Specified by:
updateGroup in interface ILockableGroupService
Parameters:
group - ILockableEntityGroup
Throws:
GroupsException

updateGroup

public void updateGroup(ILockableEntityGroup group,
                        boolean renewLock)
                 throws GroupsException
Updates the ILockableEntityGroup in the store and removes it from the cache.

Specified by:
updateGroup in interface ILockableGroupService
Parameters:
group - ILockableEntityGroup
Throws:
GroupsException

updateGroupMembers

public void updateGroupMembers(IEntityGroup group)
                        throws GroupsException
Update the store and the updated members.

Specified by:
updateGroupMembers in interface IGroupService
Specified by:
updateGroupMembers in interface IIndividualGroupService
Parameters:
group - IEntityGroup
Throws:
GroupsException

updateGroupMembers

public void updateGroupMembers(ILockableEntityGroup group)
                        throws GroupsException
Updates the ILockableEntityGroup in the cache and the store.

Specified by:
updateGroupMembers in interface ILockableGroupService
Parameters:
group - ILockableEntityGroup
Throws:
GroupsException

updateGroupMembers

public void updateGroupMembers(ILockableEntityGroup group,
                               boolean renewLock)
                        throws GroupsException
Updates the ILockableEntityGroup in the store and removes it from the cache.

Specified by:
updateGroupMembers in interface ILockableGroupService
Parameters:
group - ILockableEntityGroup
Throws:
GroupsException

primGetEntity

protected IEntity primGetEntity(java.lang.String key,
                                java.lang.Class type)
                         throws GroupsException
Returns an IEntity representing a portal entity. This does not guarantee that the underlying entity actually exists.

Throws:
GroupsException

synchronizeGroupMembersOnDelete

protected void synchronizeGroupMembersOnDelete(IEntityGroup group)
                                        throws GroupsException
Remove the back pointers of the group members of the deleted group. Then update the cache to invalidate copies on peer servers.

Parameters:
group - ILockableEntityGroup
Throws:
GroupsException

synchronizeGroupMembersOnUpdate

protected void synchronizeGroupMembersOnUpdate(IEntityGroup group)
                                        throws GroupsException
Adjust the back pointers of the updated group members to either add or remove the parent group. Then update the cache to invalidate copies on peer servers.

Parameters:
group - ILockableEntityGroup
Throws:
GroupsException

contains

public boolean contains(IEntityGroup group,
                        IGroupMember member)
                 throws GroupsException
Answers if group contains member. If the group belongs to another service and the present service is not editable, simply return false.

Specified by:
contains in interface IIndividualGroupService
Parameters:
group - org.jasig.portal.groups.IEntityGroup
member - org.jasig.portal.groups.IGroupMember
Returns:
boolean
Throws:
GroupsException

isForeign

protected boolean isForeign(IGroupMember member)
A foreign member is a group from a different service.

Parameters:
member - IGroupMember
Returns:
boolean