ACL
.
- *
- * @return a ViceIoctl formatted String representation of this
- * ACL
.
- */
- private String getFormattedString()
- {
- StringBuffer out = null;
- ACL.Entry[] nonEmptyPos = this.getNonEmptyEntries(this.getPositiveEntries());
- ACL.Entry[] nonEmptyNeg = this.getNonEmptyEntries(this.getNegativeEntries());
-
- out = new StringBuffer(nonEmptyPos.length + "\n" + nonEmptyNeg.length + "\n");
- this.entriesToString(nonEmptyPos, out);
- this.entriesToString(nonEmptyNeg, out);
-
- return out.toString();
- }
-
- /////////////// custom override methods ////////////////////
-
- /**
- * Compares two ACL objects respective to their paths and does not
- * factor any other attribute. Alphabetic case is significant in
- * comparing names.
- *
- * @param acl The ACL object to be compared to this ACL
- * instance
- *
- * @return Zero if the argument is equal to this ACL's path, a
- * value less than zero if this ACL's path is
- * lexicographically less than the argument, or a value greater
- * than zero if this ACL's path is lexicographically
- * greater than the argument
- */
- public int compareTo(ACL acl)
- {
- return this.getPath().compareTo(acl.getPath());
- }
-
- /**
- * Comparable interface method.
- *
- * @see #compareTo(ACL)
- */
- public int compareTo(Object obj)
- {
- return compareTo((ACL)obj);
- }
-
- /**
- * Tests whether two ACL
objects are equal, based on their
- * paths and permission bits.
- *
- * @param acl the ACL to test
- * @return whether the specifed ACL is the same as this ACL
- */
- public boolean equals( ACL acl )
- {
- return ( (this.getPath().equals(acl.getPath())) &&
- (positiveEntries.equals(acl.getPositiveEntries())) &&
- (negativeEntries.equals(acl.getNegativeEntries())) );
- }
-
- /**
- * Returns a String representation of this ACL
- *
- * @return a String representation of this ACL
- */
- public String toString()
- {
- ACL.Entry[] nonEmptyPos = this.getNonEmptyEntries(this.getPositiveEntries());
- ACL.Entry[] nonEmptyNeg = this.getNonEmptyEntries(this.getNegativeEntries());
-
- StringBuffer out = new StringBuffer("ACL for ");
- out.append(path);
- out.append("\n");
- out.append("Positive Entries:\n");
- for (int i = 0; i < nonEmptyPos.length; i++) {
- out.append(" ");
- out.append(nonEmptyPos[i].toString());
- }
- if (nonEmptyNeg.length > 0) {
- out.append("Negative Entries:\n");
- for (int i = 0; i < nonEmptyNeg.length; i++) {
- out.append(" ");
- out.append(nonEmptyNeg[i].toString());
- }
- }
-
- return out.toString();
- }
-
- /////////////// native methods ////////////////////
-
- /**
- * Returns a formatted String representing the ACL for the specified path.
- *
- * The string format is in the form of a ViceIoctl and is as follows:
- * printf("%d\n%d\n", positiveEntriesCount, negativeEntriesCount);
- * printf("%s\t%d\n", userOrGroupName, rightsMask);
- *
- * @param path the directory path
- * @returns a formatted String representing the ACL for the specified path.
- * @throws an AFSException if an AFS or JNI exception is encountered.
- */
- private native String getACLString(String path) throws AFSException;
-
- /**
- * Sets the ACL in the file system according to this abstract representation.
- *
- * @param path the directory path
- * @param aclString string representation of ACL to be set
- * @throws an AFSException if an AFS or JNI exception is encountered.
- */
- private native void setACLString(String path, String aclString) throws AFSException;
-
- /*====================================================================*/
- /* INNER CLASSES */
- /*====================================================================*/
-
- /**
- * AFS ACL Entry Class.
- *
- * Documentation reference:
- * Managing Access Control Lists
- *
- * @version 2.0, 04/18/2001 - Completely revised class for efficiency.
- * @version 3.0, 05/01/2002 - Converted class to an inner class.
- */
- public static final class Entry implements Serializable
- {
- /** ACL Mask read constant */
- public static final int READ = 1;
- /** ACL Mask write constant */
- public static final int WRITE = 2;
- /** ACL Mask insert constant */
- public static final int INSERT = 4;
- /** ACL Mask lookup constant */
- public static final int LOOKUP = 8;
- /** ACL Mask delete constant */
- public static final int DELETE = 16;
- /** ACL Mask lock constant */
- public static final int LOCK = 32;
- /** ACL Mask administer constant */
- public static final int ADMIN = 64;
-
- private String username;
-
- private boolean r = false;
- private boolean l = false;
- private boolean i = false;
- private boolean d = false;
- private boolean w = false;
- private boolean k = false;
- private boolean a = false;
-
- /**
- * Constructs a new ACL entry with all permission bits set to false
.
- */
- public Entry()
- {
- }
- /**
- * Constructs a new ACL entry with all permission bits set to false
- * and sets the associated user or group name.
- *
- * @param user The user or group name associated with this entry
- */
- public Entry(String user)
- {
- this.setUser(user);
- }
- /**
- * Constructs a new ACL entry setting each permission bit to its appropriate
- * value according to the permissionsMask
specified.
- *
- * @see #canRead
- * @see #canWrite
- * @see #canInsert
- * @see #canLookup
- * @see #canDelete
- * @see #canLock
- * @see #canAdmin
- * @param permissionsMask An integer representation of the permissoin
- * rights of this entry
- */
- public Entry(int permissionsMask)
- {
- this.setPermissions(permissionsMask);
- }
- /**
- * Constructs a new ACL entry setting each permission bit to its appropriate
- * value according to the permissionsMask
specified
- * and sets the associated user or group name.
- *
- * @see #canRead
- * @see #canWrite
- * @see #canInsert
- * @see #canLookup
- * @see #canDelete
- * @see #canLock
- * @see #canAdmin
- * @see #setUser
- * @param permissionsMask An integer representation of the permissoin
- * rights of this entry
- * @param user The username or group associated with this entry
- */
- public Entry(String user, int permissionsMask)
- {
- this.setUser(user);
- this.setPermissions(permissionsMask);
- }
- /*-------------------------------------------------------------------------*/
- /**
- * Set this entry's permission bits according to the value of the
- * permissionsMask
specified.
- *
- * @see #getPermissionsMask
- * @param permissionsMask An integer representation of the permissoin
- * rights of this entry
- */
- public void setPermissions(int permissionsMask)
- {
- if ((permissionsMask & READ) != 0) {
- this.setRead(true);
- }
- if ((permissionsMask & LOOKUP) != 0) {
- this.setLookup(true);
- }
- if ((permissionsMask & INSERT) != 0) {
- this.setInsert(true);
- }
- if ((permissionsMask & DELETE) != 0) {
- this.setDelete(true);
- }
- if ((permissionsMask & WRITE) != 0) {
- this.setWrite(true);
- }
- if ((permissionsMask & LOCK) != 0) {
- this.setLock(true);
- }
- if ((permissionsMask & ADMIN) != 0) {
- this.setAdmin(true);
- }
- }
- /**
- * Returns this entry's permission mask.
- *
- *
Permission Mask
- * 01 - READ
- * 02 - WRITE
- * 04 - INSERT
- * 08 - LOOKUP
- * 16 - DELETE
- * 32 - LOCK
- * 64 - ADMIN
- *
- *
Any combination of the above mask values would equate to a valid combination of
- * permission settings. For example, if the permission mask was 11, the ACL permissions
- * would be as follows: read
(1), write
(2), and lookup
(8).
- * [1 + 2 + 8 = 11]
- *
- * @return An integer representation (mask) of the permissoin rights of this entry
- */
- public int getPermissionsMask()
- {
- int permissionsMask = 0;
- if (canRead()) permissionsMask |= READ;
- if (canWrite()) permissionsMask |= WRITE;
- if (canInsert()) permissionsMask |= INSERT;
- if (canLookup()) permissionsMask |= LOOKUP;
- if (canDelete()) permissionsMask |= DELETE;
- if (canLock()) permissionsMask |= LOCK;
- if (canAdmin()) permissionsMask |= ADMIN;
- return permissionsMask;
- }
- /**
- * Returns the user or group name associated with this ACL entry.
- *
- * @return String representation of the user or group name associated with this entry.
- */
- public String getUser()
- {
- return username;
- }
- /**
- * Sets the user or group name associated with this ACL entry.
- *
- * @param user representation of the user or group name associated with this entry.
- */
- public void setUser(String user)
- {
- username = user;
- }
- /**
- * Tests whether the ACL permits read
access.
- *
- *
This permission enables a user to read the contents of files in the directory - * and to obtain complete status information for the files (read/retrieve the file - * attributes). - * - *
File Permission
- * This permission is meaningful with respect to files in
- * a directory, rather than the directory itself or its subdirectories.
- *
- *
Documentation reference:
- * The AFS ACL Permissions
- *
- * @return true
if and only if the ACL permits read
access of
- * files; false
otherwise
- */
- public boolean canRead()
- {
- return r;
- }
- /**
- * Sets the ACL permission to accomodate read
access for files.
- *
- * @see #canRead
- * @param flag boolean flag that denotes the permission bit for read
access.
- */
- public void setRead(boolean flag)
- {
- r = flag;
- }
- /**
- * Tests whether the ACL permits lookup access.
- *
- *
This permission functions as something of a gate keeper for access to the directory - * and its files, because a user must have it in order to exercise any other permissions. - * In particular, a user must have this permission to access anything in the directory's - * subdirectories, even if the ACL on a subdirectory grants extensive permissions. - * - *
This permission enables a user to list the names of the files and subdirectories in - * the directory (this does not permit read access to its respective entries), obtain - * complete status information for the directory element itself, and examine the directory's - * ACL. - * - *
This permission does not enable a user to read the contents of a file in the - * directory. - * - *
Similarly, this permission does not enable a user to lookup the contents of,
- * obtain complete status information for, or examine the ACL of the subdirectory of
- * the directory. Those operations require the lookup
permission on the ACL
- * of the subdirectory itself.
- *
- *
Directory Permission
- * This permission is meaningful with respect to the
- * directory itself. For example, the insert
permission (see: {@link #canInsert})
- * does not control addition of data to a file, but rather creation of a new file or
- * subdirectory.
- *
- *
Documentation reference:
- * The AFS ACL Permissions
- *
- * @return true
if and only if the ACL permits lookup
access for
- * directories; false
otherwise
- */
- public boolean canLookup()
- {
- return l;
- }
- /**
- * Sets the ACL permission to accomodate lookup
access for directories.
- *
- * @see #canLookup
- * @param flag boolean flag that denotes the permission bit for lookup
access.
- */
- public void setLookup(boolean flag)
- {
- l = flag;
- }
- /**
- * Tests whether the ACL permits insert
access.
- *
- *
This permission enables a user to add new files to the directory, either by creating - * or copying, and to create new subdirectories. It does not extend into any subdirectories, - * which are protected by their own ACLs. - * - *
Directory Permission
- * This permission is meaningful with respect to the
- * directory itself. For example, the insert
permission (see: {@link #canInsert})
- * does not control addition of data to a file, but rather creation of a new file or
- * subdirectory.
- *
- *
Documentation reference:
- * The AFS ACL Permissions
- *
- * @return true
if and only if the ACL permits insert
access for
- * directories; false
otherwise
- */
- public boolean canInsert()
- {
- return i;
- }
- /**
- * Sets the ACL permission to accomodate insert
access for directories.
- *
- * @see #canInsert
- * @param flag boolean flag that denotes the permission bit for insert
access.
- */
- public void setInsert(boolean flag)
- {
- i = flag;
- }
- /**
- * Tests whether the ACL permits delete
access.
- *
- *
This permission enables a user to remove files and subdirectories from the directory
- * or move them into other directories (assuming that the user has the insert
- * (see: {@link #canInsert}) permission on the ACL of the other directories).
- *
- *
Directory Permission
- * This permission is meaningful with respect to the
- * directory itself. For example, the insert
permission (see: {@link #canInsert})
- * does not control addition of data to a file, but rather creation of a new file or
- * subdirectory.
- *
- *
Documentation reference:
- * The AFS ACL Permissions
- *
- * @return true
if and only if the ACL permits delete
access for
- * directories; false
otherwise
- */
- public boolean canDelete()
- {
- return d;
- }
- /**
- * Sets the ACL permission to accomodate delete
access for directories.
- *
- * @see #canDelete
- * @param flag boolean flag that denotes the permission bit for delete
rights.
- */
- public void setDelete(boolean flag)
- {
- d = flag;
- }
- /**
- * Tests whether the ACL permits write
access.
- *
- *
This permission enables a user to modify the contents of files in the directory - * and to change their operating system specific mode bits. - * - *
File Permission
- * This permission is meaningful with respect to files in
- * a directory, rather than the directory itself or its subdirectories.
- *
- *
Documentation reference:
- * The AFS ACL Permissions
- *
- * @return true
if and only if the ACL permits write
access for
- * files; false
otherwise
- */
- public boolean canWrite()
- {
- return w;
- }
- /**
- * Sets the ACL permission to accomodate write
access for files.
- *
- * @see #canWrite
- * @param flag boolean flag that denotes the permission bit for write
access.
- */
- public void setWrite(boolean flag)
- {
- w = flag;
- }
- /**
- * Tests whether the ACL permits the lock
authority.
- *
- *
This permission enables the user to run programs that issue system calls to - * lock files in the directory. - * - *
File Permission
- * This permission is meaningful with respect to files in
- * a directory, rather than the directory itself or its subdirectories.
- *
- *
Documentation reference:
- * The AFS ACL Permissions
- *
- * @return true
if and only if the ACL permits lock
authority for
- * files; false
otherwise
- */
- public boolean canLock()
- {
- return k;
- }
- /**
- * Sets the ACL permission to accomodate lock
access for files.
- *
- * @see #canLock
- * @param flag boolean flag that denotes the permission bit for lock
rights.
- */
- public void setLock(boolean flag)
- {
- k = flag;
- }
- /**
- * Tests whether the ACL permits administer
access.
- *
- *
This permission enables a user to change the directory's ACL. Members of the
- * system:administrators
group implicitly have this permission on every
- * directory (that is, even if that group does not appear on the ACL). Similarly, the
- * owner of a directory implicitly has this permission on its ACL and those of all
- * directories below it that he or she owns.
- *
- *
Directory Permission
- * This permission is meaningful with respect to the
- * directory itself. For example, the insert
permission (see: {@link #canInsert})
- * does not control addition of data to a file, but rather creation of a new file or
- * subdirectory.
- *
- *
Documentation reference:
- * The AFS ACL Permissions
- *
- * @return true
if and only if the ACL permits administer
access for
- * directories; false
otherwise
- */
- public boolean canAdmin()
- {
- return a;
- }
- /**
- * Sets the ACL permission to accomodate administer
rights for directories.
- *
- * @see #canAdmin
- * @param flag boolean flag that denotes the permission bit for administer
rights.
- */
- public void setAdmin(boolean flag)
- {
- a = flag;
- }
-
- /////////////// custom override methods ////////////////////
-
- /**
- * Tests whether two ACL.Entry
objects are equal, based on associated
- * username and permission bits.
- *
- * @param entry the ACL.Entry to test
- * @return whether the specifed ACL.Entry is the same as this ACL.Entry
- */
- public boolean equals( ACL.Entry entry )
- {
- return ( (this.getUser().equals( entry.getUser() )) &&
- (this.getPermissionsMask() == entry.getPermissionsMask()) );
- }
-
- /**
- * Returns a String representation of this ACL.Entry
- *
- * @return a String representation of this ACL.Entry
- */
- public String toString()
- {
- StringBuffer out = new StringBuffer(username);
- out.append("\t");
- if (r) out.append("r");
- if (l) out.append("l");
- if (i) out.append("i");
- if (d) out.append("d");
- if (w) out.append("w");
- if (k) out.append("k");
- if (a) out.append("a");
- out.append("\n");
- return out.toString();
- }
-
- }
-}
-
-
-
-
-
-
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/AFSException.java b/src/JAVA/classes/org/openafs/jafs/AFSException.java
deleted file mode 100644
index a250f9abab..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/AFSException.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * @(#)AFSException.java 2.0 01/04/16
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-import java.util.Locale;
-
-/**
- * An exception indicating that an error has occurred in the Java AFS
- * API, in the Java AFS JNI, or in the AFS file system.
- *
- * @version 1.0, 04/16/2001
- * @see java.lang.Exception
- */
-public class AFSException extends Exception
-{
- /**
- * The AFS specific error number (code).
- * @see #getErrorCode()
- */
- protected int errno;
-
- /**
- * Constructs an AFSException
with the specified detail
- * message.
- *
- * @param reason the detail message.
- */
- public AFSException(String reason)
- {
- super(reason);
- }
- /**
- * Constructs an AFSException
with the specified error code.
- * This constructor will also generate the appropriate error message
- * respective to the specified error code.
- *
- * @param errno the AFS error number (error code).
- */
- public AFSException(int errno)
- {
- super(ErrorTable.getMessage( (errno == 0) ? ErrorTable.UNKNOWN : errno ));
- this.errno = (errno == 0) ? ErrorTable.UNKNOWN : errno;
- }
- /**
- * Constructs an AFSException
with the specified detail message
- * and specified error code. In this constructor the specified detail message
- * overrides the default AFS error message defined by the
- * ErrorTable
class. Therefore, to retrieve the AFS specific
- * error message, you must use the {@link #getAFSMessage}
method.
- * The {@link #getMessage}
method will return the message specified
- * in this constructor.
- *
- * @param reason the detail message.
- * @param errno the AFS error number (error code).
- */
- public AFSException(String reason, int errno)
- {
- super(reason);
- this.errno = errno;
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the AFS specific error number (code). This code can be interpreted
- * by use of the {@link ErrorTable}
class method
- * {@link ErrorTable#getMessage(int)}
.
- *
- * @return the AFS error code of this AFSException
- * object.
- * @see ErrorTable#getMessage(int)
- */
- public int getErrorCode()
- {
- return errno;
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the error message string of this exception.
- *
- * @return the error message string of this exception object.
- *
- * @see #getAFSMessage()
- */
- public String getMessage()
- {
- String msg = super.getMessage();
- return (msg == null) ? ErrorTable.getMessage(errno) : msg;
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the locale specific error message string of this exception.
- *
- * @return the error message string of this exception object.
- * @param locale the locale for which this message will be displayed
- *
- * @see #getAFSMessage()
- */
- public String getMessage(Locale locale)
- {
- String msg = super.getMessage();
- return (msg == null) ? ErrorTable.getMessage(errno, locale) : msg;
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the AFS error message string defined by the ErrorTable
- *
class. The message will be formatted according to the default
- * Locale.
- *
- *
This message is also available from this object's super class
- * method getMessage
. However, this method will always return
- * the string message associated with the actual AFS error code/number
- * specified, whereas the {@link #getMessage()} method will return the
- * string message intended for this Exception object, which may be
- * an overridden message defined in the constructor of this Exception.
- *
- * @return the AFS error message string of this exception object.
- *
- * @see #getAFSMessage(Locale)
- * @see AFSException#AFSException(String, int)
- * @see ErrorTable#getMessage(int)
- * @see java.lang.Exception#getMessage()
- */
- public String getAFSMessage()
- {
- return ErrorTable.getMessage(errno);
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the AFS error message defined by the ErrorTable
- * class. The message will be formatted according to the specified Locale.
- *
- *
This message is also available from this object's super class
- * method getMessage
. However, this method will always return
- * the string message associated with the actual AFS error code/number
- * specified, whereas the {@link #getMessage()} method will return the
- * string message intended for this Exception object, which may be
- * an overridden message defined in the constructor of this Exception.
- *
- * @return the AFS error message string of this exception object.
- * @param locale the locale for which this message will be displayed
- *
- * @see #getAFSMessage()
- * @see AFSException#AFSException(String, int)
- * @see ErrorTable#getMessage(int, Locale)
- * @see java.lang.Exception#getMessage()
- */
- public String getAFSMessage(Locale locale)
- {
- return ErrorTable.getMessage(errno, locale);
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns a string representation of this AFS Exception.
- *
- *
The message will be formatted according to the specified Locale. - * - * @return the AFS error message string of this exception object. - * - * @see #getAFSMessage() - * @see ErrorTable#getMessage(int) - * @see java.lang.Exception#getMessage() - */ - public String toString() - { - return "AFSException: Error Code: " + errno + "; Message: " + - getMessage(); - } - /*-----------------------------------------------------------------------*/ -} - - - - - - - - - - - - - - - diff --git a/src/JAVA/classes/org/openafs/jafs/AFSFileException.java b/src/JAVA/classes/org/openafs/jafs/AFSFileException.java deleted file mode 100644 index 3d6c398659..0000000000 --- a/src/JAVA/classes/org/openafs/jafs/AFSFileException.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * @(#)AFSFileException.java 2.0 01/04/16 - * - * Copyright (c) 2001 International Business Machines Corp. - * All rights reserved. - * - * This software has been released under the terms of the IBM Public - * License. For details, see the LICENSE file in the top-level source - * directory or online at http://www.openafs.org/dl/license10.html - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.openafs.jafs; - -import java.util.Locale; - -/** - * An exception indicating that a file related error has occured in the - * Java AFS API, in the Java AFS JNI, or in the AFS file system. - * - *
This exception extends Java's java.io.IOException
- * and is therefore often used as a substitution for
- * {@link java.io.IOException}.
- *
- * @version 2.0, 04/16/2001
- * @version 1.0, 05/25/2000
- * @see AFSException
- * @see java.io.IOException
- */
-public class AFSFileException extends java.io.IOException
-{
- /**
- * The AFS specific error number (code).
- * @see #getErrorCode()
- */
- protected int errno;
-
- /**
- * Constructs an AFSFileException
with the specified detail
- * message.
- *
- * @param reason the detail message.
- */
- public AFSFileException (String reason)
- {
- super(reason);
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the AFS specific error number (code). This code can be interpreted
- * by use of the {@link ErrorTable}
class method
- * {@link ErrorTable#getMessage(int)}
.
- *
- * @return the AFS error code of this AFSException
- * object.
- * @see ErrorTable#getMessage(int)
- */
- public int getErrorCode()
- {
- return errno;
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the error message string of this exception.
- *
- * @return the error message string of this exception object.
- *
- * @see #getAFSMessage()
- */
- public String getMessage()
- {
- String msg = super.getMessage();
- return (msg == null) ? ErrorTable.getMessage(errno) : msg;
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the locale specific error message string of this exception.
- *
- * @return the error message string of this exception object.
- * @param locale the locale for which this message will be displayed
- *
- * @see #getAFSMessage()
- */
- public String getMessage(Locale locale)
- {
- String msg = super.getMessage();
- return (msg == null) ? ErrorTable.getMessage(errno, locale) : msg;
- }
- /**
- * Constructs an AFSFileException
with the specified error
- * code. This constructor will also generate the appropriate error message
- * respective to the specified error code.
- *
- * @param errno the AFS error number (error code).
- */
- public AFSFileException (int errno)
- {
- super(ErrorTable.getMessage( (errno == 0) ? ErrorTable.UNKNOWN : errno ));
- this.errno = (errno == 0) ? ErrorTable.UNKNOWN : errno;
- }
- /**
- * Constructs an AFSFileException
with the specified detail
- * message and specified error code. In this constructor the specified
- * detail message overrides the default AFS error message defined by the
- * ErrorTable
class. Therefore, to retrieve the AFS specific
- * error message, you must use the {@link #getAFSMessage}
- *
method. The {@link #getMessage}
method will return
- * the message specified in this constructor.
- *
- * @param reason the detail message.
- * @param errno the AFS error number (error code).
- * @see #getAFSMessage()
- */
- public AFSFileException (String reason, int errno)
- {
- super( (reason == null) ? ErrorTable.getMessage( errno ) : reason );
- this.errno = errno;
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the AFS error message string defined by the ErrorTable
- *
class. The message will be formatted according to the default
- * Locale.
- *
- *
This message is also available from this object's super class
- * method getMessage
. However, this method will always return
- * the string message associated with the actual AFS error code/number
- * specified, whereas the {@link #getMessage()} method will return the
- * string message intended for this Exception object, which may be
- * an overridden message defined in the constructor of this Exception.
- *
- * @return the AFS error message string of this exception object.
- *
- * @see #getAFSMessage(Locale)
- * @see AFSFileException#AFSFileException(String, int)
- * @see ErrorTable#getMessage(int)
- * @see java.lang.Exception#getMessage()
- */
- public String getAFSMessage()
- {
- return ErrorTable.getMessage(errno);
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the AFS error message defined by the ErrorTable
- * class. The message will be formatted according to the specified Locale.
- *
- *
This message is also available from this object's super class
- * method getMessage
. However, this method will always return
- * the string message associated with the actual AFS error code/number
- * specified, whereas the {@link #getMessage()} method will return the
- * string message intended for this Exception object, which may be
- * an overridden message defined in the constructor of this Exception.
- *
- * @return the AFS error message string of this exception object.
- * @param locale the locale for which this message will be displayed
- *
- * @see #getAFSMessage()
- * @see AFSFileException#AFSFileException(String, int)
- * @see ErrorTable#getMessage(int, Locale)
- * @see java.lang.Exception#getMessage()
- */
- public String getAFSMessage(Locale locale)
- {
- return ErrorTable.getMessage(errno, locale);
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns a string representation of this AFS Exception.
- *
- * @return the AFS error message string of this
- * AFSFileException
object.
- *
- * @see #getMessage()
- */
- public String toString()
- {
- return "AFSFileException: Error Code: " + errno + "; Message: " +
- getMessage();
- }
- /*-----------------------------------------------------------------------*/
-}
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/AFSSecurityException.java b/src/JAVA/classes/org/openafs/jafs/AFSSecurityException.java
deleted file mode 100644
index 2aacb400ac..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/AFSSecurityException.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * @(#)AFSSecurityException.java 2.0 01/04/16
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-import java.util.Locale;
-
-/**
- * An exception indicating that a security related error has occured in the
- * Java AFS API, in the Java AFS JNI, or in the AFS file system.
- *
- * @version 1.0, 04/16/2001
- * @see AFSException
- */
-public class AFSSecurityException extends SecurityException
-{
- /**
- * The AFS specific error number (code).
- * @see #getErrorCode()
- */
- protected int errno;
-
- /**
- * Constructs an AFSSecurityException
with the specified detail
- * message.
- *
- * @param reason the detail message.
- */
- public AFSSecurityException (String reason)
- {
- super(reason);
- }
- /**
- * Constructs an AFSSecurityException
with the specified error
- * code. This constructor will also generate the appropriate error message
- * respective to the specified error code.
- *
- * @param errno the AFS error number (error code).
- */
- public AFSSecurityException (int errno)
- {
- super(ErrorTable.getMessage( (errno == 0) ? ErrorTable.UNKNOWN : errno ));
- this.errno = (errno == 0) ? ErrorTable.UNKNOWN : errno;
- }
- /**
- * Constructs an AFSFileException
with the specified detail
- * message and specified error code. In this constructor the specified
- * detail message overrides the default AFS error message defined by the
- * ErrorTable
class. Therefore, to retrieve the AFS specific
- * error message, you must use the {@link #getAFSMessage}
- *
method. The {@link #getMessage}
method will return
- * the message specified in this constructor.
- *
- * @param reason the detail message.
- * @param errno the AFS error number (error code).
- * @see #getAFSMessage()
- */
- public AFSSecurityException (String reason, int errno)
- {
- super( (reason == null) ? ErrorTable.getMessage( errno ) : reason );
- this.errno = errno;
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the AFS specific error number (code). This code can be interpreted
- * by use of the {@link ErrorTable}
class method
- * {@link ErrorTable#getMessage(int)}
.
- *
- * @return the AFS error code of this AFSException
- * object.
- * @see ErrorTable#getMessage(int)
- */
- public int getErrorCode()
- {
- return errno;
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the error message string of this exception.
- *
- * @return the error message string of this exception object.
- *
- * @see #getAFSMessage()
- */
- public String getMessage()
- {
- String msg = super.getMessage();
- return (msg == null) ? ErrorTable.getMessage(errno) : msg;
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the locale specific error message string of this exception.
- *
- * @return the error message string of this exception object.
- * @param locale the locale for which this message will be displayed
- *
- * @see #getAFSMessage()
- */
- public String getMessage(Locale locale)
- {
- String msg = super.getMessage();
- return (msg == null) ? ErrorTable.getMessage(errno, locale) : msg;
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the AFS error message string defined by the ErrorTable
- *
class. The message will be formatted according to the default
- * Locale.
- *
- *
This message is also available from this object's super class
- * method getMessage
. However, this method will always return
- * the string message associated with the actual AFS error code/number
- * specified, whereas the {@link #getMessage()} method will return the
- * string message intended for this Exception object, which may be
- * an overridden message defined in the constructor of this Exception.
- *
- * @return the AFS error message string of this exception object.
- *
- * @see #getAFSMessage(Locale)
- * @see AFSSecurityException#AFSSecurityException(String, int)
- * @see ErrorTable#getMessage(int)
- * @see java.lang.Exception#getMessage()
- */
- public String getAFSMessage()
- {
- return ErrorTable.getMessage(errno);
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns the AFS error message defined by the ErrorTable
- * class. The message will be formatted according to the specified Locale.
- *
- *
This message is also available from this object's super class
- * method getMessage
. However, this method will always return
- * the string message associated with the actual AFS error code/number
- * specified, whereas the {@link #getMessage()} method will return the
- * string message intended for this Exception object, which may be
- * an overridden message defined in the constructor of this Exception.
- *
- * @return the AFS error message string of this exception object.
- * @param locale the locale for which this message will be displayed
- *
- * @see #getAFSMessage()
- * @see AFSSecurityException#AFSSecurityException(String, int)
- * @see ErrorTable#getMessage(int, Locale)
- * @see java.lang.Exception#getMessage()
- */
- public String getAFSMessage(Locale locale)
- {
- return ErrorTable.getMessage(errno, locale);
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns a string representation of this AFS Exception.
- *
- * @return the AFS error message string of this
- * AFSSecurityException
object.
- *
- * @see #getMessage()
- */
- public String toString()
- {
- return "AFSSecurityException: Error Code: " + errno + "; Message: " +
- getMessage();
- }
- /*-----------------------------------------------------------------------*/
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/Cell.java b/src/JAVA/classes/org/openafs/jafs/Cell.java
deleted file mode 100644
index 9f6c96a356..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/Cell.java
+++ /dev/null
@@ -1,1876 +0,0 @@
-/*
- * @(#)Cell.java 1.0 6/29/2001
- *
- * Copyright (c) 2001-2002 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-import java.util.ArrayList;
-import java.util.GregorianCalendar;
-import java.util.Date;
-
-/**
- * An abstract representation of an AFS cell. It holds information about
- * the cell, such as what users, groups, and servers exist in the cell.
- *
- *
- * Constructing a Cell
object does not mean a new cell is
- * created in the AFS file system -- on the contrary, a Cell
- * object must be a representation of an already existing AFS cell. There
- * is no way to create a new AFS cell through this API. See
- * OpenAFS.org for information on how
- * to create a new cell.
- *
- * The construction of a Cell
object acts as an entry point
- * for authentication into the AFS system. Thus, when you construct a
- * Cell
, you must pass in an authenticated Token
- * of a user in the AFS cell that the Cell
represents. You
- * will be authenticated as the user represented by token
and
- * you will only be allowed to perform actions that the user is
- * authorized to perform. You must construct a Cell
before
- * attempting to construct any other object in this package, since the
- * other objects all require a Cell
object on construction,
- * either directly or indirectly.
- *
- * Note that to successfully construct a Cell
object, the
- * code must be running on a machine with a running AFS client, and the
- * cell this object is to represent must have an entry in the client's
- * CellServDB file.
- *
- * Each Cell
object has its own individual set of
- * Server
s, User
s, and Group
s.
- * This represents the properties and attributes of an actual AFS cell.
- *
- * If an error occurs during a method call, an
- * AFSException
will be thrown. This class is the Java
- * equivalent of errors thrown by AFS; see {@link AFSException}
- * for a complete description.
- *
- *
- * The following is a simple example of how to construct and use a
- * Cell
object. It shows how a Cell
can be used to
- * get an abstract representation of an AFS server, and how it can obtain an
- * array of User
objects, each of which is an abstract
- * representation of an AFS user.
- *
- *
- * import org.openafs.jafs.AFSException; - * import org.openafs.jafs.Cell; - * import org.openafs.jafs.Partition; - * import org.openafs.jafs.Server; - * import org.openafs.jafs.Token; - * import org.openafs.jafs.User; - * ... - * public class ... - * { - * ... - * private Cell cell; - * private Server server; - * private Token token; - * ... - * public static void main(String[] args) throws Exception - * { - * String username = arg[0]; - * String password = arg[1]; - * String cellName = arg[2]; - * String serverName = arg[3]; - * - * token = new Token(username, password, cellName); - * cell = new Cell(token); - * server = cell.getServer(serverName); - * - * User[] users = cell.getUsers(); - * ... - * } - * ... - * } - *- * - */ -public class Cell implements java.io.Serializable -{ - protected ArrayList users; - protected ArrayList userNames; - protected ArrayList groups; - protected ArrayList groupNames; - protected ArrayList servers; - protected ArrayList serverNames; - - protected String name; - protected long cellHandle; - protected Token token; - - protected int maxGroupID; - protected int maxUserID; - - protected GregorianCalendar tokenExpiration; - - protected boolean cachedInfo; - - /** - * Constructs a new
Cell
object instance given
- * the Token
that should represents an authenticated user
- * with administrative access. In order to get full access to the cell,
- * it is best that the Token
provided have administrative
- * privileges.
- *
- * @param token the user's authenticated token
- * @exception AFSException If an error occurs in the native code
- */
- public Cell( Token token )
- throws AFSException
- {
- this.token = token;
- this.name = token.getCellName();
-
- cellHandle = getCellHandle( name, token.getHandle() );
-//System.out.println("cellHandle: " + cellHandle);
- users = null;
- userNames = null;
- groups = null;
- groupNames = null;
- servers = null;
- serverNames = null;
- cachedInfo = false;
- tokenExpiration = null;
- }
-
- /**
- * Constructs a new Cell
object instance given
- * the Token
that should represents an authenticated user
- * with administrative access. In order to get full access to the cell,
- * it is best that the Token
provided have administrative
- * privileges.
- *
- * 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 {@link #refresh()} method to address any - * coherency concerns. - * - * @param token the user's authenticated token - * @param preloadAllMembers true will ensure all object members are - * set upon construction; otherwise members - * will be set upon access, which is the default - * behavior. - * @exception AFSException If an error occurs in the native code - * @see #refresh - */ - public Cell( Token token, boolean preloadAllMembers ) - throws AFSException - { - this(token); - if (preloadAllMembers) refresh(true); - } - - /** - * Refreshes the properties of this Cell object instance with values - * from the AFS cell it represents. All properties that have been - * initialized and/or accessed will be renewed according to the values - * of the AFS cell this Cell 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.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void refresh() throws AFSException
- {
- this.refresh(false);
- }
-
- /**
- * Refreshes the properties of this Cell object instance with values
- * from the AFS cell it represents. If all
is true
- * then all of the properties of this Cell object instance will be
- * set, or renewed, according to the values of the AFS cell 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 {@link #refresh()} for more information.
- *
- * @param all if true set or renew all object properties; otherwise
- * renew all set properties
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- protected void refresh(boolean all) throws AFSException
- {
- if( all || (users != null) ) {
- refreshUsers();
- }
- if( all || (userNames != null) ) {
- refreshUserNames();
- }
- if( all || (groups != null) ) {
- refreshGroups();
- }
- if( all || (groupNames != null) ) {
- refreshGroupNames();
- }
- if( all || (servers != null) ) {
- refreshServers();
- }
- if( all || (serverNames != null) ) {
- refreshServerNames();
- }
- if( all || cachedInfo ) {
- refreshInfo();
- }
- }
-
- /**
- * Obtains the expiration time of the token being used by this
- * Cell
object. Does not actually refresh the token; that is,
- * once a token is obtained, its expiration time will not change. This
- * method is mostly for consistency with the other methods. It is mainly
- * used for getting the token information once; after that, it need not
- * be called again.
- *
- * @exception AFSException If an error occurs in the native code
- */
- private void refreshTokenExpiration() throws AFSException
- {
- long expTime;
-
- expTime = token.getExpiration();
-
- tokenExpiration = new GregorianCalendar();
- long longTime = expTime*1000;
- Date d = new Date( longTime );
- tokenExpiration.setTime( d );
- }
-
- /**
- * Sets all the information fields of this Cell
object,
- * such as max group and user ids, to trheir most current values.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshInfo() throws AFSException
- {
- maxGroupID = getMaxGroupID( cellHandle );
- maxUserID = getMaxUserID( cellHandle );
- cachedInfo = true;
- }
-
- /**
- * Obtains the most current list of User
objects of this cell.
- * Finds all users that currently have a kas and/or pts entry for this cell.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshUsers() throws AFSException
- {
- User currUser;
- users = new ArrayList();
-
- // get kas entries
- long iterationId = getKasUsersBegin( cellHandle );
-
- currUser = new User( this );
- boolean authorized = false;
- int r = 1;
- while( r != 0 ) {
- try {
- if (authorized) {
- users.add( currUser );
- currUser = new User( this );
- }
- r = getKasUsersNext( cellHandle, iterationId, currUser );
- authorized = true;
- } catch (AFSException e) {
- System.err.println("ERROR Cell::refreshUsers():kas (User: "
- + currUser.getName() + ") -> " + e.getMessage());
- authorized = false;
- //if (org.openafs.jafs.ErrorCodes.isPermissionDenied(e.getErrorCode()))
- //r = 0;
- }
- }
- getKasUsersDone( iterationId );
-
- //take the union with the pts entries
- iterationId = getPtsUsersBegin( cellHandle );
- authorized = false;
- r = 1;
- while( r != 0 ) {
- try {
- if (authorized) {
- if( !users.contains( currUser ) ) {
- users.add( currUser );
- }
- currUser = new User( this );
- }
- r = getPtsOnlyUsersNext( cellHandle, iterationId, currUser );
- authorized = true;
- } catch (AFSException e) {
- System.err.println("ERROR Cell::refreshUsers():pts (User: "
- + currUser.getName() + ") -> " + e.getMessage());
- authorized = false;
- //if (org.openafs.jafs.ErrorCodes.isPermissionDenied(e.getErrorCode()))
- // r = 0;
- }
- }
- getPtsUsersDone( iterationId );
-
- }
-
- /**
- * Obtains the most current list of user names of this cell. Finds
- * all users that currently have a kas and/or pts entry for this cell.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshUserNames() throws AFSException
- {
- String currName;
- userNames = new ArrayList();
-
- // get kas entries
- long iterationId = getKasUsersBegin( cellHandle );
- while( ( currName = getKasUsersNextString( iterationId )) != null ) {
- userNames.add( currName );
- }
- getKasUsersDone( iterationId );
-
- //take the union with the pts entries
- iterationId = Cell.getPtsUsersBegin( cellHandle );
- while( ( currName = getPtsOnlyUsersNextString( iterationId, cellHandle ) )
- != null ) {
- if( !userNames.contains( currName ) ) {
- userNames.add( currName );
- }
- }
- getPtsUsersDone( iterationId );
- }
-
-
- /**
- * Obtains the most current list of Group
objects of this cell.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshGroups() throws AFSException
- {
- Group currGroup;
-
- long iterationId = getGroupsBegin( cellHandle );
-
- groups = new ArrayList();
-
- currGroup = new Group( this );
- boolean authorized = false;
- int r = 1;
- while( r != 0 ) {
- try {
- if (authorized) {
- groups.add( currGroup );
- currGroup = new Group( this );
- }
- r = getGroupsNext( cellHandle, iterationId, currGroup );
- authorized = true;
- } catch (AFSException e) {
- e.printStackTrace();
-
-// System.err.println("ERROR Cell::refreshGroups() (Group: "
-// + currGroup.getName() + ") -> " + e.getMessage());
- authorized = false;
- //if (org.openafs.jafs.ErrorCodes.isPermissionDenied(e.getErrorCode()))
- // r = 0;
- }
- }
- Cell.getGroupsDone( iterationId );
- }
-
- /**
- * Obtains the most current list of group names of this cell.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshGroupNames() throws AFSException
- {
- String currName;
-
- long iterationId = getGroupsBegin( cellHandle );
-
- groupNames = new ArrayList();
- while( ( currName = getGroupsNextString( iterationId ) ) != null ) {
- groupNames.add( currName );
- }
- getGroupsDone( iterationId );
- }
-
- /**
- * Obtains the most current list of Server
objects of this cell.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshServers() throws AFSException
- {
- Server currServer;
-
- long iterationId = getServersBegin( cellHandle );
-
- servers = new ArrayList();
-
- currServer = new Server( this );
- boolean authorized = false;
- int r = 1;
- while( r != 0 ) {
- try {
- if (authorized) {
- //System.out.println("[Java] Cell::refreshServers() -> adding server: "
- // + currServer.getName());
- servers.add( currServer );
- currServer = new Server( this );
- }
- r = getServersNext( cellHandle, iterationId, currServer );
-//System.out.println("[Java] Cell::refreshServers() -> r: " + r);
- authorized = true;
- } catch (AFSException e) {
- System.err.println("ERROR Cell::refreshServers() (Server: "
- + currServer.getName() + ") -> " + e.getMessage());
- authorized = false;
- //if (e.getErrorCode() == org.openafs.jafs.ErrorCodes.PERMISSION_DENIED)
- // r = 0;
- }
- }
- getServersDone( iterationId );
- }
-
- /**
- * Obtains the most current list of server names of this cell.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshServerNames()
- throws AFSException
- {
- String currName;
-
- long iterationId = getServersBegin( cellHandle );
-
- serverNames = new ArrayList();
- while( ( currName = getServersNextString( iterationId ) ) != null ) {
- serverNames.add( currName );
- }
- getServersDone( iterationId );
- }
-
- /**
- * Unauthenticates this Token object associated with this
- * Cell
and deletes all of its stored information. This
- * method should only be called when this Cell
or any of the
- * objects constructed using this Cell
will not be used
- * anymore. Note that this does not delete the actual AFS cell that this
- * Cell
object represents; it merely closes the
- * representation.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void close() throws AFSException
- {
- Cell.closeCell( cellHandle );
- token.close();
- users = null;
- userNames = null;
- groups = null;
- groupNames = null;
- servers = null;
- serverNames = null;
- cachedInfo = false;
- tokenExpiration = null;
- }
-
- //////////////// ACCESSORS ////////////////////////
-
- /**
- * Retrieves the User
object (which is an abstract
- * representation of an actual AFS user) designated by name
.
- * If a user by that name does not actually exist in AFS in the cell
- * represented by this object, an {@link AFSException} will be
- * thrown.
- *
- * @exception AFSException If an error occurs in the native code
- * @exception NullPointerException If name
is
- * null
.
- * @param name the name of the user to retrieve
- * @return User
designated by name
.
- */
- public User getUser(String name) throws AFSException
- {
- if (name == null) throw new NullPointerException();
- User user = new User(name, this);
- return user;
- }
-
- /**
- * Returns the total number of users who are registered with KAS and PTS,
- * without duplicates. If a user has a KAS entry and not a PTS entry,
- * it will still be counted. Conversely, if a user has a PTS entry and
- * not KAS, it too will be counted. Effectively it is a non-duplicate
- * union of KAS and PTS user entries.
- *
- *
If the total list of users or user names have already been
- * collected (see {@link #getUsers()}), then the returning value will be
- * calculated based upon the current list. Otherwise, KAS and PTS will be
- * explicitly queried for the information.
- *
- * @exception AFSException If an error occurs in the native code
- * @return a User
array of the users of the cell.
- * @see #getUsers()
- * @see #getUserNames()
- */
- public int getUserCount() throws AFSException
- {
- if( users != null ) {
- return users.size();
- } else if( userNames != null ) {
- return userNames.size();
- } else {
- int k = getKasUserCount(cellHandle);
- int p = getPtsOnlyUserCount(cellHandle);
- return k + p;
- }
- }
-
- /**
- * Retrieves an array containing all of the User
objects
- * associated with this Cell
, each of which are an abstract
- * representation of an actual user of the AFS cell. After this method
- * is called once, it saves the array of User
s and returns
- * that saved array on subsequent calls, until the {@link #refresh()} method
- * is called and a more current list is obtained.
- *
- * @exception AFSException If an error occurs in the native code
- * @return a User
array of the users of the cell.
- */
- public User[] getUsers() throws AFSException
- {
- if( users == null ) refreshUsers();
- return (User[]) users.toArray( new User[users.size()] );
- }
-
- /**
- * Returns an array containing a subset of the User
objects
- * associated with this Cell
, each of which is an abstract
- * representation of an actual AFS user of the AFS cell. The subset
- * is a point-in-time list of users (User
objects
- * representing AFS users) starting at the complete array's index of
- * startIndex
and containing up to length
- * elements.
- *
- * If length
is larger than the number of remaining elements,
- * respective to startIndex
, then this method will
- * ignore the remaining positions requested by length
and
- * return an array that contains the remaining number of elements found in
- * this cell's complete array of users.
- *
- *
This method is especially useful when managing iterations of very - * large lists. {@link #getUserCount()} can be used to determine if - * iteration management is practical. - * - *
This method does not save the resulting data and therefore - * queries AFS for each call. - * - *
Note: PTS-only users are collected before KAS users
- * and therefore will always, if PTS-only users exist, be within the
- * lowest range of this cell's complete list of users. PTS and KAS
- * users are joined in a non-duplicating union and are consequently
- * treated as a single list of users, thus startIndex
- * does not necessarily indicate the first KAS user.
- *
- *
Example: If there are more than 50,000 users within this cell - * then only render them in increments of 10,000. - *
- * ... - * User[] users; - * if (cell.getUserCount() > 50000) { - * int index = 0; - * int length = 10000; - * while (index < cell.getUserCount()) { - * users = cell.getUsers(index, length); - * for (int i = 0; i < users.length; i++) { - * ... - * } - * index += length; - * ... - * } - * } else { - * users = cell.getUsers(); - * for (int i = 0; i < users.length; i++) { - * ... - * } - * } - * ... - *- * - * @param startIndex the base zero index position at which the subset array - * should start from, relative to the complete list of - * elements present in AFS. - * @param length the number of elements that the subset should contain - * @return a subset array of users in this cell - * @exception AFSException If an error occurs in the native code - * @see #getUserCount() - * @see #getUserNames(int, int) - * @see #getUsers() - */ - public User[] getUsers(int startIndex, int length) throws AFSException - { - User[] users = new User[length]; - User currUser = new User( this ); - int ptsOnlyCount = getPtsOnlyUserCount(cellHandle); - long iterationID = 0; - int indexPTS = 0; - int indexKAS = 0; - - if (startIndex < ptsOnlyCount) { - int i = 0; - iterationID = getPtsUsersBegin(cellHandle); - while( getPtsOnlyUsersNext( cellHandle, iterationID, currUser ) != 0 && - indexPTS < length ) - { - if (i >= startIndex) { - users[indexPTS] = currUser; - currUser = new User( this ); - indexPTS++; - } - } - getPtsUsersDone( iterationID ); - - if (indexPTS < length) { - startIndex = 0; - length -= indexPTS; - } else { - return users; - } - } else { - startIndex -= (ptsOnlyCount - 1); - } - - iterationID = getKasUsersBeginAt( cellHandle, startIndex ); - while( getKasUsersNext(cellHandle, iterationID, currUser ) != 0 && - indexKAS < length ) - { - users[indexKAS] = currUser; - currUser = new User( this ); - indexKAS++; - } - getKasUsersDone( iterationID ); - - if (indexKAS < length) { - User[] u = new User[indexKAS + indexPTS]; - System.arraycopy(users, 0, u, 0, u.length); - return u; - } else { - return users; - } - } - - /** - * Retrieves an array containing all of the names of users - * associated with this
Cell
. After this method
- * is called once, it saves the array of String
s and returns
- * that saved array on subsequent calls, until the {@link #refresh()} method
- * is called and a more current list is obtained.
- *
- * This method is especially useful when managing iterations of
- * large lists. {@link #getUserCount()} can be used to determine if
- * iteration management is practical. In comparison to {@link #getUsers()},
- * this method has yielded an average performance advantage of approximately
- * 82% at 10K users; this statistic, however, strictly compares the response
- * time of each method and understands that the {@link #getUsers()} method
- * will return an array of populated User
objects, whereas this
- * method will return an array of String
names.
- *
- *
- * @return an String
array of the user names of the cell.
- * @exception AFSException If an error occurs in the native code
- */
- public String[] getUserNames() throws AFSException
- {
- if( userNames == null ) refreshUserNames();
- return (String[]) userNames.toArray( new String[userNames.size()] );
- }
-
- /**
- * Returns an array containing a subset of the names of users
- * associated with this Cell
. The subset
- * is a point-in-time list of users (String
names
- * of AFS users) starting at the complete array's index of
- * startIndex
and containing up to length
- * elements.
- *
- * If length
is larger than the number of remaining elements,
- * respective to startIndex
, then this method will
- * ignore the remaining positions requested by length
and
- * return an array that contains the remaining number of elements found in
- * this cell's complete array of users.
- *
- *
This method is especially useful when managing iterations of very - * large lists. {@link #getUserCount()} can be used to determine if - * iteration management is practical. - * - *
This method does not save the resulting data and therefore - * queries AFS for each call. - * - *
Note: PTS-only users are collected before KAS users
- * and therefore will always, if PTS-only users exist, be within the
- * lowest range of this cell's complete list of users. PTS and KAS
- * users are joined in a non-duplicating union and are consequently
- * treated as a single list of users, thus startIndex
- * does not necessarily indicate the first KAS user.
- *
- *
Example: If there are more than 50,000 users within this cell - * then only render them in increments of 10,000. - *
- * ... - * String[] users; - * if (cell.getUserCount() > 50000) { - * int index = 0; - * int length = 10000; - * while (index < cell.getUserCount()) { - * users = cell.getUserNames(index, length); - * for (int i = 0; i < users.length; i++) { - * ... - * } - * index += length; - * ... - * } - * } else { - * users = cell.getUserNames(); - * for (int i = 0; i < users.length; i++) { - * ... - * } - * } - * ... - *- * - * @param startIndex the base zero index position at which the subset array - * should start from, relative to the complete list of - * elements present in AFS. - * @param length the number of elements that the subset should contain - * @return a subset array of user names in this cell - * @exception AFSException If an error occurs in the native code - * @see #getUserCount() - * @see #getUserNames() - * @see #getUsers(int, int) - */ - public String[] getUserNames(int startIndex, int length) - throws AFSException - { - String[] users = new String[length]; - String currUser; - int ptsOnlyCount = getPtsOnlyUserCount(cellHandle); - long iterationID = 0; - int indexPTS = 0; - int indexKAS = 0; - - if (startIndex < ptsOnlyCount) { - int i = 0; - iterationID = getPtsUsersBegin(cellHandle); - while( (currUser = getPtsOnlyUsersNextString( iterationID, cellHandle )) - != null && indexPTS < length ) { - if (i >= startIndex) { - users[indexPTS] = currUser; - indexPTS++; - } - } - getPtsUsersDone( iterationID ); - - if (indexPTS < length) { - startIndex = 0; - length -= indexPTS; - } else { - return users; - } - } else { - startIndex -= (ptsOnlyCount - 1); - } - - iterationID = getKasUsersBeginAt( cellHandle, startIndex ); - while( (currUser = getKasUsersNextString( iterationID )) != null && - indexKAS < length ) { - users[indexKAS] = currUser; - indexKAS++; - } - getKasUsersDone( iterationID ); - - if (indexKAS < length) { - String[] u = new String[indexKAS + indexPTS]; - System.arraycopy(users, 0, u, 0, u.length); - return u; - } else { - return users; - } - } - - /** - * Retrieves the
Group
object (which is an abstract
- * representation of an actual AFS group) designated by name
.
- * If a group by that name does not actually exist in AFS in the cell
- * represented by this object, an {@link AFSException} will be
- * thrown.
- *
- * @exception AFSException If an error occurs in the native code
- * @exception NullPointerException If name
is
- * null
.
- * @param name the name of the group to retrieve
- * @return Group
designated by name
.
- */
- public Group getGroup(String name) throws AFSException
- {
- if (name == null) throw new NullPointerException();
- Group group = new Group(name, this);
- group.refresh(true);
- return group;
- }
-
- /**
- * Returns the total number of groups associated with this Cell.
- *
- * If the total list of groups or group names have already been
- * collected (see {@link #getGroups()}), then the returning value will be
- * calculated based upon the current list. Otherwise, PTS will be
- * explicitly queried for the information.
- *
- * @exception AFSException If an error occurs in the native code
- * @return a User
array of the users of the cell.
- * @see #getGroups()
- * @see #getGroupNames()
- */
- public int getGroupCount() throws AFSException
- {
- if( groups != null ) {
- return groups.size();
- } else if( groupNames != null ) {
- return groupNames.size();
- } else {
- return getGroupCount(cellHandle);
- }
- }
-
- /**
- * Retrieves an array containing all of the Group
objects
- * associated with this Cell
, each of which are an abstract
- * representation of an actual group of the AFS cell. After this method
- * is called once, it saves the array of Group
s and returns
- * that saved array on subsequent calls, until the {@link #refresh()} method
- * is called and a more current list is obtained.
- *
- * @exception AFSException If an error occurs in the native code
- * @return a Group
array of the groups of the cell.
- */
- public Group[] getGroups() throws AFSException
- {
- if( groups == null ) refreshGroups();
- return (Group[]) groups.toArray( new Group[groups.size()] );
- }
-
- /**
- * Returns an array containing a subset of the Group
objects
- * associated with this Cell
, each of which is an abstract
- * representation of an actual AFS group of the AFS cell. The subset
- * is a point-in-time list of groups (Group
objects
- * representing AFS groups) starting at the complete array's index of
- * startIndex
and containing up to length
- * elements.
- *
- * If length
is larger than the number of remaining elements,
- * respective to startIndex
, then this method will
- * ignore the remaining positions requested by length
and
- * return an array that contains the remaining number of elements found in
- * this cell's complete array of groups.
- *
- *
This method is especially useful when managing iterations of very - * large lists. {@link #getGroupCount()} can be used to determine if - * iteration management is practical. - * - *
This method does not save the resulting data and therefore - * queries AFS for each call. - * - *
Example: If there are more than 50,000 groups within this cell - * then only render them in increments of 10,000. - *
- * ... - * Group[] groups; - * if (cell.getGroupCount() > 50000) { - * int index = 0; - * int length = 10000; - * while (index < cell.getGroupCount()) { - * groups = cell.getGroups(index, length); - * for (int i = 0; i < groups.length; i++) { - * ... - * } - * index += length; - * ... - * } - * } else { - * groups = cell.getGroups(); - * for (int i = 0; i < groups.length; i++) { - * ... - * } - * } - * ... - *- * - * @param startIndex the base zero index position at which the subset array - * should start from, relative to the complete list of - * elements present in AFS. - * @param length the number of elements that the subset should contain - * @return a subset array of groups in this cell - * @exception AFSException If an error occurs in the native code - * @see #getGroupCount() - * @see #getGroupNames(int, int) - * @see #getGroups() - */ - public Group[] getGroups(int startIndex, int length) throws AFSException - { - Group[] groups = new Group[length]; - Group currGroup = new Group( this ); - int i = 0; - - long iterationID = getGroupsBeginAt( cellHandle, startIndex ); - - while( getGroupsNext( cellHandle, iterationID, currGroup ) != 0 - && i < length ) { - groups[i] = currGroup; - currGroup = new Group( this ); - i++; - } - getGroupsDone( iterationID ); - if (i < length) { - Group[] v = new Group[i]; - System.arraycopy(groups, 0, v, 0, i); - return v; - } else { - return groups; - } - } - - /** - * Retrieves an array containing all of the names of groups - * associated with this
Cell
. After this method
- * is called once, it saves the array of String
s and returns
- * that saved array on subsequent calls, until the {@link #refresh()} method
- * is called and a more current list is obtained.
- *
- * @exception AFSException If an error occurs in the native code
- * @return a String
array of the group names of the cell.
- */
- public String[] getGroupNames() throws AFSException
- {
- if( groupNames == null ) refreshGroupNames();
- return (String[]) groupNames.toArray( new String[groupNames.size()] );
- }
-
- /**
- * Returns an array containing a subset of the names of groups
- * associated with this Cell
. The subset
- * is a point-in-time list of groups (String
names
- * of AFS groups) starting at the complete array's index of
- * startIndex
and containing up to length
- * elements.
- *
- * If length
is larger than the number of remaining elements,
- * respective to startIndex
, then this method will
- * ignore the remaining positions requested by length
and
- * return an array that contains the remaining number of elements found in
- * this cell's complete array of groups.
- *
- * This method is especially useful when managing iterations of very - * large lists. {@link #getGroupCount()} can be used to determine if - * iteration management is practical. - * - *
This method does not save the resulting data and therefore - * queries AFS for each call. - * - *
Example: If there are more than 50,000 groups within this cell - * then only render them in increments of 10,000. - *
- * ... - * String[] groups; - * if (cell.getGroupCount() > 50000) { - * int index = 0; - * int length = 10000; - * while (index < cell.getGroupCount()) { - * groups = cell.getGroupNames(index, length); - * for (int i = 0; i < groups.length; i++) { - * ... - * } - * index += length; - * ... - * } - * } else { - * groups = cell.getGroupNames(); - * for (int i = 0; i < groups.length; i++) { - * ... - * } - * } - * ... - *- * - * @param startIndex the base zero index position at which the subset array - * should start from, relative to the complete list of - * elements present in AFS. - * @param length the number of elements that the subset should contain - * @return a subset array of group names in this cell - * @exception AFSException If an error occurs in the native code - * @see #getGroupCount() - * @see #getGroups(int, int) - * @see #getGroupNames() - */ - public String[] getGroupNames(int startIndex, int length) - throws AFSException - { - String[] groups = new String[length]; - String currGroup; - int i = 0; - - long iterationID = getGroupsBeginAt( cellHandle, startIndex ); - - while( (currGroup = getGroupsNextString( iterationID )) != null && - i < length ) - { - groups[i] = currGroup; - i++; - } - getGroupsDone( iterationID ); - if (i < length) { - String[] v = new String[i]; - System.arraycopy(groups, 0, v, 0, i); - return v; - } else { - return groups; - } - } - - /** - * Retrieves the
Server
object (which is an abstract
- * representation of an actual AFS server) designated by name
.
- * If a group by that name does not actually exist in AFS in the cell
- * represented by this object, an {@link AFSException} will be
- * thrown.
- *
- * @exception AFSException If an error occurs in the native code
- * @exception NullPointerException If name
is
- * null
.
- * @param name the name of the server to retrieve
- * @return Server
designated by name
.
- */
- public Server getServer(String name)
- throws AFSException
- {
- if (name == null) throw new NullPointerException();
- Server server = new Server(name, this);
- server.refresh(true);
- return server;
- }
-
- /**
- * Returns the total number of servers associated with this Cell.
- *
- * If the total list of servers or server names have already been
- * collected (see {@link #getServers()}), then the returning value will be
- * calculated based upon the current list. Otherwise, AFS will be
- * explicitly queried for the information.
- *
- * @exception AFSException If an error occurs in the native code
- * @return a User
array of the users of the cell.
- * @see #getServers()
- * @see #getServerNames()
- */
- public int getServerCount() throws AFSException
- {
- if( servers != null ) {
- return servers.size();
- } else if( serverNames != null ) {
- return serverNames.size();
- } else {
- return getServerCount(cellHandle);
- }
- }
-
- /**
- * Retrieves an array containing all of the Server
objects
- * associated with this Cell
, each of which are an abstract
- * representation of an actual server of the AFS cell. After this method
- * is called once, it saves the array of Server
s and returns
- * that saved array on subsequent calls, until the {@link #refresh()} method
- * is called and a more current list is obtained.
- *
- * @exception AFSException If an error occurs in the native code
- * @return an Server
array of the servers of the cell.
- */
- public Server[] getServers() throws AFSException
- {
- if ( servers == null ) refreshServers();
- return (Server[]) servers.toArray( new Server[servers.size()] );
- }
-
- /**
- * Retrieves an array containing all of the names of servers
- * associated with this Cell
. After this method
- * is called once, it saves the array of String
s and returns
- * that saved array on subsequent calls, until the {@link #refresh()} method
- * is called and a more current list is obtained.
- *
- * @exception AFSException If an error occurs in the native code
- * @return a String
array of the servers of the cell.
- */
- public String[] getServerNames() throws AFSException
- {
- if ( serverNames == null ) refreshServerNames();
- return (String[]) serverNames.toArray( new String[serverNames.size()] );
- }
-
- /**
- * Returns the maximum group ID that's been used within the cell.
- * The next auto-assigned group ID will be one less (more negative)
- * than this amount. After this method is called once, it saves the
- * max group id and returns that id on subsequent calls, until the
- * {@link #refresh()} method is called and a more current id is obtained.
- *
- * @return an integer representing the maximum group ID
- * @exception AFSException If an error occurs in the native code
- */
- public int getMaxGroupID() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return maxGroupID;
-
- }
-
- /**
- * Returns the maximum user ID that's been used within the cell.
- * The next auto-assigned user ID will be one greater (more positive)
- * than this amount. After this method is called once, it saves the
- * max user id and returns that id on subsequent calls, until the
- * {@link #refresh()} method is called and a more current id is obtained.
- *
- * @return an integer representing the maximum user ID
- * @exception AFSException If an error occurs in the native code
- */
- public int getMaxUserID() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return maxUserID;
- }
-
- /**
- * Returns the expiration time of the authentication token being used
- * by this Cell
object. After this time, this
- * Cell
object will no longer be authorized to perform
- * actions requiring administrative authority.
- *
- * @return expiration time of the token
- * @exception AFSException If an error occurs in the native code
- */
- public GregorianCalendar getTokenExpiration() throws AFSException
- {
- if( tokenExpiration == null ) refreshTokenExpiration();
- return tokenExpiration;
- }
-
- /**
- * Returns the cell handle of this cell.
- *
- * @return the cell handle
- * @exception AFSException If an error occurs in the native code
- */
- public long getCellHandle() throws AFSException
- {
- return cellHandle;
- }
-
- /**
- * Returns the name of this cell.
- *
- * @return the cell name
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Sets the maximum group ID that's been used within the cell. The next
- * auto-assigned group ID will be one less (more negative) than this amount.
- *
- * @param maxID an integer representing the maximum group ID
- * @exception AFSException If an error occurs in the native code
- */
- public void setMaxGroupID( int maxID ) throws AFSException
- {
- setMaxGroupID( cellHandle, maxID );
- maxGroupID = maxID;
- }
-
- /**
- * Sets the maximum user ID that's been used within the cell. The next
- * auto-assigned user ID will be one greater (more positive) than this
- * amount.
- *
- * @param maxID an integer representing the maximum user ID
- * @exception AFSException If an error occurs in the native code
- */
- public void setMaxUserID( int maxID ) throws AFSException
- {
- setMaxUserID( cellHandle, maxID );
- maxUserID = maxID;
- }
-
- /////////////// information methods ////////////////////
-
- /**
- * Returns a String
representation of this Cell
.
- * Contains the cell name followed by the names of its users and groups.
- *
- * @return a String
representation of this Cell
- */
- public String getInfo()
- {
- String r = "Cell: " + name + "\n\n";
- try {
- r += "\tMax group ID: " + getMaxGroupID() + "\n";
- r += "\tMax user ID: " + getMaxUserID() + "\n";
- r += "\tToken expiration: " + getTokenExpiration().getTime() + "\n";
- } catch( AFSException e ) {
- return e.toString();
- }
-
- String[] servs;
- String[] usrs;
- String[] grps;
- try {
- usrs = getUserNames();
- grps = getGroupNames();
- servs = getServerNames();
-
- } catch( Exception e ) {
- return e.toString();
- }
-
- r += "--Users--\n";
-
- for( int i = 0; i < usrs.length; i++ ) {
-
- r += usrs[i] + "\n";
- }
-
- r += "\n--Groups--\n";
-
- for( int i = 0; i < grps.length; i++ ) {
-
- r += grps[i] + "\n";
- }
-
- r += "\n--Servers--\n";
-
- for( int i = 0; i < servs.length; i++ ) {
-
- r += servs[i] + "\n";
- }
-
- return r;
- }
-
- /**
- * Returns a String
containing the String
- * representations of all the users of this Cell
.
- *
- * @return a String
representation of the users
- * @see User#getInfo
- */
- public String getInfoUsers() throws AFSException
- {
- String r;
-
- r = "Cell: " + name + "\n\n";
- r += "--Users--\n";
-
- User usrs[] = getUsers();
- for( int i = 0; i < usrs.length; i++ ) {
- r += usrs[i].getInfo() + "\n";
- }
-
- return r;
- }
-
- /**
- * Returns a String
containing the String
- * representations of all the groups of this Cell
.
- *
- * @return a String
representation of the groups
- * @see Group#getInfo
- */
- public String getInfoGroups() throws AFSException
- {
- String r;
-
- r = "Cell: " + name + "\n\n";
- r += "--Groups--\n";
-
- Group grps[] = getGroups();
- for( int i = 0; i < grps.length; i++ ) {
- r += grps[i].getInfo() + "\n";
- }
- return r;
- }
-
- /**
- * Returns a String
containing the String
- * representations of all the servers of this Cell
.
- *
- * @return a String
representation of the servers
- * @see Server#getInfo
- */
- public String getInfoServers()
- throws AFSException
- {
- String r;
- r = "Cell: " + name + "\n\n";
- r += "--Servers--\n";
- Server[] servs = getServers();
- for( int i = 0; i < servs.length; i++ ) {
- r += servs[i].getInfo() + "\n";
- }
- return r;
- }
-
- /////////////// override methods ////////////////////
-
- /**
- * Tests whether two Cell
objects are equal, based on their
- * names. Does not test whether the objects are actually the same
- * representational instance of the AFS cell.
- *
- * @param otherCell the Cell
to test
- * @return whether the specifed user is the same as this user
- */
- public boolean equals( Cell otherCell )
- {
- return name.equals( otherCell.getName() );
- }
-
- /**
- * Returns the name of this Cell
- *
- * @return the name of this Cell
- */
- public String toString()
- {
- return name;
- }
-
- /////////////// native methods Cell ////////////////////
-
- /**
- * Returns the total number of KAS users belonging to the cell denoted
- * by cellHandle
.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @return total count of KAS users
- * @exception AFSException If an error occurs in the native code
- * @see Cell#getCellHandle
- */
- protected static native int getKasUserCount( long cellHandle )
- throws AFSException;
-
- /**
- * Begin the process of getting the kas users that belong to the cell.
- * Returns an iteration ID to be used by subsequent calls to
- * getKasUsersNextString
(or getKasUsersNext
)
- * and getKasUsersDone
.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @see Cell#getCellHandle
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- */
- protected static native long getKasUsersBegin( long cellHandle )
- throws AFSException;
-
- /**
- * Begin the process of getting the KAS users, starting at
- * startIndex
, that belong to the cell.
- * Returns an iteration ID to be used by subsequent calls to
- * getKasUsersNextString
(or getKasUsersNext
)
- * and getKasUsersDone
.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @param startIndex the starting base-zero index
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- * @see Cell#getCellHandle
- */
- protected static native long getKasUsersBeginAt( long cellHandle,
- int startIndex )
- throws AFSException;
-
- /**
- * Returns the next kas user of the cell. Returns null
if there
- * are no more users. Appends instance names to principal names as follows:
- * principal.instance
- *
- * @param iterationId the iteration ID of this iteration
- * @see Cell#getKasUsersBegin
- * @return the name of the next user of the cell
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getKasUsersNextString( long iterationId )
- throws AFSException;
-
- /**
- * Fills the next kas user object of the cell. Returns 0 if there
- * are no more users, != 0 otherwise.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @see Cell#getCellHandle
- * @param iterationId the iteration ID of this iteration
- * @see Cell#getKasUsersBegin
- * @param theUser a User object to be populated with the values of
- * the next kas user
- * @return 0 if there are no more users, != 0 otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getKasUsersNext( long cellHandle,
- long iterationId,
- User theUser )
- throws AFSException;
-
- /**
- * Signals that the iteration is complete and will not be accessed anymore.
- *
- * @param iterationId the iteration ID of this iteration
- * @see Cell#getKasUsersBegin
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getKasUsersDone( long iterationId )
- throws AFSException;
-
- /**
- * Returns the total number of PTS users belonging to the cell denoted
- * by cellHandle
.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @return total number of PTS users
- * @exception AFSException If an error occurs in the native code
- * @see Cell#getCellHandle
- */
- protected static native int getPtsUserCount( long cellHandle )
- throws AFSException;
-
- /**
- * Returns the total number of PTS users, belonging to the cell denoted
- * by cellHandle
, that are not in KAS.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @return total number of users that are in PTS and not KAS
- * @exception AFSException If an error occurs in the native code
- * @see Cell#getCellHandle
- */
- protected static native int getPtsOnlyUserCount( long cellHandle )
- throws AFSException;
-
- /**
- * Begin the process of getting the pts users that belong to the cell.
- * Returns an iteration ID to be used by subsequent calls to
- * getPtsUsersNextString
(or getPtsUsersNext
)
- * and getPtsUsersDone
.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @see Cell#getCellHandle
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- */
- protected static native long getPtsUsersBegin( long cellHandle )
- throws AFSException;
-
- /**
- * Returns the next pts user of the cell. Returns null
if
- * there are no more users.
- *
- * @param iterationId the iteration ID of this iteration
- * @see Cell#getPtsUsersBegin
- * @return the name of the next user of the cell
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getPtsUsersNextString( long iterationId )
- throws AFSException;
-
- /**
- * Returns the next pts user (who is not a kas user) of the cell.
- * Returns null
if there are no more users.
- *
- * @param iterationId the iteration ID of this iteration
- * @param cellHandle the cell handle to which these users will belong
- * @see Cell#getPtsUsersBegin
- * @return the name of the next pts user (not kas user) of the cell
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getPtsOnlyUsersNextString( long iterationId,
- long cellHandle )
- throws AFSException;
-
- /**
- * Fills the next pts user object of the cell. Returns 0 if there
- * are no more users, != 0 otherwise.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @see Cell#getCellHandle
- * @param iterationId the iteration ID of this iteration
- * @see Cell#getPtsUsersBegin
- * @param theUser a User object to be populated with the values of
- * the next pts user
- * @return 0 if there are no more users, != 0 otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getPtsUsersNext( long cellHandle, long iterationId,
- User theUser )
- throws AFSException;
-
- /**
- * Fills the next pts user (who does not have a kas entry) object of
- * the cell. Returns 0 if there are no more users, != 0 otherwise.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @see Cell#getCellHandle
- * @param iterationId the iteration ID of this iteration
- * @see Cell#getPtsUsersBegin
- * @param theUser a User object to be populated with the values of
- * the next pts (with no kas) user
- * @return 0 if there are no more users, != 0 otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getPtsOnlyUsersNext( long cellHandle,
- long iterationId,
- User theUser )
- throws AFSException;
-
- /**
- * Signals that the iteration is complete and will not be accessed anymore.
- *
- * @param iterationId the iteration ID of this iteration
- * @see Cell#getPtsUsersBegin
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getPtsUsersDone( long iterationId )
- throws AFSException;
-
- /**
- * Returns the total number of groups belonging to the cell denoted
- * by cellHandle
.
- *
- * @param cellHandle the handle of the cell to which the groups belong
- * @return total number of groups
- * @exception AFSException If an error occurs in the native code
- * @see Cell#getCellHandle
- */
- protected static native int getGroupCount( long cellHandle )
- throws AFSException;
-
- /**
- * Begin the process of getting the groups that belong to the cell. Returns
- * an iteration ID to be used by subsequent calls to
- * getGroupsNextString
(or getGroupsNext
) and
- * getGroupsDone
.
- *
- * @param cellHandle the handle of the cell to which the groups belong
- * @see Cell#getCellHandle
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- */
- protected static native long getGroupsBegin( long cellHandle )
- throws AFSException;
-
- /**
- * Begin the process of getting the groups that belong to the cell, starting
- * with element index startIndex
. Returns an iteration ID to
- * be used by subsequent calls to getGroupsNextString
- * (or getGroupsNext
) and getGroupsDone
.
- *
- * @param cellHandle the handle of the cell to which the groups belong
- * @param startIndex the starting base-zero index
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- * @see Cell#getCellHandle
- */
- protected static native long getGroupsBeginAt( long cellHandle,
- int startIndex )
- throws AFSException;
-
- /**
- * Returns the next group of the cell. Returns null
if there
- * are no more groups.
- *
- * @param iterationId the iteration ID of this iteration
- * @see Cell#getGroupsBegin
- * @return the name of the next user of the cell
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getGroupsNextString( long iterationId )
- throws AFSException;
-
- /**
- * Fills the next group object of the cell. Returns 0 if there
- * are no more groups, != 0 otherwise.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @see Cell#getCellHandle
- * @param iterationId the iteration ID of this iteration
- * @see Cell#getGroupsBegin
- * @param theGroup a Group object to be populated with the values of
- * the next group
- * @return 0 if there are no more users, != 0 otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getGroupsNext( long cellHandle, long iterationId,
- Group theGroup )
- throws AFSException;
-
- /**
- * Signals that the iteration is complete and will not be accessed anymore.
- *
- * @param iterationId the iteration ID of this iteration
- * @see Cell#getGroupsBegin
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getGroupsDone( long iterationId )
- throws AFSException;
-
- /**
- * Returns the total number of servers belonging to the cell denoted
- * by cellHandle
.
- *
- * @param cellHandle the handle of the cell to which the servers belong
- * @return total number of servers
- * @exception AFSException If an error occurs in the native code
- * @see Cell#getCellHandle
- */
- protected static native int getServerCount( long cellHandle )
- throws AFSException;
-
- /**
- * Begin the process of getting the servers in the cell. Returns
- * an iteration ID to be used by subsequent calls to
- * getServersNextString
and getServersDone
.
- *
- * @param cellHandle the handle of the cell to which the servers belong
- * @see Cell#getCellHandle
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- */
- protected static native long getServersBegin( long cellHandle )
- throws AFSException;
-
- /**
- * Returns the next server of the cell. Returns null
if there
- * are no more servers.
- *
- * @param iterationId the iteration ID of this iteration
- * @see Cell#getServersBegin
- * @return the name of the next server of the cell
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getServersNextString( long iterationId )
- throws AFSException;
-
- /**
- * Fills the next server object of the cell. Returns 0 if there are no
- * more servers, != 0 otherwise.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @see Cell#getCellHandle
- * @param iterationId the iteration ID of this iteration
- * @param theServer a Server object to be populated with the values
- * of the next server
- * @see Cell#getServersBegin
- * @return 0 if there are no more servers, != 0 otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getServersNext( long cellHandle, long iterationId,
- Server theServer )
- throws AFSException;
-
- /**
- * Signals that the iteration is complete and will not be accessed anymore.
- *
- * @param iterationId the iteration ID of this iteration
- * @see Cell#getServersBegin
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getServersDone( long iterationId )
- throws AFSException;
-
- /**
- * Returns the name of the cell.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @return the name of the cell
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getCellName( long cellHandle )
- throws AFSException;
-
- /**
- * Creates a mount point for a volume within the file system.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @param directory the full path of the place in the AFS file system
- * at which to mount the volume
- * @param volumeName the name of the volume to mount
- * @param readWrite whether or not this is to be a readwrite mount point
- * @param forceCheck whether or not to check if this volume name exists
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void createMountPoint( long cellHandle,
- String directory,
- String volumeName,
- boolean readWrite,
- boolean forceCheck )
- throws AFSException;
-
- /*
- * Sets an ACL for a given place in the AFS file system.
- *
- * @param directory the full path of the place in the AFS file system
- * for which to add an entry
- * @param username the name of the user or group for which to add an entry
- * @param read whether or not to allow read access to this user
- * @param write whether or not to allow write access to this user
- * @param lookup whether or not to allow lookup access to this user
- * @param delete whether or not to allow deletion access to this user
- * @param insert whether or not to allow insertion access to this user
- * @param lock whether or not to allow lock access to this user
- * @param admin whether or not to allow admin access to this user
- * @exception AFSException If an error occurs in the native code
- */
- public static native void setACL( String directory, String username,
- boolean read, boolean write,
- boolean lookup, boolean delete,
- boolean insert, boolean lock,
- boolean admin )
- throws AFSException;
-
- /**
- * Gets the maximum group pts ID that's been used within a cell.
- * The next auto-assigned group ID will be one less (more negative)
- * than this value.
- *
- * @param cellHandle the handle of the cell to which the group belongs
- * @see Cell#getCellHandle
- * @return an integer reresenting the max group id in a cell
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getMaxGroupID( long cellHandle )
- throws AFSException;
-
- /**
- * Sets the maximum group pts ID that's been used within a cell. The next
- * auto-assigned group ID will be one less (more negative) than this value.
- *
- * @param cellHandle the handle of the cell to which the group belongs
- * @see Cell#getCellHandle
- * @param maxID an integer reresenting the new max group id in a cell
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void setMaxGroupID( long cellHandle, int maxID )
- throws AFSException;
-
- /**
- * Gets the maximum user pts ID that's been used within a cell.
- * The next auto-assigned user ID will be one greater (more positive)
- * than this value.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @return an integer reresenting the max user id in a cell
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getMaxUserID( long cellHandle )
- throws AFSException;
-
- /**
- * Sets the maximum user pts ID that's been used within a cell. The next
- * auto-assigned user ID will be one greater (more positive) than this value.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @param maxID an integer reresenting the new max user id in a cell
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void setMaxUserID( long cellHandle, int maxID )
- throws AFSException;
-
- /**
- * Reclaims all memory being saved by the cell portion of the native library.
- * This method should be called when no more Cell
objects
- * are expected to be used.
- */
- protected static native void reclaimCellMemory();
-
-
- /////////////// native methods jafs_Cell ////////////////////
-
- /**
- * Opens a cell for administrative use, based on the token provided.
- * Returns a cell handle to be used by other methods as a means of
- * authentication.
- *
- * @param cellName the name of the cell for which to get the handle
- * @param tokenHandle a token handle previously returned by a call to
- * {@link Token#getHandle}
- * @return a handle to the open cell
- * @exception AFSException If an error occurs in the native code
- * @see Token#getHandle
- */
- protected static native long getCellHandle( String cellName, long tokenHandle )
- throws AFSException;
-
- /**
- * Closes the given currently open cell handle.
- *
- * @param cellHandle the cell handle to close
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void closeCell( long cellHandle )
- throws AFSException;
-}
-
-
-
-
-
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/ErrorTable.java b/src/JAVA/classes/org/openafs/jafs/ErrorTable.java
deleted file mode 100644
index 431f51a982..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/ErrorTable.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * @(#)ErrorTable.java 2.0 11/06/2000
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-import java.util.ResourceBundle;
-import java.util.Locale;
-
-/**
- * Static class for error code message management.
- *
- *
Simply translates all error codes returned by the AFS native library - * to literal string messages according to the defined locale. - * - * @version 2.0, 11/06/2000 - */ -public final class ErrorTable -{ - /* Undefined Error Constants */ - public static final int UNKNOWN = -3; - public static final int SPECIAL_CASE = -2; - public static final int GENERAL_FAILURE = -1; - - /* Java Application Error Constants */ - public static final int NULL = 1000; - public static final int INVALID_SESSION = 1001; - public static final int EXPIRED_SESSION = 1002; - public static final int OPERATION_ABORTED = 1003; - public static final int FORCED_ABORT = 1004; - - /* General UNIX Error Constants */ - public static final int NOT_PERMITTED = 1; - public static final int NOT_FOUND = 2; - public static final int IO_ERROR = 5; - public static final int NO_DEVICE_ADDRESS = 6; - public static final int BAD_FILE = 9; - public static final int TRY_AGAIN = 11; - public static final int OUT_OF_MEMORY = 12; - public static final int PERMISSION_DENIED = 13; - public static final int BAD_ADDRESS = 14; - public static final int DEVICE_BUSY = 16; - public static final int FILE_EXISTS = 17; - public static final int NO_DEVICE = 19; - public static final int NOT_DIRECTORY = 20; - public static final int IS_DIRECTORY = 21; - public static final int INVALID_ARG = 22; - public static final int FILE_OVERFLOW = 23; - public static final int FILE_BUSY = 26; - public static final int NAME_TOO_LONG = 36; - public static final int DIRECTORY_NOT_EMPTY = 39; - public static final int CONNECTION_TIMED_OUT = 110; - public static final int QUOTA_EXCEEDED = 122; - - /* AFS Error Constants */ - public static final int BAD_USERNAME = 180486; - public static final int BAD_PASSWORD = 180490; - public static final int EXPIRED_PASSWORD = 180519; - public static final int SKEWED_CLOCK = 180514; - public static final int ID_LOCKED = 180522; - public static final int CELL_NOT_FOUND = 180501; - public static final int USERNAME_EXISTS = 180481; - public static final int USER_DOES_NOT_EXIST = 180484; - - /* AFS Authentication Error Constants */ - public static final int PRPERM = 267269; - public static final int UNOACCESS = 5407; - public static final int BZACCESS = 39430; - public static final int KANOAUTH = 180488; - public static final int RXKADNOAUTH = 19270405; - - private static java.util.Hashtable bundles; - - static - { - bundles = new java.util.Hashtable(2); - try { - bundles.put(Locale.US, - ResourceBundle.getBundle("ErrorMessages", Locale.US)); - bundles.put(Locale.SIMPLIFIED_CHINESE, - ResourceBundle.getBundle("ErrorMessages", Locale.SIMPLIFIED_CHINESE)); - } catch (Exception e) { - bundles.put(Locale.getDefault(), - ResourceBundle.getBundle("ErrorMessages")); - } - } - - /*-----------------------------------------------------------------------*/ - /** - * Tests to identify if the return code is a "Permission Denied" error. - * - *
This method will qualify errno
against:
- *
ErrorTable.PERMISSION_DENIED
- * ErrorTable.PRPERM
- * ErrorTable.UNOACCESS
- * ErrorTable.BZACCESS
- * ErrorTable.KANOAUTH
- * ErrorTable.RXKADNOAUTH
- *
- * @param errno Error Code/Number
- * @return boolean If errno
is a "Permission Denied"
- * error.
- */
- public static boolean isPermissionDenied(int errno)
- {
- return (errno == PERMISSION_DENIED || errno == PRPERM ||
- errno == UNOACCESS || errno == BZACCESS || errno == KANOAUTH
- || errno == RXKADNOAUTH);
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns a String message representing the error code (number) provided.
- *
- * If the error code provided is out of range of the library of defined
- * error codes, this method will return Error number [###] unknown
- *
. If an exception is thrown, this method will return either:
- * Unknown error
, Special case error
, or
- * Invalid error code: ###
.
- *
- * @param errno Error Code/Number
- * @return String Interpreted error message derived from
- * errno
.
- */
- public static String getMessage(int errno)
- {
- return getMessage(errno, Locale.getDefault());
- }
- /*-----------------------------------------------------------------------*/
- /**
- * Returns a String message, respective to the provided locale, representing
- * the error code (number) provided.
- *
- *
If the error code provided is out of range of the library of defined
- * error codes, this method will return Error number [###] unknown
- *
. If an exception is thrown, this method will return either:
- * Unknown error
, Special case error
, or
- * Invalid error code: ###
.
- *
- * @param errno Error Code/Number
- * @param locale Locale of to be used for translating the message.
- * @return String Interpreted error message derived from
- * errno
.
- */
- public static String getMessage(int errno, Locale locale)
- {
- String msg = "Error number [" + errno + "] unknown.";
- try {
- msg = getBundle(locale).getString("E" + errno);
- } catch (Exception e) {
- try {
- if (errno == 0) {
- msg = "";
- } else if (errno == GENERAL_FAILURE) {
- msg = getBundle(locale).getString("GENERAL_FAILURE");
- } else if (errno == UNKNOWN) {
- msg = getBundle(locale).getString("UNKNOWN");
- } else if (errno == SPECIAL_CASE) {
- msg = getBundle(locale).getString("SPECIAL_CASE");
- } else {
- System.err.println("ERROR in ErrorCode getMessage(): " + e);
- msg = "Invaid error code: " + errno;
- }
- } catch (Exception e2) {
- //INGORE
- }
- } finally {
- return msg;
- }
- }
- /*-----------------------------------------------------------------------*/
- private static ResourceBundle getBundle(Locale locale) throws Exception
- {
- if (locale == null) return getBundle(Locale.getDefault());
- ResourceBundle rb = (ResourceBundle)bundles.get(locale);
- if (rb == null) {
- rb = ResourceBundle.getBundle("ErrorMessages", locale);
- bundles.put(locale, rb);
- }
- return rb;
- }
-}
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/File.java b/src/JAVA/classes/org/openafs/jafs/File.java
deleted file mode 100644
index fe58b2cf4f..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/File.java
+++ /dev/null
@@ -1,942 +0,0 @@
-/*
- * @(#)File.java 1.3 10/12/2000
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-import java.io.IOException;
-import java.util.ArrayList;
-
-/*****************************************************************************/
-/**
- *
- * An abstract representation of AFS file and directory pathnames.
- *
- * This class is an extension of the standard Java File class with file-based
- * manipulation methods overridden by integrated AFS native methods.
- *
- *
Extension methods include: - * - *
{@link #isMountPoint}
- * {@link #isLink}
- * {@link #isValidated}
- * {@link #validate}
- * {@link #refresh}
- * {@link #getErrorCode}
- * {@link #getErrorMessage}
- * For performance optimization, all newly constructed File
- * objects are only validated once. Furthermore, if an abstract pathname
- * denotes a symbolic-link, then the {@link #isLink} attribute is set
- * to true and the {@link #getTarget} field member is populated with
- * this symbolic-link's target resource. (see {@link #getTarget})
- *
- *
If you are interested in validating the target resource, simply
- * call {@link #validate} before calling any of the attribute accessors.
- * This action will stat
the target resource, identifying
- * its associated attributes and populating them in this objects field
- * members.
- *
- *
Following is an example of how to construct a new AFS File Object: - *
- * - * @version 2.0, 04/16/2001 - Completely revised class for efficiency. - * @version 1.3, 10/12/2000 - Introduced error code capture from native methods. - * @version 1.2, 05/30/2000 - */ -public class File extends java.io.File implements Comparable -{ - private String path; - private String type; - private String target; - - /** Each member is mutually exclusive */ - private boolean isMountPoint = false; - private boolean isDirectory = false; - private boolean isFile = false; - private boolean isLink = false; - - private boolean exists; - private long lastModified; - private long length; - - private ACL.Entry acl; - private boolean validated = false; - private long dirHandle; - private int permissionsMask; - private int errno; - - /** - * Creates a new- * try { - * File file = new File("/afs/mycell.com/proj/"); - * if (file.isDirectory()) { - * System.out.println("This is a directory."); - * } else if (file.isLink()) { - * System.out.println("This is a symbolic-link."); - * System.out.println(" Its target is: " + file.getTarget()); - * file.validate(); - * if (file.isFile()) { - * System.out.println(" This object is now a file!"); - * } else if (file.isDirectory()) { - * System.out.println(" This object is now a directory!"); - * } else if (file.isMountPoint()) { - * System.out.println(" This object is now a volume mount point!"); - * } - * } else if (file.isMountPoint()) { - * System.out.println("This is a volume mount point."); - * } else if (file.isFile()) { - * System.out.println("This is file."); - * System.out.println(" its size is: " + file.length()); - * } - * } catch (AFSFileException ae) { - * System.out.println("AFS Exception: " + ae.getMessage()); - * System.out.println("AFS Error Code: " + ae.getErrorCode()); - * } catch (Exception e) { - * System.out.println("Exception: " + e.getMessage()); - * e.printStackTrace(); - * } - *
File
instance by converting the given
- * pathname string into an abstract pathname and validating it against
- * the file system. If the given string is an empty string, then the
- * result is the empty abstract pathname; otherwise the abstract pathname
- * is validated
to represent a qualified file object.
- *
- * @param pathname A pathname string
- * @throws NullPointerException
- * If the pathname
argument is null
- * @throws AFSFileException
- * If the user constructing this AFS file object is denied
- * access to stat the file or simply a stat cannot be performed
- * on the file. The reason code and message will be available
- * from {@link org.openafs.jafs.AFSFileException#getErrorCode} and
- * {@link org.openafs.jafs.AFSFileException#getMessage} respectively.
- * This exception will not be thrown if the file does not
- * exist. Rather, the {@link #exists} attribute will be set to
- * false
.
- * @see #validate()
- */
- public File(String pathname) throws AFSFileException
- {
- super(pathname);
- path = getAbsolutePath();
- validated = setAttributes();
- if (!validated) throw new AFSFileException(errno);
- }
- /**
- * Creates a new File
instance by converting the given
- * pathname string into an abstract pathname. If the given string is
- * an empty string, then the result is the empty abstract pathname.
- *
- *
The abstract pathname will remain abstract unless the
- * validate
parameter is set to true
. This
- * means that the abstract pathname will not be validated
- * and therefore the file object will not represent a qualified, attributed,
- * AFS file resource. Rather, this constructor provides a method by which
- * you can construct a non-validated File
object (one that
- * does not contain the file's complete status information).
- *
- *
This constructor is useful for creating file objects of file/path names
- * that you know exist, however are unauthorized to validate
(or
- * stat
- to obtain complete status information). For example,
- * if you are permitted to lookup
(see: {@link #canLookup}) the
- * contents of a given directory yet not permitted to read
- * (see: {@link #canRead}), then this constructor would enable you to render the
- * contents of the directory without validating each entry.
- *
- *
Please note: this is the only constructor that does not throw an AFSFileException.
- *
- * @param pathname A pathname string
- * @param validate A boolean flag to indicate if this abstract path
- * should be validated.
- * @throws NullPointerException
- * If the pathname
argument is null
- * @see #File(String)
- * @see #validate()
- */
- public File(String pathname, boolean validate)
- {
- super(pathname);
- path = getAbsolutePath();
- if (validate) validated = setAttributes();
- }
- /**
- * Creates a new File
instance from a parent pathname string
- * and a child pathname string and validates it against the file system.
- *
- *
If parent
is null
then the new
- * File
instance is created as if by invoking the
- * single-argument File
constructor on the given
- * filename
string (child pathname).
- *
- *
Otherwise the parent
pathname string is taken to denote
- * a directory, and the filename
string is taken to
- * denote either a directory or a file. The directory or file will then be
- * validated
to represent a qualified file object.
- *
- * @param parent The parent pathname string
- * @param filename This file's pathname string (child of specified parent)
- * @throws NullPointerException
- * If child
is null
- * @throws AFSFileException
- * If the user constructing this AFS file object is denied
- * access to stat the file or simply a stat cannot be performed
- * on the file. The reason code and message will be available
- * from {@link org.openafs.jafs.AFSFileException#getErrorCode} and
- * {@link org.openafs.jafs.AFSFileException#getMessage} respectively.
- *
This exception will not be thrown if the file does not
- * exist. Rather, the {@link #exists} attribute will be set to
- * false
.
- * @see #validate()
- */
- public File(String parent, String filename) throws AFSFileException
- {
- super(parent, filename);
- path = getAbsolutePath();
- validated = setAttributes();
- if (!validated) throw new AFSFileException(errno);
- }
- /**
- * Creates a new File
instance from a parent pathname string
- * and a child pathname string.
- *
- *
If parent
is null
then the new
- * File
instance is created as if by invoking the
- * single-argument File
constructor on the given
- * filename
string (child pathname).
- *
- *
Otherwise the parent
pathname string is taken to denote
- * a directory, and the filename
string is taken to
- * denote either a directory or a file.
- *
- *
The abstract pathname will remain abstract unless the
- * validate
parameter is set to true
. This
- * means that the abstract pathname will not be validated
- * and therefore the file object will not represent a qualified, attributed,
- * AFS file resource. Rather, this constructor provides a method by which
- * you can construct a non-validated File
object (one that
- * does not contain the file's complete status information).
- *
- *
This constructor is useful for creating file objects of file/path names
- * that you know exist, however are unauthorized to validate
(or
- * stat
- to obtain complete status information). For example,
- * if you are permitted to lookup
(see: {@link #canLookup}) the
- * contents of a given directory yet not permitted to read
- * (see: {@link #canRead}), then this constructor would enable you to render the
- * contents of the directory without validating each entry.
- *
- * @param parent The parent pathname string
- * @param filename This file's pathname string (child of specified parent)
- * @param validate A boolean flag to indicate if this abstract path
- * should be validated.
- * @throws NullPointerException
- * If child
is null
- * @throws AFSFileException
- * If the user constructing this AFS file object is denied
- * access to stat the file or simply a stat cannot be performed
- * on the file. The reason code and message will be available
- * from {@link org.openafs.jafs.AFSFileException#getErrorCode} and
- * {@link org.openafs.jafs.AFSFileException#getMessage} respectively.
- *
This exception will not be thrown if the file does not
- * exist. Rather, the {@link #exists} attribute will be set to
- * false
.
- * @see #File(String, String)
- * @see #validate()
- */
- public File(String parent, String filename, boolean validate) throws AFSFileException
- {
- super(parent, filename);
- path = getAbsolutePath();
- if (validate) {
- validated = setAttributes();
- if (!validated) throw new AFSFileException(errno);
- }
- }
- /**
- * Creates a new File
instance from a parent abstract
- * pathname and a child pathname string and validates it against the file system.
- *
- *
If parent
is null
then the new
- * File
instance is created as if by invoking the
- * single-argument File
constructor on the given
- * filename
string (child pathname).
- *
- *
Otherwise the parent
abstract pathname is taken to
- * denote a directory, and the filename
string is taken
- * to denote either a directory or a file. The directory or file will then be
- * validated
to represent a qualified file object.
- *
- * @param parent The parent abstract pathname
- * @param filename This file's pathname string (child of specified parent)
- * @param validate A boolean flag to indicate if this abstract path
- * should be validated.
- * @throws NullPointerException
- * If child
is null
- * @throws AFSFileException
- * If the user constructing this AFS file object is denied
- * access to stat the file or simply a stat cannot be performed
- * on the file. The reason code and message will be available
- * from {@link org.openafs.jafs.AFSFileException#getErrorCode} and
- * {@link org.openafs.jafs.AFSFileException#getMessage} respectively.
- *
This exception will not be thrown if the file does not
- * exist. Rather, the {@link #exists} attribute will be set to
- * false
.
- * @see #validate()
- */
- public File(File parent, String filename) throws AFSFileException
- {
- super(parent, filename);
- path = getAbsolutePath();
- validated = setAttributes();
- if (!validated) throw new AFSFileException(errno);
- }
- /**
- * Creates a new File
instance from a parent abstract
- * pathname and a child pathname string.
- *
- *
If parent
is null
then the new
- * File
instance is created as if by invoking the
- * single-argument File
constructor on the given
- * filename
string (child pathname).
- *
- *
Otherwise the parent
abstract pathname is taken to
- * denote a directory, and the filename
string is taken
- * to denote either a directory or a file.
- *
- *
The abstract pathname will remain abstract unless the
- * validate
parameter is set to true
. This
- * means that the abstract pathname will not be validated
- * and therefore the file object will not represent a qualified, attributed,
- * AFS file resource. Rather, this constructor provides a method by which
- * you can construct a non-validated File
object (one that
- * does not contain the file's complete status information).
- *
- *
This constructor is useful for creating file objects of file/path names
- * that you know exist, however are unauthorized to validate
(or
- * stat
- to obtain complete status information). For example,
- * if you are permitted to lookup
(see: {@link #canLookup}) the
- * contents of a given directory yet not permitted to read
- * (see: {@link #canRead}), then this constructor would enable you to render the
- * contents of the directory without validating each entry.
- *
- * @param parent The parent abstract pathname
- * @param filename This file's pathname string (child of specified parent)
- * @param validate A boolean flag to indicate if this abstract path
- * should be validated.
- * @throws NullPointerException
- * If child
is null
- * @throws AFSFileException
- * If the user constructing this AFS file object is denied
- * access to stat the file or simply a stat cannot be performed
- * on the file. The reason code and message will be available
- * from {@link org.openafs.jafs.AFSFileException#getErrorCode} and
- * {@link org.openafs.jafs.AFSFileException#getMessage} respectively.
- *
This exception will not be thrown if the file does not
- * exist. Rather, the {@link #exists} attribute will be set to
- * false
.
- * @see #validate()
- * @see #File(File, String)
- */
- public File(File parent, String filename, boolean validate) throws AFSFileException
- {
- super(parent, filename);
- path = getAbsolutePath();
- if (validate) {
- validated = setAttributes();
- if (!validated) throw new AFSFileException(errno);
- }
- }
-
- /*****************************************************************************/
-
- /**
- * Validates this abstract pathname as an attributed AFS file object.
- * This method will, if authorized, perform a stat
on the
- * actual AFS file and update its respective field members; defining
- * this file object's attributes.
- *
- * @throws AFSSecurityException
- * If an AFS exception occurs while attempting to stat and set this
- * AFS file object's attributes.
- */
- public void validate() throws AFSSecurityException
- {
- validated = setAttributes();
- if (!validated) throw new AFSSecurityException(errno);
- }
- /**
- * Tests whether the file denoted by this abstract pathname has
- * been validated.
- *
- *
Validation is always attempted upon construction of the file object,
- * therefore if this method returns false, then you are not permitted to
- * validate
this file and consequently all attribute accessors
- * will be invalid.
- *
- *
This method should return true
even if this abstract
- * pathname does not exist. If this is abstract pathname does not exist then
- * the {@link #exists}
method should return false, however this
- * implies that the attribute accessors are valid and accurate; thus implying
- * successful validation.
- *
- *
This method is useful before calling any of the attribute accessors
- * to ensure a valid response.
- *
- * @return true
if and only if the file denoted by this
- * abstract pathname has been validated during or after object construction;
- * false
otherwise
- */
- public boolean isValidated()
- {
- return validated;
- }
- /**
- * Refreshes this AFS file object by updating its attributes.
- * This method currently provides the same functionality as
- * {@link #validate}.
- *
- * @throws AFSSecurityException
- * If an AFS exception occurs while attempting to stat and update this
- * AFS file object's attributes.
- * @see #validate()
- */
- public void refresh() throws AFSSecurityException
- {
- validate();
- }
- /*-------------------------------------------------------------------------*/
- /**
- * Tests whether the file denoted by this abstract pathname is a
- * directory.
- *
- * @return true
if and only if the file denoted by this
- * abstract pathname exists and is a directory;
- * false
otherwise
- */
- public boolean isDirectory()
- {
- return (isDirectory || isMountPoint) ? true : false;
- }
- /**
- * Tests whether the file denoted by this abstract pathname is a normal
- * file. A file is normal if it is not a directory and, in
- * addition, satisfies other system-dependent criteria. Any non-directory
- * file created by a Java application is guaranteed to be a normal file.
- *
- * @return true
if and only if the file denoted by this
- * abstract pathname exists and is a normal file;
- * false
otherwise
- */
- public boolean isFile()
- {
- return isFile;
- }
- /**
- * Tests whether the file denoted by this abstract pathname is an
- * AFS Volume Mount Point.
- *
- * @return true
if and only if the file denoted by this
- * abstract pathname exists and is a mount point;
- * false
otherwise
- */
- public boolean isMountPoint()
- {
- return isMountPoint;
- }
- /**
- * Tests whether the file denoted by this abstract pathname is a
- * symbolic-link.
- *
- * @return true
if and only if the file denoted by this
- * abstract pathname exists and is a symbolic-link;
- * false
otherwise
- */
- public boolean isLink()
- {
- return isLink;
- }
- /*-------------------------------------------------------------------------*/
- /**
- * Tests whether the file denoted by this abstract pathname exists.
- *
- * @return true
if and only if the file denoted by this
- * abstract pathname exists; false
otherwise
- */
- public boolean exists()
- {
- return exists;
- }
- /**
- * Returns the time that the file denoted by this abstract pathname was
- * last modified.
- *
- * @return A long
value representing the time the file was
- * last modified, measured in milliseconds since the epoch
- * (00:00:00 GMT, January 1, 1970), or 0L
if the
- * file does not exist or if an I/O error occurs
- */
- public long lastModified()
- {
- return lastModified;
- }
- /**
- * Returns the length of the file denoted by this abstract pathname.
- *
- * @return The length, in bytes, of the file denoted by this abstract
- * pathname, or 0L
if the file does not exist
- */
- public long length()
- {
- return length;
- }
- /**
- * Returns an abstract pathname string that represents the target resource of
- * of this file, if it is a symbolic-link.
- *
- *
If this abstract pathname does not denote a symbolic-link, then this
- * method returns null
. Otherwise a string is
- * returned that represents the target resource of this symbolic-link.
- *
- * @return A string representation of this symbolic-link's target resource.
- * @see #isLink()
- */
- public String getTarget()
- {
- return target;
- }
- /**
- * Returns an array of strings naming the files and directories in the
- * directory denoted by this abstract pathname.
- *
- *
If this abstract pathname does not denote a directory, then this
- * method returns null
. Otherwise an array of strings is
- * returned, one for each file or directory in the directory. Names
- * denoting the directory itself and the directory's parent directory are
- * not included in the result. Each string is a file name rather than a
- * complete path.
- *
- *
There is no guarantee that the name strings in the resulting array
- * will appear in any specific order; they are not, in particular,
- * guaranteed to appear in alphabetical order.
- *
- * @return An array of strings naming the files and directories in the
- * directory denoted by this abstract pathname. The array will be
- * empty if the directory is empty. Returns null
if
- * this abstract pathname does not denote a directory, or if an
- * I/O error occurs.
- */
- public String[] list()
- {
- try {
- if (isFile()) {
- errno = ErrorTable.NOT_DIRECTORY;
- return null;
- }
- ArrayList buffer = new ArrayList();
- dirHandle = listNative(buffer);
- if (dirHandle == 0) {
- return null;
- } else {
- return (String[])buffer.toArray(new String[0]);
- }
- } catch (Exception e) {
- System.out.println(e);
- return null;
- }
- }
- /**
- * Returns an ArrayList object containing strings naming the files and
- * directories in the directory denoted by this abstract pathname.
- *
- *
If this abstract pathname does not denote a directory, then this
- * method returns null
. Otherwise an array of strings is
- * returned, one for each file or directory in the directory. Names
- * denoting the directory itself and the directory's parent directory are
- * not included in the result. Each string is a file name rather than a
- * complete path.
- *
- *
There is no guarantee that the name strings in the resulting array
- * will appear in any specific order; they are not, in particular,
- * guaranteed to appear in alphabetical order.
- *
- * @return An array of strings naming the files and directories in the
- * directory denoted by this abstract pathname. The array will be
- * empty if the directory is empty. Returns null
if
- * this abstract pathname does not denote a directory, or if an
- * I/O error occurs.
- * @throws AFSSecurityException
- * If you are not authorized to list the contents of this directory
- * @throws AFSFileException
- * If this file object is not a mount point
, link
- *
, or directory
or an unexpected AFS
- * error occurs.
- * @see #list()
- */
- public ArrayList listArray() throws AFSFileException
- {
- try {
- if (isFile()) throw new AFSFileException(ErrorTable.NOT_DIRECTORY);
- ArrayList buffer = new ArrayList();
- dirHandle = listNative(buffer);
- if (dirHandle == 0) {
- if (errno == ErrorTable.PERMISSION_DENIED) {
- throw new AFSSecurityException(errno);
- } else {
- throw new AFSFileException(errno);
- }
- } else {
- return buffer;
- }
- } catch (Exception e) {
- System.out.println(e);
- throw new AFSFileException(errno);
- }
- }
- /*-------------------------------------------------------------------------*/
- /**
- * Deletes the file or directory denoted by this abstract pathname. If
- * this pathname denotes a directory, then the directory must be empty in
- * order to be deleted.
- *
- * @return true
if and only if the file or directory is
- * successfully deleted; false
otherwise
- */
- public boolean delete()
- {
- try {
- if(this.isDirectory()) {
- return this.rmdir();
- } else if(this.isFile() || this.isLink()) {
- return this.rmfile();
- }
- return false;
- } catch (Exception e) {
- System.out.println(e);
- return false;
- }
- }
- /**
- * Copies the file denoted by this abstract pathname to the destination
- * file provided. Then checks the newly copied file's size to
- * test for file size consistency.
- *
- * @param dest The new abstract pathname for the named file
- *
- * @return true
if and only if the file that was copied
- * reports the same file size (length) as that of this file;
- * false
otherwise
- *
- * @throws AFSFileException
- * If an I/O or AFS exception is encountered while copying the file.
- */
- public boolean copyTo(File dest) throws AFSFileException
- {
- FileInputStream fis = new FileInputStream(this);
- FileOutputStream fos = new FileOutputStream(dest);
- byte[] buf = new byte[1024];
- int i = 0;
- while((i=fis.read(buf))!=-1) {
- fos.write(buf, 0, i);
- }
- fis.close();
- fos.close();
- dest.validate();
- return (dest.length() == this.length());
- }
- /*-------------------------------------------------------------------------*/
- /**
- * Returns the permissions mask of the ACL for this object relative to the user accessing it.
- *
- * @return the permissions mask of this object based upon the current user.
- * @see org.openafs.jafs.ACL.Entry#getPermissionsMask()
- */
- public int getPermissionsMask()
- {
- return getRights();
- }
- /**
- * Tests whether the user can administer the ACL (see: {@link org.openafs.jafs.ACL}
- * of the directory denoted by this abstract pathname.
- *
- * @see org.openafs.jafs.ACL.Entry#canAdmin
- * @return true
if and only if the directory specified by this
- * abstract pathname exists and can be administered by the
- * current user; false
otherwise
- */
- public boolean canAdmin()
- {
- if (acl == null) acl = new ACL.Entry(getRights());
- return acl.canAdmin();
- }
- /**
- * Tests whether the current user can delete the files or subdirectories of
- * the directory denoted by this abstract pathname.
- *
- * @see org.openafs.jafs.ACL.Entry#canDelete
- * @return true
if and only if the directory specified by this
- * abstract pathname exists and permits deletion of its files
- * and subdirectories by the current user; false
otherwise
- */
- public boolean canDelete()
- {
- if (acl == null) acl = new ACL.Entry(getRights());
- return acl.canDelete();
- }
- /**
- * Tests whether the current user can insert a file into the directory
- * denoted by this abstract pathname.
- *
- * @see org.openafs.jafs.ACL.Entry#canInsert
- * @return true
if and only if the directory specified by this
- * abstract pathname exists and a file can be inserted by the
- * current user; false
otherwise
- */
- public boolean canInsert()
- {
- if (acl == null) acl = new ACL.Entry(getRights());
- return acl.canInsert();
- }
- /**
- * Tests whether the current user can lock the file denoted by this
- * abstract pathname.
- *
- * @see org.openafs.jafs.ACL.Entry#canLock
- * @return true
if and only if the file specified by this
- * abstract pathname exists and can be locked by the
- * current user; false
otherwise
- */
- public boolean canLock()
- {
- if (acl == null) acl = new ACL.Entry(getRights());
- return acl.canLock();
- }
- /**
- * Tests whether the current user can lookup the contents of the directory
- * denoted by this abstract pathname.
- *
- * @see org.openafs.jafs.ACL.Entry#canLookup
- * @return true
if and only if the directory specified by this
- * abstract pathname exists and its contents can be listed by the
- * current user; false
otherwise
- */
- public boolean canLookup()
- {
- if (acl == null) acl = new ACL.Entry(getRights());
- return acl.canLookup();
- }
- /**
- * Tests whether the current user can read the file denoted by this
- * abstract pathname.
- *
- * @see org.openafs.jafs.ACL.Entry#canRead
- * @return true
if and only if the file specified by this
- * abstract pathname exists and can be read by the
- * current user; false
otherwise
- */
- public boolean canRead()
- {
- if (acl == null) acl = new ACL.Entry(getRights());
- return acl.canRead();
- }
- /**
- * Tests whether the current user can modify to the file denoted by this
- * abstract pathname.
- *
- * @see org.openafs.jafs.ACL.Entry#canWrite
- * @return true
if and only if the file system actually
- * contains a file denoted by this abstract pathname and
- * the current user is allowed to write to the file;
- * false
otherwise.
- */
- public boolean canWrite()
- {
- if (acl == null) acl = new ACL.Entry(getRights());
- return acl.canWrite();
- }
- /*-------------------------------------------------------------------------*/
- /**
- * Closes the directory denoted by this abstract pathname.
- *
- * @return true
if and only if the directory is
- * successfully closed; false
otherwise
- */
- public boolean close()
- {
- if (dirHandle == 0) {
- return false;
- }
- return closeDir(dirHandle);
- }
- /*-------------------------------------------------------------------------*/
- /**
- * Returns the AFS specific error number (code). This code can be interpreted
- * by use of {@link org.openafs.jafs.ErrorTable}
static class method
- * {@link org.openafs.jafs.ErrorTable#getMessage}
- *
- * @return the AFS error code (number) associated with the last action performed
- * on this object.
- * @see org.openafs.jafs.ErrorTable#getMessage(int)
- */
- public int getErrorCode()
- {
- return errno;
- }
- /**
- * Returns the AFS error message string defined by the {@link org.openafs.jafs.ErrorTable}
- * class.
- *
- * @return the AFS error message string associated with the last action performed
- * on this object.
- * @see org.openafs.jafs.ErrorTable#getMessage(int)
- */
- public String getErrorMessage()
- {
- return ErrorTable.getMessage(errno);
- }
-
- /////////////// custom override methods ////////////////////
-
- /**
- * Compares two File objects relative to their filenames and does not
- * compare their respective absolute paths. Alphabetic case is significant in
- * comparing filenames.
- *
- * @param file The File object to be compared to this file's filename
- *
- * @return Zero if the argument is equal to this file's filename, a
- * value less than zero if this file's filename is
- * lexicographically less than the argument, or a value greater
- * than zero if this file's filename is lexicographically
- * greater than the argument
- *
- * @since JDK1.2
- */
- public int compareTo(File file) {
- return this.getName().compareTo(file.getName());
- }
- /**
- * Compares this file to another File object. If the other object
- * is an abstract pathname, then this function behaves like {@link
- * #compareTo(File)}
. Otherwise, it throws a
- * ClassCastException
, since File objects can only be
- * compared to File objects.
- *
- * @param o The Object
to be compared to this abstract pathname
- *
- * @return If the argument is an File object, returns zero
- * if the argument is equal to this file's filename, a value
- * less than zero if this file's filename is lexicographically
- * less than the argument, or a value greater than zero if this
- * file's filename is lexicographically greater than the
- * argument
- *
- * @throws ClassCastException
if the argument is not an
- * File object
- *
- * @see java.lang.Comparable
- * @since JDK1.2
- */
- public int compareTo(Object o) throws ClassCastException
- {
- File file = (File)o;
- return compareTo(file);
- }
-
- /////////////// public native methods ////////////////////
-
- /**
- * Creates the directory named by this abstract pathname.
- *
- * @return true
if and only if the directory was
- * created; false
otherwise
- */
- public native boolean mkdir();
- /**
- * Renames the file denoted by this abstract pathname.
- *
- * @param dest The new abstract pathname for the named file
- *
- * @return true
if and only if the renaming succeeded;
- * false
otherwise
- *
- * @throws NullPointerException
- * If parameter dest
is null
- */
- public native boolean renameTo(File dest);
- /**
- * Performs a file stat
on the actual AFS file and populates
- * this object's respective field members with the appropriate values.
- * method will, if authorized, perform a stat
on the
- * actual AFS file and update its respective field members; defining
- * this file object's attributes.
- *
- *
This method should not be used directly for refreshing or validating
- * this AFS file object. Please use {@link #validate} instead.
- *
- * @return true
if and only if the current user is allowed to stat the file;
- * false
otherwise.
- * @see #validate()
- */
- public native boolean setAttributes() throws AFSSecurityException;
-
- /////////////// private native methods ////////////////////
-
- /**
- * List the contents of this directory.
- *
- * @return the directory handle
- */
- private native long listNative(ArrayList buffer) throws AFSSecurityException;
- /**
- * Close the currently open directory using a previously obtained handle.
- *
- * @return true if the directory closes without error
- */
- private native boolean closeDir(long dp) throws AFSSecurityException;
- /**
- * Removes/deletes the current directory.
- *
- * @return true if the directory is removed without error
- */
- private native boolean rmdir() throws AFSSecurityException;
- /**
- * Removes/deletes the current file.
- *
- * @return true if the file is removed without error
- */
- private native boolean rmfile() throws AFSSecurityException;
- /**
- * Returns the permission/ACL mask for this directory
- *
- * @return permission/ACL mask
- */
- private native int getRights() throws AFSSecurityException;
- /*-------------------------------------------------------------------------*/
-}
-
-
-
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/FileInputStream.java b/src/JAVA/classes/org/openafs/jafs/FileInputStream.java
deleted file mode 100644
index ea7f65ce10..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/FileInputStream.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * @(#)FilterInputStream.java 1.0 00/10/10
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-import java.io.InputStream;
-
-/**
- * This class is a file input stream for files within AFS.
- * It is an input stream for reading data from a
- * {@link org.openafs.jafs.File}
.
- *
- * @version 2.1, 08/03/2001
- * @see org.openafs.jafs.File
- * @see org.openafs.jafs.FileOutputStream
- * @see java.io.FileInputStream
- */
-public class FileInputStream extends InputStream
-{
- /** Status indicator for the current state of this file input stream */
- private int fileDescriptor;
-
- /**
- * Creates a FileInputStream
by
- * opening a connection to an actual AFS file,
- * the file named by the path name name
- * in the AFS file system.
- *
- * @param name the name of the file to read from
- * @exception AFSFileException If an AFS specific error occurs,
- * if the file does not, or cannot be opened for any
- * other reason, including authorization.
- */
- public FileInputStream(String name) throws AFSFileException
- {
- this.fileDescriptor = this.openReadOnly(name);
- }
- /**
- * Creates a FileInputStream
by
- * opening a connection to an actual AFS file,
- * the file represented by file file
- * in the AFS file system.
- *
- * @param file an AFS file object representing a file to read from
- * @exception AFSFileException If an AFS specific error occurs,
- * if the file does not, or cannot be opened for any
- * other reason, including authorization.
- */
- public FileInputStream(File file) throws AFSFileException
- {
- this(file.getPath());
- }
-
- /*-------------------------------------------------------------------------*/
-
- /**
- * Reads the next byte of data from this input stream. The value
- * byte is returned as an int
in the range
- * 0
to 255
. If no byte is available
- * because the end of the stream has been reached, the value
- * -1
is returned. This method blocks until input data
- * is available, the end of the stream is detected, or an exception
- * is thrown.
- *
- *
This method simply performs in.read()
and returns
- * the result.
- *
- * @return the next byte of data, or -1
if the end of the
- * stream is reached.
- * @exception AFSFileException if an I/O or other file related error occurs.
- * @see java.io.FileInputStream#read
- */
- public int read() throws AFSFileException
- {
- byte[] bytes = new byte[1];
- this.read(bytes, 0, 1);
- return bytes[0];
- }
- /**
- * Reads up to b.length
bytes of data from this input
- * stream into an array of bytes. This method blocks until some input
- * is available.
- *
- * @param b the buffer into which the data is read.
- * @return the total number of bytes read into the buffer, or
- * -1
if there is no more data because the end of
- * the file has been reached.
- * @exception AFSFileException if an I/O or other file related error occurs.
- */
- public int read(byte[] b) throws AFSFileException
- {
- return this.read(b, 0, b.length);
- }
-
- /////////////// public native methods ////////////////////
-
- /**
- * Reads up to len
bytes of data from this input stream
- * into an array of bytes. This method blocks until some input is
- * available.
- *
- * @param b the buffer into which the data is read.
- * @param off the start offset of the data.
- * @param len the maximum number of bytes read.
- * @return the total number of bytes read into the buffer, or
- * -1
if there is no more data because the end of
- * the file has been reached.
- * @exception AFSFileException if an I/O or other file related error occurs.
- */
- public native int read(byte[] b, int off, int len) throws AFSFileException;
- /**
- * Skips over and discards n
bytes of data from the
- * input stream. The skip
method may, for a variety of
- * reasons, end up skipping over some smaller number of bytes,
- * possibly 0
. The actual number of bytes skipped is returned.
- *
- * @param n the number of bytes to be skipped.
- * @return the actual number of bytes skipped.
- * @exception AFSFileException if an I/O or other file related error occurs.
- */
- public native long skip(long n) throws AFSFileException;
- /**
- * Closes this file input stream and releases any system resources
- * associated with the stream.
- *
- * @exception AFSFileException if an I/O or other file related error occurs.
- */
- public native void close() throws AFSFileException;
-
- /////////////// private native methods ////////////////////
-
- /**
- * Opens the specified AFS file for reading.
- *
- * @param name fileName of file to be opened
- * @return file descriptor
- * @exception AFSFileException if an I/O or other file related error occurs.
- */
- private native int openReadOnly(String fileName) throws AFSFileException;
-
- /*-------------------------------------------------------------------------*/
-}
-
-
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/FileOutputStream.java b/src/JAVA/classes/org/openafs/jafs/FileOutputStream.java
deleted file mode 100644
index 95c92ddfd2..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/FileOutputStream.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * @(#)FilterOutputStream.java 1.0 00/10/10
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-import java.io.OutputStream;
-
-/**
- * This class is a file output stream for files within AFS.
- * It is an output stream for writing data to a
- * {@link org.openafs.jafs.File}
.
- *
- * @version 2.1, 08/03/2001
- * @see org.openafs.jafs.File
- * @see org.openafs.jafs.FileInputStream
- * @see java.io.FileOutputStream
- */
-public class FileOutputStream extends OutputStream
-{
- /** Status indicator for the current state of this file output stream */
- private int fileDescriptor;
-
- /**
- * Creates an output file stream to write to the AFS file with the
- * specified name.
- *
- * If the file exists but is a directory rather than a regular file, does
- * not exist but cannot be created, or cannot be opened for any other
- * reason then a AFSFileException
is thrown.
- *
- * @param name the name of the file to write to
- * @exception AFSFileException If an AFS specific error occurs,
- * if the file exists but is a directory
- * rather than a regular file, does not exist but cannot
- * be created, or cannot be opened for any other reason, including
- * authorization.
- */
- public FileOutputStream(String name) throws AFSFileException
- {
- this(name, false);
- }
- /**
- * Creates an output file stream to write to the AFS file with the specified
- * name
. If the second argument is true
, then
- * bytes will be written to the end of the file rather than the beginning.
- *
- * If the file exists but is a directory rather than a regular file, does
- * not exist but cannot be created, or cannot be opened for any other
- * reason then a AFSFileException
is thrown.
- *
- * @param name the name of the file to write to
- * @param append if true
, then bytes will be written
- * to the end of the file rather than the beginning
- * @exception AFSFileException If an AFS specific error occurs,
- * if the file exists but is a directory
- * rather than a regular file, does not exist but cannot
- * be created, or cannot be opened for any other reason, including
- * authorization.
- */
- public FileOutputStream(String name, boolean append) throws AFSFileException
- {
- if (append) {
- fileDescriptor = this.openAppend(name);
- } else {
- fileDescriptor = this.openWrite(name);
- }
- }
- /**
- * Creates a file output stream to write to the AFS file represented by
- * the specified File
object.
- *
- * If the file exists but is a directory rather than a regular file, does
- * not exist but cannot be created, or cannot be opened for any other
- * reason then a AFSFileException
is thrown.
- *
- * @param file the AFS file to be opened for writing.
- * @exception AFSFileException If an AFS specific error occurs,
- * if the file exists but is a directory
- * rather than a regular file, does not exist but cannot
- * be created, or cannot be opened for any other reason, including
- * authorization.
- * @see org.openafs.jafs.File#getPath()
- */
- public FileOutputStream(File file) throws AFSFileException
- {
- this(file.getPath(), false);
- }
- /**
- * Creates a file output stream to write to the AFS file represented by
- * the specified File
object.
- *
- * If the file exists but is a directory rather than a regular file, does
- * not exist but cannot be created, or cannot be opened for any other
- * reason then a AFSFileException
is thrown.
- *
- * @param file the AFS file to be opened for writing.
- * @param append if true
, then bytes will be written
- * to the end of the file rather than the beginning
- * @exception AFSFileException If an AFS specific error occurs,
- * if the file exists but is a directory
- * rather than a regular file, does not exist but cannot
- * be created, or cannot be opened for any other reason, including
- * authorization.
- * @see org.openafs.jafs.File#getPath()
- */
- public FileOutputStream(File file, boolean append) throws AFSFileException
- {
- this(file.getPath(), append);
- }
-
- /*-------------------------------------------------------------------------*/
-
- /**
- * Writes the specified byte
to this file output stream.
- *
- * Implements the abstract write method of OutputStream.
- *
- * @param b the byte to be written.
- * @exception AFSFileException if an error occurs.
- */
- public void write(int b) throws AFSFileException
- {
- byte[] bytes = new byte[1];
- bytes[0] = (byte) b;
- this.write(bytes, 0, 1);
- }
- /**
- * Writes b.length
bytes from the specified byte array
- * to this file output stream.
- *
- * Implements the write
method of three arguments with the
- * arguments b
, 0
, and
- * b.length
.
- *
- * Note that this method does not call the one-argument
- * write
method of its underlying stream with the single
- * argument b
.
- *
- * @param b the data to be written.
- * @exception AFSFileException if an error occurs.
- * @see #write(byte[], int, int)
- * @see java.io.FilterOutputStream#write(byte[], int, int)
- */
- public void write(byte[] b) throws AFSFileException
- {
- this.write(b, 0, b.length);
- }
-
- /////////////// public native methods ////////////////////
-
- /**
- * Writes len
bytes from the specified
- * byte
array starting at offset off
to
- * this file output stream.
- *
- * @param b the data to be written
- * @param off the start offset in the data
- * @param len the number of bytes that are written
- * @exception AFSFileException if an I/O or other file related error occurs.
- * @see java.io.FilterOutputStream#write(int)
- */
- public native void write(byte[] b, int off, int len) throws AFSFileException;
- /**
- * Closes this file output stream and releases any system resources
- * associated with this stream. This file output stream may no longer
- * be used for writing bytes.
- *
- * @exception AFSFileException if an I/O or other file related error occurs.
- */
- public native void close() throws AFSFileException;
-
- /////////////// private native methods ////////////////////
-
- /**
- * Opens an AFS file, with the specified name, for writing.
- *
- * @param filename name of file to be opened
- * @return file descriptor
- * @exception AFSFileException if an I/O or other file related error occurs.
- */
- private native int openWrite(String filename) throws AFSFileException;
- /**
- * Opens an AFS file, with the specified name, for appending.
- *
- * @param filename name of file to be opened
- * @return file descriptor
- * @exception AFSFileException if an I/O or other file related error occurs.
- */
- private native int openAppend(String filename) throws AFSFileException;
-
- /*-------------------------------------------------------------------------*/
-}
-
-
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/Group.java b/src/JAVA/classes/org/openafs/jafs/Group.java
deleted file mode 100644
index 9a583912db..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/Group.java
+++ /dev/null
@@ -1,1278 +0,0 @@
-/*
- * @(#)Group.java 1.0 6/29/2001
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-import java.util.Vector;
-import java.util.Enumeration;
-import java.util.ArrayList;
-import java.io.Serializable;
-
-/**
- * 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 {@link #create(String, int)} or
- * {@link #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.
- * {@link #setListMembership(int)}. However, in order for these values to be
- * written to the actual AFS group, the {@link #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()); - * ... - * } - * ... - * } - *- * - */ -public class Group implements PTSEntry, Serializable, Comparable -{ - /** - * Only the owner of the group has access - */ - public static final int GROUP_OWNER_ACCESS = 0; - /** - * Members of the group have access - */ - public static final int GROUP_GROUP_ACCESS = 1; - /** - * Any user has access - */ - public static final int GROUP_ANYUSER_ACCESS = 2; - - protected Cell cell; - protected long cellHandle; - protected String name; - - protected int membershipCount; - protected int nameUID; - protected int ownerUID; - protected int creatorUID; - - protected String owner; - protected String creator; - - /** - * who is allowed to execute PTS examine for this group. Valid values are: - *
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 {@link #create(String, int)} or {@link #create(String)}
- * method is explicitly called to create it.
- *
- * @param name the name of the group to represent
- * @param cell the cell to which the group belongs.
- * @exception AFSException If an error occurs in the native code
- */
- public Group( String name, Cell cell ) throws AFSException
- {
- this.name = name;
- this.cell = cell;
- cellHandle = cell.getCellHandle();
-
- members = null;
- memberNames = null;
- groupsOwned = null;
- groupsOwnedNames = null;
- cachedInfo = false;
- }
-
- /**
- * Constructs a new 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 {@link #create(String, int)} or {@link #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 {@link #refresh()} method to address any coherency
- * concerns.
- *
- * @param name the name of the group to represent
- * @param cell the cell to which the group belongs.
- * @param preloadAllMembers true will ensure all object members are
- * set upon construction;
- * otherwise members will be set upon access,
- * which is the default behavior.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh
- */
- public Group( String name, Cell cell, boolean preloadAllMembers )
- throws AFSException
- {
- this(name, cell);
- if (preloadAllMembers) refresh(true);
- }
-
- /**
- * Creates a blank Group
given the cell to which the group
- * belongs. Other methods cvan then be used to fill the fields of this
- * blank object.
- *
- * @exception AFSException If an error occurs in the native code
- * @param cell the cell to which the group belongs.
- */
- Group( Cell cell ) throws AFSException
- {
- this( null, cell );
- }
-
- /*-------------------------------------------------------------------------*/
-
- /**
- * Creates the PTS entry for a new group in this cell. Automatically assigns
- * a group id.
- *
- * @param ownerName the owner of this group
- */
- public void create( String ownerName ) throws AFSException
- {
- this.create( ownerName, 0 );
- }
-
- /**
- * Creates the PTS entry for a new group in this cell.
- *
- * @param ownerName the owner of this group
- * @param gid the group id to assign to the new group
- * @exception AFSException If an error occurs in the native code
- */
- public void create( String ownerName, int gid ) throws AFSException
- {
- Group.create( cell.getCellHandle(), name, ownerName, gid );
- }
-
- /**
- * Deletes the PTS entry for a group in this cell. Deletes this group
- * from the membership list of the user that belonged to it, but does not
- * delete the groups owned by this group. Also nullifies the Java object.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void delete() throws AFSException
- {
- Group.delete( cell.getCellHandle(), name );
-
- cell = null;
- name = null;
- owner = null;
- creator = null;
- members = null;
- memberNames = null;
- groupsOwned = null;
- groupsOwnedNames = null;
- try {
- finalize();
- } catch( Throwable t ) {
- throw new AFSException( t.getMessage() );
- }
- }
-
- /**
- * Flushes the current information of this 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.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void flushInfo() throws AFSException
- {
- Group.setGroupInfo( cell.getCellHandle(), name, this );
- }
-
- /**
- * Add the specified member to this group.
- *
- * @param userName the User
object to add
- * @exception AFSException If an error occurs in the native code
- */
- public void addMember( User theUser ) throws AFSException
- {
- String userName = theUser.getName();
-
- Group.addMember( cell.getCellHandle(), name, userName );
-
- // add to cache
- if( memberNames != null ) {
- memberNames.add( userName );
- }
- if( members != null ) {
- members.add( new User( userName, cell ) );
- }
- }
-
- /**
- * Remove the specified member from this group.
- * @param userName the User
object to remove
- * @exception AFSException If an error occurs in the native code
- */
- public void removeMember( User theUser ) throws AFSException
- {
- String userName = theUser.getName();
- Group.removeMember( cell.getCellHandle(), name, userName );
-
- // remove from cache
- if( memberNames != null ) {
- memberNames.remove( memberNames.indexOf(userName) );
- memberNames.trimToSize();
- }
- if( members != null && members.indexOf(theUser) > -1) {
- members.remove( members.indexOf(theUser) );
- members.trimToSize();
- }
- }
-
- /**
- * Change the owner of this group.
- *
- * @param ownerName the new owner User
object
- * @exception AFSException If an error occurs in the native code
- */
- public void changeOwner( User theOwner ) throws AFSException
- {
- String ownerName = theOwner.getName();
-
- Group.changeOwner( cell.getCellHandle(), name, ownerName );
-
- if( cachedInfo ) {
- owner = ownerName;
- }
- }
-
- /**
- * Change the owner of this group.
- *
- * @param ownerName the new owner Group
object
- * @exception AFSException If an error occurs in the native code
- */
- public void changeOwner( Group theOwner ) throws AFSException
- {
- String ownerName = theOwner.getName();
- Group.changeOwner( cell.getCellHandle(), name, ownerName );
- if( cachedInfo ) {
- owner = ownerName;
- }
- }
-
- /**
- * Change the name of this group.
- *
- * @param newName the new name for this group
- * @exception AFSException If an error occurs in the native code
- */
- public void rename( String newName ) throws AFSException
- {
- Group.rename( cell.getCellHandle(), name, newName );
- name = newName;
- }
-
- /**
- * Refreshes the properties of this Group object instance with values from
- * the AFS group it represents. All properties that have been initialized
- * and/or accessed will be renewed according to the values of the AFS group
- * this 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.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void refresh() throws AFSException
- {
- refresh(false);
- }
-
- /**
- * Refreshes the properties of this Group object instance with values from
- * the AFS group it represents. If 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 {@link #refresh()} for more information.
- *
- * @param all if true set or renew all object properties; otherwise renew
- * all set properties
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- protected void refresh(boolean all) throws AFSException
- {
- if( all || cachedInfo ) {
- refreshInfo();
- }
- if( all || groupsOwned != null ) {
- refreshGroupsOwned();
- }
- if( all || groupsOwnedNames != null ) {
- refreshGroupsOwnedNames();
- }
- if( all || members != null ) {
- refreshMembers();
- }
- if( all || memberNames != null ) {
- refreshMemberNames();
- }
- }
-
- /**
- * Refreshes the information fields of this 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.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshInfo() throws AFSException
- {
- cachedInfo = true;
- Group.getGroupInfo( cell.getCellHandle(), name, this );
- }
-
- /**
- * Refreshes the current information about the User
objects
- * belonging to this group. Does not refresh the information fields of
- * the group or groups owned.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshMembers() throws AFSException
- {
- User currUser;
-
- long iterationID = Group.getGroupMembersBegin( cell.getCellHandle(), name );
-
- members = new ArrayList();
-
- currUser = new User( cell );
- while( Group.getGroupMembersNext( cellHandle, iterationID, currUser )
- != 0 ) {
- members.add( currUser );
- currUser = new User( cell );
- }
-
- Group.getGroupMembersDone( iterationID );
- }
-
- /**
- * Refreshes the current information about the names of members belonging
- * to this group. Does not refresh the information fields of the group
- * or groups owned.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshMemberNames() throws AFSException
- {
- String currName;
- long iterationID = Group.getGroupMembersBegin( cell.getCellHandle(), name );
-
- memberNames = new ArrayList();
-
- while( ( currName = Group.getGroupMembersNextString( iterationID ) )
- != null ) {
- memberNames.add( currName );
- }
- Group.getGroupMembersDone( iterationID );
- }
-
- /**
- * Refreshes the current information about the Group
objects the
- * group owns. Does not refresh the information fields of the group or
- * members.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshGroupsOwned() throws AFSException
- {
- Group currGroup;
-
- long iterationID = User.getGroupsOwnedBegin( cell.getCellHandle(), name );
-
- groupsOwned = new ArrayList();
-
- currGroup = new Group( cell );
- while( User.getGroupsOwnedNext( cellHandle, iterationID, currGroup )
- != 0 ) {
- groupsOwned.add( currGroup );
- currGroup = new Group( cell );
- }
-
- User.getGroupsOwnedDone( iterationID );
- }
-
- /**
- * Refreshes the current information about the names of groups the group
- * owns. Does not refresh the information fields of the group or members.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshGroupsOwnedNames() throws AFSException
- {
- String currName;
-
- long iterationID = User.getGroupsOwnedBegin( cell.getCellHandle(), name );
-
- groupsOwnedNames = new ArrayList();
- while( ( currName = User.getGroupsOwnedNextString( iterationID ) )
- != null ) {
- groupsOwnedNames.add( currName );
- }
- User.getGroupsOwnedDone( iterationID );
- }
-
- /**
- * Adds an access control list entry for some AFS directory for this group.
- *
- * @param directory the full path of the place in the AFS file system
- * for which to add an entry
- * @param read whether or not to allow read access to this user
- * @param write whether or not to allow write access to this user
- * @param lookup whether or not to allow lookup access to this user
- * @param delete whether or not to allow deletion access to this user
- * @param insert whether or not to allow insertion access to this user
- * @param lock whether or not to allow lock access to this user
- * @param admin whether or not to allow admin access to this user
- * @exception AFSException If an error occurs in the native code
- public void setACL( String directory, boolean read, boolean write, boolean lookup, boolean delete, boolean insert, boolean lock, boolean admin )
- throws AFSException
- {
- Cell.setACL( directory, name, read, write, lookup, delete, insert, lock, admin );
- }
- */
-
- ////////////////////// accessors: ///////////////
-
- /**
- * Returns the name of this group.
- *
- * @return the name of this group
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Returns the numeric AFS id of this group.
- *
- * @return the AFS id of this group
- * @exception AFSException If an error occurs in the native code
- */
- public int getUID() throws AFSException
- {
- if( !cachedInfo ) {
- refreshInfo();
- }
- return nameUID;
- }
-
- /**
- * Returns the Cell this group belongs to.
- *
- * @return the Cell this group belongs to
- */
- public Cell getCell()
- {
- return cell;
- }
-
- /**
- * Returns an array of the User
object members of this group.
- *
- * @return an array of the members of this group
- * @exception AFSException If an error occurs in the native code
- */
- public User[] getMembers() throws AFSException
- {
- if( members == null ) {
- refreshMembers();
- }
- return (User[]) members.toArray( new User[members.size()] );
- }
-
- /**
- * Returns an array of the member names of this group.
- *
- * @return an array of the member names of this group
- * @exception AFSException If an error occurs in the native code
- */
- public String[] getMemberNames() throws AFSException
- {
- if( memberNames == null ) {
- refreshMemberNames();
- }
- return (String[]) memberNames.toArray( new String[memberNames.size()] );
- }
-
- /**
- * Returns an array of the Group
objects this group owns.
- *
- * @return an array of the Groups
this group owns
- * @exception AFSException If an error occurs in the native code
- */
- public Group[] getGroupsOwned() throws AFSException
- {
- if( groupsOwned == null ) {
- refreshGroupsOwned();
- }
- return (Group[]) groupsOwned.toArray( new Group[groupsOwned.size()] );
- }
-
- /**
- * Returns an array of the group names this group owns.
- * Contains String
objects.
- *
- * @return an array of the group names this group owns
- * @exception AFSException If an error occurs in the native code
- */
- public String[] getGroupsOwnedNames() throws AFSException
- {
- if( groupsOwnedNames == null ) {
- refreshGroupsOwnedNames();
- }
- return (String[])
- groupsOwnedNames.toArray(new String[groupsOwnedNames.size()] );
- }
-
- /**
- * Returns the number of members of this group.
- *
- * @return the membership count
- * @exception AFSException If an error occurs in the native code
- */
- public int getMembershipCount() throws AFSException
- {
- if( !cachedInfo ) {
- refreshInfo();
- }
- return membershipCount;
- }
-
- /**
- * PTS: Returns the owner of this group in the form of a {@link PTSEntry}.
- *
- *
The returning object could be either a {@link User} or {@link Group}; - * to determine what type of object the {@link PTSEntry} represents, - * call the {@link PTSEntry#getType()} method. - * - * @return the owner of this group - * @exception AFSException If an error occurs in the native code - * @see PTSEntry - * @see PTSEntry#getType() - * @see #refresh() - */ - public PTSEntry getOwner() throws AFSException - { - if (!cachedInfo) refreshInfo(); - if (owner == null) return null; - if (ownerUID > 0) { - return new User(owner, cell); - } else { - return new Group(owner, cell); - } - } - - /** - * PTS: Returns the creator of this group in the form of a {@link PTSEntry}. - * - *
The returning object could be either a {@link User} or {@link Group}; - * to determine what type of object the {@link PTSEntry} represents, - * call the {@link PTSEntry#getType()} method. - * - * @return the creator of this group - * @exception AFSException If an error occurs in the native code - * @see PTSEntry - * @see PTSEntry#getType() - * @see #refresh() - */ - public PTSEntry getCreator() throws AFSException - { - if (!cachedInfo) refreshInfo(); - if (creator == null) return null; - if (creatorUID > 0) { - return new User(creator, cell); - } else { - return new Group(creator, cell); - } - } - - /** - * Returns the type of {@link PTSEntry} this object represents. - * - *
This method will always return {@link PTSEntry#PTS_GROUP}. - * - * @return the type of PTSEntry this object represents - (will always return {@link PTSEntry#PTS_GROUP}) - * @see PTSEntry - * @see PTSEntry#getType() - */ - public short getType() - { - return PTSEntry.PTS_GROUP; - } - - /** - * Returns who can list the status (pts examine) of this group. - * Valid values are: - *
{@link #GROUP_OWNER_ACCESS}
- * -- only the owner has permission{@link #GROUP_GROUP_ACCESS}
- * -- only members of the group have permission{@link #GROUP_ANYUSER_ACCESS}
- * -- any user has permission{@link #GROUP_OWNER_ACCESS}
- * -- only the owner has permission{@link #GROUP_GROUP_ACCESS}
- * -- only members of the group have permission{@link #GROUP_ANYUSER_ACCESS}
- * -- any user has permission{@link #GROUP_OWNER_ACCESS}
- * -- only the owner has permission{@link #GROUP_GROUP_ACCESS}
- * -- only members of the group have permission{@link #GROUP_ANYUSER_ACCESS}
- * -- any user has permission{@link #GROUP_OWNER_ACCESS}
- * -- only the owner has permission{@link #GROUP_GROUP_ACCESS}
- * -- only members of the group have permission{@link #GROUP_ANYUSER_ACCESS}
- * -- any user has permission{@link #GROUP_OWNER_ACCESS}
- * -- only the owner has permission{@link #GROUP_GROUP_ACCESS}
- * -- only members of the group have permission{@link #GROUP_ANYUSER_ACCESS}
- * -- any user has permission{@link #GROUP_OWNER_ACCESS}
- * -- only the owner has permission{@link #GROUP_GROUP_ACCESS}
- * -- only members of the group have permission{@link #GROUP_ANYUSER_ACCESS}
- * -- any user has permission{@link #GROUP_OWNER_ACCESS}
- * -- only the owner has permission{@link #GROUP_GROUP_ACCESS}
- * -- only members of the group have permission{@link #GROUP_ANYUSER_ACCESS}
- * -- any user has permission{@link #GROUP_OWNER_ACCESS}
- * -- only the owner has permission{@link #GROUP_GROUP_ACCESS}
- * -- only members of the group have permission{@link #GROUP_ANYUSER_ACCESS}
- * -- any user has permission{@link #GROUP_OWNER_ACCESS}
- * -- only the owner has permission{@link #GROUP_GROUP_ACCESS}
- * -- only members of the group have permission{@link #GROUP_ANYUSER_ACCESS}
- * -- any user has permission{@link #GROUP_OWNER_ACCESS}
- * -- only the owner has permission{@link #GROUP_GROUP_ACCESS}
- * -- only members of the group have permission{@link #GROUP_ANYUSER_ACCESS}
- * -- any user has permissionString
representation of this Group
.
- * Contains the information fields and members.
- *
- * @return a String
representation of the Group
- */
- public String getInfo()
- {
- String r;
- try {
- r = "Group: " + getName() + ", uid: " + getUID() + "\n";
- r += "\towner: " + getOwner().getName() + ", uid: " + getOwner().getUID() + "\n";
- r += "\tcreator: " + getCreator().getName() + ", uid: "
- + getCreator().getUID() + "\n";
- r += "\tMembership count: " + getMembershipCount() + "\n";
- r += "\tList status: " + getListStatus() + "\n";
- r += "\tList groups owned: " + getListGroupsOwned() + "\n";
- r += "\tList membership: " + getListMembership() + "\n";
- r += "\tAdd members: " + getListAdd() + "\n";
- r += "\tDelete members: " + getListDelete() + "\n";
-
- r += "\tGroup members: \n";
- String names[] = getMemberNames();
- for( int i = 0; i < names.length; i++ ) {
- r += "\t\t" + names[i] + "\n";
- }
-
- r += "\tOwns groups: \n";
- names = getGroupsOwnedNames();
- for( int i = 0; i < names.length; i++ ) {
- r += "\t\t" + names[i] + "\n";
- }
- return r;
- } catch ( AFSException e ) {
- return e.toString();
- }
- }
-
- /////////////// custom override methods ////////////////////
-
- /**
- * Compares two Group objects respective to their names and does not
- * factor any other attribute. Alphabetic case is significant in
- * comparing names.
- *
- * @param group The Group object to be compared to this Group instance
- *
- * @return Zero if the argument is equal to this Group's name, a
- * value less than zero if this Group's name is
- * lexicographically less than the argument, or a value greater
- * than zero if this Group's name is lexicographically
- * greater than the argument
- */
- public int compareTo(Group group)
- {
- return this.getName().compareTo(group.getName());
- }
-
- /**
- * Comparable interface method.
- *
- * @see #compareTo(Group)
- */
- public int compareTo(Object obj)
- {
- return compareTo((Group)obj);
- }
-
- /**
- * Tests whether two Group
objects are equal, based on their
- * names.
- *
- * @param otherGroup the Group to test
- * @return whether the specifed Group is the same as this Group
- */
- public boolean equals( Group otherGroup )
- {
- return name.equals( otherGroup.getName() );
- }
-
- /**
- * Returns the name of this Group
- *
- * @return the name of this Group
- */
- public String toString()
- {
- return getName();
- }
-
- /////////////// native methods ////////////////////
-
- /**
- * Creates the PTS entry for a new group. Pass in 0 for the uid if PTS is to
- * automatically assign the group id.
- *
- * @param cellHandle the handle of the cell to which the group belongs
- * @see Cell#getCellHandle
- * @param groupName the name of the group to create
- * @param ownerName the owner of this group
- * @param gid the group id to assign to the group (0 to have one
- * automatically assigned)
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void create( long cellHandle, String groupName,
- String ownerName, int gid )
- throws AFSException;
-
- /**
- * Deletes the PTS entry for a group. Deletes this group from the
- * membership list of the users that belonged to it, but does not delete
- * the groups owned by this group.
- *
- * @param cellHandle the handle of the cell to which the group belongs
- * @see Cell#getCellHandle
- * @param groupName the name of the group to delete
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void delete( long cellHandle, String groupName )
- throws AFSException;
-
- /**
- * Fills in the information fields of the provided Group
.
- * Fills in values based on the current PTS information of the group.
- *
- * @param cellHandle the handle of the cell to which the group belongs
- * @see Cell#getCellHandle
- * @param name the name of the group for which to get the information
- * @param group the Group
object in which to fill in the
- * information
- * @see Group
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getGroupInfo( long cellHandle, String name,
- Group group )
- throws AFSException;
-
- /**
- * Sets the information values of this AFS group to be the parameter values.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @param name the name of the user for which to set the information
- * @param theGroup the group object containing the desired information
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void setGroupInfo( long cellHandle, String name,
- Group theGroup )
- throws AFSException;
-
- /**
- * Begin the process of getting the users that belong to the group. Returns
- * an iteration ID to be used by subsequent calls to
- * getGroupMembersNext
and getGroupMembersDone
.
- *
- * @param cellHandle the handle of the cell to which the group belongs
- * @see Cell#getCellHandle
- * @param name the name of the group for which to get the members
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- */
- protected static native long getGroupMembersBegin( long cellHandle,
- String name )
- throws AFSException;
-
- /**
- * Returns the next members that belongs to the group. Returns
- * null
if there are no more members.
- *
- * @param iterationId the iteration ID of this iteration
- * @see getGroupMembersBegin
- * @return the name of the next member
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getGroupMembersNextString( long iterationId )
- throws AFSException;
-
- /**
- * Fills the next user object belonging to that group. Returns 0 if there
- * are no more users, != 0 otherwise.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @see Cell#getCellHandle
- * @param iterationId the iteration ID of this iteration
- * @see getGroupMembersBegin
- * @param theUser a User object to be populated with the values of the
- * next user
- * @return 0 if there are no more users, != 0 otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getGroupMembersNext( long cellHandle,
- long iterationId,
- User theUser )
- throws AFSException;
-
- /**
- * Signals that the iteration is complete and will not be accessed anymore.
- *
- * @param iterationId the iteration ID of this iteration
- * @see getGroupMembersBegin
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getGroupMembersDone( long iterationId )
- throws AFSException;
-
- /**
- * Adds a user to the specified group.
- *
- * @param cellHandle the handle of the cell to which the group belongs
- * @see Cell#getCellHandle
- * @param groupName the name of the group to which to add a member
- * @param userName the name of the user to add
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void addMember( long cellHandle, String groupName,
- String userName )
- throws AFSException;
-
- /**
- * Removes a user from the specified group.
- *
- * @param cellHandle the handle of the cell to which the group belongs
- * @see Cell#getCellHandle
- * @param groupName the name of the group from which to remove a
- * member
- * @param userName the name of the user to remove
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void removeMember( long cellHandle, String groupName,
- String userName )
- throws AFSException;
-
- /**
- * Change the owner of the specified group.
- *
- * @param cellHandle the handle of the cell to which the group belongs
- * @see Cell#getCellHandle
- * @param groupName the name of the group of which to change the
- * owner
- * @param ownerName the name of the new owner
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void changeOwner( long cellHandle, String groupName,
- String ownerName )
- throws AFSException;
-
- /**
- * Change the name of the specified group.
- *
- * @param cellHandle the handle of the cell to which the group belongs
- * @see Cell#getCellHandle
- * @param oldGroupName the old name of the group
- * @param newGroupName the new name for the group
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void rename( long cellHandle, String oldGroupName,
- String newGroupName )
- throws AFSException;
-
- /**
- * Reclaims all memory being saved by the group portion of the native
- * library.
- * This method should be called when no more Groups
are expected
- * to be used.
- */
- protected static native void reclaimGroupMemory();
-}
-
-
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/Key.java b/src/JAVA/classes/org/openafs/jafs/Key.java
deleted file mode 100644
index e92988f8f7..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/Key.java
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * @(#)Key.java 1.0 6/29/2001
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-import java.util.GregorianCalendar;
-import java.util.Date;
-import java.io.Serializable;
-
-/**
- * An abstract representation of an AFS key. It holds information about
- * the key, such as what its version is.
- * Key
does not mean an actual
- * AFS key is created on a server -- usually a Key
- * object is a representation of an already existing AFS key. If,
- * however, the Key
is constructed with the version number of a
- * key that does not exist on the server represented by the provided
- * Server
, a new key with that version number can be
- * created on that server by calling the {@link #create(String)} methods If
- * such a key does already exist when this method is called,
- * an exception will be thrown.Key
object. It obtains the list of Key
s from
- * a specified server, and prints the string representation of each key.
- * - * import org.openafs.jafs.Cell; - * import org.openafs.jafs.AFSException; - * import org.openafs.jafs.Key; - * import org.openafs.jafs.Server; - * ... - * public class ... - * { - * ... - * private Cell cell; - * private Server server; - * ... - * public static void main(String[] args) throws Exception - * { - * String username = arg[0]; - * String password = arg[1]; - * String cellName = arg[2]; - * String serverName = arg[3]; - * - * token = new Token(username, password, cellName); - * cell = new Cell(token); - * server = new Server(serverName, cell); - * - * System.out.println("Keys in Server " + server.getName() + ":"); - * Key[] keys = server.getKeys(); - * for (int i = 0; i < keys.length; i++) { - * System.out.println(" -> " + keys[i] ); - * } - * } - * ... - * } - *- * - */ -public class Key implements Serializable, Comparable -{ - protected Server server; - - protected int version; - protected long checkSum; - protected String encryptionKey; - protected int lastModDate; - protected int lastModMs; - - protected GregorianCalendar lastModDateDate; - - protected boolean cachedInfo; - - /** - * Constructs a new
Key
object instance given the version of
- * the AFS key and the AFS server, represented by server
,
- * to which it belongs. This does not actually
- * create a new AFS key, it just represents one.
- * If version
is not an actual AFS key, exceptions
- * will be thrown during subsequent method invocations on this
- * object, unless the {@link #create(String)}
- * method is explicitly called to create it.
- *
- * @exception AFSException If an error occurs in the native code
- * @param version the version of the key to represent
- * @param server the server to which the key belongs.
- */
- public Key( int version, Server server ) throws AFSException
- {
- this.server = server;
- this.version = version;
-
- lastModDateDate = null;
-
- cachedInfo = false;
- }
-
- /**
- * Constructs a new Key
object instance given the version of
- * the AFS key and the AFS server, represented by server
,
- * to which it belongs. This does not actually
- * create a new AFS key, it just represents one.
- * If version
is not an actual AFS key, exceptions
- * will be thrown during subsequent method invocations on this
- * object, unless the {@link #create(String)}
- * method is explicitly called to create it. Note that if the key does not
- * 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 {@link #refresh()} method to address any coherency
- * concerns.
- *
- * @param version the version of the key to represent
- * @param server the server to which the key belongs.
- * @param preloadAllMembers true will ensure all object members are set
- * upon construction; otherwise members will be
- * set upon access, which is the default behavior.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh
- */
- public Key( int version, Server server, boolean preloadAllMembers )
- throws AFSException
- {
- this(version, server);
- if (preloadAllMembers) refresh(true);
- }
-
- /**
- * Creates a blank Key
given the server to which the key
- * belongs. This blank object can then be passed into other methods to
- * fill out its properties.
- *
- * @exception AFSException If an error occurs in the native code
- * @param server the server to which the key belongs.
- */
- Key( Server server ) throws AFSException
- {
- this( -1, server );
- }
-
- /*-------------------------------------------------------------------------*/
-
- /**
- * Refreshes the properties of this Key object instance with values from
- * the AFS key it represents. All properties that have been initialized
- * and/or accessed will be renewed according to the values of the AFS key
- * this Key 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.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void refresh() throws AFSException
- {
- refresh(false);
- }
-
- /**
- * Refreshes the properties of this Key object instance with values from
- * the AFS key it represents. If all
is true
- * then all of the properties of this Key object instance will be
- * set, or renewed, according to the values of the AFS key 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 {@link #refresh()} for more information.
- *
- * @param all if true set or renew all object properties; otherwise renew
- * all set properties
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- protected void refresh(boolean all) throws AFSException
- {
- if( all || cachedInfo ) {
- refreshInfo();
- }
- }
-
- /**
- * Refreshes the information fields of this Key
to reflect the
- * current state of the AFS server key. These inlclude the last
- * modification time, etc.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshInfo() throws AFSException
- {
- getKeyInfo( server.getBosHandle(), version, this );
- cachedInfo = true;
- lastModDateDate = null;
- }
-
- /**
- * Creates a key with this Key's
version number at the server,
- * using the specified String
for the key.
- *
- * @param keyString the string to use for the encryption key
- * @exception AFSException If an error occurs in the native code
- */
- public void create( String keyString ) throws AFSException
- {
- create( server.getCell().getCellHandle(), server.getBosHandle(), version,
- keyString );
- }
-
- /**
- * Removes the key with this Key's
version number from
- * the server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void delete( ) throws AFSException
- {
- delete( server.getBosHandle(), version );
-
- encryptionKey = null;
- cachedInfo = false;
- }
-
- //////////////// accessors: ////////////////////////
-
- /**
- * Returns the version of this key in primitive form.
- *
- * @return the version number of this key
- */
- public int getVersion()
- {
- return version;
- }
-
- /**
- * Returns the server this key is associated with.
- *
- * @return this key's server
- */
- public Server getServer()
- {
- return server;
- }
-
- /**
- * Returns the encrypted key as a string in octal form. This is how AFS
- * prints it out on the command line. An example would be:
- * '\040\205\211\241\345\002\023\211'.
- *
- * @return the encrypted key
- * @exception AFSException If an error occurs in the native code
- */
- public String getEncryptionKey() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return encryptionKey;
- }
-
- /**
- * Returns the check sum of this key.
- *
- * @return the check sum of this key
- * @exception AFSException If an error occurs in the native code
- */
- public long getCheckSum() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return checkSum;
- }
-
- /**
- * Returns the last modification date of this key.
- *
- * @return the last modification date of this key
- * @exception AFSException If an error occurs in the native code
- */
- public GregorianCalendar getLastModDate() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- if ( lastModDateDate == null && cachedInfo ) {
- // make it into a date . . .
- lastModDateDate = new GregorianCalendar();
- long longTime = ((long) lastModDate)*1000;
- Date d = new Date( longTime );
- lastModDateDate.setTime( d );
- }
- return lastModDateDate;
- }
-
- /////////////// information methods ////////////////////
-
- /**
- * Returns a String
representation of this Key
.
- * Contains the information fields.
- *
- * @return a String
representation of the Key
- */
- public String getInfo()
- {
- String r;
- try {
- r = "Key version number: " + getVersion() + "\n";
- r += "\tencrypted key: " + getEncryptionKey() + "\n";
- r += "\tcheck sum: " + getCheckSum() + "\n";
- r += "\tlast mod time: " + getLastModDate().getTime() + "\n";
- } catch( Exception e ) {
- return e.toString();
- }
- return r;
- }
-
- /////////////// override methods ////////////////////
-
- /**
- * Compares two Key objects respective to their key version and does not
- * factor any other attribute.
- *
- * @param key The Key object to be compared to this Key instance
- *
- * @return Zero if the argument is equal to this Key's version, a
- * value less than zero if this Key's version is less than
- * the argument, or a value greater than zero if this Key's
- * version is greater than the argument
- */
- public int compareTo(Key key)
- {
- return (this.getVersion() - key.getVersion());
- }
-
- /**
- * Comparable interface method.
- *
- * @see #compareTo(Key)
- */
- public int compareTo(Object obj)
- {
- return compareTo((Key)obj);
- }
-
- /**
- * Tests whether two Key
objects are equal, based on their
- * encryption key, version, and associated Server.
- *
- * @param otherKey the Key to test
- * @return whether the specifed Key is the same as this Key
- */
- public boolean equals( Key otherKey )
- {
- try {
- return ( this.getEncryptionKey().equals(otherKey.getEncryptionKey()) ) &&
- ( this.getVersion() == otherKey.getVersion() ) &&
- ( this.getServer().equals(otherKey.getServer()) );
- } catch (Exception e) {
- return false;
- }
- }
-
- /**
- * Returns the name of this Key
- *
- * @return the name of this Key
- */
- public String toString()
- {
- try {
- return getVersion() + " - " + getEncryptionKey() + " - " + getCheckSum();
- } catch (Exception e) {
- return e.toString();
- }
- }
-
- /////////////// native methods ////////////////////
-
- /**
- * Fills in the information fields of the provided Key
.
- *
- * @param serverHandle the bos handle of the server to which the key
- * belongs
- * @see Server#getBosServerHandle
- * @param version the version of the key for which to get the information
- * @param key the Key
object in which to fill in the
- * information
- * @see Server
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getKeyInfo( long serverHandle, int version,
- Key key )
- throws AFSException;
-
- /**
- * Create a server key.
- *
- * @param cellHandle the handle of the cell to which the server belongs
- * @see Cell#getCellHandle
- * @param serverHandle the bos handle of the server to which the key will
- * belong
- * @see Server#getBosServerHandle
- * @param versionNumber the version number of the key to create (0 to 255)
- * @param keyString the String
version of the key that will
- * be encrypted
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void create( long cellHandle, long serverHandle, int versionNumber, String keyString )
- throws AFSException;
-
- /**
- * Delete a server key.
- *
- * @param serverHandle the bos handle of the server to which the key belongs
- * @see Server#getBosServerHandle
- * @param versionNumber the version number of the key to remove (0 to 255)
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void delete( long serverHandle, int versionNumber )
- throws AFSException;
-
- /**
- * Reclaims all memory being saved by the key portion of the native library.
- * This method should be called when no more Key
objects are
- * expected to be
- * used.
- */
- protected static native void reclaimKeyMemory();
-
-}
-
-
-
-
-
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/PTSEntry.java b/src/JAVA/classes/org/openafs/jafs/PTSEntry.java
deleted file mode 100644
index db3a291738..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/PTSEntry.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * @(#)PTSEntry.java 1.2 10/23/2001
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-/**
- * An interface representation of a PTS entry as it applies to
- * AFS users and groups. This interface is implemented in both
- * {@link User} and {@link Group} object abstractions.
- *
- *
- *
- * @version 1.0, 3/31/02
- * @see User
- * @see Group
- */
-public interface PTSEntry
-{
- /**
- * Constant for {@link User} object implementers,
- * used with {@link #getType()}
- */
- public static final short PTS_USER = 0;
- /**
- * Constant for {@link Group} object implementers,
- * used with {@link #getType()}
- */
- public static final short PTS_GROUP = 1;
- /**
- * Returns the Cell this PTS user or group belongs to.
- *
- * @return the Cell this PTS user or group belongs to
- */
- public Cell getCell();
- /**
- * Returns the creator of this PTS user or group.
- *
- * @return the creator of this PTS user or group
- * @exception AFSException If an error occurs in the native code
- */
- public PTSEntry getCreator() throws AFSException;
- /**
- * Returns the name of this PTS user or group.
- *
- * @return the name of this PTS user or group
- */
- public String getName();
- /**
- * Returns the owner of this PTS user or group.
- *
- * @return the owner of this PTS user or group
- * @exception AFSException If an error occurs in the native code
- */
- public PTSEntry getOwner() throws AFSException;
- /**
- * Returns the type of PTS entry the implementing object represents.
- *
- *
Possible values are:
- *
{@link #PTS_USER}
- * -- a {@link User} object{@link #PTS_GROUP}
- * -- a {@link Group} objectPartition
does not mean
- * an actual AFS partition is created on a server -- on the contrary,
- * a Partition
object must be a representation of an already
- * existing AFS partition. There is no way to create a new AFS partition
- * through this API.Partition
object has its own individual set of
- * Volume
s. This represents the properties and attributes
- * of an actual AFS cell.Partition
object. In this example, a list of the
- * Partition
objects of a server are obtained, and the name
- * and number of volumes is printed out for each one.- * import org.openafs.jafs.Cell; - * import org.openafs.jafs.AFSException; - * import org.openafs.jafs.Partition; - * import org.openafs.jafs.Server; - * ... - * public class ... - * { - * ... - * private Cell cell; - * private Server server; - * ... - * public static void main(String[] args) throws Exception - * { - * String username = arg[0]; - * String password = arg[1]; - * String cellName = arg[2]; - * String serverName = arg[3]; - * - * token = new Token(username, password, cellName); - * cell = new Cell(token); - * server = new Server(serverName, cell); - * - * System.out.println("Partitions in Server " + server.getName() + ":"); - * Partition[] partitions = server.getPartitions(); - * for (int i = 0; i < partitions.length; i++) { - * System.out.print("Partition " + partitions[i].getName()); - * System.out.print("hosts " + partitions[i].getVolumeCount()); - * System.out.print("volumes.\n"); - * } - * } - * ... - * } - *- * - */ -public class Partition implements Serializable, Comparable -{ - protected Cell cell; - protected Server server; - - /* Populated by native method */ - protected String name; - - /* Populated by native method */ - protected int id; - - /* Populated by native method */ - protected String deviceName; - - /* Populated by native method */ - protected int lockFileDescriptor; - - /* Populated by native method */ - protected int totalSpace; - - /* Populated by native method */ - protected int totalFreeSpace; - - protected int totalQuota; - - protected ArrayList volumes; - protected ArrayList volumeNames; - - protected boolean cachedInfo; - - /** - * Constructs a new
Partition
object instance given the
- * name of the AFS partition and the AFS server, represented by
- * server
, to which it belongs. This does not actually
- * create a new AFS partition, it just represents an existing one.
- * If name
is not an actual AFS partition, exceptions
- * will be thrown during subsequent method invocations on this
- * object.
- *
- * @param name the name of the partition to represent
- * @param server the server on which the partition resides
- * @exception AFSException If an error occurs in the native code
- */
- public Partition( String name, Server server ) throws AFSException
- {
- this.name = name;
- this.server = server;
- this.cell = server.getCell();
-
- id = -1;
-
- volumes = null;
- volumeNames = null;
-
- cachedInfo = false;
- }
-
- /**
- * Constructs a new Partition
object instance given the name
- * of the AFS partition and the AFS server, represented by
- * server
, to which it belongs. This does not actually
- * create a new AFS partition, it just represents an existing one.
- * If name
is not an actual AFS partition, exceptions
- * will be thrown during subsequent method invocations on this
- * object.
- *
- * 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 {@link #refresh()} method to address any coherency
- * concerns.
- *
- * @param name the name of the partition to represent
- * @param server the server to which the partition belongs.
- * @param preloadAllMembers true will ensure all object members are
- * set upon construction;
- * otherwise members will be set upon access,
- * which is the default behavior.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh
- */
- public Partition( String name, Server server, boolean preloadAllMembers )
- throws AFSException
- {
- this(name, server);
- if (preloadAllMembers) refresh(true);
- }
-
- /**
- * Creates a blank Server
given the cell to which the partition
- * belongs and the server on which the partition resides. This blank
- * object can then be passed into other methods to fill out its properties.
- *
- * @exception AFSException If an error occurs in the native code
- * @param cell the cell to which the partition belongs.
- * @param server the server on which the partition resides
- */
- Partition( Server server ) throws AFSException
- {
- this( null, server );
- }
-
- /*-------------------------------------------------------------------------*/
-
- /**
- * Refreshes the properties of this Partition object instance with values
- * from the AFS partition
- * it represents. All properties that have been initialized and/or
- * accessed will be renewed according to the values of the AFS partition
- * this Partition 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.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void refresh() throws AFSException
- {
- refresh(false);
- }
-
- /**
- * Refreshes the properties of this Partition object instance with values
- * from the AFS partition it represents. If all
is
- * true
then all of the properties of this Partition
- * object instance will be set, or renewed, according to the values of the
- * AFS partition 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 {@link #refresh()} for more
- * information.
- *
- * @param all if true set or renew all object properties; otherwise
- * renew all set properties
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- protected void refresh(boolean all) throws AFSException
- {
- if (all || volumes != null) {
- refreshVolumes();
- }
- if (all || volumeNames != null) {
- refreshVolumeNames();
- }
- if (all || cachedInfo) {
- refreshInfo();
- }
- }
-
- /**
- * Refreshes the information fields of this Partition
to
- * reflect the current state of the AFS partition. These include total
- * free space, id, etc.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshInfo() throws AFSException
- {
- getPartitionInfo( cell.getCellHandle(), server.getVosHandle(), getID(),
- this );
- cachedInfo = true;
- }
-
- /**
- * Obtains the most current list of Volume
objects of this
- * partition.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshVolumes() throws AFSException
- {
- Volume currVolume;
-
- long iterationID = getVolumesBegin( cell.getCellHandle(),
- server.getVosHandle(), getID() );
-
- volumes = new ArrayList();
-
- currVolume = new Volume( this );
- while( getVolumesNext( iterationID, currVolume ) != 0 ) {
- volumes.add( currVolume );
- currVolume = new Volume( this );
- }
- getVolumesDone( iterationID );
- }
-
- /**
- * Obtains the most current list of volume names of this partition.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshVolumeNames() throws AFSException
- {
- String currName;
-
- long iterationID = getVolumesBegin( cell.getCellHandle(),
- server.getVosHandle(), getID() );
-
- volumeNames = new ArrayList();
-
- while( ( currName = getVolumesNextString( iterationID ) ) != null ) {
- volumeNames.add( currName );
- }
- getVolumesDone( iterationID );
- }
-
- /**
- * Syncs this partition to the VLDB.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void syncPartition() throws AFSException
- {
- server.syncServerWithVLDB( cell.getCellHandle(), server.getVosHandle(),
- getID() );
- }
-
- /**
- * Syncs the VLDB to this partition.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void syncVLDB() throws AFSException
- {
- server.syncVLDBWithServer( cell.getCellHandle(), server.getVosHandle(),
- getID(), false );
- }
-
- /**
- * Salvages (restores consistency to) this partition. Uses default values for
- * most salvager options in order to simplify the API.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void salvage() throws AFSException
- {
- server.salvage( cell.getCellHandle(), server.getBosHandle(), name, null,
- 4, null, null, false, false, false, false, false, false );
- }
-
- //////////////// accessors: ////////////////////////
-
- /**
- * Returns the name of this partition.
- *
- * @return the name of this partition
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Returns this partition's hosting server.
- *
- * @return this partition's server
- */
- public Server getServer()
- {
- return server;
- }
-
- /**
- * Returns the number of volumes contained in this partition.
- *
- *
If the total list of volumes or volume names have already been - * collected (see {@link #getVolumes()}), then the returning value will - * be calculated based upon the current list. Otherwise, AFS will be - * explicitly queried for the information. - * - *
The product of this method is not saved, and is recalculated
- * with every call.
- *
- * @return the number of volumes contained in this partition.
- * @exception AFSException If an error occurs in any
- * of the associated native methods
- */
- public int getVolumeCount() throws AFSException
- {
- if (volumes != null) {
- return volumes.size();
- } else if (volumeNames != null) {
- return volumeNames.size();
- } else {
- return getVolumeCount( cell.getCellHandle(),
- server.getVosHandle(), getID() );
- }
- }
-
- /**
- * Retrieves the Volume
object (which is an abstract
- * representation of an actual AFS volume of this partition) designated
- * by name
(i.e. "root.afs", etc.). If a volume by
- * that name does not actually exist in AFS on the partition
- * represented by this object, an {@link AFSException} will be
- * thrown.
- *
- * @exception AFSException If an error occurs in the native code
- * @exception NullPointerException If name
is
- * null
.
- * @param name the name of the volume to retrieve
- * @return Volume
designated by name
.
- */
- public Volume getVolume(String name) throws AFSException
- {
- if (name == null) throw new NullPointerException();
- Volume volume = new Volume(name, this);
- return volume;
- }
-
- /**
- * Retrieves an array containing all of the Volume
objects
- * associated with this Partition
, each of which is an
- * abstract representation of an actual AFS volume of the AFS partition.
- * After this method is called once, it saves the array of
- * Volume
s and returns that saved array on subsequent calls,
- * until the {@link #refresh()} method is called and a more current list
- * is obtained.
- *
- * @exception AFSException If an error occurs in the native code
- * @return a Volume
array of the Volume
- * objects of the partition.
- * @see #refresh()
- */
- public Volume[] getVolumes() throws AFSException
- {
- if (volumes == null) refreshVolumes();
- return (Volume[]) volumes.toArray( new Volume[volumes.size()] );
- }
-
- /**
- * Returns an array containing a subset of the Volume
objects
- * associated with this Partition
, each of which is an abstract
- * representation of an actual AFS volume of the AFS partition. The subset
- * is a point-in-time list of volumes (Volume
objects
- * representing AFS volumes) starting at the complete array's index of
- * startIndex
and containing up to length
- * elements.
- *
- * If length
is larger than the number of remaining elements,
- * respective to startIndex
, then this method will
- * ignore the remaining positions requested by length
and
- * return an array that contains the remaining number of elements found in
- * this partition's complete array of volumes.
- *
- *
This method is especially useful when managing iterations of very - * large lists. {@link #getVolumeCount()} can be used to determine if - * iteration management is practical. - * - *
This method does not save the resulting data and therefore - * queries AFS for each call. - * - *
Example: If there are more than 50,000 volumes within this partition - * then only render them in increments of 10,000. - *
- * ... - * Volume[] volumes; - * if (partition.getVolumeCount() > 50000) { - * int index = 0; - * int length = 10000; - * while (index < partition.getVolumeCount()) { - * volumes = partition.getVolumes(index, length); - * for (int i = 0; i < volumes.length; i++) { - * ... - * } - * index += length; - * ... - * } - * } else { - * volumes = partition.getVolumes(); - * for (int i = 0; i < volumes.length; i++) { - * ... - * } - * } - * ... - *- * - * @param startIndex the base zero index position at which the subset array - * should start from, relative to the complete list of - * elements present in AFS. - * @param length the number of elements that the subset should contain - * @return a subset array of volumes hosted by this partition - * @exception AFSException If an error occurs in the native code - * @see #getVolumeCount() - * @see #getVolumeNames(int, int) - * @see #getVolumes() - */ - public Volume[] getVolumes(int startIndex, int length) throws AFSException - { - Volume[] volumes = new Volume[length]; - Volume currVolume = new Volume( this ); - int i = 0; - - long iterationID = getVolumesBeginAt( cell.getCellHandle(), - server.getVosHandle(), getID(), startIndex ); - - while( getVolumesNext( iterationID, currVolume ) != 0 && i < length ) { - volumes[i] = currVolume; - currVolume = new Volume( this ); - i++; - } - getVolumesDone( iterationID ); - if (i < length) { - Volume[] v = new Volume[i]; - System.arraycopy(volumes, 0, v, 0, i); - return v; - } else { - return volumes; - } - } - - /** - * Retrieves an array containing all of the names of volumes - * associated with this
Partition
.
- * After this method is called once, it saves the array of
- * String
s and returns that saved array on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * list is obtained.
- *
- * @return a String
array of the volumes of the partition.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public String[] getVolumeNames() throws AFSException
- {
- if (volumeNames == null) refreshVolumeNames();
- return (String []) volumeNames.toArray( new String[volumeNames.size() ] );
- }
-
- /**
- * Returns an array containing a subset of the names of volumes
- * associated with this Partition
. The subset is a
- * point-in-time list of volume names starting at the complete array's
- * index of startIndex
and containing up to length
- * elements.
- *
- * If length
is larger than the number of remaining elements,
- * respective to startIndex
, then this method will
- * ignore the remaining positions requested by length
and
- * return an array that contains the remaining number of elements found in
- * this partition's complete array of volume names.
- *
- * This method is especially useful when managing iterations of very - * large lists. {@link #getVolumeCount()} can be used to determine if - * iteration management is practical. - * - *
This method does not save the resulting data and therefore - * queries AFS for each call. - * - *
Example: If there are more than 50,000 volumes within this partition - * then only render them in increments of 10,000. - *
- * ... - * String[] volumes; - * if (partition.getVolumeCount() > 50000) { - * int index = 0; - * int length = 10000; - * while (index < partition.getVolumeCount()) { - * volumes = partition.getVolumeNames(index, length); - * for (int i = 0; i < volumes.length; i++) { - * ... - * } - * index += length; - * ... - * } - * } else { - * volumes = partition.getVolumeNames(); - * for (int i = 0; i < volumes.length; i++) { - * ... - * } - * } - * ... - *- * - * @param startIndex the base zero index position at which the subset array - * should start from, relative to the complete list of - * elements present in AFS. - * @param length the number of elements that the subset should contain - * @return a subset array of volume names hosted by this partition - * @exception AFSException If an error occurs in the native code - * @see #getVolumeCount() - * @see #getVolumes(int, int) - * @see #getVolumes() - */ - public String[] getVolumeNames(int startIndex, int length) throws AFSException - { - String[] volumes = new String[length]; - String currName; - int i = 0; - - long iterationID = getVolumesBeginAt( cell.getCellHandle(), - server.getVosHandle(), getID(), startIndex ); - - while( ( currName = getVolumesNextString( iterationID ) ) != null && i < length ) { - volumes[i] = currName; - i++; - } - getVolumesDone( iterationID ); - if (i < length) { - String[] v = new String[i]; - System.arraycopy(volumes, 0, v, 0, i); - return v; - } else { - return volumes; - } - } - - /** - * Returns the id of this partition (i.e. "vicepa" = 0, etc.) - * - * @exception AFSException If an error occurs in the native code - * @return the id of this partition - */ - public int getID() throws AFSException - { - if (id == -1) id = translateNameToID( name ); - return id; - } - - /** - * Returns the device name of this partition (i.e. "hda5", etc.) - * - * @exception AFSException If an error occurs in the native code - * @return the device name of this partition - * @see #refresh() - */ - public String getDeviceName() throws AFSException - { - if (!cachedInfo) refreshInfo(); - return deviceName; - } - - /** - * Returns the lock file descriptor of this partition - * - * @exception AFSException If an error occurs in the native code - * @return the lock file descriptor of this partition - * @see #refresh() - */ - public int getLockFileDescriptor() throws AFSException - { - if (!cachedInfo) refreshInfo(); - return lockFileDescriptor; - } - - /** - * Returns the total space on this partition. - * - * @exception AFSException If an error occurs in the native code - * @return the total space on this partition - * @see #refresh() - */ - public int getTotalSpace() throws AFSException - { - if (!cachedInfo) refreshInfo(); - return totalSpace; - } - - /** - * Returns the total free space on this partition. - * After this method is called once, it saves the total free space - * and returns that value on subsequent calls, - * until the {@link #refresh()} method is called and a more current - * value is obtained. - * - * @exception AFSException If an error occurs in the native code - * @return the total free space on this partition - * @see #refresh() - */ - public int getTotalFreeSpace() throws AFSException - { - if (!cachedInfo) refreshInfo(); - return totalFreeSpace; - } - - /** - * Returns the total used space on this partition. - * After this method is called once, it saves the total used space - * and returns that value on subsequent calls, - * until the {@link #refresh()} method is called and a more current - * value is obtained. - * - * @exception AFSException If an error occurs in the native code - * @return the total used space on this partition - * @see #refresh() - */ - public int getUsedSpace() throws AFSException - { - if (!cachedInfo) refreshInfo(); - return (totalSpace - totalFreeSpace); - } - - /** - * Returns the total combined quota of all volumes on this partition, - * unless a volume has configured an unlimited quota at which case an - * {@link AFSException} is thrown. - * - *
After this method is called once, it saves the value and returns
- * that value on subsequent calls, until the {@link #refresh()}
- * method is called and a more current value is obtained.
- *
- * @exception AFSException If an error occurs while retrieving and
- * calculating, or a volume has an
- * unlimited quota.
- * @return the total combined quota of all volumes on this partition
- * @see #getTotalQuota(boolean)
- * @see #hasVolumeWithUnlimitedQuota()
- * @see Volume#getQuota()
- */
- public int getTotalQuota() throws AFSException
- {
- return getTotalQuota(false);
- }
-
- /**
- * Returns the total combined quota of all volumes on this partition,
- * ignoring volumes with unlimited quotas, if
- * ignoreUnlimitedQuotas
is true
; otherwise an
- * {@link AFSException} is thrown if a volume has an unlimited quota.
- *
- *
After this method is called once, it saves the value and returns
- * that value on subsequent calls, until the {@link #refresh()}
- * method is called and a more current value is obtained.
- *
- * @exception AFSException If an error occurs while retrieving and
- * calculating, or a volume has an
- * unlimited quota.
- * @return the total combined quota of all volumes on this partition
- * @see #getTotalQuota()
- * @see #hasVolumeWithUnlimitedQuota()
- * @see Volume#getQuota()
- * @see #refresh()
- */
- public int getTotalQuota(boolean ignoreUnlimitedQuotas)
- throws AFSException
- {
- if (volumes == null) refreshVolumes();
- if (totalQuota == 0 || !ignoreUnlimitedQuotas) {
- Volume[] volumes = getVolumes();
- for (int i = 0; i < volumes.length; i++) {
- try {
- totalQuota += volumes[i].getQuota();
- } catch (AFSException e) {
- if (!ignoreUnlimitedQuotas) {
- totalQuota = 0;
- throw e;
- }
- }
- }
- }
- return totalQuota;
- }
-
- /**
- * Tests whether this partition contains a volume that has an unlimited
- * quota configured.
- *
- * @exception AFSException If an error occurs in the native code
- * @return true
if a contained volume's quota is configured
- * as unlimited; otherwise false
.
- * @see #getTotalQuota()
- * @see #getTotalQuota(boolean)
- * @see Volume#isQuotaUnlimited()
- * @see Volume#getQuota()
- * @see #refresh()
- */
- public boolean hasVolumeWithUnlimitedQuota() throws AFSException
- {
- if (volumes == null) refreshVolumes();
- Volume[] volumes = getVolumes();
- for (int i = 0; i < volumes.length; i++) {
- if (volumes[i].isQuotaUnlimited()) return true;
- }
- return false;
- }
-
- /////////////// custom information methods ////////////////////
-
- /**
- * Returns a String
representation of this
- * Partition
. Contains the information fields and a list of
- * volumes.
- *
- * @return a String
representation of the Partition
- */
- public String getInfo()
- {
- String r;
-
- try {
-
- r = "Partition: " + name + "\tid: " + getID() + "\n";
-
- r += "\tDevice name: " + getDeviceName() + "\n";
- r += "\tLock file descriptor: " + getLockFileDescriptor() + "\n";
- r += "\tTotal free space: " + getTotalFreeSpace() + " K\n";
- r += "\tTotal space: " + getTotalSpace() + " K\n";
-
- r += "\tVolumes:\n";
-
- String vols[] = getVolumeNames();
-
- for( int i = 0; i < vols.length; i++ ) {
- r += "\t\t" + vols[i] + "\n";
- }
-
- } catch( Exception e ) {
- return e.toString();
- }
- return r;
- }
-
- /**
- * Returns a String
containing the String
- * representations of all the volumes of this Partition
.
- *
- * @return a String
representation of the volumes
- * @see Volume#getInfo
- */
- public String getInfoVolumes() throws AFSException
- {
- String r;
-
- r = "Partition: " + name + "\n\n";
- r += "--Volumes--\n";
-
- Volume vols[] = getVolumes();
- for( int i = 0; i < vols.length; i++ ) {
- r += vols[i].getInfo() + "\n";
- }
- return r;
- }
-
- /////////////// custom override methods ////////////////////
-
- /**
- * Compares two Partition objects respective to their names and does not
- * factor any other attribute. Alphabetic case is significant in
- * comparing names.
- *
- * @param partition The Partition object to be compared to
- * this Partition instance
- *
- * @return Zero if the argument is equal to this Partition's name, a
- * value less than zero if this Partition's name is
- * lexicographically less than the argument, or a value greater
- * than zero if this Partition's name is lexicographically
- * greater than the argument
- */
- public int compareTo(Partition partition)
- {
- return this.getName().compareTo(partition.getName());
- }
-
- /**
- * Comparable interface method.
- *
- * @see #compareTo(Partition)
- */
- public int compareTo(Object obj)
- {
- return compareTo((Partition)obj);
- }
-
- /**
- * Tests whether two Partition
objects are equal,
- * based on their names and hosting server.
- *
- * @param otherPartition the Partition to test
- * @return whether the specifed Partition is the same as this Partition
- */
- public boolean equals( Partition otherPartition )
- {
- return ( name.equals(otherPartition.getName()) ) &&
- ( getServer().equals(otherPartition.getServer()) );
- }
-
- /**
- * Returns the name of this Partition
- *
- * @return the name of this Partition
- */
- public String toString()
- {
- return getName();
- }
-
- /////////////// native methods ////////////////////
-
- /**
- * Fills in the information fields of the provided Partition
.
- *
- * @param cellHandle the handle of the cell to which the partition belongs
- * @see Cell#getCellHandle
- * @param serverHandle the vos handle of the server on which the
- * partition resides
- * @see Server#getVosServerHandle
- * @param partition the numeric id of the partition for which to get the
- * info
- * @param thePartition the {@link Partition Partition} object in which to
- * fill in the information
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getPartitionInfo( long cellHandle,
- long serverHandle,
- int partition,
- Partition thePartition )
- throws AFSException;
-
- /**
- * Returns the total number of volumes hosted by this partition.
- *
- * @param cellHandle the handle of the cell to which the partition belongs
- * @param serverHandle the vos handle of the server to which the partition
- * belongs
- * @param partition the numeric id of the partition on which the volumes
- * reside
- * @return total number of volumes hosted by this partition
- * @exception AFSException If an error occurs in the native code
- * @see Cell#getCellHandle
- * @see Server#getVosServerHandle
- */
- protected static native int getVolumeCount( long cellHandle,
- long serverHandle,
- int partition )
- throws AFSException;
-
- /**
- * Begin the process of getting the volumes on a partition. Returns
- * an iteration ID to be used by subsequent calls to
- * getVolumesNext
and getVolumesDone
.
- *
- * @param cellHandle the handle of the cell to which the partition belongs
- * @see Cell#getCellHandle
- * @param serverHandle the vos handle of the server to which the partition
- * belongs
- * @see Server#getVosServerHandle
- * @param partition the numeric id of the partition on which the volumes
- * reside
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- */
- protected static native long getVolumesBegin( long cellHandle,
- long serverHandle,
- int partition )
- throws AFSException;
-
- /**
- * Begin the process of getting the volumes on a partition. Returns
- * an iteration ID to be used by subsequent calls to
- * getVolumesNext
and getVolumesDone
.
- *
- * @param cellHandle the handle of the cell to which the partition belongs
- * @see Cell#getCellHandle
- * @param serverHandle the vos handle of the server to which the partition
- * belongs
- * @see Server#getVosServerHandle
- * @param partition the numeric id of the partition on which the volumes
- * reside
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- */
- protected static native long getVolumesBeginAt( long cellHandle,
- long serverHandle,
- int partition, int index )
- throws AFSException;
-
- /**
- * Returns the next volume of the partition. Returns null
- * if there are no more volumes.
- *
- * @param iterationId the iteration ID of this iteration
- * @see #getVolumesBegin
- * @return the name of the next volume of the server
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getVolumesNextString( long iterationId )
- throws AFSException;
-
- /**
- * Fills the next volume object of the partition. Returns 0 if there
- * are no more volumes, != 0 otherwise.
- *
- * @param iterationId the iteration ID of this iteration
- * @param theVolume the Volume object in which to fill the values
- * of the next volume
- * @see #getVolumesBegin
- * @return 0 if there are no more volumes, != 0 otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getVolumesNext( long iterationId,
- Volume theVolume )
- throws AFSException;
-
- /**
- * Fills the next volume object of the partition. Returns 0 if there
- * are no more volumes, != 0 otherwise.
- *
- * @param iterationId the iteration ID of this iteration
- * @param theVolume the Volume object in which to fill the values of the
- * next volume
- * @see #getVolumesBegin
- * @return 0 if there are no more volumes, != 0 otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getVolumesAdvanceTo( long iterationId,
- Volume theVolume,
- int advanceCount )
- throws AFSException;
-
- /**
- * Signals that the iteration is complete and will not be accessed anymore.
- *
- * @param iterationId the iteration ID of this iteration
- * @see #getVolumesBegin
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getVolumesDone( long iterationId )
- throws AFSException;
-
- /**
- * Translates a partition name into a partition id
- *
- * @param name the name of the partition in question
- * @return the id of the partition in question
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int translateNameToID( String name )
- throws AFSException;
-
- /**
- * Translates a partition id into a partition name
- *
- * @param id the id of the partition in question
- * @return the name of the partition in question
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String translateIDToName( int id )
- throws AFSException;
-
- /**
- * Reclaims all memory being saved by the partition portion of the native
- * library. This method should be called when no more Partition
- * objects are expected to be
- * used.
- */
- protected static native void reclaimPartitionMemory();
-}
-
-
-
-
-
-
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/Process.java b/src/JAVA/classes/org/openafs/jafs/Process.java
deleted file mode 100644
index 178be3df3c..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/Process.java
+++ /dev/null
@@ -1,953 +0,0 @@
-/*
- * @(#)Process.java 1.0 6/29/2001
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-import java.util.GregorianCalendar;
-import java.util.Date;
-import java.io.Serializable;
-
-/**
- * An abstract representation of an AFS process. It holds information about
- * the server, such as what its state is.
- *
- *
- * Constructing an instance of a Process
does not mean an actual
- * AFS process is created on a server -- usually a Process
- * object is a representation of an already existing AFS process. If,
- * however, the Process
is constructed with the name of a
- * process that does not exist in the server represented by the provided
- * Server
, a new process with that name can be
- * created on that server by calling one of the {@link #createSimple(String)},
- * {@link #createFS(String)}, or {@link #createCron(String,String)} methods. If
- * such a process does already exist when one of these methods are called,
- * an exception will be thrown.
- *
- *
- *
- *
- * The following is a simple example of how to construct and use a
- * Process
object. This example obtains the list of all
- * Process
objects on a particular server and prints out the
- * name of each one along with its start time.
- *
- *
- * import org.openafs.jafs.Cell; - * import org.openafs.jafs.AFSException; - * import org.openafs.jafs.Process; - * import org.openafs.jafs.Server; - * ... - * public class ... - * { - * ... - * private Cell cell; - * private Server server; - * ... - * public static void main(String[] args) throws Exception - * { - * String username = arg[0]; - * String password = arg[1]; - * String cellName = arg[2]; - * String serverName = arg[3]; - * - * token = new Token(username, password, cellName); - * cell = new Cell(token); - * server = new Server(serverName, cell); - * - * System.out.println("Processes in Server " + server.getName() + ":"); - * Process[] processes = server.getProcesss(); - * for (int i = 0; i < processes.length; i++) { - * System.out.print("Process " + processes[i].getName()); - * System.out.print("was started: " + - * processes[i].getStartTimeDate().getTime() + "\n"); - * } - * } - * ... - * } - *- * - */ -public class Process implements Serializable, Comparable -{ - /** - * Any standard type of process except for fs (such as kaserver, - * upclientbin, etc.) - */ - public static final int SIMPLE_PROCESS = 0; - - /** - * Combination of File Server, Volume Server, and Salvager processes - */ - public static final int FS_PROCESS = 1; - - /** - * A process that should be restarted at a specific time either daily - * or weekly. - */ - public static final int CRON_PROCESS = 2; - - /** - * Process execution state stopped - */ - public static final int STOPPED = 0; - - /** - * Process execution state running - */ - public static final int RUNNING = 1; - - /** - * Process execution state stopping - */ - public static final int STOPPING = 2; - - /** - * Process execution state starting - */ - public static final int STARTING = 3; - - protected String name; - protected Server server; - protected long serverHandle; - - protected int type; - protected int state; - protected int goal; - - protected long startTime; - protected long numberStarts; - protected long exitTime; - protected long exitErrorTime; - protected long errorCode; - protected long errorSignal; - - protected boolean stateOk; - protected boolean stateTooManyErrors; - protected boolean stateBadFileAccess; - - protected GregorianCalendar startTimeDate; - protected GregorianCalendar exitTimeDate; - protected GregorianCalendar exitErrorTimeDate; - - protected boolean cachedInfo; - - /** - * Constructs a new
Process
object instance given the name
- * of the AFS process and the AFS server, represented by
- * server
, to which it belongs. This does not actually
- * create a new AFS process, it just represents one.
- * If name
is not an actual AFS process, exceptions
- * will be thrown during subsequent method invocations on this
- * object, unless one of the {@link #createSimple(String)},
- * {@link #createFS(String)}, or {@link #createCron(String,String)}
- * methods are explicitly called to create it.
- *
- * @param name the name of the server to represent
- * @param server the server on which the process resides
- * @exception AFSException If an error occurs in the native code
- */
- public Process( String name, Server server ) throws AFSException
- {
- this.name = name;
- this.server = server;
- serverHandle = server.getBosHandle();
-
- startTimeDate = null;
- exitTimeDate = null;
- exitErrorTimeDate = null;
-
- cachedInfo = false;
- }
-
- /**
- * Constructs a new Process
object instance given the name
- * of the AFS process and the AFS server, represented by
- * server
, to which it belongs. This does not actually
- * create a new AFS process, it just represents one.
- * If name
is not an actual AFS process, exceptions
- * will be thrown during subsequent method invocations on this
- * object, unless one of the {@link #createSimple(String)},
- * {@link #createFS(String)}, or {@link #createCron(String,String)}
- * methods are explicitly called to create it. Note that if he 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 {@link #refresh()} method to address any coherency
- * concerns.
- *
- * @param name the name of the process to represent
- * @param server the server to which the process belongs.
- * @param preloadAllMembers true will ensure all object members are
- * set upon construction; otherwise members will
- * be set upon access, which is the default
- * behavior.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh
- */
- public Process( String name, Server server, boolean preloadAllMembers )
- throws AFSException
- {
- this(name, server);
- if (preloadAllMembers) refresh(true);
- }
-
- /**
- * Creates a blank Process
given the server to which the process
- * belongs. This blank object can then be passed into other methods to fill
- * out its properties.
- *
- * @param server the server to which the process belongs.
- * @exception AFSException If an error occurs in the native code
- */
- Process( Server server ) throws AFSException
- {
- this( null, server );
- }
-
- /*-------------------------------------------------------------------------*/
-
- /**
- * Refreshes the properties of this Process object instance with values
- * from the AFS process it represents. All properties that have been
- * initialized and/or accessed will be renewed according to the values of
- * the AFS process this Process 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.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void refresh() throws AFSException
- {
- refresh(false);
- }
-
- /**
- * Refreshes the properties of this Process object instance with values from
- * the AFS process it represents. If all
is true
- * then all of the properties of this Process object instance will be
- * set, or renewed, according to the values of the AFS process 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 {@link #refresh()} for more information.
- *
- * @param all if true set or renew all object properties; otherwise renew
- * all set properties
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- protected void refresh(boolean all) throws AFSException
- {
- if (all || cachedInfo) refreshInfo();
- }
-
- /**
- * Refreshes the information fields of this Process
to reflect
- * the current state of the AFS process, such as the start time, the state,
- * etc.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshInfo() throws AFSException
- {
- getProcessInfo( server.getBosHandle(), name, this );
- cachedInfo = true;
- startTimeDate = null;
- exitTimeDate = null;
- exitErrorTimeDate = null;
- }
-
- /**
- * Creates this process as a simple process on the server.
- *
- * @param executionPath the path to the process's executable
- * @exception AFSException If an error occurs in the native code
- */
- public void createSimple( String executionPath ) throws AFSException
- {
- create( server.getBosHandle(), name, SIMPLE_PROCESS, executionPath, null,
- null );
- }
-
- /**
- * Creates this process as a file server process on the server.
- *
- * @param executionPath the path to the process's executable
- * @exception AFSException If an error occurs in the native code
- */
- public void createFS( String executionPath ) throws AFSException
- {
- create( server.getBosHandle(), name, FS_PROCESS, executionPath, null,
- null );
- }
-
- /**
- * Creates this process as a cron process on the server.
- *
- * @param executionPath the path to the process's executable
- * @param cronTime a String representing the time a cron process is
- * to be run. Acceptable formats are:
null
value
- * indicates no start time.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return the start time
- * @exception AFSException If an error occurs in the native code
- */
- public long getStartTime() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return startTime;
- }
-
- /**
- * Returns the most recent start time of this process. A null
- * value indicates no start time.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return the start time
- * @exception AFSException If an error occurs in the native code
- */
- public GregorianCalendar getStartTimeDate() throws AFSException
- {
- if (!cachedInfo) {
- refreshInfo();
- }
- if( startTimeDate == null && startTime != 0 ) {
- // make it into a date . . .
- startTimeDate = new GregorianCalendar();
- long longTime = startTime * 1000;
- Date d = new Date( longTime );
- startTimeDate.setTime( d );
- }
- return startTimeDate;
- }
-
- /**
- * Returns the number of starts of the process.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return the number of starts
- * @exception AFSException If an error occurs in the native code
- */
- public long getNumberOfStarts() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return numberStarts;
- }
-
- /**
- * Returns the most recent exit time of this process. A null
- * value indicates no exit time.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return the exit time
- * @exception AFSException If an error occurs in the native code
- */
- public long getExitTime() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return exitTime;
- }
-
- /**
- * Returns the most recent exit time of this process. A null
- * value indicates no exit time
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return the exit time
- * @exception AFSException If an error occurs in the native code
- */
- public GregorianCalendar getExitTimeDate() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- if( exitTimeDate == null && exitTime != 0 ) {
- // make it into a date . . .
- exitTimeDate = new GregorianCalendar();
- long longTime = exitTime*1000;
- Date d = new Date( longTime );
- exitTimeDate.setTime( d );
- }
- return exitTimeDate;
- }
-
- /**
- * Returns the most recent time this process exited with an error. A
- * null
value indicates no exit w/ error time.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return the exit w/ error time
- * @exception AFSException If an error occurs in the native code
- */
- public long getExitErrorTime() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return exitErrorTime;
- }
-
- /**
- * Returns the most recent time this process exited with an error. A <
- * code>null value indicates no exit w/ error time.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return the exit w/ error time
- * @exception AFSException If an error occurs in the native code
- */
- public GregorianCalendar getExitErrorTimeDate() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- if (exitErrorTimeDate == null && exitErrorTime != 0) {
- // make it into a date . . .
- exitErrorTimeDate = new GregorianCalendar();
- long longTime = exitErrorTime*1000;
- Date d = new Date( longTime );
- exitErrorTimeDate.setTime( d );
- }
- return exitErrorTimeDate;
- }
-
- /**
- * Returns the error code of the process. A value of 0 indicates
- * no error code.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return the error code
- * @exception AFSException If an error occurs in the native code
- */
- public long getErrorCode() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return errorCode;
- }
-
- /**
- * Returns the error signal of the process. A value of 0 indicates no
- * error signal.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return the error signal
- * @exception AFSException If an error occurs in the native code
- */
- public long getErrorSignal() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return errorSignal;
- }
-
- /**
- * Returns whether or not the state of the process is ok. A value of
- * false
indicates there has been a core dump.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return whether or not the state is ok
- * @exception AFSException If an error occurs in the native code
- */
- public boolean getStateOk() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return stateOk;
- }
-
- /**
- * Returns whether or not the state of the process indicates too many errors.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return whether or not the state indicates too many errors
- * @exception AFSException If an error occurs in the native code
- */
- public boolean getStateTooManyErrors() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return stateTooManyErrors;
- }
-
- /**
- * Returns whether or not the state of the process indicates bad file access.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return whether or not the state indicates bad file access
- * @exception AFSException If an error occurs in the native code
- */
- public boolean getStateBadFileAccess() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return stateBadFileAccess;
- }
-
- /////////////// custom information methods ////////////////////
-
- /**
- * Returns a String
representation of this Process
.
- * Contains the information fields.
- *
- * @return a String
representation of the Process
- */
- public String getInfo()
- {
- String r;
- try {
-
- r = "Process: " + name + "\n";
-
- r += "\ttype: ";
- switch( getType() ) {
- case SIMPLE_PROCESS:
- r += "simple";
- break;
- case FS_PROCESS:
- r += "fs";
- break;
- case CRON_PROCESS:
- r += "cron";
- break;
- default:
- r += "other - " + getType();
- }
- r += "\n";
-
- r += "\tstate: ";
- switch( getState() ) {
- case STOPPED:
- r += "stopped";
- break;
- case RUNNING:
- r += "running";
- break;
- case STOPPING:
- r += "stopping";
- break;
- case STARTING:
- r += "starting";
- break;
- default:
- r += "other - " + getState();
- }
- r += "\n";
-
- r += "\tgoal: ";
- switch( getGoal() ) {
- case STOPPED:
- r += "stopped";
- break;
- case RUNNING:
- r += "running";
- break;
- case STOPPING:
- r += "stopping";
- break;
- case STARTING:
- r += "starting";
- break;
- default:
- r += "other - " + getGoal();
- }
- r += "\n";
-
- r += "\tstartTime: ";
- if( getStartTime() == 0) {
- r += "0";
- } else {
- r += getStartTimeDate().getTime();
- }
- r += "\n";
-
- r += "\tnumberStarts: " + getNumberOfStarts() + "\n";
-
- r += "\texitTime: ";
- if( getExitTime() == 0 ) {
- r += "0";
- } else {
- r += getExitTimeDate().getTime();
- }
- r += "\n";
-
- r += "\texitErrorTime: ";
- if( getExitErrorTimeDate() == null ) {
- r += "0";
- } else {
- r += getExitErrorTimeDate().getTime();
- }
- r += "\n";
-
- r += "\terrorCode: " + getErrorCode() + "\n";
- r += "\terrorSignal: " + getErrorSignal() + "\n";
- r += "\tstateOk: " + getStateOk() + "\n";
- r += "\tstateTooManyErrors: " + getStateTooManyErrors() + "\n";
- r += "\tstateBadFileAccess: " + getStateBadFileAccess() + "\n";
-
- } catch( Exception e ) {
- return e.toString();
- }
- return r;
- }
-
- /////////////// custom override methods ////////////////////
-
- /**
- * Compares two Process objects respective to their names and does not
- * factor any other attribute. Alphabetic case is significant in
- * comparing names.
- *
- * @param process The Process object to be compared to this Process
- * instance
- *
- * @return Zero if the argument is equal to this Process' name, a
- * value less than zero if this Process' name is
- * lexicographically less than the argument, or a value greater
- * than zero if this Process' name is lexicographically
- * greater than the argument
- */
- public int compareTo(Process process)
- {
- return this.getName().compareTo(process.getName());
- }
-
- /**
- * Comparable interface method.
- *
- * @see #compareTo(Process)
- */
- public int compareTo(Object obj)
- {
- return compareTo((Process)obj);
- }
-
- /**
- * Tests whether two Process
objects are equal, based on their
- * names and hosting server.
- *
- * @param otherProcess the Process to test
- * @return whether the specifed Process is the same as this Process
- */
- public boolean equals( Process otherProcess )
- {
- return ( name.equals(otherProcess.getName()) ) &&
- ( this.getServer().equals(otherProcess.getServer()) );
- }
-
- /**
- * Returns the name of this Process
- *
- * @return the name of this Process
- */
- public String toString()
- {
- return getName();
- }
-
- /////////////// native methods ////////////////////
-
- /**
- * Fills in the information fields of the provided Process
.
- *
- * @param cellHandle the handle of the cell to which the process belongs
- * @see Cell#getCellHandle
- * @param processName the instance name of the process for which to get
- * the information
- * @param theProcess the {@link Process Process} object in which to fill
- * in the information
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getProcessInfo( long cellHandle,
- String processName,
- Process theProcess )
- throws AFSException;
-
- /**
- * Creates a processes on a server.
- *
- * @param serverHandle the bos handle of the server to which the key will
- * belong
- * @see Server#getBosServerHandle
- * @param processName the instance name to give the process. See AFS
- * documentation for a standard list of instance names
- * @param processType the type of process this will be.
- * Acceptable values are:null
for non-cron processes.
- * @param notifier the execution path to a notifier program that should
- * be called when the process terminates. Can be
- * null
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void create( long serverHandle, String processName,
- int processType, String executionPath,
- String cronTime, String notifier )
- throws AFSException;
-
- /**
- * Removes a process from a server.
- *
- * @param serverHandle the bos handle of the server to which the process
- * belongs
- * @see Server#getBosServerHandle
- * @param processName the name of the process to remove
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void delete( long serverHandle, String processName )
- throws AFSException;
-
- /**
- * Start this process.
- *
- * @param serverHandle the bos handle of the server to which the process
- * belongs
- * @see Server#getBosServerHandle
- * @param processName the name of the process to start
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void start( long serverHandle, String processName )
- throws AFSException;
-
- /**
- * Retart this process.
- *
- * @param serverHandle the bos handle of the server to which the process
- * belongs
- * @see Server#getBosServerHandle
- * @param processName the name of the process to restart
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void restart( long serverHandle, String processName )
- throws AFSException;
-
- /**
- * Stop this process.
- *
- * @param serverHandle the bos handle of the server to which the process
- * belongs
- * @see Server#getBosServerHandle
- * @param processName the name of the process to stop
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void stop( long serverHandle, String processName )
- throws AFSException;
-
- /**
- * Reclaims all memory being saved by the process portion of the native
- * library. This method should be called when no more Process
- * objects are expected to be used.
- */
- protected static native void reclaimProcessMemory();
-}
-
-
-
-
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/Server.java b/src/JAVA/classes/org/openafs/jafs/Server.java
deleted file mode 100644
index 1f826e975f..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/Server.java
+++ /dev/null
@@ -1,2357 +0,0 @@
-/*
- * @(#)Server.java 1.0 6/29/2001
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-import java.io.Serializable;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-
-/**
- * An abstract representation of an AFS server. It holds information about
- * the server, such as what its processes are.
- * Server
does not mean an actual
- * AFS server is created and added to a cell -- on the contrary, a
- * Server
object must be a representation of an already existing
- * AFS server. There is no way to create a new AFS server through this API.
- * See OpenAFS.org for information on how
- * to create a new AFS server.Server
object may represent either an AFS file server,
- * an AFS database server, or both if the same machine serves both
- * purposes.Server
object has its own individual set of
- * Partition
s, Process
es, and Key
s.
- * This represents the properties and attributes of an actual AFS server.
- * Server
using the
- * Cell
representing teh AFS cell to which the server belongs,
- * and prints out the names of all the partitions residing on the server.
- * - * import org.openafs.jafs.Cell; - * import org.openafs.jafs.AFSException; - * import org.openafs.jafs.Partition; - * import org.openafs.jafs.Server; - * ... - * public class ... - * { - * ... - * private Cell cell; - * private Server server; - * ... - * public static void main(String[] args) throws Exception - * { - * String username = arg[0]; - * String password = arg[1]; - * String cellName = arg[2]; - * String serverName = arg[3]; - * - * token = new Token(username, password, cellName); - * cell = new Cell(token); - * server = new Server(serverName, cell); - * - * System.out.println("Partitions in Server " + server.getName() + ":"); - * if( server.isFileServer() ) { - * Partition[] partitions = server.getPartitions(); - * for (int i = 0; i < partitions.length; i++) { - * System.out.println(" -> " + partitions[i]); - * } - * } - * } - * ... - * } - *- * - */ -public class Server implements Serializable, Comparable -{ - /** - * Used for binary restart time types. - */ - private static final int RESTART_BINARY = 0; - - /** - * Used for general restart time types. - */ - private static final int RESTART_GENERAL = 1; - - protected String name; - protected Cell cell; - - protected long vosHandle; - protected long bosHandle; - - protected boolean database; - protected boolean fileServer; - - // these will be true if the machine is supposedly listed as a server - // but that's wrong, or the machine is down - protected boolean badFileServer; - protected boolean badDatabase; - - // String IP Address of address[0] - protected String[] ipAddresses; - - protected ArrayList partitionNames; - protected ArrayList partitions; - protected ArrayList adminNames; - protected ArrayList admins; - protected ArrayList keys; - protected ArrayList processNames; - protected ArrayList processes; - - // Storage information - protected int totalSpace; - protected int totalQuota; - protected int totalFreeSpace; - protected int totalUsedSpace; - - protected ExecutableTime genRestartTime; - protected ExecutableTime binRestartTime; - - protected boolean cachedInfo; - - /** - * Constructs a new
Server
object instance given the
- * name of the AFS server and the AFS cell, represented by
- * cell
, to which it belongs. This does not actually
- * create a new AFS server, it just represents an existing one.
- * If name
is not an actual AFS server, exceptions
- * will be thrown during subsequent method invocations on this
- * object.
- *
- * @param name the name of the server to represent
- * @param cell the cell to which the server belongs.
- * @exception AFSException If an error occurs in the native code
- */
- public Server( String name, Cell cell ) throws AFSException
- {
- this.name = name;
- this.cell = cell;
-
- cachedInfo = false;
-
- vosHandle = 0;
- bosHandle = 0;
-
- ipAddresses = new String[16];
-
- partitionNames = null;
- partitions = null;
- adminNames = null;
- admins = null;
- keys = null;
- processNames = null;
- processes = null;
- }
-
- /**
- * Constructs a new Server
object instance given the name
- * of the AFS server and the AFS cell, represented by cell
,
- * to which it belongs. This does not actually
- * create a new AFS server, it just represents an existing one.
- * If name
is not an actual AFS server, exceptions
- * will be thrown during subsequent method invocations on this
- * object.
- *
- * 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 {@link #refresh()} method to address any
- * coherency concerns.
- *
- * @param name the name of the server to represent
- * @param cell the cell to which the server belongs.
- * @param preloadAllMembers true will ensure all object members are
- * set upon construction;
- * otherwise members will be set upon access,
- * which is the default behavior.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh
- */
- public Server( String name, Cell cell, boolean preloadAllMembers )
- throws AFSException
- {
- this(name, cell);
- if (preloadAllMembers) refresh(true);
- }
-
- /**
- * Constructs a blank Server
object instance given the cell to
- * which the server belongs. This blank object can then be passed into
- * other methods to fill out its properties.
- *
- * @param cell the cell to which the server belongs.
- * @exception AFSException If an error occurs in the native code
- */
- Server( Cell cell ) throws AFSException
- {
- this( null, cell );
- }
-
- /*-------------------------------------------------------------------------*/
-
- /**
- * Refreshes the properties of this Server object instance with values
- * from the AFS server it represents. All properties that have been
- * initialized and/or accessed will be renewed according to the values
- * of the AFS server this Server 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.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void refresh() throws AFSException
- {
- refresh(false);
- }
-
- /**
- * Refreshes the properties of this Server object instance with values
- * from the AFS server it represents. If all
is
- * true
then all of the properties of this Server
- * object instance will be set, or renewed, according to the values of the
- * AFS server 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 {@link #refresh()} for more information.
- *
- * @param all if true set or renew all object properties;
- * otherwise renew all set properties
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- protected void refresh(boolean all) throws AFSException
- {
- if ( all ) {
- refreshProcesses();
- refreshProcessNames();
- refreshKeys();
- refreshAdminNames();
- refreshAdmins();
- refreshPartitionNames();
- refreshPartitions(all);
- refreshInfo();
- refreshGeneralRestart();
- refreshBinaryRestart();
- } else {
- if ( processes != null ) refreshProcesses();
- if ( processNames != null ) refreshProcessNames();
- if ( keys != null ) refreshKeys();
- if ( adminNames != null ) refreshAdminNames();
- if ( admins != null ) refreshAdmins();
- if ( partitionNames != null ) refreshPartitionNames();
- if ( partitions != null ) refreshPartitions(all);
- if ( genRestartTime != null ) refreshGeneralRestart();
- if ( binRestartTime != null ) refreshBinaryRestart();
- if ( cachedInfo ) refreshInfo();
- }
- }
-
- /**
- * Refreshes the information fields of this Server
to
- * reflect the current state of the AFS server. These fields include
- * the IP addresses and the fileserver types.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshInfo() throws AFSException
- {
- getServerInfo( cell.getCellHandle(), name, this );
- cachedInfo = true;
- }
-
- /**
- * Refreshes the general restart time fields of this Server
- * to reflect the current state of the AFS server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshGeneralRestart() throws AFSException
- {
- if (genRestartTime == null) genRestartTime = new ExecutableTime();
- getRestartTime( getBosHandle(), RESTART_GENERAL, genRestartTime );
- }
-
- /**
- * Refreshes the binary restart time fields of this Server
- * to reflect the current state of the AFS server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshBinaryRestart() throws AFSException
- {
- if (binRestartTime == null) binRestartTime = new ExecutableTime();
- getRestartTime( getBosHandle(), RESTART_BINARY, binRestartTime );
- }
-
- /**
- * Obtains the most current list of Partition
objects
- * of this server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshPartitions() throws AFSException
- {
- this.refreshPartitions(false);
- }
-
- /**
- * Obtains the most current list of Partition
objects of
- * this server.
- *
- * @param refreshVolumes force all volumes contained in each
- * partition to be refreshed.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshPartitions(boolean refreshVolumes)
- throws AFSException
- {
- if (!isFileServer() || isBadFileServer()) return;
-
- Partition currPartition;
-
- long iterationID = getPartitionsBegin( cell.getCellHandle(),
- getVosHandle() );
-
- partitions = new ArrayList();
-
- currPartition = new Partition( this );
- while( getPartitionsNext( iterationID, currPartition ) != 0 ) {
- //Only volumes are necessary since volume information
- //is populated at time of construction
- if (refreshVolumes) currPartition.refreshVolumes();
- partitions.add( currPartition );
- currPartition = new Partition( this );
- }
- getPartitionsDone( iterationID );
- totalSpace = 0;
- totalQuota = 0;
- totalUsedSpace = 0;
- totalFreeSpace = 0;
- }
-
- /**
- * Obtains the most current list of partition names of this server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshPartitionNames() throws AFSException
- {
- if (!isFileServer() || isBadFileServer()) return;
-
- String currName;
-
- long iterationID = getPartitionsBegin( cell.getCellHandle(),
- getVosHandle() );
-
- partitionNames = new ArrayList();
-
- while( ( currName = getPartitionsNextString( iterationID ) ) != null ) {
- partitionNames.add( currName );
- }
- getPartitionsDone( iterationID );
- }
-
- /**
- * Obtains the most current list of bos admin names of this server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshAdminNames() throws AFSException
- {
- String currName;
-
- long iterationID = getBosAdminsBegin( getBosHandle() );
-
- adminNames = new ArrayList();
-
- while( ( currName = getBosAdminsNextString( iterationID ) ) != null ) {
- adminNames.add( currName );
- }
- getBosAdminsDone( iterationID );
- }
-
- /**
- * Obtains the most current list of admin User
objects of
- * this server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshAdmins() throws AFSException
- {
- User currUser;
-
- long iterationID = getBosAdminsBegin( getBosHandle() );
-
- admins = new ArrayList();
-
- currUser = new User( cell );
- while( getBosAdminsNext( cell.getCellHandle(), iterationID, currUser )
- != 0 ) {
- admins.add( currUser );
- currUser = new User( cell );
- }
- getBosAdminsDone( iterationID );
- }
-
- /**
- * Obtains the most current list of Key
objects of this server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshKeys() throws AFSException
- {
- Key currKey;
-
- long iterationID = getKeysBegin( getBosHandle() );
-
- keys = new ArrayList();
-
- currKey = new Key( this );
- while( getKeysNext( iterationID, currKey ) != 0 ) {
- keys.add( currKey );
- currKey = new Key( this );
- }
- getKeysDone( iterationID );
- }
-
- /**
- * Obtains the most current list of process names of this server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshProcessNames() throws AFSException
- {
- String currName;
-
- long iterationID = getProcessesBegin( getBosHandle() );
-
- processNames = new ArrayList();
-
- while( ( currName = getProcessesNextString( iterationID ) ) != null ) {
- processNames.add( currName );
- }
- getProcessesDone( iterationID );
- }
-
- /**
- * Obtains the most current list of Process
objects of
- * this server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshProcesses() throws AFSException
- {
- Process currProcess;
-
- long iterationID = getProcessesBegin( getBosHandle() );
-
- processes = new ArrayList();
-
- currProcess = new Process( this );
- while( getProcessesNext( getBosHandle(), iterationID, currProcess )
- != 0 ) {
- processes.add( currProcess );
- currProcess = new Process( this );
- }
- getProcessesDone( iterationID );
- }
-
- /**
- * Add a bos admin to the UserList file of this server, in order to
- * given the AFS user represented by admin
full bos
- * administrative privileges on this server.
- *
- * @param admin the admin to add
- * @exception AFSException If an error occurs in the native code
- */
- public void addAdmin( User admin ) throws AFSException
- {
- String adminName = admin.getName();
-
- addBosAdmin( getBosHandle(), adminName );
- if ( adminNames != null ) {
- adminNames.add( adminName );
- }
- }
-
- /**
- * Remove a bos admin from the UserList file of this server, in order to
- * take away from the AFS user represented by admin
bos
- * administrative privileges on this machine.
- *
- * @param admin the admin to remove
- * @exception AFSException If an error occurs in the native code
- */
- public void removeAdmin( User admin ) throws AFSException
- {
- String adminName = admin.getName();
-
- removeBosAdmin( getBosHandle(), adminName );
- if ( adminNames != null ) {
- adminNames.remove( adminNames.indexOf( adminName ) );
- adminNames.trimToSize();
- }
- }
-
- /**
- * Syncs this server to the VLDB.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void syncServer() throws AFSException
- {
- syncServerWithVLDB( cell.getCellHandle(), getVosHandle(), -1 );
- }
-
- /**
- * Syncs the VLDB to this server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void syncVLDB() throws AFSException
- {
- syncVLDBWithServer( cell.getCellHandle(), getVosHandle(), -1, false );
- }
-
- /**
- * Salvages (restores consistency to) this server. Uses default values for
- * most salvager options in order to simplify the API.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void salvage() throws AFSException
- {
- salvage( cell.getCellHandle(), getBosHandle(), null, null, 4, null, null,
- false, false, false, false, false, false );
- }
-
- /**
- * Starts up all bos processes on this server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void startAllProcesses() throws AFSException
- {
- startAllProcesses( getBosHandle() );
- }
-
- /**
- * Stops all bos processes on this server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void stopAllProcesses() throws AFSException
- {
- stopAllProcesses( getBosHandle() );
- }
-
- /**
- * Restarts all bos processes on this server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void restartAllProcesses() throws AFSException
- {
- restartAllProcesses( getBosHandle(), false );
- }
-
- /**
- * Restarts bos server and all bos processes on this server.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void restartBosServer() throws AFSException
- {
- restartAllProcesses( getBosHandle(), true );
- }
-
- /**
- * Gets the contents of a log file, in one large String
.
- * The log cannot be in AFS file space.
- *
- * @return a String
containing the contents of the log file
- * @exception AFSException If an error occurs in the native code
- */
- public String getLog( String logLocation ) throws AFSException
- {
- return getLog( getBosHandle(), logLocation );
- }
-
- /**
- * Unauthenticates all server-related tokens that have been obtained by
- * this Server
object, and shuts this server object down.
- * This method should only be called when this Server
or any
- * of the objects constructed using this Server
will not be
- * used anymore. Note that this does not effect the actual AFS server;
- * it merely closes the representation.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void close() throws AFSException
- {
- if ( vosHandle != 0 ) {
- closeVosServerHandle( vosHandle );
- }
- if ( bosHandle != 0 ) {
- closeBosServerHandle( bosHandle );
- }
-
- cachedInfo = false;
-
- vosHandle = 0;
- bosHandle = 0;
-
- partitionNames = null;
- partitions = null;
- adminNames = null;
- admins = null;
- keys = null;
- processNames = null;
- processes = null;
- }
-
- //////////////// accessors: ////////////////////////
-
- /**
- * Returns the name of this server.
- *
- * @return the name of this server
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Returns the Cell
object with which this Server
- * was constructed. It represents the actual AFS cell to which this
- * server belongs.
- *
- * @return this server's cell
- */
- public Cell getCell()
- {
- return cell;
- }
-
- /**
- * Returns the number of BOS administrators assigned to this server.
- *
- *
If the total list of admins or admin names have already been - * collected (see {@link #getAdmins()}), then the returning value will - * be calculated based upon the current list. Otherwise, AFS will be - * explicitly queried for the information. - * - *
The product of this method is not saved, and is recalculated
- * with every call.
- *
- * @return the number of admins on this server.
- * @exception AFSException If an error occurs
- * in any of the associated native methods
- * @see #getAdmins()
- * @see #getAdminNames()
- */
- public int getAdminCount() throws AFSException
- {
- if (adminNames != null) {
- return adminNames.size();
- } else if (admins != null) {
- return admins.size();
- } else {
- return getBosAdminCount(getBosHandle());
- }
- }
-
- /**
- * Retrieves an array containing all of the admin User
objects
- * associated with this Server
, each of which are an abstract
- * representation of an actual bos administrator of the AFS server.
- * After this method is called once, it saves the array of
- * User
s and returns that saved array on subsequent calls,
- * until the {@link #refresh()} method is called and a more current list
- * is obtained.
- *
- * @return a User
array of the admins of the server.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public User[] getAdmins() throws AFSException
- {
- if ( admins == null ) refreshAdmins();
- return (User[]) admins.toArray( new User[admins.size()] );
- }
-
- /**
- * Retrieves an array containing all of the names of bos admins
- * associated with this Server
. After this method
- * is called once, it saves the array of String
s and returns
- * that saved array on subsequent calls, until the {@link #refresh()} method
- * is called and a more current list is obtained.
- *
- * @return a String
array of the bos admin of the server.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public String[] getAdminNames() throws AFSException
- {
- if ( adminNames == null ) refreshAdminNames();
- return (String []) adminNames.toArray( new String[adminNames.size()] );
- }
-
- /**
- * Returns the number of partitions on this server.
- *
- *
If the total list of partitions or partition names have already been - * collected (see {@link #getPartitions()}), then the returning value will - * be calculated based upon the current list. Otherwise, AFS will be - * explicitly queried for the information. - * - *
The product of this method is not saved, and is recalculated
- * with every call.
- *
- * @return the number of partitions on this server.
- * @exception AFSException If an error occurs
- * in any of the associated native methods
- * @see #getPartitions()
- * @see #getPartitionNames()
- */
- public int getPartitionCount() throws AFSException
- {
- if (partitionNames != null) {
- return partitionNames.size();
- } else if (partitions != null) {
- return partitions.size();
- } else {
- return getPartitionCount(cell.getCellHandle(), getVosHandle());
- }
- }
-
- /**
- * Retrieves the Partition
object (which is an abstract
- * representation of an actual AFS partition of this server) designated
- * by name
(i.e. "/vicepa", etc.). If a partition by
- * that name does not actually exist in AFS on the server
- * represented by this object, an {@link AFSException} will be
- * thrown.
- *
- * @param name the name of the partition to retrieve
- * @return Partition
designated by name
.
- * @exception AFSException If an error occurs in the native code
- * @exception NullPointerException If name
is
- * null
.
- */
- public Partition getPartition(String name) throws AFSException
- {
- if (name == null) throw new NullPointerException();
- if (isFileServer() && !isBadFileServer()) {
- Partition partition = new Partition(name, this);
- partition.refresh(true);
- return partition;
- } else {
- //Throw "No such entry" error
- throw new AFSException("Server is not a file server.", 363524);
- }
- }
-
- /**
- * Retrieves an array containing all of the Partition
objects
- * associated with this Server
, each of which are an abstract
- * representation of an actual AFS partition of the AFS server.
- * After this method is called once, it saves the array of
- * Partition
s and returns that saved array on subsequent calls,
- * until the {@link #refresh()} method is called and a more current list
- * is obtained.
- *
- * @return a Partition
array of the Partition
- * objects of the server.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public Partition[] getPartitions() throws AFSException
- {
- if ( partitions == null ) refreshPartitions();
- if ( partitions != null) {
- return (Partition []) partitions.toArray( new Partition[partitions.size()] );
- } else {
- return null;
- }
- }
-
- /**
- * Retrieves an array containing all of the names of partitions
- * associated with this Server
(i.e. "vicepa", etc.).
- * After this method is called once, it saves the array of
- * String
s and returns that saved array on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * list is obtained.
- *
- * @return a String
array of the partitions of the server.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public String[] getPartitionNames() throws AFSException
- {
- if ( partitionNames == null ) refreshPartitionNames();
- return (String [])
- partitionNames.toArray( new String[partitionNames.size()] );
- }
-
- /**
- * Retrieves the Key
object (which is an abstract
- * representation of an actual AFS partition of this server) designated
- * by nkeyVersion
. If a key with
- * that version does not actually exist in AFS on the server
- * represented by this object, null
is returned.
- *
- * @param keyVersion the version of the key to retrieve
- * @return Key
designated by keyVersion
.
- * @exception AFSException If an error occurs in the native code
- */
- public Key getKey(int keyVersion) throws AFSException
- {
- try {
- Key[] keys = this.getKeys();
- for (int i = 0; i < keys.length; i++) {
- if (keys[i].getVersion() == keyVersion) {
- return keys[i];
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * Returns the number of keys on this server.
- *
- *
If the total list of keys has already been - * collected (see {@link #getKeys()}), then the returning value will - * be calculated based upon the current list. Otherwise, AFS will be - * explicitly queried for the information. - * - *
The product of this method is not saved, and is recalculated
- * with every call.
- *
- * @return the number of keys on this server.
- * @exception AFSException If an error occurs
- * in any of the associated native methods
- * @see #getKeys()
- */
- public int getKeyCount() throws AFSException
- {
- if (keys != null) {
- return keys.size();
- } else {
- return getKeyCount(getBosHandle());
- }
- }
-
- /**
- * Retrieves an array containing all of the Key
objects
- * associated with this Server
, each of which are an abstract
- * representation of an actual AFS key of the AFS server.
- * After this method is called once, it saves the array of
- * Key
s and returns that saved array on subsequent calls,
- * until the {@link #refresh()} method is called and a more current list
- * is obtained.
- *
- * @return a Key
array of the Key
objects
- * of the server.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public Key[] getKeys() throws AFSException
- {
- if ( keys == null ) refreshKeys();
- return (Key[]) keys.toArray( new Key[keys.size()] );
- }
-
- /**
- * Retrieves the Process
object (which is an abstract
- * representation of an actual AFS process of this server) designated
- * by name
(i.e. "kaserver", etc.). If a process by
- * that name does not actually exist in AFS on the server
- * represented by this object, an {@link AFSException} will be
- * thrown.
- *
- * @param name the name of the process to retrieve
- * @return Process
designated by name
.
- * @exception AFSException If an error occurs in the native code
- * @exception NullPointerException If name
is
- * null
.
- */
- public Process getProcess(String name) throws AFSException
- {
- if (name == null) throw new NullPointerException();
- //if (isFileServer() && !isBadFileServer()) {
- Process process = new Process(name, this);
- process.refresh(true);
- return process;
- //}
- }
-
- /**
- * Returns the number of processes hosted by this server.
- *
- *
If the total list of processes or process names have already been - * collected (see {@link #getProcesses()}), then the returning value will - * be calculated based upon the current list. Otherwise, AFS will be - * explicitly queried for the information. - * - *
The product of this method is not saved, and is recalculated
- * with every call.
- *
- * @return the number of processes on this server.
- * @exception AFSException If an error occurs
- * in any of the associated native methods
- * @see #getProcesses()
- * @see #getProcessNames()
- */
- public int getProcessCount() throws AFSException
- {
- if (processNames != null) {
- return processNames.size();
- } else if (processes != null) {
- return processes.size();
- } else {
- return getProcessCount(getBosHandle());
- }
- }
-
- /**
- * Retrieves an array containing all of the Process
objects
- * associated with this Server
, each of which are an abstract
- * representation of an actual AFS process of the AFS server.
- * After this method is called once, it saves the array of
- * Process
es and returns that saved array on subsequent calls,
- * until the {@link #refresh()} method is called and a more current list
- * is obtained.
- *
- * @return a Process
array of the Process
- * objects of the server.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public Process[] getProcesses() throws AFSException
- {
- if ( processes == null ) refreshProcesses();
- if ( processes != null) {
- return (Process[]) processes.toArray( new Process[processes.size()] );
- }
- return null;
- }
-
- /**
- * Retrieves an array containing all of the names of processes
- * associated with this Server
(i.e. "kaserver", etc.).
- * After this method is called once, it saves the array of
- * String
s and returns that saved array on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * list is obtained.
- *
- * @return a String
array of the processes of the server.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public String[] getProcessNames() throws AFSException
- {
- if ( processNames == null ) refreshProcessNames();
- return (String[]) processNames.toArray( new String[processNames.size()] );
- }
-
- /**
- * Returns whether or not this server is a database machine, meaning it runs
- * processes such as the "kaserver" and "vlserver", and participates in
- * elections.
- *
- * @return whether or not this user this server is a database machine.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public boolean isDatabase() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return database;
- }
-
- /**
- * Returns whether or not this server is a file server machine, meaning it
- * runs the "fs" process and stores AFS volumes.
- *
- * @return whether or not this user this server is a file server machine.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public boolean isFileServer() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return fileServer;
- }
-
- /**
- * Returns whether or not this server is a database machine AND
- * either it isn't in reality (e.g. it's incorrectly configured)
- * or it's currently down.
- *
- * @return whether or not this server is a database machine
- * AND either it isn't in reality or it's currently down
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public boolean isBadDatabase() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return badDatabase;
- }
-
- /**
- * Returns whether this machine thinks it's a file server AND
- * either it isn't in reality (e.g. it's incorrectly configured)
- * or it's currently down.
- *
- * @return whether or not this server is a file server machine AND
- * either it isn't in reality or it's currently down
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public boolean isBadFileServer() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- return badFileServer;
- }
-
- /**
- * Returns this server's IP address as a String. It returns it in
- * dotted quad notation (i.e. 123.123.123.123).
- *
- * @return this server's IP address as a String
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public String[] getIPAddresses() throws AFSException
- {
- if (!cachedInfo) refreshInfo();
- int n = 16;
- for (int i = 0; i < n; i++) {
- if (ipAddresses[i] == null) {
- n = i;
- break;
- }
- }
- String[] addresses = new String[n];
- System.arraycopy(ipAddresses, 0, addresses, 0, n);
- return addresses;
- }
-
- /**
- * Returns the BOS Server's general restart time in the form of an
- * ExecutableTime object. This is the time at which the bos server
- * restarts itself and all running processes. After this method
- * is called once, it saves the time and returns
- * that value on subsequent calls, until the {@link #refresh()} method
- * is called and a more current value is obtained.
- *
- * @return the general restart time
- * @exception AFSException If an error occurs in the native code
- * @see Server.ExecutableTime
- * @see #refresh()
- */
- public ExecutableTime getGeneralRestartTime() throws AFSException
- {
- if (genRestartTime == null) refreshGeneralRestart();
- return genRestartTime;
- }
-
- /**
- * Returns the BOS Server's binary restart time in the form of an
- * ExecutableTime object. This is the time at which all new or newly
- * modified AFS binaries are restarted. After this method
- * is called once, it saves the time and returns
- * that value on subsequent calls, until the {@link #refresh()} method
- * is called and a more current value is obtained.
- *
- * @return the binary restart time
- * @exception AFSException If an error occurs in the native code
- * @see Server.ExecutableTime
- * @see #refresh()
- */
- public ExecutableTime getBinaryRestartTime() throws AFSException
- {
- if (binRestartTime == null) refreshBinaryRestart();
- return binRestartTime;
- }
-
- /**
- * Returns the total space on this server (a sum of the space of all the
- * partitions associated with this server). If this server is not a
- * file server, zero will be returned. After this method
- * is called once, it saves the total space and returns
- * that value on subsequent calls, until the {@link #refresh()} method
- * is called and a more current value is obtained.
- *
- * @return the total space on this server
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getTotalSpace() throws AFSException
- {
- if (partitions == null) refreshPartitions(true);
- if (!isFileServer() || isBadFileServer()) return 0;
- if (totalSpace == 0) {
- Partition[] partitions = getPartitions();
- for (int i = 0; i < partitions.length; i++) {
- totalSpace += partitions[i].getTotalSpace();
- }
- }
- return totalSpace;
- }
-
- /**
- * Returns the total free space on this server (a sum of the free space of
- * all the partitions associated with this server). If this server is not a
- * file server, zero will be returned. After this method
- * is called once, it saves the total free space and returns
- * that value on subsequent calls, until the {@link #refresh()} method
- * is called and a more current value is obtained.
- *
- * @return the total free space on this server
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getTotalFreeSpace() throws AFSException
- {
- if (partitions == null) refreshPartitions(true);
- if (!isFileServer() || isBadFileServer()) return 0;
- if (totalFreeSpace == 0) {
- Partition[] partitions = getPartitions();
- for (int i = 0; i < partitions.length; i++) {
- totalFreeSpace += partitions[i].getTotalFreeSpace();
- }
- }
- return totalFreeSpace;
- }
-
- /**
- * Returns the total used space on this server (a sum of the used space of
- * all the partitions associated with this server). If this server is not a
- * file server, zero will be returned. After this method
- * is called once, it saves the total used space and returns
- * that value on subsequent calls, until the {@link #refresh()} method
- * is called and a more current value is obtained.
- *
- * @return the total space on this partition
- * @exception AFSException If an error occurs in the native code
- * @see #getTotalSpace()
- * @see #getTotalFreeSpace()
- */
- public int getTotalUsedSpace() throws AFSException
- {
- if (totalUsedSpace == 0) {
- totalUsedSpace = getTotalSpace() - getTotalFreeSpace();
- }
- return totalUsedSpace;
- }
-
- /**
- * Returns this server's vos handle.
- *
- * @return this server's vos handle
- * @exception AFSException If an error occurs in the native code
- */
- protected long getVosHandle() throws AFSException
- {
- if ( vosHandle == 0 ) {
- vosHandle = getVosServerHandle( cell.getCellHandle(), name );
- }
- return vosHandle;
- }
-
- /**
- * Returns this server's bos handle.
- *
- * @return this server's bos handle
- * @exception AFSException If an error occurs in the native code
- */
- protected long getBosHandle() throws AFSException
- {
- if ( bosHandle == 0 ) {
- bosHandle = getBosServerHandle( cell.getCellHandle(), name );
- }
- return bosHandle;
- }
-
- //////////////// mutators: ////////////////////////
-
- /**
- * Sets the BOS general restart time. This is the time at which the bos
- * server restarts itself and all running processes.
- *
- * @param executableTime Executable time object that represents what
- * the BOS Server's general restart time should be.
- * @exception AFSException If an error occurs in the native code
- * @see Server.ExecutableTime
- */
- public void setGeneralRestartTime( ExecutableTime executableTime )
- throws AFSException
- {
- this.setRestartTime( getBosHandle(), RESTART_GENERAL, executableTime );
- }
-
- /**
- * Sets the BOS binary restart time. This is the time at which all new
- * or newly modified AFS binaries are restarted.
- *
- * @param executableTime Executable time object that represents what
- * the BOS Server's binary restart time should be.
- * @exception AFSException If an error occurs in the native code
- * @see Server.ExecutableTime
- */
- public void setBinaryRestartTime( ExecutableTime executableTime )
- throws AFSException
- {
- this.setRestartTime( getBosHandle(), RESTART_BINARY, executableTime );
- }
-
- /////////////// custom information methods ////////////////////
-
- /**
- * Returns a String
representation of this Server
.
- * Contains the information fields and a list of partitions, admin, and
- * processes.
- *
- * @return a String
representation of the Server
- */
- public String getInfo()
- {
- String r;
- try {
-
- r = "Server: " + name + "\n";
-
- r += "\tdatabase: " + isDatabase() + "\t\tfileServer: " +
- isFileServer() + "\n";
- r += "\tbad database: " + isBadDatabase() + "\tbad fileServer: " +
- isBadFileServer() + "\n";
- //r += "\tAddress: " + getIPAddress()[0] + "\n";
-
- // restart times:
- r += "\tGeneral restart date: " + getGeneralRestartTime() + "\n";
- r += "\tBinary restart date: " + getBinaryRestartTime() + "\n";
-
- if ( isFileServer() && !isBadFileServer() ) {
- r += "\tPartitions:\n";
-
- String parts[] = getPartitionNames();
-
- for( int i = 0; i < parts.length; i++ ) {
- r += "\t\t" + parts[i] + "\n";
- }
- }
-
- if ( (isDatabase() && !isBadDatabase()) ||
- (isFileServer() && !isBadFileServer()) ) {
- r += "\tAdmins:\n";
-
- String ads[] = getAdminNames();
-
- for( int i = 0; i < ads.length; i++ ) {
- r += "\t\t" + ads[i] + "\n";
- }
- }
-
- if ( (isDatabase() && !isBadDatabase()) ||
- (isFileServer() && !isBadFileServer()) ) {
- r += "\tProcesses:\n";
-
- String pros[] = getProcessNames();
-
- for( int i = 0; i < pros.length; i++ ) {
- r += "\t\t" + pros[i] + "\n";
- }
- }
-
- } catch( Exception e ) {
- return e.toString();
- }
- return r;
- }
-
- /**
- * Returns a String
containing the String
- * representations of all the partitions of this Server
.
- *
- * @return a String
representation of the partitions
- * @see Partition#getInfo
- */
- public String getInfoPartitions() throws AFSException
- {
- String r;
- r = "Server: " + name + "\n\n";
- r += "--Partitions--\n";
-
- Partition parts[] = getPartitions();
-
- for( int i = 0; i < parts.length; i++ ) {
- r += parts[i].getInfo() + "\n";
- }
- return r;
- }
-
- /**
- * Returns a String
containing the String
- * representations of all the keys of this Server
.
- *
- * @return a String
representation of the keys
- * @see Key#getInfo
- */
- public String getInfoKeys() throws AFSException
- {
- String r;
-
- r = "Server: " + name + "\n\n";
- r += "--Keys--\n";
-
- Key kys[] = getKeys();
-
- for( int i = 0; i < kys.length; i++ ) {
- r += kys[i].getInfo() + "\n";
- }
-
- return r;
- }
-
- /**
- * Returns a String
containing the String
- * representations of all the processes of this Server
.
- *
- * @return a String
representation of the processes
- * @see Process#getInfo
- */
- public String getInfoProcesses() throws AFSException
- {
- String r;
-
- r = "Server: " + name + "\n\n";
- r += "--Processes--\n";
-
- Process pros[] = getProcesses();
-
- for( int i = 0; i < pros.length; i++ ) {
- r += pros[i].getInfo() + "\n";
- }
- return r;
- }
-
- /////////////// custom override methods ////////////////////
-
- /**
- * Compares two Server objects respective to their names and does not
- * factor any other attribute. Alphabetic case is significant in
- * comparing names.
- *
- * @param server The Server object to be compared to this
- * Server instance
- *
- * @return Zero if the argument is equal to this Server's name, a
- * value less than zero if this Server's name is
- * lexicographically less than the argument, or a value greater
- * than zero if this Server's name is lexicographically
- * greater than the argument
- */
- public int compareTo(Server server)
- {
- return this.getName().compareTo(server.getName());
- }
-
- /**
- * Comparable interface method.
- *
- * @see #compareTo(Server)
- */
- public int compareTo(Object obj)
- {
- return compareTo((Server)obj);
- }
-
- /**
- * Tests whether two Server
objects are equal, based on their
- * names and hosting Cell.
- *
- * @param otherServer the Server to test
- * @return whether the specifed Server is the same as this Server
- */
- public boolean equals( Server otherServer )
- {
- return ( name.equals(otherServer.getName()) ) &&
- ( this.getCell().equals(otherServer.getCell()) );
- }
-
- /**
- * Returns the name of this Server
- *
- * @return the name of this Server
- */
- public String toString()
- {
- return getName();
- }
-
- /////////////// native methods ////////////////////
-
- /**
- * Opens a server for administrative vos use, based on the cell handle
- * provided. Returns a vos server handle to be used by other
- * methods as a means of identification.
- *
- * @param cellHandle a cell handle previously returned by
- * a call to {@link #getCellHandle}
- * @param serverName the name of the server for which to retrieve
- * a vos handle
- * @return a vos handle to the server
- * @exception AFSException If an error occurs in the native code
- * @see #getCellHandle
- */
- protected static native long getVosServerHandle( long cellHandle,
- String serverName )
- throws AFSException;
-
- /**
- * Closes the given currently open vos server handle.
- *
- * @param vosHandle the vos server handle to close
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void closeVosServerHandle( long vosHandle )
- throws AFSException;
-
- /**
- * Opens a server for administrative bos use, based on the cell handle
- * provided. Returns a bos server handle to be used by other methods
- * as a means of identification.
- *
- * @param cellHandle a cell handle previously returned by a call
- * to {@link #getCellHandle}
- * @param serverName the name of the server for which to retrieve
- * a bos handle
- * @return a bos handle to the server
- * @exception AFSException If an error occurs in the native code
- * @see #getCellHandle
- */
- protected static native long getBosServerHandle( long cellHandle,
- String serverName )
- throws AFSException;
-
- /**
- * Closes the given currently open bos server handle.
- *
- * @param bosHandle the bos server handle to close
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void closeBosServerHandle( long bosHandle )
- throws AFSException;
-
- /**
- * Fills in the information fields of the provided Server
.
- *
- * @param cellHandle the handle of the cell to which the server belongs
- * @see Cell#getCellHandle
- * @param name the name of the server for which to get the information
- * @param server the Server
object in which to fill in
- * the information
- * @see Server
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getServerInfo( long cellHandle, String name,
- Server server )
- throws AFSException;
-
- /**
- * Returns the total number of partitions hosted by the server denoted by
- * serverHandle
, if the server is a fileserver.
- *
- * @param cellHandle the handle of the cell to which the server belongs
- * @param serverHandle the vos handle of the server to which the
- * partitions belong
- * @return total number of partitions
- * @exception AFSException If an error occurs in the native code
- * @see Cell#getCellHandle
- * @see #getVosServerHandle
- */
- protected static native int getPartitionCount( long cellHandle,
- long serverHandle )
- throws AFSException;
-
- /**
- * Begin the process of getting the partitions on a server. Returns
- * an iteration ID to be used by subsequent calls to
- * getPartitionsNext
and getPartitionsDone
.
- *
- * @param cellHandle the handle of the cell to which the server belongs
- * @see Cell#getCellHandle
- * @param serverHandle the vos handle of the server to which the
- * partitions belong
- * @see #getVosServerHandle
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- */
- protected static native long getPartitionsBegin( long cellHandle,
- long serverHandle )
- throws AFSException;
-
- /**
- * Returns the next partition of the server. Returns null
- * if there are no more partitions.
- *
- * @param iterationId the iteration ID of this iteration
- * @see #getPartitionsBegin
- * @return the name of the next partition of the server
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getPartitionsNextString( long iterationId )
- throws AFSException;
-
- /**
- * Fills the next partition object of the server. Returns 0 if there
- * are no more partitions, != 0 otherwise
- *
- * @param iterationId the iteration ID of this iteration
- * @param thePartition the Partition object in which to fill the
- * values of the next partition
- * @see #getPartitionsBegin
- * @return 0 if there are no more servers, != 0 otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getPartitionsNext( long iterationId,
- Partition thePartition )
- throws AFSException;
-
- /**
- * Signals that the iteration is complete and will not be accessed anymore.
- *
- * @param iterationId the iteration ID of this iteration
- * @see #getPartitionsBegin
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getPartitionsDone( long iterationId )
- throws AFSException;
-
- /**
- * Returns the total number of processes hosted by the server denoted by
- * serverHandle
.
- *
- * @param serverHandle the vos handle of the server to which the
- * processes belong
- * @return total number of processes
- * @exception AFSException If an error occurs in the native code
- * @see #getVosServerHandle
- */
- protected static native int getProcessCount( long serverHandle )
- throws AFSException;
-
- /**
- * Begin the process of getting the processes on a server. Returns
- * an iteration ID to be used by subsequent calls to
- * getProcessesNext
and getProcessesDone
.
- *
- * @param serverHandle the bos handle of the server to which the
- * processes belong
- * @see #getBosServerHandle
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- */
- protected static native long getProcessesBegin( long serverHandle )
- throws AFSException;
-
- /**
- * Returns the next process of the server. Returns null
- * if there are no more processes.
- *
- * @param iterationId the iteration ID of this iteration
- * @see #getProcessesBegin
- * @return the name of the next process of the cell
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getProcessesNextString( long iterationId )
- throws AFSException;
-
- /**
- * Fills the next process object of the server. Returns 0 if there
- * are no more processes, != 0 otherwise.
- *
- * @param serverHandle the handle of the BOS server that hosts the process
- * @see #getBosHandle
- * @param iterationId the iteration ID of this iteration
- * @param theProcess the Process object in which to fill the
- * values of the next process
- * @see #getProcessesBegin
- * @return 0 if there are no more processes, != otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getProcessesNext( long serverHandle,
- long iterationId,
- Process theProcess )
- throws AFSException;
-
- /**
- * Signals that the iteration is complete and will not be accessed anymore.
- *
- * @param iterationId the iteration ID of this iteration
- * @see #getProcessesBegin
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getProcessesDone( long iterationId )
- throws AFSException;
-
- /**
- * Returns the total number of keys hosted by the server denoted by
- * serverHandle
.
- *
- * @param serverHandle the vos handle of the server to which the
- * keys belong
- * @return total number of keys
- * @exception AFSException If an error occurs in the native code
- * @see #getVosServerHandle
- */
- protected static native int getKeyCount( long serverHandle )
- throws AFSException;
-
- /**
- * Begin the process of getting the keys of a server. Returns
- * an iteration ID to be used by subsequent calls to
- * getKeysNext
and getKeysDone
.
- *
- * @param serverHandle the bos handle of the server to which the keys belong
- * @see #getBosServerHandle
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- */
- protected static native long getKeysBegin( long serverHandle )
- throws AFSException;
-
- /**
- * Returns the next key of the server. Returns 0 if there
- * are no more keys, != 0 otherwise.
- *
- * @param iterationId the iteration ID of this iteration
- * @param theKey a {@link Key Key} object, in which to fill in the
- * properties of the next key.
- * @see #getKeysBegin
- * @return 0 if there are no more keys, != 0 otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getKeysNext( long iterationId, Key theKey )
- throws AFSException;
-
- /**
- * Signals that the iteration is complete and will not be accessed anymore.
- *
- * @param iterationId the iteration ID of this iteration
- * @see #getKeysBegin
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getKeysDone( long iterationId )
- throws AFSException;
-
- /**
- * Returns the total number of BOS administrators associated with the server
- * denoted by serverHandle
.
- *
- * @param serverHandle the vos handle of the server to which the
- * BOS admins belong
- * @return total number of BOS administrators
- * @exception AFSException If an error occurs in the native code
- * @see #getVosServerHandle
- */
- protected static native int getBosAdminCount( long serverHandle )
- throws AFSException;
-
- /**
- * Begin the process of getting the bos amdinistrators on a server. Returns
- * an iteration ID to be used by subsequent calls to
- * getBosAdminsNext
and getBosAdminsDone
.
- *
- * @param serverHandle the bos handle of the server to which the
- * partitions belong
- * @see #getBosServerHandle
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- */
- protected static native long getBosAdminsBegin( long serverHandle )
- throws AFSException;
-
- /**
- * Returns the next bos admin of the server. Returns null
- * if there are no more admins.
- *
- * @param iterationId the iteration ID of this iteration
- * @see #getBosAdminsBegin
- * @return the name of the next admin of the server
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getBosAdminsNextString( long iterationId )
- throws AFSException;
-
- /**
- * Returns the next bos admin of the server. Returns 0 if there
- * are no more admins, != 0 otherwise.
- *
- * @param cellHandle the handle of the cell to which these admins belong
- * @see #getCellHandle
- * @param iterationId the iteration ID of this iteration
- * @see #getBosAdminsBegin
- * @param theUser the user object in which to fill the values of this admin
- * @return 0 if no more admins, != 0 otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getBosAdminsNext( long cellHandle,
- long iterationId, User theUser )
- throws AFSException;
-
- /**
- * Signals that the iteration is complete and will not be accessed anymore.
- *
- * @param iterationId the iteration ID of this iteration
- * @see #getBosAdminsBegin
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getBosAdminsDone( long iterationId )
- throws AFSException;
-
- /**
- * Adds the given to name to the list of bos administrators on that server.
- *
- * @param serverHandle the bos handle of the server to which the
- * partitions belong
- * @see #getBosServerHandle
- * @param adminName the name of the admin to add to the list
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void addBosAdmin( long serverHandle,
- String adminName )
- throws AFSException;
-
- /**
- * Removes the given to name from the list of bos administrators on
- * that server.
- *
- * @param serverHandle the bos handle of the server to which the
- * partitions belong
- * @see #getBosServerHandle
- * @param adminName the name of the admin to remove from the list
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void removeBosAdmin( long serverHandle,
- String adminName )
- throws AFSException;
-
- /**
- * Salvages (restores consistency to) a volume, partition, or server
- *
- * @param cellHandle the handle of the cell to which the volume belongs
- * @see #getCellHandle
- * @param serverHandle the bos handle of the server on which the
- * volume resides
- * @see #getBosServerHandle
- * @param partitionName the name of the partition to salvage,
- * can be null
only if volName is
- * null
- * @param volName the name of the volume to salvage,
- * can be null
- * @param numSalvagers the number of salvager processes to run in parallel
- * @param tempDir directory to place temporary files, can be
- * null
- * @param logFile where salvager log will be written, can be
- * null
- * @param inspectAllVolumes whether or not to inspect all volumes,
- * not just those marked as active at crash
- * @param removeBadlyDamaged whether or not to remove a volume if it's
- * badly damaged
- * @param writeInodes whether or not to record a list of inodes modified
- * @param writeRootInodes whether or not to record a list of AFS
- * inodes owned by root
- * @param forceDirectory whether or not to salvage an entire directory
- * structure
- * @param forceBlockReads whether or not to force the salvager to read
- * the partition
- * one block at a time and skip badly damaged
- * blocks. Use if partition has disk errors
- */
- protected static native void salvage( long cellHandle, long serverHandle,
- String partitionName, String volName,
- int numSalvagers, String tempDir,
- String logFile,
- boolean inspectAllVolumes,
- boolean removeBadlyDamaged,
- boolean writeInodes,
- boolean writeRootInodes,
- boolean forceDirectory,
- boolean forceBlockReads)
- throws AFSException;
-
- /**
- * Synchronizes a particular server with the volume location database.
- *
- * @param cellHandle the handle of the cell to which the server belongs
- * @see #getCellHandle
- * @param serverHandle the vos handle of the server
- * @see #getVosServerHandle
- * @param partition the id of the partition to sync, can be -1 to ignore
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void syncServerWithVLDB( long cellHandle,
- long serverHandle,
- int partition )
- throws AFSException;
-
- /**
- * Synchronizes the volume location database with a particular server.
- *
- * @param cellHandle the handle of the cell to which the server belongs
- * @see #getCellHandle
- * @param serverHandle the vos handle of the server
- * @see #getVosServerHandle
- * @param partition the id of the partition to sync, can be -1 to ignore
- * @param forceDeletion whether or not to force the deletion of bad volumes
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void syncVLDBWithServer( long cellHandle,
- long serverHandle,
- int partition,
- boolean forceDeletion )
- throws AFSException;
-
- /**
- * Retrieves a specified bos log from a server. Right now this
- * method will simply return a huge String containing the log, but
- * hopefully we can devise a better way to make this work more efficiently.
- *
- * @param serverHandle the bos handle of the server to which the key belongs
- * @see #getBosServerHandle
- * @param logLocation the full path and name of the desired bos log
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getLog( long serverHandle, String logLocation )
- throws AFSException;
-
- /**
- * Fills in the restart time fields of the given {@link Server Server}
- * object.
- *
- * @param serverHandle the bos handle of the server to which the key belongs
- * @see #getBosServerHandle
- * @param restartType whether to get the general or binary restart.
- * Acceptable values are:
Server
object, in which to fill
- * the restart time fields
- * @exception AFSException If an error occurs in the native code
- */
- private static native void getRestartTime( long serverHandle,
- int restartType,
- ExecutableTime executableTime )
- throws AFSException;
-
- /**
- * Sets the restart time of the bos server.
- *
- * @param serverHandle the bos handle of the server to which the key belongs
- * @see #getBosServerHandle
- * @param restartType whether this is to be a general or binary restart.
- * Acceptable values are:Server
- * objects are expected to be used.
- */
- protected static native void reclaimServerMemory();
-
- /*====================================================================*/
- /* INNER CLASSES */
- /*====================================================================*/
- public static final class ExecutableTime implements Serializable
- {
- public static final short NEVER = 0;
- public static final short NOW = 1;
-
- public static final short EVERYDAY = -1;
- public static final short SUNDAY = 0;
- public static final short MONDAY = 1;
- public static final short TUESDAY = 2;
- public static final short WEDNESDAY = 3;
- public static final short THURSDAY = 4;
- public static final short FRIDAY = 5;
- public static final short SATURDAY = 6;
-
- static final DecimalFormat formatter =
- (DecimalFormat)DecimalFormat.getInstance();
-
- private short second;
- private short minute;
- private short hour;
- private short day;
- private boolean now;
- private boolean never;
-
- static
- {
- formatter.applyPattern("00");
- }
-
- /**
- * Internal constructor used to construct an empty object that will
- * be passed to JNI for member synchronization of the BOS Server
- * executable time this object represents.
- */
- ExecutableTime()
- {
- this.second = (short) 0;
- this.minute = (short) 0;
- this.hour = (short) 0;
- this.day = (short) -1;
- this.now = false;
- this.never = false;
- }
-
- /**
- * Constructs an ExecutableTime
object that represents either
- * a "now
" or "never
" BOS Executable
- * Restart Time.
- *
- * Valid values for the type
parameter are ExecutableTime.NOW
- * or ExecutableTime.NEVER. If a value other than these two is used an
- * IllegalArgumentException will be thrown.
- *
- * @param type either ExecutableTime.NOW or ExecutableTime.NEVER
- * @exception IllegalArgumentException
- * If a value other than ExecutableTime.NOW or
- * ExecutableTime.NEVER is used for the type
- * parameter.
- * @see #isNow()
- * @see #isNever()
- * @see #Server.ExecutableTime(short, short, short)
- */
- public ExecutableTime(short type) throws IllegalArgumentException
- {
- if (type == NOW) {
- this.now = true;
- this.never = false;
- } else if (type == NEVER) {
- this.now = false;
- this.never = true;
- } else {
- throw new IllegalArgumentException("You must specify either " +
- "ExecutableTime.NOW or " +
- "ExecutableTime.NEVER when " +
- "using this constructor.");
- }
- this.second = (short) 0;
- this.minute = (short) 0;
- this.hour = (short) 0;
- this.day = (short) -1;
- }
-
- /**
- * Constructs an ExecutableTime
object that may be used to
- * represent a daily BOS Executable Restart Time of a process.
- *
- * @param second the second field for this representation of a
- * BOS Server restart time value (range: 0-59)
- * @param minute the minute field for this representation of a
- * BOS Server restart time value (range: 0-59)
- * @param hour the hour field for this representation of a BOS
- * Server restart time value (range: 0-23)
- * @exception IllegalArgumentException
- * If any of the parameters values are out of range
- * of their respective fields.
- * @see #Server.ExecutableTime(short, short, short, short)
- * @see #getSecond()
- * @see #getMinute()
- * @see #getHour()
- */
- public ExecutableTime(short second, short minute, short hour)
- throws IllegalArgumentException
- {
- this(second, minute, hour, ExecutableTime.EVERYDAY);
- }
-
- /**
- * Constructs an ExecutableTime
object that may be used to
- * represent the BOS Executable Restart Time of a process.
- *
- * @param second the second field for this representation of a
- * BOS Server restart time value (range: 0-59)
- * @param minute the minute field for this representation of a
- * BOS Server restart time value (range: 0-59)
- * @param hour the hour field for this representation of a BOS
- * Server restart time value (range: 0-23)
- * @param day the day field for this representation of a BOS
- * Server restart time value.
ExecutableTime.EVERYDAY
(see also {@link
- * #Server.ExecutableTime(short, short, short)})
- * ExecutableTime.SUNDAY
- * ExecutableTime.MONDAY
- * ExecutableTime.TUESDAY
- * ExecutableTime.WEDNESDAY
- * ExecutableTime.THURSDAY
- * ExecutableTime.FRIDAY
- * ExecutableTime.SATURDAY
- *
now
" or "never
".
- */
- public short getSecond() throws IllegalStateException
- {
- if (now || never) {
- throw new IllegalStateException("Executable time is set to 'now' or" +
- " 'never'.");
- }
- return second;
- }
-
- /**
- * Returns the minute of this ExecutableTime object.
- *
- * @return the minute of this ExecutableTime object.
- * @exception IllegalStateException
- * If the executable time this object represents has a value of
- * "now
" or "never
".
- */
- public short getMinute() throws IllegalStateException
- {
- if (now || never) {
- throw new IllegalStateException("Executable time is set to 'now' or" +
- " 'never'.");
- }
- return minute;
- }
-
- /**
- * Returns the hour of this ExecutableTime object, in 24 hour time.
- *
- * @return the hour of this ExecutableTime object.
- * @exception IllegalStateException
- * If the executable time this object represents has a value of
- * "now
" or "never
".
- */
- public short getHour() throws IllegalStateException
- {
- if (now || never) {
- throw new IllegalStateException("Executable time is set to 'now' or" +
- " 'never'.");
- }
- return hour;
- }
-
- /**
- * Returns a numeric representation of the day of this ExecutableTime
- * object. If it is daily, the value of ExecutableTime.EVERYDAY is returned.
- *
- * Possible return values are:
- *
- * ExecutableTime.EVERYDAY
- *
- * @return a numeric representation of the day of this ExecutableTime
- * object.
- * @exception IllegalStateException
- * If the executable time this object represents has a value of
- * "
- *
- * ExecutableTime.SUNDAY
- * ExecutableTime.MONDAY
- * ExecutableTime.TUESDAY
- * ExecutableTime.WEDNESDAY
- * ExecutableTime.THURSDAY
- * ExecutableTime.FRIDAY
- * ExecutableTime.SATURDAY
- * now
" or "never
".
- */
- public short getDay() throws IllegalStateException
- {
- if (now || never) {
- throw new IllegalStateException("Executable time is set to 'now' or" +
- " 'never'.");
- }
- return day;
- }
-
- /**
- * Returns a String representation, name for the day of the week or
- * "Everyday", of this object's day property.
- *
- *
Possible return values are: - *
- * Sunday - * Monday - * Tuesday - * Wednesday - * Thursday - * Friday - * Saturday - * - * Everyday - *- * - * @return the day of this ExecutableTime object. - * @exception IllegalStateException - * If the executable time this object represents has a value of - * "
now
" or "never
".
- * @see #getDay()
- */
- public String getDayString() throws IllegalStateException
- {
- switch (getDay())
- {
- case 0:
- return "Sunday";
- case 1:
- return "Monday";
- case 2:
- return "Tuesday";
- case 3:
- return "Wednesday";
- case 4:
- return "Thursday";
- case 5:
- return "Friday";
- case 6:
- return "Saturday";
- default:
- return "Everyday";
- }
- }
-
- /**
- * Returns whether or not the BOS restart time, represented by this
- * ExecutableTime object, is set to "now
" or not.
- * This means that at some point in the past, when someone set it to
- * "now
", the bosserver restarted all its processes,
- * and never again.
- *
- * @return whether or not the restart time is "now
"
- */
- public boolean isNow()
- {
- return now;
- }
-
- /**
- * Returns the second of this ExecutableTime object.
- *
- * @return the second of this ExecutableTime object.
- */
- /**
- * Returns whether or not the BOS restart time, represented by this
- * ExecutableTime object, is set to "never
" or not.
- * This means that the bosserver will never restart its processes.
- *
- * @return whether or not the restart time is "never
"
- */
- public boolean isNever()
- {
- return never;
- }
-
- /**
- * Tests whether two ExecutableTime
objects are equal,
- * based on a
- * comparison of each of their respective properties. If
- * "now
" or "never
" is set in either object,
- * only those properties are analyzed.
- *
- * @param time the ExecutableTime to test against
- * @return whether the specifed ExecutableTime is the same as this
- * ExecutableTime as defined above
- */
- public boolean equals( ExecutableTime time )
- {
- boolean same = false;
- try {
- same = ( (second == time.getSecond()) &&
- (minute == time.getMinute()) &&
- (hour == time.getHour() ) &&
- (day == time.getDay() ) );
- } catch (Exception e) {
- same = ( (now == time.isNow() ) &&
- (never == time.isNever() ) );
-
- }
- return same;
- }
-
- /**
- * Returns the String representation of time value of this
- * ExecutableTime
object.
- *
- * Possible return values:
- *
<day> at <hh>:<MM>[:<ss>]
- * - * Sunday at 04:00 - * Sunday at 05:10:30 - * Everyday at 20:00- * - * @return the String representation of this
ExecutableTime
- * object
- */
- public String toString()
- {
- if (now) {
- return "Now";
- } else if (never) {
- return "Never";
- } else {
- try {
- if (second != 0) {
- return getDayString() + " at " +
- ExecutableTime.formatter.format(hour) + ":" +
- ExecutableTime.formatter.format(minute) + ":" +
- ExecutableTime.formatter.format(second);
- } else {
- return getDayString() + " at " +
- ExecutableTime.formatter.format(hour) + ":" +
- ExecutableTime.formatter.format(minute);
- }
- } catch (Exception e) {
- return "(unknown)";
- }
- }
- }
-
- }
- /*====================================================================*/
-
-}
-
-
-
-
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/Token.java b/src/JAVA/classes/org/openafs/jafs/Token.java
deleted file mode 100644
index d8f7dfa9e3..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/Token.java
+++ /dev/null
@@ -1,507 +0,0 @@
-/*
- * @(#)Token.java 1.2 05/06/2002
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-import java.io.Serializable;
-
-/**
- * An abstract representation of an AFS authentication token. It conveniently
- * maintains the handle associated with token and the cell to which the token
- * is authenticated.
- * Token
object results in an immediate attempt to
- * authenticate the user within the specified cell. If this attempt fails, an
- * {@link AFSException}
will be thrown. Therefore, if the
- * construction of the object succeeds without an exception, then the
- * Token
is considered authenticated.
- *
- * The construction of a Token
object acts as an entry point
- * for authentication into the AFS system. Thus, when you construct a
- * {@link Cell}
object, you must pass in an instance of a
- * Token
that has been authenticated within the AFS cell that
- * Cell
is intended to represent. You will only be
- * allowed to perform actions that the user, used to authenticate
- * Token
, is authorized to perform. You must construct a
- * Token
object before constructing a Cell
object,
- * which is required by all other objects within this package either directly
- * or indirectly.AFSException
will be thrown. This class is the Java
- * equivalent of errors thrown by AFS; see {@link AFSException}
- * for a complete description.Token
object. It shows how to construct a Cell
- * using a Token
. See {@link Cell} for a more detailed example
- * of constructing and using a Cell
object.- * import org.openafs.jafs.AFSException; - * import org.openafs.jafs.Cell; - * import org.openafs.jafs.Token; - * ... - * public class ... - * { - * ... - * private Cell cell; - * private Token token; - * ... - * public static void main(String[] args) throws Exception - * { - * String username = arg[0]; - * String password = arg[1]; - * String cellName = arg[2]; - * String serverName = arg[3]; - * - * token = new Token(username, password, cellName); - * cell = new Cell(token); - * ... - * } - * ... - * } - *- * - */ - -public class Token implements Serializable, Comparable -{ - public static int ANYUSER_PAG_ID; - - protected long tokenHandle; - protected int pagID = -1; - protected int errno; - - protected String cellName; - protected String username; - private String password; - - private boolean hasInitialized = false; - - /** - * Load the native libraries
libjafs
and
- * libjafs
.
- */
- static
- {
- try {
- Class.forName("org.openafs.jafs.AFSLibraryLoader");
- try {
- initializeAdminClient();
- } catch (Exception e) {
- System.err.println(e);
- }
- } catch (ClassNotFoundException e) {
- /* Most likely running on a client, do nothing */
- }
- }
-
- /**
- * Constructs a new Token
object instance given
- * the name of the AFS cell it represents and the username and password
- * of the user to be Tokend for
- * administrative access.
- *
- * @param username the name of the user to Token with
- * @param password the password of that user
- * @param cellName the name of the cell to Token into
- * @param login if true, automatically login upon construction
- * @exception AFSException If an error occurs in the native code
- */
- protected Token( String username, String password, String cellName,
- boolean automaticallyLogin )
- throws AFSException
- {
- this.username = username;
- this.password = password;
- this.cellName = cellName;
-
- /* By default lets authenticate the user using libafsauthent.a */
- if (automaticallyLogin) login();
- }
-
- /**
- * Constructs a new Token
object instance given the
- * name of the AFS cell it represents; the token for administrative
- * access will be extracted from the kernel cache manager if possible.
- *
- * @param cellName the name of the cell to Token into
- * @exception AFSException If an error occurs in the native code
- */
- public Token(String cellName)
- throws AFSException
- {
- this(null, null, cellName);
- }
-
- /**
- * Constructs a new Token
object instance given
- * the name of the AFS cell it represents and the username and password
- * of the user to be Tokend for
- * administrative access.
- *
- * @param username the name of the user to Token with
- * @param password the password of that user
- * @param cellName the name of the cell to Token into
- * @exception AFSException If an error occurs in the native code
- */
- public Token( String username, String password, String cellName )
- throws AFSException
- {
- this.username = username;
- this.password = password;
- this.cellName = cellName;
-
-//System.out.println(username + ", " + cellName);
- /* By default lets authenticate the user using libafsauthent.a */
- login();
- }
-
- /**
- * Returns the name of the AFS cell that this Token
was
- * authenticated against.
- *
- * @exception AFSException If an error occurs in the native code
- * @return the name of the AFS cell associated with this Token
.
- */
- public String getCellName()
- {
- return cellName;
- }
-
- /**
- * Returns the username of user to whom this token belongs.
- *
- * @exception AFSException If an error occurs in the native code
- * @return the username of the user represented by this Token
- */
- public String getUsername()
- {
- return username;
- }
-
- /**
- * Returns a token handle that can be used to prove this authentication
- * later.
- *
- * @exception AFSException If an error occurs in the native code
- * @return a token representing the authentication
- */
- protected long getHandle()
- {
- return tokenHandle;
- }
-
- /**
- * Closes the given currently open token.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void close() throws AFSException
- {
- close(tokenHandle);
- }
-
- /**
- * Gets the expiration time for a given token.
- *
- * @return a long representing the UTC time for the token expiration
- * @exception AFSException If an error occurs in the native code
- */
- public long getExpiration() throws AFSException
- {
- return getExpiration(tokenHandle);
- }
-
- /**
- * Authenticates a user in kas, and binds that authentication
- * to the current process.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void klog() throws AFSException
- {
- if (!hasInitialized) {
- initializeUserSpace();
- hasInitialized = true;
- }
- if (pagID > -1) {
- relog(pagID);
- } else {
- pagID = klog(username, password, cellName, pagID);
- }
- }
-
- /**
- * Authenticates a user in KAS, and binds that authentication
- * to the current process.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void login() throws AFSException
- {
- this.tokenHandle = this.getToken(cellName, username, password);
-//System.out.println("Token handle -> " + tokenHandle);
- }
-
- /**
- * Initialize the user space AFS client (libjafs).
- *
- * The user space client must be initialized prior to any
- * user space related methods, including: klog, unlog, relog,
- * and shutdown.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected static void initializeUserSpace() throws AFSException
- {
- try {
- Token.initUserSpace();
- } catch (AFSException e) {
- System.err.println(e.getMessage());
- }
- try {
- Runtime.getRuntime().addShutdownHook(new AFSShutdownHandler());
- } catch (Exception e) {
- System.err.println("Could not register shutdown hook: " + e.toString());
- }
- }
-
- /////////////// custom override methods ////////////////////
-
- /**
- * Compares two ACL objects respective to their paths and does not
- * factor any other attribute. Alphabetic case is significant in
- * comparing names.
- *
- * @param acl The ACL object to be compared to this ACL
- * instance
- *
- * @return Zero if the argument is equal to this ACL's path, a
- * value less than zero if this ACL's path is
- * lexicographically less than the argument, or a value greater
- * than zero if this ACL's path is lexicographically
- * greater than the argument
- */
- public int compareTo(Token token)
- {
- return this.toString().compareTo(token.toString());
- }
-
- /**
- * Comparable interface method.
- *
- * @see #compareTo(Token)
- */
- public int compareTo(Object obj)
- {
- return compareTo((Token)obj);
- }
-
- /**
- * Tests whether two Cell
objects are equal, based on their
- * names. Does not test whether the objects are actually the same
- * representational instance of the AFS cell.
- *
- * @param otherCell the Cell
to test
- * @return whether the specifed user is the same as this user
- */
- public boolean equals( Token token )
- {
- return this.toString().equals( token.toString() );
- }
-
- /**
- * Returns the name of this Cell
- *
- * @return the name of this Cell
- */
- public String toString()
- {
- return username + "@" + cellName + ":" + tokenHandle;
- }
-
- /////////////// native methods found in *Token.c ////////////////////
-
- /**
- * Initialize the user space library.
- *
- * @exception AFSException If an error occurs in the native code
- */
- private static native void initUserSpace() throws AFSException;
-
- /**
- * Initialize the administrative library.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void initializeAdminClient() throws AFSException;
-
- /**
- * Returns a token handle that can be used to prove this authentication
- * later.
- *
- * @param cellName the name of the cell in which to Token this user
- * @param userName the name of the user to Token
- * @param password the password of the user
- * @exception AFSException If an error occurs in the native code
- * @return a token representing the authentication
- */
- protected native long getToken( String cellName, String username,
- String password )
- throws AFSException;
-
- /**
- * Closes the given currently open token.
- *
- * @param tokenHandle the token to close
- * @exception AFSException If an error occurs in the native code
- */
- protected native void close( long tokenHandle ) throws AFSException;
-
- /**
- * Gets the expiration time for a given token.
- *
- * @param tokenHandle a token handle previously returned by a call
- * to {@link #getToken}
- * @see #getToken
- * @return a long representing the UTC time for the token expiration
- * @exception AFSException If an error occurs in the native code
- */
- protected native long getExpiration( long tokenHandle )
- throws AFSException;
-
- /**
- * Authenticates a user in KAS, and binds that authentication
- * to the current thread or native process.
- *
- * @param username the login to authenticate
- * (expected as username@cellname)
- * @param password the password of the login
- * @param cellName the name of the cell to authenticate into
- * @param id the existing pag (or 0)
- *
- * @return the assigned pag
- * @exception AFSException If an error occurs in the native code
- */
- protected native int klog(String username, String password,
- String cellName, int id)
- throws AFSException;
-
- /**
- * Authenticates a user in KAS by a previously acquired PAG ID, and binds
- * that authentication to the current thread or native process.
- *
- *
This method does not require the user's username and password to - * fully authenticate their request. Rather it utilizes the user's PAG ID - * to recapture the user's existing credentials. - * - *
This method is called by the public klog
method, which
- * internally manages the PAG ID. Additionally, an application needs only
- * call klog
, this reduces the amount of complexity and ensures
- * that relog
is never called before a klog
.
- *
- * @param int User's current PAG (process authentication group) ID
- * @exception AFSException If an error occurs in the native code
- */
- protected native void relog(int id) throws AFSException;
-
- /**
- * Manually discards all AFS credentials associated with the bound user.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public native void unlog() throws AFSException;
-
- /**
- * Inform the native library that the application is
- * shutting down and will be unloading.
- *
- *
The library will make a call informing the file server that it will - * no longer be available for callbacks. - */ - protected static native void shutdown(); - - /** - * Reclaims all memory being saved by the authentication portion of - * the native library. - * This method should be called when no more authentications are expected. - */ - protected static native void reclaimAuthMemory(); -} - -/*=======================================================================*/ -/** - * Class that loads the native libraries required for direct communication with - * AFS. Since the Token class is serializable the function of loading the - * native libraries must be performed in a non-serialized class, one that will - * not be included in any client side application packages. - * - * @version 1.0, 06/13/2001 - */ -class AFSLibraryLoader -{ - static - { - System.loadLibrary("jafs"); - System.loadLibrary("jafsadm"); - } -} -/*=======================================================================*/ -/** - * Class that handles graceful AFS application shutdown procedures by - * instructing the native library to inform the file system server that - * it is shutting down. - * - * @version 1.0, 06/13/2001 - */ -class AFSShutdownHandler extends Thread -{ - public AFSShutdownHandler() {} - - /** - * This is the execution method satisfying the interface requirement as a - * stand alone runnable thread. - * - *
This method will automatically be invoked by the Thread instantiator.
- *
- * @see Token#shutdown()
- */
- public void run()
- {
- System.out.println("Shutting down Java AFS library...");
- org.openafs.jafs.Token.shutdown();
- }
-}
-/*=======================================================================*/
-
-
-
-
-
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/User.java b/src/JAVA/classes/org/openafs/jafs/User.java
deleted file mode 100644
index fdda30f892..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/User.java
+++ /dev/null
@@ -1,1948 +0,0 @@
-/*
- * @(#)User.java 1.0 6/29/2001
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-import java.util.GregorianCalendar;
-import java.util.Date;
-import java.util.ArrayList;
-import java.io.Serializable;
-
-/**
- * An abstract representation of an AFS user. It holds information about
- * the user, such as what groups it belongs to.
- *
- *
- * Constructing an instance of a User
does not mean an actual
- * AFS user is created in a cell -- usually a User
- * object is a representation of an already existing AFS user. If,
- * however, the User
is constructed with the name of a
- * user that does not exist in the cell represented by the provided
- * Cell
, a new user with that name can be
- * created in that server by calling the {@link #create(String, int)} or
- * {@link #create(String)} method. If such a user does already exist when
- * one of these methods is called, an exception will be thrown.
- *
- * Each User
object has its own individual set of
- * Group
s that it owns and Group
s for which
- * it is a member. These represents the properties and attributes
- * of an actual AFS user.
- *
- *
- * Since this User
object is a union of both the PTS and KAS
- * properties of AFS users, some methods meant for users with a PTS entry
- * will throw exceptions if used on a user with only a KAS entry, and vice
- * versa.
- *
- *
- *
- * Associated with an AFS user are many attributes, such as whether or not
- * it can change its own password, or who is allowed to find out the groups
- * to which this user belongs. The User
class has many
- * "set" methods to indicate values for these attributes (i.e.
- * {@link #setChangePassword(boolean)} and {@link #setListMembership(int)}).
- * However, in order for these values to be written to the actual AFS user,
- * the {@link #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
- * User
object. It iterates through the list of users
- * (a union of pts and kas users) for a cell, and prints out the name and
- * id of each.
- *
- *
- * import org.openafs.jafs.Cell; - * import org.openafs.jafs.AFSException; - * import org.openafs.jafs.User; - * ... - * public class ... - * { - * ... - * private Cell cell; - * ... - * public static void main(String[] args) throws Exception - * { - * String username = arg[0]; - * String password = arg[1]; - * String cellName = arg[2]; - * - * token = new Token(username, password, cellName); - * cell = new Cell(token); - * server = cell.getServer(serverName); - * - * System.out.println("Users in Cell " + cell.getName() + ":"); - * User[] users = cell.getUsers(); - * for (int i = 0; i < users.length; i++) { - * System.out.println(" -> " + users[i] + ": " users[i].getID()); - * } - * } - * ... - * } - *- * - */ -public class User implements PTSEntry, Serializable, Comparable -{ - /** - * Only the owner of the user has access - */ - public static final int USER_OWNER_ACCESS = 0; - /** - * Any user has access - */ - public static final int USER_ANYUSER_ACCESS = 1; - - /** - * User has administrative kas privileges - */ - public static final int ADMIN = 0; - /** - * User has no administrative kas privileges - */ - public static final int NO_ADMIN = 1; - - /** - * TGS will grant tickets for user - */ - public static final int GRANT_TICKETS = 0; - /** - * TGS will not grant tickets for user - */ - public static final int NO_GRANT_TICKETS = 1; - - /** - * TGS can use user's key for an encryption key - */ - public static final int ENCRYPT = 0; - /** - * TGS cannot use user's key for an encryption key - */ - public static final int NO_ENCRYPT = 1; - - /** - * User can change their password - */ - public static final int CHANGE_PASSWORD = 0; - /** - * User cannot change their password - */ - public static final int NO_CHANGE_PASSWORD = 1; - - /** - * User can reuse their password - */ - public static final int REUSE_PASSWORD = 0; - /** - * User cannot reuse their password - */ - public static final int NO_REUSE_PASSWORD = 1; - - protected Cell cell; - protected long cellHandle; - protected String name; - - /** - * Does this user have a kas entry? - */ - protected boolean kas; - /** - * Does this user have a pts entry? - */ - protected boolean pts; - - // pts fields - protected int groupCreationQuota; - protected int groupMembershipCount; - protected int nameUID; - protected int ownerUID; - protected int creatorUID; - - /** - * who is allowed to execute pts examine for this user. Valid values are: - *
User
object instance given the name
- * of the AFS user and the AFS cell, represented by
- * cell
, to which it belongs. This does not actually
- * create a new AFS user, it just represents one.
- * If name
is not an actual AFS user, exceptions
- * will be thrown during subsequent method invocations on this
- * object, unless the {@link #create(String, int)} or {@link #create(String)}
- * method is explicitly called to create it.
- *
- * @param name the name of the user to represent
- * @param cell the cell to which the user belongs.
- * @exception AFSException If an error occurs in the native code
- */
- public User( String name, Cell cell ) throws AFSException
- {
- this.name = name;
- this.cell = cell;
- cellHandle = cell.getCellHandle();
-
- groups = null;
- groupNames = null;
- groupsOwned = null;
- groupsOwnedNames = null;
- cachedInfo = false;
- kas = false;
- pts = false;
- }
-
- /**
- * Constructs a new User
object instance given the name
- * of the AFS user and the AFS cell, represented by
- * cell
, to which it belongs. This does not actually
- * create a new AFS user, it just represents one.
- * If name
is not an actual AFS user, exceptions
- * will be thrown during subsequent method invocations on this
- * object, unless the {@link #create(String, int)} or {@link #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 {@link #refresh()} method to address any coherency
- * concerns.
- *
- * @param name the name of the user to represent
- * @param cell the cell to which the user belongs.
- * @param preloadAllMembers true will ensure all object members are
- * set upon construction;
- * otherwise members will be set upon access,
- * which is the default behavior.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh
- */
- public User( String name, Cell cell, boolean preloadAllMembers )
- throws AFSException
- {
- this(name, cell);
- if (preloadAllMembers) refresh(true);
- }
-
- /**
- * Constructs a blank User
object given the cell to which
- * the user belongs. This blank object can then be passed into other
- * methods to fill out its properties.
- *
- * @exception AFSException If an error occurs in the native code
- * @param cell the cell to which the user belongs.
- */
- User( Cell cell ) throws AFSException
- {
- this( null, cell );
- }
-
- /*-------------------------------------------------------------------------*/
-
- /**
- * Creates the kas and pts entries for a new user in this cell.
- * Automatically assigns a user id.
- * *
- * @param password the password for the new user
- * @exception AFSException If an error occurs in the native code
- */
- public void create( String password ) throws AFSException
- {
- create( password, 0 );
- }
-
- /**
- * Creates the kas and pts entries for a new user in this cell.
- *
- * @param password the password for the new user
- * @param uid the user id to assign to the new user
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void create( String password, int uid ) throws AFSException
- {
- create( cell.getCellHandle(), name, password, uid );
- }
-
- /**
- * Deletes the pts and kas entries for a user in this cell. Deletes this user
- * from the membership list of the groups to which it belonged, but does not
- * delete the groups owned by this user. Also nullifies this corresponding
- * Java object.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void delete() throws AFSException
- {
- delete( cell.getCellHandle(), name );
-
- cell = null;
- name = null;
- kas = false;
- pts = false;
- owner = null;
- creator = null;
- groups = null;
- groupsOwned = null;
- groupNames = null;
- groupsOwnedNames = null;
- lastModName = null;
- encryptionKey = null;
- lockedUntilDate = null;
- userExpirationDate = null;
- lastModTimeDate = null;
- lastChangePasswordTimeDate = null;
- try {
- finalize();
- } catch( java.lang.Throwable t ) {
- throw new AFSException( t.getMessage() );
- }
- }
-
- /**
- * Unlocks the given user if they were locked out of the cell.
- *
- * @param userName the name of the user to unlock
- * @exception AFSException If an error occurs in the native code
- */
- public void unlock() throws AFSException
- {
- unlock( cell.getCellHandle(), name );
- lockedUntil = 0;
- lockedUntilDate = null;
- }
-
- /**
- * Flushes the current information of this User
object to disk.
- * This will update the information of the actual AFS user to match the
- * settings that have been modified within this User
object.
- * This function must be called before any changes made to the information
- * fields of this user will be seen by AFS.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void flushInfo() throws AFSException
- {
- setUserInfo( cell.getCellHandle(), name, this );
- }
-
- /**
- * Change the name of this user. Automatically flushes the info of this
- * user in order to update kas entry of the new name. NOTE: renaming a
- * locked user will unlock that user.
- *
- * @param newName the new name for this user
- * @exception AFSException If an error occurs in the native code
- */
- public void rename( String newName ) throws AFSException
- {
- rename( cell.getCellHandle(), name, newName );
- name = newName;
- flushInfo();
- }
-
- /**
- * Refreshes the properties of this User object instance with values from
- * the AFS user it represents. All properties that have been initialized
- * and/or accessed will be renewed according to the values of the AFS user
- * this User 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.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void refresh() throws AFSException
- {
- refresh(false);
- }
-
- /**
- * Refreshes the properties of this User object instance with values from
- * the AFS user it represents. If all
is true
- * then all of the properties of this User object instance will be
- * set, or renewed, according to the values of the AFS user 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 {@link #refresh()} for more information.
- *
- * @param all if true set or renew all object properties; otherwise renew
- * all set properties
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- protected void refresh(boolean all) throws AFSException
- {
- if ( all || cachedInfo ) {
- refreshInfo();
- }
- if ( all || groupsOwned != null ) {
- refreshGroupsOwned();
- }
- if ( all || groupsOwnedNames != null ) {
- refreshGroupsOwnedNames();
- }
- if ( all || groups != null ) {
- refreshGroups();
- }
- if ( all || groupNames != null ) {
- refreshGroupNames();
- }
- }
-
- /**
- * Refreshes the information fields of this User
to reflect
- * the current state of the AFS user. Does not refresh the groups to which
- * the user belongs or groups owned by the user.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshInfo() throws AFSException
- {
- getUserInfo( cell.getCellHandle(), name, this );
- cachedInfo = true;
- lastModTimeDate = null;
- lastChangePasswordTimeDate = null;
- lockedUntilDate = null;
- userExpirationDate = null;
- }
-
- /**
- * Refreshes the current information about the group names to which the
- * user belongs. Does not refresh the information fields of the user or
- * the groups owned.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshGroupNames() throws AFSException
- {
- String currName;
- long iterationID = getUserGroupsBegin( cell.getCellHandle(), name );
- groupNames = new ArrayList();
- while( ( currName = getUserGroupsNextString( iterationID ) ) != null ) {
- groupNames.add( currName );
- }
- getUserGroupsDone( iterationID );
- }
-
- /**
- * Refreshes the current information about the group objects to which the
- * user belongs. Does not refresh the information fields of the user or
- * the groups owned.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshGroups() throws AFSException
- {
- Group currGroup;
- long iterationID = getUserGroupsBegin( cell.getCellHandle(), name );
-
- groups = new ArrayList();
-
- currGroup = new Group( cell );
- while( getUserGroupsNext( cellHandle, iterationID, currGroup ) != 0 ) {
- groups.add( currGroup );
- currGroup = new Group( cell );
- }
- getUserGroupsDone( iterationID );
- }
-
- /**
- * Refreshes the current information about the group names that the user
- * owns. Does not refresh the information fields of the user or the groups
- * belonged to.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshGroupsOwnedNames() throws AFSException
- {
- String currName;
- long iterationID = this.getGroupsOwnedBegin( cell.getCellHandle(), name );
- groupsOwnedNames = new ArrayList();
- while( ( currName = this.getGroupsOwnedNextString( iterationID ) )
- != null ) {
- groupsOwnedNames.add( currName );
- }
- this.getGroupsOwnedDone( iterationID );
- }
-
- /**
- * Refreshes the current information about the group objects that the user \
- * owns. Does not refresh the information fields of the user or the groups
- * belonged to.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshGroupsOwned() throws AFSException
- {
- Group currGroup;
- long iterationID = getGroupsOwnedBegin( cell.getCellHandle(), name );
- groupsOwned = new ArrayList();
- currGroup = new Group( cell );
- while( getGroupsOwnedNext( cellHandle, iterationID, currGroup ) != 0 ) {
- groupsOwned.add( currGroup );
- currGroup = new Group( cell );
- }
- getGroupsOwnedDone( iterationID );
- }
-
- /**
- * Adds an access control list entry for some AFS directory for this user.
- *
- * @param directory the full path of the place in the AFS file system
- * for which to add an entry
- * @param read whether or not to allow read access to this user
- * @param write whether or not to allow write access to this user
- * @param lookup whether or not to allow lookup access to this user
- * @param delete whether or not to allow deletion access to this user
- * @param insert whether or not to allow insertion access to this user
- * @param lock whether or not to allow lock access to this user
- * @param admin whether or not to allow admin access to this user
- * @exception AFSException If an error occurs in the native code
- public void setACL( String directory, boolean read, boolean write, boolean lookup, boolean delete, boolean insert, boolean lock, boolean admin ) throws AFSException
- {
- cell.setACL( directory, name, read, write, lookup, delete, insert, lock, admin );
- }
- */
-
- //////////////// ACCESSORS ////////////////////////
-
- /**
- * Returns the name of this user.
- *
- * @return the name of this user
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Returns the Cell this user belongs to.
- *
- * @return the Cell this user belongs to
- */
- public Cell getCell()
- {
- return cell;
- }
-
- /**
- * Returns whether or not this user has a kas entry.
- *
- * @return whether or not this user has a kas entry
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public boolean isKAS() throws AFSException
- {
- if ( !cachedInfo ) refreshInfo();
- return kas;
- }
-
- /**
- * Returns whether or not this user has a pts entry.
- *
- * @return whether or not this user has a pts entry
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public boolean isPTS() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return pts;
- }
-
- /**
- * PTS: Returns an array of the Group
objects
- * to which this user belongs.
- *
- * @return an array of the groups to which this user belongs
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public Group[] getGroups() throws AFSException
- {
- if( groups == null ) refreshGroups();
- return (Group[]) groups.toArray( new Group[groups.size()] );
- }
-
- /**
- * PTS: Returns the total count of groups this user owns.
- *
- *
If the total list of groups or group names have already been
- * collected (see {@link #getGroupsOwned()}), then the returning value
- * will be calculated based upon the current list. Otherwise, PTS will
- * be explicitly queried for the information.
- *
- * @return total count of groups this user owns
- * @exception AFSException If an error occurs in the native code
- * @see #getGroupsOwned()
- * @see #getGroupsOwnedNames()
- */
- public int getGroupsOwnedCount() throws AFSException
- {
- if( groupsOwned != null ) {
- return groupsOwned.size();
- } else if ( groupsOwnedNames != null ) {
- return groupsOwnedNames.size();
- } else {
- return getGroupsOwnedCount( cell.getCellHandle(), name );
- }
- }
-
- /**
- * PTS: Returns an array of the Group
objects
- * this user owns.
- *
- * @return an array of the Groups
this user owns
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public Group[] getGroupsOwned() throws AFSException
- {
- if( groupsOwned == null ) refreshGroupsOwned();
- return (Group[]) groupsOwned.toArray( new Group[groupsOwned.size()] );
- }
-
- /**
- * PTS: Returns a String
array of the group names
- * to which this user belongs.
- *
- * @return a String
array of the groups to which this
- * user belongs
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public String[] getGroupNames() throws AFSException
- {
- if( groupNames == null ) refreshGroupNames();
- return (String []) groupNames.toArray( new String[groupNames.size() ] );
- }
-
- /**
- * PTS: Returns a String
array of the group names
- * this user owns.
- *
- * @return a String
array of the groups this user owns
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public String[] getGroupsOwnedNames() throws AFSException
- {
- if( groupsOwnedNames == null ) refreshGroupsOwnedNames();
- return (String []) groupsOwnedNames.toArray( new String[groupsOwnedNames.size() ] );
- }
-
- /**
- * PTS: Returns the numeric AFS id of this user.
- *
- * @return the AFS id of this user
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getUID() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return nameUID;
- }
-
- /**
- * PTS: Returns how many more groups this user is allowed to create.
- * -1 indicates unlimited.
- *
- * @return the group creation quota
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getGroupCreationQuota() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return groupCreationQuota;
- }
-
- /**
- * PTS: Returns the number of groups to which this user belongs.
- *
- * @return the group membership count
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getGroupMembershipCount() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return groupMembershipCount;
- }
-
- /**
- * PTS: Returns the owner of this user in the form of a {@link PTSEntry}.
- *
- *
The returning object could be either a {@link User} or {@link Group}; - * to determine what type of object the {@link PTSEntry} represents, - * call the {@link PTSEntry#getType()} method. - * - * @return the owner of this user - * @exception AFSException If an error occurs in the native code - * @see PTSEntry - * @see PTSEntry#getType() - * @see #refresh() - */ - public PTSEntry getOwner() throws AFSException - { - if (!cachedInfo) refreshInfo(); - if (owner == null) return null; - if (ownerUID > 0) { - return new User(owner, cell); - } else { - return new Group(owner, cell); - } - } - - /** - * PTS: Returns the creator of this user in the form of a {@link PTSEntry}. - * - *
The returning object could be either a {@link User} or {@link Group}; - * to determine what type of object the {@link PTSEntry} represents, - * call the {@link PTSEntry#getType()} method. - * - * @return the creator of this user - * @exception AFSException If an error occurs in the native code - * @see PTSEntry - * @see PTSEntry#getType() - * @see #refresh() - */ - public PTSEntry getCreator() throws AFSException - { - if (!cachedInfo) refreshInfo(); - if (creator == null) return null; - if (creatorUID > 0) { - return new User(creator, cell); - } else { - return new Group(creator, cell); - } - } - - /** - * Returns the type of {@link PTSEntry} this object represents. - * - *
This method will always return {@link PTSEntry#PTS_USER}. - * - * @return the type of PTSEntry this object represents - (will always return {@link PTSEntry#PTS_USER}) - * @see PTSEntry - * @see PTSEntry#getType() - */ - public short getType() - { - return PTSEntry.PTS_USER; - } - - /** - * PTS: Returns who can list the status (pts examine) of this user. - * Valid values are: - *
{@link #USER_OWNER_ACCESS}
- * -- only the owner has permission{@link #USER_ANYUSER_ACCESS}
- * -- any user has permission{@link #USER_OWNER_ACCESS}
- * -- only the owner has permission{@link #USER_ANYUSER_ACCESS}
- * -- any user has permission{@link #USER_OWNER_ACCESS}
- * -- only the owner has permission{@link #USER_ANYUSER_ACCESS}
- * -- any user has permissionnull
value indicates the user never exipres (or that
- * there is no kas entry for this user).
- *
- * @return the date and time the user expires
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getUserExpiration() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return userExpiration;
- }
- /**
- * KAS: Returns the date and time the user expires.
- * A null
value indicates the user never expires (or that
- * there is no kas entry for this user).
- *
- * @return the date and time the user expires
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public GregorianCalendar getUserExpirationDate() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- if( userExpirationDate == null && userExpiration != 0 ) {
- // make it into a date . . .
- if( userExpiration == 0 ) {
- userExpirationDate = null;
- } else {
- userExpirationDate = new GregorianCalendar();
- long longTime = ((long) userExpiration)*1000;
- Date d = new Date( longTime );
- userExpirationDate.setTime( d );
- }
- }
- return userExpirationDate;
- }
-
- /**
- * KAS: Returns the date and time (in UTC) the user's KAS entry was
- * last modified.
- *
- * @return the date and time (in UTC) the user was last modified
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getLastModTime() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return lastModTime;
- }
- /**
- * KAS: Returns the date and time the user was last modified.
- *
- * @return the date and time the user was last modified
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public GregorianCalendar getLastModTimeDate() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- if( lastModTimeDate == null ) {
- // make it into a date . . .
- lastModTimeDate = new GregorianCalendar();
- long longTime = ((long) lastModTime)*1000;
- Date d = new Date( longTime );
- lastModTimeDate.setTime( d );
- }
- return lastModTimeDate;
- }
-
- /**
- * KAS: Returns the name of the user that last modified this user.
- *
- * @return the name of this user that last modified this user.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public String getLastModName() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return lastModName;
- }
-
- /**
- * KAS: Returns the last date and time the user changed its password.
- *
- * @return the last date and time the user changed its password.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public GregorianCalendar getLastChangePasswordTimeDate()
- throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- if( lastChangePasswordTimeDate == null ) {
- // make it into a date . . .
- lastChangePasswordTimeDate = new GregorianCalendar();
- long longTime = ((long) lastChangePasswordTime)*1000;
- Date d = new Date( longTime );
- lastChangePasswordTimeDate.setTime( d );
- }
- return lastChangePasswordTimeDate;
- }
-
- /**
- * KAS: Returns the last date and time (in UTC) the user changed
- * its password.
- *
- * @return the last date and time (in UTC) the user changed its password.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getLastChangePasswordTime() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return lastChangePasswordTime;
- }
-
- /**
- * KAS: Returns the maximum lifetime of a ticket issued to this user
- * (in seconds).
- *
- * @return the maximum lifetime of a ticket issued to this user (in seconds).
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getMaxTicketLifetime() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return maxTicketLifetime;
- }
-
- /**
- * KAS: Returns the number of days a password is valid before it expires.
- * A value of 0 indicates passwords never expire.
- *
- * @return the number of days for which a password is valid
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getDaysToPasswordExpire() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return daysToPasswordExpire;
- }
-
- /**
- * KAS: Returns the number of failed login attempts this user is allowed
- * before being locked out. A value of 0 indicates there is no limit.
- *
- * @return the number of failed login attempts a user is allowed
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getFailLoginCount() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return failLoginCount;
- }
-
- /**
- * KAS: Returns the amount of time (in seconds) a user is locked out when
- * it exceeds the maximum number of allowable failed login attempts.
- * A value of 0 indicates an infinite lockout time.
- *
- * @return the number of failed login attempts a user is allowed
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getLockTime() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return lockTime;
- }
-
- /**
- * KAS: Returns the encryption key, in octal form, of this user. An
- * example of a key in octal form is:
- * '\040\205\211\241\345\002\023\211'.
- *
- * @return the encryption key
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public String getEncryptionKey() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return encryptionKey;
- }
-
- /**
- * KAS: Returns the check sum of this user's key.
- *
- * @return the check sum
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public long getKeyCheckSum() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return keyCheckSum;
- }
-
- /**
- * KAS: Returns the version number of the user's key.
- *
- * @return the key version
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getKeyVersion() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return keyVersion;
- }
-
- /**
- * KAS: Returns the date and time (in UTC) at which the user stops
- * being locked out. A value of 0 indicates the user is not currently
- * locked out. If the user is locked out forever, the value
- * will be equal to -1.
- *
- * @return the date and time (in UTC) at which the user stops being
- * locked out
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public int getLockedUntil() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return lockedUntil;
- }
-
- /**
- * KAS: Returns the date and time at which the user stops being locked out.
- * A value of null
indicates the user is not currently locked
- * out. If the user is locked out forever, the value
- * getLockedUntil().getTime().getTime()
will be equal to -1.
- *
- * @return the date and time at which the user stops being locked out
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- public GregorianCalendar getLockedUntilDate() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- if( lockedUntilDate == null ) {
- // make it into a date . . .
- Date d;
- if( lockedUntil == 0 ) {
- lockedUntilDate = null;
- } else if( lockedUntil == -1 ) {
- d = new Date( lockedUntil );
- lockedUntilDate = new GregorianCalendar();
- lockedUntilDate.setTime( d );
- } else {
- d = new Date( ((long) lockedUntil)*1000 );
- lockedUntilDate = new GregorianCalendar();
- lockedUntilDate.setTime( d );
- }
- }
- return lockedUntilDate;
- }
-
- /////////////// mutators ////////////////////
-
- /**
- * PTS: Sets how many more groups this user is allowed to create.
- * -1 indicates unlimited.
- *
- * @param quota the new group creation quota
- */
- public void setGroupCreationQuota( int quota )
- {
- groupCreationQuota = quota;
- }
-
-
- /**
- * PTS: Sets who can list the status (pts examine) of this user.
- * Valid values are:
- * {@link #USER_OWNER_ACCESS}
- * -- only the owner has permission{@link #USER_ANYUSER_ACCESS}
- * -- any user has permission{@link #USER_OWNER_ACCESS}
- * -- only the owner has permission{@link #USER_ANYUSER_ACCESS}
- * -- any user has permission{@link #USER_OWNER_ACCESS}
- * -- only the owner has permission{@link #USER_ANYUSER_ACCESS}
- * -- any user has permissionnull
value indicates the user never exipres.
- *
- * @param expirationDate the date and time the user expires
- */
- public void setUserExpiration( GregorianCalendar expirationDate )
- {
- userExpirationDate = expirationDate;
- if( expirationDate == null ) {
- userExpiration = -1;
- } else {
- Date d = expirationDate.getTime();
- long millis = d.getTime();
- userExpiration = (int) (millis/((long)1000));
- }
- }
-
- /**
- * KAS: Sets the maximum lifetime of a ticket issued to this user
- * (in seconds).
- *
- * @param seconds the maximum lifetime of a ticket issued to this user (in seconds).
- */
- public void setMaxTicketLifetime( int seconds )
- {
- maxTicketLifetime = seconds;
- }
-
- /**
- * KAS: Sets the number of days a password is valid before it expires.
- * A value of 0 indicates passwords never expire.
- *
- * @param days the number of days for which a password is valid
- */
- public void setDaysToPasswordExpire( int days )
- {
- daysToPasswordExpire = days;
- }
-
- /**
- * KAS: Sets the number of failed login attempts this user is allowed before
- * being locked out. A value of 0 indicates there is no limit.
- *
- * @param logins the number of failed login attempts a user is allowed
- */
- public void setFailLoginCount( int logins )
- {
- failLoginCount = logins;
- }
-
- /**
- * KAS: Sets the amount of time (in seconds) a user is locked out when it
- * exceeds the maximum number of allowable failed login attempts.
- * A value of 0 indicates an infinite lockout time. Any nonzero value gets
- * rounded up to the next highest multiple of 8.5 minutes, and any value over
- * 36 hours gets rounded down to 36 hours.
- *
- * @param seconds the number of failed login attempts a user is allowed
- */
- public void setLockTime( int seconds )
- {
- lockTime = seconds;
- }
-
- /**
- * Sets the password of this user to something new. Sets the key version
- * to 0 automatically.
- *
- * @param newPassword the new password for this user
- * @exception AFSException If an error occurs in the native code
- */
- public void setPassword( String newPassword ) throws AFSException
- {
- this.setPassword( cell.getCellHandle(), name, newPassword );
- }
-
- /////////////// custom information methods ////////////////////
-
- /**
- * Returns a String
representation of this User
.
- * Contains the information fields and groups.
- *
- * @return a String
representation of the User
- */
- public String getInfo()
- {
- String r;
- try {
-
- r = "User: " + name;
-
- if( pts ) {
- r += ", uid: " + getUID();
- }
- r += "\n";
- r += "\tKAS: " + isKAS() + "\tPTS: " + isPTS() + "\n";
-
- if( pts ) {
- r += "\towner: " + getOwner().getName() + ", uid: "
- + getOwner().getUID() + "\n";
- r += "\tcreator: " + getCreator().getName() + ", uid: "
- + getCreator().getUID() + "\n";
- r += "\tGroup creation quota: " + getGroupCreationQuota() + "\n";
- r += "\tGroup membership count: " + getGroupMembershipCount()
- + "\n";
- r += "\tList status: " + getListStatus() + "\n";
- r += "\tList groups owned: " + getListGroupsOwned() + "\n";
- r += "\tList membership: " + getListMembership() + "\n";
- }
-
- if( kas ) {
- r += "\tKAS admin status: ";
-
- if( isAdmin() ) {
- r += "Yes\n";
- } else {
- r += "No\n";
- }
-
- r += "\tTGS grant tickets: ";
- if( willGrantTickets() ) {
- r += "Yes\n";
- } else {
- r += "No\n";
- }
-
- r += "\tUse key as encryption key: ";
- if( canEncrypt() ) {
- r += "Yes\n";
- } else {
- r += "No\n";
- }
-
-
- r += "\tCan change password: ";
-
- if( canChangePassword() ) {
- r += "Yes\n";
- } else {
- r += "No\n";
- }
-
- r += "\tCan reuse password: ";
- if( canReusePassword() ) {
- r += "Yes\n";
- } else {
- r += "No\n";
- }
-
- if( userExpiration != 0 ) {
- r += "\tExpiration date: "
- + getUserExpirationDate().getTime() + "\n";
- } else {
- r += "\tUser never expires\n";
- }
- r += "\tLast modified " + getLastModTimeDate().getTime()
- + " by " + getLastModName() + "\n";
- r += "\tLast changed password "
- + getLastChangePasswordTimeDate().getTime() + "\n";
- r += "\tMax ticket lifetime: " + getMaxTicketLifetime() + "\n";
- r += "\tKey: " + getEncryptionKey() + ", version: "
- + getKeyVersion() + ", checksum: " + getKeyCheckSum() + "\n";
- r += "\tDays till password expires: " + getDaysToPasswordExpire()
- + "\n";
- r += "\tAllowed failed logins: " + getFailLoginCount() + "\n";
- r += "\tLock time after failed logins: " + getLockTime() + "\n";
- if( lockedUntil == 0 ) {
- r += "\tNot locked\n";
- } else if( getLockedUntilDate().getTime().getTime() == -1 ) {
- r += "\tLocked forever\n";
- } else {
- r += "\tLocked until: " + getLockedUntilDate().getTime()
- + "\n";
- }
-
- }
- if( pts ) {
-
- r += "\tBelongs to groups: \n";
-
- String grps[] = getGroupNames();
- for( int i = 0; i < grps.length; i++ ) {
- r += "\t\t" + grps[i] + "\n";
- }
-
- r += "\tOwns groups: \n";
- grps = getGroupsOwnedNames();
- for( int i = 0; i < grps.length; i++ ) {
- r += "\t\t" + grps[i] + "\n";
- }
-
- }
- } catch( AFSException e ) {
- return e.toString();
- }
- return r;
- }
-
- /**
- * Returns a String
containing the String
- * representations of all the groups to which this user belongs.
- *
- * @return a String
representation of the groups belonged to
- * @see Group#toString
- */
- public String getInfoGroups() throws AFSException
- {
- String r;
- r = "User: " + name + "\n\n";
- r += "--Member of Groups:--\n";
-
- Group grps[] = getGroups();
- for( int i = 0; i < grps.length; i++ ) {
- r += grps[i].getInfo() + "\n";
- }
- return r;
- }
-
- /**
- * Returns a String
containing the String
- * representations of all the groups that this user owns.
- *
- * @return a String
representation of the groups owned
- * @see Group#toString
- */
- public String getInfoGroupsOwned() throws AFSException
- {
- String r;
- r = "User: " + name + "\n\n";
- r += "--Owns Groups:--\n";
- Group grps[] = getGroupsOwned();
- for( int i = 0; i < grps.length; i++ ) {
- r += grps[i].getInfo() + "\n";
- }
- return r;
- }
-
- /////////////// custom override methods ////////////////////
-
- /**
- * Compares two User objects respective to their names and does not
- * factor any other attribute. Alphabetic case is significant in
- * comparing names.
- *
- * @param user The User object to be compared to this User instance
- *
- * @return Zero if the argument is equal to this User's name, a
- * value less than zero if this User's name is
- * lexicographically less than the argument, or a value greater
- * than zero if this User's name is lexicographically
- * greater than the argument
- */
- public int compareTo(User user)
- {
- return this.getName().compareTo(user.getName());
- }
-
- /**
- * Comparable interface method.
- *
- * @see #compareTo(User)
- */
- public int compareTo(Object obj)
- {
- return compareTo((User)obj);
- }
-
- /**
- * Tests whether two User
objects are equal, based on their
- * names.
- *
- * @param otherUser the user to test
- * @return whether the specifed user is the same as this user
- */
- public boolean equals( User otherUser )
- {
- return name.equals(otherUser.getName());
- }
-
- /**
- * Returns the name of this User
- *
- * @return the name of this User
- */
- public String toString()
- {
- return getName();
- }
-
-
- /////////////// native methods ////////////////////
-
- /**
- * Creates the kas and pts entries for a new user. Pass in 0 for the uid
- * if pts is to automatically assign the user id.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @param userName the name of the user to create
- * @param password the password for the new user
- * @param uid the user id to assign to the user (0 to have one
- * automatically assigned)
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void create( long cellHandle, String userName,
- String password, int uid )
- throws AFSException;
-
- /**
- * Deletes the pts and kas entry for a user. Deletes this user from the
- * membership list of the groups to which it belonged, but does not delete
- * the groups owned by this user.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @param groupName the name of the user to delete
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void delete( long cellHandle, String userName )
- throws AFSException;
-
- /**
- * Unlocks a user.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @param groupName the name of the user to unlock
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void unlock( long cellHandle, String userName )
- throws AFSException;
-
- /**
- * Fills in the information fields of the provided User
.
- * Fills in values based on the current pts and kas information of the user.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @param name the name of the user for which to get the information
- * @param user the User
object in which to fill in the
- * information
- * @see User
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getUserInfo( long cellHandle, String name,
- User user )
- throws AFSException;
-
- /**
- * Sets the information values of this AFS user to be the parameter values.
- * Sets both kas and pts fields.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @param name the name of the user for which to set the information
- * @param theUser the User
object containing the desired
- * information
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void setUserInfo( long cellHandle, String name,
- User theUser )
- throws AFSException;
-
- /**
- * Renames the given user. Does not update the info fields of the kas entry
- * -- the calling code is responsible for that.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @param oldName the name of the user to rename
- * @param newName the new name for the user
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void rename( long cellHandle, String oldName,
- String newName )
- throws AFSException;
-
- /**
- * Sets the password of the given user. Sets the key version to 0.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @param userName the name of the user for which to set the password
- * @param newPassword the new password for the user
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void setPassword( long cellHandle, String userName,
- String newPassword )
- throws AFSException;
-
- /**
- * Begin the process of getting the groups to which the user belongs.
- * Returns an iteration ID to be used by subsequent calls to
- * getUserGroupsNext
and getUserGroupsDone
.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @param name the name of the user for which to get the groups
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- */
- protected static native long getUserGroupsBegin( long cellHandle, String name )
- throws AFSException;
-
- /**
- * Returns the next group to which the user belongs. Returns
- * null
if there are no more groups.
- *
- * @param iterationId the iteration ID of this iteration
- * @see getUserGroupsBegin
- * @return the name of the next group
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getUserGroupsNextString( long iterationId )
- throws AFSException;
-
- /**
- * Fills the next group object of which the user belongs. Returns 0 if there
- * are no more groups, != 0 otherwise.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @see Cell#getCellHandle
- * @param iterationId the iteration ID of this iteration
- * @see getUserGroupsBegin
- * @param theGroup a Group object to be populated with the values of the
- * next group
- * @return 0 if there are no more users, != 0 otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getUserGroupsNext( long cellHandle,
- long iterationId,
- Group theGroup )
- throws AFSException;
-
- /**
- * Signals that the iteration is complete and will not be accessed anymore.
- *
- * @param iterationId the iteration ID of this iteration
- * @see getUserGroupsBegin
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getUserGroupsDone( long iterationId )
- throws AFSException;
-
- /**
- * Returns the total number of groups owned by the user.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @param name the name of the user for which to get the groups
- * @return total number of groups owned by the user
- * @exception AFSException If an error occurs in the native code
- * @see Cell#getCellHandle
- */
- protected static native int getGroupsOwnedCount( long cellHandle, String name )
- throws AFSException;
-
- /**
- * Begin the process of getting the groups that a user or group owns.
- * Returns an iteration ID to be used by subsequent calls to
- * getGroupsOwnedNext
and getGroupsOwnedDone
.
- *
- * @param cellHandle the handle of the cell to which the user belongs
- * @see Cell#getCellHandle
- * @param name the name of the user or group for which to get the groups
- * @return an iteration ID
- * @exception AFSException If an error occurs in the native code
- */
- protected static native long getGroupsOwnedBegin( long cellHandle,
- String name )
- throws AFSException;
-
- /**
- * Returns the next group the user or group owns. Returns null
- * if there are no more groups.
- *
- * @param iterationId the iteration ID of this iteration
- * @see getGroupsOwnedBegin
- * @return the name of the next group
- * @exception AFSException If an error occurs in the native code
- */
- protected static native String getGroupsOwnedNextString( long iterationId )
- throws AFSException;
-
- /**
- * Fills the next group object that the user or group owns. Returns 0 if
- * there are no more groups, != 0 otherwise.
- *
- * @param cellHandle the handle of the cell to which the users belong
- * @see Cell#getCellHandle
- * @param iterationId the iteration ID of this iteration
- * @see getGroupsOwnedBegin
- * @param theGroup a Group object to be populated with the values of the
- * next group
- * @return 0 if there are no more users, != 0 otherwise
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int getGroupsOwnedNext( long cellHandle,
- long iterationId,
- Group theGroup )
- throws AFSException;
-
- /**
- * Signals that the iteration is complete and will not be accessed anymore.
- *
- * @param iterationId the iteration ID of this iteration
- * @see getGroupsOwnedBegin
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getGroupsOwnedDone( long iterationId )
- throws AFSException;
-
- /**
- * Reclaims all memory being saved by the user portion of the native library.
- * This method should be called when no more Users
are expected
- * to be used.
- */
- protected static native void reclaimUserMemory();
-}
-
-
-
-
-
-
-
-
-
diff --git a/src/JAVA/classes/org/openafs/jafs/VersionInfo.java b/src/JAVA/classes/org/openafs/jafs/VersionInfo.java
deleted file mode 100644
index ccf521f3d3..0000000000
--- a/src/JAVA/classes/org/openafs/jafs/VersionInfo.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * @(#)VersionInfo.java 1.0 05/09/2005
- *
- * Copyright (c) 2001 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.openafs.jafs;
-
-/**
- * Provides version information about the native C library and the JAVA side.
- *
- * At least a <Volume
does not mean an actual
- * AFS partition is created on a partition -- usually a Volume
- * object is a representation of an already existing AFS volume. If,
- * however, the Volume
is constructed with the name of a
- * volume that does not exist in the cell to which the provided
- * Partition
belongs, a new AFS volume with that name can be
- * created on that partition by calling the {@link #create(int)} method. If
- * such a volume does already exist when this method is called, an exception
- * will be thrown.Volume
object. This example obtains the list of
- * Volume
objects residing on a particular partition, and prints
- * out the name and id of each one.- * import org.openafs.jafs.Cell; - * import org.openafs.jafs.AFSException; - * import org.openafs.jafs.Partition; - * import org.openafs.jafs.Server; - * import org.openafs.jafs.Volume; - * ... - * public class ... - * { - * ... - * private Cell cell; - * private Server server; - * private Partition partition; - * ... - * public static void main(String[] args) throws Exception - * { - * String username = arg[0]; - * String password = arg[1]; - * String cellName = arg[2]; - * String serverName = arg[3]; - * String partitionName = arg[4]; - * - * token = new Token(username, password, cellName); - * cell = new Cell(token); - * server = cell.getServer(serverName); - * partition = cell.getPartition(partitionName); - * - * System.out.println("Volumes in Partition " + partition.getName() + ":"); - * Volume[] volumes = partition.getVolumes(); - * for (int i = 0; i < volumes.length; i++) { - * System.out.println(" -> " + volumes[i] + ": " + volumes[i].getID()); - * } - * } - * ... - * } - *- * - */ -public class Volume implements Serializable, Comparable -{ - /** - * Read-write volume type - */ - public static final int VOLUME_TYPE_READ_WRITE = 0; - /** - * Read-only volume type - */ - public static final int VOLUME_TYPE_READ_ONLY = 1; - /** - * Backup volume type - */ - public static final int VOLUME_TYPE_BACKUP = 2; - - /** - * Status/disposition ok - */ - public static final int VOLUME_OK = 0; - /** - * Status/disposition salvage - */ - public static final int VOLUME_SALVAGE = 1; - /** - * Status/disposition no vnode - */ - public static final int VOLUME_NO_VNODE = 2; - /** - * Status/disposition no volume - */ - public static final int VOLUME_NO_VOL = 3; - /** - * Status/disposition volume exists - */ - public static final int VOLUME_VOL_EXISTS = 4; - /** - * Status/disposition no service - */ - public static final int VOLUME_NO_SERVICE = 5; - /** - * Status/disposition offline - */ - public static final int VOLUME_OFFLINE = 6; - /** - * Status/disposition online - */ - public static final int VOLUME_ONLINE = 7; - /** - * Status/disposition disk full - */ - public static final int VOLUME_DISK_FULL = 8; - /** - * Status/disposition over quota - */ - public static final int VOLUME_OVER_QUOTA = 9; - /** - * Status/disposition busy - */ - public static final int VOLUME_BUSY = 10; - /** - * Status/disposition moved - */ - public static final int VOLUME_MOVED = 11; - - protected Cell cell; - protected Server server; - protected Partition partition; - - protected String name; - - protected int id; - protected int readWriteID; - protected int readOnlyID; - protected int backupID; - - protected long creationDate; - protected long lastAccessDate; - protected long lastUpdateDate; - protected long lastBackupDate; - protected long copyCreationDate; - - protected int accessesSinceMidnight; - protected int fileCount; - protected int maxQuota; - protected int currentSize; - protected int status; - protected int disposition; - protected int type; - - protected GregorianCalendar creationDateCal; - protected GregorianCalendar lastUpdateDateCal; - protected GregorianCalendar copyCreationDateCal; - - protected boolean cachedInfo; - - /** - * Constructs a new
Volume
object instance given the name of
- * the AFS volume and the AFS cell, represented by partition
,
- * to which it belongs. This does not actually
- * create a new AFS volume, it just represents one.
- * If name
is not an actual AFS volume, exceptions
- * will be thrown during subsequent method invocations on this
- * object, unless the {@link #create(int)} method is explicitly called
- * to create it.
- *
- * @param name the name of the volume to represent
- * @param partition the partition on which the volume resides
- * @exception AFSException If an error occurs in the native code
- */
- public Volume( String name, Partition partition ) throws AFSException
- {
- this.partition = partition;
- this.server = partition.getServer();
- this.cell = server.getCell();
- this.name = name;
-
- creationDateCal = null;
- lastUpdateDateCal = null;
- copyCreationDateCal = null;
-
- id = -1;
- cachedInfo = false;
- }
-
- /**
- * Constructs a new Volume
object instance given the name of
- * the AFS volume and the AFS partition, represented by
- * partition
, to which it belongs. This does not actually
- * create a new AFS volume, it just represents one.
- * If name
is not an actual AFS volume, exceptions
- * will be thrown during subsequent method invocations on this
- * object, unless the {@link #create(int)} method is explicitly called
- * to create it. Note that if the volume 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 {@link #refresh()} method to address any coherency
- * concerns.
- *
- * @param name the name of the volume to represent
- * @param partition the partition on which the volume resides.
- * @param preloadAllMembers true will ensure all object members are set
- * upon construction; otherwise members will be
- * set upon access, which is the default behavior.
- * @exception AFSException If an error occurs in the native code
- * @see #refresh
- */
- public Volume( String name, Partition partition, boolean preloadAllMembers )
- throws AFSException
- {
- this(name, partition);
- if (preloadAllMembers) refresh(true);
- }
-
- /**
- * Creates a blank Volume
given the cell to which the volume
- * belongs, the server on which the partition resides, and
- * the partition on which the volume resides. This blank
- * object can then be passed into other methods to fill out its properties.
- *
- * @exception AFSException If an error occurs in the native code
- * @param cell the cell to which the server belongs.
- * @param server the server on which the partition resides
- * @param partition the partition on which the volume resides
- */
- Volume( Partition partition ) throws AFSException
- {
- this( null, partition );
- }
-
- /*-------------------------------------------------------------------------*/
-
- /**
- * Refreshes the properties of this Volume object instance with values from
- * the AFS volume it represents. All properties that have been initialized
- * and/or accessed will be renewed according to the values of the AFS volume
- * this Volume 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.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void refresh() throws AFSException
- {
- refresh(false);
- }
-
- /**
- * Refreshes the properties of this Volume object instance with values from
- * the AFS volume it represents. If all
is true
- * then all of the properties of this Volume object instance will be
- * set, or renewed, according to the values of the AFS volume 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 {@link #refresh()} for more information.
- *
- * @param all if true set or renew all object properties; otherwise renew
- * all set properties
- * @exception AFSException If an error occurs in the native code
- * @see #refresh()
- */
- protected void refresh(boolean all) throws AFSException
- {
- if (all || cachedInfo) refreshInfo();
- }
-
- /**
- * Refreshes the information fields of this Volume
to reflect
- * the current state of the AFS volume. These include the last update time,
- * file count, etc.
- *
- * @exception AFSException If an error occurs in the native code
- */
- protected void refreshInfo() throws AFSException
- {
- getVolumeInfo( cell.getCellHandle(), server.getVosHandle(),
- partition.getID(), getID(), this );
- cachedInfo = true;
- creationDateCal = null;
- lastUpdateDateCal = null;
- copyCreationDateCal = null;
- }
-
- /**
- * Creates a new volume on the server and partition given upon construction.
- *
- * @param quota the quota for the volume in K, 0 indicates an unlimited
- * quota
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void create( int quota ) throws AFSException
- {
- id = create( cell.getCellHandle(), server.getVosHandle(),
- partition.getID(), name, quota );
- maxQuota = quota;
- }
-
- /**
- * Creates a backup volume for this volume.
- *
- * @return the Volume
object representation for the
- * backup volume that was created
- * @exception AFSException If an error occurs in the native code
- */
- public Volume createBackup( ) throws AFSException
- {
- createBackupVolume( cell.getCellHandle(), getID() );
- return new Volume( name + ".backup", partition );
- }
-
- /**
- * Creates a readonly site for this volume on the specified server and
- * partition. Automatically releases the volume.
- *
- * @param sitePartition the partition on which the readonly volume is
- * to reside
- *
- * @return the Volume
representation for the
- * read-only volume that was created
- * @exception AFSException If an error occurs in the native code
- */
- public Volume createReadOnly( Partition sitePartition )
- throws AFSException
- {
- Server siteServer = sitePartition.getServer();
- createReadOnlyVolume( cell.getCellHandle(), siteServer.getVosHandle(),
- sitePartition.getID(), getID() );
- release( false );
- return new Volume( name + ".readonly", sitePartition );
- }
-
- /**
- * Deletes the volume from the cell.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void delete() throws AFSException
- {
- delete( cell.getCellHandle(), server.getVosHandle(), partition.getID(),
- getID() );
- name = null;
- creationDateCal = null;
- lastUpdateDateCal = null;
- copyCreationDateCal = null;
- cell = null;
- server = null;
- partition = null;
- }
-
- /**
- * Releases this volume, which updates the read-only copies of it.
- *
- *
This method will force a complete release; a complete release updates
- * all read-only sites even if the VLDB entry has a flag.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void release() throws AFSException
- {
- this.release( true );
- }
-
- /**
- * Releases this volume, which updates the read-only copies of it.
- *
- * @param forceComplete whether or not to force a complete release;
- * a complete release updates all read-only sites
- * even if the VLDB entry has a flag
- * @exception AFSException If an error occurs in the native code
- */
- public void release( boolean forceComplete ) throws AFSException
- {
- release( cell.getCellHandle(), getID(), forceComplete );
- }
-
- /**
- * Dumps this volume to a file. If you use the dumpSince argument you will
- * create an incremental dump, but you can leave it null
- * for a full dump.
- *
- * @param fileName the path name of the file on the client machine to
- * which to dump this volume
- * @param dumpSince dump only files that have been modified more recently
- * than this date
- * @exception AFSException If an error occurs in the native code
- */
- public void dump( String fileName, GregorianCalendar dumpSince )
- throws AFSException
- {
- int startTime = 0;
- if ( dumpSince != null ) {
- startTime = (int) ((dumpSince.getTime().getTime())/((long) 1000));
- }
- dump( cell.getCellHandle(), server.getVosHandle(), partition.getID(),
- getID(), startTime, fileName );
- }
-
- /**
- * Dumps this volume to a file. Creates a full dump.
- *
- * @param fileName the path name of the file to which to dump this volume
- * @exception AFSException If an error occurs in the native code
- */
- public void dump( String fileName ) throws AFSException
- {
- this.dump( fileName, null );
- }
-
- /**
- * Restores a file to this volume. Note that this does not have to be an
- * existing volume in order to be restored - you may create a
- * Volume
as a volume that doesn't yet exist and then restore
- * a file to it. Or you can restore over an existing volume. If a new
- * volume is being created with this method, the id will be automatically
- * assigned.
- *
- * @param fileName the path name of the file on the client machine from
- * which to restore this volume
- * @param incremental if true, restores an incremental dump over an
- * existing volume
- * @exception AFSException If an error occurs in the native code
- */
- public void restore( String fileName, boolean incremental )
- throws AFSException
- {
- restore( fileName, incremental, 0 );
- }
-
- /**
- * Restores a file to this volume. Note that this does not have to be an
- * existing volume in order to be restored - you may create a
- * Volume
as a volume that doesn't yet exist and then restore
- * a file to it. Or you can restore over an existing volume.
- *
- * @param fileName the path name of the file on the client machine from
- * which to restore this volume
- * @param incremental if true, restores an incremental dump over an
- * existing volume
- * @param id the id to assign this volume
- * @exception AFSException If an error occurs in the native code
- */
- public void restore( String fileName, boolean incremental, int id )
- throws AFSException
- {
- restore( cell.getCellHandle(), server.getVosHandle(), partition.getID(),
- id, name, fileName, incremental );
- }
-
- /**
- * Mounts this volume, bringing it online and making it accessible.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void mount( ) throws AFSException
- {
- mount( server.getVosHandle(), partition.getID(), getID(), 0, true );
- }
-
- /**
- * Unmounts this volume, bringing it offline and making it inaccessible.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void unmount( ) throws AFSException
- {
- unmount( server.getVosHandle(), partition.getID(), getID() );
- }
-
- /**
- * Locks the VLDB enrty for this volume
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void lock( ) throws AFSException
- {
- lock( cell.getCellHandle(), getID() );
- }
-
- /**
- * Unlocks the VLDB entry for this volume
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void unlock( ) throws AFSException
- {
- unlock( cell.getCellHandle(), getID() );
- }
-
- /**
- * Moves this volume to the specified partition (which indirectly
- * specifies a new server, as well). Caution: This will remove any backup
- * volumes at the original site.
- *
- * @param newPartition the partition to which to move the volume
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void moveTo( Partition newPartition ) throws AFSException
- {
- Server newServer = newPartition.getServer();
- move( cell.getCellHandle(), server.getVosHandle(), partition.getID(),
- newServer.getVosHandle(), newPartition.getID(), getID() );
-
- server = newServer;
- partition = newPartition;
- }
-
- /**
- * Renames this volume.
- *
- * @param newName the new name for this volume
- * @exception AFSException If an error occurs in the native code
- */
- public void rename( String newName ) throws AFSException
- {
- rename( cell.getCellHandle(), getID(), newName );
- name = newName;
- }
-
- /**
- * Salvages (restores consistency to) this volume. Uses default values for
- * most salvager options in order to simplify the API.
- *
- * @exception AFSException If an error occurs in the native code
- */
- public void salvage() throws AFSException
- {
- Server.salvage( cell.getCellHandle(), server.getBosHandle(),
- partition.getName(), name, 4, null, null, false, false,
- false, false, false, false );
- }
-
- /**
- * Creates a read-write mount point for this volume. Does not ensure the
- * volume already exists.
- *
- * @param directory the name of the directory where this volume
- * should be mounted
- * @exception AFSException If an error occurs in the native code
- */
- public void createMountPoint( String directory ) throws AFSException
- {
- createMountPoint(directory, true);
- }
-
- /**
- * Creates a mount point for this volume. Does not ensure the volume
- * already exists.
- *
- * @param directory the name of the directory where this volume should be
- * mounted
- * @param readWrite whether or not this mount point should be read-write
- * @exception AFSException If an error occurs in the native code
- */
- public void createMountPoint( String directory, boolean readWrite )
- throws AFSException
- {
- Cell.createMountPoint( cell.getCellHandle(), directory, getName(),
- readWrite, false );
- }
-
- //////////////// accessors: ////////////////////////
-
- /**
- * Returns the name of this volume.
- *
- * @return the name of this volume
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Returns this volume's hosting partition.
- *
- * @return this volume's partition
- */
- public Partition getPartition()
- {
- return partition;
- }
-
- /**
- * Returns the id of this volume.
- *
- * @exception AFSException If an error occurs in the native code
- * @return the id of this volume
- */
- public int getID() throws AFSException
- {
- if( id == -1 && name != null ) {
- String nameNoSuffix;
- if( name.endsWith( "backup" ) ) {
- type = VOLUME_TYPE_BACKUP;
- nameNoSuffix = name.substring( 0, name.lastIndexOf( '.' ) );
- } else if( name.endsWith( "readonly" ) ) {
- type = VOLUME_TYPE_READ_ONLY;
- nameNoSuffix = name.substring( 0, name.lastIndexOf( '.' ) );
- } else {
- type = VOLUME_TYPE_READ_WRITE;
- nameNoSuffix = name;
- }
- id = translateNameToID( cell.getCellHandle(),
- nameNoSuffix, type );
- }
- return id;
- }
-
- /**
- * Returns the read-write ID of this volume
- *
- * @exception AFSException If an error occurs in the native code
- * @return the read-write id
- */
- public int getReadWriteID() throws AFSException
- {
- if( !cachedInfo ) {
- refreshInfo();
- }
- return readWriteID;
- }
-
- /**
- * Returns the read-only ID of this volume
- *
- * @exception AFSException If an error occurs in the native code
- * @return the read-only id
- */
- public int getReadOnlyID() throws AFSException
- {
- if( !cachedInfo ) {
- refreshInfo();
- }
- return readOnlyID;
- }
-
- /**
- * Returns the backup ID of this volume
- *
- * @exception AFSException If an error occurs in the native code
- * @return the backup id
- */
- public int getBackupID() throws AFSException
- {
- if( !cachedInfo ) {
- refreshInfo();
- }
- return backupID;
- }
-
- /**
- * Returns the date the volume was created
- *
- * @return the date the volume was created
- * @exception AFSException If an error occurs in the native code
- */
- public GregorianCalendar getCreationDate() throws AFSException
- {
- if( !cachedInfo ) {
- refreshInfo();
- }
- if( creationDateCal == null ) {
- // make it into a date . . .
- creationDateCal = new GregorianCalendar();
- Date d = new Date( creationDate*1000 );
- creationDateCal.setTime( d );
- }
- return creationDateCal;
- }
-
- /**
- * Returns the date the volume was last updated.
- * After this method is called once, it saves the date
- * and returns that date on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return the date the volume was last updated
- * @exception AFSException If an error occurs in the native code
- */
- public GregorianCalendar getLastUpdateDate() throws AFSException
- {
- if( !cachedInfo ) {
- refreshInfo();
- }
- if( lastUpdateDateCal == null ) {
- // make it into a date . . .
- lastUpdateDateCal = new GregorianCalendar();
- Date d = new Date( lastUpdateDate*1000 );
- lastUpdateDateCal.setTime( d );
- }
- return lastUpdateDateCal;
- }
-
- /**
- * Returns the date the volume was copied.
- * After this method is called once, it saves the date
- * and returns that date on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @return the date the volume was copied
- * @exception AFSException If an error occurs in the native code
- */
- public GregorianCalendar getCopyCreationDate() throws AFSException
- {
- if( !cachedInfo ) {
- refreshInfo();
- }
- if( copyCreationDateCal == null ) {
- // make it into a date . . .
- copyCreationDateCal = new GregorianCalendar();
- Date d = new Date( copyCreationDate*1000 );
- copyCreationDateCal.setTime( d );
- }
- return copyCreationDateCal;
- }
-
- /**
- * Returns the number of accesses since midnight.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @exception AFSException If an error occurs in the native code
- * @return the number of accesses since midnight
- */
- public int getAccessesSinceMidnight() throws AFSException
- {
- if( !cachedInfo ) {
- refreshInfo();
- }
- return accessesSinceMidnight;
- }
-
- /**
- * Returns file count.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @exception AFSException If an error occurs in the native code
- * @return the file count
- */
- public int getFileCount() throws AFSException
- {
- if( !cachedInfo ) {
- refreshInfo();
- }
- return fileCount;
- }
-
- /**
- * Returns current volume size in K.
- * After this method is called once, it saves the value
- * and returns that value on subsequent calls,
- * until the {@link #refresh()} method is called and a more current
- * value is obtained.
- *
- * @exception AFSException If an error occurs in the native code
- * @return the current volume size in K
- */
- public int getCurrentSize() throws AFSException
- {
- if( !cachedInfo ) refreshInfo();
- return currentSize;
- }
-
- /**
- * Returns the difference between quota and current volume size (in K).
- *
- *
Please note: the product of this method is not saved. - * - * @exception AFSException If an error occurs in the native code - * @return the current free space in K - */ - public int getTotalFreeSpace() throws AFSException - { - if ( !cachedInfo ) refreshInfo(); - return (maxQuota - currentSize); - } - - /** - * Returns this volume's quota, expressed in kilobyte blocks (1024 - * kilobyte blocks equal one megabyte). After this method is called once, - * it saves the value and returns that value on subsequent calls, - * until the {@link #refresh()} method is called and a more current - * value is obtained. - * - *
Note: A quota value of zero, "0", grants an unlimited quota - * in AFS. Consequently, to avoid delusion this method will throw an - * {@link AFSException} if the returning value is zero. - * - * @exception AFSException If an error occurs in the native code or - * this volume's quota is configured as - * unlimited. - * @return the volume quota in K - * @see #isQuotaUnlimited() - */ - public int getQuota() throws AFSException - { - if ( !cachedInfo ) refreshInfo(); - if (maxQuota == 0) { - throw new AFSException("Volume with id " + id + - " has an unlimited quota configured.", 0); - } - return maxQuota; - } - - /** - * Tests whether this volume's quota is configured as unlimited. - * - *
After this method is called once, it saves the value and returns
- * that value on subsequent calls, until the {@link #refresh()}
- * method is called and a more current value is obtained.
- *
- * @exception AFSException If an error occurs in the native code
- * @return true
if this volume's quota is configured as
- * unlimited; otherwise false
.
- * @see #getQuota()
- */
- public boolean isQuotaUnlimited() throws AFSException
- {
- if ( !cachedInfo ) refreshInfo();
- return (maxQuota == 0);
- }
-
- /**
- * Returns volume status. Possible values are:
String
representation of this Volume
.
- * Contains the information fields.
- *
- * @return a String
representation of the Volume
- */
- public String getInfo()
- {
- String r;
- try {
- r = "Volume: " + name + "\tid: " + getID() + "\n";
-
- r += "\tread-write id: " + getReadWriteID() + "\tread-only id: "
- + getReadOnlyID() + "\n";
- r += "\tbackup id: " + getBackupID() + "\n";
-
- r += "\tcreation date: " + getCreationDate().getTime() + "\n";
- r += "\tlast update date: " + getLastUpdateDate().getTime() + "\n";
- r += "\tcopy creation date: " + getCopyCreationDate().getTime() + "\n";
- r += "\taccesses since midnight: " + getAccessesSinceMidnight() + "\n";
- r += "\tfile count: " + getFileCount() + "\n";
- r += "\tcurrent size: " + getCurrentSize() + " K\tquota: " +
- getQuota() + " K\n";
- r += "\tstatus: ";
- switch( getStatus() ) {
- case VOLUME_OK:
- r += "OK";
- break;
- default:
- r += "OTHER";
- }
-
- r += "\tdisposition: ";
- switch( getDisposition() ) {
- case VOLUME_ONLINE:
- r += "ONLINE";
- break;
- default:
- r += "OTHER - " + getDisposition();
- }
- r += "\n";
-
- r += "\ttype: ";
- switch( getType() ) {
- case VOLUME_TYPE_READ_WRITE:
- r += "read-write";
- break;
- case VOLUME_TYPE_READ_ONLY:
- r += "read-only";
- break;
- case VOLUME_TYPE_BACKUP:
- r += "backup";
- break;
- default:
- r += "OTHER";
- }
- r += "\n";
-
- } catch( Exception e ) {
- return e.toString();
- }
- return r;
- }
-
- /////////////// custom override methods ////////////////////
-
- /**
- * Compares two Volume objects respective to their names and does not
- * factor any other attribute. Alphabetic case is significant in
- * comparing names.
- *
- * @param volume The Volume object to be compared to this Volume
- * instance
- *
- * @return Zero if the argument is equal to this Volume's name, a
- * value less than zero if this Volume's name is
- * lexicographically less than the argument, or a value greater
- * than zero if this Volume's name is lexicographically
- * greater than the argument
- */
- public int compareTo(Volume volume)
- {
- return this.getName().compareTo(volume.getName());
- }
-
- /**
- * Comparable interface method.
- *
- * @see #compareTo(Volume)
- */
- public int compareTo(Object obj)
- {
- return compareTo((Volume)obj);
- }
-
- /**
- * Tests whether two Volume
objects are equal, based on their
- * names and hosting partition.
- *
- * @param otherVolume the Volume to test
- * @return whether the specifed Volume is the same as this Volume
- */
- public boolean equals( Volume otherVolume )
- {
- return ( name.equals(otherVolume.getName()) ) &&
- ( this.getPartition().equals(otherVolume.getPartition()) );
- }
-
- /**
- * Returns the name of this Volume
- *
- * @return the name of this Volume
- */
- public String toString()
- {
- return getName();
- }
-
-
- /////////////// native methods ////////////////////
-
- /**
- * Fills in the information fields of the provided Volume
.
- *
- * @param cellHandle the handle of the cell to which the volume belongs
- * @see Cell#getCellHandle
- * @param serverHandle the vos handle of the server on which the volume
- * resides
- * @see Server#getVosServerHandle
- * @param partition the numeric id of the partition on which the volume
- * resides
- * @param volId the numeric id of the volume for which to get the info
- * @param theVolume the {@link Volume Volume} object in which to fill in
- * the information
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void getVolumeInfo( long cellHandle, long serverHandle,
- int partition, int volId,
- Volume theVolume )
- throws AFSException;
-
- /**
- * Creates a volume on a particular partition.
- *
- * @param cellHandle the handle of the cell in which to create the volume
- * @see Cell#getCellHandle
- * @param serverHandle the vos handle of the server on which to create
- * the volume
- * @see Server#getVosServerHandle
- * @param partition the numeric id of the partition on which to create
- * the volume
- * @param volumeName the name of the volume to create
- * @param quota the amount of space (in KB) to set as this volume's quota
- * @return the numeric ID assigned to the volume
- * @exception AFSException If an error occurs in the native code
- */
- protected static native int create( long cellHandle, long serverHandle,
- int partition, String volumeName,
- int quota )
- throws AFSException;
-
- /**
- * Deletes a volume from a particular partition.
- *
- * @param cellHandle the handle of the cell in which to delete the volume
- * @see Cell#getCellHandle
- * @param serverHandle the vos handle of the server from which to delete
- * the volume
- * @see Server#getVosServerHandle
- * @param partition the numeric id of the partition from which to delete
- * the volume
- * @param volId the numeric id of the volume to delete
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void delete( long cellHandle, long serverHandle,
- int partition, int volId )
- throws AFSException;
-
- /**
- * Creates a backup volume for the specified regular volume.
- *
- * @param cellHandle the handle of the cell to which the volume belongs
- * @param volId the numeric id of the volume for which to create a backup
- * volume
- * @see Cell#getCellHandle
- */
- protected static native void createBackupVolume( long cellHandle, int volId )
- throws AFSException;
-
- /**
- * Creates a read-only volume for the specified regular volume.
- *
- * @param cellHandle the handle of the cell to which the volume belongs
- * @param serverHandle the vos handle of the server on which the read-only
- * volume is to reside
- * @see Server#getVosServerHandle
- * @param partition the numeric id of the partition on which the read-only
- volume is to reside
- * @param volId the numeric id of the volume for which to create a read-only volume
- * @see Cell#getCellHandle
- */
- protected static native void createReadOnlyVolume( long cellHandle,
- long serverHandle,
- int partition, int volId )
- throws AFSException;
-
- /**
- * Deletes a read-only volume for the specified regular volume.
- *
- * @param cellHandle the handle of the cell to which the volume belongs
- * @param serverHandle the vos handle of the server on which the read-only
- * volume residea
- * @see Server#getVosServerHandle
- * @param partition the numeric id of the partition on which the read-only
- * volume resides
- * @param volId the numeric read-write id of the volume for which to
- * delete the read-only volume
- * @see Cell#getCellHandle
- */
- protected static native void deleteReadOnlyVolume( long cellHandle,
- long serverHandle,
- int partition, int volId )
- throws AFSException;
-
- /**
- * Changes the quota of the specified volume.
- *
- * @param cellHandle the handle of the cell to which the volume belongs
- * @see Cell#getCellHandle
- * @param serverHandle the vos handle of the server on which the volume
- * resides
- * @see Server#getVosServerHandle
- * @param partition the numeric id of the partition on which the volume
- * resides
- * @param volId the numeric id of the volume for which to change the quota
- * @param newQuota the new quota (in KB) to assign the volume
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void changeQuota( long cellHandle, long serverHandle,
- int partition, int volId,
- int newQuota )
- throws AFSException;
-
- /**
- * Move the specified volume to a different site.
- *
- * @param cellHandle the handle of the cell to which the volume belongs
- * @see Cell#getCellHandle
- * @param fromServerHandle the vos handle of the server on which the volume
- * currently resides
- * @see Server#getVosServerHandle
- * @param fromPartition the numeric id of the partition on which the volume
- * currently resides
- * @param toServerHandle the vos handle of the server to which the volume
- * should be moved
- * @param toPartition the numeric id of the partition to which the volume
- * should be moved
- * @param volId the numeric id of the volume to move
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void move( long cellHandle, long fromServerHandle,
- int fromPartition, long toServerHandle,
- int toPartition, int volId )
- throws AFSException;
-
- /**
- * Releases the specified volume that has readonly volume sites.
- *
- * @param cellHandle the handle of the cell to which the volume belongs
- * @param volId the numeric id of the volume to release
- * @param forceComplete whether or not to force a complete release
- * @see Cell#getCellHandle
- */
- protected static native void release( long cellHandle, int volId,
- boolean forceComplete )
- throws AFSException;
-
- /**
- * Dumps the specified volume to a file.
- *
- * @param cellHandle the handle of the cell to which the volume belongs
- * @see Cell#getCellHandle
- * @param serverHandle the vos handle of the server on which the volume
- * resides
- * @see Server#getVosServerHandle
- * @param partition the numeric id of the partition on which the
- * volume resides
- * @param volId the numeric id of the volume to dump
- * @param startTime files with a modification time >= to this time will
- * be dumped
- * @param dumpFile the full path of the file to which to dump
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void dump( long cellHandle, long serverHandle,
- int partition, int volId, int startTime,
- String dumpFile )
- throws AFSException;
-
- /**
- * Restores the specified volume from a dump file.
- *
- * @param cellHandle the handle of the cell to which the volume belongs
- * @see Cell#getCellHandle
- * @param serverHandle the vos handle of the server on which the volume is
- * to reside
- * @see Server#getVosServerHandle
- * @param partition the numeric id of the partition on which the volume is
- * to reside
- * @param volId the numeric id to assign the restored volume (can be 0)
- * @param volumeName the name of the volume to restore as
- * @param dumpFile the full path of the dump file from which to restore
- * @param incremental if true, restores an incremental dump over an existing
- * volume (server and partition values must correctly
- * indicate the current position of the existing volume),
- * otherwise restores a full dump
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void restore( long cellHandle, long serverHandle,
- int partition, int volId,
- String volumeName, String dumpFile,
- boolean incremental )
- throws AFSException;
-
- /**
- * Renames the specified read-write volume.
- *
- * @param cellHandle the handle of the cell to which the volume belongs
- * @see Cell#getCellHandle
- * @param volId the numeric id of the read-write volume to rename
- * @param newVolumeName the new name for the volume
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void rename( long cellHandle, int volId,
- String newVolumeName )
- throws AFSException;
-
- /**
- * "Mounts" the specified volume, bringing it online.
- *
- * @param serverHandle the vos handle of the server on which the volume
- * resides
- * @see Server#getVosServerHandle
- * @param partition the numeric id of the partition on which the volume
- * resides
- * @param volId the numeric id of the volume to bring online
- * @param sleepTime ? (not sure what this is yet, possibly a time to wait
- * before brining it online)
- * @param offline ? (not sure what this is either, probably the current
- * status of the volume -- busy or offline)
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void mount( long serverHandle, int partition,
- int volId, int sleepTime,
- boolean offline )
- throws AFSException;
-
- /**
- * "Unmounts" the specified volume, bringing it offline.
- *
- * @param serverHandle the vos handle of the server on which the volume
- * resides
- * @see Server#getVosServerHandle
- * @param partition the numeric id of the partition on which the volume
- * resides
- * @param volId the numeric id of the volume to bring offline
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void unmount( long serverHandle, int partition,
- int volId )
- throws AFSException;
-
- /**
- * Locks the VLDB entry specified volume
- *
- * @param cellHandle the handle of the cell on which the volume resides
- * @see Cell#getCellHandle
- * @param volId the numeric id of the volume to lock
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void lock( long cellHandle, int volId )
- throws AFSException;
-
- /**
- * Unlocks the VLDB entry of the specified volume
- *
- * @param cellHandle the handle of the cell on which the volume resides
- * @see Cell#getCellHandle
- * @param volId the numeric id of the volume to unlock
- * @exception AFSException If an error occurs in the native code
- */
- protected static native void unlock( long cellHandle, int volId )
- throws AFSException;
-
- /**
- * Translates a volume name into a volume id
- *
- * @param cellHandle the handle of the cell to which the volume belongs
- * @see Cell#getCellHandle
- * @param name the name of the volume in question, cannot end in backup or
- * readonly
- * @param type the type of volume: read-write, read-only, or backup.
- * Acceptable values are:Volume
- * objects are expected to be used.
- */
- protected static native void reclaimVolumeMemory();
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/JAVA/classes/testAFS.java b/src/JAVA/classes/testAFS.java
deleted file mode 100644
index c0110a9f1e..0000000000
--- a/src/JAVA/classes/testAFS.java
+++ /dev/null
@@ -1,684 +0,0 @@
-import java.io.File;
-import java.util.GregorianCalendar;
-
-import org.openafs.jafs.*;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public class testAFS
-{
- public class TesterThread implements Runnable
- {
- private String user = null;
- private String pass = null;
- private String cell = null;
- private boolean letItRun = true;
-
- public TesterThread(String user, String pass, String cell)
- {
- this.user = user;
- this.pass = pass;
- this.cell = cell;
- }
- public void finish()
- {
- letItRun = false;
- }
- public void run()
- {
- while(letItRun)
- {
- try
- {
- Token t = new Token(user, pass, cell);
- Cell c = new Cell(t, false);
- c.getInfo();
-
- for(int j=0; j<100; j++)
- {
- ACL acl = new ACL("/afs/." + cell, true);
- }
-
- c.close();
- } catch(Exception e) {
- e.printStackTrace();
- }
- Thread.yield();
- }
- }
- }
-
-
- static java.io.PrintStream out = System.out;
- static String firstCellPathRW = null;
-
- static boolean allowDump = true;
-
- static int ident = 0;
-
- static void DumpBegin()
- {
- if (allowDump)
- {
- for(int i=0; i-1
if there is no more data because the end of
- * the file has been reached.
- * @exception AFSFileException if an I/O or other file related error occurs.
- */
-JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileInputStream_read
- (JNIEnv *env, jobject obj, jbyteArray jbytes, jint offset, jint length)
-{
- int fd, bytesLen, bytesRead;
- jclass thisClass;
- jmethodID getFileDescriptorID;
- jbyte *bytes;
- jfieldID fid;
-
- /* If we have to read 0 bytes just return */
- if(length == 0) return 0;
-
- thisClass = (*env)->GetObjectClass(env, obj);
- fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
- fd = (*env)->GetIntField(env, obj, fid);
-
- if(fd < 0) {
- fprintf(stderr, "FileInputStream::read(): invalid file state\n");
- throwAFSFileException(env, 0, "Invalid file state");
- return -1;
- }
-
- bytes = (*env) -> GetByteArrayElements(env, jbytes, 0);
- bytesLen = (*env) -> GetArrayLength(env, jbytes);
- bytesRead = uafs_read(fd, bytes, bytesLen);
-
- if (errno != 0) throwAFSFileException(env, errno, NULL);
-
- (*env) -> ReleaseByteArrayElements(env, jbytes, bytes, 0);
- return (bytesRead > 0) ? bytesRead : -1;
-}
-
-/**
- * Closes this file input stream and releases any system resources
- * associated with this stream. This file input stream may no longer
- * be used for writing bytes.
- *
- * env the Java environment
- * obj the current Java object
- *
- * @exception AFSFileException if an I/O or other file related error occurs.
- */
-JNIEXPORT void JNICALL Java_org_openafs_jafs_FileInputStream_close
- (JNIEnv *env, jobject obj)
-{
- int fd, rc;
- jclass thisClass;
- jmethodID getFileDescriptorID;
- jfieldID fid;
- char *bytes;
-
- thisClass = (*env)->GetObjectClass(env, obj);
- fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
- fd = (*env)->GetIntField(env, obj, fid);
-
- if(fd < 0) {
- fprintf(stderr, "FileInputStream::close(): invalid file state\n");
- throwAFSFileException(env, 0, "Invalid file state");
- return;
- }
-
- rc = uafs_close(fd);
-
- if (rc != 0) {
- throwAFSFileException(env, errno, NULL);
- }
-}
-
-
-
diff --git a/src/JAVA/libjafs/FileOutputStream.c b/src/JAVA/libjafs/FileOutputStream.c
deleted file mode 100644
index 3223e9feb0..0000000000
--- a/src/JAVA/libjafs/FileOutputStream.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (c) 2001-2002 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include This method does not require the user's username and password to - * fully authenticate their request. Rather it utilizes the user's PAG ID - * to recapture the user's existing credentials. - * - * env the Java environment - * obj the current Java class - * id User's current PAG (process authentication group) ID - * - * throws AFSException - */ -JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_relog - (JNIEnv *env, jobject obj, jint id) -{ - int rc; - - rc = afs_setpag_val(id); - - if (rc != 0) { - throwAFSException( env, rc ); - } -} - -/** - * Authenticates a user in KAS, and binds that authentication - * to the current process. - * - * env the Java environment - * obj the current Java class - * - * throws AFSException - */ -JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_unlog - (JNIEnv *env, jobject obj) -{ - int rc; - - rc = uafs_unlog(); - - if (rc != 0) { - throwAFSException( env, rc ); - } -} - -/** - * Inform the native library that the application is - * shutting down and will be unloading. - * - *
The library will make a call informing the file server that it will
- * no longer be available for callbacks.
- *
- * env the Java environment
- * obj the current Java class
- *
- * throws AFSException
- */
-JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_shutdown
- (JNIEnv *env, jobject obj)
-{
- uafs_Shutdown();
-}
-
-
-
-
diff --git a/src/JAVA/libjafs/Version2.c b/src/JAVA/libjafs/Version2.c
deleted file mode 100644
index 20c3979a0b..0000000000
--- a/src/JAVA/libjafs/Version2.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "JAFS_Version.h"
-#include "org_openafs_jafs_VersionInfo.h"
-
-JNIEXPORT jstring JNICALL Java_org_openafs_jafs_VersionInfo_getVersionOfLibjafsadm
- (JNIEnv *env, jobject obj)
-{
- return (*env)->NewStringUTF(env, VERSION_LIB_JAVA_OPENAFS);
-}
-
-JNIEXPORT jstring JNICALL Java_org_openafs_jafs_VersionInfo_getBuildInfoOfLibjafsadm
- (JNIEnv *env, jobject obj)
-{
- return (*env)->NewStringUTF(env, cml_version_number);
-}
diff --git a/src/JAVA/libjafs/VersionInfo.c b/src/JAVA/libjafs/VersionInfo.c
deleted file mode 100644
index 8e16d9fc6f..0000000000
--- a/src/JAVA/libjafs/VersionInfo.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "JAFS_Version.h"
-#include "org_openafs_jafs_VersionInfo.h"
-
-JNIEXPORT jstring JNICALL Java_org_openafs_jafs_VersionInfo_getVersionOfLibjafs
- (JNIEnv *env, jobject obj)
-{
- return (*env)->NewStringUTF(env, VERSION_LIB_JAVA_OPENAFS);
-}
-
-JNIEXPORT jstring JNICALL Java_org_openafs_jafs_VersionInfo_getBuildInfoOfLibjafs
- (JNIEnv *env, jobject obj)
-{
- return (*env)->NewStringUTF(env, cml_version_number);
-}
diff --git a/src/JAVA/libjafs/Volume.c b/src/JAVA/libjafs/Volume.c
deleted file mode 100644
index 41f7be4b1c..0000000000
--- a/src/JAVA/libjafs/Volume.c
+++ /dev/null
@@ -1,901 +0,0 @@
-/*
- * Copyright (c) 2001-2002 International Business Machines Corp.
- * All rights reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License. For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "Internal.h"
-#include "org_openafs_jafs_Volume.h"
-
-#include