remm        02/01/02 09:14:17

  Added:       src/stores/slidestore/file XMLFileDescriptorsStore.java
  Removed:     src/stores/slidestore/file XAFileContentStore.java
                        XMLMemDescriptorsStore.java
  Log:
  - Rename the new filesystem based store, so that its name reflects what it does.
  - Remove the old WIP file store.
  
  Revision  Changes    Path
  1.1                  
jakarta-slide/src/stores/slidestore/file/XMLFileDescriptorsStore.java
  
  Index: XMLFileDescriptorsStore.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/stores/slidestore/file/XMLFileDescriptorsStore.java,v 1.1 
2002/01/02 17:14:17 remm Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/02 17:14:17 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
   * ITS 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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package slidestore.file;
  
  import java.util.Hashtable;
  import java.util.Enumeration;
  import java.util.Vector;
  import java.io.File;
  import org.apache.slide.common.*;
  import org.apache.slide.store.*;
  import org.apache.slide.structure.*;
  import org.apache.slide.security.*;
  import org.apache.slide.lock.*;
  import org.apache.slide.content.*;
  
  /**
   * Memory with persistence, reorganization of the <a 
href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
   * Reference implementation.
   * Use of UriProperties.
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]";>Marc D�cugis</a>
   * @contact <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a> 
   * @version $Revision: 1.1 $ , $Date: 2002/01/02 17:14:17 $
   */
  public class XMLFileDescriptorsStore extends AbstractService
      implements LockStore, NodeStore, RevisionDescriptorsStore,
      RevisionDescriptorStore, SecurityStore {
      
      
      // ----------------------------------------------------- Instance Variables
      
      
      /** Caches all the uri's definition */
      protected Hashtable definitions;
  
      /**
       * Path from which files are stored.
       */
      protected String rootpath;
  
      /**
       * Return de uri properties associated with uri
       * @return null if the uri has no properties
       */
      protected UriProperties getUriProperties(Uri uri) {
          return (UriProperties)definitions.get(uri.toString());
      }
  
      
      // ---------------------------------------------------- ServiceImpl Methods
      
      
      /**
       * Initializes the descriptors store with a set of parameters.
       * Those could be :
       * <li>User name, login info
       * <li>Host name on which to connect
       * <li>Remote port
       * <li>JDBC driver whoich is to be used :-)
       * <li>Anything else ...
       *
       * @param parameters Hashtable containing the parameters' name
       * and associated value
       */
      public void setParameters(Hashtable parameters)
          throws ServiceParameterErrorException,
          ServiceParameterMissingException {
                // copy/paste of FileDescriptorsStoreNoVersioning
                
                
          // A parameter will tell were serialization files are.
          rootpath = (String) parameters.get("rootpath");
          if (rootpath == null) {
              // Default is that files are stored starting in the 
              // current directory
              rootpath = "";
          }
                System.out.println("----------- XMLMemDescriptorsStore setParameters 
rootpath="+rootpath);
      }
      
      
      /**
       * Connects to descriptors store.
       *
       * @exception DataException
       */
      public synchronized void connect()
          throws ServiceConnectionFailedException {
                System.out.println("----------- XMLMemDescriptorsStore connect 
definitions="+definitions);
          if (definitions == null) {
              definitions = new Hashtable();
          }
      }
      
      
      /**
       * Disconnects from descriptors store.
       *
       * @exception ServiceDisconnectionFailedException
       */
      public void disconnect()
          throws ServiceDisconnectionFailedException {
      }
      
      
      /**
       * Initializes descriptors store.
       *
       * @exception ServiceInitializationFailedException Throws an exception
       * if the descriptors store has already been initialized before
       */
      public synchronized void initialize(NamespaceAccessToken token)
          throws ServiceInitializationFailedException {
          super.initialize(token);
                System.out.println("----------- XMLMemDescriptorsStore initialize 
token="+token);
                definitions = new Hashtable();
      }
      
      
      /**
       * Deletes descriptors store. Should remove stored data if possible.
       *
       * @exception ServiceResetFailedException Reset failed
       */
      public synchronized void reset()
          throws ServiceResetFailedException {
                
                definitions = new Hashtable();
      }
      
      
      /**
       * Does nothing.
       *
       * @exception ServiceAccessException Service access error
       */
      public void commit()
          throws ServiceAccessException {
      }
      
      
      /**
       * This function tells whether or not the descriptors store is connected.
       *
       * @return boolean true if we are connected
       * @exception ServiceAccessException Service access error
       */
      public boolean isConnected()
          throws ServiceAccessException {
          return true;
      }
      
      
      
      // ----------------------------------------------- DescriptorsStore Methods
      
      
      /**
       * Retrive an object from the Descriptors Store.
       *
       * @param uri Uri of the object we want to retrieve
       * @exception ServiceAccessException Error accessing the Descriptors Store
       * @exception ObjectNotFoundException The object to retrieve was not found
       */
      public ObjectNode retrieveObject(Uri uri)
          throws ServiceAccessException, ObjectNotFoundException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore retrieveObject 
uri="+uri+" aProps="+aProps);
          if (aProps == null) {
                        File aFile=UriProperties.getFile(rootpath,uri);
                        if (aFile.exists()) {
                                try {
                                        aProps=new UriProperties(rootpath,uri);
                                }
                                catch (ServiceAccessException e) {
                                        throw new ObjectNotFoundException(uri);
                                }
                                definitions.put(uri.toString(),aProps);
                        }
                        else {
                                throw new ObjectNotFoundException(uri);
                        }
          }
          return aProps.retrieveObject(uri);
      }
      
      
      /**
       * Store an object in the Descriptors Store.
       *
       * @param object Object to update
       * @exception ServiceAccessException Error accessing the Descriptors Store
       * @exception ObjectNotFoundException The object to update was not found
       */
      public void storeObject(Uri uri, ObjectNode object)
          throws ServiceAccessException, ObjectNotFoundException {
          UriProperties aProps = getUriProperties(uri);
                try {
                        if (aProps == null) {
                                aProps=new UriProperties(rootpath,uri);
                                definitions.put(uri.toString(),aProps);
                        }
                }
                catch (Throwable t) {
                        t.printStackTrace();
                }
                aProps.storeObject(uri,object);
                System.out.println("----------- XMLMemDescriptorsStore storeObject 3/n 
uri="+uri+" aProps="+aProps);
  
      }
      
      
      /**
       * Create a new object in the Descriptors Store.
       *
       * @param object SlideObject
       * @param uri Uri of the object we want to create
       * @exception ServiceAccessException Error accessing the Descriptors Store
       * @exception ObjectAlreadyExistsException An object already exists
       * at this Uri
       */
      public void createObject(Uri uri, ObjectNode object)
          throws ServiceAccessException, ObjectAlreadyExistsException {
          try {
                        UriProperties aProps = getUriProperties(uri);
                        System.out.println("----------- XMLMemDescriptorsStore 1/n 
createObject uri="+uri+" aProps="+aProps);
                        if (aProps == null) {
                                storeObject(uri,object);
              }
                        else {
                                aProps.createObject(uri, object);
                        }
          } catch(ObjectNotFoundException e) {
              // Never happens
          }
      }
      
      
      /**
       * Remove an object from the Descriptors Store.
       *
       * @param object Object to remove
       * @exception ServiceAccessException Error accessing the Descriptors Store
       * @exception ObjectNotFoundException The object to remove was not found
       */
      public void removeObject(Uri uri, ObjectNode object)
          throws ServiceAccessException, ObjectNotFoundException {
                UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore removeObject 
1/n uri="+uri+" aProps="+aProps);
                if (aProps == null) {
              throw new ObjectNotFoundException(uri);
          }
          aProps.removeObject(uri,object);
                System.out.println("----------- XMLMemDescriptorsStore removeObject 
2/n uri="+uri+" aProps="+aProps);
      }
      
      
      /**
       * Store an object permissions in the Descriptors Store.
       *
       * @param permission Permission we want to create
       * @exception ServiceAccessException Error accessing the Descriptors Store
       */
      public void grantPermission(Uri uri, NodePermission permission)
          throws ServiceAccessException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore grantPermission 
1/n uri="+uri+" aProps="+aProps);
          if (aProps == null) {
                        aProps=new UriProperties(rootpath,uri);
                        definitions.put(uri.toString(),aProps);
          }
                aProps.grantPermission(uri,permission);
                System.out.println("----------- XMLMemDescriptorsStore grantPermission 
2/n uri="+uri+" aProps="+aProps);
      }
      
      
      /**
       * Store an object permissions in the Descriptors Store.
       *
       * @param permission Permission we want to create
       * @exception ServiceAccessException Error accessing the Descriptors Store
       */
      public void revokePermission(Uri uri, NodePermission permission)
          throws ServiceAccessException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore 
revokePermission 1/n uri="+uri+" aProps="+aProps);
          if (aProps != null) {
                        aProps.revokePermission(uri,permission);
          }
                System.out.println("----------- XMLMemDescriptorsStore 
revokePermission 2/n uri="+uri+" aProps="+aProps);
      }
      
      
      /**
       * Revoke all the permissions on the object .
       *
       * @param permission Permission we want to create
       * @exception ServiceAccessException Error accessing the Descriptors Store
       */
      public void revokePermissions(Uri uri)
          throws ServiceAccessException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore 
revokePermissions 1/n uri="+uri+" aProps="+aProps);
          if (aProps != null) {
                        aProps.revokePermissions(uri);
          }
                System.out.println("----------- XMLMemDescriptorsStore 
revokePermissions 2/n uri="+uri+" aProps="+aProps);
      }
      
      
      /**
       * Store an object permissions in the Descriptors Store.
       *
       * @param permission Permission we want to create
       * @exception ServiceAccessException Error accessing the Descriptors Store
       */
      public Enumeration enumeratePermissions(Uri uri)
          throws ServiceAccessException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore 
enumeratePermissions 1/n uri="+uri+" aProps="+aProps);
          if (aProps == null) {
                        return new Vector().elements();
          }
          else {
                        return aProps.enumeratePermissions();
                }
      }
      
      
      /**
       * Puts a lock on a subject.
       *
       * @param lock Lock token
       * @exception ServiceAccessException Service access error
       */
      public void putLock(Uri uri, NodeLock lock)
          throws ServiceAccessException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore putLock 1/n 
uri="+uri+" aProps="+aProps);
          if (aProps == null) {
                        aProps=new UriProperties(rootpath,uri);
                        definitions.put(uri.toString(),aProps);
          }
                aProps.putLock(uri,lock);
                System.out.println("----------- XMLMemDescriptorsStore putLock 2/n 
uri="+uri+" aProps="+aProps);
       }
      
      
      /**
       * Renews a lock.
       *
       * @param lock Token to renew
       * @exception ServiceAccessException Service access error
       * @exception LockTokenNotFoundException Lock token was not found
       */
      public void renewLock(Uri uri, NodeLock lock)
          throws ServiceAccessException, LockTokenNotFoundException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore renewLock 1/n 
uri="+uri+" aProps="+aProps);
          if (aProps == null) {
                        aProps=new UriProperties(rootpath,uri);
                        definitions.put(uri.toString(),aProps);
          }
                aProps.renewLock(uri,lock);
                System.out.println("----------- XMLMemDescriptorsStore renewLock 2/n 
uri="+uri+" aProps="+aProps);
      }
      
      
      /**
       * Removes (cancels) a lock.
       *
       * @param lock Token to remove
       * @exception ServiceAccessException Service access error
       * @exception LockTokenNotFoundException Lock token was not found
       */
      public void removeLock(Uri uri, NodeLock lock)
          throws ServiceAccessException, LockTokenNotFoundException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore removeLock 1/n 
uri="+uri+" aProps="+aProps);
          if (aProps == null) {
              throw new LockTokenNotFoundException(lock);
          } else {
                        aProps.removeLock(uri,lock);
          }
                System.out.println("----------- XMLMemDescriptorsStore removeLock 2/n 
uri="+uri+" aProps="+aProps);
      }
      
      
      /**
       * Kills a lock.
       *
       * @param lock Token to remove
       * @exception ServiceAccessException Service access error
       * @exception LockTokenNotFoundException Lock token was not found
       */
      public void killLock(Uri uri, NodeLock lock)
          throws ServiceAccessException, LockTokenNotFoundException {
          removeLock(uri, lock);
      }
      
      
      /**
       * Returns the list of locks put on a subject.
       *
       * @param subject Subject
       * @return Enumeration List of locks which have been put on the subject
       * @exception ServiceAccessException Service access error
       */
      public Enumeration enumerateLocks(Uri uri)
          throws ServiceAccessException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore enumerateLocks 
1/n uri="+uri+" aProps="+aProps);
          if (aProps == null) {
                        return new Vector().elements();
          }
          else {
                        return aProps.enumerateLocks();
                }
      }
      
      
      /**
       * Retrieve a revision descriptors.
       *
       * @param uri Uri
       * @exception ServiceAccessException Service access error
       * @exception RevisionDescriptorNotFoundException Revision descriptor
       * was not found
       */
      public NodeRevisionDescriptors retrieveRevisionDescriptors(Uri uri)
          throws ServiceAccessException, RevisionDescriptorNotFoundException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore 
retrieveRevisionDescriptors 1/n uri="+uri+" aProps="+aProps);
          if (aProps == null) {
              throw new RevisionDescriptorNotFoundException(uri.toString());
          }
                System.out.println("----------- XMLMemDescriptorsStore 
retrieveRevisionDescriptors 2/n uri="+uri+" aProps="+aProps);
          return aProps.retrieveRevisionDescriptors(uri);
      }
      
      
      /**
       * Create new revision descriptors.
       *
       * @param uri Uri
       * @param revisionDescriptors Node revision descriptors
       * @exception ServiceAccessException Service access error
       */
      public void createRevisionDescriptors
          (Uri uri, NodeRevisionDescriptors revisionDescriptors)
          throws ServiceAccessException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore 
createRevisionDescriptors 1/n uri="+uri+" aProps="+aProps);
          if (aProps == null) {
                        aProps=new UriProperties(rootpath,uri);
                        definitions.put(uri.toString(),aProps);
          }
                aProps.createRevisionDescriptors(uri,revisionDescriptors);
                System.out.println("----------- XMLMemDescriptorsStore 
createRevisionDescriptors 2/n uri="+uri+" aProps="+aProps);
      }
      
      
      /**
       * Update revision descriptors.
       *
       * @param uri Uri
       * @param revisionDescriptors Node revision descriptors
       * @exception ServiceAccessException Service access error
       * @exception RevisionDescriptorNotFoundException Revision descriptor
       * was not found
       */
      public void storeRevisionDescriptors
          (Uri uri, NodeRevisionDescriptors revisionDescriptors)
          throws ServiceAccessException, RevisionDescriptorNotFoundException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore 
storeRevisionDescriptors 1/n uri="+uri+" aProps="+aProps);
          if (aProps == null) {
              throw new RevisionDescriptorNotFoundException(uri.toString());
          }
          aProps.storeRevisionDescriptors(uri, revisionDescriptors);
                System.out.println("----------- XMLMemDescriptorsStore 
storeRevisionDescriptors 2/n uri="+uri+" aProps="+aProps);
      }
      
      
      /**
       * Remove revision descriptors.
       *
       * @param uri Uri
       * @exception ServiceAccessException Service access error
       */
      public void removeRevisionDescriptors(Uri uri)
          throws ServiceAccessException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore 
removeRevisionDescriptors 1/n uri="+uri+" aProps="+aProps);
          if (aProps != null) {
                        aProps.removeRevisionDescriptors(uri);
          }
                System.out.println("----------- XMLMemDescriptorsStore 
removeRevisionDescriptors 2/n uri="+uri+" aProps="+aProps);
      }
      
      
      /**
       * Retrieve revision descriptor.
       *
       * @param Uri uri
       * @param revisionNumber Node revision number
       */
      public NodeRevisionDescriptor retrieveRevisionDescriptor (Uri uri, 
NodeRevisionNumber revisionNumber)
          throws ServiceAccessException, RevisionDescriptorNotFoundException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore 
retrieveRevisionDescriptor 1/n uri="+uri+" aProps="+aProps);
          if (aProps == null) {
                        aProps=new UriProperties(rootpath,uri);
                        definitions.put(uri.toString(),aProps);
          }
                System.out.println("----------- XMLMemDescriptorsStore 
retrieveRevisionDescriptor 2/n uri="+uri+" revisionNumber="+revisionNumber);
                try {
                        return aProps.retrieveRevisionDescriptor(uri,revisionNumber);
                }
                catch (RevisionDescriptorNotFoundException e) {
                        System.out.println("----------- XMLMemDescriptorsStore 
retrieveRevisionDescriptor 3/n uri="+uri+" aProps="+aProps);
                        e.printStackTrace();
                        throw e;
                }
      }
      
      
      /**
       * Create new revision descriptor.
       *
       * @param uri Uri
       * @param revisionDescriptor Node revision descriptor
       * @exception ServiceAccessException Service access error
       */
      public void createRevisionDescriptor
          (Uri uri, NodeRevisionDescriptor revisionDescriptor)
          throws ServiceAccessException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore 
createRevisionDescriptor 1/n uri="+uri+" aProps="+aProps);
          if (aProps == null) {
                        aProps=new UriProperties(rootpath,uri);
                        definitions.put(uri.toString(),aProps);
          }
                aProps.createRevisionDescriptor(uri,revisionDescriptor);
                System.out.println("----------- XMLMemDescriptorsStore 
createRevisionDescriptor 2/n uri="+uri+" aProps="+aProps);
      }
      
      
      /**
       * Update revision descriptor.
       *
       * @param uri Uri
       * @param revisionDescriptors Node revision descriptor
       * @exception ServiceAccessException Service access error
       * @exception RevisionDescriptorNotFoundException Revision descriptor
       * was not found
       */
      public void storeRevisionDescriptor(Uri uri, NodeRevisionDescriptor 
revisionDescriptor)
          throws ServiceAccessException, RevisionDescriptorNotFoundException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore 
storeRevisionDescriptor 1/n uri="+uri+" aProps="+aProps);
          if (aProps == null) {
              throw new RevisionDescriptorNotFoundException(uri.toString());
          }
                aProps.storeRevisionDescriptor(uri,revisionDescriptor);
                System.out.println("----------- XMLMemDescriptorsStore 
storeRevisionDescriptor 2/n uri="+uri+" aProps="+aProps);
      }
      
      
      /**
       * Remove revision descriptor.
       *
       * @param uri Uri
       * @param revisionNumber Revision number
       * @exception ServiceAccessException Service access error
       */
      public void removeRevisionDescriptor(Uri uri, NodeRevisionNumber number)
          throws ServiceAccessException {
          UriProperties aProps = getUriProperties(uri);
                System.out.println("----------- XMLMemDescriptorsStore 
removeRevisionDescriptor 1/n uri="+uri+" aProps="+aProps);
          if (aProps != null) {
                        aProps.removeRevisionDescriptor(uri,number);
          }
                System.out.println("----------- XMLMemDescriptorsStore 
removeRevisionDescriptor 2/n uri="+uri+" aProps="+aProps);
      }
  
  
      
  }
  
  
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to