Uploaded image for project: 'Chemistry (Retired)'
  1. Chemistry (Retired)
  2. CMIS-906

doc.getContentStreamLength() returns the length of whole content even it is partial retrieved

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Not A Problem
    • OpenCMIS 0.13.0
    • None
    • None
    • WIN

    Description

      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?

      Attachments

        Activity

          People

            Unassigned Unassigned
            lixuhua@cn.ibm.com James Li
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: