org.edg.security.voms.database
Class DBGroup

java.lang.Object
  |
  +--org.edg.security.voms.database.DBGroup
All Implemented Interfaces:
DBContainer

public final class DBGroup
extends java.lang.Object
implements DBContainer

A class representing the groups in a VO. Essentially, a wrapper class for the groups table.

Version:
$Name: v0_7_0 $
Author:
Karoly Lorentey, Akos Frohner

Field Summary
private  long aclId
          The id of the group's access control list.
private static ContainerNamingScheme cns
          The container naming scheme for this instance of VOMS.
private  long createdBy
          The id of the client who created this row.
private  long createdSerial
          The number of the transaction that created this row.
private  long defaultACLId
          The id of the group's default access control list.
private  long id
          The id of this group.
private static int ID
           
private static VOMSException initError
           
private static org.apache.log4j.Logger log
          Logger.
private  boolean must
          Whether this is a non-deniable group.
private  java.lang.String name
          The fully qualified name of this group, in display form.
private static int NAME
           
private  long parent
          The id of the group's parent group.
(package private) static Sequence seq
          Sequence.
static long VO_GROUP_ID
          The id of the VO group.
private static DBGroup voGroup
          The VO group.
 
Constructor Summary
private DBGroup(long id)
          Initialize a new DBGroup from the given id.
private DBGroup(java.lang.String name)
          Initialize a new DBGroup from the given name.
 
Method Summary
 void addMember(DBUser user)
          Add a user to the members of this group.
 void checkPermission(Operation o)
          Convenience method: check that the client has the necessary privileges to perform the given operation on this group.
 int countAllGroups()
          Return the number of groups in this VO.
 int countChildGroups()
          Return the number of direct subgroups of this group.
 int countMembers()
          Returns the number of users who are members of this group.
 DBGroup createChildGroup(java.lang.String name)
          Creates a new group with this group as parent.
 void deleteGroup()
          Delete this group.
 DBACL getACL()
          Return this group's ACL.
(package private)  long getACLId()
          Return the ACL id of this group.
 java.util.List getAdminUsersForOperation(Operation o)
          Convenience method: returns the list of users, who also play administrative role for the given operation.
 java.lang.String[] getChildGroupNames()
          Get the names of direct subgroups of this group.
 DBGroup[] getChildGroups()
          Get the direct subgroups of this group.
 DBAdmin getCreatedBy()
          Return the administrator who created this group.
(package private)  long getCreatedById()
          Return the id of the user who created this group.
 long getCreatedSerial()
          Return the serial number of the transaction that committed this group.
 DBACL getDefaultACL()
          Return this group's default ACL.
(package private)  long getDefaultACLId()
          Return the default ACL id of this group.
 java.lang.String getDN()
          Return the name of this group.
(package private)  long getId()
          Return the id of this group.
(package private) static DBGroup getInstance(long id)
          Returns a DBGroup object representing the group with the given id.
static DBGroup getInstance(java.lang.String name)
          Returns a DBGroup object representing the named group.
 DBUser[] getMembers()
          Return the members of this group as DBUser objects.
 User[] getMembersAsUser()
          Return the names of all members of this group as User objects.
 boolean getMust()
          Return true iff the group is non-deniable.
 DBGroup getParent()
          Return this group's parent group.
(package private)  long getParentId()
          Return the id of this group's parent group.
static DBGroup getVOGroup()
          Returns a DBGroup object representing the VO group.
private  void initialize(int from)
          Query the database for the full group row.
 boolean isChildGroup(DBGroup child)
          Return true if the given group is a direct subgroup of this group.
 boolean isMember(DBUser user)
          Returns true if the given user is a member of this group.
 boolean isVOGroup()
          Return true if this group is the VO group.
 void removeAllMembers()
          Remove all members of this group.
 void removeMember(DBUser user)
          Remove a user from this group.
 void setAttributes(boolean must)
          Set auxiliary attributes.
 java.lang.String toString()
          Convert to a human-readable string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static final org.apache.log4j.Logger log
Logger.


VO_GROUP_ID

public static final long VO_GROUP_ID
The id of the VO group.

See Also:
Constant Field Values

name

