org.jasig.portal.services
Class GroupService

java.lang.Object
  extended by org.jasig.portal.services.GroupService
All Implemented Interfaces:
IGroupConstants

public class GroupService
extends java.lang.Object
implements IGroupConstants

Bootstrap class for the IGroupService implementation.

Version:
$Revision: 1.27.2.2 $
Author:
Alex Vigdor, Dan Ellentuck

Field Summary
private static boolean composite
           
private  ICompositeGroupService compositeGroupService
           
protected static java.lang.String GROUP_SERVICE_KEY
           
private  IGroupService groupService
           
private static GroupService instance
           
private static org.apache.commons.logging.Log log
           
 
Fields inherited from interface org.jasig.portal.groups.IGroupConstants
CHANNEL_CATEGORIES, CONTAINS, ENDS_WITH, EVERYONE, IS, NODE_SEPARATOR, PORTAL_ADMINISTRATORS, STARTS_WITH
 
Constructor Summary
private GroupService()
          Creates new GroupService
 
Method Summary
static IEntityGroup findGroup(java.lang.String key)
          Returns a pre-existing IEntityGroup or null if the IGroupMember does not exist.
static ILockableEntityGroup findLockableGroup(java.lang.String key, java.lang.String lockOwner)
          Returns a pre-existing ILockableEntityGroup or null if the group is not found.
static void finishedSession(IPerson person)
          Receives notice that the UserInstance has been unbound from the HttpSession.
static ICompositeGroupService getCompositeGroupService()
          Returns the ICompositeGroupService implementation in use.
protected  java.lang.String getDefaultServiceName()
           
static IEntityGroup getDistinguishedGroup(java.lang.String name)
          Refers to the PropertiesManager to get the key for the group associated with 'name' and asks the group store implementation for the corresponding IEntityGroup.
 java.lang.String getDistinguishedGroupKey(java.lang.String name)
           
static IEntity getEntity(java.lang.String key, java.lang.Class type)
          Returns an IEntity representing a portal entity.
static IEntity getEntity(java.lang.String key, java.lang.Class type, java.lang.String service)
          Returns an IEntity representing a portal entity.
static 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.
static IGroupMember getGroupMember(java.lang.String key, java.lang.Class type)
          Returns an IGroupMember representing either a group or a portal entity.
static IGroupService getGroupService()
          Returns the IGroupService implementation in use.
static IEntityGroup getRootGroup(java.lang.Class type)
          Refers to the PropertiesManager to get the key for the root group associated with 'type' and asks the group store implementation for the corresponding IEntityGroup.
protected  GroupServiceConfiguration getServiceConfiguration()
           
protected  IEntityGroup ifindGroup(java.lang.String key)
          Returns a pre-existing IEntityGroup or null if the IGroupMember does not exist.
protected  ILockableEntityGroup ifindLockableGroup(java.lang.String key, java.lang.String lockOwner)
          Returns a pre-existing ILockableEntityGroup or null if the group is not found.
protected  void ifinishedSession(IPerson person)
          Receives notice that the UserInstance has been unbound from the HttpSession.
protected  IEntityGroup igetDistinguishedGroup(java.lang.String name)
          Refers to the PropertiesManager to get the key for the group associated with 'name' and asks the group store implementation for the corresponding IEntityGroup.
protected  IEntity igetEntity(java.lang.String key, java.lang.Class type, java.lang.String service)
          Returns an IEntity representing a pre-existing portal entity.
protected  IGroupMember igetGroupMember(java.lang.String key, java.lang.Class type)
          Returns an IGroupMember representing either a group or a portal entity.
protected  IEntityGroup igetRootGroup(java.lang.Class type)
          Refers to the PropertiesManager to get the key for the root group associated with 'type' and asks the group store implementation for the corresponding IEntityGroup.
protected  IEntityGroup inewGroup(java.lang.Class type)
          Returns a new IEntityGroup for the given Class with an unused key.
protected  IEntityGroup inewGroup(java.lang.Class type, java.lang.String serviceName)
          Returns a new IEntityGroup for the given Class with an unused key.
private  void initialize()
           
private  void initializeCompositeService()
           
