Created
February 28, 2012 22:17
-
-
Save jukka/1935626 to your computer and use it in GitHub Desktop.
jr3 MicroKernel read operations based on the Tree interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MicroKernelImpl implements MicroKernel { | |
public boolean nodeExists(String path, String revisionId) | |
throws MicroKernelException { | |
Tree tree = getTree(revisionId); | |
for (String name : splitPathToElements(path)) { | |
if (tree == null) { | |
return false; | |
} | |
tree = tree.get(name); | |
} | |
return tree != null && !tree.isLeaf(); | |
} | |
public String getNodes(String path, String revisionId) | |
throws MicroKernelException { | |
return getNodes(path, revisionId, 1, 0, -1); | |
} | |
public String getNodes( | |
String path, String revisionId, int depth, long offset, int count) | |
throws MicroKernelException { | |
Tree tree = getTree(revisionId); | |
for (String name : splitPathToElements(path)) { | |
if (tree == null) { | |
throw new MicroKernelException("Path not found: " + path); | |
} | |
tree = tree.get(name); | |
} | |
if (tree != null && !tree.isLeaf()) { | |
return serializeToJson(tree, depth, offset, count); | |
} else { | |
throw new MicroKernelException("Path not found: " + path); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment