jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r426582 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ state/
Date Fri, 28 Jul 2006 16:00:00 GMT
Author: mreutegg
Date: Fri Jul 28 09:00:00 2006
New Revision: 426582

URL: http://svn.apache.org/viewvc?rev=426582&view=rev
Log:
SPI:
- remove ItemStateFactory parameter from resolve methods
- add create[Node|Property]State methods to ItemStateFactory which take a parent NodeState
- use PropertyReference in NodeState instead of plain property QNames
- add getNodeState() and getPropertyState() on NodeState for state traversal

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildItemReference.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntry.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeReference.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathElementReference.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyReference.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=426582&r1=426581&r2=426582&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Fri Jul 28 09:00:00 2006
@@ -462,17 +462,57 @@
             throws NoSuchItemStateException, ItemStateException {
         try {
             NodeInfo info = service.getNodeInfo(sessionInfo, nodeId);
-            QName ntName = info.getNodetype();
-            NodeId parentId = (info.getParentId() != null) ? info.getParentId() : null;
 
             // get parent
+            NodeId parentId = (info.getParentId() != null) ? info.getParentId() : null;
             NodeState parent = (parentId != null) ? (NodeState) ism.getItemState(parentId)
: null;
+
+            return createNodeState(info, parent);
+        } catch (PathNotFoundException e) {
+            throw new NoSuchItemStateException(e.getMessage(), e);
+        } catch (RepositoryException e) {
+            throw new ItemStateException(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * Creates the node with information retrieved from the
+     * <code>RepositoryService</code>.
+     *
+     * @inheritDoc
+     * @see ItemStateFactory#createNodeState(NodeId, NodeState)
+     */
+    public NodeState createNodeState(NodeId nodeId, NodeState parent)
+            throws NoSuchItemStateException, ItemStateException {
+        try {
+            NodeInfo info = service.getNodeInfo(sessionInfo, nodeId);
+            return createNodeState(info, parent);
+        } catch (PathNotFoundException e) {
+            throw new NoSuchItemStateException(e.getMessage(), e);
+        } catch (RepositoryException e) {
+            throw new ItemStateException(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * Creates the node with information retrieved from <code>info</code>.
+     *
+     * @param info   the <code>NodeInfo</code> to use to create the
+     *               <code>NodeState</code>.
+     * @param parent the parent <code>NodeState</code>.
+     * @return the new <code>NodeState</code>.
+     */
+    private NodeState createNodeState(NodeInfo info, NodeState parent)
+            throws NoSuchItemStateException, ItemStateException {
+        try {
+            QName ntName = info.getNodetype();
+
             // TODO pass parent in constructor of NodeState
 
             // build the node state
             // NOTE: unable to retrieve definitionId -> needs to be retrieved
             // by the itemManager upon Node creation.
-            NodeState state = new NodeState(info.getId(), ntName, parentId, ItemState.STATUS_EXISTING,
false, getIdFactory());
+            NodeState state = new NodeState(info.getId(), ntName, parent.getNodeId(), ItemState.STATUS_EXISTING,
false, getIdFactory());
             // set mixin nodetypes
             state.setMixinTypeNames(info.getMixins());
 
@@ -513,9 +553,49 @@
             throws NoSuchItemStateException, ItemStateException {
         try {
             PropertyInfo info = service.getPropertyInfo(sessionInfo, propertyId);
-
-            // get parent
             NodeState parent = (NodeState) ism.getItemState(info.getParentId());
+            return createPropertyState(info, parent);
+        } catch (PathNotFoundException e) {
+            throw new NoSuchItemStateException(e.getMessage(), e);
+        } catch (RepositoryException e) {
+            throw new ItemStateException(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * Creates the property with information retrieved from the
+     * <code>RepositoryService</code>.
+     *
+     * @inheritDoc
+     * @see ItemStateFactory#createPropertyState(PropertyId, NodeState)
+     */
+    public PropertyState createPropertyState(PropertyId propertyId,
+                                             NodeState parent)
+            throws NoSuchItemStateException, ItemStateException {
+        try {
+            PropertyInfo info = service.getPropertyInfo(sessionInfo, propertyId);
+            return createPropertyState(info, parent);
+        } catch (PathNotFoundException e) {
+            throw new NoSuchItemStateException(e.getMessage(), e);
+        } catch (RepositoryException e) {
+            throw new ItemStateException(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * Creates the property with information retrieved from <code>info</code>.
+     *
+     * @param info   the <code>PropertyInfo</code> to use to create the
+     *               <code>PropertyState</code>.
+     * @param parent the parent <code>NodeState</code>.
+     * @return the new <code>PropertyState</code>.
+     * @throws ItemStateException if an error occurs while retrieving the
+     *                            <code>PropertyState</code>.
+     */
+    private PropertyState createPropertyState(PropertyInfo info,
+                                              NodeState parent)
+            throws ItemStateException {
+        try {
             // TODO: pass parent in constructor of PropertyState
 
             // build the PropertyState
@@ -545,10 +625,6 @@
             // TODO check if needed
             // state.addListener(this);
             return state;
-        } catch (PathNotFoundException e) {
-            throw new NoSuchItemStateException(e.getMessage(), e);
-        } catch (RepositoryException e) {
-            throw new ItemStateException(e.getMessage(), e);
         } catch (IOException e) {
             throw new ItemStateException(e.getMessage(), e);
         }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildItemReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildItemReference.java?rev=426582&r1=426581&r2=426582&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildItemReference.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildItemReference.java
Fri Jul 28 09:00:00 2006
@@ -44,16 +44,23 @@
     protected final QName name;
 
     /**
+     * The item state factory to create the the item state.
+     */
+    protected final ItemStateFactory isf;
+
+    /**
      * Creates a new <code>ChildItemReference</code> with the given parent
      * <code>NodeState</code>.
      *
      * @param parent the <code>NodeState</code> that owns this child node
      *               reference.
-     * @param name      the name of the child item.
+     * @param name   the name of the child item.
+     * @param isf    the item state factory to create the item state.
      */
-    public ChildItemReference(NodeState parent, QName name) {
+    public ChildItemReference(NodeState parent, QName name, ItemStateFactory isf) {
         this.parent = parent;
         this.name = name;
+        this.isf = isf;
     }
 
     /**
@@ -61,14 +68,12 @@
      * <code>ItemState</code> of this reference.
      *
      * @param isf the item state factory responsible for creating node states.
-     * @param ism the item state manager to access already created / known
-     *            <code>ItemState</code>s.
      * @return the <code>ItemState</code> where this reference points to.
      * @throws NoSuchItemStateException if the referenced <code>ItemState</code>
      *                                  does not exist.
      * @throws ItemStateException       if an error occurs.
      */
-    public ItemState resolve(ItemStateFactory isf, ItemStateManager ism)
+    public ItemState resolve(ItemStateFactory isf)
             throws NoSuchItemStateException, ItemStateException {
         // check if cached
         if (target != null) {
@@ -78,7 +83,7 @@
             }
         }
         // not cached. retrieve and keep weak reference to state
-        ItemState state = doResolve(isf, ism);
+        ItemState state = doResolve();
         target = new WeakReference(state);
         return state;
     }
@@ -97,15 +102,11 @@
      * Resolves this <code>ChildItemReference</code> and returns the target
      * <code>ItemState</code> of this reference.
      *
-     * @param isf the item state factory responsible for creating node states.
-     * @param ism the item state manager to access already created / known
-     *            <code>ItemState</code>s.
      * @return the <code>ItemState</code> where this reference points to.
      * @throws NoSuchItemStateException if the referenced <code>ItemState</code>
      *                                  does not exist.
      * @throws ItemStateException       if an error occurs.
      */
-    protected abstract ItemState doResolve(ItemStateFactory isf,
-                                           ItemStateManager ism)
+    protected abstract ItemState doResolve()
             throws NoSuchItemStateException, ItemStateException;
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntry.java?rev=426582&r1=426581&r2=426582&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntry.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntry.java
Fri Jul 28 09:00:00 2006
@@ -41,16 +41,12 @@
     public int getIndex();
 
     /**
-     * TODO: move parameters isf and ism to constructor of implementations of this interface
-     * @param isf the item state factory to create the node state.
-     * @param ism the item state manager to access already created / known
-     *            <code>ItemState</code>s.
      * @return the referenced <code>NodeState</code>.
      * @throws NoSuchItemStateException if the <code>NodeState</code> does not
      *                                  exist anymore.
      * @throws ItemStateException       if an error occurs while retrieving the
      *                                  <code>NodeState</code>.
      */
-    public NodeState getNodeState(ItemStateFactory isf, ItemStateManager ism)
+    public NodeState getNodeState()
             throws NoSuchItemStateException, ItemStateException;
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeReference.java?rev=426582&r1=426581&r2=426582&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeReference.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeReference.java
Fri Jul 28 09:00:00 2006
@@ -30,10 +30,11 @@
      *
      * @param parent the <code>NodeState</code> that owns this child node
      *               reference.
-     * @param name      the name of the child item.
+     * @param name   the name of the child item.
+     * @param isf    the item state factory to create the item state.
      */
-    public ChildNodeReference(NodeState parent, QName name) {
-        super(parent, name);
+    public ChildNodeReference(NodeState parent, QName name, ItemStateFactory isf) {
+        super(parent, name, isf);
     }
 
     /**
@@ -54,10 +55,10 @@
 
     /**
      * @inheritDoc
-     * @see ChildNodeEntry#getNodeState(ItemStateFactory, ItemStateManager)
+     * @see ChildNodeEntry#getNodeState()
      */
-    public NodeState getNodeState(ItemStateFactory isf, ItemStateManager ism)
+    public NodeState getNodeState()
             throws NoSuchItemStateException, ItemStateException {
-        return (NodeState) resolve(isf, ism);
+        return (NodeState) resolve(isf);
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java?rev=426582&r1=426581&r2=426582&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateFactory.java
Fri Jul 28 09:00:00 2006
@@ -42,12 +42,26 @@
             throws NoSuchItemStateException, ItemStateException;
 
     /**
+     * Creates the child <code>NodeState</code> with the given
+     * <code>nodeId</code>.
+     *
+     * @param nodeId the id of the <code>NodeState</code> to create.
+     * @param parent the parent of the <code>NodeState</code> to create.
+     * @return the created <code>NodeState</code>.
+     * @throws NoSuchItemStateException if there is no such <code>NodeState</code>.
+     * @throws ItemStateException       if an error occurs while retrieving the
+     *                                  <code>NodeState</code>.
+     */
+    public NodeState createNodeState(NodeId nodeId, NodeState parent)
+            throws NoSuchItemStateException, ItemStateException;
+
+    /**
      * Creates the <code>PropertyState</code> with the given
      * <code>propertyId</code>.
      *
      * @param propertyId the id of the <code>PropertyState</code> to create.
      * @param ism        the item state manager to retrievev the parent of the
-     *                   <code>NodeState</code> to create.
+     *                   <code>PropertyState</code> to create.
      * @return the created <code>PropertyState</code>.
      * @throws NoSuchItemStateException if there is no such <code>PropertyState</code>.
      * @throws ItemStateException       if an error occurs while retrieving the
@@ -55,5 +69,20 @@
      */
     public PropertyState createPropertyState(PropertyId propertyId,
                                              ItemStateManager ism)
+            throws NoSuchItemStateException, ItemStateException;
+
+    /**
+     * Creates the <code>PropertyState</code> with the given
+     * <code>propertyId</code>.
+     *
+     * @param propertyId the id of the <code>PropertyState</code> to create.
+     * @param parent the parent of the <code>PropertyState</code> to create.
+     * @return the created <code>PropertyState</code>.
+     * @throws NoSuchItemStateException if there is no such <code>PropertyState</code>.
+     * @throws ItemStateException       if an error occurs while retrieving the
+     *                                  <code>PropertyState</code>.
+     */
+    public PropertyState createPropertyState(PropertyId propertyId,
+                                             NodeState parent)
             throws NoSuchItemStateException, ItemStateException;
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java?rev=426582&r1=426581&r2=426582&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
Fri Jul 28 09:00:00 2006
@@ -85,12 +85,13 @@
     private boolean sharedChildNodeEntries = false;
 
     /**
-     * set of property names (QName objects)
+     * Map of properties. Key = {@link QName} of property. Value = {@link
+     * PropertyReference}.
      */
-    private HashSet propertyNames = new HashSet();
+    private HashMap properties = new HashMap();
 
     /**
-     * Set to <code>true</code> if {@link #propertyNames} is shared between
+     * Set to <code>true</code> if {@link #properties} is shared between
      * different <code>NodeState</code> instances.
      */
     private boolean sharedPropertyNames = false;
@@ -105,6 +106,33 @@
     private final IdFactory idFactory;
 
     /**
+     * The <code>ItemStateFactory</code> which is used to create new
+     * <code>ItemState</code> instances.
+     */
+    private final ItemStateFactory isf;
+
+    /**
+     * Constructs a new node state that is not connected.
+     *
+     * @param id            id of this NodeState
+     * @param parent        the parent of this NodeState
+     * @param nodeTypeName  node type of this node
+     * @param initialStatus the initial status of the node state object
+     * @param isTransient   flag indicating whether this state is transient or
+     *                      not.
+     * @param isf           the item state factory responsible for creating node
+     *                      states.
+     */
+    public NodeState(NodeId id, NodeState parent, QName nodeTypeName,
+                     int initialStatus, boolean isTransient, ItemStateFactory isf) {
+        super(initialStatus, isTransient);
+        this.id = id;
+        this.idFactory = parent.idFactory;
+        this.nodeTypeName = nodeTypeName;
+        this.isf = isf;
+    }
+
+    /**
      * Constructs a new <code>NodeState</code> that is initially connected to
      * an overlayed state.
      *
@@ -117,6 +145,8 @@
         super(overlayedState, initialStatus, isTransient);
         pull();
         idFactory = overlayedState.idFactory;
+        // TODO: remove this constructor
+        this.isf = null;
     }
 
     /**
@@ -135,6 +165,8 @@
         this.parentId = parentId;
         this.nodeTypeName = nodeTypeName;
         this.idFactory = idFactory;
+        // TODO: remove this constructor
+        this.isf = null;
     }
 
     /**
@@ -148,7 +180,7 @@
             nodeTypeName = nodeState.nodeTypeName;
             mixinTypeNames = nodeState.mixinTypeNames;
             def = nodeState.getDefinition();
-            propertyNames = nodeState.propertyNames;
+            properties = nodeState.properties;
             sharedPropertyNames = true;
             nodeState.sharedPropertyNames = true;
             childNodeEntries = nodeState.childNodeEntries;
@@ -322,7 +354,7 @@
      *         <code>QName</code>.
      */
     public synchronized boolean hasPropertyName(QName propName) {
-        return propertyNames.contains(propName);
+        return properties.containsKey(propName);
     }
 
     /**
@@ -517,7 +549,7 @@
      * @see #removePropertyName
      */
     public synchronized Set getPropertyNames() {
-        return Collections.unmodifiableSet(propertyNames);
+        return Collections.unmodifiableSet(properties.keySet());
     }
 
     /**
@@ -527,10 +559,10 @@
      */
     public synchronized void addPropertyName(QName propName) {
         if (sharedPropertyNames) {
-            propertyNames = (HashSet) propertyNames.clone();
+            properties = (HashMap) properties.clone();
             sharedPropertyNames = false;
         }
-        propertyNames.add(propName);
+        properties.put(propName, new PropertyReference(this, propName, isf, idFactory));
     }
 
     /**
@@ -542,10 +574,10 @@
      */
     public synchronized boolean removePropertyName(QName propName) {
         if (sharedPropertyNames) {
-            propertyNames = (HashSet) propertyNames.clone();
+            properties = (HashMap) properties.clone();
             sharedPropertyNames = false;
         }
-        return propertyNames.remove(propName);
+        return properties.remove(propName) != null;
     }
 
     /**
@@ -553,10 +585,10 @@
      */
     public synchronized void removeAllPropertyNames() {
         if (sharedPropertyNames) {
-            propertyNames = new HashSet();
+            properties = new HashMap();
             sharedPropertyNames = false;
         } else {
-            propertyNames.clear();
+            properties.clear();
         }
     }
 
@@ -565,18 +597,9 @@
      * properties of this node.
      */
     public synchronized void setPropertyNames(Set propNames) {
-        if (propNames instanceof HashSet) {
-            HashSet names = (HashSet) propNames;
-            propertyNames = (HashSet) names.clone();
-            sharedPropertyNames = false;
-        } else {
-            if (sharedPropertyNames) {
-                propertyNames = new HashSet();
-                sharedPropertyNames = false;
-            } else {
-                propertyNames.clear();
-            }
-            propertyNames.addAll(propNames);
+        removeAllPropertyNames();
+        for (Iterator it = propNames.iterator(); it.hasNext(); ) {
+            addPropertyName((QName) it.next());
         }
     }
 
@@ -590,7 +613,48 @@
         this.nodeTypeName = nodeTypeName;
     }
 
+    /**
+     * Returns the property state with the given name.
+     *
+     * @param propertyName the name of the property state to return.
+     * @throws NoSuchItemStateException if there is no property state with the
+     *                                  given name.
+     * @throws ItemStateException       if an error occurs while retrieving the
+     *                                  property state.
+     */
+    public synchronized PropertyState getPropertyState(QName propertyName)
+            throws NoSuchItemStateException, ItemStateException {
+        PropertyReference propRef = (PropertyReference) properties.get(propertyName);
+        if (propRef == null) {
+            throw new NoSuchItemStateException(idFactory.createPropertyId(getNodeId(), propertyName).toString());
+        }
+        return (PropertyState) propRef.resolve(isf);
+    }
+
+    /**
+     * Returns the node state with the given relative path.
+     *
+     * @param relPath the relative path (actually PathElement) of the child node
+     *                state.
+     * @return the child node state
+     * @throws NoSuchItemStateException if there is no node state with the given
+     *                                  <code>relPath</code>.
+     * @throws ItemStateException       if an error occurs while retrieving the
+     *                                  node state.
+     */
+    public synchronized NodeState getNodeState(Path.PathElement relPath)
+            throws NoSuchItemStateException, ItemStateException {
+        ChildNodeEntry cne = childNodeEntries.get(relPath.getName(), relPath.getNormalizedIndex());
+        if (cne == null) {
+            Path p = Path.create(relPath.getName(), relPath.getIndex());
+            NodeId id = idFactory.createNodeId(getNodeId(), p);
+            throw new NoSuchItemStateException(id.toString());
+        }
+        return cne.getNodeState();
+    }
+
     //---------------------------------------------------------< diff methods >
+
     /**
      * Returns a set of <code>QName</code>s denoting those properties that
      * do not exist in the overlayed node state but have been added to
@@ -601,12 +665,12 @@
      */
     public synchronized Set getAddedPropertyNames() {
         if (!hasOverlayedState()) {
-            return Collections.unmodifiableSet(propertyNames);
+            return Collections.unmodifiableSet(properties.keySet());
         }
 
         NodeState other = (NodeState) getOverlayedState();
-        HashSet set = new HashSet(propertyNames);
-        set.removeAll(other.propertyNames);
+        HashSet set = new HashSet(properties.keySet());
+        set.removeAll(other.properties.keySet());
         return set;
     }
 
@@ -639,8 +703,8 @@
         }
 
         NodeState other = (NodeState) getOverlayedState();
-        HashSet set = new HashSet(other.propertyNames);
-        set.removeAll(propertyNames);
+        HashSet set = new HashSet(other.properties.keySet());
+        set.removeAll(properties.keySet());
         return set;
     }
 
@@ -1125,9 +1189,9 @@
          */
         private ChildNodeEntry createChildNodeEntry(QName nodeName, NodeId id) {
             if (id.getRelativePath() != null) {
-                return new PathElementReference(NodeState.this, nodeName, NodeState.this.idFactory);
+                return new PathElementReference(NodeState.this, nodeName, NodeState.this.isf,
NodeState.this.idFactory);
             } else {
-                return new UUIDReference(NodeState.this, id, nodeName);
+                return new UUIDReference(NodeState.this, id, NodeState.this.isf, nodeName);
             }
         }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathElementReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathElementReference.java?rev=426582&r1=426581&r2=426582&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathElementReference.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PathElementReference.java
Fri Jul 28 09:00:00 2006
@@ -38,22 +38,24 @@
      * @param parent    the <code>ItemState</code> that owns this child item
      *                  reference.
      * @param name      the name of the child node.
+     * @param isf       the item state factory to create the node state.
      * @param idFactory the <code>IdFactory</code> to create new ItemIds
      */
-    public PathElementReference(NodeState parent, QName name, IdFactory idFactory) {
-        super(parent, name);
+    public PathElementReference(NodeState parent, QName name,
+                                ItemStateFactory isf, IdFactory idFactory) {
+        super(parent, name, isf);
         this.idFactory = idFactory;
     }
 
     /**
      * @inheritDoc
-     * @see ChildItemReference#doResolve(ItemStateFactory, ItemStateManager)
+     * @see ChildItemReference#doResolve()
      * <p/>
      * Returns a <code>NodeState</code>.
      */
-    protected ItemState doResolve(ItemStateFactory isf, ItemStateManager ism)
+    protected ItemState doResolve()
             throws NoSuchItemStateException, ItemStateException {
-        return isf.createNodeState(getId(), ism);
+        return isf.createNodeState(getId(), getParent());
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyReference.java?rev=426582&r1=426581&r2=426582&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyReference.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyReference.java
Fri Jul 28 09:00:00 2006
@@ -33,24 +33,26 @@
     /**
      * Creates a new <code>PropertyReference</code>.
      *
-     * @param parent the parent <code>NodeState</code> where the property
-     *               belongs to.
-     * @param name   the name of the property.
+     * @param parent    the parent <code>NodeState</code> where the property
+     *                  belongs to.
+     * @param name      the name of the property.
+     * @param isf       the item state factory to create the node state.
+     * @param idFactory the id factory to create new ids.
      */
-    public PropertyReference(NodeState parent, QName name, IdFactory idFactory) {
-        super(parent, name);
+    public PropertyReference(NodeState parent, QName name, ItemStateFactory isf, IdFactory
idFactory) {
+        super(parent, name, isf);
         this.idFactory = idFactory;
     }
 
     /**
      * @inheritDoc
-     * @see ChildItemReference#doResolve(ItemStateFactory, ItemStateManager)
+     * @see ChildItemReference#doResolve()
      * <p/>
      * Returns a <code>PropertyState</code>.
      */
-    protected ItemState doResolve(ItemStateFactory isf, ItemStateManager ism)
+    protected ItemState doResolve()
             throws NoSuchItemStateException, ItemStateException {
         PropertyId id = idFactory.createPropertyId(parent.getNodeId(), name);
-        return isf.createPropertyState(id, ism);
+        return isf.createPropertyState(id, getParent());
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java?rev=426582&r1=426581&r2=426582&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/UUIDReference.java
Fri Jul 28 09:00:00 2006
@@ -37,11 +37,13 @@
      *                reference.
      * @param childId the id of the referenced <code>NodeState</code>. This id
      *                must not have a relative path component.
+     * @param name    the name of the child node.
+     * @param isf     the item state factory to create the node state.
      * @throws IllegalArgumentException if <code>childId</code> has a relative
      *                                  path component.
      */
-    public UUIDReference(NodeState parent, NodeId childId, QName name) {
-        super(parent, name);
+    public UUIDReference(NodeState parent, NodeId childId, ItemStateFactory isf, QName name)
{
+        super(parent, name, isf);
         if (childId.getRelativePath() == null) {
             throw new IllegalArgumentException("childId must not contain a relative path");
         }
@@ -50,13 +52,13 @@
 
     /**
      * @inheritDoc
-     * @see ChildItemReference#doResolve(ItemStateFactory, ItemStateManager)
+     * @see ChildItemReference#doResolve()
      * <p/>
      * Returns a <code>NodeState</code>.
      */
-    protected ItemState doResolve(ItemStateFactory isf, ItemStateManager ism)
+    protected ItemState doResolve()
             throws NoSuchItemStateException, ItemStateException {
-        return isf.createNodeState(childId, ism);
+        return isf.createNodeState(childId, getParent());
     }
 
     /**



Mime
View raw message