jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1333807 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: SessionDelegate.java SessionImpl.java WorkspaceImpl.java security/user/UserManagerImpl.java
Date Fri, 04 May 2012 08:24:08 GMT
Author: angela
Date: Fri May  4 08:24:07 2012
New Revision: 1333807

URL: http://svn.apache.org/viewvc?rev=1333807&view=rev
Log:
OAK-61 : Implement JCR path handling

- use consistent method names
- remove duplicate code

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
    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/security/user/UserManagerImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java?rev=1333807&r1=1333806&r2=1333807&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
Fri May  4 08:24:07 2012
@@ -57,7 +57,7 @@ public class SessionDelegate {
     private boolean isAlive = true;
     private Root root;
 
-    public SessionDelegate(GlobalContext context, ContentSession contentSession)
+    SessionDelegate(GlobalContext context, ContentSession contentSession)
             throws RepositoryException {
 
         this.context = context;
@@ -117,6 +117,22 @@ public class SessionDelegate {
         return namePathMapper;
     }
 
+    /**
+     * Shortcut for {@code SessionDelegate.getNamePathMapper().getOakPath(jcrPath)}.
+     *
+     * @param jcrPath
+     * @return
+     * @throws RepositoryException
+     */
+    public String getOakPath(String jcrPath) throws RepositoryException {
+        try {
+            return getNamePathMapper().getOakPath(jcrPath);
+        } catch (IllegalArgumentException ex) {
+            // TODO we shouldn't have to catch this one
+            throw new RepositoryException(ex);
+        }
+    }
+
     public NodeTypeManager getNodeTypeManager() throws RepositoryException {
         return workspace.getNodeTypeManager();
     }

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=1333807&r1=1333806&r2=1333807&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
Fri May  4 08:24:07 2012
@@ -79,12 +79,11 @@ public class SessionImpl extends Abstrac
         return dlg.getWorkspace();
     }
 
-    /**
-     * @see javax.jcr.Session#impersonate(Credentials)
-     */
     @Override
     public Session impersonate(Credentials credentials) throws RepositoryException {
         ensureIsAlive();
+
+        // TODO
         throw new UnsupportedRepositoryOperationException("TODO: Session.impersonate");
     }
 
@@ -94,8 +93,6 @@ public class SessionImpl extends Abstrac
         return dlg.getValueFactory();
     }
 
-    //------------------------------------------------------------< Reading >---
-
     @Override
     public Node getRootNode() throws RepositoryException {
         ensureIsAlive();
@@ -120,16 +117,12 @@ public class SessionImpl extends Abstrac
         }
     }
 
-    //------------------------------------------------------------< Writing >---
-
     @Override
     public void move(String srcAbsPath, String destAbsPath) throws RepositoryException {
         ensureIsAlive();
-        dlg.move(toOakPath(srcAbsPath), toOakPath(destAbsPath), true);
+        dlg.move(dlg.getOakPath(srcAbsPath), dlg.getOakPath(destAbsPath), true);
     }
 
-    //------------------------------------------------------------< state >---
-
     @Override
     public void save() throws RepositoryException {
         ensureIsAlive();
@@ -148,8 +141,6 @@ public class SessionImpl extends Abstrac
         return dlg.hasPendingChanges();
     }
 
-    //----------------------------------------------------------< Lifecycle >---
-
     @Override
     public boolean isLive() {
         return dlg.isAlive();
@@ -161,20 +152,15 @@ public class SessionImpl extends Abstrac
         dlg.logout();
     }
 
-    //----------------------------------------------------< Import / Export >---
-
     @Override
     public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior)
throws RepositoryException {
-        return internalGetImportContentHandler(toOakPath(parentAbsPath), uuidBehavior);
-    }
-
-    private ContentHandler internalGetImportContentHandler(String parentAbsPath, int uuidBehavior)
throws RepositoryException {
         ensureIsAlive();
+
+        // TODO
+        String internalPath = dlg.getOakPath(parentAbsPath);
         throw new UnsupportedRepositoryOperationException("TODO: Session.getImportContentHandler");
     }
 
-    //------------------------------------------------------------< Locking >---
-
     /**
      * @see javax.jcr.Session#addLockToken(String)
      */
@@ -211,15 +197,10 @@ public class SessionImpl extends Abstrac
         }
     }
 
-    //------------------------------------------------------< AccessControl >---
-
     @Override
     public boolean hasPermission(String absPath, String actions) throws RepositoryException
{
-        return internalHasPermission(toOakPath(absPath), actions);
-    }
-
-    private boolean internalHasPermission(String absPath, String actions) throws RepositoryException
{
         ensureIsAlive();
+        String internalPath = dlg.getOakPath(absPath);
 
         // TODO
         return false;
@@ -249,8 +230,9 @@ public class SessionImpl extends Abstrac
         throw new UnsupportedRepositoryOperationException("TODO: Session.getAccessControlManager");
     }
 
