jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francisco Carriedo Scher <fcarrie...@gmail.com>
Subject Re: JR Future idea
Date Sun, 25 Mar 2012 22:51:38 GMT
Thanks Jukka, great news, it will help for sure!

I will check the extension you described and the code snipped to give it a
try and i will tell back!

Thank you so much for your attention!

2012/3/21 Jukka Zitting <jukka.zitting@gmail.com>

> Hi Francisco,
>
> On Tue, Mar 20, 2012 at 9:59 PM, Francisco Carriedo Scher
> <fcarriedos@gmail.com> wrote:
> > I can imagine lots of questions to properly integrate this (efficient
> > methods for asking about the existence, for instance), but i really need
> > some (expertise) tips to do this... Let's say, an entry point...
>
> For now one of the main goals of the data store design was to avoid
> duplicating binaries that already exist in the repository, for example
> when copying or versioning existing content. We didn't put much effort
> into thinking how an external client could also leverage this feature
> like you're suggesting. But I agree that it's a good use case, so
> thanks for following up on this!
>
> As for how to implement this on top of the JCR API, the main thing
> you'd need is a Value reference that matches a given content hash. To
> start with this identifier was completely internal, but in JCR-1892
> [1] we already started exposing it through the
> JackrabbitValue.getContentIdentity() [2] extension. What you'd need
> then is another extension method, for example
> JackrabbitValueFactory.createBinary(String) or something similar, that
> turns a given content hash to a matching binary Value (or returns null
> if a matching value is not found).
>
> With such a method, your client could work roughly like this:
>
>    File file = ...;
>    String hash = computeContentHash(file);
>
>    // Check if the binary already exists in the repository
>    JackrabbitValueFactory factory = ...;
>    Binary binary = factory.createBinary(hash);
>    if (binary == null) {
>        // Doesn't exist yet, so stream it to the repository
>        binary = factory.creatBinary(new FileInputStream(file));
>    }
>
>    Node node = ...;
>    node.setProperty(Property.JCR_DATA, binary);
>
> Does this help you forward?
>
> [1] https://issues.apache.org/jira/browse/JCR-1892
> [2] http://jackrabbit.apache.org/api/2.4/org/apache/jackraasĂ­ que es algo
> bbit/api/JackrabbitValue.html#getContentIdentity()<http://jackrabbit.apache.org/api/2.4/org/apache/jackrabbit/api/JackrabbitValue.html#getContentIdentity%28%29>
>
> BR,
>
> Jukka Zitting
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message