private java.lang.String name
The fully qualified name of this group, in display form.


id

private long id
The id of this group.


parent

private long parent
The id of the group's parent group.


aclId

private long aclId
The id of the group's access control list.


defaultACLId

private long defaultACLId
The id of the group's default access control list.


must

private boolean must
Whether this is a non-deniable group.


createdBy

private long createdBy
The id of the client who created this row.


createdSerial

private long createdSerial
The number of the transaction that created this row.


seq

static final Sequence seq
Sequence.


cns

private static ContainerNamingScheme cns
The container naming scheme for this instance of VOMS.


voGroup

private static DBGroup voGroup
The VO group.


initError

private static VOMSException initError

NAME

private static final int NAME
See Also:
Constant Field Values

ID

private static final int ID
See Also:
Constant Field Values
Constructor Detail

DBGroup

private DBGroup(java.lang.String name)
         throws GeneralDatabaseException,
                NotInDatabase,
                ArgumentException
Initialize a new DBGroup from the given name.


DBGroup

private DBGroup(long id)
         throws GeneralDatabaseException,
                NotInDatabase
Initialize a new DBGroup from the given id.

Method Detail

initialize

private void initialize(int from)
                 throws GeneralDatabaseException,
                        NotInDatabase,
                        ArgumentException
Query the database for the full group row. Use either the gid or the name field to find the correct group in the database.

GeneralDatabaseException
NotInDatabase
ArgumentException

getInstance

public static DBGroup getInstance(java.lang.String name)
                           throws GeneralDatabaseException,
                                  NotInDatabase,
                                  ArgumentException
Returns a DBGroup object representing the named group.

Parameters:
name - The fully qualified name of the group. (Null is an alias for the VO group.)
Returns:
The DBGroup instance representing the named group.
Throws:
NotInDatabase - If there is no such group in the database.
GeneralDatabaseException
ArgumentException

getInstance

static DBGroup getInstance(long id)
                    throws GeneralDatabaseException,
                           NotInDatabase
Returns a DBGroup object representing the group with the given id.

Parameters:
id - The internal id of the group. A group with that id must be present in the database.
Throws:
NotInDatabase - If there is no such group in the database.
GeneralDatabaseException

getVOGroup

public static DBGroup getVOGroup()
                          throws GeneralDatabaseException
Returns a DBGroup object representing the VO group.

GeneralDatabaseException

getId

long getId()
Return the id of this group.


getDN

public java.lang.String getDN()
Return the name of this group.

Specified by:
getDN in interface DBContainer

getMust

public boolean getMust()
Return true iff the group is non-deniable.


toString

public java.lang.String toString()
Convert to a human-readable string.

Specified by:
toString in interface DBContainer
Overrides:
toString in class java.lang.Object

getParentId

long getParentId()
Return the id of this group's parent group. Please consider using getParent instead of this method.


getACLId

long getACLId()
Return the ACL id of this group. Please consider using getACL instead of this method.


getDefaultACLId

long getDefaultACLId()
Return the default ACL id of this group. Please consider using getDefaultACl instead of this method.


getCreatedById

long getCreatedById()
Return the id of the user who created this group. Please consider using getCreatedBy instead of this method.


getCreatedSerial

public long getCreatedSerial()
Return the serial number of the transaction that committed this group.


getParent

public DBGroup getParent()
                  throws GeneralDatabaseException
Return this group's parent group.

Returns:
null if this group is the VO group.
GeneralDatabaseException

getACL

public DBACL getACL()
             throws DatabaseError,
                    InconsistentDatabase
Return this group's ACL.

Specified by:
getACL in interface DBContainer
DatabaseError
InconsistentDatabase

getDefaultACL

public DBACL getDefaultACL()
                    throws DatabaseError,
                           InconsistentDatabase
Return this group's default ACL.

DatabaseError
InconsistentDatabase

getCreatedBy

public DBAdmin getCreatedBy()
                     throws GeneralDatabaseException,
                            NotInDatabase
Return the administrator who created this group.

Throws:
NotInDatabase - if the administrator has been deleted from the database.
GeneralDatabaseException

isVOGroup

public boolean isVOGroup()
Return true if this group is the VO group.