static GroupService instance()
           
static boolean isComposite()
          Answer if the underlying group service is a composite service, implementing ICompositeGroupService.
static IEntityGroup newGroup(java.lang.Class type)
          Returns a new IEntityGroup for the given Class with an unused key.
static IEntityGroup newGroup(java.lang.Class type, java.lang.String serviceName)
          Returns a new IEntityGroup for the given Class with an unused key.
static java.lang.String parseLocalKey(java.lang.String compositeKey)
          Extracts the final node from the String form of a composite key.
static javax.naming.Name parseServiceName(java.lang.String serviceName)
          Converts the String form of a service name into a Name.
static EntityIdentifier[] searchForEntities(java.lang.String query, int method, java.lang.Class type)
           
static EntityIdentifier[] searchForEntities(java.lang.String query, int method, java.lang.Class type, IEntityGroup ancestor)
           
static EntityIdentifier[] searchForGroups(java.lang.String query, int method, java.lang.Class leaftype)
           
static EntityIdentifier[] searchForGroups(java.lang.String query, int method, java.lang.Class leaftype, IEntityGroup ancestor)
           
static void startUp()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

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

instance

private static GroupService instance

composite

private static boolean composite

groupService

private IGroupService groupService

compositeGroupService

private ICompositeGroupService compositeGroupService

GROUP_SERVICE_KEY

protected static final java.lang.String GROUP_SERVICE_KEY
See Also:
Constant Field Values
Constructor Detail

GroupService

private GroupService()
              throws GroupsException
Creates new GroupService

Throws:
GroupsException
Method Detail

findGroup

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

Parameters:
key - String - the group key.
Returns:
org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

findLockableGroup

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

Parameters:
key - String - the group key.
lockOwner - String - the owner of the lock, typically the user.
Returns:
org.jasig.portal.groups.ILockableEntityGroup
Throws:
GroupsException

finishedSession

public static void finishedSession(IPerson person)
Receives notice that the UserInstance has been unbound from the HttpSession. In response, we remove the corresponding group member from the cache.

Parameters:
person - org.jasig.portal.security.IPerson

getCompositeGroupService

public static ICompositeGroupService getCompositeGroupService()
                                                       throws GroupsException
Returns the ICompositeGroupService implementation in use.

Returns:
org.jasig.portal.groups.ICompositeGroupService
Throws:
GroupsException

getDefaultServiceName

protected java.lang.String getDefaultServiceName()
                                          throws GroupsException
Returns:
java.lang.String
Throws:
GroupsException

getDistinguishedGroup

public static IEntityGroup getDistinguishedGroup(java.lang.String name)
                                          throws GroupsException
Refers to the PropertiesManager to get the key for the group associated with 'name' and asks the group store implementation for the corresponding IEntityGroup.

Throws:
GroupsException

getDistinguishedGroupKey

public java.lang.String getDistinguishedGroupKey(java.lang.String name)
Returns:
java.lang.String

getEntity

public static 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 entity actually exists.

Parameters:
key - String - the group key.
type - Class - the Class of the underlying IGroupMember.
Returns:
org.jasig.portal.groups.IEntity
Throws:
GroupsException

getEntity

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

Parameters:
key - String - the group key.
type - Class - the Class of the underlying IGroupMember.
service - String - the name of the component service.
Returns:
org.jasig.portal.groups.IEntity
Throws:
GroupsException

getGroupMember

public static 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 .

Throws:
GroupsException

getGroupMember

public static 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.

Throws:
GroupsException

getGroupService

public static IGroupService getGroupService()
                                     throws GroupsException
Returns the IGroupService implementation in use.

Returns:
org.jasig.portal.groups.IGroupService
Throws:
GroupsException

getRootGroup

public static IEntityGroup getRootGroup(java.lang.Class type)
                                 throws GroupsException
Refers to the PropertiesManager to get the key for the root group associated with 'type' and asks the group store implementation for the corresponding IEntityGroup.

Throws:
GroupsException

getServiceConfiguration

protected GroupServiceConfiguration getServiceConfiguration()
                                                     throws GroupsException
