2 * @(#)Cell.java 1.0 6/29/2001
4 * Copyright (c) 2001-2002 International Business Machines Corp.
7 * This software has been released under the terms of the IBM Public
8 * License. For details, see the LICENSE file in the top-level source
9 * directory or online at http://www.openafs.org/dl/license10.html
11 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
12 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
13 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
14 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
15 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
18 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
19 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 package org.openafs.jafs;
26 import java.util.ArrayList;
27 import java.util.GregorianCalendar;
28 import java.util.Date;
31 * An abstract representation of an AFS cell. It holds information about
32 * the cell, such as what users, groups, and servers exist in the cell.
35 * Constructing a <code>Cell</code> object does not mean a new cell is
36 * created in the AFS file system -- on the contrary, a <code>Cell</code>
37 * object must be a representation of an already existing AFS cell. There
38 * is no way to create a new AFS cell through this API. See
39 * <a href="http://www.openafs.org">OpenAFS.org</a> for information on how
40 * to create a new cell.<BR><BR>
42 * The construction of a <code>Cell</code> object acts as an entry point
43 * for authentication into the AFS system. Thus, when you construct a
44 * <code>Cell</code>, you must pass in an authenticated <code>Token</code>
45 * of a user in the AFS cell that the <code>Cell</code> represents. You
46 * will be authenticated as the user represented by <code>token</code> and
47 * you will only be allowed to perform actions that the user is
48 * authorized to perform. You must construct a <code>Cell</code> before
49 * attempting to construct any other object in this package, since the
50 * other objects all require a <code>Cell</code> object on construction,
51 * either directly or indirectly.<BR><BR>
53 * Note that to successfully construct a <code>Cell</code> object, the
54 * code must be running on a machine with a running AFS client, and the
55 * cell this object is to represent must have an entry in the client's
56 * CellServDB file.<BR><BR>
58 * Each <code>Cell</code> object has its own individual set of
59 * <code>Server</code>s, <code>User</code>s, and <code>Group</code>s.
60 * This represents the properties and attributes of an actual AFS cell.
62 * If an error occurs during a method call, an
63 * <code>AFSException</code> will be thrown. This class is the Java
64 * equivalent of errors thrown by AFS; see {@link AFSException}
65 * for a complete description.<BR><BR>
67 * <!--Example of how to use class-->
68 * The following is a simple example of how to construct and use a
69 * <code>Cell</code> object. It shows how a <code>Cell</code> can be used to
70 * get an abstract representation of an AFS server, and how it can obtain an
71 * array of <code>User</code> objects, each of which is an abstract
72 * representation of an AFS user.<BR><BR>
75 * import org.openafs.jafs.AFSException;
76 * import org.openafs.jafs.Cell;
77 * import org.openafs.jafs.Partition;
78 * import org.openafs.jafs.Server;
79 * import org.openafs.jafs.Token;
80 * import org.openafs.jafs.User;
86 * private Server server;
87 * private Token token;
89 * public static void main(String[] args) throws Exception
91 * String username = arg[0];
92 * String password = arg[1];
93 * String cellName = arg[2];
94 * String serverName = arg[3];
96 * token = new Token(username, password, cellName);
97 * cell = new Cell(token);
98 * server = cell.getServer(serverName);
100 * User[] users = cell.getUsers();
108 public class Cell implements java.io.Serializable
110 protected ArrayList users;
111 protected ArrayList userNames;
112 protected ArrayList groups;
113 protected ArrayList groupNames;
114 protected ArrayList servers;
115 protected ArrayList serverNames;
117 protected String name;
118 protected int cellHandle;
119 protected Token token;
121 protected int maxGroupID;
122 protected int maxUserID;
124 protected GregorianCalendar tokenExpiration;
126 protected boolean cachedInfo;
129 * Constructs a new <CODE>Cell</CODE> object instance given
130 * the <code>Token</code> that should represents an authenticated user
131 * with administrative access. In order to get full access to the cell,
132 * it is best that the <code>Token</code> provided have administrative
135 * @param token the user's authenticated token
136 * @exception AFSException If an error occurs in the native code
138 public Cell( Token token )
142 this.name = token.getCellName();
144 cellHandle = getCellHandle( name, token.getHandle() );
153 tokenExpiration = null;
157 * Constructs a new <CODE>Cell</CODE> object instance given
158 * the <code>Token</code> that should represents an authenticated user
159 * with administrative access. In order to get full access to the cell,
160 * it is best that the <code>Token</code> provided have administrative
163 * <P> This constructor is ideal for point-in-time representation and
164 * transient applications. It ensures all data member values are set
165 * and available without calling back to the filesystem at the first
166 * request for them. Use the {@link #refresh()} method to address any
167 * coherency concerns.
169 * @param token the user's authenticated token
170 * @param preloadAllMembers true will ensure all object members are
171 * set upon construction; otherwise members
172 * will be set upon access, which is the default
174 * @exception AFSException If an error occurs in the native code
177 public Cell( Token token, boolean preloadAllMembers )
181 if (preloadAllMembers) refresh(true);
185 * Refreshes the properties of this Cell object instance with values
186 * from the AFS cell it represents. All properties that have been
187 * initialized and/or accessed will be renewed according to the values
188 * of the AFS cell this Cell object instance represents.
190 * <P>Since in most environments administrative changes can be administered
191 * from an AFS command-line program or an alternate GUI application, this
192 * method provides a means to refresh the Java object representation and
193 * thereby ascertain any possible modifications that may have been made
194 * from such alternate administrative programs. Using this method before
195 * an associated instance accessor will ensure the highest level of
196 * representative accuracy, accommodating changes made external to the
197 * Java application space. If administrative changes to the underlying AFS
198 * system are only allowed via this API, then the use of this method is
201 * @exception AFSException If an error occurs in the native code
203 public void refresh() throws AFSException
209 * Refreshes the properties of this Cell object instance with values
210 * from the AFS cell it represents. If <CODE>all</CODE> is <CODE>true</CODE>
211 * then <U>all</U> of the properties of this Cell object instance will be
212 * set, or renewed, according to the values of the AFS cell it represents,
213 * disregarding any previously set properties.
215 * <P> Thus, if <CODE>all</CODE> is <CODE>false</CODE> then properties that
216 * are currently set will be refreshed and properties that are not set will
217 * remain uninitialized. See {@link #refresh()} for more information.
219 * @param all if true set or renew all object properties; otherwise
220 * renew all set properties
221 * @exception AFSException If an error occurs in the native code
224 protected void refresh(boolean all) throws AFSException
226 if( all || (users != null) ) {
229 if( all || (userNames != null) ) {
232 if( all || (groups != null) ) {
235 if( all || (groupNames != null) ) {
238 if( all || (servers != null) ) {
241 if( all || (serverNames != null) ) {
242 refreshServerNames();
244 if( all || cachedInfo ) {
250 * Obtains the expiration time of the token being used by this
251 * <code>Cell</code> object. Does not actually refresh the token; that is,
252 * once a token is obtained, its expiration time will not change. This
253 * method is mostly for consistency with the other methods. It is mainly
254 * used for getting the token information once; after that, it need not
257 * @exception AFSException If an error occurs in the native code
259 private void refreshTokenExpiration() throws AFSException
263 expTime = token.getExpiration();
265 tokenExpiration = new GregorianCalendar();
266 long longTime = expTime*1000;
267 Date d = new Date( longTime );
268 tokenExpiration.setTime( d );
272 * Sets all the information fields of this <code>Cell</code> object,
273 * such as max group and user ids, to trheir most current values.
275 * @exception AFSException If an error occurs in the native code
277 protected void refreshInfo() throws AFSException
279 maxGroupID = getMaxGroupID( cellHandle );
280 maxUserID = getMaxUserID( cellHandle );
285 * Obtains the most current list of <code>User</code> objects of this cell.
286 * Finds all users that currently have a kas and/or pts entry for this cell.
288 * @exception AFSException If an error occurs in the native code
290 protected void refreshUsers() throws AFSException
293 users = new ArrayList();
296 int iterationId = getKasUsersBegin( cellHandle );
298 currUser = new User( this );
299 boolean authorized = false;
304 users.add( currUser );
305 currUser = new User( this );
307 r = getKasUsersNext( cellHandle, iterationId, currUser );
309 } catch (AFSException e) {
310 System.err.println("ERROR Cell::refreshUsers():kas (User: "
311 + currUser.getName() + ") -> " + e.getMessage());
313 //if (org.openafs.jafs.ErrorCodes.isPermissionDenied(e.getErrorCode()))
317 getKasUsersDone( iterationId );
319 //take the union with the pts entries
320 iterationId = getPtsUsersBegin( cellHandle );
326 if( !users.contains( currUser ) ) {
327 users.add( currUser );
329 currUser = new User( this );
331 r = getPtsOnlyUsersNext( cellHandle, iterationId, currUser );
333 } catch (AFSException e) {
334 System.err.println("ERROR Cell::refreshUsers():pts (User: "
335 + currUser.getName() + ") -> " + e.getMessage());
337 //if (org.openafs.jafs.ErrorCodes.isPermissionDenied(e.getErrorCode()))
341 getPtsUsersDone( iterationId );
346 * Obtains the most current list of user names of this cell. Finds
347 * all users that currently have a kas and/or pts entry for this cell.
349 * @exception AFSException If an error occurs in the native code
351 protected void refreshUserNames() throws AFSException
354 userNames = new ArrayList();
357 int iterationId = getKasUsersBegin( cellHandle );
358 while( ( currName = getKasUsersNextString( iterationId )) != null ) {
359 userNames.add( currName );
361 getKasUsersDone( iterationId );
363 //take the union with the pts entries
364 iterationId = Cell.getPtsUsersBegin( cellHandle );
365 while( ( currName = getPtsOnlyUsersNextString( iterationId, cellHandle ) )
367 if( !userNames.contains( currName ) ) {
368 userNames.add( currName );
371 getPtsUsersDone( iterationId );
376 * Obtains the most current list of <code>Group</code> objects of this cell.
378 * @exception AFSException If an error occurs in the native code
380 protected void refreshGroups() throws AFSException
384 int iterationId = getGroupsBegin( cellHandle );
386 groups = new ArrayList();
388 currGroup = new Group( this );
389 boolean authorized = false;
394 groups.add( currGroup );
395 currGroup = new Group( this );
397 r = getGroupsNext( cellHandle, iterationId, currGroup );
399 } catch (AFSException e) {
400 System.err.println("ERROR Cell::refreshGroups() (Group: "
401 + currGroup.getName() + ") -> " + e.getMessage());
403 //if (org.openafs.jafs.ErrorCodes.isPermissionDenied(e.getErrorCode()))
407 Cell.getGroupsDone( iterationId );
411 * Obtains the most current list of group names of this cell.
413 * @exception AFSException If an error occurs in the native code
415 protected void refreshGroupNames() throws AFSException
419 int iterationId = getGroupsBegin( cellHandle );
421 groupNames = new ArrayList();
422 while( ( currName = getGroupsNextString( iterationId ) ) != null ) {
423 groupNames.add( currName );
425 getGroupsDone( iterationId );
429 * Obtains the most current list of <code>Server</code> objects of this cell.
431 * @exception AFSException If an error occurs in the native code
433 protected void refreshServers() throws AFSException
437 int iterationId = getServersBegin( cellHandle );
439 servers = new ArrayList();
441 currServer = new Server( this );
442 boolean authorized = false;
447 System.out.println("[Java] Cell::refreshServers() -> adding server: "
448 + currServer.getName());
449 servers.add( currServer );
450 currServer = new Server( this );
452 r = getServersNext( cellHandle, iterationId, currServer );
453 System.out.println("[Java] Cell::refreshServers() -> r: " + r);
455 } catch (AFSException e) {
456 System.err.println("ERROR Cell::refreshServers() (Server: "
457 + currServer.getName() + ") -> " + e.getMessage());
459 //if (e.getErrorCode() == org.openafs.jafs.ErrorCodes.PERMISSION_DENIED)
463 getServersDone( iterationId );
467 * Obtains the most current list of server names of this cell.
469 * @exception AFSException If an error occurs in the native code
471 protected void refreshServerNames()
476 int iterationId = getServersBegin( cellHandle );
478 serverNames = new ArrayList();
479 while( ( currName = getServersNextString( iterationId ) ) != null ) {
480 serverNames.add( currName );
482 getServersDone( iterationId );
486 * Unauthenticates this </code>Token</code> object associated with this
487 * <code>Cell</code> and deletes all of its stored information. This
488 * method should only be called when this <code>Cell</code> or any of the
489 * objects constructed using this <code>Cell</code> will not be used
490 * anymore. Note that this does not delete the actual AFS cell that this
491 * <code>Cell</code> object represents; it merely closes the
494 * @exception AFSException If an error occurs in the native code
496 public void close() throws AFSException
498 Cell.closeCell( cellHandle );
507 tokenExpiration = null;
510 //////////////// ACCESSORS ////////////////////////
513 * Retrieves the <CODE>User</CODE> object (which is an abstract
514 * representation of an actual AFS user) designated by <code>name</code>.
515 * If a user by that name does not actually exist in AFS in the cell
516 * represented by this object, an {@link AFSException} will be
519 * @exception AFSException If an error occurs in the native code
520 * @exception NullPointerException If <CODE>name</CODE> is
522 * @param name the name of the user to retrieve
523 * @return <CODE>User</CODE> designated by <code>name</code>.
525 public User getUser(String name) throws AFSException
527 if (name == null) throw new NullPointerException();
528 User user = new User(name, this);
533 * Returns the total number of users who are registered with KAS and PTS,
534 * without duplicates. If a user has a KAS entry and not a PTS entry,
535 * it will still be counted. Conversely, if a user has a PTS entry and
536 * not KAS, it too will be counted. Effectively it is a non-duplicate
537 * union of KAS and PTS user entries.
539 * <P>If the total list of users or user names have already been
540 * collected (see {@link #getUsers()}), then the returning value will be
541 * calculated based upon the current list. Otherwise, KAS and PTS will be
542 * explicitly queried for the information.
544 * @exception AFSException If an error occurs in the native code
545 * @return a <code>User</code> array of the users of the cell.
547 * @see #getUserNames()
549 public int getUserCount() throws AFSException
551 if( users != null ) {
553 } else if( userNames != null ) {
554 return userNames.size();
556 int k = getKasUserCount(cellHandle);
557 int p = getPtsOnlyUserCount(cellHandle);
563 * Retrieves an array containing all of the <code>User</code> objects
564 * associated with this <code>Cell</code>, each of which are an abstract
565 * representation of an actual user of the AFS cell. After this method
566 * is called once, it saves the array of <code>User</code>s and returns
567 * that saved array on subsequent calls, until the {@link #refresh()} method
568 * is called and a more current list is obtained.
570 * @exception AFSException If an error occurs in the native code
571 * @return a <code>User</code> array of the users of the cell.
573 public User[] getUsers() throws AFSException
575 if( users == null ) refreshUsers();
576 return (User[]) users.toArray( new User[users.size()] );
580 * Returns an array containing a subset of the <code>User</code> objects
581 * associated with this <code>Cell</code>, each of which is an abstract
582 * representation of an actual AFS user of the AFS cell. The subset
583 * is a point-in-time list of users (<code>User</code> objects
584 * representing AFS users) starting at the complete array's index of
585 * <code>startIndex</code> and containing up to <code>length</code>
588 * If <code>length</code> is larger than the number of remaining elements,
589 * respective to <code>startIndex</code>, then this method will
590 * ignore the remaining positions requested by <code>length</code> and
591 * return an array that contains the remaining number of elements found in
592 * this cell's complete array of users.
594 * <P>This method is especially useful when managing iterations of very
595 * large lists. {@link #getUserCount()} can be used to determine if
596 * iteration management is practical.
598 * <P>This method does not save the resulting data and therefore
599 * queries AFS for each call.
601 * <P><B>Note:</B> PTS-only users are collected before KAS users
602 * and therefore will always, if PTS-only users exist, be within the
603 * lowest range of this cell's complete list of users. PTS and KAS
604 * users are joined in a non-duplicating union and are consequently
605 * treated as a single list of users, thus <code>startIndex</code>
606 * does not necessarily indicate the first KAS user.
608 * <P><B>Example:</B> If there are more than 50,000 users within this cell
609 * then only render them in increments of 10,000.
613 * if (cell.getUserCount() > 50000) {
615 * int length = 10000;
616 * while (index < cell.getUserCount()) {
617 * users = cell.<B>getUsers</B>(index, length);
618 * for (int i = 0; i < users.length; i++) {
625 * users = cell.getUsers();
626 * for (int i = 0; i < users.length; i++) {
633 * @param startIndex the base zero index position at which the subset array
634 * should start from, relative to the complete list of
635 * elements present in AFS.
636 * @param length the number of elements that the subset should contain
637 * @return a subset array of users in this cell
638 * @exception AFSException If an error occurs in the native code
639 * @see #getUserCount()
640 * @see #getUserNames(int, int)
643 public User[] getUsers(int startIndex, int length) throws AFSException
645 User[] users = new User[length];
646 User currUser = new User( this );
647 int ptsOnlyCount = getPtsOnlyUserCount(cellHandle);
652 if (startIndex < ptsOnlyCount) {
654 iterationID = getPtsUsersBegin(cellHandle);
655 while( getPtsOnlyUsersNext( cellHandle, iterationID, currUser ) != 0 &&
658 if (i >= startIndex) {
659 users[indexPTS] = currUser;
660 currUser = new User( this );
664 getPtsUsersDone( iterationID );
666 if (indexPTS < length) {
673 startIndex -= (ptsOnlyCount - 1);
676 iterationID = getKasUsersBeginAt( cellHandle, startIndex );
677 while( getKasUsersNext(cellHandle, iterationID, currUser ) != 0 &&
680 users[indexKAS] = currUser;
681 currUser = new User( this );
684 getKasUsersDone( iterationID );
686 if (indexKAS < length) {
687 User[] u = new User[indexKAS + indexPTS];
688 System.arraycopy(users, 0, u, 0, u.length);
696 * Retrieves an array containing all of the names of users
697 * associated with this <code>Cell</code>. After this method
698 * is called once, it saves the array of <code>String</code>s and returns
699 * that saved array on subsequent calls, until the {@link #refresh()} method
700 * is called and a more current list is obtained.
702 * <P>This method is especially useful when managing iterations of
703 * large lists. {@link #getUserCount()} can be used to determine if
704 * iteration management is practical. In comparison to {@link #getUsers()},
705 * this method has yielded an average performance advantage of approximately
706 * 82% at 10K users; this statistic, however, strictly compares the response
707 * time of each method and understands that the {@link #getUsers()} method
708 * will return an array of populated <code>User</code> objects, whereas this
709 * method will return an array of <code>String</code> names.
712 * @return an <code>String</code> array of the user names of the cell.
713 * @exception AFSException If an error occurs in the native code
715 public String[] getUserNames() throws AFSException
717 if( userNames == null ) refreshUserNames();
718 return (String[]) userNames.toArray( new String[userNames.size()] );
722 * Returns an array containing a subset of the names of users
723 * associated with this <code>Cell</code>. The subset
724 * is a point-in-time list of users (<code>String</code> names
725 * of AFS users) starting at the complete array's index of
726 * <code>startIndex</code> and containing up to <code>length</code>
729 * If <code>length</code> is larger than the number of remaining elements,
730 * respective to <code>startIndex</code>, then this method will
731 * ignore the remaining positions requested by <code>length</code> and
732 * return an array that contains the remaining number of elements found in
733 * this cell's complete array of users.
735 * <P>This method is especially useful when managing iterations of very
736 * large lists. {@link #getUserCount()} can be used to determine if
737 * iteration management is practical.
739 * <P>This method does not save the resulting data and therefore
740 * queries AFS for each call.
742 * <P><B>Note:</B> PTS-only users are collected before KAS users
743 * and therefore will always, if PTS-only users exist, be within the
744 * lowest range of this cell's complete list of users. PTS and KAS
745 * users are joined in a non-duplicating union and are consequently
746 * treated as a single list of users, thus <code>startIndex</code>
747 * does not necessarily indicate the first KAS user.
749 * <P><B>Example:</B> If there are more than 50,000 users within this cell
750 * then only render them in increments of 10,000.
754 * if (cell.getUserCount() > 50000) {
756 * int length = 10000;
757 * while (index < cell.getUserCount()) {
758 * users = cell.<B>getUserNames</B>(index, length);
759 * for (int i = 0; i < users.length; i++) {
766 * users = cell.getUserNames();
767 * for (int i = 0; i < users.length; i++) {
774 * @param startIndex the base zero index position at which the subset array
775 * should start from, relative to the complete list of
776 * elements present in AFS.
777 * @param length the number of elements that the subset should contain
778 * @return a subset array of user names in this cell
779 * @exception AFSException If an error occurs in the native code
780 * @see #getUserCount()
781 * @see #getUserNames()
782 * @see #getUsers(int, int)
784 public String[] getUserNames(int startIndex, int length)
787 String[] users = new String[length];
789 int ptsOnlyCount = getPtsOnlyUserCount(cellHandle);
794 if (startIndex < ptsOnlyCount) {
796 iterationID = getPtsUsersBegin(cellHandle);
797 while( (currUser = getPtsOnlyUsersNextString( iterationID, cellHandle ))
798 != null && indexPTS < length ) {
799 if (i >= startIndex) {
800 users[indexPTS] = currUser;
804 getPtsUsersDone( iterationID );
806 if (indexPTS < length) {
813 startIndex -= (ptsOnlyCount - 1);
816 iterationID = getKasUsersBeginAt( cellHandle, startIndex );
817 while( (currUser = getKasUsersNextString( iterationID )) != null &&
818 indexKAS < length ) {
819 users[indexKAS] = currUser;
822 getKasUsersDone( iterationID );
824 if (indexKAS < length) {
825 String[] u = new String[indexKAS + indexPTS];
826 System.arraycopy(users, 0, u, 0, u.length);
834 * Retrieves the <CODE>Group</CODE> object (which is an abstract
835 * representation of an actual AFS group) designated by <code>name</code>.
836 * If a group by that name does not actually exist in AFS in the cell
837 * represented by this object, an {@link AFSException} will be
840 * @exception AFSException If an error occurs in the native code
841 * @exception NullPointerException If <CODE>name</CODE> is
843 * @param name the name of the group to retrieve
844 * @return <CODE>Group</CODE> designated by <code>name</code>.
846 public Group getGroup(String name) throws AFSException
848 if (name == null) throw new NullPointerException();
849 Group group = new Group(name, this);
855 * Returns the total number of groups associated with this Cell.
857 * <P>If the total list of groups or group names have already been
858 * collected (see {@link #getGroups()}), then the returning value will be
859 * calculated based upon the current list. Otherwise, PTS will be
860 * explicitly queried for the information.
862 * @exception AFSException If an error occurs in the native code
863 * @return a <code>User</code> array of the users of the cell.
865 * @see #getGroupNames()
867 public int getGroupCount() throws AFSException
869 if( groups != null ) {
870 return groups.size();
871 } else if( groupNames != null ) {
872 return groupNames.size();
874 return getGroupCount(cellHandle);
879 * Retrieves an array containing all of the <code>Group</code> objects
880 * associated with this <code>Cell</code>, each of which are an abstract
881 * representation of an actual group of the AFS cell. After this method
882 * is called once, it saves the array of <code>Group</code>s and returns
883 * that saved array on subsequent calls, until the {@link #refresh()} method
884 * is called and a more current list is obtained.
886 * @exception AFSException If an error occurs in the native code
887 * @return a <code>Group</code> array of the groups of the cell.
889 public Group[] getGroups() throws AFSException
891 if( groups == null ) refreshGroups();
892 return (Group[]) groups.toArray( new Group[groups.size()] );
896 * Returns an array containing a subset of the <code>Group</code> objects
897 * associated with this <code>Cell</code>, each of which is an abstract
898 * representation of an actual AFS group of the AFS cell. The subset
899 * is a point-in-time list of groups (<code>Group</code> objects
900 * representing AFS groups) starting at the complete array's index of
901 * <code>startIndex</code> and containing up to <code>length</code>
904 * If <code>length</code> is larger than the number of remaining elements,
905 * respective to <code>startIndex</code>, then this method will
906 * ignore the remaining positions requested by <code>length</code> and
907 * return an array that contains the remaining number of elements found in
908 * this cell's complete array of groups.
910 * <P>This method is especially useful when managing iterations of very
911 * large lists. {@link #getGroupCount()} can be used to determine if
912 * iteration management is practical.
914 * <P>This method does not save the resulting data and therefore
915 * queries AFS for each call.
917 * <P><B>Example:</B> If there are more than 50,000 groups within this cell
918 * then only render them in increments of 10,000.
922 * if (cell.getGroupCount() > 50000) {
924 * int length = 10000;
925 * while (index < cell.getGroupCount()) {
926 * groups = cell.<B>getGroups</B>(index, length);
927 * for (int i = 0; i < groups.length; i++) {
934 * groups = cell.getGroups();
935 * for (int i = 0; i < groups.length; i++) {
942 * @param startIndex the base zero index position at which the subset array
943 * should start from, relative to the complete list of
944 * elements present in AFS.
945 * @param length the number of elements that the subset should contain
946 * @return a subset array of groups in this cell
947 * @exception AFSException If an error occurs in the native code
948 * @see #getGroupCount()
949 * @see #getGroupNames(int, int)
952 public Group[] getGroups(int startIndex, int length) throws AFSException
954 Group[] groups = new Group[length];
955 Group currGroup = new Group( this );
958 int iterationID = getGroupsBeginAt( cellHandle, startIndex );
960 while( getGroupsNext( cellHandle, iterationID, currGroup ) != 0
962 groups[i] = currGroup;
963 currGroup = new Group( this );
966 getGroupsDone( iterationID );
968 Group[] v = new Group[i];
969 System.arraycopy(groups, 0, v, 0, i);
977 * Retrieves an array containing all of the names of groups
978 * associated with this <code>Cell</code>. After this method
979 * is called once, it saves the array of <code>String</code>s and returns
980 * that saved array on subsequent calls, until the {@link #refresh()} method
981 * is called and a more current list is obtained.
983 * @exception AFSException If an error occurs in the native code
984 * @return a <code>String</code> array of the group names of the cell.
986 public String[] getGroupNames() throws AFSException
988 if( groupNames == null ) refreshGroupNames();
989 return (String[]) groupNames.toArray( new String[groupNames.size()] );
993 * Returns an array containing a subset of the names of groups
994 * associated with this <code>Cell</code>. The subset
995 * is a point-in-time list of groups (<code>String</code> names
996 * of AFS groups) starting at the complete array's index of
997 * <code>startIndex</code> and containing up to <code>length</code>
1000 * If <code>length</code> is larger than the number of remaining elements,
1001 * respective to <code>startIndex</code>, then this method will
1002 * ignore the remaining positions requested by <code>length</code> and
1003 * return an array that contains the remaining number of elements found in
1004 * this cell's complete array of groups.
1006 * <P>This method is especially useful when managing iterations of very
1007 * large lists. {@link #getGroupCount()} can be used to determine if
1008 * iteration management is practical.
1010 * <P>This method does not save the resulting data and therefore
1011 * queries AFS for each call.
1013 * <P><B>Example:</B> If there are more than 50,000 groups within this cell
1014 * then only render them in increments of 10,000.
1018 * if (cell.getGroupCount() > 50000) {
1020 * int length = 10000;
1021 * while (index < cell.getGroupCount()) {
1022 * groups = cell.<B>getGroupNames</B>(index, length);
1023 * for (int i = 0; i < groups.length; i++) {
1030 * groups = cell.getGroupNames();
1031 * for (int i = 0; i < groups.length; i++) {
1038 * @param startIndex the base zero index position at which the subset array
1039 * should start from, relative to the complete list of
1040 * elements present in AFS.
1041 * @param length the number of elements that the subset should contain
1042 * @return a subset array of group names in this cell
1043 * @exception AFSException If an error occurs in the native code
1044 * @see #getGroupCount()
1045 * @see #getGroups(int, int)
1046 * @see #getGroupNames()
1048 public String[] getGroupNames(int startIndex, int length)
1051 String[] groups = new String[length];
1055 int iterationID = getGroupsBeginAt( cellHandle, startIndex );
1057 while( (currGroup = getGroupsNextString( iterationID )) != null &&
1060 groups[i] = currGroup;
1063 getGroupsDone( iterationID );
1065 String[] v = new String[i];
1066 System.arraycopy(groups, 0, v, 0, i);
1074 * Retrieves the <CODE>Server</CODE> object (which is an abstract
1075 * representation of an actual AFS server) designated by <code>name</code>.
1076 * If a group by that name does not actually exist in AFS in the cell
1077 * represented by this object, an {@link AFSException} will be
1080 * @exception AFSException If an error occurs in the native code
1081 * @exception NullPointerException If <CODE>name</CODE> is
1082 * <CODE>null</CODE>.
1083 * @param name the name of the server to retrieve
1084 * @return <CODE>Server</CODE> designated by <code>name</code>.
1086 public Server getServer(String name)
1089 if (name == null) throw new NullPointerException();
1090 Server server = new Server(name, this);
1091 server.refresh(true);
1096 * Returns the total number of servers associated with this Cell.
1098 * <P>If the total list of servers or server names have already been
1099 * collected (see {@link #getServers()}), then the returning value will be
1100 * calculated based upon the current list. Otherwise, AFS will be
1101 * explicitly queried for the information.
1103 * @exception AFSException If an error occurs in the native code
1104 * @return a <code>User</code> array of the users of the cell.
1105 * @see #getServers()
1106 * @see #getServerNames()
1108 public int getServerCount() throws AFSException
1110 if( servers != null ) {
1111 return servers.size();
1112 } else if( serverNames != null ) {
1113 return serverNames.size();
1115 return getServerCount(cellHandle);
1120 * Retrieves an array containing all of the <code>Server</code> objects
1121 * associated with this <code>Cell</code>, each of which are an abstract
1122 * representation of an actual server of the AFS cell. After this method
1123 * is called once, it saves the array of <code>Server</code>s and returns
1124 * that saved array on subsequent calls, until the {@link #refresh()} method
1125 * is called and a more current list is obtained.
1127 * @exception AFSException If an error occurs in the native code
1128 * @return an <code>Server</code> array of the servers of the cell.
1130 public Server[] getServers() throws AFSException
1132 if ( servers == null ) refreshServers();
1133 return (Server[]) servers.toArray( new Server[servers.size()] );
1137 * Retrieves an array containing all of the names of servers
1138 * associated with this <code>Cell</code>. After this method
1139 * is called once, it saves the array of <code>String</code>s and returns
1140 * that saved array on subsequent calls, until the {@link #refresh()} method
1141 * is called and a more current list is obtained.
1143 * @exception AFSException If an error occurs in the native code
1144 * @return a <code>String</code> array of the servers of the cell.
1146 public String[] getServerNames() throws AFSException
1148 if ( serverNames == null ) refreshServerNames();
1149 return (String[]) serverNames.toArray( new String[serverNames.size()] );
1153 * Returns the maximum group ID that's been used within the cell.
1154 * The next auto-assigned group ID will be one less (more negative)
1155 * than this amount. After this method is called once, it saves the
1156 * max group id and returns that id on subsequent calls, until the
1157 * {@link #refresh()} method is called and a more current id is obtained.
1159 * @return an integer representing the maximum group ID
1160 * @exception AFSException If an error occurs in the native code
1162 public int getMaxGroupID() throws AFSException
1164 if( !cachedInfo ) refreshInfo();
1170 * Returns the maximum user ID that's been used within the cell.
1171 * The next auto-assigned user ID will be one greater (more positive)
1172 * than this amount. After this method is called once, it saves the
1173 * max user id and returns that id on subsequent calls, until the
1174 * {@link #refresh()} method is called and a more current id is obtained.
1176 * @return an integer representing the maximum user ID
1177 * @exception AFSException If an error occurs in the native code
1179 public int getMaxUserID() throws AFSException
1181 if( !cachedInfo ) refreshInfo();
1186 * Returns the expiration time of the authentication token being used
1187 * by this <code>Cell</code> object. After this time, this
1188 * <code>Cell</code> object will no longer be authorized to perform
1189 * actions requiring administrative authority.
1191 * @return expiration time of the token
1192 * @exception AFSException If an error occurs in the native code
1194 public GregorianCalendar getTokenExpiration() throws AFSException
1196 if( tokenExpiration == null ) refreshTokenExpiration();
1197 return tokenExpiration;
1201 * Returns the cell handle of this cell.
1203 * @return the cell handle
1204 * @exception AFSException If an error occurs in the native code
1206 public int getCellHandle() throws AFSException
1212 * Returns the name of this cell.
1214 * @return the cell name
1216 public String getName()
1222 * Sets the maximum group ID that's been used within the cell. The next
1223 * auto-assigned group ID will be one less (more negative) than this amount.
1225 * @param maxID an integer representing the maximum group ID
1226 * @exception AFSException If an error occurs in the native code
1228 public void setMaxGroupID( int maxID ) throws AFSException
1230 setMaxGroupID( cellHandle, maxID );
1235 * Sets the maximum user ID that's been used within the cell. The next
1236 * auto-assigned user ID will be one greater (more positive) than this
1239 * @param maxID an integer representing the maximum user ID
1240 * @exception AFSException If an error occurs in the native code
1242 public void setMaxUserID( int maxID ) throws AFSException
1244 setMaxUserID( cellHandle, maxID );
1248 /////////////// information methods ////////////////////
1251 * Returns a <code>String</code> representation of this <code>Cell</code>.
1252 * Contains the cell name followed by the names of its users and groups.
1254 * @return a <code>String</code> representation of this <code>Cell</code>
1256 protected String getInfo()
1258 String r = "Cell: " + name + "\n\n";
1260 r += "\tMax group ID: " + getMaxGroupID() + "\n";
1261 r += "\tMax user ID: " + getMaxUserID() + "\n";
1262 r += "\tToken expiration: " + getTokenExpiration().getTime() + "\n";
1263 } catch( AFSException e ) {
1264 return e.toString();
1271 usrs = getUserNames();
1272 grps = getGroupNames();
1273 servs = getServerNames();
1275 } catch( Exception e ) {
1276 return e.toString();
1281 for( int i = 0; i < usrs.length; i++ ) {
1283 r += usrs[i] + "\n";
1286 r += "\n--Groups--\n";
1288 for( int i = 0; i < grps.length; i++ ) {
1290 r += grps[i] + "\n";
1293 r += "\n--Servers--\n";
1295 for( int i = 0; i < servs.length; i++ ) {
1297 r += servs[i] + "\n";
1304 * Returns a <code>String</code> containing the <code>String</code>
1305 * representations of all the users of this <code>Cell</code>.
1307 * @return a <code>String</code> representation of the users
1310 protected String getInfoUsers() throws AFSException
1314 r = "Cell: " + name + "\n\n";
1317 User usrs[] = getUsers();
1318 for( int i = 0; i < usrs.length; i++ ) {
1319 r += usrs[i].getInfo() + "\n";
1326 * Returns a <code>String</code> containing the <code>String</code>
1327 * representations of all the groups of this <code>Cell</code>.
1329 * @return a <code>String</code> representation of the groups
1330 * @see Group#getInfo
1332 protected String getInfoGroups() throws AFSException
1336 r = "Cell: " + name + "\n\n";
1337 r += "--Groups--\n";
1339 Group grps[] = getGroups();
1340 for( int i = 0; i < grps.length; i++ ) {
1341 r += grps[i].getInfo() + "\n";
1347 * Returns a <code>String</code> containing the <code>String</code>
1348 * representations of all the servers of this <code>Cell</code>.
1350 * @return a <code>String</code> representation of the servers
1351 * @see Server#getInfo
1353 protected String getInfoServers()
1357 r = "Cell: " + name + "\n\n";
1358 r += "--Servers--\n";
1359 Server[] servs = getServers();
1360 for( int i = 0; i < servs.length; i++ ) {
1361 r += servs[i].getInfo() + "\n";
1366 /////////////// override methods ////////////////////
1369 * Tests whether two <code>Cell</code> objects are equal, based on their
1370 * names. Does not test whether the objects are actually the same
1371 * representational instance of the AFS cell.
1373 * @param otherCell the <code>Cell</code> to test
1374 * @return whether the specifed user is the same as this user
1376 public boolean equals( Cell otherCell )
1378 return name.equals( otherCell.getName() );
1382 * Returns the name of this <CODE>Cell</CODE>
1384 * @return the name of this <CODE>Cell</CODE>
1386 public String toString()
1391 /////////////// native methods Cell ////////////////////
1394 * Returns the total number of KAS users belonging to the cell denoted
1395 * by <CODE>cellHandle</CODE>.
1397 * @param cellHandle the handle of the cell to which the users belong
1398 * @return total count of KAS users
1399 * @exception AFSException If an error occurs in the native code
1400 * @see Cell#getCellHandle
1402 protected static native int getKasUserCount( int cellHandle )
1403 throws AFSException;
1406 * Begin the process of getting the kas users that belong to the cell.
1407 * Returns an iteration ID to be used by subsequent calls to
1408 * <code>getKasUsersNextString</code> (or <code>getKasUsersNext</code>)
1409 * and <code>getKasUsersDone</code>.
1411 * @param cellHandle the handle of the cell to which the users belong
1412 * @see Cell#getCellHandle
1413 * @return an iteration ID
1414 * @exception AFSException If an error occurs in the native code
1416 protected static native int getKasUsersBegin( int cellHandle )
1417 throws AFSException;
1420 * Begin the process of getting the KAS users, starting at
1421 * <code>startIndex</code>, that belong to the cell.
1422 * Returns an iteration ID to be used by subsequent calls to
1423 * <code>getKasUsersNextString</code> (or <code>getKasUsersNext</code>)
1424 * and <code>getKasUsersDone</code>.
1426 * @param cellHandle the handle of the cell to which the users belong
1427 * @param startIndex the starting base-zero index
1428 * @return an iteration ID
1429 * @exception AFSException If an error occurs in the native code
1430 * @see Cell#getCellHandle
1432 protected static native int getKasUsersBeginAt( int cellHandle,
1434 throws AFSException;
1437 * Returns the next kas user of the cell. Returns <code>null</code> if there
1438 * are no more users. Appends instance names to principal names as follows:
1439 * <i>principal</i>.<i>instance</i>
1441 * @param iterationId the iteration ID of this iteration
1442 * @see Cell#getKasUsersBegin
1443 * @return the name of the next user of the cell
1444 * @exception AFSException If an error occurs in the native code
1446 protected static native String getKasUsersNextString( int iterationId )
1447 throws AFSException;
1450 * Fills the next kas user object of the cell. Returns 0 if there
1451 * are no more users, != 0 otherwise.
1453 * @param cellHandle the handle of the cell to which the users belong
1454 * @see Cell#getCellHandle
1455 * @param iterationId the iteration ID of this iteration
1456 * @see Cell#getKasUsersBegin
1457 * @param theUser a User object to be populated with the values of
1459 * @return 0 if there are no more users, != 0 otherwise
1460 * @exception AFSException If an error occurs in the native code
1462 protected static native int getKasUsersNext( int cellHandle,
1465 throws AFSException;
1468 * Signals that the iteration is complete and will not be accessed anymore.
1470 * @param iterationId the iteration ID of this iteration
1471 * @see Cell#getKasUsersBegin
1472 * @exception AFSException If an error occurs in the native code
1474 protected static native void getKasUsersDone( int iterationId )
1475 throws AFSException;
1478 * Returns the total number of PTS users belonging to the cell denoted
1479 * by <CODE>cellHandle</CODE>.
1481 * @param cellHandle the handle of the cell to which the users belong
1482 * @return total number of PTS users
1483 * @exception AFSException If an error occurs in the native code
1484 * @see Cell#getCellHandle
1486 protected static native int getPtsUserCount( int cellHandle )
1487 throws AFSException;
1490 * Returns the total number of PTS users, belonging to the cell denoted
1491 * by <CODE>cellHandle</CODE>, that are not in KAS.
1493 * @param cellHandle the handle of the cell to which the users belong
1494 * @return total number of users that are in PTS and not KAS
1495 * @exception AFSException If an error occurs in the native code
1496 * @see Cell#getCellHandle
1498 protected static native int getPtsOnlyUserCount( int cellHandle )
1499 throws AFSException;
1502 * Begin the process of getting the pts users that belong to the cell.
1503 * Returns an iteration ID to be used by subsequent calls to
1504 * <code>getPtsUsersNextString</code> (or <code>getPtsUsersNext</code>)
1505 * and <code>getPtsUsersDone</code>.
1507 * @param cellHandle the handle of the cell to which the users belong
1508 * @see Cell#getCellHandle
1509 * @return an iteration ID
1510 * @exception AFSException If an error occurs in the native code
1512 protected static native int getPtsUsersBegin( int cellHandle )
1513 throws AFSException;
1516 * Returns the next pts user of the cell. Returns <code>null</code> if
1517 * there are no more users.
1519 * @param iterationId the iteration ID of this iteration
1520 * @see Cell#getPtsUsersBegin
1521 * @return the name of the next user of the cell
1522 * @exception AFSException If an error occurs in the native code
1524 protected static native String getPtsUsersNextString( int iterationId )
1525 throws AFSException;
1528 * Returns the next pts user (who is not a kas user) of the cell.
1529 * Returns <code>null</code> if there are no more users.
1531 * @param iterationId the iteration ID of this iteration
1532 * @param cellHandle the cell handle to which these users will belong
1533 * @see Cell#getPtsUsersBegin
1534 * @return the name of the next pts user (not kas user) of the cell
1535 * @exception AFSException If an error occurs in the native code
1537 protected static native String getPtsOnlyUsersNextString( int iterationId,
1539 throws AFSException;
1542 * Fills the next pts user object of the cell. Returns 0 if there
1543 * are no more users, != 0 otherwise.
1545 * @param cellHandle the handle of the cell to which the users belong
1546 * @see Cell#getCellHandle
1547 * @param iterationId the iteration ID of this iteration
1548 * @see Cell#getPtsUsersBegin
1549 * @param theUser a User object to be populated with the values of
1551 * @return 0 if there are no more users, != 0 otherwise
1552 * @exception AFSException If an error occurs in the native code
1554 protected static native int getPtsUsersNext( int cellHandle, int iterationId,
1556 throws AFSException;
1559 * Fills the next pts user (who does not have a kas entry) object of
1560 * the cell. Returns 0 if there are no more users, != 0 otherwise.
1562 * @param cellHandle the handle of the cell to which the users belong
1563 * @see Cell#getCellHandle
1564 * @param iterationId the iteration ID of this iteration
1565 * @see Cell#getPtsUsersBegin
1566 * @param theUser a User object to be populated with the values of
1567 * the next pts (with no kas) user
1568 * @return 0 if there are no more users, != 0 otherwise
1569 * @exception AFSException If an error occurs in the native code
1571 protected static native int getPtsOnlyUsersNext( int cellHandle,
1574 throws AFSException;
1577 * Signals that the iteration is complete and will not be accessed anymore.
1579 * @param iterationId the iteration ID of this iteration
1580 * @see Cell#getPtsUsersBegin
1581 * @exception AFSException If an error occurs in the native code
1583 protected static native void getPtsUsersDone( int iterationId )
1584 throws AFSException;
1587 * Returns the total number of groups belonging to the cell denoted
1588 * by <CODE>cellHandle</CODE>.
1590 * @param cellHandle the handle of the cell to which the groups belong
1591 * @return total number of groups
1592 * @exception AFSException If an error occurs in the native code
1593 * @see Cell#getCellHandle
1595 protected static native int getGroupCount( int cellHandle )
1596 throws AFSException;
1599 * Begin the process of getting the groups that belong to the cell. Returns
1600 * an iteration ID to be used by subsequent calls to
1601 * <code>getGroupsNextString</code> (or <code>getGroupsNext</code>) and
1602 * <code>getGroupsDone</code>.
1604 * @param cellHandle the handle of the cell to which the groups belong
1605 * @see Cell#getCellHandle
1606 * @return an iteration ID
1607 * @exception AFSException If an error occurs in the native code
1609 protected static native int getGroupsBegin( int cellHandle )
1610 throws AFSException;
1613 * Begin the process of getting the groups that belong to the cell, starting
1614 * with element index <code>startIndex</code>. Returns an iteration ID to
1615 * be used by subsequent calls to <code>getGroupsNextString</code>
1616 * (or <code>getGroupsNext</code>) and <code>getGroupsDone</code>.
1618 * @param cellHandle the handle of the cell to which the groups belong
1619 * @param startIndex the starting base-zero index
1620 * @return an iteration ID
1621 * @exception AFSException If an error occurs in the native code
1622 * @see Cell#getCellHandle
1624 protected static native int getGroupsBeginAt( int cellHandle,
1626 throws AFSException;
1629 * Returns the next group of the cell. Returns <code>null</code> if there
1630 * are no more groups.
1632 * @param iterationId the iteration ID of this iteration
1633 * @see Cell#getGroupsBegin
1634 * @return the name of the next user of the cell
1635 * @exception AFSException If an error occurs in the native code
1637 protected static native String getGroupsNextString( int iterationId )
1638 throws AFSException;
1641 * Fills the next group object of the cell. Returns 0 if there
1642 * are no more groups, != 0 otherwise.
1644 * @param cellHandle the handle of the cell to which the users belong
1645 * @see Cell#getCellHandle
1646 * @param iterationId the iteration ID of this iteration
1647 * @see Cell#getGroupsBegin
1648 * @param theGroup a Group object to be populated with the values of
1650 * @return 0 if there are no more users, != 0 otherwise
1651 * @exception AFSException If an error occurs in the native code
1653 protected static native int getGroupsNext( int cellHandle, int iterationId,
1655 throws AFSException;
1658 * Signals that the iteration is complete and will not be accessed anymore.
1660 * @param iterationId the iteration ID of this iteration
1661 * @see Cell#getGroupsBegin
1662 * @exception AFSException If an error occurs in the native code
1664 protected static native void getGroupsDone( int iterationId )
1665 throws AFSException;
1668 * Returns the total number of servers belonging to the cell denoted
1669 * by <CODE>cellHandle</CODE>.
1671 * @param cellHandle the handle of the cell to which the servers belong
1672 * @return total number of servers
1673 * @exception AFSException If an error occurs in the native code
1674 * @see Cell#getCellHandle
1676 protected static native int getServerCount( int cellHandle )
1677 throws AFSException;
1680 * Begin the process of getting the servers in the cell. Returns
1681 * an iteration ID to be used by subsequent calls to
1682 * <code>getServersNextString</code> and <code>getServersDone</code>.
1684 * @param cellHandle the handle of the cell to which the servers belong
1685 * @see Cell#getCellHandle
1686 * @return an iteration ID
1687 * @exception AFSException If an error occurs in the native code
1689 protected static native int getServersBegin( int cellHandle )
1690 throws AFSException;
1693 * Returns the next server of the cell. Returns <code>null</code> if there
1694 * are no more servers.
1696 * @param iterationId the iteration ID of this iteration
1697 * @see Cell#getServersBegin
1698 * @return the name of the next server of the cell
1699 * @exception AFSException If an error occurs in the native code
1701 protected static native String getServersNextString( int iterationId )
1702 throws AFSException;
1705 * Fills the next server object of the cell. Returns 0 if there are no
1706 * more servers, != 0 otherwise.
1708 * @param cellHandle the handle of the cell to which the users belong
1709 * @see Cell#getCellHandle
1710 * @param iterationId the iteration ID of this iteration
1711 * @param theServer a Server object to be populated with the values
1712 * of the next server
1713 * @see Cell#getServersBegin
1714 * @return 0 if there are no more servers, != 0 otherwise
1715 * @exception AFSException If an error occurs in the native code
1717 protected static native int getServersNext( int cellHandle, int iterationId,
1719 throws AFSException;
1722 * Signals that the iteration is complete and will not be accessed anymore.
1724 * @param iterationId the iteration ID of this iteration
1725 * @see Cell#getServersBegin
1726 * @exception AFSException If an error occurs in the native code
1728 protected static native void getServersDone( int iterationId )
1729 throws AFSException;
1732 * Returns the name of the cell.
1734 * @param cellHandle the handle of the cell to which the user belongs
1735 * @see Cell#getCellHandle
1736 * @return the name of the cell
1737 * @exception AFSException If an error occurs in the native code
1739 protected static native String getCellName( int cellHandle )
1740 throws AFSException;
1743 * Creates a mount point for a volume within the file system.
1745 * @param cellHandle the handle of the cell to which the user belongs
1746 * @see Cell#getCellHandle
1747 * @param directory the full path of the place in the AFS file system
1748 * at which to mount the volume
1749 * @param volumeName the name of the volume to mount
1750 * @param readWrite whether or not this is to be a readwrite mount point
1751 * @param forceCheck whether or not to check if this volume name exists
1752 * @exception AFSException If an error occurs in the native code
1754 protected static native void createMountPoint( int cellHandle,
1758 boolean forceCheck )
1759 throws AFSException;
1762 * Sets an ACL for a given place in the AFS file system.
1764 * @param directory the full path of the place in the AFS file system
1765 * for which to add an entry
1766 * @param username the name of the user or group for which to add an entry
1767 * @param read whether or not to allow read access to this user
1768 * @param write whether or not to allow write access to this user
1769 * @param lookup whether or not to allow lookup access to this user
1770 * @param delete whether or not to allow deletion access to this user
1771 * @param insert whether or not to allow insertion access to this user
1772 * @param lock whether or not to allow lock access to this user
1773 * @param admin whether or not to allow admin access to this user
1774 * @exception AFSException If an error occurs in the native code
1776 public static native void setACL( String directory, String username,
1777 boolean read, boolean write,
1778 boolean lookup, boolean delete,
1779 boolean insert, boolean lock,
1781 throws AFSException;
1784 * Gets the maximum group pts ID that's been used within a cell.
1785 * The next auto-assigned group ID will be one less (more negative)
1788 * @param cellHandle the handle of the cell to which the group belongs
1789 * @see Cell#getCellHandle
1790 * @return an integer reresenting the max group id in a cell
1791 * @exception AFSException If an error occurs in the native code
1793 protected static native int getMaxGroupID( int cellHandle )
1794 throws AFSException;
1797 * Sets the maximum group pts ID that's been used within a cell. The next
1798 * auto-assigned group ID will be one less (more negative) than this value.
1800 * @param cellHandle the handle of the cell to which the group belongs
1801 * @see Cell#getCellHandle
1802 * @param maxID an integer reresenting the new max group id in a cell
1803 * @exception AFSException If an error occurs in the native code
1805 protected static native void setMaxGroupID( int cellHandle, int maxID )
1806 throws AFSException;
1809 * Gets the maximum user pts ID that's been used within a cell.
1810 * The next auto-assigned user ID will be one greater (more positive)
1813 * @param cellHandle the handle of the cell to which the user belongs
1814 * @see Cell#getCellHandle
1815 * @return an integer reresenting the max user id in a cell
1816 * @exception AFSException If an error occurs in the native code
1818 protected static native int getMaxUserID( int cellHandle )
1819 throws AFSException;
1822 * Sets the maximum user pts ID that's been used within a cell. The next
1823 * auto-assigned user ID will be one greater (more positive) than this value.
1825 * @param cellHandle the handle of the cell to which the user belongs
1826 * @see Cell#getCellHandle
1827 * @param maxID an integer reresenting the new max user id in a cell
1828 * @exception AFSException If an error occurs in the native code
1830 protected static native void setMaxUserID( int cellHandle, int maxID )
1831 throws AFSException;
1834 * Reclaims all memory being saved by the cell portion of the native library.
1835 * This method should be called when no more <code>Cell</code> objects
1836 * are expected to be used.
1838 protected static native void reclaimCellMemory();
1841 /////////////// native methods jafs_Cell ////////////////////
1844 * Opens a cell for administrative use, based on the token provided.
1845 * Returns a cell handle to be used by other methods as a means of
1848 * @param cellName the name of the cell for which to get the handle
1849 * @param tokenHandle a token handle previously returned by a call to
1850 * {@link Token#getHandle}
1851 * @return a handle to the open cell
1852 * @exception AFSException If an error occurs in the native code
1853 * @see Token#getHandle
1855 protected static native int getCellHandle( String cellName, int tokenHandle )
1856 throws AFSException;
1859 * Closes the given currently open cell handle.
1861 * @param cellHandle the cell handle to close
1862 * @exception AFSException If an error occurs in the native code
1864 protected static native void closeCell( int cellHandle )
1865 throws AFSException;