jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r430059 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ItemManagerImpl.java LazyItemIterator.java NodeImpl.java state/NodeReferences.java version/VersionHistoryImpl.java
Date Wed, 09 Aug 2006 14:21:41 GMT
Author: angela
Date: Wed Aug  9 07:21:38 2006
New Revision: 430059

URL: http://svn.apache.org/viewvc?rev=430059&view=rev
Log:
work in progress

- remove commented code
- adjust usages of LazyItemIterator

TODO redefined handling of references

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeReferences.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java?rev=430059&r1=430058&r2=430059&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
Wed Aug  9 07:21:38 2006
@@ -212,20 +212,6 @@
         session.checkIsAlive();
         checkAccess(parentState, true);
 
-        /*
-        // REMOVED. left check for access to Iterator (getSize() returns -1)
-        ArrayList childIds = new ArrayList();
-        Iterator iter = parentState.getChildNodeEntries().iterator();
-
-        while (iter.hasNext()) {
-            ChildNodeEntry entry = (ChildNodeEntry) iter.next();
-            NodeId id = entry.getId();
-            // check read access
-            if (session.getAccessManager().canRead(id)) {
-                childIds.add(id);
-            }
-        }
-        */
         return new LazyItemIterator(this, parentState.getChildNodeEntries());
     }
 
@@ -260,25 +246,6 @@
         session.checkIsAlive();
         checkAccess(parentState, true);
 
-        /*
-        // REMOVED. left check for access to Iterator (getSize() returns -1)
-        ArrayList childIds = new ArrayList();
-        Iterator iter = parentState.getPropertyNames().iterator();
-
-        while (iter.hasNext()) {
-            QName propName = (QName) iter.next();
-            try {
-                PropertyId id = parentState.getPropertyState(propName).getPropertyId();
-                // check read access
-                if (session.getAccessManager().canRead(id)) {
-                    childIds.add(id);
-                }
-            } catch (ItemStateException e) {
-                // should not occur.
-                throw new RepositoryException(e);
-            }
-        }
-        */
         return new LazyItemIterator(this, parentState.getPropertyEntries());
     }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java?rev=430059&r1=430058&r2=430059&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java
Wed Aug  9 07:21:38 2006
@@ -67,11 +67,11 @@
      * Creates a new <code>LazyItemIterator</code> instance.
      *
      * @param itemMgr item manager
-     * @param stateList Collection of item states
+     * @param itemStates Collection of item states
      */
-    public LazyItemIterator(ItemManager itemMgr, Collection stateList) {
+    public LazyItemIterator(ItemManager itemMgr, Collection itemStates) {
         this.itemMgr = itemMgr;
-        this.stateList = new ArrayList(stateList);
+        this.stateList = new ArrayList(itemStates);
         // prefetch first item
         pos = 0;
         prefetchNext();

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=430059&r1=430058&r2=430059&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
Wed Aug  9 07:21:38 2006
@@ -92,6 +92,7 @@
 import java.util.List;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Iterator;
 
 /**
  * <code>NodeImpl</code>...
@@ -561,9 +562,9 @@
         try {
             if (itemStateMgr.hasNodeReferences(getNodeId())) {
                 NodeReferences refs = itemStateMgr.getNodeReferences(getNodeId());
-                // refs.getReferences() returns a list of PropertyId's
-                List idList = refs.getReferences();
-                return new LazyItemIterator(itemMgr, idList);
+                // refs.getReferences() returns a list of Property states
+                Collection refStates = refs.getReferences();
+                return new LazyItemIterator(itemMgr, refStates);
             } else {
                 // there are no references, return empty iterator
                 return IteratorHelper.EMPTY;
@@ -871,11 +872,26 @@
         // make sure the workspace exists and is accessible for this session.
         session.checkAccessibleWorkspace(srcWorkspace);
 
+        // TODO: improve... (and review return value of VM.merge)
         Collection failedIds = session.getVersionManager().merge(getNodeId(), srcWorkspace,
bestEffort);
         if (failedIds.isEmpty()) {
             return IteratorHelper.EMPTY;
         } else {
-            return new LazyItemIterator(itemMgr, failedIds);
+            List failedStates = new ArrayList();
+            Iterator it = failedIds.iterator();
+            while (it.hasNext()) {
+                try {
+                    ItemState state = session.getItemStateManager().getItemState((NodeId)
it.next());
+                    if (state.isNode()) {
+                        failedStates.add(state);
+                    } else {
+                        throw new RepositoryException("Unexpected error: NodeState expected.");
+                    }
+                } catch (ItemStateException e) {
+                    throw new RepositoryException("Unexpected error", e);
+                }
+            }
+            return new LazyItemIterator(itemMgr, failedStates);
         }
     }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeReferences.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeReferences.java?rev=430059&r1=430058&r2=430059&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeReferences.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeReferences.java
Wed Aug  9 07:21:38 2006
@@ -18,7 +18,7 @@
 
 import org.apache.jackrabbit.spi.NodeId;
 
-import java.util.List;
+import java.util.Collection;
 
 /**
  * <code>NodeReferences</code>...
@@ -42,7 +42,8 @@
     public boolean hasReferences();
 
     /**
-     * @return the list of references
+     * @return the collection of states referring to the node identified by this
+     * <code>NodeReference</code>.
      */
-    public List getReferences();
+    public Collection getReferences();
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java?rev=430059&r1=430058&r2=430059&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
Wed Aug  9 07:21:38 2006
@@ -126,16 +126,20 @@
      */
     public VersionIterator getAllVersions() throws RepositoryException {
         Iterator childIter = vhState.getChildNodeEntries().iterator();
-        Set versionIds = new HashSet();
+        Set versionStates = new HashSet();
 
         // all child-nodes except from jcr:versionLabels point to Versions.
         while (childIter.hasNext()) {
             ChildNodeEntry entry = (ChildNodeEntry) childIter.next();
             if (!QName.JCR_VERSIONLABELS.equals(entry.getName())) {
-                versionIds.add(entry.getId());
+                try {
+                    versionStates.add(entry.getNodeState());
+                } catch (ItemStateException e) {
+                    throw new RepositoryException(e);
+                }
             }
         }
-        return new LazyItemIterator(itemMgr, versionIds);
+        return new LazyItemIterator(itemMgr, versionStates);
     }
 
     /**



Mime
View raw message