-    //----------------------------------------------------------< Retention >---
-
+    /**
+     * @see javax.jcr.Session#getRetentionManager()
+     */
     @Override
     public RetentionManager getRetentionManager() throws RepositoryException {
         throw new UnsupportedRepositoryOperationException("Retention Management is not supported.");
@@ -284,14 +266,4 @@ public class SessionImpl extends Abstrac
             throw new RepositoryException("This session has been closed.");
         }
     }
-
-    private String toOakPath(String jcrPath) throws RepositoryException {
-        try {
-            return dlg.getNamePathMapper().getOakPath(jcrPath);
-        } catch (IllegalArgumentException ex) {
-            // TODO we shouldn't have to catch this one
-            throw new RepositoryException(ex);
-        }
-    }
-
 }
\ No newline at end of file

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=1333807&r1=1333806&r2=1333807&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
Fri May  4 08:24:07 2012
@@ -91,7 +91,7 @@ public class WorkspaceImpl implements Ja
         }
 
         // FIXME: convert to oak paths
-        sessionDelegate.copy(toOakPath(srcAbsPath), toOakPath(destAbsPath));
+        sessionDelegate.copy(sessionDelegate.getOakPath(srcAbsPath), sessionDelegate.getOakPath(destAbsPath));
     }
 
     @SuppressWarnings("deprecation")
@@ -109,7 +109,7 @@ public class WorkspaceImpl implements Ja
         ensureSupportedOption(Repository.LEVEL_2_SUPPORTED);
         ensureIsAlive();
 
-        sessionDelegate.move(toOakPath(srcAbsPath), toOakPath(destAbsPath), false);
+        sessionDelegate.move(sessionDelegate.getOakPath(srcAbsPath), sessionDelegate.getOakPath(destAbsPath),
false);
     }
 
     @Override
@@ -142,8 +142,10 @@ public class WorkspaceImpl implements Ja
 
     @Override
     public ObservationManager getObservationManager() throws RepositoryException {
-        ensureSupportedOption(Repository.OPTION_OBSERVATION_SUPPORTED);
         ensureIsAlive();
+        ensureSupportedOption(Repository.OPTION_OBSERVATION_SUPPORTED);
+
+        // TODO
         throw new UnsupportedRepositoryOperationException("TODO: Workspace.getObservationManager");
     }
 
@@ -151,6 +153,8 @@ public class WorkspaceImpl implements Ja
     public VersionManager getVersionManager() throws RepositoryException {
         ensureIsAlive();
         ensureSupportedOption(Repository.OPTION_VERSIONING_SUPPORTED);
+
+        // TODO
         throw new UnsupportedRepositoryOperationException("TODO: Workspace.getVersionManager");
     }
 
@@ -165,16 +169,18 @@ public class WorkspaceImpl implements Ja
     @SuppressWarnings("deprecation")
     @Override
     public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior)
throws RepositoryException {
-        ensureSupportedOption(Repository.LEVEL_2_SUPPORTED);
         ensureIsAlive();
+        ensureSupportedOption(Repository.LEVEL_2_SUPPORTED);
+
+        // TODO
         throw new UnsupportedRepositoryOperationException("TODO: Workspace.getImportContentHandler");
     }
 
     @SuppressWarnings("deprecation")
     @Override
     public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws
IOException, RepositoryException {
-        ensureSupportedOption(Repository.LEVEL_2_SUPPORTED);
         ensureIsAlive();
+        ensureSupportedOption(Repository.LEVEL_2_SUPPORTED);
 
         // TODO -> SPI
     }
@@ -221,7 +227,6 @@ public class WorkspaceImpl implements Ja
         return new PrivilegeManagerImpl(sessionDelegate);
     }
 
-
     //------------------------------------------------------------< private >---
 
     private void ensureIsAlive() throws RepositoryException {
@@ -314,15 +319,4 @@ public class WorkspaceImpl implements Ja
             throw new UnsupportedRepositoryOperationException(option + " is not supported
by this repository.");
         }
     }
-
-    private String toOakPath(String jcrPath) throws RepositoryException {
-        try {
-            return sessionDelegate.getNamePathMapper().getOakPath(jcrPath);
-        } catch (IllegalArgumentException ex) {
-            // TODO we shouldn't have to catch this one
-            throw new RepositoryException(ex);
-        }
-    }
-
-
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java?rev=1333807&r1=1333806&r2=1333807&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java
Fri May  4 08:24:07 2012
@@ -377,6 +377,6 @@ public class UserManagerImpl implements 
     }
 
     private String getInternalPath(Node node) throws RepositoryException {
-        return sessionDelegate.getNamePathMapper().getOakPath(node.getPath());
+        return sessionDelegate.getOakPath(node.getPath());
     }
 }
\ No newline at end of file



Mime
View raw message