jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cech. Ulrich" <Ulrich.C...@aeb.de>
Subject AW: Avoid binary streaming
Date Fri, 05 Oct 2012 08:32:47 GMT
You can get the physical path to the file in a FileDataStore as following (note, that this
is then Jackrabbit-specific).

(The PhysicalFileInDataStore-class is just a simple POJO)
    public static class PhysicalFileInDataStore {

        private String nodeIdentifier;
        private File file;

        ... (getter und setter)

List<Node> fileNodes = getResourceNodes(node);
DataStore ds = ((RepositoryImpl) node.getSession().getRepository()).getConfig().getDataStore();
if (ds instanceof FileDataStore) {
    dsPath = new File(((FileDataStore) ds).getPath());
for (Node fn : fileNodes) {
    Property prop = fn.getProperty(JcrConstants.JCR_DATA);
    Binary b = prop.getBinary();
    if (b instanceof BLOBInDataStore) {
        if (ds instanceof FileDataStore) {
            PhysicalFileInDataStore pf = new PhysicalFileInDataStore();
            pf.setFile(getFile(getIdentifier(b), dsPath));

    public List<Node> getResourceNodes(final Node node) throws
            RepositoryException {
        List<Node> nodes = new ArrayList<Node>();
        NodeIterator nitg = node.getNodes();
        while (nitg.hasNext()) {
            Node n = (Node) nitg.next();
            if (n.isNodeType(JcrConstants.NT_FILE)) {
                NodeIterator nitFile = n.getNodes();
                while (nitFile.hasNext()) {
                    Node nodeContent = (Node) nitFile.next();
                    if ((JcrConstants.JCR_CONTENT.equals(nodeContent.getName()))
                            && (nodeContent.isNodeType(JcrConstants.NT_RESOURCE)))
        return nodes;

    public File getFile(DataIdentifier identifier, File directory) {
        String string = identifier.toString();
        File file = directory;
        file = new File(file, string.substring(0, 2));
        file = new File(file, string.substring(2, 4));
        file = new File(file, string.substring(4, 6));
        return new File(file, string);

    public DataIdentifier getIdentifier(Binary binary) {
        if (binary instanceof BLOBFileValue) {
            return ((BLOBFileValue) binary).getDataIdentifier();
        } else {
            return null;

-----Urspr√ľngliche Nachricht-----
Von: polofan123 [mailto:polofan@web.de]
Gesendet: Donnerstag, 4. Oktober 2012 16:03
An: users@jackrabbit.apache.org
Betreff: Avoid binary streaming

In my jackrabbit datastore there are large binary files stored. I can browse the datastore
filesystem and open these files without any problems.

Now how can I use these files from within my application? I of course could use the getStream()
method of type jcr.binary but then I would just stream all the content of the already exsisting
file into a new temporary file right? Since my binarys are very large I don't want that. I'm
looking for a way to get the full filesystem path of a binary. The method getpath() of jcr.Property
only returns the path within the repository and only with the mapped node names and not the
node names which are really stored on my filesystem. In general I have to parse a binary object
into a Java.IO.File object and I want to avoid Streaming

View this message in context: http://jackrabbit.510166.n4.nabble.com/Avoid-binary-streaming-tp4656705.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Treffen Sie AEB vom 17.-19. Oktober 2012 auf dem 29. Deutschen Logistik-Kongress in Berlin.
Weitere Informationen und Termin-Vereinbarung unter: www.aeb.de/dlk

View raw message