uPortal 2.4.1
API Documentation

org.jasig.portal.groups.filesystem
Class FileSystemGroupStore

java.lang.Object
  extended byorg.jasig.portal.groups.filesystem.FileSystemGroupStore
All Implemented Interfaces:
IEntityGroupStore, IEntitySearcher, IEntityStore, IGroupConstants

public class FileSystemGroupStore
extends java.lang.Object
implements IEntityGroupStore, IEntityStore, IEntitySearcher

This class is an IEntityGroupStore that uses the native file system for its back end. It also implements IEntityStore and a no-op IEntitySearcher. You can substitute a functional entity searcher by adding it to the group service element for this component in the configuration document, compositeGroupServices.xml.

A groups file system looks like this:


-- groups root
 -- org.jasig.portal.ChannelDefinition
 -- channel definition file
 -- channel definition file
...
 -- org.jasig.portal.security.IPerson
 -- person directory
 -- person file
 -- person file
...
 -- person directory
etc.

The groups root is a file system directory declared in the group service configuration document, where it is an attribute of the filesystem group service element. This directory has sub-directories, each named for the underlying entity type that groups in that sub-directory contain. If a service only contains groups of IPersons, the groups root would have 1 sub-directory named org.jasig.portal.security.IPerson.

A directory named for a type may contain both sub-directories and files. The sub-directories represent groups that can contain other groups. The files represent groups that can contain entity as well as group members. The files contain keys, one to a line, and look like this:


# this is a comment
# another comment

key1 Key One
key2
group:org$jasig$portal$security$IPerson/someDirectory/someFile
key3
 # comment

