You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by tr...@apache.org on 2015/10/12 21:14:56 UTC
svn commit: r1708208 -
/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
Author: tripod
Date: Mon Oct 12 19:14:55 2015
New Revision: 1708208
URL: http://svn.apache.org/viewvc?rev=1708208&view=rev
Log:
JCRVLT-101 Importer.TxInfo : access to root node
Modified:
jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java?rev=1708208&r1=1708207&r2=1708208&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java (original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java Mon Oct 12 19:14:55 2015
@@ -1159,25 +1159,16 @@ public class Importer {
}
public Node getParentNode(Session s) throws RepositoryException {
- Node root = s.getRootNode();
- String parentPath = Text.getRelativeParent(path, 1);
- if (parentPath.length() > 0 && !parentPath.equals("/")) {
- parentPath = parentPath.substring(1);
- if (root.hasNode(parentPath)) {
- root = root.getNode(parentPath);
- } else {
- root = null;
- }
- }
- return root;
+ String parentPath = emptyPathToRoot(Text.getRelativeParent(path, 1));
+ return s.nodeExists(parentPath)
+ ? s.getNode(parentPath)
+ : null;
}
public Node getNode(Session s) throws RepositoryException {
- if (path.length() == 0) {
- return s.getRootNode();
- }
- return s.nodeExists(path)
- ? s.getNode(path)
+ String p = emptyPathToRoot(path);
+ return s.nodeExists(p)
+ ? s.getNode(p)
: null;
}
@@ -1236,6 +1227,10 @@ public class Importer {
return ret;
}
+
+ private static String emptyPathToRoot(String path) {
+ return path == null || path.length() == 0 ? "/" : path;
+ }
}
}
\ No newline at end of file