checkPermission

public void checkPermission(Operation o)
                     throws GeneralDatabaseException,
                            VOMSSecurityException
Convenience method: check that the client has the necessary privileges to perform the given operation on this group.

Specified by:
checkPermission in interface DBContainer
GeneralDatabaseException
VOMSSecurityException

getAdminUsersForOperation

public java.util.List getAdminUsersForOperation(Operation o)
                                         throws GeneralDatabaseException,
                                                VOMSSecurityException
Convenience method: returns the list of users, who also play administrative role for the given operation.

GeneralDatabaseException
VOMSSecurityException

countAllGroups

public int countAllGroups()
                   throws GeneralDatabaseException
Return the number of groups in this VO.

Returns:
The number of groups in this VO, including the VO group.
GeneralDatabaseException

countChildGroups

public int countChildGroups()
                     throws GeneralDatabaseException
Return the number of direct subgroups of this group.

Returns:
The number of direct subgroups of this group.
GeneralDatabaseException

isChildGroup

public boolean isChildGroup(DBGroup child)
                     throws GeneralDatabaseException
Return true if the given group is a direct subgroup of this group.

Parameters:
child - The group to check.
Returns:
true if child is a direct subgroup of this group.
GeneralDatabaseException

getChildGroups

public DBGroup[] getChildGroups()
                         throws GeneralDatabaseException
Get the direct subgroups of this group.

Returns:
The array of the direct subgroups of this group.
GeneralDatabaseException

getChildGroupNames

public java.lang.String[] getChildGroupNames()
                                      throws GeneralDatabaseException
Get the names of direct subgroups of this group.

Returns:
The names of direct subgroups.
GeneralDatabaseException

createChildGroup

public DBGroup createChildGroup(java.lang.String name)
                         throws GeneralDatabaseException,
                                ArgumentException
Creates a new group with this group as parent. Note that this method does not check for naming inconsistencies. It is up to the caller to ensure that the name of the new group corresponds to the configured naming scheme.

The new groups gets a copy of the parent group's ACL and default ACL, extended with an entry for the current user.

The group becomes a non-deniable group by default.

Parameters:
name - The fqgn of the new group.
Returns:
the newly created group.
Throws:
ArgumentException - if a group with the given name already exists.
GeneralDatabaseException

deleteGroup

public void deleteGroup()
                 throws GeneralDatabaseException,
                        ArgumentException
Delete this group.

Throws:
ArgumentException - if the group has members or subcontainers or if the group is the VO group.
GeneralDatabaseException

countMembers

public int countMembers()
                 throws GeneralDatabaseException
Returns the number of users who are members of this group.

Returns:
The number of users who are in this group.
GeneralDatabaseException

isMember

public boolean isMember(DBUser user)
                 throws GeneralDatabaseException
Returns true if the given user is a member of this group.

Parameters:
user - The user to check for.
Returns:
True if the given user is a member; false otherwise.
GeneralDatabaseException

getMembers

public DBUser[] getMembers()
                    throws GeneralDatabaseException
Return the members of this group as DBUser objects.

Returns:
The members of this group.
GeneralDatabaseException

getMembersAsUser

public User[] getMembersAsUser()
                        throws GeneralDatabaseException
Return the names of all members of this group as User objects.

Returns:
The members of this group.
GeneralDatabaseException

addMember

public void addMember(DBUser user)
               throws GeneralDatabaseException,
                      ArgumentException
Add a user to the members of this group.

Parameters:
user - The user to add.
Throws:
ArgumentException - if the user is already a member of this group.
GeneralDatabaseException

removeMember

public void removeMember(DBUser user)
                  throws GeneralDatabaseException,
                         ArgumentException
Remove a user from this group.

Parameters:
user - The user to remove.
Throws:
ArgumentException - if the user is not a member of the group.
GeneralDatabaseException

removeAllMembers

public void removeAllMembers()
                      throws GeneralDatabaseException
Remove all members of this group.

GeneralDatabaseException

setAttributes

public void setAttributes(boolean must)
                   throws InconsistentDatabase,
                          DatabaseError
Set auxiliary attributes.

InconsistentDatabase
DatabaseError