jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r208906 [5/5] - in /incubator/jackrabbit/trunk/contrib/phpcr: ./ PHPCR/ PHPCR/lock/ PHPCR/nodetype/ PHPCR/observation/ PHPCR/query/ PHPCR/util/ PHPCR/version/
Date Sun, 03 Jul 2005 11:58:39 GMT
Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/observation/ObservationManager.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/observation/ObservationManager.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/observation/ObservationManager.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/observation/ObservationManager.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,110 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require_once 'PHPCR/RepositoryException.php';
+require_once 'PHPCR/observation/EventListener.php';
+require_once 'PHPCR/observation/EventListenerIterator.php';
+
+
+/**
+ * The ObservationManager object.
+ * <p>
+ * Allows for the registration and deregistration of event listeners.
+ *
+ * @author Markus Nix <mnix@mayflower.de>
+ * @package phpcr
+ * @subpackage observation
+ */
+interface ObservationManager
+{
+    /**
+     * Adds an event listener that listens for the specified <code>eventTypes</code> (a combination of one or more
+     * event types encoded as a bit mask value).
+     * <p>
+     * The set of events can be filtered by specifying restrictions based on characteristics of the node associated
+     * with the event. In the case of  event types <code>NODE_ADDED</code> and <code>NODE_REMOVED</code>, the node
+     * associated with an event is the node at (or formerly at) the path returned by <code>Event.getPath</code>.
+     * In the case of  event types <code>PROPERTY_ADDED</code>,  <code>PROPERTY_REMOVED</code> and
+     * <code>PROPERTY_CHANGED</code>, the node associated with an event is the parent node of the property at
+     * (or formerly at) the path returned by <code>Event.getPath</code>:
+     * <ul>
+     *   <li>
+     *     <code>absPath</code>, <code>isDeep</code>: Only events whose associated node is at
+     *     <code>absPath</code> (or within its subtree, if <code>isDeep</code> is <code>true</code>) will be received.
+     *     It is permissible to register a listener for a path where no node currently exists.
+     *   </li>
+     *   <li>
+     *     <code>uuid</code>: Only events whose associated node has one of the UUIDs in this list will be
+     *     received. If his parameter is <code>null</code> then no UUID-related restriction is placed on events
+     *     received.
+     *   </li>
+     *   <li>
+     *     <code>nodeTypeName</code>: Only events whose associated node has one of the node types
+     *     (or a subtype of one of the node types) in this list will be received. If his parameter is
+     *     <code>null</code> then no node type-related restriction is placed on events received.
+     *   </li>
+     * </ul>
+     * The restrictions are "ANDed" together. In other words, for a particular node to be "listened to" it must meet all the restrictions.
+     * <p>
+     * Additionally, if <code>noLocal</code> is <code>true</code>, then events generated by the session through which
+     * the listener was registered are ignored. Otherwise, they are not ignored.
+     * <p>
+     * The filters of an already-registered <code>EventListener</code> can be changed at runtime by re-registering the
+     * same <code>EventListener</code> object (i.e. the same actual Java object) with a new set of filter arguments.
+     * The implementation must ensure that no events are lost during the changeover.
+     *
+     * @param listener an {@link EventListener} object.
+     * @param eventTypes A combination of one or more event type constants encoded as a bitmask.
+     * @param absPath an absolute path.
+     * @param isDeep a <code>boolean</code>.
+     * @param uuid array of UUIDs.
+     * @param nodeTypeName array of node type names.
+     * @param noLocal a <code>boolean</code>.
+     * @throws RepositoryException If an error occurs.
+     */
+    public function addEventListener( EventListener $listener, $eventTypes, $absPath, $isDeep, $uuid, $nodeTypeName, $noLocal );
+
+    /**
+     * Deregisters an event listener.
+     * <p>
+     * A listener may be deregistered while it is being executed. The
+     * deregistration method will block until the listener has completed
+     * executing. An exception to this rule is a listener which deregisters
+     * itself from within the <code>onEvent</code> method. In this case, the
+     * deregistration method returns immediately, but deregistration will
+     * effectively be delayed until the listener completes.
+     *
+     * @param listener The listener to deregister.
+     *
+     * @throws RepositoryException If an error occurs.
+     */
+    public function removeEventListener( EventListener $listener );
+
+    /**
+     * Returns all event listeners that have been registered through this session.
+     * If no listeners have been registered, an empty iterator is returned.
+     *
+     * @return an <code>EventListenerIterator</code>.
+     * @throws RepositoryException
+     */
+    public function getRegisteredEventListeners();
+}
+
+?>
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/InvalidQueryException.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/InvalidQueryException.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/InvalidQueryException.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/InvalidQueryException.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,35 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require_once 'PHPCR/RepositoryException.php';
+
+
+/**
+ * Thrown by methods of <code>Query</code>.
+ *
+ * @author Markus Nix <mnix@mayflower.de>
+ * @package phpcr
+ * @subpackage query
+ */
+class InvalidQueryException extends RepositoryException
+{
+}
+
+?>
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/Query.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/Query.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/Query.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/Query.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,157 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require_once 'PHPCR/ItemExistsException.php';
+require_once 'PHPCR/PathNotFoundException.php';
+require_once 'PHPCR/RepositoryException.php';
+require_once 'PHPCR/nodetype/ConstraintViolationException.php';
+require_once 'PHPCR/lock/LockException.php';
+
+
+/**
+ * A <code>Query</code> object.
+ *
+ * @author Markus Nix <mnix@mayflower.de>
+ * @package phpcr
+ * @subpackage query
+ */
+interface Query
+{
+    /**
+     * A String constant representing the XPath query language applied to the <i>document view</i>
+     * XML mapping of the workspace.
+     * <p/>
+     * This language must be supported in level 1 repositories.
+     * <p/>
+     * Used when defining a query using {@link QueryManager#createQuery}.
+     * Also among the strings returned by {@link QueryManager#getSupportedQueryLanguages}.
+     */
+    const XPATH = "xpath";
+
+    /**
+     * A String constant representing the SQL query language applied to the <i>database view</i>
+     * of the workspace.
+     * <p/>
+     * This language is optional.
+     * <p/>
+     * Used when defining a query using {@link QueryManager#createQuery}.
+     * Also among the strings returned by {@link QueryManager#getSupportedQueryLanguages}.
+     */
+    const SQL = "sql";
+
+
+    /**
+     * Executes this query and returns a <code>{@link QueryResult}</code>.
+     *
+     * @return a <code>QueryResult</code>
+     * @throws RepositoryException if an error occurs
+     */
+    public function execute();
+
+    /**
+     * Returns the statement set for this query. Returns <code>null</code>
+     * if no statement is currently set.
+     *
+     * @return the query statement.
+     */
+    public function getStatement();
+
+    /**
+     * Returns the language set for this query. This will be one of the
+     * QueryLanguage constants returned by
+     * QueryManager.getSupportedQueryLanguages(). If the query was created
+     * using a mechanism outside the specification, this method may return 0.
+     *
+     * @return the query language.
+     */
+    public function getLanguage();
+
+    /**
+     * If this is a Query object that has been stored using
+     * <code>storeAsNode($string)</code> (regardless of whether it has
+     * been saved yet) or retrieved using
+     * <code>QueryManager.getQuery($node)</code>), then this method returns
+     * the path of the <code>nt:query</code> node that stores the query. If
+     * this is a transient query (that is, a <code>Query</code> object created
+     * with <code>QueryManager.createQuery($string, $string)</code> but not
+     * yet stored) then this method throws an ItemNotFoundException.
+     *
+     * @return path of persisted node representing this query in content.
+     */
+    public function getStoredQueryPath();
+
+    /**
+     * Creates a node representing this Query in content.
+     *
+     * In a level 1 repository this method throws an
+     * UnsupportedRepositoryOperationException.
+     *
+     * In a level 2 repository it creates a node of type nt:query at absPath
+     * and returns that node.
+     *
+     * In order to persist the newly created node, a save must be performed
+     * that includes the parent of this new node within its scope. In other
+     * words, either a Session.save or an Item.save on the parent or
+     * higher-degree ancestor of absPath must be performed.
+     *
+     * An ItemExistsException will be thrown either immediately (by this
+     * method), or on save, if an item at the specified path already exists
+     * and same-name siblings are not allowed. Implementations may differ
+     * on when this validation is performed.
+     *
+     * A PathNotFoundException will be thrown either immediately , or on
+     * save, if the specified path implies intermediary nodes that do not
+     * exist. Implementations may differ on when this validation is performed.
+     *
+     * A ConstraintViolationExceptionwill be thrown either immediately or
+     * on save, if adding the node would violate a node type or
+     * implementation-specific constraintor if an attempt is made to add
+     * a node as the child of a property. Implementations may differ on when
+     * this validation is performed.
+     *
+     * A VersionException will be thrown either immediately (by this method),
+     * or on save, if the node to which the new child is being added is
+     * versionable and checked-in or is non-versionable but its nearest
+     * versionable ancestor is checked-in. Implementations may differ on when
+     * this validation is performed.
+     *
+     * A LockException will be thrown either immediately (by this method), or
+     * on save, if a lock prevents the addition of the node. Implementations
+     * may differ on when this validation is performed.
+     *
+     * @param absPath path at which to persist this query.
+     * @return the newly created node.
+     * @throws ItemExistsException If an item already exists at the indicated position
+     * @throws PathNotFoundException If the path cannot be found
+     * @throws ConstraintViolationException If creating the node would violate a
+     * node type (or other implementation specific) constraint.
+     * @throws VersionException f the node to which the new child is being
+     * added is versionable and checked-in or is non-versionable but its
+     * nearest versionable ancestor is checked-in and this implementation
+     * performs this validation immediately instead of waiting until save.
+     * @throws LockException if a lock prevents the addition of the node and
+     * this implementation performs this validation immediately instead of
+     * waiting until save.
+     * @throws RepositoryException If another error occurs.
+     */
+    public function storeAsNode( $absPath );
+}
+
+?>
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/QueryManager.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/QueryManager.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/QueryManager.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/QueryManager.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,79 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require_once 'PHPCR/RepositoryException.php';
+require_once 'PHPCR/Node.php';
+require_once 'PHPCR/query/Query.php';
+require_once 'PHPCR/query/InvalidQueryException.php';
+
+
+/**
+ * This interface encapsulates methods for the management of search queries.
+ * Provides methods for the creation and retrieval of search queries.
+ *
+ * @author Markus Nix <mnix@mayflower.de>
+ * @package phpcr
+ * @subpackage query
+ */
+interface QueryManager
+{
+    /**
+     * Creates a new query by specifying the query statement itself and the
+     * language in which the query is stated.  If the query statement is
+     * syntactically invalid, given the language specified, an
+     * InvalidQueryException is thrown. language must specify a query language
+     * from among those returned by QueryManager.getSupportedQueryLanguages(); if it is not
+     * then an InvalidQueryException is thrown.
+     *
+     * @throws InvalidQueryException if statement is invalid or language is unsupported.
+     * @throws RepositoryException if another error occurs
+     * @return A <code>Query</code> object.
+     */
+    public function createQuery( $statement, $language );
+
+    /**
+     * Retrieves an existing persistent query. If <code>node</code>
+     * is not a valid persisted query (that is, a node of type
+     * <code>nt:query</code>), an <code>InvalidQueryException</code>
+     * is thrown.
+     * <p/>
+     * Persistent queries are created by first using <code>QueryManager.createQuery</code>
+     * to create a <code>Query</code> object and then calling <code>Query.save</code> to
+     * persist the query to a location in the workspace.
+     *
+     * @param node a persisted query (that is, a node of type <code>nt:query</code>).
+     * @throws InvalidQueryException If <code>node</code> is not a valid persisted query
+     * (that is, a node of type <code>nt:query</code>).
+     * @throws RepositoryException if another error occurs
+     * @return a <code>Query</code> object.
+     */
+    public function getQuery( Node $node );
+
+    /**
+     * Returns an array of integers identifying the supported query languages.
+     * See QueryLanguage.
+     *
+     * @return An string array.
+     * @throws RepositoryException if an error occurs.
+     */
+    public function getSupportedQueryLanguages();
+}
+
+?>
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/QueryResult.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/QueryResult.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/QueryResult.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/QueryResult.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,67 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require_once 'PHPCR/NodeIterator.php';
+require_once 'PHPCR/query/RowIterator.php';
+require_once 'PHPCR/RepositoryException.php';
+
+
+/**
+ * A QueryResult object. Returned in an iterator by query.Query#execute()
+ * Query.execute()
+ *
+ * @author Markus Nix <mnix@mayflower.de>
+ * @package phpcr
+ * @subpackage query
+ */
+interface QueryResult
+{
+    /**
+     * Returns an array of all the property names (column names) in this result set.
+     *
+     * @return array of strings
+     * @throws RepositoryException if an error occurs.
+     */
+    public function getColumnNames();
+
+    /**
+     * Returns an iterator over the <code>Row</code>s of the query result table.
+     * If an <code>ORDER BY</code> clause was specified in the query, then the
+     * order of the returned properties in the iterator will reflect the order
+     * specified in that clause. If no items match, an empty iterator is returned.
+     *
+     * @return a <code>RowIterator</code>
+     * @throws RepositoryException if an error occurs.
+     */
+    public function getRows();
+
+    /**
+     * Returns an iterator over all nodes that match the query. If an <code>ORDER BY</code>
+     * clause was specified in the query, then the order of the returned nodes in the iterator
+     * will reflect the order specified in that clause. If no nodes match, an empty iterator
+     * is returned.
+     *
+     * @return a <code>NodeIterator</code>
+     * @throws RepositoryException if an error occurs.
+     */
+    public function getNodes();
+}
+
+?>
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/Row.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/Row.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/Row.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/Row.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,58 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require_once 'PHPCR/Value.php';
+require_once 'PHPCR/RepositoryException.php';
+require_once 'PHPCR/ItemNotFoundException.php';
+
+
+/**
+ * A row in the query result table.
+ *
+ * @author Markus Nix <mnix@mayflower.de>
+ * @package phpcr
+ * @subpackage query
+ */
+interface Row
+{
+    /**
+     * Returns an array of all the values in the same order as the property names
+     * (column names) returned by {@link QueryResult#getPropertyNames()}.
+     *
+     * @return a <code>Value</code> array.
+     * @throws RepositoryException if an error occurs
+     */
+    public function getValues();
+
+    /**
+     * Returns the value of the indicated  property in this <code>Row</code>.
+     * <p/>
+     * If <code>propertyName</code> is not among the column names of the query result
+     * table, an <code>ItemNotFoundException</code> is thrown.
+     *
+     * @return a <code>Value</code>
+     * @throws ItemNotFoundException if <code>propertyName</code> s not among the
+     * column names of the query result table
+     * @throws RepositoryException if anopther error occurs.
+     */
+    public function getValue( $propertyName );
+}
+
+?>
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/RowIterator.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/RowIterator.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/RowIterator.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/query/RowIterator.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,42 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require_once 'PHPCR/RangeIterator.php';
+require_once 'PHPCR/query/Row.php';
+require_once 'PHPCR/NoSuchElementException.php';
+
+
+
+/**
+ * @package phpcr
+ * @subpackage query
+ */
+interface RowIterator extends RangeIterator
+{
+    /**
+     * Returns the next <code>Row</code> in the iteration.
+     *
+     * @return the next <code>Row</code> in the iteration.
+     * @throws NoSuchElementException if iteration has no more <code>Row</code>s.
+     */
+    public function nextRow();
+}
+
+?>
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/util/ISO8601.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/util/ISO8601.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/util/ISO8601.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/util/ISO8601.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,68 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * The <code>ISO8601</code> utility class provides helper methods
+ * to deal with date/time formatting using a specific ISO8601-compliant
+ * format (see <a href="http://www.w3.org/TR/NOTE-datetime">ISO 8601</a>).
+ * <p/>
+ * Currently we only support the format <code>yyyy-mm-ddThh:mm:ss</code>,
+ * which includes the complete date plus hours, minutes, seconds and a decimal
+ * fraction of a second. Currently there is no timezone support
+ *
+ * @author Markus Nix <mnix@mayflower.de>
+ * @todo Timezone support
+ * @package phpcr
+ * @subpackage util
+ */
+final class ISO8601
+{
+    /**
+     * Parses a ISO8601-compliant date/time string.
+     *
+     * @param  text the date/time string to be parsed
+     * @return <code>date</code>, or <code>null</code> if the input could
+     *         not be parsed
+     * @return mixed date or false if an parsing error occured
+     * @static
+     */
+    public static function parse( $text ) {
+        $year   = substr( $iso,  0, 4 );
+        $month  = substr( $iso,  4, 2 );
+        $day    = substr( $iso,  6, 2 );
+        $hour   = substr( $iso,  9, 2 );
+        $minute = substr( $iso, 12, 2 );
+        $second = substr( $iso, 15, 2 );
+
+        // correctly parsed? if not, return false
+        return $year . $month . $day . 'T' . $hour . ':' . $minute . ':' . $second;
+    }
+
+    /**
+     * Returns ISO formatted date
+     *
+     * @access public
+     */
+    public function format( $val ) {
+        // TODO
+    }
+}
+
+?>
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/util/TraversingItemVisitor.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/util/TraversingItemVisitor.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/util/TraversingItemVisitor.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/util/TraversingItemVisitor.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,201 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require_once 'PHPCR/ItemVisitor.php';
+require_once 'PHPCR/Property.php';
+require_once 'PHPCR/RepositoryException.php';
+require_once 'PHPCR/Node.php';
+
+
+/**
+ * An implementaion of <code>ItemVisitor</code>.
+ * <p/>
+ * <b>Level 1 and 2</b>
+ * <p/>
+ * <code>TraversingItemVisitor</code> is an abstract utility class
+ * which allows to easily traverse an <code>Item</code> hierarchy.
+ * <p/>
+ * <p><code>TraversingItemVisitor</code> makes use of the Visitor Pattern
+ * as described in the book 'Design Patterns' by the Gang Of Four
+ * (Gamma et al.).
+ * <p/>
+ * <p>Tree traversal is done observing the left-to-right order of
+ * child <code>Item</code>s if such an order is supported and exists.
+ *
+ * @author Markus Nix <mnix@mayflower.de>
+ * @package phpcr
+ * @subpackage util
+ */
+abstract class TraversingItemVisitor implements ItemVisitor
+{
+    /**$currentQueue
+     * indicates if traversal should be done in a breadth-first
+     * manner rather than depth-first (which is the default)
+     *
+     * @var bool
+     */
+    protected $breadthFirst = false;
+
+    /**
+     * the 0-based level up to which the hierarchy should be traversed
+     * (if it's -1, the hierarchy will be traversed until there are no
+     * more children of the current item)
+     *
+     * @var int
+     */
+    protected $maxLevel = -1;
+
+    /**
+     * queues used to implement breadth-first traversal
+     *
+     * @var array
+     */
+    private $currentQueue;
+    private $nextQueue;
+
+    /**
+     * used to track hierarchy level of item currently being processed
+     *
+     * @var int
+     */
+    private $currentLevel;
+
+
+    /**
+     * Constructs a new instance of this class.
+     *
+     * @param breadthFirst if <code>breadthFirst</code> is true then traversal
+     *                     is done in a breadth-first manner; otherwise it is done in a
+     *                     depth-first manner (which is the default behaviour).
+     */
+    public function __construct( $breadthFirst = false, $maxLevel = -1 ) {
+        $this->breadthFirst = $breadthFirst;
+
+        if ( $this->breadthFirst === true ) {
+            $this->currentQueue = array();
+            $this->nextQueue    = array();
+        }
+
+        $this->currentLevel = 0;
+        $this->maxLevel = $maxLevel;
+    }
+
+
+    /**
+     * Implement this method to add behaviour performed before a
+     * <code>Property</code> or <code>Node</code> is visited.
+     *
+     * @param  entry that is accepting this visitor.
+     * @param  level    hierarchy level of this property (the root node starts at level 0)
+     * @throws RepositoryException if an error occurrs
+     */
+    protected abstract function entering( $entry, $level );
+
+    /**
+     * Implement this method to add behaviour performed after a
+     * <code>Property</code> is visited.
+     *
+     * @param  entry the <code>Property</code> that is accepting this visitor.
+     * @param  level    hierarchy level of this property (the root node starts at level 0)
+     * @throws RepositoryException if an error occurrs
+     */
+    protected abstract function leaving( $entry, $level );
+
+    /**
+     * Called when the Visitor is passed to a <code>Node</code>.
+     * <p/>
+     * It calls <code>TraversingItemVisitor.entering(Node, int)</code> followed by
+     * <code>TraversingItemVisitor.leaving(Node, int)</code>. Implement these abstract methods to
+     * specify behaviour on 'arrival at' and 'after leaving' the <code>Node</code>.
+     * <p/>
+     * If this method throws, the visiting process is aborted.
+     *
+     * @param Either Node or Property that is accepting this visitor.
+     * @throws RepositoryException if an error occurrs
+     */
+    public function visit( $entry ) {
+        if ( $entry instanceof Property ) {
+            $this->entering( $entry, $this->currentLevel );
+            $this->leaving( $entry, $this->currentLevel );
+        } else {
+            try {
+                if ( !$this->breadthFirst ) {
+                    // depth-first traversal
+                    $this->entering( $entry, $this->currentLevel );
+
+                    if ( $this->maxLevel == -1 || $this->currentLevel < $this->maxLevel ) {
+                        $this->currentLevel++;
+
+                        $nodeIter = $entry->getNodes();
+
+                        while ( $nodeIter->hasNext() ) {
+                            $nodeIter->nextNode()->accept( $this );
+                        }
+
+                        $propIter = $entry->getProperties();
+
+                        while ( $propIter->hasNext()) {
+                            $propIter->nextProperty()->accept( $this );
+                        }
+
+                        $currentLevel--;
+                    }
+
+                    $this->leaving( $entry, $this->currentLevel );
+                } else {
+                    // breadth-first traversal
+                    $this->entering( $entry, $this->currentLevel );
+                    $this->leaving( $entry, $this->currentLevel );
+
+                    if ( $this->maxLevel == -1 || $this->currentLevel < $this->maxLevel ) {
+                        $nodeIter = $entry->getNodes();
+
+                        while ( $nodeIter->hasNext() ) {
+                            $this->nextQueue[] = $nodeIter->nextNode();
+                        }
+
+                        $propIter = $entry->getProperties();
+
+                        while ( $propIter->hasNext() ) {
+                            $this->nextQueue[] = $propIter->nextProperty();
+                        }
+                    }
+
+                    while ( !empty( $this->currentQueue ) || !empty( $this->nextQueue ) ) {
+                        if ( empty( $this->currentQueue ) ) {
+                            $this->currentLevel++;
+                            $this->currentQueue = $this->nextQueue;
+                            $this->nextQueue = array();
+                        }
+
+                        $this->currentQueue = array_shift( $this->currentQueue );
+                    }
+
+                    $this->currentLevel = 0;
+               }
+            } catch ( RepositoryException $re ) {
+                $this->currentLevel = 0;
+                throw $re;
+            }
+        }
+    }
+}
+
+?>
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/OnParentVersionAction.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/OnParentVersionAction.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/OnParentVersionAction.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/OnParentVersionAction.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,279 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require_once 'PHPCR/IllegalArgumentException.php';
+
+
+/**
+ * The possible actions specified by the <code>onParentVersion</code> attribute
+ * in a property definition within a node type definition.
+ * <p>
+ * <b>Level 2 only</b>
+ * <p>
+ * This interface defines the following actions:
+ * <UL>
+ *    <LI>COPY
+ *    <LI>VERSION
+ *    <LI>INITIALIZE
+ *    <LI>COMPUTE
+ *    <LI>IGNORE
+ *    <LI>ABORT
+ * </UL>
+ * <p>
+ * Every item (node or property) in the repository has a status indicator that
+ * governs what happens to that item when its parent node is versioned. This
+ * status is defined by the onParentVersion attribute in the PropertyDef or
+ * NodeDef that applies to the item in question. This PropertyDef or NodeDef is
+ * part of the NodeType of the parent node of the item in question.
+ * <p>
+ * For example, let N be a versionable node in workspace W of repository R.
+ * Furthermore, let N be of node type T, where T is a sub-type of
+ * nt:versionable and T allows N to have one property called P and one child
+ * node called C.
+ * <p>
+ * What happens to P and C when N is versioned depends on their respective
+ * OnParentVersion attribute as defined in the PropertyDef for P and the
+ * NodeDef for C, found in the definition of node type T.
+ * <p>
+ * The possible values for the OnParentVersion attribute are: COPY, VERSION,
+ * INITIALIZE, COMPUTE, NOTHING and FORBIDDEN.
+ * <p>
+ * The sections below describe, for each possible value of the OnParentVersion
+ * attribute, what happens to C and P when,
+ * <ul>
+ * <li>N.checkin() is performed, creating the new version VN and adding to the
+ * version history.
+ * <li>N.restore(VN)  is performed, restoring the version VN.
+ * </ul>
+ * <p>
+ * COPY
+ * <p>
+ * Child Node
+ * <p>
+ * On checkin of N, C and all its descendent items, down to the leaves of the
+ * subtree, will be copied to the version storage as a child subtree of VN. The
+ * copy of C and its subtree will not have its own version history but will be
+ * part of the state preserved in VN. C itself need not be versionable.
+ * <p>
+ * On restore of VN, the copy of C and its subtree stored will be restored as
+ * well, replacing the current C and its subtree in the workspace.
+ * <p>
+ * Property
+ * <p>
+ * On checkin of N, P will be copied to the version storage as a child of VN.
+ * This copy of P is part of the state preserved in VN.
+ * <p>
+ * On restore of VN, the copy of P stored as its child will be restored as
+ * well, replacing the current P in the workspace.
+ * <p>
+ * VERSION
+ * <p>
+ * Child Node
+ * <p>
+ * On checkin of N, the node VN will get a child reference to the version
+ * history of C (not to C or any actual version of C). In practice, this means
+ * that the root version of C's version history becomes the child of VN
+ * because, as mentioned before, the root version is used as the referent when
+ * a reference to the version history as a whole is required. This also
+ * requires that C itself be versionable (otherwise it would not have a version
+ * history). If C is not versionable then behavior of IGNORE applies on checkin
+ * (see below).
+ * <p>
+ * On restore of VN, if the workspace currently has an already existing node
+ * corresponding to C's version history, then that instance of C becomes the
+ * child of the restored N. If the workspace does not have an instance of C
+ * then one is restored from C's version history. The workspace in which the
+ * restore is being performed will determine which particular version of C will
+ * be restored. This determination depends on the configuration of the
+ * workspace and is outside the scope of this specification.
+ * <p>
+ * Property
+ * <p>
+ * In the case of properties, an OnParentVersion attribute of VERSION has the
+ * same effect as COPY.
+ * <p>
+ * INITIALIZE
+ * <p>
+ * Child Node
+ * <p>
+ * On checkin of N, a new node C will be created and placed in version storage
+ * as a child of VN. This new C will be initialized just as it would be if
+ * created normally in a workspace. No state information of the current C in
+ * the workspace is preserved. The new C will not have its own version history
+ * but will be part of the state preserved in VN. C itself need not be
+ * versionable.
+ * <p>
+ * On restore of VN, the C stored as its child will be restored as well,
+ * replacing the current C in the workspace.
+ * <p>
+ * Property
+ * <p>
+ * On checkin of N, a new P will be created and placed in version storage as a
+ * child of VN. The new P will be initialized just as it would be if created
+ * normally in a workspace. The new P is part of the state preserved in VN.
+ * <p>
+ * On restore of VN, the P stored as its child will be restored as well,
+ * replacing the current P in the workspace.
+ * <p>
+ * COMPUTE
+ * <p>
+ * Child Node
+ * <p>
+ * On checkin of N, a new node C will be created and placed in version storage
+ * as a child of VN. This new C will be initialized according to some
+ * configuration-specific procedure beyond the scope of this specification. The
+ * new C will not have its own version history but will be part of the state
+ * preserved in VN. C itself need not be versionable.
+ * <p>
+ * On restore of VN, the C stored as its child will be restored as well,
+ * replacing the current C in the workspace.
+ * <p>
+ * Property
+ * <p>
+ * On checkin of N, a new P will be created and placed in version storage as a
+ * child of VN. The new P will be initialized according to some
+ * configuration-specific procedure beyond the scope of this specification. The
+ * new P is part of the state preserved in VN.
+ * <p>
+ * On restore of VN, the P stored as its child will be restored as well,
+ * replacing the current P in the workspace.
+ * <p>
+ * IGNORE
+ * <p>
+ * Child Node
+ * <p>
+ * On checkin of N, no state information about C will be stored in VN.
+ * <p>
+ * On restore of VN, the child node C of the current N will remain and not be
+ * removed, despite not being included in the state recorded in VN, since its
+ * IGNORE status tells the system to leave it alone.
+ * <p>
+ * Property
+ * <p>
+ * On checkin of N, no state information about P will be stored in VN.
+ * <p>
+ * On restore of VN, the property P of the current N will remain and not be
+ * removed, despite not being included in the state of recorded in VN, since
+ * its IGNORE status tells the system to leave it alone.
+ * <p>
+ * ABORT
+ * <p>
+ * Child Node or Property
+ * <p>
+ * On checkin of N an exception will be thrown. Having a child node or property
+ * with an OnParentVersion attribute of ABORT prevents the parent node from
+ * being checked-in.
+ *
+ * @author Markus Nix <mnix@mayflower.de>
+ * @package phpcr
+ * @subpackage version
+ */
+final class OnParentVersionAction
+{
+    /**
+     * The action constants.
+     */
+    const COPY       = 1;
+    const VERSION    = 2;
+    const INITIALIZE = 3;
+    const COMPUTE    = 4;
+    const IGNORE     = 5;
+    const ABORT      = 6;
+
+    /**
+     * The names of the defined on-version actions,
+     * as used in serialization.
+     */
+    const ACTIONNAME_COPY       = "COPY";
+    const ACTIONNAME_VERSION    = "VERSION";
+    const ACTIONNAME_INITIALIZE = "INITIALIZE";
+    const ACTIONNAME_COMPUTE    = "COMPUTE";
+    const ACTIONNAME_IGNORE     = "IGNORE";
+    const ACTIONNAME_ABORT      = "ABORT";
+
+
+    /**
+     * Private constructor to prevent instantiation
+     */
+    private function __construct() {
+    }
+
+
+    /**
+     * Returns the name of the specified <code>action</code>,
+     * as used in serialization.
+     * @param  int    $action the on-version action
+     * @return string the name of the specified <code>action</code>
+     * @throws IllegalArgumentException if <code>action</code>
+     * is not a valid on-version action.
+     */
+    public static function nameFromValue( $action ) {
+        switch ( $action ) {
+            case self::COPY:
+               return self::ACTIONNAME_COPY;
+
+            case self::VERSION:
+                return self::ACTIONNAME_VERSION;
+
+            case self::INITIALIZE:
+                return self::ACTIONNAME_INITIALIZE;
+
+            case self::COMPUTE:
+                return self::ACTIONNAME_COMPUTE;
+
+            case self::IGNORE:
+                return self::ACTIONNAME_IGNORE;
+
+            case self::ABORT:
+                return self::ACTIONNAME_ABORT;
+
+            default:
+               throw new IllegalArgumentException("unknown on-version action: " + $action);
+        }
+    }
+
+    /**
+     * Returns the numeric constant value of the on-version action with the
+     * specified name.
+     * @param  string $name the name of the on-version action
+     * @return int    the numeric constant value
+     * @throws IllegalArgumentException if <code>name</code>
+     * is not a valid on-version action name.
+     */
+    public static function valueFromName( $name ) {
+        if ( $name == self::ACTIONNAME_COPY ) {
+            return self::COPY;
+        } else if ( $name == self::ACTIONNAME_VERSION ) {
+            return self::VERSION;
+        } else if ( $name == self::ACTIONNAME_INITIALIZE ) {
+            return self::INITIALIZE;
+        } else if ( $name == self::ACTIONNAME_COMPUTE ) {
+            return self::COMPUTE;
+        } else if ( $name == self::ACTIONNAME_IGNORE ) {
+            return self::IGNORE;
+        } else if ( $name == self::ACTIONNAME_ABORT ) {
+            return self::ABORT;
+        } else {
+            throw new IllegalArgumentException( "unknown on-version action: " + $name );
+        }
+    }
+}
+
+?>
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/Version.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/Version.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/Version.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/Version.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,76 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require_once 'PHPCR/Node.php';
+require_once 'PHPCR/version/VersionHistory.php';
+require_once 'PHPCR/RepositoryException.php';
+
+
+/**
+ * A <code>Version</code> object wraps an <code>nt:version</code> node. It
+ * provides convenient access to version information.
+ *
+ * @author Markus Nix <mnix@mayflower.de>
+ * @package phpcr
+ * @subpackage version
+ */
+interface Version extends Node
+{
+    /**
+     * Returns the <code>VersionHistory</code> that contains this <code>Version</code>.
+     * @return the <code>VersionHistory</code> that contains this <code>Version</code>.
+     * @throws RepositoryException if an error occurs.
+     */
+     public function getContainingHistory();
+
+    /**
+     * Returns the date this version was created. This corresponds to the value
+     * of the <code>jcr:created</code> property in the <code>nt:version</code>
+     * node that represents this version.
+     *
+     * @return date
+     * @throws RepositoryException if an error occurs.
+     */
+    public function getCreated();
+
+    /**
+     * Returns the successor versions of this version. This corresponds to
+     * returning all the <code>nt:version</code> nodes referenced by the
+     * <code>jcr:successors</code> multi-value property in the
+     * <code>nt:version</code> node that represents this version.
+     *
+     * @return a <code>Version</code> array.
+     * @throws RepositoryException if an error occurs.
+     */
+    public function getSuccessors();
+
+    /**
+     * Returns the predecessor versions of this version. This corresponds to
+     * returning all the <code>nt:version</code> nodes whose
+     * <code>jcr:successors</code> property includes a reference to the
+     * <code>nt:version</code> node that represents this version.
+     *
+     * @return a <code>Version</code> array.
+     * @throws RepositoryException if an error occurs.
+     */
+    public function getPredecessors();
+}
+
+?>

Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/VersionException.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/VersionException.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/VersionException.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/VersionException.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,36 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require_once 'PHPCR/RepositoryException.php';
+
+
+/**
+ * Exception thrown by Version.addSuccessor if an invalid
+ * version graph operation is attempted.
+ *
+ * @author Markus Nix <mnix@mayflower.de>
+ * @package phpcr
+ * @subpackage version
+ */
+class VersionException extends RepositoryException
+{
+}
+
+?>
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/VersionHistory.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/VersionHistory.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/VersionHistory.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/VersionHistory.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,212 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require_once 'PHPCR/RepositoryException.php';
+require_once 'PHPCR/version/Version.php';
+require_once 'PHPCR/version/VersionIterator.php';
+require_once 'PHPCR/ReferentialIntegrityException.php';
+require_once 'PHPCR/AccessDeniedException.php';
+require_once 'PHPCR/UnsupportedRepositoryOperationException.php';
+require_once 'PHPCR/version/VersionException.php';
+
+
+/**
+ * A <code>VersionHistory</code> object wraps an <code>nt:versionHistory</code>
+ * node. It provides convenient access to version history information.
+ *
+ * @author Markus Nix <mnix@mayflower.de>
+ * @package phpcr
+ * @subpackage version
+ */
+interface VersionHistory
+{
+    /**
+     * Returns the UUID of the versionable node for which this is the version history.
+     *
+     * @return the UUID of the versionable node for which this is the version history.
+     * @throws RepositoryException if an error occurs.
+     */
+    public function getVersionableUUID();
+
+    /**
+     * Returns the root version of this version history.
+     *
+     * @return a <code>Version</code> object.
+     * @throws RepositoryException if an error occurs.
+     */
+    public function getRootVersion();
+
+    /**
+     * Returns an iterator over all the versions within this version history
+     * The order of the returned objects will not necessarily correspond to the
+     * order of versions in terms of the successor relation. To traverse the
+     * version graph one must traverse the <code>jcr:successor REFERENCE</code>
+     * properties starting with the root version. A version history will always
+     * have at least one version, the root version. Therefore, this method will
+     * always return an iterator of at least size 1.
+     *
+     * @return a <code>VersionIterator</code> object.
+     * @throws RepositoryException if an error occurs.
+     */
+    public function getAllVersions();
+
+    /**
+     * Retrieves a particular version from this version history by version name.
+     * <p/>
+     * Throws a <code>VersionException</code> if the specified version is not in
+     * this version history.
+     *
+     * @param versionName a version name
+     * @return a <code>Version</code> object.
+     * @throws VersionException if the specified version is not in this version history.
+     * @throws RepositoryException if an error occurs.
+     */
+    public function getVersion( $versionName );
+
+    /**
+     * Retrieves a particular version from this version history by version label.
+     * <p/>
+     * Throws a <code>VersionException</code> if the specified <code>label</code> is not in
+     * this version history.
+     *
+     * @param label a version label
+     * @return a <code>Version</code> object.
+     * @throws VersionException if the specified <code>label</code> is not in this version history.
+     * @throws RepositoryException if an error occurs.
+     */
+    public function getVersionByLabel( $label );
+
+    /**
+     * Adds the specified label to the specified version. This corresponds to adding a
+     * value to the <code>jcr:versionLabels</code> multi-value property of the
+     * <code>nt:version</code> node that represents the specified version.
+     * <p/>
+     * Note that this change is made immediately; there is no need to call <code>save</code>.
+     * In fact, since the the version storage is read-only with respect to normal repository
+     * methods, <code>save</code> does not even function in this context.
+     * <p/>
+     * Within a particular version history, a given label may appear a maximum of once.
+     * If the specified label is already assigned to a version in this history and
+     * <code>moveLabel</code> is <code>true</code> then the label is removed from its
+     * current location and added to the version with the specified <code>versionName</code>.
+     * If <code>moveLabel</code> is <code>false</code>, then an attempt to add a label that
+     * already exists in this version history will throw a <code>VersionException</code>.
+     *
+     * @param versionName the name of the version to which the label is to be added.
+     * @param label the label to be added.
+     * @param moveLabel if <code>true</code>, then if <code>label</code> is already assigned to a version in
+     * this version history, it is moved to the new version specified; if <code>false</code>, then attempting
+     * to assign an already used label will throw a <code>VersionException</code>.
+     *
+     * @throws VersionException if an attempt is made to add an existing label to a version history
+     * and <code>moveLabel</code> is <code>false</code> or if the specifed version does not exisit in
+     * this version history.
+     * @throws RepositoryException if another error occurs.
+     */
+    public function addVersionLabel( $versionName, $label, $moveLabel );
+
+    /**
+     * Removes the specified label from among the labels of this version history.
+     * This corresponds to removing a property from the <code>jcr:versionLabels</code>
+     * child node of the <code>nt:versionHistory</code> node that represents this version
+     * history.
+     * <p/>
+     * Note that this change is made immediately; there is no need to call <code>save</code>.
+     * In fact, since the the version storage is read-only with respect to normal repository
+     * methods, <code>save</code> does not even function in this context.
+     * <p/>
+     * If a label is specified that does not exist in this version history,
+     * a <code>VersionException</code> is thrown.
+     *
+     * @param label a version label
+     * @throws VersionException if the name labvel does not exist in this version history.
+     * @throws RepositoryException if another error occurs.
+     */
+    public function removeVersionLabel( $label );
+
+    /**
+     * Returns true if the given version has the given <code>label</code>.
+     * @param version a Version object
+     * @param label a version label
+     * @return a <code>boolean</code>.
+     * @throws VersionException if the specified <code>version</code> is not of this version history.
+     * @throws RepositoryException if another error occurs.
+     *
+     */
+    public function hasVersionLabel( Version $version, $label );
+
+    /**
+     * Returns all version labels of the given <code>version</code> - empty array if none.
+     * Throws a <code>VersionException</code> if the specified <code>version</code> is not
+     * in this version history.
+     * @param version
+     * @return a <code>String</code> array containing all the labels of the given version
+     * @throws VersionException if the specified <code>version</code> is not in this version history.
+     * @throws RepositoryException if another error occurs.
+     */
+    public function getVersionLabels( Version $version );
+
+    /**
+     * Removes the named version from this version history and automatically
+     * repairs the version graph. If the version to be removed is <code>V</code>, <code>V</code>'s
+     * predecessor set is <code>P</code> and <code>V</code>'s successor set is <code>S</code>, then
+     * the version graph is repaired s follows:
+     * <ul>
+     * <li>For each member of <code>P</code>, remove the reference to <code>V</code> from its
+     * successor list and add references to each member of <code>S</code>.
+     * <li>For each member of <code>S</code>, remove the reference to <code>V</code> from its
+     * predecessor list and add references to each member of <code>P</code>.
+     * </ul>
+     * Note that this change is made immediately; there is no need to call <code>save</code>.
+     * In fact, since the the version storage is read-only with respect to normal repository
+     * methods, <code>save</code> does not even function in this context.
+     * <p/>
+     * A <code>ReferentialIntegrityException</code> will be thrown if the specified version is
+     * currently the target of a <code>REFERENCE</code> property elsewhere in the repository
+     * (not just in this workspace) and the current <code>Session</code> has read access to
+     * that <code>REFERENCE</code> property.
+     * <p/>
+     * An <code>AccessDeniedException</code> will be thrown if the current <code>Session</code>
+     * does not have permission to remove the specified version or if the specified version is
+     * currently the target of a <code>REFERENCE</code> property elsewhere in the repository
+     * (not just in this workspace) and the current <code>Session</code> does not have read
+     * access to that <code>REFERENCE</code> property.
+     * <p/>
+     * Throws an <code>UnsupportedRepositoryOperationException</code> if this operation is
+     * not supported by the implementation.
+     * <p/>
+     * Throws a <code>VersionException</code> if the named version is not in this <code>VersionHistory</code>.
+     *
+     * @param versionName the name of a version in this version history.
+     * @throws ReferentialIntegrityException if the specified version is currently the target of a
+     * <code>REFERENCE</code> property elsewhere in the repository (not necessarily in this workspace)
+     * and the current <code>Session</code> has read access to that <code>REFERENCE</code> property.
+     * @throws AccessDeniedException if the current Session does not have permission to remove the
+     * specified version or if the specified version is currently the target of a <code>REFERENCE</code>
+     * property elsewhere in the repository (not just in this workspace) and the current <code>Session</code>
+     * does not have read access to that <code>REFERENCE</code> property.
+     * @throws UnsupportedRepositoryOperationException if this operation is not supported by the implementation.
+     * @throws VersionException if the named version is not in this version history.
+     * @throws RepositoryException if another error occurs.
+     */
+    public function removeVersion( $versionName );
+}
+
+?>
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/VersionIterator.php
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/VersionIterator.php?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/VersionIterator.php (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/PHPCR/version/VersionIterator.php Sun Jul  3 04:58:33 2005
@@ -0,0 +1,46 @@
+<?php
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+require_once 'PHPCR/RangeIterator.php';
+require_once 'PHPCR/version/Version.php';
+require_once 'PHPCR/NoSuchElementException.php';
+
+
+/**
+ * Allows easy iteration through a list of <code>Version</code> objects
+ * with <code>nextNode</code> as well as a <code>skip</code> method inherited from
+ * <code>RangeIterator</code>.
+ *
+ * @author Markus Nix <mnix@mayflower.de>
+ * @package phpcr
+ * @subpackage version
+ */
+interface VersionIterator extends RangeIterator
+{
+     /**
+      * Returns the next <code>Version</code> in the iteration.
+      *
+      * @return the next <code>Version</code> in the iteration.
+      * @throws NoSuchElementException if iteration has no more <code>Version</code>s.
+     */
+    public function nextVersion();
+}
+
+?>
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/phpcr/package.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/phpcr/package.xml?rev=208906&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/phpcr/package.xml (added)
+++ incubator/jackrabbit/trunk/contrib/phpcr/package.xml Sun Jul  3 04:58:33 2005
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0">
+<package version="1.0">
+  <name>PHPCR</name>
+  <summary>Port of JSR-170 Specification to PHP</summary>
+  <description>
+    The JSR-170 API defines how an application and a content
+    repository interact with respect to a number of content services.
+    For example the versioning facilities of a content repository are
+    clearly defined, so an application knows how to browse the version
+    history, check in and check out content items, or update and merge
+    content in a standard fashion. This is the PHP pot of the API.
+  </description>
+  <maintainers>
+    <maintainer>
+      <user>mnix</user>
+      <name>Markus Nix</name>
+      <email>mnix@docuverse.de</email>
+      <role>lead</role>
+    </maintainer>
+  </maintainers>
+  <release>
+    <version>0.2</version>
+    <date>2005-06-15</date>
+    <license>Apache License</license>
+    <state>alpha</state>
+    <notes>Changes reflect most of the latest changes in the JCR spec.</notes>
+    <deps>
+      <dep type="php" rel="ge" version="5.0.0" optional="no"/>
+    </deps>
+    <filelist>
+      <dir name="PHPCR" role="php">
+        <file>AccessDeniedException.php</file>
+        <file>Credentials.php</file>
+        <file>IllegalArgumentException.php</file>
+        <file>IllegalStateException.php</file>
+        <file>InvalidItemStateException.php</file>
+        <file>InvalidSerializedDataException.php</file>
+        <file>IOException.php</file>
+        <file>Item.php</file>
+        <file>ItemExistsException.php</file>
+        <file>ItemNotFoundException.php</file>
+        <file>ItemVisitor.php</file>
+        <file>LoginException.php</file>
+        <file>MergeException.php</file>
+        <file>NamespaceException.php</file>
+        <file>NamespaceRegistry.php</file>
+        <file>Node.php</file>
+        <file>NodeIterator.php</file>
+        <file>NoSuchElementException.php</file>
+        <file>NoSuchWorkspaceException.php</file>
+        <file>NumberFormatException.php</file>
+        <file>PathNotFoundException.php</file>
+        <file>Property.php</file>
+        <file>PropertyIterator.php</file>
+        <file>PropertyType.php</file>
+        <file>RangeIterator.php</file>
+        <file>ReferentialIntegrityException.php</file>
+        <file>Repository.php</file>
+        <file>RepositoryException.php</file>
+        <file>SAXException.php</file>
+        <file>Session.php</file>
+        <file>SimpleCredentials.php</file>
+        <file>UnsupportedRepositoryOperationException.php</file>
+        <file>Value.php</file>
+        <file>ValueFormatException.php</file>
+        <file>Workspace.php</file>
+        <file>lock/Lock.php</file>
+        <file>lock/LockException.php</file>
+        <file>nodetype/ConstraintViolationException.php</file>
+        <file>nodetype/NodeType.php</file>
+        <file>nodetype/NodeTypeIterator.php</file>
+        <file>nodetype/NodeTypeManager.php</file>
+        <file>nodetype/NoSuchNodeTypeException.php</file>
+        <file>nodetype/ItemDefinition.php</file>
+        <file>nodetype/NodeDefinition.php</file>
+        <file>nodetype/PropertyDefinition.php</file>
+        <file>observation/Event.php</file>
+        <file>observation/EventIterator.php</file>
+        <file>observation/EventListener.php</file>
+        <file>observation/EventListenerIterator.php</file>
+        <file>observation/ObservationManager.php</file>
+        <file>query/InvalidQueryException.php</file>
+        <file>query/Query.php</file>
+        <file>query/QueryManager.php</file>
+        <file>query/QueryResult.php</file>
+        <file>query/Row.php</file>
+        <file>query/RowIterator.php</file>
+        <file>util/ISO8601.php</file>
+        <file>util/TraversingItemVisitor.php</file>
+        <file>version/OnParentVersionAction.php</file>
+        <file>version/Version.php</file>
+        <file>version/VersionException.php</file>
+        <file>version/VersionHistory.php</file>
+        <file>version/VersionIterator.php</file>
+      </dir>
+    </filelist>
+  </release>
+  <changelog>
+    <release>
+      <version>0.1</version>
+      <date>2005-05-06</date>
+      <license>Apache License</license>
+      <state>alpha</state>
+    </release>
+  </changelog>
+</package>

Propchange: incubator/jackrabbit/trunk/contrib/phpcr/package.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message