|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jasig.portal.groups.filesystem.FileSystemGroupStore
public class FileSystemGroupStore
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
-- org.jasig.portal.security.IPerson
-- channel definition file
...
-- person directory
etc.
-- person file
-- person directory
-- person file
...
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.
| Field Summary | |
|---|---|
protected static char |
BACK_SLASH
|
protected char |
badSeparator
|
protected static String |
COMMENT
|
protected static char |
FORWARD_SLASH
|
protected char |
goodSeparator
|
protected static String |
GROUP_PREFIX
|
protected static char |
PERIOD
|
protected static char |
SUBSTITUTE_PERIOD
|
protected boolean |
useSubstitutePeriod
|
| 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. |
|
FileSystemGroupStore(GroupServiceConfiguration cfg)
FileSystemGroupStore constructor. |
|
| Method Summary | |
|---|---|
protected org.jasig.portal.groups.filesystem.FileSystemGroupStore.GroupHolder |
cacheGet(String key)
|
protected void |
cachePut(String key,
Object val)
|
protected String |
conformSeparatorChars(String s)
|
boolean |
contains(IEntityGroup group,
IGroupMember member)
Answers if group contains member. |
boolean |
containsGroupNamed(IEntityGroup group,
String name)
Answers if group contains a member group named
name. |
void |
delete(IEntityGroup group)
Delete this IEntityGroup from the data store. |
IEntityGroup |
find(String key)
Returns an instance of the IEntityGroup from the data store. |
protected Iterator |
findContainingGroups(IEntity ent)
Returns an Iterator over the Collection of
IEntityGroups that the IEntity belongs to. |
protected Iterator |
findContainingGroups(IEntityGroup group)
Returns an Iterator over the Collection of
IEntityGroups that the IGroupMember belongs to. |
Iterator |
findContainingGroups(IGroupMember gm)
Returns an Iterator over the Collection of
IEntityGroups that the IGroupMember belongs to. |
Iterator |
findEntitiesForGroup(IEntityGroup group)
Returns an Iterator over the Collection of
IEntities that are members of this IEntityGroup. |
ILockableEntityGroup |
findLockable(String key)
Returns an instance of the ILockableEntityGroup from the data store. |
String[] |
findMemberGroupKeys(IEntityGroup group)
Returns a String[] containing the keys of IEntityGroups
that are members of this IEntityGroup. |
Iterator |
findMemberGroups(IEntityGroup group)
Returns an Iterator over the Collection of
IEntityGroups that are members of this IEntityGroup. |
Set |
getAllDirectoriesBelow(File dir)
Recursive search of directories underneath dir for files that match filter. |
File[] |
getAllFilesBelow(File dir)
Recursive search of directories underneath dir for files that match filter. |
protected char |
getBadSeparator()
Returns the filesystem separator character NOT in use. |
protected Map |
getCache()
|
protected Class |
getDefaultEntityType()
Returns a Class representing the default entity type. |
protected Collection |
getEntitiesFromFile(File idFile)
|
protected Collection |
getEntityIdsFromFile(File idFile)
|
protected Class |
getEntityType(File f)
|
protected File |
getFile(IEntityGroup group)
|
protected String |
getFilePathFromKey(String key)
|
protected File |
getFileRoot(Class type)
Returns a File that is the root for groups of the given type. |
protected char |
getGoodSeparator()
Returns the filesystem separator character in use. |
protected Collection |
getGroupIdsFromFile(File idFile)
|
String |
getGroupsRootPath()
|
protected Collection |
getIdsFromFile(File idFile,
boolean groupIds)
|
protected String |
getKeyFromFile(File f)
|
protected void |
initialize(GroupServiceConfiguration cfg)
|
IEntityGroup |
newInstance(Class entityType)
|
IEntity |
newInstance(String key)
|
IEntity |
newInstance(String key,
Class type)
|
EntityIdentifier[] |
searchForEntities(String query,
int method,
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(String query,
int searchMethod,
Class leafType)
Returns an EntityIdentifier[] of groups of the given leaf type whose names match the query string according to the search method. |
protected void |
setCache(Map newCache)
|
protected void |
setGroupsRootPath(String newGroupsRootPath)
|
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 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static char FORWARD_SLASH
protected static char BACK_SLASH
protected static String COMMENT
protected static String GROUP_PREFIX
protected static char PERIOD
protected static char SUBSTITUTE_PERIOD
protected boolean useSubstitutePeriod
protected char goodSeparator
protected char badSeparator
| Constructor Detail |
|---|
public FileSystemGroupStore()
public FileSystemGroupStore(GroupServiceConfiguration cfg)
| Method Detail |
|---|
protected org.jasig.portal.groups.filesystem.FileSystemGroupStore.GroupHolder cacheGet(String key)
protected void cachePut(String key,
Object val)
protected String conformSeparatorChars(String s)
public void delete(IEntityGroup group)
throws GroupsException
IEntityGroup from the data store. We assume that
groups will be deleted via the file system, not the group service.
delete in interface IEntityGroupStoregroup - org.jasig.portal.groups.IEntityGroup
GroupsException
public IEntityGroup find(String key)
throws GroupsException
IEntityGroup from the data store.
find in interface IEntityGroupStorekey - java.lang.String
GroupsException
protected Iterator findContainingGroups(IEntity ent)
throws GroupsException
Iterator over the Collection of
IEntityGroups that the IEntity belongs to.
ent - org.jasig.portal.groups.IEntityGroup
GroupsException
protected Iterator findContainingGroups(IEntityGroup group)
throws GroupsException
Iterator over the Collection of
IEntityGroups that the IGroupMember belongs to.
group - org.jasig.portal.groups.IEntityGroup
GroupsException
public Iterator findContainingGroups(IGroupMember gm)
throws GroupsException
Iterator over the Collection of
IEntityGroups that the IGroupMember belongs to.
findContainingGroups in interface IEntityGroupStoregm - org.jasig.portal.groups.IEntityGroup
GroupsException
public Iterator findEntitiesForGroup(IEntityGroup group)
throws GroupsException
Iterator over the Collection of
IEntities that are members of this IEntityGroup.
findEntitiesForGroup in interface IEntityGroupStoregroup - org.jasig.portal.groups.IEntityGroup
GroupsException
public ILockableEntityGroup findLockable(String key)
throws GroupsException
ILockableEntityGroup from the data store.
findLockable in interface IEntityGroupStorekey - java.lang.String
GroupsException
public String[] findMemberGroupKeys(IEntityGroup group)
throws GroupsException
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.
findMemberGroupKeys in interface IEntityGroupStoregroup - org.jasig.portal.groups.IEntityGroup
GroupsException
public Iterator findMemberGroups(IEntityGroup group)
throws GroupsException
Iterator over the Collection of
IEntityGroups that are members of this IEntityGroup.
findMemberGroups in interface IEntityGroupStoregroup - org.jasig.portal.groups.IEntityGroup
GroupsExceptionpublic Set getAllDirectoriesBelow(File dir)
public File[] getAllFilesBelow(File dir)
protected char getBadSeparator()
protected Map getCache()
protected Class getDefaultEntityType()
protected Collection getEntitiesFromFile(File idFile)
throws GroupsException
idFile - java.io.File - a file of ids.
GroupsException
protected Collection getEntityIdsFromFile(File idFile)
throws IOException,
FileNotFoundException
idFile - java.io.File - a file of ids.
IOException
FileNotFoundExceptionprotected Class getEntityType(File f)
f - File
protected File getFile(IEntityGroup group)
group - IEntityGroup.
protected String getFilePathFromKey(String key)
protected File getFileRoot(Class type)
protected char getGoodSeparator()
protected Collection getGroupIdsFromFile(File idFile)
throws IOException,
FileNotFoundException
idFile - java.io.File - a file of ids.
IOException
FileNotFoundExceptionpublic String getGroupsRootPath()
protected Collection getIdsFromFile(File idFile,
boolean groupIds)
throws IOException,
FileNotFoundException
idFile - java.io.File - a file of ids.
IOException
FileNotFoundExceptionprotected String getKeyFromFile(File f)
protected void initialize(GroupServiceConfiguration cfg)
public IEntityGroup newInstance(Class entityType)
throws GroupsException
newInstance in interface IEntityGroupStoreGroupsException
public IEntity newInstance(String key)
throws GroupsException
newInstance in interface IEntityStorekey - java.lang.String
GroupsException
public IEntity newInstance(String key,
Class type)
throws GroupsException
newInstance in interface IEntityStorekey - java.lang.String - the entity's keytype - java.lang.Class - the entity's Type
GroupsException
public EntityIdentifier[] searchForEntities(String query,
int method,
Class type)
throws GroupsException
searchForEntities in interface IEntitySearcherGroupsException
public EntityIdentifier[] searchForGroups(String query,
int searchMethod,
Class leafType)
throws GroupsException
searchForGroups in interface IEntityGroupStorequery - 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.
GroupsExceptionprotected void setCache(Map newCache)
newCache - java.util.Mapprotected void setGroupsRootPath(String newGroupsRootPath)
newGroupsRootPath - java.lang.String
public void update(IEntityGroup group)
throws GroupsException
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.
update in interface IEntityGroupStoregroup - org.jasig.portal.groups.IEntityGroup
GroupsException
public void updateMembers(IEntityGroup group)
throws GroupsException
IEntityGroup to
the data store. We assume that groups will be updated via the
file system, not the group service.
updateMembers in interface IEntityGroupStoregroup - org.jasig.portal.groups.IEntityGroup
GroupsException
public boolean contains(IEntityGroup group,
IGroupMember member)
throws GroupsException
group contains member.
contains in interface IEntityGroupStoregroup - org.jasig.portal.groups.IEntityGroupmember - org.jasig.portal.groups.IGroupMember
GroupsException
public boolean containsGroupNamed(IEntityGroup group,
String name)
throws GroupsException
group contains a member group named
name.
group - org.jasig.portal.groups.IEntityGroupname - java.lang.String
GroupsException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||