chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sklev...@apache.org
Subject svn commit: r941268 - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-client: chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/cli...
Date Wed, 05 May 2010 12:41:24 GMT
Author: sklevenz
Date: Wed May  5 12:41:23 2010
New Revision: 941268

URL: http://svn.apache.org/viewvc?rev=941268&view=rev
Log:
Fix:

https://issues.apache.org/jira/browse/CMIS-200

Removed:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ItemIterator.java
Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ItemIterable.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterator.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterable.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIterableImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/ItemIterableTest.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ItemIterable.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ItemIterable.java?rev=941268&r1=941267&r2=941268&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ItemIterable.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ItemIterable.java
Wed May  5 12:41:23 2010
@@ -18,6 +18,8 @@
  */
 package org.apache.chemistry.opencmis.client.api;
 
+import java.util.Iterator;
+
 /**
  * Iterable for CMIS collections that allows ability to skip to specific
  * position or return a sub collection.
@@ -57,5 +59,25 @@ public interface ItemIterable<T> extends
      * 
      * @see java.lang.Iterable#iterator()
      */
-    ItemIterator<T> iterator();
+    Iterator<T> iterator();
+
+    /**
+     * Returns the number of items fetched for the current page.
+     * 
+     * @return number of items for currently fetched collection
+     */
+    long getPageNumItems();
+    
+    /**
+     * Returns the total number of items. If the repository knows the total
+     * number of items in a result set, the repository SHOULD include the number
+     * here. If the repository does not know the number of items in a result
+     * set, this parameter SHOULD not be set. The value in the parameter MAY NOT
+     * be accurate the next time the client retrieves the result set or the next
+     * page in the result set.
+     * 
+     * @return total number of items or (-1)
+     */
+    long getTotalNumItems();
+
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterator.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterator.java?rev=941268&r1=941267&r2=941268&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterator.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterator.java
Wed May  5 12:41:23 2010
@@ -18,9 +18,9 @@
  */
 package org.apache.chemistry.opencmis.client.runtime.util;
 
+import java.util.Iterator;
 import java.util.List;
 
-import org.apache.chemistry.opencmis.client.api.ItemIterator;
 import org.apache.chemistry.opencmis.client.runtime.util.AbstractPageFetch.PageFetchResult;
 
 
@@ -29,7 +29,7 @@ import org.apache.chemistry.opencmis.cli
  * 
  * @param <T>
  */
