jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r156188 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: ./ state/ version/ version/persistence/ virtual/
Date Fri, 04 Mar 2005 17:40:20 GMT
Author: tripod
Date: Fri Mar  4 09:40:12 2005
New Revision: 156188

URL: http://svn.apache.org/viewcvs?view=rev&rev=156188
Log:
JCR-45 fixes:
- fixing references into version storage
- fixing inter-version storage references

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/LazyItemIterator.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java?view=diff&r1=156187&r2=156188
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java Fri Mar 
4 09:40:12 2005
@@ -1197,11 +1197,12 @@
 
                     // initialize version histories for new nodes (might generate new transient
state)
                     if (initVersionHistories(dirty.iterator())) {
-                        /**
-                         * re-build the list of transient states because the previous call
-                         * generated new transient state
-                         */
+                        // re-build the list of transient states because the previous call
+                        // generated new transient state
                         dirty = getTransientStates();
+
+                        // and aswell the references
+                        dirtyRefs= checkReferences(dirty.iterator(), removed.iterator());
                     }
 
                     // process 'new' or 'modified' transient states

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/LazyItemIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/LazyItemIterator.java?view=diff&r1=156187&r2=156188
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/LazyItemIterator.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/LazyItemIterator.java Fri
Mar  4 09:40:12 2005
@@ -17,19 +17,31 @@
 package org.apache.jackrabbit.core;
 
 import javax.jcr.*;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.NoSuchElementException;
+import java.util.ArrayList;
+import java.util.Iterator;
 
 /**
  * <code>LazyItemIterator</code> is an id-based iterator that instantiates
  * the <code>Item</code>s only when they are requested.
  */
