Author: stefan Date: Fri May 4 15:45:35 2012 New Revision: 1334040 URL: http://svn.apache.org/viewvc?rev=1334040&view=rev Log: OAK-85: NPE and wrong result on copy operation
Modified: jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java Modified: jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java?rev=1334040&r1=1334039&r2=1334040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java (original) +++ jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java Fri May 4 15:45:35 2012 @@ -263,6 +263,19 @@ public class MicroKernelIT extends Abstr assertTrue(mk.nodeExists("/test/child", null)); assertTrue(mk.nodeExists("/test/copy/child", null)); + JSONObject obj = parseJSONObject(mk.getNodes("/test", null, 99, 0, -1, null)); + assertPropertyValue(obj, ":childNodeCount", 2l); + assertPropertyValue(obj, "copy/:childNodeCount", 1l); + assertPropertyValue(obj, "copy/child/:childNodeCount", 0l); + + mk.commit("", "+\"/root\":{} +\"/root/N4\":{} *\"/root/N4\":\"/root/N4/N5\"", null, null); + assertTrue(mk.nodeExists("/root", null)); + assertTrue(mk.nodeExists("/root/N4", null)); + assertTrue(mk.nodeExists("/root/N4/N5", null)); + obj = parseJSONObject(mk.getNodes("/root", null, 99, 0, -1, null)); + assertPropertyValue(obj, ":childNodeCount", 1l); + assertPropertyValue(obj, "N4/:childNodeCount", 1l); + assertPropertyValue(obj, "N4/N5/:childNodeCount", 0l); } @Test Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java?rev=1334040&r1=1334039&r2=1334040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java (original) +++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java Fri May 4 15:45:35 2012 @@ -77,14 +77,20 @@ public interface MicroKernel { * ... * ] * </pre> + * The {@code path} parameter allows to filter the revisions by path, i.e. + * only those revisions that affected the subtree rooted at {@code path} + * will be included. * * @param since timestamp (ms) of earliest revision to be returned * @param maxEntries maximum #entries to be returned; * if < 0, no limit will be applied. + * @param path optional path filter; if {@code null} or {@code ""} the + * default ({@code"/"}) will be assumed, i.e. no filter + * will be applied * @return a list of revisions in chronological order in JSON format. * @throws MicroKernelException if an error occurs */ - String /* jsonArray */ getRevisionHistory(long since, int maxEntries) + String /* jsonArray */ getRevisionHistory(long since, int maxEntries/*, String path*/) throws MicroKernelException; /** @@ -127,6 +133,10 @@ public interface MicroKernel { * If {@code fromRevisionId} and {@code toRevisionId} are not in chronological * order the returned journal will be empty (i.e. {@code []}) * <p/> + * The {@code path} parameter allows to filter the revisions by path, i.e. + * only those revisions that affected the subtree rooted at {@code path} + * will be included. + * <p/> * A {@code MicroKernelException} is thrown if either {@code fromRevisionId} * or {@code toRevisionId} doesn't exist, denotes a <i>private</i> branch * revision or if another error occurs. @@ -134,14 +144,14 @@ public interface MicroKernel { * @param fromRevisionId id of first revision to be returned in journal * @param toRevisionId id of last revision to be returned in journal, * if {@code null} the current head revision is assumed - * @param filter (optional) filter criteria - * (e.g. path, property names, etc); - * TODO specify format and semantics + * @param path optional path filter; if {@code null} or {@code ""} + * the default ({@code"/"}) will be assumed, i.e. no + * filter will be applied * @return a chronological list of revisions in JSON format * @throws MicroKernelException if an error occurs */ String /* jsonArray */ getJournal(String fromRevisionId, String toRevisionId, - String filter) + String path) throws MicroKernelException; /** @@ -149,17 +159,21 @@ public interface MicroKernel { * revisions. The changes will be consolidated if the specified range * covers intermediary revisions. {@code fromRevisionId} and {@code toRevisionId} * don't need not be in a specific chronological order. + * <p/> + * The {@code path} parameter allows to filter the revisions by path, i.e. + * only those revisions that affected the subtree rooted at {@code path} + * will be included. * * @param fromRevisionId a revision id, if {@code null} the current head revision is assumed * @param toRevisionId another revision id, if {@code null} the current head revision is assumed - * @param filter (optional) filter criteria - * (e.g. path, property names, etc); - * TODO specify format and semantics + * @param path optional path filter; if {@code null} or {@code ""} + * the default ({@code"/"}) will be assumed, i.e. no + * filter will be applied * @return JSON diff representation of the changes * @throws MicroKernelException if an error occurs */ String /* JSON diff */ diff(String fromRevisionId, String toRevisionId, - String filter) + String path) throws MicroKernelException; //-------------------------------------------------------------< READ ops > @@ -250,6 +264,20 @@ public interface MicroKernel { * <p/> * The {@code offset} and {@code count} parameters are only applied to the * direct child nodes of the root of the returned node tree. + * <p/> + * The {@code filter} parameter allows to specify the names of properties + * to be included or excluded. + * <p/> + * Format: + * <pre> + * { + * incl: [ "foo", "foo1" ], + * excl: [ "bar", "tmp" ] + * } + * </pre> + * TODO clarify (globbing) syntax, semantics and implicit default filter (OAK-75) + * <p/> + * For more information see {@link #getNodes(String, String)}. * * @param path path denoting root of node tree to be retrieved * @param revisionId revision id, if {@code null} the current head revision is assumed @@ -257,11 +285,11 @@ public interface MicroKernel { * @param offset start position in the iteration order of child nodes (0 to start at the * beginning) * @param count maximum number of child nodes to retrieve (-1 for all) - * @param filter (optional) filter criteria - * (e.g. names of properties to be included, etc); - * TODO specify format and semantics + * @param filter optional filter on property names; if {@code null} or + * {@code ""} the default filter will be assumed * @return node tree in JSON format or {@code null} if the specified node does not exist * @throws MicroKernelException if the specified revision does not exist or if another error occurs + * @see #getNodes(String, String) */ String /* jsonTree */ getNodes(String path, String revisionId, int depth, long offset, int count, String filter) Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java?rev=1334040&r1=1334039&r2=1334040&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java (original) +++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java Fri May 4 15:45:35 2012 @@ -615,15 +615,16 @@ public class CommitBuilder { throw new NotFoundException(srcPath); } - MutableNode destParent = getOrCreateStagedNode(destParentPath); - destParent.add(new ChildNode(destNodeName, srcCNE.getId())); - if (staged.containsKey(srcPath)) { // the copied subtree is modified // update staging area copyStagedNodes(srcPath, destPath, destPath); } + + MutableNode destParent = getOrCreateStagedNode(destParentPath); + destParent.add(new ChildNode(destNodeName, srcCNE.getId())); + } @Override