|
Java AFS API v1.4 | |||||||||
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 | |
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 |
Fields inherited from interface org.openafs.jafs.PTSEntry |
PTS_GROUP, PTS_USER |
Constructor Summary | |
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 | |
void |
addMember(User theUser)
Add the specified member to this group. |
void |
changeOwner(Group theOwner)
Change the owner of this 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. |
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. |
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 .
|
Group[] |
getGroupsOwned()
Returns an array of the Group objects this group owns. |
String[] |
getGroupsOwnedNames()
Returns an array of the group names this group owns. |
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. |
void |
refresh()
Refreshes the properties of this Group object instance with values from the AFS group it represents. |
void |
removeMember(User theUser)
Remove the specified member from this group. |
void |
rename(String newName)
Change the name of this group. |
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 |
equals, 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
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()
Method 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 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 providedpublic 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
|
Java AFS API (jafs) for OpenAFS | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |