package org.okip.service.filing.api;
/*
   Copyright (c) 2002 Massachusetts Institute of Technology

   This work, including any software, documents, or other related items
   (the "Work"), is being provided by the copyright holder(s) subject to
   the terms of the MIT OKI(TM) API Definition License. By obtaining,
   using and/or copying this Work, you agree that you have read,
   understand, and will comply with the following terms and conditions of
   the MIT OKI(TM) API Definition License:

   You may use, copy, and distribute unmodified versions of this Work for
   any purpose, without fee or royalty, provided that you include the
   following on ALL copies of the Work that you make or distribute:

    *  The full text of the MIT OKI(TM) API Definition License in a
       location viewable to users of the redistributed Work.

    *  Any pre-existing intellectual property disclaimers, notices, or
       terms and conditions. If none exist, a short notice similar to the
       following should be used within the body of any redistributed
       Work: "Copyright (c) 2002 Massachusetts Institute of Technology. All
       Rights Reserved."

   You may modify or create Derivatives of this Work only for your
   internal purposes. You shall not distribute or transfer any such
   Derivative of this Work to any location or any other third party. For
   purposes of this license, "Derivative" shall mean any derivative of
   the Work as defined in the United States Copyright Act of 1976, such
   as a translation or modification.

   THIS WORK PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE WORK
   OR THE USE OR OTHER DEALINGS IN THE WORK.

   The name and trademarks of copyright holder(s) and/or MIT may NOT be
   used in advertising or publicity pertaining to the Work without
   specific, written prior permission. Title to copyright in the Work and
   any associated documentation will at all times remain with the
   copyright holders.

*/

/*
 * $Source: /cvs/oki/tech/src/org/okip/service/filing/api/CabinetEntry.java,v $
 */

/**
 * A entry in a Cabinet, usually a ByteStore or another Cabinet.
 * <p>
 * Licensed under the {@link org.okip.service.ApiLicense MIT OKI&#153; API Definition License}.
 *
 * @version $Name:  $ / $Revision: 1.9 $ / $Date: 2002/11/14 18:12:54 $
 */
