You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by Ugo Cei <u....@sourcesense.com> on 2009/07/09 17:28:44 UTC

Reading a document's contents

Is there a method in Chemistry client APIs for reading a document's  
contents (basically for fetching whatever is pointed to by the  
ContentStreamUri property?).

If there isn't, should I just fetch it myself using HttpClient? Would  
it make sense to add such a method to the APIs?

	Ugo

-- 
Ugo Cei
Sourcesense - making sense of Open Source: http://www.sourcesense.com


Re: Reading a document's contents

Posted by Florent Guillaume <fg...@nuxeo.com>.
On 9 Jul 2009, at 18:37, Ugo Cei wrote:
> That would be nice, were it not for a small detail:
>
>    public InputStream getStream() throws IOException {
>        throw new UnsupportedOperationException("Not yet implemented");
>    }
>
> I guess there's space here for someone wanting to contribute a nice  
> little implementation ;)

Ah, this is APPDocument, right? Yes this part isn't much implemented  
yet.
I guess something simple based on
         String href = entry.getLink(CMIS.LINK_STREAM);
Then using HttpClient to fetch the stream would be sufficient.

> P.S.: is there a way to check that a CMISObject is a Document before  
> casting down, other that using instanceof?

Another way is to check doc.getType().getBaseType() ==  
BaseType.DOCUMENT.
But instanceof seems fine to me too.

Florent

-- 
Florent Guillaume, Head of R&D, Nuxeo
Open Source, Java EE based, Enterprise Content Management (ECM)
http://www.nuxeo.com   http://www.nuxeo.org   +33 1 40 33 79 87


Re: Reading a document's contents

Posted by Ugo Cei <u....@sourcesense.com>.
On Jul 9, 2009, at 5:47 PM, Florent Guillaume wrote:

> On 9 Jul 2009, at 17:28, Ugo Cei wrote:
>> Is there a method in Chemistry client APIs for reading a document's  
>> contents (basically for fetching whatever is pointed to by the  
>> ContentStreamUri property?).
>
> Document.getStream does that. It hides the details of the transport  
> from you (and there may not even by any CMIS transport if everything  
> is local).
> You can also use Document.getContentStream which returns a richer  
> ContentStream datastructure with filename, mime type and length.


That would be nice, were it not for a small detail:


     public InputStream getStream() throws IOException {
         throw new UnsupportedOperationException("Not yet implemented");
     }

I guess there's space here for someone wanting to contribute a nice  
little implementation ;)

	Ugo

P.S.: is there a way to check that a CMISObject is a Document before  
casting down, other that using instanceof?

-- 
Ugo Cei
Sourcesense - making sense of Open Source: http://www.sourcesense.com


Re: Reading a document's contents

Posted by Florent Guillaume <fg...@nuxeo.com>.
On 9 Jul 2009, at 17:28, Ugo Cei wrote:
> Is there a method in Chemistry client APIs for reading a document's  
> contents (basically for fetching whatever is pointed to by the  
> ContentStreamUri property?).

Document.getStream does that. It hides the details of the transport  
from you (and there may not even by any CMIS transport if everything  
is local).
You can also use Document.getContentStream which returns a richer  
ContentStream datastructure with filename, mime type and length.

Note that the ContentStreamUri property is going away in CMIS draft  
0.62.

Florent

-- 
Florent Guillaume, Head of R&D, Nuxeo
Open Source, Java EE based, Enterprise Content Management (ECM)
http://www.nuxeo.com   http://www.nuxeo.org   +33 1 40 33 79 87