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 <[email protected]> > Hi Francisco, > > On Tue, Mar 20, 2012 at 9:59 PM, Francisco Carriedo Scher > <[email protected]> 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 >
