You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2009/07/15 17:59:23 UTC
svn commit: r794314 - in /incubator/chemistry/trunk/chemistry:
chemistry-api/src/main/java/org/apache/chemistry/
chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/
chemistry-atompub-client/src/main/java/org/apache/chemistry/ato...
Author: fguillaume
Date: Wed Jul 15 15:59:23 2009
New Revision: 794314
URL: http://svn.apache.org/viewvc?rev=794314&view=rev
Log:
CMIS-28: allow passing all SPI parameters to Connector#postQuery
Modified:
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/Connector.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/DefaultIOProvider.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/HttpClientConnector.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/IOProvider.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISQueryFeed.java
incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java
incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/xml/stax/XMLWriter.java
Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java?rev=794314&r1=794313&r2=794314&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java Wed Jul 15 15:59:23 2009
@@ -197,9 +197,6 @@
* @param includeAllowableActions {@code true} to include allowable actions
* @param includeRelationships {@code true} if relationships should be
* included as well
- * @param maxItems the maximum number of objects to returned, or {@code 0}
- * for a repository-specific default
- * @param skipCount the skip count
* @return the collection of parent folders
*/
Collection<ObjectEntry> getObjectParents(ObjectId object, String filter,
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java?rev=794314&r1=794313&r2=794314&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java Wed Jul 15 15:59:23 2009
@@ -14,6 +14,7 @@
* Authors:
* Bogdan Stefanescu, Nuxeo
* Florent Guillaume, Nuxeo
+ * Ugo Cei, Sourcesense
*/
package org.apache.chemistry.atompub.client;
@@ -352,7 +353,8 @@
boolean includeRelationships, int maxItems, int skipCount,
boolean[] hasMoreItems) {
String href = repository.getCollectionHref(CMIS.COL_QUERY);
- Response resp = connector.postQuery(new Request(href), statement);
+ Response resp = connector.postQuery(new Request(href), statement,
+ searchAllVersions, maxItems, skipCount, includeAllowableActions);
if (!resp.isOk()) {
throw new ContentManagerException(
"Remote server returned error code: "
@@ -366,7 +368,7 @@
boolean searchAllVersions) {
boolean[] hasMoreItems = new boolean[1];
Collection<ObjectEntry> res = query(statement, searchAllVersions,
- false, false, 0, 0, hasMoreItems);
+ false, false, -1, 0, hasMoreItems);
List<CMISObject> objects = new ArrayList<CMISObject>(res.size());
for (ObjectEntry e : res) {
objects.add(APPObject.construct((APPObjectEntry) e));
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/Connector.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/Connector.java?rev=794314&r1=794313&r2=794314&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/Connector.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/Connector.java Wed Jul 15 15:59:23 2009
@@ -62,12 +62,15 @@
Response putObject(Request req, ObjectEntry entry)
throws ContentManagerException;
- Response putQuery(Request req, String query) throws ContentManagerException;
+ Response putQuery(Request req, String query, boolean searchAllVersions,
+ long maxItems, long skipCount, boolean includeAllowableActions)
+ throws ContentManagerException;
Response postObject(Request req, ObjectEntry entry)
throws ContentManagerException;
- Response postQuery(Request req, String query)
+ Response postQuery(Request req, String query, boolean searchAllVersions,
+ long maxItems, long skipCount, boolean includeAllowableActions)
throws ContentManagerException;
}
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/DefaultIOProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/DefaultIOProvider.java?rev=794314&r1=794313&r2=794314&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/DefaultIOProvider.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/DefaultIOProvider.java Wed Jul 15 15:59:23 2009
@@ -13,6 +13,8 @@
*
* Authors:
* Bogdan Stefanescu, Nuxeo
+ * Florent Guillaume, Nuxeo
+ * Ugo Cei, Sourcesense
*/
package org.apache.chemistry.atompub.client.connector;
@@ -51,8 +53,6 @@
protected APPObjectEntryWriter objectWriter = new APPObjectEntryWriter();
- protected QueryWriter queryWriter = new QueryWriter();
-
public EntryReader<? extends ObjectEntry> getObjectEntryReader() {
return objectReader;
}
@@ -77,7 +77,13 @@
return objectWriter;
}
- public XmlObjectWriter<String> getQueryWriter() {
+ public XmlObjectWriter<String> getQueryWriter(boolean searchAllVersions,
+ long maxItems, long skipCount, boolean includeAllowableActions) {
+ QueryWriter queryWriter = new QueryWriter();
+ queryWriter.setSearchAllVersions(searchAllVersions);
+ queryWriter.setMaxItems(maxItems);
+ queryWriter.setSkipCount(skipCount);
+ queryWriter.setIncludeAllowableActions(includeAllowableActions);
return queryWriter;
}
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/HttpClientConnector.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/HttpClientConnector.java?rev=794314&r1=794313&r2=794314&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/HttpClientConnector.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/HttpClientConnector.java Wed Jul 15 15:59:23 2009
@@ -13,6 +13,7 @@
*
* Authors:
* Bogdan Stefanescu, Nuxeo
+ * Ugo Cei, Sourcesense
*/
package org.apache.chemistry.atompub.client.connector;
@@ -210,9 +211,11 @@
return put(req, io.getObjectEntryWriter(), entry);
}
- public Response putQuery(Request req, String query)
- throws ContentManagerException {
- return put(req, io.getQueryWriter(), query);
+ public Response putQuery(Request req, String query,
+ boolean searchAllVersions, long maxItems, long skipCount,
+ boolean includeAllowableActions) throws ContentManagerException {
+ return put(req, io.getQueryWriter(searchAllVersions, maxItems,
+ skipCount, includeAllowableActions), query);
}
public Response postObject(Request req, ObjectEntry entry)
@@ -220,9 +223,11 @@
return post(req, io.getObjectEntryWriter(), entry);
}
- public Response postQuery(Request req, String query)
- throws ContentManagerException {
- return post(req, io.getQueryWriter(), query);
+ public Response postQuery(Request req, String query,
+ boolean searchAllVersions, long maxItems, long skipCount,
+ boolean includeAllowableActions) throws ContentManagerException {
+ return post(req, io.getQueryWriter(searchAllVersions, maxItems,
+ skipCount, includeAllowableActions), query);
}
public static class XmlObjectWriterRequestEntity<T> implements
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/IOProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/IOProvider.java?rev=794314&r1=794313&r2=794314&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/IOProvider.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/IOProvider.java Wed Jul 15 15:59:23 2009
@@ -13,6 +13,7 @@
*
* Authors:
* Bogdan Stefanescu, Nuxeo
+ * Ugo Cei, Sourcesense
*/
package org.apache.chemistry.atompub.client.connector;
@@ -27,7 +28,8 @@
import org.apache.chemistry.atompub.client.stax.XmlObjectWriter;
/**
- * This abstracts the operations used to read and write objects from XML streams.
+ * This abstracts the operations used to read and write objects from XML
+ * streams.
*/
public interface IOProvider {
@@ -43,6 +45,7 @@
XmlObjectWriter<ObjectEntry> getObjectEntryWriter();
- XmlObjectWriter<String> getQueryWriter();
+ XmlObjectWriter<String> getQueryWriter(boolean searchAllVersions,
+ long maxItems, long skipCount, boolean includeAllowableActions);
}
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java?rev=794314&r1=794313&r2=794314&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java Wed Jul 15 15:59:23 2009
@@ -13,6 +13,7 @@
*
* Authors:
* Florent Guillaume, Nuxeo
+ * Ugo Cei, Sourcesense
*/
package org.apache.chemistry.atompub.client.stax;
@@ -26,6 +27,44 @@
*/
public class QueryWriter extends AbstractXmlObjectWriter<String> {
+ protected boolean searchAllVersions;
+
+ protected long maxItems = -1;
+
+ protected long skipCount;
+
+ protected boolean includeAllowableActions;
+
+ public void setSearchAllVersions(boolean searchAllVersions) {
+ this.searchAllVersions = searchAllVersions;
+ }
+
+ /**
+ * Sets the max number of items to return.
+ * <p>
+ * The default, {@code -1}, means that no max number will be sent
+ *
+ * @param maxItems the max number of items
+ */
+ public void setMaxItems(long maxItems) {
+ this.maxItems = maxItems;
+ }
+
+ /**
+ * Sets the skip count.
+ * <p>
+ * The default is {@code 0}.
+ *
+ * @param skipCount the skip count
+ */
+ public void setSkipCount(long skipCount) {
+ this.skipCount = skipCount;
+ }
+
+ public void setIncludeAllowableActions(boolean includeAllowableActions) {
+ this.includeAllowableActions = includeAllowableActions;
+ }
+
@Override
public String getContentType() {
return "application/cmisquery+xml";
@@ -37,9 +76,13 @@
xw.element(CMIS.QUERY);
xw.start();
xw.element(CMIS.STATEMENT).econtent(statement);
- xw.element(CMIS.SEARCH_ALL_VERSIONS).content("false");
- xw.element(CMIS.PAGE_SIZE).content("0");
- xw.element(CMIS.SKIP_COUNT).content("0");
+ xw.element(CMIS.SEARCH_ALL_VERSIONS).content(searchAllVersions);
+ if (maxItems > -1) {
+ xw.element(CMIS.PAGE_SIZE).content(maxItems);
+ }
+ xw.element(CMIS.SKIP_COUNT).content(skipCount);
+ xw.element(CMIS.INCLUDE_ALLOWABLE_ACTIONS).content(
+ includeAllowableActions);
xw.end();
xw.end();
}
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISQueryFeed.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISQueryFeed.java?rev=794314&r1=794313&r2=794314&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISQueryFeed.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISQueryFeed.java Wed Jul 15 15:59:23 2009
@@ -96,7 +96,7 @@
boolean searchAllVersions = false;
boolean includeAllowableActions = false;
boolean includeRelationships = false;
- int maxItems = 0;
+ int maxItems = -1;
int skipCount = 0;
boolean[] hasMoreItems = new boolean[1];
Collection<ObjectEntry> results = spi.query(statement,
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java?rev=794314&r1=794313&r2=794314&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java Wed Jul 15 15:59:23 2009
@@ -185,10 +185,12 @@
public static final QName SEARCH_ALL_VERSIONS = CMISName("searchAllVersions");
- public static final QName PAGE_SIZE = CMISName("pageSize");
+ public static final QName PAGE_SIZE = CMISName("pageSize"); // TODO rename to maxItems
public static final QName SKIP_COUNT = CMISName("skipCount");
+ public static final QName INCLUDE_ALLOWABLE_ACTIONS = CMISName("includeAllowableActions");
+
/*
* ----- CMIS Collection Types -----
*/
Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java?rev=794314&r1=794313&r2=794314&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java Wed Jul 15 15:59:23 2009
@@ -276,7 +276,7 @@
hasMoreItems[0] = false;
return Collections.emptyList();
}
- if (maxItems == 0) {
+ if (maxItems <= 0) {
maxItems = total;
}
int toIndex = skipCount + maxItems;
Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/xml/stax/XMLWriter.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/xml/stax/XMLWriter.java?rev=794314&r1=794313&r2=794314&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/xml/stax/XMLWriter.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/xml/stax/XMLWriter.java Wed Jul 15 15:59:23 2009
@@ -14,6 +14,8 @@
* Authors:
* Original org.apache.commons.betwixt.XMLUtils authors
* Bogdan Stefanescu, Nuxeo
+ * Florent Guillaume, Nuxeo
+ * Ugo Cei, Sourcesense
*/
package org.apache.chemistry.xml.stax;
@@ -246,6 +248,14 @@
return content(formatDate(value));
}
+ public XMLWriter content(int value) throws IOException {
+ return content(String.valueOf(value));
+ }
+
+ public XMLWriter content(long value) throws IOException {
+ return content(String.valueOf(value));
+ }
+
public XMLWriter text(String text) throws IOException {
indent(text);
return this;