linuxunil
linuxunil

Reputation: 313

how to get a document by uuid

I'm working with jackrabbit (v2.6.0).

What I'm trying to do is get a document repository from a UUID.

I'm reading the jackrabbit api and does not seem to have a method that performs this task.

Any tips?

Thanks

Upvotes: 1

Views: 505

Answers (2)

linuxunil
linuxunil

Reputation: 313

The document is a Node too. So you can just:

String pdfUUID = "put-uuid-here";
Node pdfNode = session.getNodeByIdentifier(pdfUUID);
Node jcrContent = pdfNode.getNode("jcr:content");
Property dataProperty = jcrContent.getProperty("jcr:data");
Binary dataBinary = dataProperty.getBinary();
InputStream dataInputStream = dataBinary.getStream();
//do something
dataInputStream.close();
dataBinary.dispose();

Upvotes: 0

Thomas Mueller
Thomas Mueller

Reputation: 50107

As of JCR 2.0, you can get a node by identifier using Session.getNodeByIdentifier(). Also possible is Session.getNodeByUUID, but it is deprecated.

Upvotes: 1

Related Questions