|
JAFS API v2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.openafs.jafs.Group
An abstract representation of an AFS group. It holds information about
the group, such as what groups it owns.
Constructing an instance of a Group
does not mean an actual
AFS group is created in a cell -- usually a Group
object is a representation of an already existing AFS group. If,
however, the Group
is constructed with the name of a
group that does not exist in the cell represented by the provided
Cell
, a new group with that name can be
created in that cell by calling the create(String, int)
or
create(String)
method. If such a group does already exist when
one of these methods is called, an exception will be thrown.
Each Group
object has its own individual set of
Group
s that it owns and User
s that belong
to it. These represents the properties and attributes
of an actual AFS group.
Associated with an AFS group are many attributes, such as whether or not
who is allowed to list the members of this group. The Group
class has many "set" methods to indicate values for these attributes (i.e.
setListMembership(int)
. However, in order for these values to be
written to the actual AFS group, the flushInfo()
method needs to
be called. This writes all user attributes set through this API to AFS.
This is done to minimize calls through JNI.
The following is a simple example of how to construct and use a
Group
object. It lists the name and owner of a specified
group.
import org.openafs.jafs.Cell; import org.openafs.jafs.AFSException; import org.openafs.jafs.Partition; import org.openafs.jafs.Group; ... public class ... { ... private Cell cell; private Group group; ... public static void main(String[] args) throws Exception { String username = arg[0]; String password = arg[1]; String cellName = arg[2]; String groupName = arg[3]; token = new Token(username, password, cellName); cell = new Cell(token); group = new Group(groupName, cell); System.out.println("Owner of group " + group.getName() + " is " + group.getOwnerName()); ... } ... }
Field Summary | |
protected boolean |
cachedInfo
Whether or not the information fields of this group have been filled. |
protected Cell |
cell
|
protected int |
cellHandle
|
protected String |
creator
|
protected int |
creatorUID
|
static int |
GROUP_ANYUSER_ACCESS
Any user has access |
static int |
GROUP_GROUP_ACCESS
Members of the group have access |
static int |
GROUP_OWNER_ACCESS
Only the owner of the group has access |
protected ArrayList |
groupsOwned
|
protected ArrayList |
groupsOwnedNames
|
protected int |
listAdd
who is allowed to execute PTS adduser for this group. |
protected int |
listDelete
who is allowed to execute PTS removeuser for this group. |
protected int |
listGroupsOwned
who is allowed to execute PTS examine for this group. |
protected int |
listMembership
who is allowed to execute PTS listowned for this group. |
protected int |
listStatus
who is allowed to execute PTS examine for this group. |
protected ArrayList |
memberNames
|
protected ArrayList |
members
|
protected int |
membershipCount
|
protected String |
name
|
protected int |
nameUID
|
protected String |
owner
|
protected int |
ownerUID
|
Fields inherited from interface org.openafs.jafs.PTSEntry |
PTS_GROUP, PTS_USER |
Constructor Summary | |
(package private) |
Group(Cell cell)
Creates a blank Group given the cell to which the group
belongs. |
|
Group(String name,
Cell cell)
Constructs a new Group object instance given the name
of the AFS group and the AFS cell, represented by
cell , to which it belongs. |
|
Group(String name,
Cell cell,
boolean preloadAllMembers)
Constructs a new Group object instance given the name
of the AFS group and the AFS cell, represented by
cell , to which it belongs. |
Method Summary | |
protected static void |
addMember(int cellHandle,
String groupName,
String userName)
Adds a user to the specified group. |
void |
addMember(User theUser)
Add the specified member to this group. |
void |
changeOwner(Group theOwner)
Change the owner of this group. |
protected static void |
changeOwner(int cellHandle,
String groupName,
String ownerName)
Change the owner of the specified group. |
void |
changeOwner(User theOwner)
Change the owner of this group. |
int |
compareTo(Group group)
Compares two Group objects respective to their names and does not factor any other attribute. |
int |
compareTo(Object obj)
Comparable interface method. |
protected static void |
create(int cellHandle,
String groupName,
String ownerName,
int gid)
Creates the PTS entry for a new group. |
void |
create(String ownerName)
Creates the PTS entry for a new group in this cell. |
void |
create(String ownerName,
int gid)
Creates the PTS entry for a new group in this cell. |
void |
delete()
Deletes the PTS entry for a group in this cell. |
protected static void |
delete(int cellHandle,
String groupName)
Deletes the PTS entry for a group. |
boolean |
equals(Group otherGroup)
Tests whether two Group objects are equal, based on their
names. |
void |
flushInfo()
Flushes the current information of this Group object to disk.
|
Cell |
getCell()
Returns the Cell this group belongs to. |
PTSEntry |
getCreator()
PTS: Returns the creator of this group in the form of a PTSEntry .
|
protected static void |
getGroupInfo(int cellHandle,
String name,
Group group)
Fills in the information fields of the provided Group .
|
protected static int |
getGroupMembersBegin(int cellHandle,
String name)
Begin the process of getting the users that belong to the group. |
protected static void |
getGroupMembersDone(int iterationId)
Signals that the iteration is complete and will not be accessed anymore. |
protected static int |
getGroupMembersNext(int cellHandle,
int iterationId,
User theUser)
Fills the next user object belonging to that group. |
protected static String |
getGroupMembersNextString(int iterationId)
Returns the next members that belongs to the group. |
Group[] |
getGroupsOwned()
Returns an array of the Group objects this group owns. |
String[] |
getGroupsOwnedNames()
Returns an array of the group names this group owns. |
protected String |
getInfo()
Returns a String representation of this Group .
|
int |
getListAdd()
Returns who can add members (pts adduser) to this group. |
int |
getListDelete()
Returns who can delete members (pts removemember) from this group. |
int |
getListGroupsOwned()
Returns who can list the groups owned (pts listowned) by this group. |
int |
getListMembership()
Returns who can list the users (pts membership) that belong to this group. |
int |
getListStatus()
Returns who can list the status (pts examine) of this group. |
String[] |
getMemberNames()
Returns an array of the member names of this group. |
User[] |
getMembers()
Returns an array of the User object members of this group. |
int |
getMembershipCount()
Returns the number of members of this group. |
String |
getName()
Returns the name of this group. |
PTSEntry |
getOwner()
PTS: Returns the owner of this group in the form of a PTSEntry .
|
short |
getType()
Returns the type of PTSEntry this object represents.
|
int |
getUID()
Returns the numeric AFS id of this group. |
protected static void |
reclaimGroupMemory()
Reclaims all memory being saved by the group portion of the native library. |
void |
refresh()
Refreshes the properties of this Group object instance with values from the AFS group it represents. |
protected void |
refresh(boolean all)
Refreshes the properties of this Group object instance with values from the AFS group it represents. |
protected void |
refreshGroupsOwned()
Refreshes the current information about the Group objects the
group owns. |
protected void |
refreshGroupsOwnedNames()
Refreshes the current information about the names of groups the group owns. |
protected void |
refreshInfo()
Refreshes the information fields of this Group to reflect
the current state of the AFS group. |
protected void |
refreshMemberNames()
Refreshes the current information about the names of members belonging to this group. |
protected void |
refreshMembers()
Refreshes the current information about the User objects
belonging to this group. |
protected static void |
removeMember(int cellHandle,
String groupName,
String userName)
Removes a user from the specified group. |
void |
removeMember(User theUser)
Remove the specified member from this group. |
protected static void |
rename(int cellHandle,
String oldGroupName,
String newGroupName)
Change the name of the specified group. |
void |
rename(String newName)
Change the name of this group. |
protected static void |
setGroupInfo(int cellHandle,
String name,
Group theGroup)
Sets the information values of this AFS group to be the parameter values. |
void |
setListAdd(int value)
Sets who can add members (pts adduser) to this group. |
void |
setListDelete(int value)
Sets who can delete members (pts removemember) from this group. |
void |
setListGroupsOwned(int value)
Sets who can list the groups owned (pts listowned) by this group. |
void |
setListMembership(int value)
Sets who can list the users (pts membership) that belong to this group. |
void |
setListStatus(int value)
Sets who can list the status (pts examine) of this group. |
String |
toString()
Returns the name of this Group |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int GROUP_OWNER_ACCESS
public static final int GROUP_GROUP_ACCESS
public static final int GROUP_ANYUSER_ACCESS
protected Cell cell
protected int cellHandle
protected String name
protected int membershipCount
protected int nameUID
protected int ownerUID
protected int creatorUID
protected String owner
protected String creator
protected int listStatus
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
protected int listGroupsOwned
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
protected int listMembership
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
protected int listAdd
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
protected int listDelete
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
protected ArrayList members
protected ArrayList memberNames
protected ArrayList groupsOwned
protected ArrayList groupsOwnedNames
protected boolean cachedInfo
Constructor Detail |
public Group(String name, Cell cell) throws AFSException
Group
object instance given the name
of the AFS group and the AFS cell, represented by
cell
, to which it belongs. This does not actually
create a new AFS group, it just represents one.
If name
is not an actual AFS group, exceptions
will be thrown during subsequent method invocations on this
object, unless the create(String, int)
or create(String)
method is explicitly called to create it.
name
- the name of the group to representcell
- the cell to which the group belongs.
AFSException
- If an error occurs in the native codepublic Group(String name, Cell cell, boolean preloadAllMembers) throws AFSException
Group
object instance given the name
of the AFS group and the AFS cell, represented by
cell
, to which it belongs. This does not actually
create a new AFS group, it just represents one.
If name
is not an actual AFS group, exceptions
will be thrown during subsequent method invocations on this
object, unless the create(String, int)
or create(String)
method is explicitly called to create it. Note that if the process
doesn't exist and preloadAllMembers
is true, an exception
will be thrown.
This constructor is ideal for point-in-time representation and
transient applications. It ensures all data member values are set and
available without calling back to the filesystem at the first request
for them. Use the refresh()
method to address any coherency
concerns.
name
- the name of the group to representcell
- the cell to which the group belongs.preloadAllMembers
- true will ensure all object members are
set upon construction;
otherwise members will be set upon access,
which is the default behavior.
AFSException
- If an error occurs in the native coderefresh()
Group(Cell cell) throws AFSException
Group
given the cell to which the group
belongs. Other methods cvan then be used to fill the fields of this
blank object.
cell
- the cell to which the group belongs.
AFSException
- If an error occurs in the native codeMethod Detail |
public void create(String ownerName) throws AFSException
ownerName
- the owner of this group
AFSException
public void create(String ownerName, int gid) throws AFSException
ownerName
- the owner of this groupgid
- the group id to assign to the new group
AFSException
- If an error occurs in the native codepublic void delete() throws AFSException
AFSException
- If an error occurs in the native codepublic void flushInfo() throws AFSException
Group
object to disk.
This will update the information of the actual AFS group to match the
settings that have been modified in this Group
object.
This function must be called before any changes made to the information
fields of this group will be seen by the AFS system.
AFSException
- If an error occurs in the native codepublic void addMember(User theUser) throws AFSException
AFSException
- If an error occurs in the native codepublic void removeMember(User theUser) throws AFSException
AFSException
- If an error occurs in the native codepublic void changeOwner(User theOwner) throws AFSException
AFSException
- If an error occurs in the native codepublic void changeOwner(Group theOwner) throws AFSException
AFSException
- If an error occurs in the native codepublic void rename(String newName) throws AFSException
newName
- the new name for this group
AFSException
- If an error occurs in the native codepublic void refresh() throws AFSException
Group
object instance represents.
Since in most environments administrative changes can be administered from an AFS command-line program or an alternate GUI application, this method provides a means to refresh the Java object representation and thereby ascertain any possible modifications that may have been made from such alternate administrative programs. Using this method before an associated instance accessor will ensure the highest level of representative accuracy, accommodating changes made external to the Java application space. If administrative changes to the underlying AFS system are only allowed via this API, then the use of this method is unnecessary.
AFSException
- If an error occurs in the native codeprotected void refresh(boolean all) throws AFSException
all
is true
then all of the properties of this Group object instance will be
set, or renewed, according to the values of the AFS group it represents,
disregarding any previously set properties.
Thus, if all
is false
then properties that
are currently set will be refreshed and properties that are not set will
remain uninitialized. See refresh()
for more information.
all
- if true set or renew all object properties; otherwise renew
all set properties
AFSException
- If an error occurs in the native coderefresh()
protected void refreshInfo() throws AFSException
Group
to reflect
the current state of the AFS group. Does not refresh the members that
belong to the group, nor the groups the group owns.
AFSException
- If an error occurs in the native codeprotected void refreshMembers() throws AFSException
User
objects
belonging to this group. Does not refresh the information fields of
the group or groups owned.
AFSException
- If an error occurs in the native codeprotected void refreshMemberNames() throws AFSException
AFSException
- If an error occurs in the native codeprotected void refreshGroupsOwned() throws AFSException
Group
objects the
group owns. Does not refresh the information fields of the group or
members.
AFSException
- If an error occurs in the native codeprotected void refreshGroupsOwnedNames() throws AFSException
AFSException
- If an error occurs in the native codepublic String getName()
getName
in interface PTSEntry
public int getUID() throws AFSException
getUID
in interface PTSEntry
AFSException
- If an error occurs in the native codepublic Cell getCell()
getCell
in interface PTSEntry
public User[] getMembers() throws AFSException
User
object members of this group.
AFSException
- If an error occurs in the native codepublic String[] getMemberNames() throws AFSException
AFSException
- If an error occurs in the native codepublic Group[] getGroupsOwned() throws AFSException
Group
objects this group owns.
Groups
this group owns
AFSException
- If an error occurs in the native codepublic String[] getGroupsOwnedNames() throws AFSException
String
objects.
AFSException
- If an error occurs in the native codepublic int getMembershipCount() throws AFSException
AFSException
- If an error occurs in the native codepublic PTSEntry getOwner() throws AFSException
PTSEntry
.
The returning object could be either a User
or Group
;
to determine what type of object the PTSEntry
represents,
call the PTSEntry.getType()
method.
getOwner
in interface PTSEntry
AFSException
- If an error occurs in the native codePTSEntry
,
PTSEntry.getType()
,
refresh()
public PTSEntry getCreator() throws AFSException
PTSEntry
.
The returning object could be either a User
or Group
;
to determine what type of object the PTSEntry
represents,
call the PTSEntry.getType()
method.
getCreator
in interface PTSEntry
AFSException
- If an error occurs in the native codePTSEntry
,
PTSEntry.getType()
,
refresh()
public short getType()
PTSEntry
this object represents.
This method will always return PTSEntry.PTS_GROUP
.
getType
in interface PTSEntry
PTSEntry.PTS_GROUP
)PTSEntry
,
PTSEntry.getType()
public int getListStatus() throws AFSException
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
AFSException
- If an error occurs in the native codepublic int getListGroupsOwned() throws AFSException
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
AFSException
- If an error occurs in the native codepublic int getListMembership() throws AFSException
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
AFSException
- If an error occurs in the native codepublic int getListAdd() throws AFSException
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
AFSException
- If an error occurs in the native codepublic int getListDelete() throws AFSException
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
AFSException
- If an error occurs in the native codepublic void setListStatus(int value) throws AFSException
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
value
- the value of the new list membership permission
AFSException
- if an error occurs in the native code
IllegalArgumentException
- if an invalud argument is providedpublic void setListGroupsOwned(int value) throws AFSException
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
value
- the value of the new list membership permission
AFSException
- if an error occurs in the native code
IllegalArgumentException
- if an invalud argument is providedpublic void setListMembership(int value) throws AFSException
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
value
- the value of the new list membership permission
AFSException
- if an error occurs in the native code
IllegalArgumentException
- if an invalud argument is providedpublic void setListAdd(int value) throws AFSException
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
value
- the value of the new list membership permission
AFSException
- if an invalid value is providedpublic void setListDelete(int value) throws AFSException
GROUP_OWNER_ACCESS
-- only the owner has permissionGROUP_GROUP_ACCESS
-- only members of the group have permissionGROUP_ANYUSER_ACCESS
-- any user has permission
value
- the value of the new list membership permission
AFSException
- if an invalid value is providedprotected String getInfo()
String
representation of this Group
.
Contains the information fields and members.
String
representation of the Group
public int compareTo(Group group)
group
- The Group object to be compared to this Group instance
public int compareTo(Object obj)
compareTo
in interface Comparable
compareTo(Group)
public boolean equals(Group otherGroup)
Group
objects are equal, based on their
names.
otherGroup
- the Group to test
public String toString()
Group
toString
in class Object
Group
protected static void create(int cellHandle, String groupName, String ownerName, int gid) throws AFSException
cellHandle
- the handle of the cell to which the group belongsgroupName
- the name of the group to createownerName
- the owner of this groupgid
- the group id to assign to the group (0 to have one
automatically assigned)
AFSException
- If an error occurs in the native codeCell.getCellHandle()
protected static void delete(int cellHandle, String groupName) throws AFSException
cellHandle
- the handle of the cell to which the group belongsgroupName
- the name of the group to delete
AFSException
- If an error occurs in the native codeCell.getCellHandle()
protected static void getGroupInfo(int cellHandle, String name, Group group) throws AFSException
Group
.
Fills in values based on the current PTS information of the group.
cellHandle
- the handle of the cell to which the group belongsname
- the name of the group for which to get the informationgroup
- the Group
object in which to fill in the
information
AFSException
- If an error occurs in the native codeCell.getCellHandle()
,
Group
protected static void setGroupInfo(int cellHandle, String name, Group theGroup) throws AFSException
cellHandle
- the handle of the cell to which the user belongsname
- the name of the user for which to set the informationtheGroup
- the group object containing the desired information
AFSException
- If an error occurs in the native codeCell.getCellHandle()
protected static int getGroupMembersBegin(int cellHandle, String name) throws AFSException
getGroupMembersNext
and getGroupMembersDone
.
cellHandle
- the handle of the cell to which the group belongsname
- the name of the group for which to get the members
AFSException
- If an error occurs in the native codeCell.getCellHandle()
protected static String getGroupMembersNextString(int iterationId) throws AFSException
null
if there are no more members.
iterationId
- the iteration ID of this iteration
AFSException
- If an error occurs in the native codegetGroupMembersBegin(int, java.lang.String)
protected static int getGroupMembersNext(int cellHandle, int iterationId, User theUser) throws AFSException
cellHandle
- the handle of the cell to which the users belongiterationId
- the iteration ID of this iterationtheUser
- a User object to be populated with the values of the
next user
AFSException
- If an error occurs in the native codeCell.getCellHandle()
,
getGroupMembersBegin(int, java.lang.String)
protected static void getGroupMembersDone(int iterationId) throws AFSException
iterationId
- the iteration ID of this iteration
AFSException
- If an error occurs in the native codegetGroupMembersBegin(int, java.lang.String)
protected static void addMember(int cellHandle, String groupName, String userName) throws AFSException
cellHandle
- the handle of the cell to which the group belongsgroupName
- the name of the group to which to add a memberuserName
- the name of the user to add
AFSException
- If an error occurs in the native codeCell.getCellHandle()
protected static void removeMember(int cellHandle, String groupName, String userName) throws AFSException
cellHandle
- the handle of the cell to which the group belongsgroupName
- the name of the group from which to remove a
memberuserName
- the name of the user to remove
AFSException
- If an error occurs in the native codeCell.getCellHandle()
protected static void changeOwner(int cellHandle, String groupName, String ownerName) throws AFSException
cellHandle
- the handle of the cell to which the group belongsgroupName
- the name of the group of which to change the
ownerownerName
- the name of the new owner
AFSException
- If an error occurs in the native codeCell.getCellHandle()
protected static void rename(int cellHandle, String oldGroupName, String newGroupName) throws AFSException
cellHandle
- the handle of the cell to which the group belongsoldGroupName
- the old name of the groupnewGroupName
- the new name for the group
AFSException
- If an error occurs in the native codeCell.getCellHandle()
protected static void reclaimGroupMemory()
Groups
are expected
to be used.
|
JAFS API v2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |