You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2008/10/20 23:21:41 UTC

svn commit: r706415 - in /jackrabbit/branches/1.5: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/

Author: jukka
Date: Mon Oct 20 14:21:41 2008
New Revision: 706415

URL: http://svn.apache.org/viewvc?rev=706415&view=rev
Log:
1.5: Merged revisions 705579 and 705925 (JCR-1729 and JCR-1612). Ignored revisions 705932 and 705937.

Added:
    jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java
      - copied unchanged from r705579, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java
      - copied unchanged from r705925, jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java
Modified:
    jackrabbit/branches/1.5/   (props changed)
    jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java

Propchange: jackrabbit/branches/1.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Oct 20 14:21:41 2008
@@ -1,2 +1,2 @@
 /jackrabbit/branches/1.3:631261
-/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522
+/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705937

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=706415&r1=706414&r2=706415&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java Mon Oct 20 14:21:41 2008
@@ -3855,14 +3855,21 @@
          * but also verify that node.isNodeType("mix:versionable")==true;
          * this would have a negative impact on performance though...
          */
-        NodeImpl node = this;
-        while (!node.hasProperty(NameConstants.JCR_ISCHECKEDOUT)) {
-            if (node.getDepth() == 0) {
-                return true;
+        try {
+            NodeState state = (NodeState) getItemState();
+            while (!state.hasPropertyName(NameConstants.JCR_ISCHECKEDOUT)) {
+                ItemId parentId = state.getParentId();
+                if (parentId == null) {
+                    // root reached or out of hierarchy
+                    return true;
+                }
+                state = (NodeState) session.getItemStateManager().getItemState(parentId);
             }
-            node = (NodeImpl) node.getParent();
+            PropertyState ps = (PropertyState) session.getItemStateManager().getItemState(new PropertyId(state.getNodeId(), NameConstants.JCR_ISCHECKEDOUT));
+            return ps.getValues()[0].getBoolean();
+        } catch (ItemStateException e) {
+            throw new RepositoryException(e.getMessage());
         }
-        return node.getProperty(NameConstants.JCR_ISCHECKEDOUT).getBoolean();
     }
 
     /**

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java?rev=706415&r1=706414&r2=706415&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java Mon Oct 20 14:21:41 2008
@@ -37,6 +37,7 @@
         suite.addTestSuite(TransientRepositoryTest.class);
         suite.addTestSuite(XATest.class);
         suite.addTestSuite(RestoreAndCheckoutTest.class);
+        suite.addTestSuite(NodeImplTest.class);
 
         return suite;
     }

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java?rev=706415&r1=706414&r2=706415&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java Mon Oct 20 14:21:41 2008
@@ -18,37 +18,31 @@
 
 import java.util.Collection;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import javax.jcr.NamespaceRegistry;
+import javax.jcr.NamespaceException;
+import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.RepositoryException;
 
-import org.apache.jackrabbit.spi.RepositoryService;
-import org.apache.jackrabbit.spi.SessionInfo;
-
 /**
  * <code>NamespaceRegistryImpl</code> implements the JCR client facing
  * NamespaceRegistry.
  */
 public class NamespaceRegistryImpl implements NamespaceRegistry {
 
-    /**
-     * Repository service.
-     */
-    private final RepositoryService service;
+    private static Logger log = LoggerFactory.getLogger(NamespaceRegistryImpl.class);
 
-    /**
-     * Session info.
-     */
-    private final SessionInfo info;
+    private final NamespaceStorage storage;
 
     /**
      * Create a new <code>NamespaceRegistryImpl</code>.
      *
-     * @param service repository service
-     * @param info session info
+     * @param storage
      */
-    public NamespaceRegistryImpl(RepositoryService service, SessionInfo info) {
-        this.service = service;
-        this.info = info;
+    public NamespaceRegistryImpl(NamespaceStorage storage) {
+        this.storage = storage;
     }
 
     //--------------------------------------------------< NamespaceRegistry >---
@@ -56,23 +50,22 @@
     /**
      * @see NamespaceRegistry#registerNamespace(String, String)
      */
-    public void registerNamespace(String prefix, String uri)
-            throws RepositoryException {
-        service.registerNamespace(info, prefix, uri);
+    public void registerNamespace(String prefix, String uri) throws NamespaceException, UnsupportedRepositoryOperationException, RepositoryException {
+        storage.registerNamespace(prefix, uri);
     }
 
     /**
      * @see NamespaceRegistry#unregisterNamespace(String)
      */
-    public void unregisterNamespace(String prefix) throws RepositoryException {
-        service.unregisterNamespace(info, getURI(prefix));
+    public void unregisterNamespace(String prefix) throws NamespaceException, UnsupportedRepositoryOperationException, RepositoryException {
+        storage.unregisterNamespace(prefix);
     }
 
     /**
      * @see javax.jcr.NamespaceRegistry#getPrefixes()
      */
     public String[] getPrefixes() throws RepositoryException {
-        Collection prefixes = service.getRegisteredNamespaces(info).keySet();
+        Collection prefixes = storage.getRegisteredNamespaces().keySet();
         return (String[]) prefixes.toArray(new String[prefixes.size()]);
     }
 
@@ -80,22 +73,36 @@
      * @see javax.jcr.NamespaceRegistry#getURIs()
      */
     public String[] getURIs() throws RepositoryException {
-        Collection uris = service.getRegisteredNamespaces(info).values();
+        Collection uris = storage.getRegisteredNamespaces().values();
         return (String[]) uris.toArray(new String[uris.size()]);
     }
 
     /**
      * @see javax.jcr.NamespaceRegistry#getURI(String)
+     * @see org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver#getURI(String)
      */
-    public String getURI(String prefix) throws RepositoryException {
-        return service.getNamespaceURI(info, prefix);
+    public String getURI(String prefix) throws NamespaceException {
+        // try to load the uri
+        try {
+            return storage.getURI(prefix);
+        } catch (RepositoryException ex) {
+            log.debug("Internal error while loading registered namespaces.");
+            throw new NamespaceException(prefix + ": is not a registered namespace prefix.");
+        }
     }
 
     /**
      * @see javax.jcr.NamespaceRegistry#getPrefix(String)
+     * @see org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver#getPrefix(String)
      */
-    public String getPrefix(String uri) throws RepositoryException {
-        return service.getNamespacePrefix(info, uri);
+    public String getPrefix(String uri) throws NamespaceException {
+        // try to load the prefix
+        try {
+            return storage.getPrefix(uri);
+        } catch (RepositoryException ex) {
+            log.debug("Internal error while loading registered namespaces.");
+            throw new NamespaceException(uri + ": is not a registered namespace uri.");
+        }
     }
 
 }

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=706415&r1=706414&r2=706415&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java Mon Oct 20 14:21:41 2008
@@ -90,6 +90,7 @@
 import javax.jcr.AccessDeniedException;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.ItemNotFoundException;
+import javax.jcr.NamespaceException;
 import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.ItemExistsException;
 import javax.jcr.InvalidItemStateException;
@@ -116,7 +117,8 @@
 /**
  * <code>WorkspaceManager</code>...
  */
-public class WorkspaceManager implements UpdatableItemStateManager, AccessManager {
+public class WorkspaceManager
+        implements UpdatableItemStateManager, NamespaceStorage, AccessManager {
 
     private static Logger log = LoggerFactory.getLogger(WorkspaceManager.class);
 
@@ -169,7 +171,7 @@
         this.pathFactory = service.getPathFactory();
 
         idFactory = service.getIdFactory();
-        nsRegistry = new NamespaceRegistryImpl(service, sessionInfo);
+        nsRegistry = new NamespaceRegistryImpl(this);
         ntRegistry = createNodeTypeRegistry(nsRegistry);
         changeFeed = createChangeFeed(pollTimeout, enableObservation);
         definitionProvider = createDefinitionProvider(getEffectiveNodeTypeProvider());
@@ -620,6 +622,40 @@
         return false;
     }
 
+    //---------------------------------------------------< NamespaceStorage >---
+
+    public Map getRegisteredNamespaces() throws RepositoryException {
+        return service.getRegisteredNamespaces(sessionInfo);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String getPrefix(String uri) throws NamespaceException, RepositoryException {
+        return service.getNamespacePrefix(sessionInfo, uri);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String getURI(String prefix) throws NamespaceException, RepositoryException {
+        return service.getNamespaceURI(sessionInfo, prefix);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void registerNamespace(String prefix, String uri) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
+        service.registerNamespace(sessionInfo, prefix, uri);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void unregisterNamespace(String uri) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
+        service.unregisterNamespace(sessionInfo, uri);
+    }
+
     //--------------------------------------------------------------------------
     /**
      * Called when local or external events occured. This method is called after