Returns:
java.lang.String
Throws:
GroupsException

ifindGroup

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

Parameters:
key - String - the group key.
Returns:
org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

ifindLockableGroup

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

Parameters:
key - String - the group key.
lockOwner - String - typically the user.
Returns:
org.jasig.portal.groups.ILockableEntityGroup
Throws:
GroupsException

ifinishedSession

protected void ifinishedSession(IPerson person)
                         throws GroupsException
Receives notice that the UserInstance has been unbound from the HttpSession. In response, we remove the corresponding group member from the cache. We use the roundabout route of creating a group member and then getting its EntityIdentifier because we need the EntityIdentifier for the group member, which is cached, not the EntityIdentifier for the IPerson, which is not.

Parameters:
person - org.jasig.portal.security.IPerson
Throws:
GroupsException

igetDistinguishedGroup

protected IEntityGroup igetDistinguishedGroup(java.lang.String name)
                                       throws GroupsException
Refers to the PropertiesManager to get the key for the group associated with 'name' and asks the group store implementation for the corresponding IEntityGroup.

Throws:
GroupsException

igetEntity

protected IEntity igetEntity(java.lang.String key,
                             java.lang.Class type,
                             java.lang.String service)
                      throws GroupsException
Returns an IEntity representing a pre-existing portal entity.

Parameters:
key - String - the group key.
type - Class - the Class of the underlying IGroupMember.
Returns:
org.jasig.portal.groups.IEntity
Throws:
GroupsException

igetGroupMember

protected IGroupMember igetGroupMember(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.

Throws:
GroupsException

igetRootGroup

protected IEntityGroup igetRootGroup(java.lang.Class type)
                              throws GroupsException
Refers to the PropertiesManager to get the key for the root group associated with 'type' and asks the group store implementation for the corresponding IEntityGroup.

Throws:
GroupsException

inewGroup

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

Returns:
org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

inewGroup

protected IEntityGroup inewGroup(java.lang.Class type,
                                 java.lang.String serviceName)
                          throws GroupsException
Returns a new IEntityGroup for the given Class with an unused key.

Returns:
org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

initialize

private void initialize()
                 throws GroupsException
Throws:
GroupsException

initializeCompositeService

private void initializeCompositeService()
                                 throws GroupsException
Throws:
GroupsException

instance

public static GroupService instance()
                             throws GroupsException
Throws:
GroupsException

isComposite

public static boolean isComposite()
Answer if the underlying group service is a composite service, implementing ICompositeGroupService.


newGroup

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

Returns:
org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

newGroup

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

Returns:
org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

parseLocalKey

public static java.lang.String parseLocalKey(java.lang.String compositeKey)
                                      throws javax.naming.InvalidNameException,
                                             GroupsException
Extracts the final node from the String form of a composite key.

Returns:
String
Throws:
javax.naming.InvalidNameException
GroupsException

parseServiceName

public static javax.naming.Name parseServiceName(java.lang.String serviceName)
                                          throws javax.naming.InvalidNameException,
                                                 GroupsException
Converts the String form of a service name into a Name.

Returns:
javax.naming.Name
Throws:
javax.naming.InvalidNameException
GroupsException

searchForEntities

public static EntityIdentifier[] searchForEntities(java.lang.String query,
                                                   int method,
                                                   java.lang.Class type)
                                            throws GroupsException
Throws:
GroupsException

searchForEntities

public static EntityIdentifier[] searchForEntities(java.lang.String query,
                                                   int method,
                                                   java.lang.Class type,
                                                   IEntityGroup ancestor)
                                            throws GroupsException
Throws:
GroupsException

searchForGroups

public static EntityIdentifier[] searchForGroups(java.lang.String query,
                                                 int method,
                                                 java.lang.Class leaftype)
                                          throws GroupsException
Throws:
GroupsException

searchForGroups

public static EntityIdentifier[] searchForGroups(java.lang.String query,
                                                 int method,
                                                 java.lang.Class leaftype,
                                                 IEntityGroup ancestor)
                                          throws GroupsException
Throws:
GroupsException

startUp

public static void startUp()
                    throws GroupsException
Throws:
GroupsException