jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1456024 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: SessionImpl.java WorkspaceImpl.java delegate/SessionDelegate.java
Date Wed, 13 Mar 2013 16:24:16 GMT
Author: mduerig
Date: Wed Mar 13 16:24:16 2013
New Revision: 1456024

URL: http://svn.apache.org/r1456024
Log:
OAK-672: Avoid JCR APIs calling other JCR APIs
- Clean up SessionDelegate

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java?rev=1456024&r1=1456023&r2=1456024&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
Wed Mar 13 16:24:16 2013
@@ -21,6 +21,7 @@ import java.util.HashSet;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+
 import javax.annotation.Nonnull;
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Credentials;
@@ -89,6 +90,13 @@ public class SessionImpl extends Abstrac
         this.namespaces = namespaces;
     }
 
+    public void checkProtectedNodes(String... absJcrPaths) throws RepositoryException {
+        for (String absPath : absJcrPaths) {
+            NodeImpl<?> node = (NodeImpl<?>) getNode(absPath);
+            node.checkProtected();
+        }
+    }
+
     //------------------------------------------------------------< Session >---
 
     @Override
@@ -281,11 +289,11 @@ public class SessionImpl extends Abstrac
             @Override
             protected void checkPreconditions() throws RepositoryException {
                 ensureIsAlive();
+                checkProtectedNodes(Text.getRelativeParent(srcAbsPath, 1), Text.getRelativeParent(destAbsPath,
1));
             }
 
             @Override
             public Void perform() throws RepositoryException {
-                dlg.checkProtectedNodes(Text.getRelativeParent(srcAbsPath, 1), Text.getRelativeParent(destAbsPath,
1));
                 String oakPath = SessionContextProvider.getOakPathKeepIndexOrThrowNotFound(dlg,
destAbsPath);
                 String oakName = PathUtils.getName(oakPath);
                 // handle index

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java?rev=1456024&r1=1456023&r2=1456024&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
Wed Mar 13 16:24:16 2013
@@ -18,11 +18,11 @@ package org.apache.jackrabbit.oak.jcr;
 
 import java.io.IOException;
 import java.io.InputStream;
+
 import javax.annotation.Nonnull;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.ValueFactory;
 import javax.jcr.lock.LockManager;
@@ -100,7 +100,7 @@ public class WorkspaceImpl implements Ja
     //----------------------------------------------------------< Workspace >---
     @Override
     @Nonnull
-    public Session getSession() {
+    public SessionImpl getSession() {
         return SessionContextProvider.getSession(sessionDelegate);
     }
 
@@ -126,7 +126,7 @@ public class WorkspaceImpl implements Ja
             throw new UnsupportedRepositoryOperationException("Not implemented.");
         }
 
-        sessionDelegate.checkProtectedNodes(Text.getRelativeParent(srcAbsPath, 1), Text.getRelativeParent(destAbsPath,
1));
+        getSession().checkProtectedNodes(Text.getRelativeParent(srcAbsPath, 1), Text.getRelativeParent(destAbsPath,
1));
 
         String oakPath = getOakPathKeepIndexOrThrowNotFound(destAbsPath);
         String oakName = PathUtils.getName(oakPath);
@@ -148,7 +148,7 @@ public class WorkspaceImpl implements Ja
     public void clone(String srcWorkspace, String srcAbsPath, String destAbsPath, boolean
removeExisting) throws RepositoryException {
         ensureIsAlive();
 
-        sessionDelegate.checkProtectedNodes(Text.getRelativeParent(srcAbsPath, 1), Text.getRelativeParent(destAbsPath,
1));
+        getSession().checkProtectedNodes(Text.getRelativeParent(srcAbsPath, 1), Text.getRelativeParent(destAbsPath,
1));
 
         // TODO
         throw new UnsupportedRepositoryOperationException("Not implemented.");
@@ -158,7 +158,7 @@ public class WorkspaceImpl implements Ja
     public void move(String srcAbsPath, String destAbsPath) throws RepositoryException {
         ensureIsAlive();
 
-        sessionDelegate.checkProtectedNodes(Text.getRelativeParent(srcAbsPath, 1), Text.getRelativeParent(destAbsPath,
1));
+        getSession().checkProtectedNodes(Text.getRelativeParent(srcAbsPath, 1), Text.getRelativeParent(destAbsPath,
1));
 
         String oakPath = getOakPathKeepIndexOrThrowNotFound(destAbsPath);
         String oakName = PathUtils.getName(oakPath);

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java?rev=1456024&r1=1456023&r2=1456024&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
Wed Mar 13 16:24:16 2013
@@ -23,7 +23,6 @@ import javax.annotation.Nonnull;
 import javax.jcr.ItemExistsException;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 
 import org.apache.jackrabbit.oak.api.AuthInfo;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
@@ -34,8 +33,6 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.api.TreeLocation;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.core.IdentifierManager;
-import org.apache.jackrabbit.oak.jcr.NodeImpl;
-import org.apache.jackrabbit.oak.jcr.SessionContextProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -358,12 +355,4 @@ public class SessionDelegate {
     private Tree getTree(String path) {
         return root.getTree(path);
     }
-
-    public void checkProtectedNodes(String... absJcrPaths) throws RepositoryException {
-        Session session = SessionContextProvider.getSession(this);
-        for (String absPath : absJcrPaths) {
-            NodeImpl<?> node = (NodeImpl<?>) session.getNode(absPath);
-            node.checkProtected();
-        }
-    }
 }



Mime
View raw message