-public class LazyItemIterator implements NodeIterator, PropertyIterator {
+class LazyItemIterator implements NodeIterator, PropertyIterator {
 
+    /**
+     * the item manager that is used to fetch the items
+     */
     private final ItemManager itemMgr;
+
+    /**
+     * the list of item ids
+     */
     private final List idList;
-    private int pos;
+
+    /**
+     * the position of the next item
+     */
+    private int pos = 0;
 
     /**
      * Creates a new <code>LazyItemIterator</code> instance.
@@ -37,65 +49,104 @@
      * @param itemMgr item manager
      * @param idList  list of item id's
      */
-    LazyItemIterator(ItemManager itemMgr, List idList) {
+    public LazyItemIterator(ItemManager itemMgr, List idList) {
+        this(itemMgr, idList, false);
+    }
+
+    /**
+     * Creates a new <code>LazyItemIterator</code> instance.
+     *
+     * @param itemMgr item manager
+     * @param idList  list of item id's
+     */
+    public LazyItemIterator(ItemManager itemMgr, List idList, boolean skipInexistent) {
         this.itemMgr = itemMgr;
-        this.idList = new ArrayList(idList);
-        pos = -1;
+        if (skipInexistent) {
+            // check all items first
+            this.idList = new ArrayList();
+            Iterator iter = idList.iterator();
+            while (iter.hasNext()) {
+                ItemId id = (ItemId) iter.next();
+                if (itemMgr.itemExists(id)) {
+                    this.idList.add(id);
+                }
+            }
+        } else {
+            this.idList = idList;
+        }
     }
 
-    //---------------------------------------------------------< NodeIterator >
+    //-------------------------------------------------------< NodeIterator >---
+    /**
+     * {@inheritDoc}
+     */
     public Node nextNode() {
         return (Node) next();
     }
 
-    //-----------------------------------------------------< PropertyIterator >
+    //---------------------------------------------------< PropertyIterator >---
+    /**
+     * {@inheritDoc}
+     */
     public Property nextProperty() {
         return (Property) next();
     }
 
-    //--------------------------------------------------------< RangeIterator >
+    //------------------------------------------------------< RangeIterator >---
+    /**
+     * {@inheritDoc}
+     */
     public long getPos() {
-        return pos + 1;
+        return pos;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public long getSize() {
         return idList.size();
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public void skip(long skipNum) {
         if (skipNum < 0) {
             throw new IllegalArgumentException("skipNum must be a positive number");
         }
-        if (pos + skipNum >= idList.size()) {
-            pos = idList.size() - 1;
-            throw new NoSuchElementException();
+        if (pos + skipNum > idList.size()) {
+            throw new NoSuchElementException("skipNum + pos greater than size");
         }
         pos += skipNum;
     }
 
-    //-------------------------------------------------------------< Iterator >
+    //-----------------------------------------------------------< Iterator >---
+    /**
+     * {@inheritDoc}
+     */
     public boolean hasNext() {
-        return pos < idList.size() - 1;
+        return pos < idList.size();
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public Object next() {
-        if (pos >= idList.size() - 1) {
+        if (pos >= idList.size()) {
             throw new NoSuchElementException();
         }
-        while (true) {
-            pos++;
-            try {
-                return itemMgr.getItem((ItemId) idList.get(pos));
-            } catch (AccessDeniedException ade) {
-                // silently ignore and try next
-                continue;
-            } catch (RepositoryException re) {
-                // FIXME: not quite correct
-                throw new NoSuchElementException(re.getMessage());
-            }
+        try {
+            return itemMgr.getItem((ItemId) idList.get(pos++));
+        } catch (RepositoryException e) {
+            throw new NoSuchElementException(e.getMessage());
         }
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * @throws UnsupportedOperationException allways, since not implemented
+     */
     public void remove() {
         throw new UnsupportedOperationException("remove");
     }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java?view=diff&r1=156187&r2=156188
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java Fri Mar 
4 09:40:12 2005
@@ -2419,12 +2419,26 @@
      * @see Node#getReferences()
      */
     public PropertyIterator getReferences() throws RepositoryException {
+        return getReferences(false);
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * In addition to the normal behaviour, this method also filters out the
+     * references that do not exist in this workspace if <code>skipExistent</code>
+     * is set to <code>true</code>.
+     *
+     * @param skipInexistent if set to <code>true</code> inexistent items are
skipped
+     */
+    protected PropertyIterator getReferences(boolean skipInexistent)
+            throws RepositoryException {
         try {
             NodeReferencesId targetId = new NodeReferencesId(((NodeId) id).getUUID());
             NodeReferences refs = stateMgr.getNodeReferences(targetId);
             // refs.getReferences returns a list of PropertyId's
             List idList = refs.getReferences();
-            return new LazyItemIterator(itemMgr, idList);
+            return new LazyItemIterator(itemMgr, idList, skipInexistent);
         } catch (ItemStateException e) {
             String msg = "Unable to retrieve node references for: " + id;
             log.debug(msg);

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?view=diff&r1=156187&r2=156188
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Fri Mar  4 09:40:12 2005
@@ -34,6 +34,7 @@
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import java.io.PrintStream;
 import java.util.Iterator;
+import java.util.ArrayList;
 
 /**
  * Shared <code>ItemStateManager</code>. Caches objects returned from a
@@ -390,6 +391,10 @@
     public synchronized void store(ChangeLog local, ObservationManagerImpl obsMgr) throws
ItemStateException {
         ChangeLog shared = new ChangeLog();
 
+        // set of virtual node references
+        // todo: remember by provider
+        ArrayList virtualRefs = new ArrayList();
+
         /**
          * Validate modified references. Target node of references may
          * have been deleted in the meantime.
@@ -398,18 +403,28 @@
         while (iter.hasNext()) {
             NodeReferences refs = (NodeReferences) iter.next();
             NodeId id = new NodeId(refs.getUUID());
-
-            if (refs.hasReferences()) {
-                try {
-                    if (local.get(id) == null && !hasItemState(id)) {
-                        throw new NoSuchItemStateException();
+            // if targetid is in virtual provider, transfer to its modified set
+            for (int i=0; i<virtualProviders.length; i++) {
+                VirtualItemStateProvider provider = virtualProviders[i];
+                if (provider.hasItemState(id)) {
+                    virtualRefs.add(refs);
+                    refs = null;
+                    break;
+                }
+            }
+            if (refs != null) {
+                if (refs.hasReferences()) {
+                    try {
+                        if (local.get(id) == null && !hasItemState(id)) {
+                            throw new NoSuchItemStateException();
+                        }
+                    } catch (NoSuchItemStateException e) {
+                        String msg = "Target node " + id + " of REFERENCE property does not
exist";
+                        throw new ItemStateException(msg);
                     }
-                } catch (NoSuchItemStateException e) {
-                    String msg = "Target node " + id + " of REFERENCE property does not exist";
-                    throw new ItemStateException(msg);
                 }
+                shared.modified(refs);
             }
-            shared.modified(refs);
         }
 
         /**
@@ -452,6 +467,18 @@
 
         /* Let the shared item listeners know about the change */
         shared.persisted();
+
+        /* notify virtual providers about node references */
+        iter = virtualRefs.iterator();
+        while (iter.hasNext()) {
+            NodeReferences refs = (NodeReferences) iter.next();
+            // if targetid is in virtual provider, transfer to its modified set
+            for (int i=0; i<virtualProviders.length; i++) {
+                if (virtualProviders[i].setNodeReferences(refs)) {
+                    break;
+                }
+            }
+        }
 
         /* dispatch the events */
         if (events != null) {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java?view=diff&r1=156187&r2=156188
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
Fri Mar  4 09:40:12 2005
@@ -24,6 +24,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.version.VersionException;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * This interface defines the access to the persistence layer of the
@@ -147,6 +148,23 @@
      * @return item state manager
      */
     public UpdatableItemStateManager getItemStateMgr();
+
+    /**
+     * Returns the references that exist to this version item
+     *
+     * @param item
+     * @return a collection of property ids
+     */
+    public List getItemReferences(InternalVersionItem item);
+
+    /**
+     * Informs this version manager that the references to one of its
+     * items has changed.
+     *
+     * @param item the version item that is referenced
+     * @param references the collection of PropertyIds that references the item
+     */
+    public void setItemReferences(InternalVersionItem item, List references);
 
     /**
      * Close this persistence version manager. After having closed a persistence

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java?view=diff&r1=156187&r2=156188
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
Fri Mar  4 09:40:12 2005
@@ -18,6 +18,9 @@
 
 import org.apache.jackrabbit.core.*;
 import org.apache.jackrabbit.core.state.NodeState;
+import org.apache.jackrabbit.core.state.NodeReferencesId;
+import org.apache.jackrabbit.core.state.NodeReferences;
+import org.apache.jackrabbit.core.state.ItemStateException;
 
 import javax.jcr.Item;
 import javax.jcr.RepositoryException;
@@ -28,6 +31,7 @@
 import javax.jcr.version.VersionException;
 import javax.jcr.version.VersionHistory;
 import javax.jcr.version.VersionIterator;
+import java.util.List;
 
 /**
  * This Class implements a version history that extends a node.
@@ -260,5 +264,15 @@
         if (!version.getParent().isSame(this)) {
             throw new VersionException("Specified version not contained in this history.");
         }
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * In addition to the normal behaviour, this method also filters out the
+     * references that do not exist in this workspace.
+     */
+    public PropertyIterator getReferences() throws RepositoryException {
+        return getReferences(true);
     }
 }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionImpl.java?view=diff&r1=156187&r2=156188
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionImpl.java
Fri Mar  4 09:40:12 2005
@@ -18,13 +18,18 @@
 
 import org.apache.jackrabbit.core.*;
 import org.apache.jackrabbit.core.state.NodeState;
+import org.apache.jackrabbit.core.state.NodeReferencesId;
+import org.apache.jackrabbit.core.state.NodeReferences;
+import org.apache.jackrabbit.core.state.ItemStateException;
 
 import javax.jcr.Item;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.PropertyIterator;
 import javax.jcr.nodetype.NodeDef;
 import javax.jcr.version.Version;
 import java.util.Calendar;
+import java.util.List;
 
 /**
  * This Class implements a Version that extends the node interface
@@ -127,4 +132,13 @@
         }
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * In addition to the normal behaviour, this method also filters out the
+     * references that do not exist in this workspace.
+     */
+    public PropertyIterator getReferences() throws RepositoryException {
+        return getReferences(true);
+    }
 }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java?view=diff&r1=156187&r2=156188
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
Fri Mar  4 09:40:12 2005
@@ -141,8 +141,32 @@
      */
     public NodeReferences getNodeReferences(NodeReferencesId id)
             throws NoSuchItemStateException, ItemStateException {
+        try {
+            InternalVersionItem vi = vMgr.getItem(id.getUUID());
+            if (vi != null) {
+                // todo: add caching
+                NodeReferences ref = new NodeReferences(id);
+                ref.addAllReferences(vMgr.getItemReferences(vi));
+                // check for versionstorage internal references
+                if (vi instanceof InternalVersion) {
+                    InternalVersion v = (InternalVersion) vi;
+                    InternalVersion[] suc = v.getSuccessors();
+                    for (int i=0; i<suc.length; i++) {
+                        InternalVersion s = suc[i];
+                        ref.addReference(new PropertyId(s.getId(), JCR_PREDECESSORS));
+                    }
+                    InternalVersion[] pred = v.getPredecessors();
+                    for (int i=0; i<pred.length; i++) {
+                        InternalVersion p = pred[i];
+                        ref.addReference(new PropertyId(p.getId(), JCR_SUCCESSORS));
+                    }
+                }
 
-        //@todo return node references
+                return ref;
+            }
+        } catch (RepositoryException e) {
+            // ignore
+        }
         throw new NoSuchItemStateException(id.getUUID());
     }
 
@@ -436,6 +460,22 @@
             String msg = "internal error: failed to build effective node type for node "
+ parent.getUUID();
             throw new RepositoryException(msg, ntce);
         }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean setNodeReferences(NodeReferences refs) {
+        try {
+            InternalVersionItem vi = vMgr.getItem(refs.getUUID());
+            if (vi != null) {
+                vMgr.setItemReferences(vi, refs.getReferences());
+                return true;
+            }
+        } catch (RepositoryException e) {
+            // ignore
+        }
+        return false;
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java?view=diff&r1=156187&r2=156188
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManager.java
Fri Mar  4 09:40:12 2005
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.core.version;
 
 import org.apache.jackrabbit.core.NodeImpl;
-import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 
@@ -25,6 +24,7 @@
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * This interface defines the version manager. It gives access to the underlaying
@@ -115,6 +115,7 @@
 
     /**
      * checks, if the node with the given id exists
+     * todo: move probably to VersionManagerImpl
      *
      * @param id
      * @return
@@ -123,12 +124,32 @@
 
     /**
      * Returns the version item with the given id
+     * todo: move probably to VersionManagerImpl
      *
      * @param id
      * @return
      * @throws RepositoryException
      */
     public InternalVersionItem getItem(String id) throws RepositoryException;
+
+    /**
+     * Returns the references that exist to this version item
+     * todo: move probably to VersionManagerImpl
+     *
+     * @param item
+     * @return a collection of property ids
+     */
+    public List getItemReferences(InternalVersionItem item);
+
+    /**
+     * Informs this version manager that the references to one of its
+     * items has changed.
+     * todo: move probably to VersionManagerImpl
+     *
+     * @param item the version item that is referenced
+     * @param references the collection of PropertyIds that references the item
+     */
+    public void setItemReferences(InternalVersionItem item, List references);
 
     /**
      * Close this version manager. After having closed a persistence

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?view=diff&r1=156187&r2=156188
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Fri Mar  4 09:40:12 2005
@@ -27,6 +27,7 @@
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * This Class implements a VersionManager. It more or less acts as proxy
@@ -228,5 +229,17 @@
         return (Version) node.getSession().getNodeByUUID(version.getId());
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public List getItemReferences(InternalVersionItem item) {
+        return vMgr.getItemReferences(item);
+    }
 
+    /**
+     * {@inheritDoc}
+     */
+    public void setItemReferences(InternalVersionItem item, List references) {
+        vMgr.setItemReferences(item, references);
+    }
 }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java?view=diff&r1=156187&r2=156188
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/NativePVM.java
Fri Mar  4 09:40:12 2005
@@ -18,7 +18,6 @@
 
 import org.apache.commons.collections.ReferenceMap;
 import org.apache.jackrabbit.core.*;
-import org.apache.jackrabbit.core.observation.ObservationManagerImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.state.*;
 import org.apache.jackrabbit.core.util.uuid.UUID;
@@ -30,9 +29,7 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.*;
 
 /**
  * This Class implements the persistent part of the versioning. the
@@ -551,6 +548,36 @@
      */
     public UpdatableItemStateManager getItemStateMgr() {
         return stateMgr;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public List getItemReferences(InternalVersionItem item) {
+        try {
+            PersistentId id = getIdByExternal(item.getId());
+            NodeReferences refs = pMgr.load(new NodeReferencesId(id.internalId));
+            return refs.getReferences();
+        } catch (ItemStateException e) {
+            // ignore
+        }
+        return Collections.EMPTY_LIST;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setItemReferences(InternalVersionItem item, List references) {
+        try {
+            ChangeLog log = new ChangeLog();
+            PersistentId id = getIdByExternal(item.getId());
+            NodeReferences refs = new NodeReferences(new NodeReferencesId(id.internalId));
+            refs.addAllReferences(references);
+            log.modified(refs);
+            pMgr.store(log);
+        } catch (ItemStateException e) {
+            log.error("Error while storing", e);
+        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java?view=diff&r1=156187&r2=156188
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/PersistentNode.java
Fri Mar  4 09:40:12 2005
@@ -21,6 +21,7 @@
 import org.apache.jackrabbit.core.util.uuid.UUID;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.PropertyType;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import java.util.List;

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java?view=diff&r1=156187&r2=156188
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java
Fri Mar  4 09:40:12 2005
@@ -20,10 +20,7 @@
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.QName;
-import org.apache.jackrabbit.core.state.ItemStateException;
-import org.apache.jackrabbit.core.state.ItemStateManager;
-import org.apache.jackrabbit.core.state.NoSuchItemStateException;
-import org.apache.jackrabbit.core.state.ItemStateListener;
+import org.apache.jackrabbit.core.state.*;
 
 import javax.jcr.RepositoryException;
 
@@ -114,4 +111,12 @@
                                             String uuid, QName nodeTypeName)
             throws RepositoryException;
 
+    /**
+     * Informs this provider that the node references to one of its states has
+     * changed.
+     *
+     * @param refs
+     * @return <code>true</code> if the reference target is one of its items.
+     */
+    public boolean setNodeReferences(NodeReferences refs);
 }



Mime
View raw message