Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0C1ADFB29 for ; Thu, 2 May 2013 11:35:41 +0000 (UTC) Received: (qmail 52357 invoked by uid 500); 2 May 2013 11:35:40 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 52298 invoked by uid 500); 2 May 2013 11:35:39 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 52258 invoked by uid 99); 2 May 2013 11:35:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 May 2013 11:35:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 May 2013 11:35:34 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 469C02388ABB; Thu, 2 May 2013 11:35:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1478331 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api: Root.java Tree.java Date: Thu, 02 May 2013 11:35:13 -0000 To: oak-commits@jackrabbit.apache.org From: mduerig@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130502113513.469C02388ABB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mduerig Date: Thu May 2 11:35:12 2013 New Revision: 1478331 URL: http://svn.apache.org/r1478331 Log: OAK-798: Review / refactor TreeImpl and related classes Javadoc Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java?rev=1478331&r1=1478330&r2=1478331&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java Thu May 2 11:35:12 2013 @@ -21,21 +21,19 @@ package org.apache.jackrabbit.oak.api; import javax.annotation.Nonnull; /** - * The root of a {@link Tree}. - *

- * The data returned by this class filtered for the access rights that are set - * in the {@link ContentSession} that created this object. - *

+ * A {@code Root} instance serves as a container for a {@link Tree}. It is + * obtained from a {@link ContentSession}, which governs accessibility and + * visibility of the {@code Tree} and its sub trees. + *

* All root instances created by a content session become invalid after the * content session is closed. Any method called on an invalid root instance * will throw an {@code InvalidStateException}. - *

- * {@link Tree} instances may become disconnected after a call to {@link #refresh()}, - * {@link #rebase()} or {@link #commit()}. Any access to disconnected tree instances - * - except for {@link Tree#getName()}, {@link Tree#isRoot()}, {@link Tree#getPath()}, - * {@link Tree#getParent()} and {@link Tree#exists()} - will cause an + *

+ * {@link Tree} instances may become non existing after a call to + * {@link #refresh()}, {@link #rebase()} or {@link #commit()}. Any write + * access to non existing {@code Tree} instances will cause an * {@code InvalidStateException}. - * TODO document iterability / existence (OAK-798) + * @see Tree Existence and iterability of trees */ public interface Root { @@ -92,9 +90,9 @@ public interface Root { /** * Get a tree location for a given absolute {@code path} - * * @param path absolute path to the location * @return the tree location for {@code path} + * @deprecated use {@link #getTree(String)} */ @Nonnull @Deprecated @@ -102,22 +100,21 @@ public interface Root { /** * Rebase this root instance to the latest revision. After a call to this method, - * trees obtained through {@link #getTree(String)} may become disconnected. + * trees obtained through {@link #getTree(String)} may become non existing. */ void rebase(); /** * Reverts all changes made to this root and refreshed to the latest trunk. * After a call to this method, trees obtained through {@link #getTree(String)} - * may become disconnected. + * may become non existing. */ void refresh(); /** - * Atomically apply all changes made to the tree beneath this root to the + * Atomically apply all changes made to the tree contained in this root to the * underlying store and refreshes this root. After a call to this method, - * all trees obtained through {@link #getTree(String)} become invalid and fresh - * instances must be obtained. + * trees obtained through {@link #getTree(String)} may become non existing. * * @throws CommitFailedException */ Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java?rev=1478331&r1=1478330&r2=1478331&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java Thu May 2 11:35:12 2013 @@ -23,46 +23,65 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; /** - * A tree instance represents a snapshot of the {@code ContentRepository} - * tree at the time the instance was acquired. Tree instances may - * become invalid over time due to garbage collection of old content, at - * which point an outdated snapshot will start throwing + * A tree instance represents a snapshot of the {@link ContentRepository} + * tree at the time the instance was acquired from a {@link ContentSession}. + * Tree instances may become invalid over time due to garbage collection of + * old content, at which point an outdated snapshot will start throwing * {@code IllegalStateException}s to indicate that the snapshot is no * longer available. - *

+ * + *

Order and orderability

* The children of a {@code Tree} are generally unordered. That is, the * sequence of the children returned by {@link #getChildren()} may change over - * time as this Tree is modified either directly or through some other session. - * Calling {@link #orderBefore(String)} will persist the current order and - * maintain the order as new children are added or removed. In this case a new - * child will be inserted after the last child as seen by {@link #getChildren()}. - *

+ * time as this {@code Tree} is modified either directly or through some other + * session. Calling {@link #orderBefore(String)} will persist the current order + * and maintain the order as new children are added or removed. In this case a + * new child will be inserted after the last child as seen by {@link #getChildren()}. + * + *

State and state transitions

* A tree instance belongs to the client and its state is only modified * in response to method calls made by the client. The various accessors * on this interface mirror these of the underlying {@code NodeState} * interface. However, since instances of this class are mutable return * values may change between invocations. - *

+ *

+ * All tree instances created in the context of a content session become invalid + * after the content session is closed. Any method called on an invalid tree instance + * will throw an {@code InvalidStateException}. + *

+ * {@link Tree} instances may become non existing after a call to + * {@link Root#refresh()}, {@link Root#rebase()} or {@link Root#commit()}. Any write + * access to non existing {@code Tree} instances will cause an + * {@code InvalidStateException}. + * + *

Thread safety

* Tree instances are not thread-safe for write access, so writing clients * need to ensure that they are not accessed concurrently from multiple * threads. Instances are however thread-safe for read access, so * implementations need to ensure that all reading clients see a * coherent state. - *

- * The data returned by this class and intermediary objects such as - * {@link PropertyState} is filtered for the access rights that are set in the - * {@link ContentSession} that created the {@link Root} of this object. - *

- * All tree instances created in the context of a content session become invalid - * after the content session is closed. Any method called on an invalid tree instance - * will throw an {@code InvalidStateException}. - *

- * {@link Tree} instances may become disconnected after a call to {@link Root#refresh()}, - * {@link Root#rebase()} or {@link Root#commit()}. Any access to disconnected tree instances - * - except for {@link Tree#getName()}, {@link Tree#isRoot()}, {@link Tree#getPath()}, - * {@link Tree#getParent()} and {@link Tree#exists()} - will cause an - * {@code InvalidStateException}. - * TODO document iterability / existence (OAK-798) + * + *

Visibility and access control

+ * The data returned by this class and intermediary objects such as are access + * controlled governed by the {@code ContentSession} instance from which + * the containing {@code Root} was obtained. + * + *

Existence and iterability of trees

+ *

+ * The {@link #getChild(String)} method is special in that it never + * returns a {@code null} value, even if the named tree does not exist. + * Instead a client should use the {@link #exists()} method on the returned + * tree to check whether that tree exists. + *

+ * The iterability of a tree is a related to existence. A node + * state is iterable if it is included in the return values of the + * {@link #getChildrenCount()} and {@link #getChildren()} methods. An iterable + * node is guaranteed to exist, though not all existing nodes are necessarily + * iterable. + *

+ * Furthermore, a non-existing node is guaranteed to contain no properties + * or iterable child nodes. It can, however contain non-iterable children. + * Such scenarios are typically the result of access control restrictions. */ public interface Tree {