org.jwarp.service.groups
Class FileGroupManager

java.lang.Object
  |
  +--org.jwarp.service.groups.FileGroupManager
All Implemented Interfaces:
IGroupManager, java.io.Serializable

public class FileGroupManager
extends java.lang.Object
implements IGroupManager, java.io.Serializable

See Also:
Serialized Form

Field Summary
(package private)  java.util.Hashtable items
          The currently defined users.
(package private)  java.util.Hashtable members
          The group members table.
(package private)  java.util.Hashtable names
          The currently defined groups.
(package private)  java.io.File storeFile
          The file's the group are stored in.
(package private)  int[] supportedTypes
           
(package private)  java.util.Hashtable typeDescriptions
           
 
Constructor Summary
FileGroupManager(java.io.File storeFile)
           
FileGroupManager(java.lang.String storeFile)
           
 
Method Summary
 void addGroup(IGroup group, java.lang.String name)
          Create a new group with the setings given.
 void addItem(IItem item, java.lang.String name)
          Create a new user with the setings given.
 void addMember(int newMember, int g)
          Add a user to a group
 void clear()
           
 void dump()
           
 IItem getItem(int ref)
          Returns the user with the given id.
 IItem getItemByName(java.lang.String name)
          Returns all defined items.
 java.util.Iterator getItems()
          Returns all defined items.
 java.util.Iterator getMembers(int ref)
          Returns all members of a group.
 boolean isMember(int item, int group)
          Is an item member of a group or one of its subgroups.
 void load()
           
 IItem removeItem(int item)
          Removes the item.
 void removeMember(int member, int target)
          Remove a user from a group
 void store()
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

storeFile

transient java.io.File storeFile
The file's the group are stored in.

supportedTypes

int[] supportedTypes

typeDescriptions

java.util.Hashtable typeDescriptions

items

java.util.Hashtable items
The currently defined users. Keys are the ids.

names

java.util.Hashtable names
The currently defined groups. Keys are the group's name.

members

java.util.Hashtable members
The group members table.
Constructor Detail

FileGroupManager

public FileGroupManager(java.io.File storeFile)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException

FileGroupManager

public FileGroupManager(java.lang.String storeFile)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Method Detail

store

public void store()

clear

public void clear()

load

public void load()
          throws java.io.IOException,
                 java.lang.ClassNotFoundException

addItem

public void addItem(IItem item,
                    java.lang.String name)
Create a new user with the setings given. The relationID is used to have a reference to whatever data the user needs, e.g. the primary key in the enterpise's personal db or a more complex string containing several infos.
Specified by:
addItem in interface IGroupManager
Parameters:
uid - The user's identification
pwd - The user's password
name - The user's name
description - An optional description
relationID - An optional relation ID
admin - The user who tries to create the new user
Throws:
java.lang.SecurityException - If the creation failed.

removeItem

public IItem removeItem(int item)
Removes the item. If the item was removed its instance is returned.
Specified by:
removeItem in interface IGroupManager
Parameters:
item - The item to be removed
Returns:
The item removed or null

addGroup

public void addGroup(IGroup group,
                     java.lang.String name)
Create a new group with the setings given. The relationID is used to have a reference to whatever data the user needs, e.g. the primary key in the enterpise's db or a more complex string containing several infos.
Specified by:
addGroup in interface IGroupManager
Parameters:
name - The user's name
description - An optional description
relationID - An optional relation ID
admin - The user who tries to create the new user
Throws:
java.lang.SecurityException - If the creation failed.

addMember

public void addMember(int newMember,
                      int g)
Add a user to a group
Specified by:
addMember in interface IGroupManager
Parameters:
user - The user
group - The group
admin - The admin user
Throws:
java.lang.SecurityException - If the setting failed.

removeMember

public void removeMember(int member,
                         int target)
Remove a user from a group
Specified by:
removeMember in interface IGroupManager
Parameters:
user - The user
group - The group
admin - The admin user
Throws:
java.lang.SecurityException - If the setting failed.

getItem

public IItem getItem(int ref)
Returns the user with the given id.
Specified by:
getItem in interface IGroupManager
Returns:
The corresponding user or null

getItems

public java.util.Iterator getItems()
Returns all defined items.
Specified by:
getItems in interface IGroupManager

getMembers

public java.util.Iterator getMembers(int ref)
Returns all members of a group.
Specified by:
getMembers in interface IGroupManager
Parameters:
ref - The group reference

getItemByName

public IItem getItemByName(java.lang.String name)
Returns all defined items.
Specified by:
getItemByName in interface IGroupManager

isMember

public boolean isMember(int item,
                        int group)
Is an item member of a group or one of its subgroups.
Specified by:
isMember in interface IGroupManager
Parameters:
item - The item to be lookedup
group - The group
Returns:
true If the item is a member of the group

dump

public void dump()

©   O R C A   S y s t e m s