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 2013/05/16 17:49:24 UTC
svn commit: r1483416 - 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-bindings/src/main/java/org/apache/c...
Author: fmui
Date: Thu May 16 15:49:23 2013
New Revision: 1483416
URL: http://svn.apache.org/r1483416
Log:
- added PartialContentStream interface to let clients distinguish between full and partial content streams
- added code to extract the filename from the Content-Disposition header if the repository provides it (AtomPub and Browser binding only)
Added:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/PartialContentStream.java (with props)
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PartialContentStreamImpl.java (with props)
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/ObjectServiceImpl.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-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/WSConverter.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/ObjectService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/VersioningService.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/ContentRangesTest.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.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/ObjectFactory.java?rev=1483416&r1=1483415&r2=1483416&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.java Thu May 16 15:49:23 2013
@@ -90,7 +90,27 @@ public interface ObjectFactory {
ContentStream createContentStream(String filename, long length, String mimetype, InputStream stream);
/**
- * Converts a low level {@link ContentStream} object into a high level
+ * Creates an object that implements the {@link ContentStream} interface.
+ *
+ * @param filename
+ * the filename, should be set
+ * @param length
+ * the length of the stream or -1 if the length is unknown
+ * @param mimetype
+ * the MIME type, if unknown "application/octet-stream" should be
+ * used
+ * @param stream
+ * the stream, should not be <code>null</code>
+ * @param partial
+ * if <code>false</code> the stream represents the full content,
+ * if <code>true</code> the stream is only a part of the content
+ *
+ * @return the {@link ContentStream} object
+ */
+ ContentStream createContentStream(String filename, long length, String mimetype, InputStream stream, boolean partial);
+
+ /**
+ * Converts a high level {@link ContentStream} object into a low level
* {@link ContentStream} object.
*
* @param contentStream
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java?rev=1483416&r1=1483415&r2=1483416&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ObjectServiceImpl.java Thu May 16 15:49:23 2013
@@ -63,6 +63,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.impl.dataobjects.BulkUpdateObjectIdAndChangeTokenImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.FailedToDeleteDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PartialContentStreamImpl;
import org.apache.chemistry.opencmis.commons.spi.Holder;
import org.apache.chemistry.opencmis.commons.spi.ObjectService;
@@ -549,8 +550,6 @@ public class ObjectServiceImpl extends A
public ContentStream getContentStream(String repositoryId, String objectId, String streamId, BigInteger offset,
BigInteger length, ExtensionsData extension) {
- ContentStreamImpl result = new ContentStreamImpl();
-
// find the link
String link = null;
if (streamId != null) {
@@ -581,7 +580,20 @@ public class ObjectServiceImpl extends A
throw convertStatusCode(resp.getResponseCode(), resp.getResponseMessage(), resp.getErrorContent(), null);
}
- result.setFileName(null);
+ ContentStreamImpl result;
+ if (resp.getResponseCode() == 206) {
+ result = new PartialContentStreamImpl();
+ } else {
+ result = new ContentStreamImpl();
+ }
+
+ String filename = null;
+ String contentDisposition = resp.getHeader("Content-Disposition");
+ if (contentDisposition != null) {
+ filename = MimeHelper.decodeContentDispositionFilename(contentDisposition);
+ }
+
+ result.setFileName(filename);
result.setLength(resp.getContentLength());
result.setMimeType(resp.getContentTypeHeader());
result.setStream(resp.getStream());
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java?rev=1483416&r1=1483415&r2=1483416&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java Thu May 16 15:49:23 2013
@@ -42,10 +42,12 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.impl.Constants;
import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
+import org.apache.chemistry.opencmis.commons.impl.MimeHelper;
import org.apache.chemistry.opencmis.commons.impl.TypeCache;
import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.FailedToDeleteDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PartialContentStreamImpl;
import org.apache.chemistry.opencmis.commons.spi.Holder;
import org.apache.chemistry.opencmis.commons.spi.ObjectService;
@@ -330,7 +332,6 @@ public class ObjectServiceImpl extends A
public ContentStream getContentStream(String repositoryId, String objectId, String streamId, BigInteger offset,
BigInteger length, ExtensionsData extension) {
- ContentStreamImpl result = new ContentStreamImpl();
// build URL
UrlBuilder url = getObjectUrl(repositoryId, objectId, Constants.SELECTOR_CONTENT);
@@ -344,7 +345,20 @@ public class ObjectServiceImpl extends A
throw convertStatusCode(resp.getResponseCode(), resp.getResponseMessage(), resp.getErrorContent(), null);
}
- result.setFileName(null);
+ ContentStreamImpl result;
+ if (resp.getResponseCode() == 206) {
+ result = new PartialContentStreamImpl();
+ } else {
+ result = new ContentStreamImpl();
+ }
+
+ String filename = null;
+ String contentDisposition = resp.getHeader("Content-Disposition");
+ if (contentDisposition != null) {
+ filename = MimeHelper.decodeContentDispositionFilename(contentDisposition);
+ }
+
+ result.setFileName(filename);
result.setLength(resp.getContentLength());
result.setMimeType(resp.getContentTypeHeader());
result.setStream(resp.getStream());
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/ObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/ObjectServiceImpl.java?rev=1483416&r1=1483415&r2=1483416&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/ObjectServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/ObjectServiceImpl.java Thu May 16 15:49:23 2013
@@ -327,7 +327,13 @@ public class ObjectServiceImpl extends A
ObjectServicePort port = portProvider.getObjectServicePort(getCmisVersion(repositoryId), "getContentStream");
try {
- return convert(port.getContentStream(repositoryId, objectId, streamId, offset, length, convert(extension)));
+ boolean isPartial = false;
+ if ((offset != null && offset.signum() == 1) || length != null) {
+ isPartial = true;
+ }
+
+ return convert(port.getContentStream(repositoryId, objectId, streamId, offset, length, convert(extension)),
+ isPartial);
} catch (CmisException e) {
throw convertException(e);
} catch (Exception e) {
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=1483416&r1=1483415&r2=1483416&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 May 16 15:49:23 2013
@@ -39,6 +39,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.data.Ace;
import org.apache.chemistry.opencmis.commons.data.ContentStream;
import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.commons.data.PartialContentStream;
import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
import org.apache.chemistry.opencmis.commons.enums.Updatability;
@@ -396,7 +397,7 @@ public class DocumentImpl extends Abstra
// convert and return stream object
return getSession().getObjectFactory().createContentStream(filename, lengthLong, contentStream.getMimeType(),
- contentStream.getStream());
+ contentStream.getStream(), contentStream instanceof PartialContentStream);
}
public Document setContentStream(ContentStream contentStream, boolean overwrite) {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.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/repository/ObjectFactoryImpl.java?rev=1483416&r1=1483415&r2=1483416&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java Thu May 16 15:49:23 2013
@@ -94,6 +94,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.enums.Updatability;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PartialContentStreamImpl;
import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
/**
@@ -197,7 +198,17 @@ public class ObjectFactoryImpl implement
// content stream
public ContentStream createContentStream(String filename, long length, String mimetype, InputStream stream) {
- return new ContentStreamImpl(filename, (length < 0 ? null : BigInteger.valueOf(length)), mimetype, stream);
+ return createContentStream(filename, length, mimetype, stream, false);
+ }
+
+ public ContentStream createContentStream(String filename, long length, String mimetype, InputStream stream,
+ boolean partial) {
+ if (partial) {
+ return new PartialContentStreamImpl(filename, (length < 0 ? null : BigInteger.valueOf(length)), mimetype,
+ stream);
+ } else {
+ return new ContentStreamImpl(filename, (length < 0 ? null : BigInteger.valueOf(length)), mimetype, stream);
+ }
}
public ContentStream convertContentStream(ContentStream contentStream) {
Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/PartialContentStream.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/PartialContentStream.java?rev=1483416&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/PartialContentStream.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/PartialContentStream.java Thu May 16 15:49:23 2013
@@ -0,0 +1,30 @@
+/*
+ * 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.commons.data;
+
+/**
+ * Content stream that indicates that this stream may not represent the complete
+ * document content. (Client only.)
+ *
+ * Note that if the client provides an offset and/or a length that cover the
+ * whole document content, the server might report this as partial content.
+ */
+public interface PartialContentStream extends ContentStream {
+
+}
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/PartialContentStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/WSConverter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/WSConverter.java?rev=1483416&r1=1483415&r2=1483416&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/WSConverter.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/WSConverter.java Thu May 16 15:49:23 2013
@@ -143,6 +143,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderListImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectParentDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PartialContentStreamImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PermissionDefinitionDataImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PermissionMappingDataImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PolicyIdListImpl;
@@ -2581,12 +2582,17 @@ public final class WSConverter {
/**
* Converts a content stream object.
*/
- public static ContentStream convert(CmisContentStreamType contentStream) {
+ public static ContentStream convert(CmisContentStreamType contentStream, boolean partial) {
if (contentStream == null) {
return null;
}
- ContentStreamImpl result = new ContentStreamImpl();
+ ContentStreamImpl result;
+ if (partial) {
+ result = new PartialContentStreamImpl();
+ } else {
+ result = new ContentStreamImpl();
+ }
result.setFileName(contentStream.getFilename());
result.setLength(contentStream.getLength());
Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PartialContentStreamImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PartialContentStreamImpl.java?rev=1483416&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PartialContentStreamImpl.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PartialContentStreamImpl.java Thu May 16 15:49:23 2013
@@ -0,0 +1,44 @@
+/*
+ * 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.commons.impl.dataobjects;
+
+import java.io.InputStream;
+import java.math.BigInteger;
+
+import org.apache.chemistry.opencmis.commons.data.PartialContentStream;
+
+/**
+ * Implementation of the {@link PartialContentStream} interface.
+ */
+public class PartialContentStreamImpl extends ContentStreamImpl implements PartialContentStream {
+
+ public PartialContentStreamImpl() {
+ }
+
+ public PartialContentStreamImpl(String filename, BigInteger length, String mimetype, InputStream stream) {
+ super(filename, length, mimetype, stream);
+ }
+
+ public PartialContentStreamImpl(String filename, String mimetype, String string) {
+ super(filename, mimetype, string);
+ }
+
+ private static final long serialVersionUID = 1L;
+
+}
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PartialContentStreamImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java?rev=1483416&r1=1483415&r2=1483416&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java Thu May 16 15:49:23 2013
@@ -464,7 +464,7 @@ public class ObjectService {
}
// set headers
- if ((offset == null) && (length == null)) {
+ if ((offset == null || offset.signum() == 0) && (length == null)) {
response.setStatus(HttpServletResponse.SC_OK);
} else {
response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java?rev=1483416&r1=1483415&r2=1483416&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java Thu May 16 15:49:23 2013
@@ -565,7 +565,7 @@ public class ObjectService {
}
// set headers
- if (offset == null && length == null) {
+ if ((offset == null || offset.signum() == 0) && length == null) {
response.setStatus(HttpServletResponse.SC_OK);
} else {
setStatus(request, response, HttpServletResponse.SC_PARTIAL_CONTENT);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/ObjectService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/ObjectService.java?rev=1483416&r1=1483415&r2=1483416&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/ObjectService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/ObjectService.java Thu May 16 15:49:23 2013
@@ -81,9 +81,9 @@ public class ObjectService extends Abstr
ExtensionsData extData = convertExtensionHolder(extension);
- String id = service.createDocument(repositoryId, convert(properties), folderId, convert(contentStream),
- convert(VersioningState.class, versioningState), policies, convert(addAces, null),
- convert(removeAces, null), extData);
+ String id = service.createDocument(repositoryId, convert(properties), folderId,
+ convert(contentStream, false), convert(VersioningState.class, versioningState), policies,
+ convert(addAces, null), convert(removeAces, null), extData);
if (objectId != null) {
objectId.value = id;
@@ -416,7 +416,7 @@ public class ObjectService extends Abstr
ExtensionsData extData = convertExtensionHolder(extension);
service.setContentStream(repositoryId, objectIdHolder, overwriteFlag, changeTokenHolder,
- convert(contentStream), extData);
+ convert(contentStream, false), extData);
setHolderValue(objectIdHolder, objectId);
setHolderValue(changeTokenHolder, changeToken);
@@ -439,7 +439,7 @@ public class ObjectService extends Abstr
org.apache.chemistry.opencmis.commons.spi.Holder<String> changeTokenHolder = convertHolder(changeToken);
ExtensionsData extData = convertExtensionHolder(extension);
- service.appendContentStream(repositoryId, objectIdHolder, changeTokenHolder, convert(contentStream),
+ service.appendContentStream(repositoryId, objectIdHolder, changeTokenHolder, convert(contentStream, true),
isLastChunk, extData);
setHolderValue(objectIdHolder, objectId);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/VersioningService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/VersioningService.java?rev=1483416&r1=1483415&r2=1483416&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/VersioningService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/VersioningService.java Thu May 16 15:49:23 2013
@@ -88,7 +88,7 @@ public class VersioningService extends A
org.apache.chemistry.opencmis.commons.spi.Holder<String> objectIdHolder = convertHolder(objectId);
ExtensionsData extData = convertExtensionHolder(extension);
- service.checkIn(repositoryId, objectIdHolder, major, convert(properties), convert(contentStream),
+ service.checkIn(repositoryId, objectIdHolder, major, convert(properties), convert(contentStream, false),
checkinComment, policies, convert(addAces, null), convert(removeAces, null), extData);
setHolderValue(objectIdHolder, objectId);
Modified: 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=1483416&r1=1483415&r2=1483416&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/ContentRangesTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/ContentRangesTest.java Thu May 16 15:49:23 2013
@@ -28,6 +28,7 @@ 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.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.data.PartialContentStream;
import org.apache.chemistry.opencmis.tck.CmisTestResult;
import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
@@ -60,6 +61,40 @@ public class ContentRangesTest extends A
String excerpt;
ContentStream content;
+ // no offset, no length -> full content
+ try {
+ content = doc.getContentStream(null, null);
+ excerpt = getStringFromContentStream(content);
+
+ if (CONTENT.equals(excerpt)) {
+ addResult(assertIsFalse(content instanceof PartialContentStream, null, createResult(FAILURE,
+ "Retrieved stream is marked as partial stream "
+ + "although the full stream {offset=null, length=null} was expected!")));
+ } else {
+ addResult(createResult(FAILURE, "Retrieved stream doesn't match the document content!"));
+ }
+ } catch (Exception e) {
+ addResult(createResult(FAILURE,
+ "Unexpected exception while retrieving full stream {offset=null, length=null}: " + e, e, false));
+ }
+
+ // offset = 0, no length -> full content
+ try {
+ content = doc.getContentStream(BigInteger.ZERO, null);
+ excerpt = getStringFromContentStream(content);
+
+ if (CONTENT.equals(excerpt)) {
+ addResult(assertIsFalse(content instanceof PartialContentStream, null, createResult(WARNING,
+ "Retrieved stream is marked as partial stream "
+ + "although the full stream {offset=0, length=null} was expected!")));
+ } else {
+ addResult(createResult(FAILURE, "Retrieved stream doesn't match the document content!"));
+ }
+ } catch (Exception e) {
+ addResult(createResult(FAILURE,
+ "Unexpected exception while retrieving full stream {offset=0, length=null}: " + e, e, false));
+ }
+
// offset, no length
try {
content = doc.getContentStream(BigInteger.valueOf(3), null);
@@ -68,9 +103,14 @@ public class ContentRangesTest extends A
if (CONTENT.equals(excerpt)) {
addResult(createResult(WARNING,
"Retrieved full stream instead of an excerpt {offset=3, length=null}! Content ranges supported?"));
+ addResult(assertIsFalse(content instanceof PartialContentStream, null, createResult(WARNING,
+ "Retrieved stream is marked as partial stream, " + "although the full stream is returned!")));
} else {
f = createResult(FAILURE, "Retrieved stream excerpt {offset=3, length=null} doesn't match!");
addResult(assertEquals(CONTENT.substring(3), excerpt, null, f));
+ addResult(assertIsTrue(content instanceof PartialContentStream, null, createResult(WARNING,
+ "Retrieved stream is not marked as partial stream. "
+ + "(AtomPub and Browser Binding should return the HTTP status code 206.)")));
}
} catch (Exception e) {
addResult(createResult(FAILURE,
@@ -85,9 +125,14 @@ public class ContentRangesTest extends A
if (CONTENT.equals(excerpt)) {
addResult(createResult(WARNING,
"Retrieved full stream instead of an excerpt {offset=null, length=12}! Content ranges supported?"));
+ addResult(assertIsFalse(content instanceof PartialContentStream, null, createResult(WARNING,
+ "Retrieved stream is marked as partial stream, " + "although the full stream is returned!")));
} else {
f = createResult(FAILURE, "Retrieved stream excerpt {offset=null, length=12} doesn't match!");
addResult(assertEquals(CONTENT.substring(0, 12), excerpt, null, f));
+ addResult(assertIsTrue(content instanceof PartialContentStream, null, createResult(WARNING,
+ "Retrieved stream is not marked as partial stream. "
+ + "(AtomPub and Browser Binding should return the HTTP status code 206.)")));
}
} catch (Exception e) {
addResult(createResult(FAILURE,
@@ -102,9 +147,14 @@ public class ContentRangesTest extends A
if (CONTENT.equals(excerpt)) {
addResult(createResult(WARNING,
"Retrieved full stream instead of an excerpt {offset=5, length=17}! Content ranges supported?"));
+ addResult(assertIsFalse(content instanceof PartialContentStream, null, createResult(WARNING,
+ "Retrieved stream is marked as partial stream, " + "although the full stream is returned!")));
} else {
f = createResult(FAILURE, "Retrieved stream excerpt {offset=5, length=17} doesn't match!");
addResult(assertEquals(CONTENT.substring(5, 5 + 17), excerpt, null, f));
+ addResult(assertIsTrue(content instanceof PartialContentStream, null, createResult(WARNING,
+ "Retrieved stream is not marked as partial stream. "
+ + "(AtomPub and Browser Binding should return the HTTP status code 206.)")));
}
} catch (Exception e) {
addResult(createResult(FAILURE, "Unexpected exception while retrieving stream {offset=5, length=17}: "
@@ -119,9 +169,14 @@ public class ContentRangesTest extends A
if (CONTENT.equals(excerpt)) {
addResult(createResult(WARNING,
"Retrieved full stream instead of an excerpt {offset=9, length=123}! Content ranges supported?"));
+ addResult(assertIsFalse(content instanceof PartialContentStream, null, createResult(WARNING,
+ "Retrieved stream is marked as partial stream, " + "although the full stream is returned!")));
} else {
f = createResult(FAILURE, "Retrieved stream excerpt {offset=9, length=123} doesn't match!");
addResult(assertEquals(CONTENT.substring(9), excerpt, null, f));
+ addResult(assertIsTrue(content instanceof PartialContentStream, null, createResult(WARNING,
+ "Retrieved stream is not marked as partial stream. "
+ + "(AtomPub and Browser Binding should return the HTTP status code 206.)")));
}
} catch (Exception e) {
addResult(createResult(FAILURE, "Unexpected exception while retrieving stream {offset=9, length=123}: "