You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by sk...@apache.org on 2010/05/05 09:03:13 UTC
svn commit: r941171 - in /incubator/chemistry/opencmis/trunk:
chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/
chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apa...
Author: sklevenz
Date: Wed May 5 07:03:12 2010
New Revision: 941171
URL: http://svn.apache.org/viewvc?rev=941171&view=rev
Log:
Patch:
https://issues.apache.org/jira/browse/CMIS-200
Added:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/ItemIterableTest.java (contents, props changed)
- copied, changed from r940777, incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java
Removed:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java
Modified:
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/CmisObject.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectType.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/OperationContext.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterable.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractPersistentCmisObject.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentFolderImpl.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentSessionImpl.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/DocumentTypeImpl.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/FolderTypeImpl.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/ObjectTypeHelper.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/PolicyTypeImpl.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/RelationshipTypeImpl.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractPageFetch.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/PageIterable.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyDiscoverIT.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyNavigationIT.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyTypeIT.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectRelationIT.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectVersionIT.java
incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/sample/AbstractSampleIT.java
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/CmisObject.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/CmisObject.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/CmisObject.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/CmisObject.java Wed May 5 07:03:12 2010
@@ -124,7 +124,7 @@ public interface CmisObject extends Obje
// relationship service
PagingIterable<Relationship> getRelationships(boolean includeSubRelationshipTypes,
- RelationshipDirection relationshipDirection, ObjectType type, OperationContext context, int itemsPerPage);
+ RelationshipDirection relationshipDirection, ObjectType type, OperationContext context);
// renditions
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.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/Folder.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Folder.java Wed May 5 07:03:12 2010
@@ -59,9 +59,9 @@ public interface Folder extends Fileable
List<Tree<FileableCmisObject>> getDescendants(int depth, OperationContext context);
- PagingIterable<CmisObject> getChildren(int itemsPerPage);
+ PagingIterable<CmisObject> getChildren();
- PagingIterable<CmisObject> getChildren(OperationContext context, int itemsPerPage);
+ PagingIterable<CmisObject> getChildren(OperationContext context);
boolean isRootFolder();
@@ -72,9 +72,9 @@ public interface Folder extends Fileable
/**
* Returns all checked out documents of this folder.
*/
- PagingIterable<Document> getCheckedOutDocs(int itemsPerPage);
+ PagingIterable<Document> getCheckedOutDocs();
- PagingIterable<Document> getCheckedOutDocs(OperationContext context, int itemsPerPage);
+ PagingIterable<Document> getCheckedOutDocs(OperationContext context);
// folder specific properties
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectType.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/ObjectType.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectType.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectType.java Wed May 5 07:03:12 2010
@@ -67,12 +67,10 @@ public interface ObjectType extends Type
* Get the list of types directly derived from this type (which will return
* this type on {@code getParent()}).
*
- * @param itemsPerPage
- * types per page
* @return a {@code List} of types which are directly derived from this
* type. @
*/
- PagingIterable<ObjectType> getChildren(int itemsPerPage);
+ PagingIterable<ObjectType> getChildren();
/**
* Get the list of all types somehow derived from this type.
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/OperationContext.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/OperationContext.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/OperationContext.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/OperationContext.java Wed May 5 07:03:12 2010
@@ -73,4 +73,8 @@ public interface OperationContext {
void setCacheEnabled(boolean cacheEnabled);
String getCacheKey();
+
+ void setMaxItemsPerPage(int maxItemsPerPage);
+
+ int getMaxItemsPerPage();
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterable.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/PagingIterable.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterable.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterable.java Wed May 5 07:03:12 2010
@@ -19,7 +19,8 @@
package org.apache.chemistry.opencmis.client.api;
/**
- * Iterable for CMIS collections that allows ability to skip to specific position.
+ * Iterable for CMIS collections that allows ability to skip to specific
+ * position.
*
* @param <T>
*/
@@ -34,14 +35,26 @@ public interface PagingIterable<T> exten
PagingIterable<T> skipTo(long position);
/**
- * Gets an iterable for the current page within the CMIS collection
- *
+ * Gets an iterable for the current page within the CMIS collection using
+ * default page size
+ *
* @return iterable for current page
*/
PagingIterable<T> getPage();
-
+
+ /**
+ * Gets an iterable for the current page within the CMIS collection
+ *
+ * @param maxNumItems
+ * maximum number of items the page will contain
+ *
+ * @return iterable for current page
+ */
+ PagingIterable<T> getPage(int maxNumItems);
+
/*
* (non-Javadoc)
+ *
* @see java.lang.Iterable#iterator()
*/
PagingIterator<T> iterator();
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.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/Session.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java Wed May 5 07:03:12 2010
@@ -85,7 +85,7 @@ public interface Session {
*/
OperationContext createOperationContext(Set<String> filter, boolean includeAcls, boolean includeAllowableActions,
boolean includePolicies, IncludeRelationships includeRelationships, Set<String> renditionFilter,
- boolean includePathSegments, String orderBy, boolean cacheEnabled);
+ boolean includePathSegments, String orderBy, boolean cacheEnabled, int maxItemsPerPage);
/**
* Creates an object id.
@@ -123,7 +123,7 @@ public interface Session {
/**
* Returns the type children of the given type id.
*/
- PagingIterable<ObjectType> getTypeChildren(String typeId, boolean includePropertyDefinitions, int itemsPerPage);
+ PagingIterable<ObjectType> getTypeChildren(String typeId, boolean includePropertyDefinitions);
/**
* Returns the type descendants of the given type id.
@@ -144,9 +144,9 @@ public interface Session {
*
* @see Folder#getCheckedOutDocs(int)
*/
- PagingIterable<Document> getCheckedOutDocs(int itemsPerPage);
+ PagingIterable<Document> getCheckedOutDocs();
- PagingIterable<Document> getCheckedOutDocs(OperationContext context, int itemsPerPage);
+ PagingIterable<Document> getCheckedOutDocs(OperationContext context);
/**
* Object service <code>getObject</code>.
@@ -167,15 +167,14 @@ public interface Session {
/**
* Discovery service <code>query</code>.
*/
- PagingIterable<QueryResult> query(String statement, boolean searchAllVersions, int itemsPerPage);
+ PagingIterable<QueryResult> query(String statement, boolean searchAllVersions);
- PagingIterable<QueryResult> query(String statement, boolean searchAllVersions, OperationContext context,
- int itemsPerPage);
+ PagingIterable<QueryResult> query(String statement, boolean searchAllVersions, OperationContext context);
/**
* Discovery service <code>getContentChanges</code>.
*/
- PagingIterable<ChangeEvent> getContentChanges(String changeLogToken, int itemsPerPage);
+ PagingIterable<ChangeEvent> getContentChanges(String changeLogToken);
// create
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractPersistentCmisObject.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/AbstractPersistentCmisObject.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractPersistentCmisObject.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractPersistentCmisObject.java Wed May 5 07:03:12 2010
@@ -727,18 +727,14 @@ public abstract class AbstractPersistent
* org.apache.opencmis.client.api.OperationContext, int)
*/
public PagingIterable<Relationship> getRelationships(final boolean includeSubRelationshipTypes,
- final RelationshipDirection relationshipDirection, ObjectType type, OperationContext context,
- final int itemsPerPage) {
- if (itemsPerPage < 1) {
- throw new IllegalArgumentException("itemsPerPage must be > 0!");
- }
+ final RelationshipDirection relationshipDirection, ObjectType type, OperationContext context) {
final String objectId = getObjectId();
final String typeId = (type == null ? null : type.getId());
final RelationshipService relationshipService = getBinding().getRelationshipService();
final OperationContext ctxt = new OperationContextImpl(context);
- return new CollectionIterable<Relationship>(new AbstractPageFetch<Relationship>() {
+ return new CollectionIterable<Relationship>(new AbstractPageFetch<Relationship>(ctxt.getMaxItemsPerPage()) {
@Override
protected AbstractPageFetch.PageFetchResult<Relationship> fetchPage(long skipCount) {
@@ -746,7 +742,7 @@ public abstract class AbstractPersistent
// fetch the relationships
ObjectList relList = relationshipService.getObjectRelationships(getRepositoryId(), objectId,
includeSubRelationshipTypes, relationshipDirection, typeId, ctxt.getFilterString(), ctxt
- .isIncludeAllowableActions(), BigInteger.valueOf(itemsPerPage), BigInteger
+ .isIncludeAllowableActions(), BigInteger.valueOf(this.pageSize), BigInteger
.valueOf(skipCount), null);
// convert relationship objects
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.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/OperationContextImpl.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java Wed May 5 07:03:12 2010
@@ -47,6 +47,7 @@ public class OperationContextImpl implem
private String orderBy;
private boolean cacheEnabled;
private String cacheKey;
+ private int maxItemsPerPage;
/**
* Default constructor.
@@ -62,6 +63,8 @@ public class OperationContextImpl implem
setOrderBy(null);
setCacheEnabled(false);
generateCacheKey();
+
+ setMaxItemsPerPage(100); // default
}
/**
@@ -78,14 +81,16 @@ public class OperationContextImpl implem
setOrderBy(source.getOrderBy());
setCacheEnabled(source.isCacheEnabled());
generateCacheKey();
- }
+
+ setMaxItemsPerPage(source.getMaxItemsPerPage());
+}
/**
* Constructor with parameters.
*/
public OperationContextImpl(Set<String> propertyFilter, boolean includeAcls, boolean includeAllowableActions,
boolean includePolicies, IncludeRelationships includeRelationships, Set<String> renditionFilter,
- boolean includePathSegments, String orderBy, boolean cacheEnabled) {
+ boolean includePathSegments, String orderBy, boolean cacheEnabled, int maxItemsPerPage) {
setFilter(propertyFilter);
setIncludeAcls(includeAcls);
setIncludeAllowableActions(includeAllowableActions);
@@ -96,6 +101,8 @@ public class OperationContextImpl implem
setOrderBy(orderBy);
setCacheEnabled(cacheEnabled);
generateCacheKey();
+
+ setMaxItemsPerPage(maxItemsPerPage);
}
/*
@@ -484,4 +491,16 @@ public class OperationContextImpl implem
cacheKey = sb.toString();
}
+
+ public int getMaxItemsPerPage() {
+ return this.maxItemsPerPage ;
+ }
+
+ public void setMaxItemsPerPage(int maxItemsPerPage) {
+ if (maxItemsPerPage < 1) {
+ throw new IllegalArgumentException("itemsPerPage must be > 0!");
+ }
+
+ this.maxItemsPerPage = maxItemsPerPage;
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentFolderImpl.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/PersistentFolderImpl.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentFolderImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentFolderImpl.java Wed May 5 07:03:12 2010
@@ -38,8 +38,8 @@ import org.apache.chemistry.opencmis.cli
import org.apache.chemistry.opencmis.client.api.Policy;
import org.apache.chemistry.opencmis.client.api.Tree;
import org.apache.chemistry.opencmis.client.runtime.util.AbstractPageFetch;
-import org.apache.chemistry.opencmis.client.runtime.util.ContainerImpl;
import org.apache.chemistry.opencmis.client.runtime.util.CollectionIterable;
+import org.apache.chemistry.opencmis.client.runtime.util.ContainerImpl;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.api.Ace;
import org.apache.chemistry.opencmis.commons.api.ContentStream;
@@ -273,8 +273,8 @@ public class PersistentFolderImpl extend
*
* @see org.apache.opencmis.client.api.Folder#getCheckedOutDocs(int)
*/
- public PagingIterable<Document> getCheckedOutDocs(int itemsPerPage) {
- return getCheckedOutDocs(getSession().getDefaultContext(), itemsPerPage);
+ public PagingIterable<Document> getCheckedOutDocs() {
+ return getCheckedOutDocs(getSession().getDefaultContext());
}
/*
@@ -283,17 +283,13 @@ public class PersistentFolderImpl extend
* @seeorg.apache.opencmis.client.api.Folder#getCheckedOutDocs(org.apache.
* opencmis.client.api. OperationContext, int)
*/
- public PagingIterable<Document> getCheckedOutDocs(OperationContext context, final int itemsPerPage) {
- if (itemsPerPage < 1) {
- throw new IllegalArgumentException("itemsPerPage must be > 0!");
- }
-
+ public PagingIterable<Document> getCheckedOutDocs(OperationContext context) {
final String objectId = getObjectId();
final NavigationService navigationService = getBinding().getNavigationService();
final ObjectFactory objectFactory = getSession().getObjectFactory();
final OperationContext ctxt = new OperationContextImpl(context);
- return new CollectionIterable<Document>(new AbstractPageFetch<Document>() {
+ return new CollectionIterable<Document>(new AbstractPageFetch<Document>(ctxt.getMaxItemsPerPage()) {
@Override
protected AbstractPageFetch.PageFetchResult<Document> fetchPage(long skipCount) {
@@ -301,7 +297,7 @@ public class PersistentFolderImpl extend
// get checked out documents for this folder
ObjectList checkedOutDocs = navigationService.getCheckedOutDocs(getRepositoryId(), objectId, ctxt
.getFilterString(), ctxt.getOrderBy(), ctxt.isIncludeAllowableActions(), ctxt
- .getIncludeRelationships(), ctxt.getRenditionFilterString(), BigInteger.valueOf(itemsPerPage),
+ .getIncludeRelationships(), ctxt.getRenditionFilterString(), BigInteger.valueOf(this.pageSize),
BigInteger.valueOf(skipCount), null);
// convert objects
@@ -330,8 +326,8 @@ public class PersistentFolderImpl extend
*
* @see org.apache.opencmis.client.api.Folder#getChildren(int)
*/
- public PagingIterable<CmisObject> getChildren(int itemsPerPage) {
- return getChildren(getSession().getDefaultContext(), itemsPerPage);
+ public PagingIterable<CmisObject> getChildren() {
+ return getChildren(getSession().getDefaultContext());
}
/*
@@ -341,18 +337,13 @@ public class PersistentFolderImpl extend
* org.apache.opencmis.client.api.Folder#getChildren(org.apache.opencmis
* .client.api.OperationContext , int)
*/
- public PagingIterable<CmisObject> getChildren(OperationContext context, final int itemsPerPage) {
-
- if (itemsPerPage < 1) {
- throw new IllegalArgumentException("itemsPerPage must be > 0!");
- }
-
+ public PagingIterable<CmisObject> getChildren(OperationContext context) {
final String objectId = getObjectId();
final NavigationService navigationService = getBinding().getNavigationService();
final ObjectFactory objectFactory = getSession().getObjectFactory();
final OperationContext ctxt = new OperationContextImpl(context);
- return new CollectionIterable<CmisObject>(new AbstractPageFetch<CmisObject>() {
+ return new CollectionIterable<CmisObject>(new AbstractPageFetch<CmisObject>(ctxt.getMaxItemsPerPage()) {
@Override
protected AbstractPageFetch.PageFetchResult<CmisObject> fetchPage(long skipCount) {
@@ -361,7 +352,7 @@ public class PersistentFolderImpl extend
ObjectInFolderList children = navigationService.getChildren(getRepositoryId(), objectId, ctxt
.getFilterString(), ctxt.getOrderBy(), ctxt.isIncludeAllowableActions(), ctxt
.getIncludeRelationships(), ctxt.getRenditionFilterString(), ctxt.isIncludePathSegments(),
- BigInteger.valueOf(itemsPerPage), BigInteger.valueOf(skipCount), null);
+ BigInteger.valueOf(this.pageSize), BigInteger.valueOf(skipCount), null);
// convert objects
List<CmisObject> page = new ArrayList<CmisObject>();
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentSessionImpl.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/PersistentSessionImpl.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentSessionImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentSessionImpl.java Wed May 5 07:03:12 2010
@@ -75,7 +75,7 @@ import org.apache.commons.logging.LogFac
public class PersistentSessionImpl implements Session, Serializable {
private static final OperationContext DEFAULT_CONTEXT = new OperationContextImpl(null, false, true, false,
- IncludeRelationships.NONE, null, true, null, true);
+ IncludeRelationships.NONE, null, true, null, true, 100);
private static final Set<Updatability> CREATE_UPDATABILITY = new HashSet<Updatability>();
static {
@@ -234,8 +234,8 @@ public class PersistentSessionImpl imple
*
* @see org.apache.opencmis.client.api.Session#getCheckedOutDocs(int)
*/
- public PagingIterable<Document> getCheckedOutDocs(int itemsPerPage) {
- return getCheckedOutDocs(getDefaultContext(), itemsPerPage);
+ public PagingIterable<Document> getCheckedOutDocs() {
+ return getCheckedOutDocs(getDefaultContext());
}
/*
@@ -244,16 +244,12 @@ public class PersistentSessionImpl imple
* @seeorg.apache.opencmis.client.api.Session#getCheckedOutDocs(org.apache.
* opencmis.client.api. OperationContext, int)
*/
- public PagingIterable<Document> getCheckedOutDocs(OperationContext context, final int itemsPerPage) {
- if (itemsPerPage < 1) {
- throw new IllegalArgumentException("itemsPerPage must be > 0!");
- }
-
+ public PagingIterable<Document> getCheckedOutDocs(OperationContext context) {
final NavigationService navigationService = getBinding().getNavigationService();
final ObjectFactory objectFactory = getObjectFactory();
final OperationContext ctxt = new OperationContextImpl(context);
- return new CollectionIterable<Document>(new AbstractPageFetch<Document>() {
+ return new CollectionIterable<Document>(new AbstractPageFetch<Document>(ctxt.getMaxItemsPerPage()) {
@Override
protected AbstractPageFetch.PageFetchResult<Document> fetchPage(long skipCount) {
@@ -261,7 +257,7 @@ public class PersistentSessionImpl imple
// get all checked out documents
ObjectList checkedOutDocs = navigationService.getCheckedOutDocs(getRepositoryId(), null, ctxt
.getFilterString(), ctxt.getOrderBy(), ctxt.isIncludeAllowableActions(), ctxt
- .getIncludeRelationships(), ctxt.getRenditionFilterString(), BigInteger.valueOf(itemsPerPage),
+ .getIncludeRelationships(), ctxt.getRenditionFilterString(), BigInteger.valueOf(this.pageSize),
BigInteger.valueOf(skipCount), null);
// convert objects
@@ -292,7 +288,7 @@ public class PersistentSessionImpl imple
* org.apache.opencmis.client.api.Session#getContentChanges(java.lang.String
* , int)
*/
- public PagingIterable<ChangeEvent> getContentChanges(String changeLogToken, int itemsPerPage) {
+ public PagingIterable<ChangeEvent> getContentChanges(String changeLogToken) {
throw new CmisRuntimeException("not implemented");
}
@@ -336,9 +332,10 @@ public class PersistentSessionImpl imple
*/
public OperationContext createOperationContext(Set<String> filter, boolean includeAcls,
boolean includeAllowableActions, boolean includePolicies, IncludeRelationships includeRelationships,
- Set<String> renditionFilter, boolean includePathSegments, String orderBy, boolean cacheEnabled) {
+ Set<String> renditionFilter, boolean includePathSegments, String orderBy, boolean cacheEnabled,
+ int maxItemsPerPage) {
return new OperationContextImpl(filter, includeAcls, includeAllowableActions, includePolicies,
- includeRelationships, renditionFilter, includePathSegments, orderBy, cacheEnabled);
+ includeRelationships, renditionFilter, includePathSegments, orderBy, cacheEnabled, maxItemsPerPage);
}
/*
@@ -488,6 +485,7 @@ public class PersistentSessionImpl imple
*
*
*
+ *
* @seeorg.apache.opencmis.client.api.Session#getRootFolder(org.apache.opencmis
* .client.api. OperationContext)
*/
@@ -509,16 +507,11 @@ public class PersistentSessionImpl imple
* org.apache.opencmis.client.api.Session#getTypeChildren(java.lang.String,
* boolean, int)
*/
- public PagingIterable<ObjectType> getTypeChildren(final String typeId, final boolean includePropertyDefinitions,
- final int itemsPerPage) {
- if (itemsPerPage < 1) {
- throw new IllegalArgumentException("itemsPerPage must be > 0!");
- }
-
+ public PagingIterable<ObjectType> getTypeChildren(final String typeId, final boolean includePropertyDefinitions) {
final RepositoryService repositoryService = getBinding().getRepositoryService();
final ObjectFactory objectFactory = this.getObjectFactory();
- return new CollectionIterable<ObjectType>(new AbstractPageFetch<ObjectType>() {
+ return new CollectionIterable<ObjectType>(new AbstractPageFetch<ObjectType>(this.getDefaultContext().getMaxItemsPerPage()) {
@Override
protected AbstractPageFetch.PageFetchResult<ObjectType> fetchPage(long skipCount) {
@@ -526,7 +519,7 @@ public class PersistentSessionImpl imple
// fetch the data
TypeDefinitionList tdl = repositoryService.getTypeChildren(
PersistentSessionImpl.this.getRepositoryId(), typeId, includePropertyDefinitions, BigInteger
- .valueOf(itemsPerPage), BigInteger.valueOf(skipCount), null);
+ .valueOf(this.pageSize), BigInteger.valueOf(skipCount), null);
// convert type definitions
List<ObjectType> page = new ArrayList<ObjectType>(tdl.getList().size());
@@ -590,9 +583,8 @@ public class PersistentSessionImpl imple
* @see org.apache.opencmis.client.api.Session#query(java.lang.String,
* boolean, int)
*/
- public PagingIterable<QueryResult> query(final String statement, final boolean searchAllVersions,
- final int itemsPerPage) {
- return query(statement, searchAllVersions, getDefaultContext(), itemsPerPage);
+ public PagingIterable<QueryResult> query(final String statement, final boolean searchAllVersions) {
+ return query(statement, searchAllVersions, getDefaultContext());
}
/*
@@ -602,17 +594,13 @@ public class PersistentSessionImpl imple
* boolean, org.apache.opencmis.client.api.OperationContext, int)
*/
public PagingIterable<QueryResult> query(final String statement, final boolean searchAllVersions,
- OperationContext context, final int itemsPerPage) {
-
- if (itemsPerPage < 1) {
- throw new IllegalArgumentException("itemsPerPage must be > 0!");
- }
+ OperationContext context) {
final DiscoveryService discoveryService = getBinding().getDiscoveryService();
final ObjectFactory objectFactory = this.getObjectFactory();
final OperationContext ctxt = new OperationContextImpl(context);
- return new CollectionIterable<QueryResult>(new AbstractPageFetch<QueryResult>() {
+ return new CollectionIterable<QueryResult>(new AbstractPageFetch<QueryResult>(ctxt.getMaxItemsPerPage()) {
@Override
protected AbstractPageFetch.PageFetchResult<QueryResult> fetchPage(long skipCount) {
@@ -620,7 +608,7 @@ public class PersistentSessionImpl imple
// fetch the data
ObjectList resultList = discoveryService.query(getRepositoryId(), statement, searchAllVersions, ctxt
.isIncludeAllowableActions(), ctxt.getIncludeRelationships(), ctxt.getRenditionFilterString(),
- BigInteger.valueOf(itemsPerPage), BigInteger.valueOf(skipCount), null);
+ BigInteger.valueOf(this.pageSize), BigInteger.valueOf(skipCount), null);
// convert type definitions
List<QueryResult> page = new ArrayList<QueryResult>();
@@ -845,4 +833,5 @@ public class PersistentSessionImpl imple
return createObjectId(newId);
}
+
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/DocumentTypeImpl.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/objecttype/DocumentTypeImpl.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/DocumentTypeImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/DocumentTypeImpl.java Wed May 5 07:03:12 2010
@@ -46,8 +46,8 @@ public class DocumentTypeImpl extends Do
return helper.getBaseType();
}
- public PagingIterable<ObjectType> getChildren(int itemsPerPage) {
- return helper.getChildren(itemsPerPage);
+ public PagingIterable<ObjectType> getChildren() {
+ return helper.getChildren();
}
public List<Tree<ObjectType>> getDescendants(int depth) {
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/FolderTypeImpl.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/objecttype/FolderTypeImpl.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/FolderTypeImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/FolderTypeImpl.java Wed May 5 07:03:12 2010
@@ -46,8 +46,8 @@ public class FolderTypeImpl extends Fold
return helper.getBaseType();
}
- public PagingIterable<ObjectType> getChildren(int itemsPerPage) {
- return helper.getChildren(itemsPerPage);
+ public PagingIterable<ObjectType> getChildren() {
+ return helper.getChildren();
}
public List<Tree<ObjectType>> getDescendants(int depth) {
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/ObjectTypeHelper.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/objecttype/ObjectTypeHelper.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/ObjectTypeHelper.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/ObjectTypeHelper.java Wed May 5 07:03:12 2010
@@ -75,8 +75,8 @@ public class ObjectTypeHelper {
return parentType;
}
- public PagingIterable<ObjectType> getChildren(int itemsPerPage) {
- return session.getTypeChildren(objectType.getId(), true, itemsPerPage);
+ public PagingIterable<ObjectType> getChildren() {
+ return session.getTypeChildren(objectType.getId(), true);
}
public List<Tree<ObjectType>> getDescendants(int depth) {
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/PolicyTypeImpl.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/objecttype/PolicyTypeImpl.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/PolicyTypeImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/PolicyTypeImpl.java Wed May 5 07:03:12 2010
@@ -46,8 +46,8 @@ public class PolicyTypeImpl extends Poli
return helper.getBaseType();
}
- public PagingIterable<ObjectType> getChildren(int itemsPerPage) {
- return helper.getChildren(itemsPerPage);
+ public PagingIterable<ObjectType> getChildren() {
+ return helper.getChildren();
}
public List<Tree<ObjectType>> getDescendants(int depth) {
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/RelationshipTypeImpl.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/objecttype/RelationshipTypeImpl.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/RelationshipTypeImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/RelationshipTypeImpl.java Wed May 5 07:03:12 2010
@@ -49,8 +49,8 @@ public class RelationshipTypeImpl extend
return helper.getBaseType();
}
- public PagingIterable<ObjectType> getChildren(int itemsPerPage) {
- return helper.getChildren(itemsPerPage);
+ public PagingIterable<ObjectType> getChildren() {
+ return helper.getChildren();
}
public List<Tree<ObjectType>> getDescendants(int depth) {
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractPageFetch.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/AbstractPageFetch.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractPageFetch.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractPageFetch.java Wed May 5 07:03:12 2010
@@ -28,6 +28,12 @@ import java.util.List;
*/
public abstract class AbstractPageFetch<T> {
+ protected long pageSize;
+
+ public AbstractPageFetch(long pageSize) {
+ this.pageSize = pageSize;
+ }
+
/**
* Fetches the given page from the server.
*
@@ -62,4 +68,8 @@ public abstract class AbstractPageFetch<
}
}
+ public void setPageSize(int maxNumItems) {
+ this.pageSize = maxNumItems;
+ }
+
}
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=941171&r1=941170&r2=941171&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 07:03:12 2010
@@ -75,4 +75,14 @@ public class CollectionIterable<T> imple
public PagingIterable<T> getPage() {
return new PageIterable<T>(skipCount, pageFetch);
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.chemistry.opencmis.client.api.PagingIterable#getPage(int)
+ */
+ public PagingIterable<T> getPage(int maxNumItems) {
+ this.pageFetch.setPageSize(maxNumItems);
+ return new PageIterable<T>(skipCount, pageFetch);
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/PageIterable.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/PageIterable.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/PageIterable.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/PageIterable.java Wed May 5 07:03:12 2010
@@ -61,7 +61,8 @@ public class PageIterable<T> implements
/*
* (non-Javadoc)
*
- * @see org.apache.chemistry.opencmis.client.api.util.PagingIterable#skipTo(long)
+ * @see
+ * org.apache.chemistry.opencmis.client.api.util.PagingIterable#skipTo(long)
*/
public PagingIterable<T> skipTo(long position) {
return new CollectionIterable<T>(position, pageFetch);
@@ -69,9 +70,19 @@ public class PageIterable<T> implements
/*
* (non-Javadoc)
+ *
* @see org.apache.chemistry.opencmis.client.api.PagingIterable#getPage()
*/
public PagingIterable<T> getPage() {
return new PageIterable<T>(skipCount, pageFetch);
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.chemistry.opencmis.client.api.PagingIterable#getPage(int)
+ */
+ public PagingIterable<T> getPage(int maxNumItems) {
+ return new PageIterable<T>(skipCount, pageFetch);
+ }
}
Copied: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/ItemIterableTest.java (from r940777, incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.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?p2=incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/ItemIterableTest.java&p1=incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java&r1=940777&r2=941171&rev=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.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 07:03:12 2010
@@ -20,35 +20,52 @@ package org.apache.chemistry.opencmis.cl
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
+import java.util.Properties;
import org.apache.chemistry.opencmis.client.api.PagingIterable;
import org.apache.chemistry.opencmis.client.api.PagingIterator;
import org.apache.chemistry.opencmis.client.runtime.util.AbstractPageFetch;
import org.apache.chemistry.opencmis.client.runtime.util.CollectionIterable;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.PropertyConfigurator;
import org.junit.Test;
-public class PagingListTest {
+public class ItemIterableTest {
+ private static Log log = LogFactory.getLog(ItemIterableTest.class);
+ static {
+ Properties p = new Properties();
+ try {
+ p.load(ItemIterableTest.class.getResourceAsStream("/log4j.properties"));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ PropertyConfigurator.configure(p);
+
+ }
private String[] data10 = { "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9" };
private String[] data1 = { "A0" };
private String[] data0 = {};
- private PagingIterable<String> getIterable(final String[] data, final long pageSize) {
- return new CollectionIterable<String>(new AbstractPageFetch<String>() {
+ private PagingIterable<String> getIterable(final String[] data, long pageSize) {
+ return new CollectionIterable<String>(new AbstractPageFetch<String>(pageSize) {
@Override
protected PageFetchResult<String> fetchPage(long skipCount) {
Boolean hasMoreItems = Boolean.TRUE;
List<String> page = new ArrayList<String>();
- System.out.print("(" + skipCount + "|" + pageSize + ") ");
+ ItemIterableTest.log.info("(" + skipCount + "|" + this.pageSize + ") ");
int from = (int) skipCount;
- int to = (int) (skipCount + pageSize);
+ int to = (int) (skipCount + this.pageSize);
if (to >= data.length) {
to = data.length;
@@ -90,6 +107,17 @@ public class PagingListTest {
}
@Test
+ public void loopSubPage() {
+ this.loopSubPage(this.data10, 0, 3, 5);
+ this.loopSubPage(this.data10, 2, 3, 5);
+ this.loopSubPage(this.data10, 9, 3, 5);
+ this.loopSubPage(this.data10, 10, 3, 5);
+
+ this.loopSubPage(this.data10, 2, 3, 3);
+ this.loopSubPage(this.data10, 2, 1000, 1000);
+ }
+
+ @Test
public void loopSkip() {
this.loopSkip(this.data10, 0, 5);
this.loopSkip(this.data10, 1, 5);
@@ -147,7 +175,7 @@ public class PagingListTest {
@Test
public void totalNumItems() {
- System.out.println("\ntotalNumItems");
+ ItemIterableTest.log.info("totalNumItems");
int pageSize = 5;
PagingIterable<String> p = this.getIterable(this.data10, pageSize);
@@ -164,8 +192,8 @@ public class PagingListTest {
@Test
public void hasMoreItems() {
- System.out.println("\ntotalHasMoreItems");
-
+ ItemIterableTest.log.info("totalHasMoreItems");
+
int pageSize = 5;
PagingIterable<String> p = this.getIterable(this.data10, pageSize);
assertNotNull(p);
@@ -181,8 +209,8 @@ public class PagingListTest {
@Test
public void pageNumItems() {
- System.out.println("\ntotalPageNumItems");
-
+ ItemIterableTest.log.info("totalPageNumItems");
+
int pageSize = 7;
PagingIterable<String> p = this.getIterable(this.data10, pageSize);
assertNotNull(p);
@@ -196,8 +224,31 @@ public class PagingListTest {
assertEquals(this.data10.length - pageSize, i.getPageNumItems());
}
+ private void loopSubPage(String[] data, int skipCount, int maxItems, int pageSize) {
+ ItemIterableTest.log.info("loopSubPage (" + skipCount + ", " + maxItems + ", " + pageSize + ")");
+ String msg = "";
+
+ PagingIterable<String> p = this.getIterable(data, pageSize);
+ assertNotNull(p);
+ PagingIterable<String> pp = p.skipTo(skipCount);
+ assertNotNull(pp);
+ PagingIterable<String> ppp = pp.getPage(maxItems);
+ assertNotNull(ppp);
+
+ int count = 0;
+ for (String s : ppp) {
+ assertNotNull(s);
+ assertEquals("A" + (count + skipCount), s);
+ msg += (s + " ");
+ count++;
+ }
+ ItemIterableTest.log.info(msg);
+ assertTrue(count <= pageSize);
+ }
+
private void loopSkip(String[] data, int skipCount, int pageSize) {
- System.out.println("\nloopSkip (" + skipCount + ", " + pageSize + ")");
+ ItemIterableTest.log.info("loopSkip (" + skipCount + ", " + pageSize + ")");
+ String msg = "";
PagingIterable<String> p = this.getIterable(data, pageSize);
assertNotNull(p);
@@ -208,15 +259,16 @@ public class PagingListTest {
for (String s : pp) {
assertNotNull(s);
assertEquals("A" + (count + skipCount), s);
- System.out.print(s + " ");
+ msg += (s + " ");
count++;
}
- System.out.print("\n");
+ ItemIterableTest.log.info(msg);
assertEquals(data.length - skipCount, count);
}
private void loopAll(String[] data, int pageSize) {
- System.out.println("\nloopAll (" + pageSize + ")");
+ ItemIterableTest.log.info("loopAll (" + pageSize + ")");
+ String msg = "";
PagingIterable<String> p = this.getIterable(data, pageSize);
assertNotNull(p);
@@ -225,15 +277,16 @@ public class PagingListTest {
for (String s : p) {
assertNotNull(s);
assertEquals("A" + count, s);
- System.out.print(s + " ");
+ msg += (s + " ");
count++;
}
- System.out.print("\n");
+ ItemIterableTest.log.info(msg);
assertEquals(data.length, count);
}
private void loopPage(String[] data, int skipCount, int pageSize) {
- System.out.println("\nloopPage (" + skipCount + ", " + pageSize + ")");
+ ItemIterableTest.log.info("loopPage (" + skipCount + ", " + pageSize + ")");
+ String msg = "";
PagingIterable<String> p = this.getIterable(data, pageSize);
assertNotNull(p);
@@ -244,10 +297,10 @@ public class PagingListTest {
for (String s : pp) {
assertNotNull(s);
assertEquals("A" + (count + skipCount), s);
- System.out.print(s + " ");
+ msg += (s + " ");
count++;
}
- System.out.print("\n");
+ ItemIterableTest.log.info(msg);
assertEquals(Math.min(data.length - skipCount, pageSize), count);
}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/ItemIterableTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyDiscoverIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyDiscoverIT.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyDiscoverIT.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyDiscoverIT.java Wed May 5 07:03:12 2010
@@ -40,7 +40,27 @@ public class ReadOnlyDiscoverIT extends
ReadOnlyDiscoverIT.log.info("queries not supported");
break;
default:
- PagingIterable<QueryResult> resultSet = this.session.query(FixtureData.QUERY.toString(), false, 2);
+ PagingIterable<QueryResult> resultSet = this.session.query(FixtureData.QUERY.toString(), false);
+ Assert.assertNotNull(resultSet);
+ // Assert.assertFalse(resultSet.isEmpty());
+ for (QueryResult o : resultSet) {
+ Assert.assertNotNull(o);
+ }
+
+ break;
+ }
+
+ }
+ @Test
+ public void querySkip() {
+ CapabilityQuery query = this.session.getRepositoryInfo().getCapabilities().getQueryCapability();
+
+ switch (query) {
+ case NONE:
+ ReadOnlyDiscoverIT.log.info("queries not supported");
+ break;
+ default:
+ PagingIterable<QueryResult> resultSet = this.session.query(FixtureData.QUERY.toString(), false).skipTo(2).getPage(2);
Assert.assertNotNull(resultSet);
// Assert.assertFalse(resultSet.isEmpty());
for (QueryResult o : resultSet) {
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyNavigationIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyNavigationIT.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyNavigationIT.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyNavigationIT.java Wed May 5 07:03:12 2010
@@ -32,12 +32,26 @@ import org.junit.Test;
public class ReadOnlyNavigationIT extends AbstractSessionTest {
@Test
+ public void navigateChildrenSkip() {
+ String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
+ Folder folder = (Folder) this.session.getObjectByPath(path);
+ Assert.assertNotNull("folder not found: " + path, folder);
+
+ PagingIterable<CmisObject> pl = folder.getChildren().skipTo(2).getPage(2);
+ Assert.assertNotNull(pl);
+
+ for (CmisObject o : pl) {
+ Assert.assertNotNull(o);
+ }
+ }
+
+ @Test
public void navigateChildrenMin() {
String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
Folder folder = (Folder) this.session.getObjectByPath(path);
Assert.assertNotNull("folder not found: " + path, folder);
- PagingIterable<CmisObject> pl = folder.getChildren(1);
+ PagingIterable<CmisObject> pl = folder.getChildren();
Assert.assertNotNull(pl);
for (CmisObject o : pl) {
@@ -51,7 +65,8 @@ public class ReadOnlyNavigationIT extend
Folder folder = (Folder) this.session.getObjectByPath(path);
Assert.assertNotNull("folder not found: " + path, folder);
- PagingIterable<CmisObject> pl = folder.getChildren(1000);
+ this.session.getDefaultContext().setMaxItemsPerPage(1000);
+ PagingIterable<CmisObject> pl = folder.getChildren();
Assert.assertNotNull(pl);
for (CmisObject o : pl) {
@@ -65,7 +80,8 @@ public class ReadOnlyNavigationIT extend
Folder folder = (Folder) this.session.getObjectByPath(path);
Assert.assertNotNull("folder not found: " + path, folder);
- PagingIterable<CmisObject> pl = folder.getChildren(2);
+ this.session.getDefaultContext().setMaxItemsPerPage(2);
+ PagingIterable<CmisObject> pl = folder.getChildren();
Assert.assertNotNull(pl);
for (CmisObject o : pl) {
@@ -175,7 +191,8 @@ public class ReadOnlyNavigationIT extend
Folder folder = (Folder) this.session.getObjectByPath(path);
Assert.assertNotNull("folder not found: " + path, folder);
- PagingIterable<CmisObject> pl = folder.getChildren(2);
+ this.session.getDefaultContext().setMaxItemsPerPage(2);
+ PagingIterable<CmisObject> pl = folder.getChildren();
Assert.assertNotNull(pl);
CmisObject firstObject = pl.iterator().next();
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyTypeIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyTypeIT.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyTypeIT.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/ReadOnlyTypeIT.java Wed May 5 07:03:12 2010
@@ -82,7 +82,8 @@ public class ReadOnlyTypeIT extends Abst
public void readTypeChildrenDocument() {
ObjectType otd = this.session.getTypeDefinition(ObjectType.DOCUMENT_BASETYPE_ID);
Assert.assertNotNull(otd);
- PagingIterable<ObjectType> pc = this.session.getTypeChildren(otd.getId(), true, 2);
+ this.session.getDefaultContext().setMaxItemsPerPage(2);
+ PagingIterable<ObjectType> pc = this.session.getTypeChildren(otd.getId(), true);
Assert.assertNotNull(pc);
for (ObjectType ot1 : pc) {
@@ -92,10 +93,26 @@ public class ReadOnlyTypeIT extends Abst
}
@Test
+ public void readTypeChildrenDocumentSkip() {
+ ObjectType otd = this.session.getTypeDefinition(ObjectType.DOCUMENT_BASETYPE_ID);
+ Assert.assertNotNull(otd);
+ this.session.getDefaultContext().setMaxItemsPerPage(2);
+ PagingIterable<ObjectType> pc = this.session.getTypeChildren(otd.getId(), true);
+ Assert.assertNotNull(pc);
+
+ PagingIterable<ObjectType> pcc = pc.skipTo(2).getPage(2);
+ for (ObjectType ot1 : pcc) {
+ ObjectType ot2 = this.session.getTypeDefinition(ot1.getId());
+ Assert.assertEquals(ot1.getId(), ot2.getId());
+ }
+ }
+
+ @Test
public void readTypeChildrenFolder() {
ObjectType otd = this.session.getTypeDefinition(ObjectType.FOLDER_BASETYPE_ID);
Assert.assertNotNull(otd);
- PagingIterable<ObjectType> pc = this.session.getTypeChildren(otd.getId(), true, 2);
+ this.session.getDefaultContext().setMaxItemsPerPage(2);
+ PagingIterable<ObjectType> pc = this.session.getTypeChildren(otd.getId(), true);
Assert.assertNotNull(pc);
for (ObjectType ot1 : pc) {
@@ -105,6 +122,21 @@ public class ReadOnlyTypeIT extends Abst
}
@Test
+ public void readTypeChildrenFolderSkip() {
+ ObjectType otd = this.session.getTypeDefinition(ObjectType.FOLDER_BASETYPE_ID);
+ Assert.assertNotNull(otd);
+ this.session.getDefaultContext().setMaxItemsPerPage(2);
+ PagingIterable<ObjectType> pc = this.session.getTypeChildren(otd.getId(), true);
+ Assert.assertNotNull(pc);
+
+ PagingIterable<ObjectType> pcc = pc.skipTo(0).getPage(2);
+ for (ObjectType ot1 : pcc) {
+ ObjectType ot2 = this.session.getTypeDefinition(ot1.getId());
+ Assert.assertEquals(ot1, ot2);
+ }
+ }
+
+ @Test
public void readTypeDescandantsDocument() {
ObjectType otd = this.session.getTypeDefinition(ObjectType.DOCUMENT_BASETYPE_ID);
Assert.assertNotNull(otd);
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectRelationIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectRelationIT.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectRelationIT.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectRelationIT.java Wed May 5 07:03:12 2010
@@ -57,7 +57,7 @@ public class WriteObjectRelationIT exten
ObjectType ot = document1.getType();
PagingIterable<Relationship> relations = document1.getRelationships(true, RelationshipDirection.EITHER, ot,
- this.session.getDefaultContext(), 10);
+ this.session.getDefaultContext());
for (Relationship r : relations) {
assertNotNull(r);
assertEquals(id, r.getId());
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectVersionIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectVersionIT.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectVersionIT.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/WriteObjectVersionIT.java Wed May 5 07:03:12 2010
@@ -26,32 +26,56 @@ import org.apache.chemistry.opencmis.cli
import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.ObjectId;
import org.apache.chemistry.opencmis.client.api.PagingIterable;
+import org.junit.Before;
import org.junit.Test;
public class WriteObjectVersionIT extends AbstractSessionTest {
- @Test
- public void checkOutDocs() {
+ private ObjectId checkdOutId = null;
+
+ @Before
+ public void checkOutVersionableDocument() {
/* check out one versionable document */
String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + FixtureData.DOCUMENT1_NAME;
Document document = (Document) this.session.getObjectByPath(path);
assertNotNull("Document not found: " + path, document);
DocumentType dt = (DocumentType) document.getType();
assertNotNull(dt);
- ObjectId id = null;
if (dt.isVersionable() != null && dt.isVersionable().booleanValue()) {
- id = document.checkOut();
+ this.checkdOutId = document.checkOut();
}
+ }
+
+ @Test
+ public void checkOutDocs() {
/* get all verchecked out docs which should be exactly one or zero */
Folder f = this.session.getRootFolder();
assertNotNull(f);
- PagingIterable<Document> pi = f.getCheckedOutDocs(10);
+ PagingIterable<Document> pi = f.getCheckedOutDocs();
assertNotNull(pi);
for (Document d : pi) {
assertNotNull(d);
- assertEquals(id, d.getId());
+ assertEquals(this.checkdOutId, d.getId());
+ break; // check only first and only loop entry
+ }
+
+ }
+
+ @Test
+ public void checkOutDocsSkip() {
+
+ /* get all verchecked out docs which should be exactly one or zero */
+ Folder f = this.session.getRootFolder();
+ assertNotNull(f);
+ PagingIterable<Document> pi = f.getCheckedOutDocs();
+ assertNotNull(pi);
+ // test skipTo and getPage
+ PagingIterable<Document> pii = pi.skipTo(2).getPage(2);
+ for (Document d : pii) {
+ assertNotNull(d);
+ assertEquals(this.checkdOutId, d.getId());
break; // check only first and only loop entry
}
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/sample/AbstractSampleIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/sample/AbstractSampleIT.java?rev=941171&r1=941170&r2=941171&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/sample/AbstractSampleIT.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/sample/AbstractSampleIT.java Wed May 5 07:03:12 2010
@@ -103,7 +103,7 @@ public abstract class AbstractSampleIT {
checkBaseType(folderBaseId, BaseTypeId.CMIS_FOLDER, folderType);
// get base types via getTypesChildren
- PagingIterable<ObjectType> baseTypes = getSession().getTypeChildren(null, true, 10);
+ PagingIterable<ObjectType> baseTypes = getSession().getTypeChildren(null, true);
assertNotNull(baseTypes);
boolean hasDocumentBaseType = false;