You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2012/07/19 17:37:28 UTC
svn commit: r1363386 - in /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/apache/chemi...
Author: fmui
Date: Thu Jul 19 15:37:28 2012
New Revision: 1363386
URL: http://svn.apache.org/viewvc?rev=1363386&view=rev
Log:
CMIS 556: support for content ranges (high level client API) + TCK test + server fixes
Added:
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/ContentRangesTest.java (with props)
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java?rev=1363386&r1=1363385&r2=1363386&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Document.java Thu Jul 19 15:37:28 2012
@@ -18,6 +18,7 @@
*/
package org.apache.chemistry.opencmis.client.api;
+import java.math.BigInteger;
import java.util.List;
import java.util.Map;
@@ -49,14 +50,46 @@ public interface Document extends Fileab
ContentStream getContentStream();
/**
+ * Retrieves the content stream of this document.
+ *
+ * @param offset
+ * the offset of the stream or <code>null</code> to read the
+ * stream from the beginning
+ * @param length
+ * the maximum length of the stream or <code>null</code> to read
+ * to the end of the stream
+ * @return the content stream, or {@code null}
+ */
+ ContentStream getContentStream(BigInteger offset, BigInteger length);
+
+ /**
* Retrieves the content stream that is associated with the given stream id.
* This is usually a rendition of the document.
*
+ * @param streamId
+ * the stream id
+ *
* @return the content stream, or {@code null}
*/
ContentStream getContentStream(String streamId);
/**
+ * Retrieves the content stream that is associated with the given stream id.
+ * This is usually a rendition of the document.
+ *
+ * @param streamId
+ * the stream id
+ * @param offset
+ * the offset of the stream or <code>null</code> to read the
+ * stream from the beginning
+ * @param length
+ * the maximum length of the stream or <code>null</code> to read
+ * to the end of the stream
+ * @return the content stream, or {@code null}
+ */
+ ContentStream getContentStream(String streamId, BigInteger offset, BigInteger length);
+
+ /**
* Sets a new content stream for the document and refreshes this object
* afterwards. If the repository created a new version, this new document is
* returned. Otherwise the current document is returned.
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java?rev=1363386&r1=1363385&r2=1363386&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/DocumentImpl.java Thu Jul 19 15:37:28 2012
@@ -346,12 +346,20 @@ public class DocumentImpl extends Abstra
// content operations
public ContentStream getContentStream() {
- return getContentStream(null);
+ return getContentStream(null, null, null);
+ }
+
+ public ContentStream getContentStream(BigInteger offset, BigInteger length) {
+ return getContentStream(null, offset, length);
}
public ContentStream getContentStream(String streamId) {
+ return getContentStream(streamId, null, null);
+ }
+
+ public ContentStream getContentStream(String streamId, BigInteger offset, BigInteger length) {
// get the stream
- ContentStream contentStream = getSession().getContentStream(this, streamId, null, null);
+ ContentStream contentStream = getSession().getContentStream(this, streamId, offset, length);
if (contentStream == null) {
return null;
@@ -364,10 +372,10 @@ public class DocumentImpl extends Abstra
filename = getContentStreamFileName();
}
- long length = (contentStream.getBigLength() == null ? -1 : contentStream.getBigLength().longValue());
+ long lengthLong = (contentStream.getBigLength() == null ? -1 : contentStream.getBigLength().longValue());
// convert and return stream object
- return getSession().getObjectFactory().createContentStream(filename, length, contentStream.getMimeType(),
+ return getSession().getObjectFactory().createContentStream(filename, lengthLong, contentStream.getMimeType(),
contentStream.getStream());
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java?rev=1363386&r1=1363385&r2=1363386&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java Thu Jul 19 15:37:28 2012
@@ -40,6 +40,7 @@ public class CRUDTestGroup extends Abstr
addTest(new CreateAndDeleteRelationshipTest());
addTest(new UpdateSmokeTest());
addTest(new SetAndDeleteContentTest());
+ addTest(new ContentRangesTest());
addTest(new CopyTest());
addTest(new MoveTest());
addTest(new DeleteTreeTest());
Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/ContentRangesTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/ContentRangesTest.java?rev=1363386&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/ContentRangesTest.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/ContentRangesTest.java Thu Jul 19 15:37:28 2012
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.tck.tests.crud;
+
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING;
+
+import java.math.BigInteger;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+public class ContentRangesTest extends AbstractSessionTest {
+
+ private static final String CONTENT = "0123456789012345678901234567890";
+
+ @Override
+ public void init(Map<String, String> parameters) {
+ super.init(parameters);
+ setName("Content Ranges Test");
+ setDescription("Creates a document and reads different excerpts of the content.");
+ }
+
+ @Override
+ public void run(Session session) {
+ CmisTestResult f;
+
+ // create a test folder
+ Folder testFolder = createTestFolder(session);
+ Document doc = null;
+
+ try {
+ // create the document
+ doc = createDocument(session, testFolder, "testcontent.txt", CONTENT);
+
+ String excerpt;
+ ContentStream content;
+
+ try {
+ content = doc.getContentStream(BigInteger.valueOf(3), null);
+ excerpt = getStringFromContentStream(content);
+
+ f = createResult(WARNING,
+ "Retrieved stream excerpt {offset=3, length=nil} doesn't match! Content ranges supported?");
+ addResult(assertEquals(CONTENT.substring(3), excerpt, null, f));
+ } catch (Exception e) {
+ addResult(createResult(WARNING,
+ "Unexpected exception while retrieving stream {offset=3, length=null}: " + e, e, false));
+ }
+
+ try {
+ content = doc.getContentStream(null, BigInteger.valueOf(12));
+ excerpt = getStringFromContentStream(content);
+
+ f = createResult(WARNING,
+ "Retrieved stream excerpt {offset=null, length=12} doesn't match! Content ranges supported?");
+ addResult(assertEquals(CONTENT.substring(0, 12), excerpt, null, f));
+ } catch (Exception e) {
+ addResult(createResult(WARNING,
+ "Unexpected exception while retrieving stream {offset=null, length=12}: " + e, e, false));
+ }
+
+ try {
+ content = doc.getContentStream(BigInteger.valueOf(5), BigInteger.valueOf(17));
+ excerpt = getStringFromContentStream(content);
+
+ f = createResult(WARNING,
+ "Retrieved stream excerpt {offset=5, length=17} doesn't match! Content ranges supported?");
+ addResult(assertEquals(CONTENT.substring(5, 5 + 17), excerpt, null, f));
+ } catch (Exception e) {
+ addResult(createResult(WARNING, "Unexpected exception while retrieving stream {offset=5, length=17}: "
+ + e, e, false));
+ }
+ } finally {
+ // clean up
+ deleteObject(doc);
+ deleteTestFolder();
+ }
+ }
+}
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/ContentRangesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java?rev=1363386&r1=1363385&r2=1363386&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java Thu Jul 19 15:37:28 2012
@@ -19,7 +19,6 @@
package org.apache.chemistry.opencmis.tck.tests.crud;
import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
-import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED;
import java.util.Map;
@@ -27,7 +26,6 @@ import org.apache.chemistry.opencmis.cli
import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
-import org.apache.chemistry.opencmis.commons.enums.BindingType;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.tck.CmisTestResult;
import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
@@ -47,11 +45,11 @@ public class CopyTest extends AbstractSe
@Override
public void run(Session session) {
- if (getBinding() == BindingType.ATOMPUB) {
- addResult(createResult(SKIPPED,
- "AtomPub binding does not support createDocumentFromSource(). Test Skipped!"));
- return;
- }
+ // if (getBinding() == BindingType.ATOMPUB) {
+ // addResult(createResult(SKIPPED,
+ // "AtomPub binding does not support createDocumentFromSource(). Test Skipped!"));
+ // return;
+ // }
CmisTestResult f;