jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1333630 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: ItemImpl.java NodeImpl.java PropertyImpl.java SessionImpl.java WorkspaceImpl.java
Date Thu, 03 May 2012 21:23:04 GMT
Author: mduerig
Date: Thu May  3 21:23:04 2012
New Revision: 1333630

URL: http://svn.apache.org/viewvc?rev=1333630&view=rev
Log:
OAK-84: Delegates for Session, Node, Property and Item
- clean up: leverage SessionDelegate where possible 

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.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

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java?rev=1333630&r1=1333629&r2=1333630&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
Thu May  3 21:23:04 2012
@@ -134,7 +134,8 @@ abstract class ItemImpl implements Item 
         getSession().refresh(keepChanges);
     }
 
-    //--------------------------------------------------------------------------
+    //------------------------------------------------------------< internal >---
+
     /**
      * Performs a sanity check on this item and the associated session.
      *
@@ -175,6 +176,9 @@ abstract class ItemImpl implements Item 
         return sessionDelegate.getValueFactory();
     }
 
+    String toOakName(String jcrName) {
+        return sessionDelegate.getNamePathMapper().getOakName(jcrName);
+    }
     
     String toOakPath(String jcrPath) throws RepositoryException {
         try {
@@ -185,6 +189,10 @@ abstract class ItemImpl implements Item 
         }
     }
 
+    String toJcrName(String oakName) {
+        return sessionDelegate.getNamePathMapper().getJcrName(oakName);
+    }
+
     String toJcrPath(String oakPath) {
         return sessionDelegate.getNamePathMapper().toJcrPath(oakPath);
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1333630&r1=1333629&r2=1333630&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Thu May  3 21:23:04 2012
@@ -158,7 +158,7 @@ public class NodeImpl extends ItemImpl i
         }
 
         // TODO: figure out the right place for this check
-        NodeTypeManager ntm = sessionDelegate.getSession().getWorkspace().getNodeTypeManager();
+        NodeTypeManager ntm = sessionDelegate.getNodeTypeManager();
         NodeType nt = ntm.getNodeType(primaryNodeTypeName); // throws on not found
         if (nt.isAbstract() || nt.isMixin()) {
             throw new ConstraintViolationException();
@@ -568,7 +568,7 @@ public class NodeImpl extends ItemImpl i
         checkStatus();
 
         // TODO: check if transient changes to mixin-types are reflected here
-        NodeTypeManager ntMgr = getSession().getWorkspace().getNodeTypeManager();
+        NodeTypeManager ntMgr = sessionDelegate.getNodeTypeManager();
         String primaryNtName = getProperty(Property.JCR_PRIMARY_TYPE).getString();
 
         return ntMgr.getNodeType(primaryNtName);
@@ -583,7 +583,7 @@ public class NodeImpl extends ItemImpl i
 
         // TODO: check if transient changes to mixin-types are reflected here
         if (hasProperty(Property.JCR_MIXIN_TYPES)) {
-            NodeTypeManager ntMgr = getSession().getWorkspace().getNodeTypeManager();
+            NodeTypeManager ntMgr = sessionDelegate.getNodeTypeManager();
             Value[] mixinNames = getProperty(Property.JCR_MIXIN_TYPES).getValues();
             NodeType[] mixinTypes = new NodeType[mixinNames.length];
             for (int i = 0; i < mixinNames.length; i++) {
@@ -600,10 +600,10 @@ public class NodeImpl extends ItemImpl i
         checkStatus();
 
         // TODO: might be expanded, need a better way for this
-        String jcrName = sessionDelegate.getNamePathMapper().getJcrName(sessionDelegate.getNamePathMapper().getOakName(nodeTypeName));
+        String jcrName = toJcrName(toOakName(nodeTypeName));
 
         // TODO: figure out the right place for this check
-        NodeTypeManager ntm = sessionDelegate.getSession().getWorkspace().getNodeTypeManager();
+        NodeTypeManager ntm = sessionDelegate.getNodeTypeManager();
         NodeType ntToCheck = ntm.getNodeType(jcrName); // throws on not found
         String nameToCheck = ntToCheck.getName();
 
@@ -949,18 +949,14 @@ public class NodeImpl extends ItemImpl i
     private NodeImpl getNodeOrNull(String relJcrPath)
             throws RepositoryException {
 
-        String relOakPath = toOakPath(relJcrPath);
-
-        NodeDelegate nd = dlg.getNodeOrNull(relOakPath);
+        NodeDelegate nd = dlg.getNodeOrNull(toOakPath(relJcrPath));
         return nd == null ? null : new NodeImpl(nd);
     }
 
     private PropertyImpl getPropertyOrNull(String relJcrPath)
             throws RepositoryException {
 
-        String relOakPath = toOakPath(relJcrPath);
-
-        PropertyDelegate pd = dlg.getPropertyOrNull(relOakPath);
+        PropertyDelegate pd = dlg.getPropertyOrNull(toOakPath(relJcrPath));
         return pd == null ? null : new PropertyImpl(pd);
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1333630&r1=1333629&r2=1333630&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
Thu May  3 21:23:04 2012
@@ -505,6 +505,8 @@ public class PropertyImpl extends ItemIm
         return dlg.getPropertyState().isArray();
     }
 
+    //------------------------------------------------------------< private >---
+
     /**
      * Return the length of the specified JCR value object.
      *
@@ -580,7 +582,7 @@ public class PropertyImpl extends ItemIm
           throw new ValueFormatException("Attempt to set multiple values to single valued
property.");
       }
       if (values == null) {
-          remove();
+          dlg.remove();
       } else {
           Value[] targetValues = ValueHelper.convert(values, requiredType, sessionDelegate.getValueFactory());
           dlg.setValues(ValueConverter.toCoreValues(targetValues, sessionDelegate));

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=1333630&r1=1333629&r2=1333630&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
Thu May  3 21:23:04 2012
@@ -125,7 +125,7 @@ public class SessionImpl extends Abstrac
     @Override
     public void move(String srcAbsPath, String destAbsPath) throws RepositoryException {
         ensureIsAlive();
-        dlg.move(dlg.getNamePathMapper().toOakPath(srcAbsPath), dlg.getNamePathMapper().toOakPath(destAbsPath),
true);
+        dlg.move(toOakPath(srcAbsPath), toOakPath(destAbsPath), true);
     }
 
     //------------------------------------------------------------< state >---
@@ -165,7 +165,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior)
throws RepositoryException {
-        return internalGetImportContentHandler(dlg.getNamePathMapper().toOakPath(parentAbsPath),
uuidBehavior);
+        return internalGetImportContentHandler(toOakPath(parentAbsPath), uuidBehavior);
     }
 
     private ContentHandler internalGetImportContentHandler(String parentAbsPath, int uuidBehavior)
throws RepositoryException {
@@ -215,7 +215,7 @@ public class SessionImpl extends Abstrac
 
     @Override
     public boolean hasPermission(String absPath, String actions) throws RepositoryException
{
-        return internalHasPermission(dlg.getNamePathMapper().toOakPath(absPath), actions);
+        return internalHasPermission(toOakPath(absPath), actions);
     }
 
     private boolean internalHasPermission(String absPath, String actions) throws RepositoryException
{
@@ -285,4 +285,13 @@ public class SessionImpl extends Abstrac
         }
     }
 
+    private String toOakPath(String jcrPath) throws RepositoryException {
+        try {
+            return dlg.getNamePathMapper().toOakPath(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=1333630&r1=1333629&r2=1333630&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
Thu May  3 21:23:04 2012
@@ -51,12 +51,9 @@ public class WorkspaceImpl implements Ja
     private static final Logger log = LoggerFactory.getLogger(WorkspaceImpl.class);
 
     private final SessionDelegate sessionDelegate;
-
-    private QueryManagerImpl queryManager;
-
     private final NamespaceRegistry nsRegistry;
-
     private final NodeTypeManager nodeTypeManager;
+    private final QueryManagerImpl queryManager;
 
     public WorkspaceImpl(SessionDelegate sessionDelegate, NamespaceRegistry nsRegistry)
             throws RepositoryException {
@@ -64,6 +61,7 @@ public class WorkspaceImpl implements Ja
         this.sessionDelegate = sessionDelegate;
         this.nsRegistry = nsRegistry;
         this.nodeTypeManager = new NodeTypeManagerImpl(sessionDelegate.getNamePathMapper());
+        this.queryManager = new QueryManagerImpl(this, sessionDelegate);
     }
 
     //----------------------------------------------------------< Workspace >---
@@ -93,7 +91,7 @@ public class WorkspaceImpl implements Ja
         }
 
         // FIXME: convert to oak paths
-        sessionDelegate.copy(srcAbsPath, destAbsPath);
+        sessionDelegate.copy(toOakPath(srcAbsPath), toOakPath(destAbsPath));
     }
 
     @SuppressWarnings("deprecation")
@@ -111,7 +109,7 @@ public class WorkspaceImpl implements Ja
         ensureSupportedOption(Repository.LEVEL_2_SUPPORTED);
         ensureIsAlive();
 
-        sessionDelegate.move(srcAbsPath, destAbsPath, false);
+        sessionDelegate.move(toOakPath(srcAbsPath), toOakPath(destAbsPath), false);
     }
 
     @Override
@@ -129,9 +127,6 @@ public class WorkspaceImpl implements Ja
     @Override
     public QueryManager getQueryManager() throws RepositoryException {
         ensureIsAlive();
-        if (queryManager == null) {
-            queryManager = new QueryManagerImpl(this, sessionDelegate);
-        }
         return queryManager;
     }
 
@@ -320,5 +315,14 @@ public class WorkspaceImpl implements Ja
         }
     }
 
+    private String toOakPath(String jcrPath) throws RepositoryException {
+        try {
+            return sessionDelegate.getNamePathMapper().toOakPath(jcrPath);
+        } catch (IllegalArgumentException ex) {
+            // TODO we shouldn't have to catch this one
+            throw new RepositoryException(ex);
+        }
+    }
+
 
 }
\ No newline at end of file



Mime
View raw message