-public abstract class AbstractIterator<T> implements ItemIterator<T> {
+public abstract class AbstractIterator<T> implements Iterator<T> {
 
     private long skipCount;
     private int skipOffset;
@@ -64,7 +64,7 @@ public abstract class AbstractIterator<T
      * (non-Javadoc)
      * @see org.apache.chemistry.opencmis.client.api.ItemIterator#getPageNumItems()
      */
-    public long getCurrentCollectionNumItems() {
+    public long getPageNumItems() {
         PageFetchResult<T> page = getCurrentPage();
         if (page != null) {
             List<T> items = page.getPage();

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterable.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterable.java?rev=941268&r1=941267&r2=941268&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterable.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterable.java
Wed May  5 12:41:23 2010
@@ -18,8 +18,9 @@
  */
 package org.apache.chemistry.opencmis.client.runtime.util;
 
+import java.util.Iterator;
+
 import org.apache.chemistry.opencmis.client.api.ItemIterable;
-import org.apache.chemistry.opencmis.client.api.ItemIterator;
 
 /**
  * CMIS Collection Iterable
@@ -28,6 +29,7 @@ public class CollectionIterable<T> imple
 
     private AbstractPageFetch<T> pageFetch;
     private long skipCount;
+    private CollectionIterator<T> iterator;
 
     /**
      * Construct
@@ -54,8 +56,11 @@ public class CollectionIterable<T> imple
      * 
      * @see java.lang.Iterable#iterator()
      */
-    public ItemIterator<T> iterator() {
-        return new CollectionIterator<T>(skipCount, pageFetch);
+    public Iterator<T> iterator() {
+        if (this.iterator == null) {
+            this.iterator = new CollectionIterator<T>(skipCount, pageFetch);
+        }
+        return this.iterator;
     }
 
     /*
@@ -85,4 +90,18 @@ public class CollectionIterable<T> imple
         this.pageFetch.setMaxNumItems(maxNumItems);
         return new ItemIterableImpl<T>(skipCount, pageFetch);
    }
+
+    public long getPageNumItems() {
+        if (this.iterator == null) {
+            this.iterator = new CollectionIterator<T>(skipCount, pageFetch);
+        }
+        return this.iterator.getPageNumItems();
+    }
+
+    public long getTotalNumItems() {
+        if (this.iterator == null) {
+            this.iterator = new CollectionIterator<T>(skipCount, pageFetch);
+        }
+        return this.iterator.getTotalNumItems();
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIterableImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIterableImpl.java?rev=941268&r1=941267&r2=941268&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIterableImpl.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIterableImpl.java
Wed May  5 12:41:23 2010
@@ -18,8 +18,10 @@
  */
 package org.apache.chemistry.opencmis.client.runtime.util;
 
+import java.util.Iterator;
+
 import org.apache.chemistry.opencmis.client.api.ItemIterable;
-import org.apache.chemistry.opencmis.client.api.ItemIterator;
+import org.apache.chemistry.opencmis.client.runtime.util.AbstractPageFetch.PageFetchResult;
 
 /**
  * Iterable for a CMIS Collection Page
@@ -28,6 +30,7 @@ public class ItemIterableImpl<T> impleme
 
     private AbstractPageFetch<T> pageFetch;
     private long skipCount;
+    private ItemIteratorImpl<T> iterator;
 
     /**
      * Construct
@@ -54,8 +57,11 @@ public class ItemIterableImpl<T> impleme
      * 
      * @see java.lang.Iterable#iterator()
      */
-    public ItemIterator<T> iterator() {
-        return new ItemIteratorImpl<T>(skipCount, pageFetch);
+    public Iterator<T> iterator() {
+        if (this.iterator == null) {
+            this.iterator = new ItemIteratorImpl<T>(skipCount, pageFetch);
+        }
+        return this.iterator;
     }
 
     /*
@@ -86,4 +92,18 @@ public class ItemIterableImpl<T> impleme
         this.pageFetch.setMaxNumItems(maxNumItems);
         return new ItemIterableImpl<T>(skipCount, pageFetch);
     }
+
+    public long getPageNumItems() {
+        if (this.iterator == null) {
+            this.iterator = new ItemIteratorImpl<T>(skipCount, pageFetch);
+        }
+        return this.iterator.getPageNumItems();
+    }
+
+    public long getTotalNumItems() {
+        if (this.iterator == null) {
+            this.iterator = new ItemIteratorImpl<T>(skipCount, pageFetch);
+        }
+        return this.iterator.getTotalNumItems();
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/ItemIterableTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/ItemIterableTest.java?rev=941268&r1=941267&r2=941268&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/ItemIterableTest.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/ItemIterableTest.java
Wed May  5 12:41:23 2010
@@ -25,11 +25,11 @@ import static org.junit.Assert.assertTru
 import java.io.IOException;
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 
 import org.apache.chemistry.opencmis.client.api.ItemIterable;
-import org.apache.chemistry.opencmis.client.api.ItemIterator;
 import org.apache.chemistry.opencmis.client.runtime.util.AbstractPageFetch;
 import org.apache.chemistry.opencmis.client.runtime.util.CollectionIterable;
 import org.apache.commons.logging.Log;
@@ -180,14 +180,13 @@ public class ItemIterableTest {
         int pageSize = 5;
         ItemIterable<String> p = this.getIterable(this.data10, pageSize);
         assertNotNull(p);
-        ItemIterator<String> i = (ItemIterator<String>) p.iterator();
+        Iterator<String> i = p.iterator();
         assertNotNull(i);
-        assertEquals(pageSize + 1, i.getTotalNumItems());
+        assertEquals(pageSize + 1, p.getTotalNumItems());
         for (int idx = 0; i.hasNext() && idx < (pageSize + 1); idx++) {
-            i.next();
+            assertNotNull(i.next());
         }
-        assertEquals(pageSize + 1, i.getPosition());
-        assertEquals(this.data10.length, i.getTotalNumItems());
+        assertEquals(this.data10.length, p.getTotalNumItems());
     }
 
     @Test
@@ -197,14 +196,11 @@ public class ItemIterableTest {
         int pageSize = 5;
         ItemIterable<String> p = this.getIterable(this.data10, pageSize);
         assertNotNull(p);
-        ItemIterator<String> i = (ItemIterator<String>) p.iterator();
+        Iterator<String> i = p.iterator();
         assertNotNull(i);
-        assertEquals(true, i.getHasMoreItems());
         for (int idx = 0; i.hasNext() && idx < (pageSize + 1); idx++) {
-            i.next();
+            assertNotNull(i.next());
         }
-        assertEquals(pageSize + 1, i.getPosition());
-        assertEquals(false, i.getHasMoreItems());
     }
 
     @Test
@@ -214,14 +210,13 @@ public class ItemIterableTest {
         int pageSize = 7;
         ItemIterable<String> p = this.getIterable(this.data10, pageSize);
         assertNotNull(p);
-        ItemIterator<String> i = (ItemIterator<String>) p.iterator();
+        Iterator<String> i = p.iterator();
         assertNotNull(i);
-        assertEquals(pageSize, i.getCurrentCollectionNumItems());
+        assertEquals(pageSize, p.getPageNumItems());
         for (int idx = 0; i.hasNext() && idx < (pageSize + 1); idx++) {
-            i.next();
+            assertNotNull(i.next());
         }
-        assertEquals(pageSize + 1, i.getPosition());
-        assertEquals(this.data10.length - pageSize, i.getCurrentCollectionNumItems());
+        assertEquals(this.data10.length - pageSize, p.getPageNumItems());
     }
 
     private void loopSubPage(String[] data, int skipCount, int maxItems, int pageSize) {



Mime
View raw message