You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by md...@apache.org on 2011/07/19 19:48:27 UTC

svn commit: r1148460 - /jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java

Author: mduerig
Date: Tue Jul 19 17:48:27 2011
New Revision: 1148460

URL: http://svn.apache.org/viewvc?rev=1148460&view=rev
Log:
spi2microkernel (WIP)
- error handling

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1148460&r1=1148459&r2=1148460&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java (original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java Tue Jul 19 17:48:27 2011
@@ -221,7 +221,7 @@ public class RepositoryServiceImpl exten
     public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException {
         try {
             String wspName = sessionInfo.getWorkspaceName();
-            Path path = nodeId.getPath();
+            Path path = getPath(nodeId);
             String mkPath = Paths.pathToString(wspName, path);
             String rev = sessionState(sessionInfo).getHeadRevision();
 
@@ -241,7 +241,7 @@ public class RepositoryServiceImpl exten
     public NodeInfo getNodeInfo(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException {
         try {
             String wspName = sessionInfo.getWorkspaceName();
-            Path path = nodeId.getPath();
+            Path path = getPath(nodeId);
             String mkPath = Paths.pathToString(wspName, path);
             String rev = sessionState(sessionInfo).getHeadRevision();
 
@@ -401,6 +401,15 @@ public class RepositoryServiceImpl exten
 
     //------------------------------------------< private >---
 
+    private static Path getPath(NodeId nodeId) {
+        Path path = nodeId.getPath();
+        if (path == null) {
+            throw new IllegalArgumentException("Non path based id: " + nodeId);
+        }
+        
+        return path;
+    }
+
     private static SubscriptionImpl subscription(Subscription subscription) throws RepositoryException {
         if (subscription instanceof SubscriptionImpl) {
             return (SubscriptionImpl) subscription;
@@ -535,7 +544,7 @@ public class RepositoryServiceImpl exten
         public void remove(ItemId itemId) throws RepositoryException {
             if (itemId.denotesNode()) {
                 NodeId nodeId = (NodeId) itemId;
-                if (nodeId.getPath().denotesRoot()) {
+                if (getPath(nodeId).denotesRoot()) {
                     throw new RepositoryException("Cannot remove root node");
                 }
 
@@ -565,7 +574,7 @@ public class RepositoryServiceImpl exten
 
             if (contains(mixinNodeTypeNames, MIX_REFERENCEABLE)) {
                 // todo uuid is not stable across move operations
-                setProperty(nodeId, JCR_UUID, Values.pathToString(nodeId.getPath()));
+                setProperty(nodeId, JCR_UUID, Values.pathToString(getPath(nodeId)));
             }
         }
 
@@ -589,11 +598,11 @@ public class RepositoryServiceImpl exten
 
         private String target(NodeId nodeId) throws RepositoryException {
             return '\"' + JsonBuilder.escape(
-                PathUtils.relativize("/", Paths.pathToString(sessionInfo.getWorkspaceName(), nodeId.getPath()))) + '\"';
+                PathUtils.relativize("/", Paths.pathToString(sessionInfo.getWorkspaceName(), getPath(nodeId)))) + '\"';
         }
 
         private String target(NodeId parentId, Name itemName) throws RepositoryException {
-            String path = Paths.pathToString(sessionInfo.getWorkspaceName(), parentId.getPath());
+            String path = Paths.pathToString(sessionInfo.getWorkspaceName(), getPath(parentId));
             String name = Paths.nameToString(itemName);
             return '\"' + JsonBuilder.escape(PathUtils.concat(PathUtils.relativize("/", path), name)) + '\"';
         }