jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r605155 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ state/
Date Tue, 18 Dec 2007 09:40:20 GMT
Author: jukka
Date: Tue Dec 18 01:40:17 2007
New Revision: 605155

URL: http://svn.apache.org/viewvc?rev=605155&view=rev
Log:
JCR-1244: No need for NodeReferences in jcr2spi
    - Applied the proposed patch

Removed:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/EmptyNodeReferences.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeReferences.java
Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=605155&r1=605154&r2=605155&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
Tue Dec 18 01:40:17 2007
@@ -26,7 +26,6 @@
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
-import org.apache.jackrabbit.jcr2spi.state.NodeReferences;
 import org.apache.jackrabbit.jcr2spi.state.Status;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeManagerImpl;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType;
@@ -536,13 +535,8 @@
      */
     public PropertyIterator getReferences() throws RepositoryException {
         checkStatus();
-        NodeReferences refs = getNodeState().getNodeReferences();
-        if (refs.isEmpty()) {
-            // there are no references, return empty iterator
-            return PropertyIteratorAdapter.EMPTY;
-        } else {
-            return new LazyItemIterator(itemMgr, session.getHierarchyManager(), refs.iterator());
-        }
+        List refs = Arrays.asList(getNodeState().getNodeReferences());
+        return new LazyItemIterator(itemMgr, session.getHierarchyManager(), refs.iterator());
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java?rev=605155&r1=605154&r2=605155&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java
Tue Dec 18 01:40:17 2007
@@ -109,12 +109,13 @@
     public Iterator getChildNodeInfos(NodeId nodeId) throws ItemNotFoundException, RepositoryException;
 
     /**
-     * Returns the NodeReferences for the given NodeState.
+     * Returns the identifiers of all reference properties that  point to
+     * the given node.
      *
-     * @param nodeState
-     * @return NodeReferences
+     * @param nodeState reference target
+     * @return reference property identifiers
      */
-    public NodeReferences getNodeReferences(NodeState nodeState);
+    public PropertyId[] getNodeReferences(NodeState nodeState);
 
     /**
      * Adds the given <code>ItemStateCreationListener</code>.

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java?rev=605155&r1=605154&r2=605155&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
Tue Dec 18 01:40:17 2007
@@ -24,6 +24,7 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.NodeInfo;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
@@ -399,12 +400,12 @@
     }
 
     /**
-     * Return the <code>NodeReferences</code> present on this state or
-     * <code>null</code>.
+     * Returns the identifiers of all reference properties that point to
+     * this node.
      *
-     * @return references
+     * @return reference property identifiers
      */
-    public NodeReferences getNodeReferences() {
+    public PropertyId[] getNodeReferences() {
         return isf.getNodeReferences(this);
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java?rev=605155&r1=605154&r2=605155&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientISFactory.java
Tue Dec 18 01:40:17 2007
@@ -29,6 +29,7 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.ItemNotFoundException;
+
 import java.util.Iterator;
 
 /**
@@ -141,9 +142,9 @@
      * @inheritDoc
      * @see ItemStateFactory#getNodeReferences(NodeState)
      */
-    public NodeReferences getNodeReferences(NodeState nodeState) {
+    public PropertyId[] getNodeReferences(NodeState nodeState) {
         if (nodeState.getStatus() == Status.NEW) {
-            return EmptyNodeReferences.getInstance();
+            return new PropertyId[0];
         }
         return workspaceStateFactory.getNodeReferences(nodeState);
     }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?rev=605155&r1=605154&r2=605155&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
Tue Dec 18 01:40:17 2007
@@ -37,10 +37,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
-import java.util.HashSet;
-import java.util.Set;
 import java.util.Collections;
-import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ArrayList;
@@ -160,25 +157,24 @@
      * @see ItemStateFactory#getNodeReferences(NodeState)
      * @param nodeState
      */
-    public NodeReferences getNodeReferences(NodeState nodeState) {
+    public PropertyId[] getNodeReferences(NodeState nodeState) {
         NodeEntry entry = nodeState.getNodeEntry();
         // shortcut
-        if (entry.getUniqueID() == null || !entry.hasPropertyEntry(NameConstants.JCR_UUID))
{
+        if (entry.getUniqueID() == null
+                || !entry.hasPropertyEntry(NameConstants.JCR_UUID)) {
             // for sure not referenceable
-            return EmptyNodeReferences.getInstance();
+            return new PropertyId[0];
         }
 
         // nodestate has a unique ID and is potentially mix:referenceable
         // => try to retrieve references
         try {
             NodeInfo nInfo = service.getNodeInfo(sessionInfo, entry.getWorkspaceId());
-            return new NodeReferencesImpl(nInfo.getReferences());
+            return nInfo.getReferences();
         } catch (RepositoryException e) {
-            // ignore
+            log.debug("Unable to determine references to {}", nodeState);
+            return new PropertyId[0];
         }
-        // exception or no matching entry found.
-        log.debug("Unable to determine references for NodeState " + nodeState);
-        return EmptyNodeReferences.getInstance();
     }
 
     //------------------------------------------------------------< private >---
@@ -425,43 +421,4 @@
         return parent;
     }
 
-    //-----------------------------------------------------< NodeReferences >---
-    /**
-     * <code>NodeReferences</code> represents the references (i.e. properties
of
-     * type <code>REFERENCE</code>) to a particular node (denoted by its unique
ID).
-     */
-    private class NodeReferencesImpl implements NodeReferences {
-
-        private PropertyId[] references;
-
-        /**
-         * Private constructor
-         *
-         * @param references
-         */
-        private NodeReferencesImpl(PropertyId[] references) {
-            this.references = references;
-        }
-
-        //-------------------------------------------------< NodeReferences >---
-        /**
-         * @see NodeReferences#isEmpty()
-         */
-        public boolean isEmpty() {
-            return references.length <= 0;
-        }
-
-        /**
-         * @see NodeReferences#iterator()
-         */
-        public Iterator iterator() {
-            if (references.length > 0) {
-                Set referenceIds = new HashSet();
-                referenceIds.addAll(Arrays.asList(references));
-                return Collections.unmodifiableSet(referenceIds).iterator();
-            } else {
-                return Collections.EMPTY_SET.iterator();
-            }
-        }
-    }
 }



Mime
View raw message