public interface CabinetEntry
extends java.io.Serializable, Comparable  {

  /**
   * Tests whether this is a Cabinet.
   *
   *
   * @return boolean - true if this entry is a Cabinet.
   *
   */
  public boolean isCabinet();
  //throws FilingException;

  /**
   * Tests whether this is a ByteStore.
   *
   *
   * @return boolean - true if this entry is a ByteStore.
   *
   */
  public boolean isByteStore();
  //throws FilingException;

  /**
   * Returns the Cabinet in which this is an entry, or null if it has
   * no parent (for example is the root cabinet).
   *
   *
   * @return Cabinet - the parent Cabinet of this entry, or null if it has
   * no parent (e.g. is the root cabinet)
   *
   * @throws FilingIOException - if an IO error occurs.
   * @throws FilingPermissionDeniedException - if Factory Owner
   * does not have read permission on the parent Cabinet.
   */
  public Cabinet getParent()
  throws FilingException;

  /**
   * Return the name of this CabinetEntry in its parent Cabinet.
   *
   * @return name
   *
   */
  public String getName();
  //throws FilingException;

  /**
   * Return the path, the sequence of names of CabinetEntries leading
   * to this CabinetEntry from its root Cabinet.
   *
   * @return path
   *
   */
  public String getPath();
  //throws FilingException;

  /**
   * Tests whether the Factory Owner may read this CabinetEntry.
   *
   * @return <code>true</code> if and only if this CabinetEntry can be
   *          read by the Factory Owner; <code>false</code> otherwise
   *
   */
  public boolean canRead();
  //throws FilingException;

  /**
   * Tests whether the Factory Owner may modify this CabinetEntry.
   *
   * @return <code>true</code> if and only if the Factory Owner is
   *          allowed to write to this CabinetEntry
   *          <code>false</code> otherwise.
   *
   */
  public boolean canWrite();
  //throws FilingException;

  //[GS]

  // I. REFACTORINGS
  /**
   * Get ID of this CabinetEntry
   *
   * @return ID
   *
   */
  public ID getID()
  throws FilingException;

  /**
   * Returns the time that this Cabinet was last modified.
   *
   * @return  A <code>long</code> value representing the time the file was
   *          last modified, measured in milliseconds since the epoch
   *          (00:00:00 GMT, January 1, 1970)
   *
   * @throws FilingIOException - if an IO error occurs.
  */
  public long getLastModifiedTime()
  throws FilingException;

  /**
   * Sets the last-modified time of this Cabinet.
   *
   * <p> All platforms support file-modification times to the nearest second,
   * but some provide more precision.  The argument will be truncated to fit
   * the supported precision.  If the operation succeeds and no intervening
   * operations on the file take place, then the next invocation of the
   * <code>{@link #getLastModifiedTime}</code> method will return the (possibly
   * truncated) <code>time</code> argument that was passed to this method.
   *
   * @param  time  The new last-modified time, measured in milliseconds since
   *               the epoch (00:00:00 GMT, January 1, 1970)
   *
   * @return <code>true</code> if and only if the operation succeeded;
   *          <code>false</code> otherwise
   *
   * @throws FilingException - If the argument is negative
   * @throws FilingPermissionDeniedException - if Factory Owner
   * does not have permission to set the lastModified time.
   * @throws FilingIOException - if an IO error occurs setting the
   * lastModified time.
   */
  public boolean setLastModifiedTime(long time)
  throws FilingException;

   /**
   * Returns the time that this Cabinet was last accessed.
   *
   * Not all implementations will record last access times accurately,
   * due to caching and for performance.  The value returned will be
   * at least the last modified time, the actual time when a read was
   * performed may be later.
   *
   * @return  A <code>long</code> value representing the time the file was
   *          last accessed, measured in milliseconds since the epoch
   *          (00:00:00 GMT, January 1, 1970)
   *
   * @throws FilingIOException - if an IO error occurs.
   */
  public long getLastAccessedTime()
  throws FilingException;

  /**
   * Returns the time that this CabinetEntry was created.
   *
   * Not all implementations will record the time of creation
   * accurately.  The value returned will be at least the last
   * modified time, the actual creation time may be earlier.
   *
   * @return  A <code>long</code> value representing the time the file was
   *          created, measured in milliseconds since the epoch
   *          (00:00:00 GMT, January 1, 1970)
   *
   * @throws FilingIOException - if an IO error occurs.
   */
  public long getCreatedTime()
  throws FilingException;

  /**
   * Deletes this CabinetEntry.
   *
   * CabinetEntry must be empty, and the Owner of the Factory must have
   * sufficient permissions.
   *
   * @return  <code>true</code> if and only if this Cabinet is
   *          successfully deleted; <code>false</code> otherwise
   *
   * @throws FilingPermissionDeniedException - if Factory Owner
   * does not have permission to delete this Cabinet.
   * @throws FilingIOException - if an IO error occurs deleting the
   * lastModified time.
   * @throws FilingException - if the Cabinet isn't empty.
   */
  public boolean delete()
  throws FilingException;

  /**
   * Return owner of this Cabinet.
   *
   * Owner may be used for quota and/or access control.
   *
   * @return owner
   *
   * @throws FilingPermissionDeniedException - if Factory Owner
   * does not have permission to learn who owns this Cabinet.
   * @throws FilingIOException - if an IO error occurs.
   * @throws UnsupportedFilingOperationException - if owners of Cabinets
   * are not implemented.
   */
  public org.okip.service.shared.api.Agent getOwner()
  throws FilingException;

  /**
   * Set owner of this Cabinet.
   *
   * Owner may be used for quota and/or access control.
   *
   * @param owner
   *
   * @throws FilingPermissionDeniedException - if Factory Owner
   * does not have permission to change ownership of this Cabinet.
   * @throws FilingIOException - if an IO error occurs.
   * @throws UnsupportedFilingOperationException - if owners of Cabinets
   * are not implemented.
   */
  public void setOwner(org.okip.service.shared.api.Agent owner)
  throws FilingException;

  /**
   * Marks this ByteStore so that only read operations are allowed.
   * After invoking this method this ByteStore is guaranteed not to
   * change until it is either deleted or marked to allow write
   * access.
   *
   * Note that whether or not a read-only ByteStore may be deleted
   * depends upon the underlying system of the implementation.
   *
   * @return <code>true</code> if and only if the operation succeeded;
   *          <code>false</code> otherwise
   *
   * @throws FilingPermissionDeniedException - if Factory Owner
   * does not have permission to set the ByteStore readOnly.
   * @throws FilingIOException - if an IO error occurs.
   */
  public boolean setReadOnly()
  throws FilingException;

  /**
   * Marks this Cabinet so that write operations are allowed.
   *
   * @return <code>true</code> if and only if the operation succeeded;
   *          <code>false</code> otherwise
   *
   * @throws FilingPermissionDeniedException - if Factory Owner
   * does not have permission to set the Cabinet writable.
   * @throws FilingIOException - if an IO error occurs.
   * @throws UnsupportedFilingOperationException - if it is not
   * possible to set writable in this implementation
   */
  public boolean setWritable()
  throws FilingException;

  /**
   * Indicates whether this entry exists
   */

  public boolean exists();

    /**
     * Change the name of this entry to <code>newName</code>
     *
     * @param newName the new name for the entry
     *
     * @return  <code>true</code> if and only if the renaming succeeded;
     *          <code>false</code> otherwise
     */
    public boolean rename(String newName) throws FilingException;

}
