[ 
https://issues.apache.org/jira/browse/CMIS-906?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Florian Müller updated CMIS-906:
--------------------------------
    Description: 
I have a test to just retrieve partial content:
{code:java}
public void getContentRange() throws IOException{
            byte[] content = "Hello World, this is for contentstream range 
test!".getBytes();  
            InputStream stream = new ByteArrayInputStream(content);
        ContentStream contentStream = 
session.getObjectFactory().createContentStream("hello.txt", content.length, 
"text/plain", stream);
            
     // (minimal set: name and object type id)
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.OBJECT_TYPE_ID, 
BaseTypeId.CMIS_DOCUMENT.value());
        properties.put(PropertyIds.NAME, "hello");
        
        Document doc = this.scratchFolder.createDocument(properties, 
contentStream, VersioningState.MAJOR);
        
        ContentStream retrieved =  doc.getContentStream("0", 
BigInteger.valueOf(5), BigInteger.valueOf(5));
        System.out.println("streamlength: " + doc.getContentStreamLength());
        }
{code}

The test only retrieve from position 5, length 5 of contentstream, but the 
{{doc.getContentStreamlength()}} actually return 50 (the length of whole 
ocntent).
On server side implmentation, we actually set the length to 5:
ContentStream [filename=hello.txt, length=5, MIME type=text/plain, has 
stream=true][extensions=null]

I traced the client.bindings.spi.atompub.ObjectServiceImple, the response 
header is:
{noformat}
{cache-control=[private, max-age=0], content-type=[text/plain], null=[HTTP/1.1 
206 Partial Content], transfer-encoding=[chunked], 
content-disposition=[attachment; filename=hello.txt], content-language=[en-US], 
server=[Apache-Chemistry-OpenCMIS/1.0.0-SNAPSHOT], date=[Thu, 09 Apr 2015 
06:43:24 GMT], content-range=[bytes 5-9/*]}
{noformat}

The code set the length using {{result.setLength(resp.getContentLength());}}

Is this a bug? 

  was:
I have a test to just retrieve partial content:
public void getContentRange() throws IOException{
            byte[] content = "Hello World, this is for contentstream range 
test!".getBytes();  
            InputStream stream = new ByteArrayInputStream(content);
        ContentStream contentStream = 
session.getObjectFactory().createContentStream("hello.txt", content.length, 
"text/plain", stream);
            
     // (minimal set: name and object type id)
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.OBJECT_TYPE_ID, 
BaseTypeId.CMIS_DOCUMENT.value());
        properties.put(PropertyIds.NAME, "hello");
        
        Document doc = this.scratchFolder.createDocument(properties, 
contentStream, VersioningState.MAJOR);
        
        ContentStream retrieved =  doc.getContentStream("0", 
BigInteger.valueOf(5), BigInteger.valueOf(5));
        System.out.println("streamlength: " + doc.getContentStreamLength());
        }

The test only retrieve from position 5, length 5 of contentstream, but the 
doc.getContentStreamlength() actually return 50( the length of whole ocntent).
On server side implmentation, we actually set the length to 5:
ContentStream [filename=hello.txt, length=5, MIME type=text/plain, has 
stream=true][extensions=null]

I traced the client.bindings.spi.atompub.ObjectServiceImple, the response 
header is:
{cache-control=[private, max-age=0], content-type=[text/plain], null=[HTTP/1.1 
206 Partial Content], transfer-encoding=[chunked], 
content-disposition=[attachment; filename=hello.txt], content-language=[en-US], 
server=[Apache-Chemistry-OpenCMIS/1.0.0-SNAPSHOT], date=[Thu, 09 Apr 2015 
06:43:24 GMT], content-range=[bytes 5-9/*]}

The code set the length using  result.setLength(resp.getContentLength());

Is this a bug? 


> 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{
>           byte[] content = "Hello World, this is for contentstream range 
> test!".getBytes();  
>           InputStream stream = new ByteArrayInputStream(content);
>         ContentStream contentStream = 
> session.getObjectFactory().createContentStream("hello.txt", content.length, 
> "text/plain", stream);
>           
>      // (minimal set: name and object type id)
>         Map<String, Object> properties = new HashMap<String, Object>();
>         properties.put(PropertyIds.OBJECT_TYPE_ID, 
> BaseTypeId.CMIS_DOCUMENT.value());
>         properties.put(PropertyIds.NAME, "hello");
>         
>         Document doc = this.scratchFolder.createDocument(properties, 
> contentStream, VersioningState.MAJOR);
>         
>         ContentStream retrieved =  doc.getContentStream("0", 
> BigInteger.valueOf(5), BigInteger.valueOf(5));
>         System.out.println("streamlength: " + doc.getContentStreamLength());
>       }
> {code}
> The test only retrieve from position 5, length 5 of contentstream, but the 
> {{doc.getContentStreamlength()}} actually return 50 (the length of whole 
> ocntent).
> On server side implmentation, we actually set the length to 5:
> ContentStream [filename=hello.txt, length=5, MIME type=text/plain, has 
> stream=true][extensions=null]
> I traced the client.bindings.spi.atompub.ObjectServiceImple, the response 
> header is:
> {noformat}
> {cache-control=[private, max-age=0], content-type=[text/plain], 
> null=[HTTP/1.1 206 Partial Content], transfer-encoding=[chunked], 
> content-disposition=[attachment; filename=hello.txt], 
> content-language=[en-US], server=[Apache-Chemistry-OpenCMIS/1.0.0-SNAPSHOT], 
> date=[Thu, 09 Apr 2015 06:43:24 GMT], content-range=[bytes 5-9/*]}
> {noformat}
> The code set the length using {{result.setLength(resp.getContentLength());}}
> Is this a bug? 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to