Return-Path: X-Original-To: apmail-chemistry-dev-archive@www.apache.org Delivered-To: apmail-chemistry-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 84F7E10F2D for ; Fri, 10 Apr 2015 07:09:12 +0000 (UTC) Received: (qmail 81838 invoked by uid 500); 10 Apr 2015 07:09:12 -0000 Delivered-To: apmail-chemistry-dev-archive@chemistry.apache.org Received: (qmail 81775 invoked by uid 500); 10 Apr 2015 07:09:12 -0000 Mailing-List: contact dev-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list dev@chemistry.apache.org Received: (qmail 81763 invoked by uid 99); 10 Apr 2015 07:09:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Apr 2015 07:09:12 +0000 Date: Fri, 10 Apr 2015 07:09:12 +0000 (UTC) From: =?utf-8?Q?Florian_M=C3=BCller_=28JIRA=29?= To: dev@chemistry.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CMIS-906) doc.getContentStreamLength() returns the length of whole content even it is partial retrieved MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CMIS-906?page=3Dcom.atlassian.j= ira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D144890= 77#comment-14489077 ]=20 Florian M=C3=BCller commented on CMIS-906: ------------------------------------- Depending on the binding and server the stream length is unknown. In this c= ase {{getLength()}} returns -1 (see [JavaDoc|https://chemistry.apache.org/j= ava/0.13.0/maven/apidocs/org/apache/chemistry/opencmis/commons/data/Content= Stream.html#getLength%28%29]). > doc.getContentStreamLength() returns the length of whole content even it = is partial retrieved > -------------------------------------------------------------------------= -------------------- > > Key: CMIS-906 > URL: https://issues.apache.org/jira/browse/CMIS-906 > Project: Chemistry > Issue Type: Bug > Components: opencmis-client-bindings > Affects Versions: OpenCMIS 0.13.0 > Environment: WIN > Reporter: James Li > Priority: Minor > > I have a test to just retrieve partial content: > {code:java} > public void getContentRange() throws IOException{ > =09 byte[] content =3D "Hello World, this is for contentstream range t= est!".getBytes(); =20 > =09 InputStream stream =3D new ByteArrayInputStream(content); > ContentStream contentStream =3D session.getObjectFactory().create= ContentStream("hello.txt", content.length, "text/plain", stream); > =09 =20 > // (minimal set: name and object type id) > Map properties =3D new HashMap(); > properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUME= NT.value()); > properties.put(PropertyIds.NAME, "hello"); > =20 > Document doc =3D this.scratchFolder.createDocument(properties, co= ntentStream, VersioningState.MAJOR); > =20 > ContentStream retrieved =3D doc.getContentStream("0", BigInteger= .valueOf(5), BigInteger.valueOf(5)); > System.out.println("streamlength: " + doc.getContentStreamLength(= )); > =09} > {code} > The test only retrieve from position 5, length 5 of contentstream, but th= e {{doc.getContentStreamlength()}} actually return 50 (the length of whole = ocntent). > On server side implmentation, we actually set the length to 5: > ContentStream [filename=3Dhello.txt, length=3D5, MIME type=3Dtext/plain, = has stream=3Dtrue][extensions=3Dnull] > I traced the client.bindings.spi.atompub.ObjectServiceImple, the response= header is: > {noformat} > {cache-control=3D[private, max-age=3D0], content-type=3D[text/plain], nul= l=3D[HTTP/1.1 206 Partial Content], transfer-encoding=3D[chunked], content-= disposition=3D[attachment; filename=3Dhello.txt], content-language=3D[en-US= ], server=3D[Apache-Chemistry-OpenCMIS/1.0.0-SNAPSHOT], date=3D[Thu, 09 Apr= 2015 06:43:24 GMT], content-range=3D[bytes 5-9/*]} > {noformat} > The code set the length using {{result.setLength(resp.getContentLength())= ;}} > Is this a bug?=20 -- This message was sent by Atlassian JIRA (v6.3.4#6332)