You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by mh...@apache.org on 2004/01/09 20:52:50 UTC

cvs commit: jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms PostgresRDBMSAdapter.java createPostgresSchema.sql dropPostgresSchema.sql

mholz       2004/01/09 11:52:49

  Added:       src/stores/org/apache/slide/store/impl/rdbms
                        PostgresRDBMSAdapter.java createPostgresSchema.sql
                        dropPostgresSchema.sql
  Log:
  Added PostgresAdapter.
  TProcessor.pl -pattern '*cases/functional/*'  will result in one error in
  xmltestcases/functional/msexplorer/multi-user/dragAndDropSmall.xml. The test
  seems to be broken.
  For 4 users and 4 iterations 4 more testcase fail. This needs further investigation.
  
  Revision  Changes    Path
  1.1                  jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/PostgresRDBMSAdapter.java
  
  Index: PostgresRDBMSAdapter.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/PostgresRDBMSAdapter.java,v 1.1 2004/01/09 19:52:49 mholz Exp $
   * $Revision: 1.1 $
   * $Date: 2004/01/09 19:52:49 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 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", "Slide", 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 apache@apache.org.
   *
   * 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 org.apache.slide.store.impl.rdbms;
  
  import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.SQLException;
  
  import org.apache.slide.common.Service;
  import org.apache.slide.common.ServiceAccessException;
  import org.apache.slide.common.Uri;
  import org.apache.slide.content.NodeRevisionDescriptor;
  import org.apache.slide.content.NodeRevisionNumber;
  import org.apache.slide.lock.LockTokenNotFoundException;
  import org.apache.slide.lock.NodeLock;
  import org.apache.slide.macro.ConflictException;
  import org.apache.slide.security.NodePermission;
  import org.apache.slide.structure.ObjectNode;
  import org.apache.slide.structure.ObjectNotFoundException;
  import org.apache.slide.util.logger.Logger;
  
  /**
   * Adapter for Postgres 7.3/7.4.
   * 
   * The delete statements differ from StandardRDBMSAdapter
   * as Postgres does not understand "DELETE table FROM ...".
   *  
   * The Postgres driver for version 7.4.1 will alway load
   * the content into memory. This will be a problem for 
   * large documents.
   * 
   * @author <a href="mailto:holz@fiz-chemie.de">Martin Holz</a>
   * @version $Revision: 1.1 $
   */
  
  public class PostgresRDBMSAdapter extends StandardRDBMSAdapter {
  
  	protected static final String LOG_CHANNEL =
  		PostgresRDBMSAdapter.class.getName();
  
  	public PostgresRDBMSAdapter(Service service, Logger logger) {
  		super(service, logger);
  	}
  
  	public void removeObject(Connection connection, Uri uri, ObjectNode object)
  		throws ServiceAccessException, ObjectNotFoundException {
  		PreparedStatement statement = null;
  		try {
  
  			clearBinding(connection, uri);
  
  			// delete links
  			try {
  				statement =
  					connection.prepareStatement(
  						"delete from LINKS where LINKS.URI_ID = URI.URI_ID and URI.URI_STRING = ?");
  				statement.setString(1, uri.toString());
  				statement.executeUpdate();
  			} finally {
  				close(statement);
  			}
  			// delete version history
  			// FIXME: Is this true??? Should the version history be removed if the object is removed???
  			try {
  				statement =
  					connection.prepareStatement(
  						"delete from VERSION_HISTORY  where VERSION_HISTORY.URI_ID = URI.URI_ID and URI.URI_STRING = ?");
  				statement.setString(1, uri.toString());
  				statement.executeUpdate();
  			} finally {
  				close(statement);
  			}
  			// delete version
  			try {
  				statement =
  					connection.prepareStatement(
  						"delete from VERSION where VERSION.URI_ID = URI.URI_ID and URI.URI_STRING = ?");
  				statement.setString(1, uri.toString());
  				statement.executeUpdate();
  			} finally {
  				close(statement);
  			}
  			// delete the object itself
  			try {
  				statement =
  					connection.prepareStatement(
  						"delete from OBJECT  where OBJECT.URI_ID = URI.URI_ID and URI.URI_STRING = ?");
  				statement.setString(1, uri.toString());
  				statement.executeUpdate();
  			} finally {
  				close(statement);
  			}
  			// finally delete the uri
  			try {
  				statement =
  					connection.prepareStatement(
  						"delete from URI where URI_STRING = ?");
  				statement.setString(1, uri.toString());
  				statement.executeUpdate();
  			} finally {
  				close(statement);
  			}
  		} catch (SQLException e) {
  			getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
  			throw new ServiceAccessException(service, e);
  		}
  	}
  
  	public void removeRevisionContent(
  		Connection connection,
  		Uri uri,
  		NodeRevisionDescriptor revisionDescriptor)
  		throws ServiceAccessException {
  		try {
  			PreparedStatement statement = null;
  			try {
  				statement =
  					connection.prepareStatement(
  						"delete from VERSION_CONTENT where VERSION_CONTENT.VERSION_ID = VERSION_HISTORY.VERSION_ID and VERSION_HISTORY.REVISION_NO = ? and VERSION_HISTORY.URI_ID=URI.URI_ID AND URI.URI_STRING=?");
  				statement.setString(
  					1,
  					revisionDescriptor.getRevisionNumber().toString());
  				statement.setString(2, uri.toString());
  				statement.executeUpdate();
  			} finally {
  				close(statement);
  			}
  		} catch (Exception e) {
  			getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
  			throw new ServiceAccessException(service, e);
  		}
  	}
  
  	public void removeRevisionDescriptor(
  		Connection connection,
  		Uri uri,
  		NodeRevisionNumber revisionNumber)
  		throws ServiceAccessException {
  		PreparedStatement statement = null;
  		try {
  			try {
  				statement =
  					connection.prepareStatement(
  						"delete from VERSION_LABELS where VERSION_LABELS.VERSION_ID = VERSION_HISTORY.VERSION_ID and VERSION_HISTORY.REVISION_NO = ? and VERSION_HISTORY.URI_ID = URI.URI_ID AND URI.URI_STRING = ?");
  				statement.setString(1, revisionNumber.toString());
  				statement.setString(2, uri.toString());
  				statement.executeUpdate();
  			} finally {
  				close(statement);
  			}
  			try {
  				statement =
  					connection.prepareStatement(
  						"delete from PROPERTIES where PROPERTIES.VERSION_ID = VERSION_HISTORY.VERSION_ID and VERSION_HISTORY.REVISION_NO = ? and VERSION_HISTORY.URI_ID = URI.URI_ID AND URI.URI_STRING = ?");
  				statement.setString(1, revisionNumber.toString());
  				statement.setString(2, uri.toString());
  				statement.executeUpdate();
  			} finally {
  				close(statement);
  			}
  		} catch (SQLException e) {
  			getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
  			throw new ServiceAccessException(service, e);
  		}
  	}
  
  	public void removeLock(Connection connection, Uri uri, NodeLock lock)
  		throws ServiceAccessException, LockTokenNotFoundException {
  		PreparedStatement statement = null;
  		try {
  			// FIXME: What about inheritage?
  			try {
  				statement =
  					connection.prepareStatement(
  						"delete from LOCKS where LOCK_ID = URI.URI_ID and URI.URI_STRING=?");
  				statement.setString(1, lock.getLockId());
  				statement.executeUpdate();
  			} finally {
  				close(statement);
  			}
  			try {
  				statement =
  					connection.prepareStatement(
  						"delete from URI, where URI_ID = LOCKS.LOCK_ID and URI_STRING=?");
  				statement.setString(1, lock.getLockId());
  			} finally {
  				close(statement);
  			}
  		} catch (SQLException e) {
  			getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
  			throw new ServiceAccessException(service, e);
  		}
  	}
  
  	public void revokePermission(
  		Connection connection,
  		Uri uri,
  		NodePermission permission)
  		throws ServiceAccessException {
  		PreparedStatement statement = null;
  		try {
  			NodeRevisionNumber revisionNumber = permission.getRevisionNumber();
  			statement =
  				connection.prepareStatement(
  					"delete from PERMISSIONS, URI ou, URI su, URI au where OBJECT_ID = ou.URI_ID and ou.URI_STRING = ? and SUBJECT_ID = su.URI_ID and su.URI_STRING = ? and ACTION_ID = au.URI_ID and au.URI_STRING = ? and VERSION_NO"
  						+ getRevisionNumberAsWhereQueryFragement(revisionNumber));
  			statement.setString(1, permission.getObjectUri());
  			statement.setString(2, permission.getSubjectUri());
  			statement.setString(3, permission.getActionUri());
  			statement.executeUpdate();
  		} catch (SQLException e) {
  			getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
  			throw new ServiceAccessException(service, e);
  		} finally {
  			close(statement);
  		}
  	}
  
  	public void revokePermissions(Connection connection, Uri uri)
  		throws ServiceAccessException {
  		PreparedStatement statement = null;
  		try {
  			statement =
  				connection.prepareStatement(
  					"delete from PERMISSIONS where PERMISSIONS.OBJECT_ID = URI.URI_ID and URI.URI_STRING = ?");
  			statement.setString(1, uri.toString());
  			statement.executeUpdate();
  		} catch (SQLException e) {
  			getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
  			throw new ServiceAccessException(service, e);
  		} finally {
  			close(statement);
  		}
  	}
  
  	protected void clearBinding(Connection connection, Uri uri)
  		throws ServiceAccessException, ObjectNotFoundException, SQLException {
  		PreparedStatement statement = null;
  
  		// clear this uri from having bindings and being bound 
  
  		// getLogger().log("Clear bindings for " + uri.toString(),LOG_CHANNEL,Logger.INFO);  
  
  		try {
  			statement =
  				connection.prepareStatement(
  					"delete from BINDING where (BINDING.URI_ID = URI.URI_ID and URI.URI_STRING = ?) ");
  			//or (BINDING.CHILD_UURI_ID = URI.URI_ID and URI.URI_STRING = ?");
  			statement.setString(1, uri.toString());
  			//statement.setString(2, uri.toString());
  			statement.executeUpdate();
  		} finally {
  			close(statement);
  		}
  
  		try {
  			statement =
  				connection.prepareStatement(
  					"delete from PARENT_BINDING where PARENT_BINDING.URI_ID = URI.URI_ID and URI.URI_STRING = ?");
  			//  or PARENT_BINDING.PARENT_UURI_ID = URI.URI_ID and URI.URI_STRING = ?");
  			statement.setString(1, uri.toString());
  			//statement.setString(2, uri.toString());
  			statement.executeUpdate();
  		} finally {
  			close(statement);
  		}
  	}
  
  	protected ServiceAccessException createException(
  		SQLException e,
  		String uri) {
  		/*  For Postgresql error states see  http://developer.postgresql.org/docs/postgres/errcodes-appendix.html
  		 */
  
  		String sqlstate = e.getSQLState();
  
  		if (sqlstate.startsWith("23")) {
  			getLogger().log(e.getErrorCode() + ": Deadlock resolved on " + uri,
  				LOG_CHANNEL, Logger.WARNING);
  			return new ServiceAccessException(service, new ConflictException(uri));
  		} else if (sqlstate.startsWith("40")) {
  			getLogger().log(
  				e.getErrorCode() + ": Deadlock resolved on " + uri,
  				LOG_CHANNEL,
  				Logger.WARNING);
  			return new ServiceAccessException(service, new ConflictException(uri));
  		} else {
  			getLogger().log(
  				"SQL error "
  					+ e.getErrorCode()
  					+ " on "
  					+ uri
  					+ ": "
  					+ e.getMessage(),
  				LOG_CHANNEL,
  				Logger.ERROR);
  
  			return new ServiceAccessException(service, e);
  		}
  	}
  }
  
  
  
  1.1                  jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/createPostgresSchema.sql
  
  Index: createPostgresSchema.sql
  ===================================================================
  /* $Header: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/createPostgresSchema.sql,v 1.1 2004/01/09 19:52:49 mholz Exp $
   * $Revision: 1.1 $
   * $Date: 2004/01/09 19:52:49 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 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", "Slide", 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 apache@apache.org.
   *
   * 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]
   *
   */
  
  /*
   * create the SQL schema used by org.apache.slide.impl.rdbms.PostgresAdapter.
   * Tested with Postgres 7.4.
   *
   */
  
  CREATE TABLE URI (
      URI_ID          serial               PRIMARY KEY  NOT NULL,
      URI_STRING      varchar(800)          UNIQUE NOT NULL
  );
  
  
  
  CREATE TABLE OBJECT (
      URI_ID          integer               PRIMARY KEY,
      CLASS_NAME      varchar(255)          NOT NULL,
      CONSTRAINT      FK_OBJECT_URI_ID
         FOREIGN KEY (URI_ID)
         REFERENCES   URI (URI_ID)
  );
  
  
  CREATE TABLE BINDING (
    URI_ID         integer   		NOT NULL  REFERENCES URI(URI_ID), 
    NAME           varchar(255) 		NOT NULL,
    CHILD_UURI_ID  integer   		NOT NULL  REFERENCES URI(URI_ID), 
    PRIMARY KEY    (URI_ID, NAME, CHILD_UURI_ID) 
  );
  
  
  CREATE TABLE PARENT_BINDING (
      URI_ID        integer               NOT NULL  REFERENCES  URI (URI_ID),
      NAME          varchar(255)          NOT NULL, 
      PARENT_UURI_ID integer              NOT NULL  REFERENCES  URI (URI_ID),
      PRIMARY KEY    (URI_ID, NAME, PARENT_UURI_ID)
  ); 
  
  /* TODO Which indices for binding? */
  
  
  CREATE TABLE LINKS (
      URI_ID          integer               NOT NULL  REFERENCES  URI (URI_ID),
      LINK_TO_ID      integer               NOT NULL  REFERENCES  URI (URI_ID),
      UNIQUE (URI_ID, LINK_TO_ID)
  );
  
  CREATE INDEX XURI_ID
  	ON LINKS(URI_ID); 
  
  
  CREATE INDEX XLINK_TO_ID
  	ON LINKS(LINK_TO_ID); 
  
  CREATE TABLE LOCKS (
      LOCK_ID         integer               PRIMARY KEY, 
      OBJECT_ID       integer               REFERENCES   URI (URI_ID),
      SUBJECT_ID      integer               REFERENCES   URI (URI_ID),
      TYPE_ID         integer               REFERENCES   URI (URI_ID),
      EXPIRATION_DATE numeric(14, 0)   	  NOT NULL,
      IS_INHERITABLE  smallint              NOT NULL, 
      IS_EXCLUSIVE    smallint              NOT NULL,
      OWNER           varchar(255),                	
      CONSTRAINT      FK_LOCKS_LOCK_ID
         FOREIGN KEY (LOCK_ID)
         REFERENCES   URI (URI_ID)
  );
  
  
  CREATE TABLE BRANCH ( 
      BRANCH_ID       serial               UNIQUE NOT NULL,
      BRANCH_STRING   varchar(255)          UNIQUE NOT NULL
  );
  
  CREATE TABLE LABEL (
      LABEL_ID        serial               UNIQUE NOT NULL,
      LABEL_STRING    varchar(255)         NOT NULL
  );
  
  CREATE TABLE VERSION (
      URI_ID          integer               PRIMARY KEY,
      IS_VERSIONED    smallint                   NOT NULL,    
      CONSTRAINT      FK_VERSION_URI_ID
         FOREIGN KEY (URI_ID)
         REFERENCES   URI (URI_ID)
  );
  
  
  CREATE TABLE VERSION_HISTORY (
      VERSION_ID      serial               UNIQUE NOT NULL,
      URI_ID          integer               NOT NULL  REFERENCES   URI (URI_ID),
      BRANCH_ID       integer               NOT NULL  REFERENCES   BRANCH (BRANCH_ID),
      REVISION_NO     VARCHAR(20)	       	  NOT NULL,
      UNIQUE (URI_ID, BRANCH_ID, REVISION_NO)
  );
  
  CREATE INDEX XVERSION_HISTORY1 
  	ON VERSION_HISTORY(URI_ID, BRANCH_ID, REVISION_NO); 
  
  
  CREATE TABLE VERSION_PREDS (
      VERSION_ID         integer            NOT NULL  REFERENCES  VERSION_HISTORY (VERSION_ID),
      PREDECESSOR_ID     integer            NOT NULL  REFERENCES  VERSION_HISTORY (VERSION_ID),
      UNIQUE (VERSION_ID, PREDECESSOR_ID)
  );
  
  CREATE INDEX XVERSION_PREDS1 
  	ON VERSION_PREDS(VERSION_ID, PREDECESSOR_ID); 
  
  
  CREATE TABLE VERSION_LABELS (
      VERSION_ID         integer            NOT NULL  REFERENCES  VERSION_HISTORY (VERSION_ID),
      LABEL_ID           integer            NOT NULL  REFERENCES  LABEL (LABEL_ID), 
      UNIQUE (VERSION_ID, LABEL_ID)
  );
  
  
  CREATE TABLE VERSION_CONTENT (
      VERSION_ID         integer            PRIMARY KEY REFERENCES VERSION_HISTORY (VERSION_ID),
      CONTENT            bytea
  );
  
  
  CREATE TABLE PROPERTIES (
      VERSION_ID         integer            NOT NULL  REFERENCES  VERSION_HISTORY (VERSION_ID),    
      PROPERTY_NAMESPACE varchar(50)        NOT NULL, 
      PROPERTY_NAME      varchar(50)        NOT NULL,        
      PROPERTY_VALUE     varchar(255)       NOT NULL,
      PROPERTY_TYPE      varchar(50)        NOT NULL, 
      IS_PROTECTED       smallint                NOT NULL,
      UNIQUE  (VERSION_ID, PROPERTY_NAMESPACE, PROPERTY_NAME)
  );
  
  
  CREATE TABLE PERMISSIONS (
      OBJECT_ID       integer               NOT NULL  REFERENCES   URI (URI_ID),
      SUBJECT_ID      integer               NOT NULL  REFERENCES   URI (URI_ID),
      ACTION_ID       integer               NOT NULL  REFERENCES   URI (URI_ID),
      VERSION_NO      VARCHAR(20)           NULL,
      IS_INHERITABLE  smallint                   NOT NULL,
      IS_NEGATIVE     smallint                   NOT NULL,
      -- Both order and sequence would be more suitable, but can not be used
      SUCCESSION      int                   NOT NULL,
      UNIQUE (OBJECT_ID, SUBJECT_ID, ACTION_ID),
      UNIQUE (OBJECT_ID, SUCCESSION)
  );
  
  /**
   * The views are not used by slide, but only as a  debugging/administration help. 
   */
  CREATE VIEW OBJECT_VIEW AS 
    SELECT u.URI_STRING,o.CLASS_NAME FROM URI u, OBJECT o WHERE o.URI_ID = u.URI_ID;
  
  CREATE VIEW BINDING_VIEW AS 
     SELECT u1.URI_STRING AS PARENT,u2.URI_STRING AS CHILD 
  	FROM BINDING b,URI u1, URI u2 WHERE b.URI_ID = u1.URI_ID AND b.CHILD_UURI_ID = u2.URI_ID;
  
  CREATE VIEW PERMISSIONS_VIEW AS 
     SELECT u1.URI_STRING AS OBJECT, u2.URI_STRING AS SUBJECT, u3.URI_STRING AS ACTION,
  	  p.VERSION_NO,p.IS_INHERITABLE,p.IS_NEGATIVE, p.SUCCESSION
  	FROM PERMISSIONS p,URI u1,URI u2, URI u3
  	WHERE p.OBJECT_ID = u1.URI_ID AND p.SUBJECT_ID = u2.URI_ID AND p.ACTION_ID = u3.URI_ID;
  
  CREATE VIEW LOCKS_VIEW AS
    SELECT l.LOCK_ID,ou.URI_STRING AS OBJECT,su.URI_STRING AS SUBJECT,tu.URI_STRING AS TYPE ,l.EXPIRATION_DATE,l.IS_INHERITABLE,l.IS_EXCLUSIVE
      FROM LOCKS l, URI ou,URI su,URI tu 
      WHERE l.OBJECT_ID = ou.URI_ID AND 	l.SUBJECT_ID = su.URI_ID AND l.TYPE_ID = su.URI_ID;
  
  
  1.1                  jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/dropPostgresSchema.sql
  
  Index: dropPostgresSchema.sql
  ===================================================================
  /* $Header: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/dropPostgresSchema.sql,v 1.1 2004/01/09 19:52:49 mholz Exp $
   * $Revision: 1.1 $
   * $Date: 2004/01/09 19:52:49 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 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", "Slide", 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 apache@apache.org.
   *
   * 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]
   *
   */
  
  /*
   * drop the SQL schema used by org.apache.slide.impl.rdbms.PostgresAdapter.
   * Tested with Postgres 7.4.
   *
   */
  
  DROP VIEW LOCKS_VIEW;
  DROP VIEW PERMISSIONS_VIEW;
  DROP VIEW BINDING_VIEW;
  DROP VIEW OBJECT_VIEW;
  DROP TABLE PROPERTIES; 
  DROP TABLE VERSION_CONTENT; 
  DROP TABLE VERSION_PREDS;
  DROP TABLE VERSION_LABELS;
  DROP TABLE VERSION_HISTORY; 
  DROP TABLE VERSION; 
  DROP TABLE BINDING;
  DROP TABLE PARENT_BINDING;
  DROP TABLE LINKS;
  DROP TABLE LOCKS;
  DROP TABLE BRANCH;
  DROP TABLE LABEL; 
  DROP TABLE PERMISSIONS; 
  DROP TABLE OBJECT;
  DROP TABLE URI;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org