org.mycore.user
Class MCRGroup

java.lang.Object
  extended by org.mycore.user.MCRUserObject
      extended by org.mycore.user.MCRGroup
All Implemented Interfaces:
MCRPrincipal

public class MCRGroup
extends MCRUserObject
implements MCRPrincipal

Instances of this class represent MyCoRe groups.

The main duty of a group object is to define exactly which members it will have.

Version:
$Revision: 14841 $ $Date: 2007-05-02 22:23:40 +0200 (Mi, 02 Mai 2007) $
Author:
Detlev Degenhardt, Jens Kupferschmidt, Heiko Helmbrecht
See Also:
MCRUserMgr, MCRUserObject

Field Summary
 
Fields inherited from class org.mycore.user.MCRUserObject
config, creationDate, creator, description, description_len, ID, id_len, logger, modifiedDate, password_len, privilege_len
 
Constructor Summary
MCRGroup()
          Default constructor.
MCRGroup(Element elm)
          This constructor creates the data of this object from a given JDOM Element.
MCRGroup(MCRGroup other)
           
MCRGroup(String id)
          This minimal constructor only takes the group ID as a parameter.
MCRGroup(String ID, String creator, Timestamp creationDate, Timestamp modifiedDate, String description, ArrayList<String> admUserIDs, ArrayList<String> admGroupIDs, ArrayList<String> mbrUserIDs)
          This constructor takes a subset of attributes of this class as single variables and calls the main constructor (taking all attributes) with default values for the remaining attribute (parameter 'create').
 
Method Summary
 void addAdminGroupID(String groupID)
          This method adds a group to the list of groups with administrative privileges for the group.
 void addAdminUserID(String userID)
          This method adds a user (ID) to the administrators list of the group
 void addMemberUserID(String userID)
          This method adds a user (ID) to the users list of the group
 void debug()
          This method writes debug data to the logger (for the debug mode).
 ArrayList<String> getAdminGroupIDs()
           
 ArrayList<String> getAdminUserIDs()
           
 String getID()
          This method must be implemented by a subclass and returns the the ID of the object.
 ArrayList<String> getMemberUserIDs()
           
 boolean hasUserMember(MCRUser user)
          This method checks if a user is a member of this group.
 boolean hasUserMember(String user)
          This method checks if a user is a member of this group.
 boolean isValid()
          This method checks if all required fields have been provided.
 void removeAdminGroupID(String groupID)
          This method removes a group from the list of groups with administrative privileges for this group.
 void removeAdminUserID(String userID)
          This method removes a user from the list of administrators of the group.
 void removeAllAdminGroupID()
          This method remove all administrator group IDs.
 void removeAllAdminUserID()
          This method remove all administrator group IDs.
 void removeAllMemberUserID()
          This method remove all administrator group IDs.
 void removeMemberUserID(String userID)
          This method removes a user from the users list (members) of the group.
 void setAdminGroupIDs(ArrayList<String> array)
          This method set the list of administrator groups as a ArrayList of Strings.
 void setAdminUserIDs(ArrayList<String> array)
          This method set the list of administrator users as a ArrayList of Strings.
 void setID(String value)
           
 Document toJDOMDocument()
          This method must be implemented by a subclass and then returns the user or group object as a JDOM document.
 Element toJDOMElement()
          This method must be implemented by a subclass and then returns the user or group object as a JDOM element.
 
Methods inherited from class org.mycore.user.MCRUserObject
debugDefault, getCreationDate, getCreator, getDescription, getModifiedDate, setCreationDate, setCreationDate, setCreator, setDescription, setModifiedDate, setModifiedDate, toString, trim, trim
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MCRGroup

public MCRGroup()
Default constructor. It is used to create a group object with empty fields. This is useful for constructing an XML representation of a group without specialized data. This empty group object will not be created in the persistent data store.


MCRGroup

public MCRGroup(MCRGroup other)

MCRGroup

public MCRGroup(String id)
This minimal constructor only takes the group ID as a parameter. For all other attributes the default constructor is invoked.


MCRGroup

public MCRGroup(String ID,
                String creator,
                Timestamp creationDate,
                Timestamp modifiedDate,
                String description,
                ArrayList<String> admUserIDs,
                ArrayList<String> admGroupIDs,
                ArrayList<String> mbrUserIDs)
         throws MCRException,
                Exception
This constructor takes a subset of attributes of this class as single variables and calls the main constructor (taking all attributes) with default values for the remaining attribute (parameter 'create').

