You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2009/08/20 09:19:26 UTC

JCR utilities library (was: how to store images into jackrabbit repository)

On Thu, Aug 20, 2009 at 9:12 AM, Jukka Zitting<ju...@gmail.com> wrote:
> The recommended way to store images or in fact any kinds of binary
> files is to use the nt:file and nt:resource node types....

> ...And the JCR 1.0 code to create such a file is:
>
>    InputStream stream = ...; // the binary image data
>    Node parent = ...;        // where you want to store the image
>
>    Node image = parent.addNode("myimage.png", "nt:file");
>    Node content = image.addNode("jcr:content", "nt:resource");
>    content.setProperty("jcr:mimeType", "image/png");
>    content.setProperty("jcr:lastModified", Calendar.getInstance());
>    Value data = session.getValueFactory().createValue(stream);
>    content.setProperty("jcr:data", data);
>    parent.save();

I've been thinking for a while that a JCR utilities library that
encapsulates such things ("create a file from this InputStream",
"create child node with a unique name", ...) in JCR would be useful.

Is there a module in Jackrabbit for such general-purpose JCR
utilities? Or where should that go?

-Bertrand

Re: JCR utilities library (was: how to store images into jackrabbit repository)

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Thu, Aug 20, 2009 at 9:29 AM, Jukka Zitting<ju...@gmail.com> wrote:
> ...jackrabbit-jcr-commons
>
> That component has traditionally been more of a support library for
> jackrabbit-core (and to some extent also for jackrabbit-jcr2spi), but
> recent work there (see for example the new JcrUtils class) has been
> targeted more for JCR clients.
>
> I'm still not entirely happy about the scope of that component and it
> actually might make sense to start a fresh new component in the new
> JCR Commons subproject for this based on selected parts of the
> existing code...

Agreed, it might be good to separate the "support library for
jackrabbit core" parts from things that are useful to JCR clients.

-Bertrand

Re: JCR utilities library (was: how to store images into jackrabbit repository)

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Thu, Aug 20, 2009 at 9:19 AM, Bertrand
Delacretaz<bd...@apache.org> wrote:
> I've been thinking for a while that a JCR utilities library that
> encapsulates such things ("create a file from this InputStream",
> "create child node with a unique name", ...) in JCR would be useful.
>
> Is there a module in Jackrabbit for such general-purpose JCR
> utilities? Or where should that go?

jackrabbit-jcr-commons

That component has traditionally been more of a support library for
jackrabbit-core (and to some extent also for jackrabbit-jcr2spi), but
recent work there (see for example the new JcrUtils class) has been
targeted more for JCR clients.

I'm still not entirely happy about the scope of that component and it
actually might make sense to start a fresh new component in the new
JCR Commons subproject for this based on selected parts of the
existing code.

BR,

Jukka Zitting