Blank lines and lines that start with the COMMENT String (here #) are ignored. The first token on a non-ignored line is assumed to be a group member key. If the key starts with the GROUP_PREFIX (here :group), it is treated as a local group key. Otherwise, it is assumed to be an entity key. The rest of the tokens on the line are ignored.

The file above contains 3 entity keys, key1, key2, and key3, and 1 group key, org$jasig$portal$security$IPerson/someDirectory/someFile. It represents a group with 3 entity members and 1 group member. The local key of a group is its file path starting at the type name, with the FileSystemGroupStore.SUBSTITUTE_PERIOD character substituted for the real period character.

The store is not implemented as a singleton, so you can have multiple concurrent instances pointing to different groups root directories.

Version:
$Revision: 1.12 $
Author:
Dan Ellentuck

Field Summary
 
Fields inherited from interface org.jasig.portal.groups.IGroupConstants
CHANNEL_CATEGORIES, CONTAINS, ENDS_WITH, EVERYONE, IS, NODE_SEPARATOR, PORTAL_ADMINISTRATORS, STARTS_WITH
 
Constructor Summary
FileSystemGroupStore()
          FileSystemGroupStore constructor.
 
Method Summary
 boolean contains(IEntityGroup group, IGroupMember member)
          Answers if group contains member.
 boolean containsGroupNamed(IEntityGroup group, java.lang.String name)
          Answers if group contains a member group named name.
 void delete(IEntityGroup group)
          Delete this IEntityGroup from the data store.
 IEntityGroup find(java.lang.String key)
          Returns an instance of the IEntityGroup from the data store.
 java.util.Iterator findContainingGroups(IGroupMember gm)
          Returns an Iterator over the Collection of IEntityGroups that the IGroupMember belongs to.
 java.util.Iterator findEntitiesForGroup(IEntityGroup group)
          Returns an Iterator over the Collection of IEntities that are members of this IEntityGroup.
 ILockableEntityGroup findLockable(java.lang.String key)
          Returns an instance of the ILockableEntityGroup from the data store.
 java.lang.String[] findMemberGroupKeys(IEntityGroup group)
          Returns a String[] containing the keys of IEntityGroups that are members of this IEntityGroup.
 java.util.Iterator findMemberGroups(IEntityGroup group)
          Returns an Iterator over the Collection of IEntityGroups that are members of this IEntityGroup.
 java.util.Set getAllDirectoriesBelow(java.io.File dir)
          Recursive search of directories underneath dir for files that match filter.
 java.io.File[] getAllFilesBelow(java.io.File dir)
          Recursive search of directories underneath dir for files that match filter.
 java.lang.String getGroupsRootPath()
           
 IEntityGroup newInstance(java.lang.Class entityType)
           
 IEntity newInstance(java.lang.String key)
           
 IEntity newInstance(java.lang.String key, java.lang.Class type)
           
 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[] searchForGroups(java.lang.String query, int searchMethod, java.lang.Class leafType)
          Returns an EntityIdentifier[] of groups of the given leaf type whose names match the query string according to the search method.
 void update(IEntityGroup group)
          Adds or updates the IEntityGroup AND ITS MEMBERSHIPS to the data store, as appropriate.
 void updateMembers(IEntityGroup group)
          Commits the group memberships of the IEntityGroup to the data store.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSystemGroupStore

public FileSystemGroupStore()
FileSystemGroupStore constructor.

Method Detail

delete

public void delete(IEntityGroup group)
            throws GroupsException
Delete this IEntityGroup from the data store. We assume that groups will be deleted via the file system, not the group service.

Specified by:
delete in interface IEntityGroupStore
Parameters:
group - org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

find

public IEntityGroup find(java.lang.String key)
                  throws GroupsException
Returns an instance of the IEntityGroup from the data store.

Specified by:
find in interface IEntityGroupStore
Parameters:
key - java.lang.String
Returns:
org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

findContainingGroups

public java.util.Iterator findContainingGroups(IGroupMember gm)
                                        throws GroupsException
Returns an Iterator over the Collection of IEntityGroups that the IGroupMember belongs to.

Specified by:
findContainingGroups in interface IEntityGroupStore
Parameters:
gm - org.jasig.portal.groups.IEntityGroup
Returns:
java.util.Iterator
Throws:
GroupsException

findEntitiesForGroup

public java.util.Iterator findEntitiesForGroup(IEntityGroup group)
                                        throws GroupsException
Returns an Iterator over the Collection of IEntities that are members of this IEntityGroup.

Specified by:
findEntitiesForGroup in interface IEntityGroupStore
Parameters:
group - org.jasig.portal.groups.IEntityGroup
Returns:
java.util.Iterator
Throws:
GroupsException

findLockable

public ILockableEntityGroup findLockable(java.lang.String key)
                                  throws GroupsException
Returns an instance of the ILockableEntityGroup from the data store.

Specified by:
findLockable in interface IEntityGroupStore
Parameters:
key - java.lang.String
Returns:
org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

findMemberGroupKeys

public java.lang.String[] findMemberGroupKeys(IEntityGroup group)
                                       throws GroupsException
Returns a String[] containing the keys of IEntityGroups that are members of this IEntityGroup. In a composite group system, a group may contain a member group from a different service. This is called a foreign membership, and is only possible in an internally-managed service. A group store in such a service can return the key of a foreign member group, but not the group itself, which can only be returned by its local store.

Specified by:
findMemberGroupKeys in interface IEntityGroupStore
Parameters:
group - org.jasig.portal.groups.IEntityGroup
Returns:
String[]
Throws:
GroupsException

findMemberGroups

public java.util.Iterator findMemberGroups(IEntityGroup group)
                                    throws GroupsException
Returns an Iterator over the Collection of IEntityGroups that are members of this IEntityGroup.

Specified by:
findMemberGroups in interface IEntityGroupStore
Parameters:
group - org.jasig.portal.groups.IEntityGroup
Returns:
java.util.Iterator
Throws:
GroupsException

getAllDirectoriesBelow

public java.util.Set getAllDirectoriesBelow(java.io.File dir)
Recursive search of directories underneath dir for files that match filter.

Returns:
java.util.Set

getAllFilesBelow

public java.io.File[] getAllFilesBelow(java.io.File dir)
Recursive search of directories underneath dir for files that match filter.


getGroupsRootPath

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

newInstance

public IEntityGroup newInstance(java.lang.Class entityType)
                         throws GroupsException
Specified by:
newInstance in interface IEntityGroupStore
Returns:
org.jasig.portal.groups.IEntityGroup We assume that new groups will be created updated via the file system, not the group service.
Throws:
GroupsException

newInstance

public IEntity newInstance(java.lang.String key)
                    throws GroupsException
Specified by:
newInstance in interface IEntityStore
Parameters:
key - java.lang.String
Returns:
org.jasig.portal.groups.IEntity
Throws:
GroupsException

newInstance

public IEntity newInstance(java.lang.String key,
                           java.lang.Class type)
                    throws GroupsException
Specified by:
newInstance in interface IEntityStore
Parameters:
key - java.lang.String - the entity's key
type - java.lang.Class - the entity's Type
Returns:
org.jasig.portal.groups.IEntity
Throws:
GroupsException

searchForEntities

public EntityIdentifier[] searchForEntities(java.lang.String query,
                                            int method,
                                            java.lang.Class type)
                                     throws GroupsException
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 IEntitySearcher
Throws:
GroupsException

searchForGroups

public EntityIdentifier[] searchForGroups(java.lang.String query,
                                          int searchMethod,
                                          java.lang.Class leafType)
                                   throws GroupsException
Returns an EntityIdentifier[] of groups of the given leaf type whose names match the query string according to the search method.

Specified by:
searchForGroups in interface IEntityGroupStore
Parameters:
query - String the string used to match group names.
searchMethod - see org.jasig.portal.groups.IGroupConstants.
leafType - the leaf type of the groups we are searching for.
Returns:
EntityIdentifier[]
Throws:
GroupsException

update

public void update(IEntityGroup group)
            throws GroupsException
Adds or updates the IEntityGroup AND ITS MEMBERSHIPS to the data store, as appropriate. We assume that groups will be updated via the file system, not the group service.

Specified by:
update in interface IEntityGroupStore
Parameters:
group - org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

updateMembers

public void updateMembers(IEntityGroup group)
                   throws GroupsException
Commits the group memberships of the IEntityGroup to the data store. We assume that groups will be updated via the file system, not the group service.

Specified by:
updateMembers in interface IEntityGroupStore
Parameters:
group - org.jasig.portal.groups.IEntityGroup
Throws:
GroupsException

contains

public boolean contains(IEntityGroup group,
                        IGroupMember member)
                 throws GroupsException
Answers if group contains member.

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

containsGroupNamed

public boolean containsGroupNamed(IEntityGroup group,
                                  java.lang.String name)
                           throws GroupsException
Answers if group contains a member group named name.

Parameters:
group - org.jasig.portal.groups.IEntityGroup
name - java.lang.String
Returns:
boolean
Throws:
GroupsException

uPortal 2.4.1
API Documentation