Parameters:
ID - the group ID
creator - the user ID who created this group
creationDate - timestamp of the creation of this group, if null the current date will be used
modifiedDate - timestamp of the last modification of this group
description - description of the group
admUserIDs - ArrayList of user IDs which have administrative rights for the group
admGroupIDs - ArrayList of groups which members have administrative rights for the group
mbrUserIDs - ArrayList of user IDs this group has as members
Throws:
MCRException
Exception

MCRGroup

public MCRGroup(Element elm)
This constructor creates the data of this object from a given JDOM Element.

Parameters:
elm - the JDOM Element
Method Detail

addAdminGroupID

public void addAdminGroupID(String groupID)
                     throws MCRException
This method adds a group to the list of groups with administrative privileges for the group.

Parameters:
groupID - ID of the group added to the group administrator list
Throws:
MCRException

addAdminUserID

public void addAdminUserID(String userID)
                    throws MCRException
This method adds a user (ID) to the administrators list of the group

Parameters:
userID - ID of the administrative user added to the group
Throws:
MCRException

addMemberUserID

public void addMemberUserID(String userID)
                     throws MCRException
This method adds a user (ID) to the users list of the group

Parameters:
userID - ID of the user added to the group
Throws:
MCRException

getAdminGroupIDs

public final ArrayList<String> getAdminGroupIDs()
Returns:
This method returns the list of administrator groups as a ArrayList of strings.

setAdminGroupIDs

public final void setAdminGroupIDs(ArrayList<String> array)
This method set the list of administrator groups as a ArrayList of Strings.


getAdminUserIDs

public final ArrayList<String> getAdminUserIDs()
Returns:
This method returns the list of administrator users as a ArrayList of strings.

setAdminUserIDs

public final void setAdminUserIDs(ArrayList<String> array)
This method set the list of administrator users as a ArrayList of Strings.


getMemberUserIDs

public final ArrayList<String> getMemberUserIDs()
Returns:
This method returns the user list (group members) as a ArrayList of strings.

getID

public final String getID()
Description copied from class: MCRUserObject
This method must be implemented by a subclass and returns the the ID of the object.

Specified by:
getID in interface MCRPrincipal
Specified by:
getID in class MCRUserObject
Returns:
This method returns the ID (user ID or group ID) of the user object.

setID

public final void setID(String value)

hasUserMember

public boolean hasUserMember(MCRUser user)
This method checks if a user is a member of this group.

Parameters:
user - Is this user a member of the group?
Returns:
Returns true if the given user is a member of this group.

hasUserMember

public boolean hasUserMember(String user)
This method checks if a user is a member of this group.

Parameters:
user - Is this user a member of the group?
Returns:
Returns true if the given user is a member of this group.

isValid

public boolean isValid()
                throws MCRException
This method checks if all required fields have been provided. In a later stage of the software development a User Policy object will be asked, which fields exactly are the required fields. This will be configurable.

Specified by:
isValid in class MCRUserObject
Returns:
returns true if all required fields have been provided
Throws:
MCRException

removeAdminGroupID

public void removeAdminGroupID(String groupID)
                        throws MCRException
This method removes a group from the list of groups with administrative privileges for this group.

Parameters:
groupID - ID of the administrative group removed from the group
Throws:
MCRException

removeAllAdminGroupID

public void removeAllAdminGroupID()
This method remove all administrator group IDs.


removeAdminUserID

public void removeAdminUserID(String userID)
                       throws MCRException
This method removes a user from the list of administrators of the group.

Parameters:
userID - ID of the administrative user removed from the group
Throws:
MCRException

removeAllAdminUserID

public void removeAllAdminUserID()
This method remove all administrator group IDs.


removeMemberUserID

public void removeMemberUserID(String userID)
                        throws MCRException
This method removes a user from the users list (members) of the group.

Parameters:
userID - ID of the user removed from the group
Throws:
MCRException

removeAllMemberUserID

public void removeAllMemberUserID()
This method remove all administrator group IDs.


toJDOMDocument

public Document toJDOMDocument()
                        throws MCRException
Description copied from class: MCRUserObject
This method must be implemented by a subclass and then returns the user or group object as a JDOM document.

Specified by:
toJDOMDocument in class MCRUserObject
Returns:
This method returns the user or group object as a JDOM document.
Throws:
MCRException

toJDOMElement

public Element toJDOMElement()
Description copied from class: MCRUserObject
This method must be implemented by a subclass and then returns the user or group object as a JDOM element.

Specified by:
toJDOMElement in class MCRUserObject
Returns:
This method returns the user or group object as a JDOM element. This is needed if one wants to get a representation of several user or group objects in one xml document.

debug

public final void debug()
This method writes debug data to the logger (for the debug mode).