You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by st...@apache.org on 2011/07/25 17:36:24 UTC
svn commit: r1150752 - in
/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk:
MicroKernelImpl.java Repository.java
Author: stefan
Date: Mon Jul 25 15:36:23 2011
New Revision: 1150752
URL: http://svn.apache.org/viewvc?rev=1150752&view=rev
Log:
minor improvements (WIP)...
Modified:
jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java
Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java?rev=1150752&r1=1150751&r2=1150752&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java Mon Jul 25 15:36:23 2011
@@ -218,9 +218,7 @@ public class MicroKernelImpl implements
}
try {
- // TODO exception handling for flow control is very slow
- rep.getNode(revisionId, path);
- return true;
+ return rep.nodeExists(revisionId, path);
} catch (Exception e) {
return false;
}
@@ -240,18 +238,6 @@ public class MicroKernelImpl implements
}
}
- public long getChildNodeCount(String path, String revisionId) throws MicroKernelException {
- if (rep == null) {
- throw new IllegalStateException("this instance has already been disposed");
- }
-
- try {
- return rep.getNode(revisionId, path).getChildNodeCount();
- } catch (Exception e) {
- throw new MicroKernelException(e);
- }
- }
-
public String commit(String path, String jsonDiff, String revisionId, String message) throws MicroKernelException {
if (rep == null) {
throw new IllegalStateException("this instance has already been disposed");
@@ -310,6 +296,64 @@ public class MicroKernelImpl implements
targetPath = PathUtils.concat(path, targetPath);
}
cb.moveNode(PathUtils.concat(path, relPath), targetPath);
+/*
+ path = t.readString();
+ String from = PathUtils.concat(fromRoot, path);
+ String name = PathUtils.getName(from);
+ t.read(':');
+ String position, target;
+ boolean rename;
+ String to;
+ if (t.matches('{')) {
+ rename = false;
+ position = t.readString();
+ t.read(':');
+ target = t.readString();
+ t.read('}');
+ } else {
+ rename = true;
+ position = null;
+ target = t.readString();
+ }
+ boolean before = false;
+ if ("last".equals(position)) {
+ target = PathUtils.concat(target, name);
+ position = null;
+ } else if ("first".equals(position)) {
+ target = PathUtils.concat(target, name);
+ position = null;
+ before = true;
+ } else if ("before".equals(position)) {
+ position = PathUtils.getName(target);
+ target = PathUtils.getParentPath(target);
+ target = PathUtils.concat(target, name);
+ before = true;
+ } else if ("after".equals(position)) {
+ position = PathUtils.getName(target);
+ target = PathUtils.getParentPath(target);
+ target = PathUtils.concat(target, name);
+ } else if (position == null) {
+ // move
+ } else {
+ throw new AssertionError("position: " + position);
+ }
+ to = PathUtils.concat(fromRoot, target);
+ boolean inPlaceRename = false;
+ if (rename) {
+ if (PathUtils.getParentPath(from).equals(PathUtils.getParentPath(to))) {
+ inPlaceRename = true;
+ position = PathUtils.getName(from);
+ }
+ }
+ NodeImpl node = headRoot.getNode(from);
+ if (!inPlaceRename) {
+ headRoot = headRoot.cloneAndRemoveChildNode(from, headRevId);
+ }
+ headRoot = headRoot.cloneAndAddChildNode(to, before, position, node, headRevId);
+ if (inPlaceRename) {
+ headRoot = headRoot.cloneAndRemoveChildNode(from, headRevId);
+ }
+*/
break;
}
default:
Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java?rev=1150752&r1=1150751&r2=1150752&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java Mon Jul 25 15:36:23 2011
@@ -98,6 +98,32 @@ public class Repository {
return store.getNode(ids[ids.length - 1]);
}
+ public boolean nodeExists(String revId, String path) {
+ if (!initialized) {
+ throw new IllegalStateException("not initialized");
+ }
+
+ if (!PathUtils.isAbsolute(path)) {
+ throw new IllegalArgumentException("illegal path");
+ }
+
+ try {
+ String[] names = PathUtils.split(path);
+ Node parent = store.getNode(store.getCommit(revId).getRootNodeId());
+ for (int i = 0; i < names.length; i++) {
+ String id = parent.getChildNodeEntries().get(names[i]);
+ if (id == null) {
+ return false;
+ }
+ parent = store.getNode(id);
+ }
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+
public CommitBuilder getCommitBuilder(String revId, String msg) throws Exception {
return new CommitBuilder(revId, msg, this);