You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Tim Terlegård <ti...@gmail.com> on 2010/04/01 10:09:21 UTC
Sane file hierarchy when persisting file/folder nodes
I'm investigating whether using Jackrabbit/JCR is a good abstraction
when dealing with files.
I created a workspace (myspace) and used BundleFsPersistenceManager.
When I tried the code below it created the file
repository/workspaces/myspace/items/54/d6/c2bc4964477ab060d399ea532.n
I'd rather it create
repository/workspaces/myspace/items/hi.txt
Is it possible to get a nice file hierarchy and not these random
numbers? And is it possible to store the files as plain text instead
of binary?
Thanks,
Tim
Node root = session.getRootNode();
Node fileNode = root.addNode("hi.txt", "nt:file");
Node resNode = fileNode.addNode("jcr:content", "nt:resource");
resNode.setProperty("jcr:mimeType", "text/plain");
resNode.setProperty("jcr:encoding", "utf8");
resNode.setProperty("jcr:data", new FileInputStream(new File("hi.txt")));
session.save();
Re: Sane file hierarchy when persisting file/folder nodes
Posted by Joseph Ottinger <dr...@gmail.com>.
You may want to consider using JNDI if you're actually trying to map to a
physical filesystem - JCR is better, mind, in that it provides a more useful
document-oriented feature set, but if you're actually NEEDING to work with
the filesystem, a directory structure is one of the samples for JNDI.
2010/4/1 Tim Terlegård <ti...@gmail.com>
> 2010/4/1 Alexander Klimetschek <ak...@day.com>:
> > 2010/4/1 Tim Terlegård <ti...@gmail.com>:
> >> Is it possible to get a nice file hierarchy and not these random
> >> numbers? And is it possible to store the files as plain text instead
> >> of binary?
> >
> > No. In order to provide the features that JCR offers (eg. finer
> > granularity) compared to a normal file system, it is hard to map it
> > 1:1 to the file system, while still being performant.
> >
> > See also http://markmail.org/message/3o26qhrls2u4sj4q
> >
> *> I would recommend to use the H2 or Derby embedded BundleDBPMs together
> > with a FileDataStore for best performance and full local storage.
>
> Thank you very much.
>
> Tim
>
--
Joseph B. Ottinger
http://enigmastation.com
Re: Sane file hierarchy when persisting file/folder nodes
Posted by Tim Terlegård <ti...@gmail.com>.
2010/4/1 Alexander Klimetschek <ak...@day.com>:
> 2010/4/1 Tim Terlegård <ti...@gmail.com>:
>> Is it possible to get a nice file hierarchy and not these random
>> numbers? And is it possible to store the files as plain text instead
>> of binary?
>
> No. In order to provide the features that JCR offers (eg. finer
> granularity) compared to a normal file system, it is hard to map it
> 1:1 to the file system, while still being performant.
>
> See also http://markmail.org/message/3o26qhrls2u4sj4q
>
*> I would recommend to use the H2 or Derby embedded BundleDBPMs together
> with a FileDataStore for best performance and full local storage.
Thank you very much.
Tim
Re: Sane file hierarchy when persisting file/folder nodes
Posted by Alexander Klimetschek <ak...@day.com>.
2010/4/1 Tim Terlegård <ti...@gmail.com>:
> Is it possible to get a nice file hierarchy and not these random
> numbers? And is it possible to store the files as plain text instead
> of binary?
No. In order to provide the features that JCR offers (eg. finer
granularity) compared to a normal file system, it is hard to map it
1:1 to the file system, while still being performant.
See also http://markmail.org/message/3o26qhrls2u4sj4q
I would recommend to use the H2 or Derby embedded BundleDBPMs together
with a FileDataStore for best performance and full local storage.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: Sane file hierarchy when persisting file/folder nodes [SEC=UNCLASSIFIED]
Posted by Ro...@ipaustralia.gov.au.
You can mount the JCR repository using the Webdav interface, and so you
get a view of the repository as if it were all just files in folders.
I don't believe the files are stored in binary, they are really just plain
text.
Ross.
Tim Terlegård <ti...@gmail.com> wrote on 01/04/2010 07:09:21 PM:
> From: Tim Terlegård <ti...@gmail.com>
> To: users@jackrabbit.apache.org
> Date: 01/04/2010 07:10 PM
> Subject: Sane file hierarchy when persisting file/folder nodes
>
> I'm investigating whether using Jackrabbit/JCR is a good abstraction
> when dealing with files.
>
> I created a workspace (myspace) and used BundleFsPersistenceManager.
> When I tried the code below it created the file
> repository/workspaces/myspace/items/54/d6/c2bc4964477ab060d399ea532.n
> I'd rather it create
> repository/workspaces/myspace/items/hi.txt
>
> Is it possible to get a nice file hierarchy and not these random
> numbers? And is it possible to store the files as plain text instead
> of binary?
>
> Thanks,
> Tim
>
>
> Node root = session.getRootNode();
> Node fileNode = root.addNode("hi.txt", "nt:file");
> Node resNode = fileNode.addNode("jcr:content", "nt:resource");
> resNode.setProperty("jcr:mimeType", "text/plain");
> resNode.setProperty("jcr:encoding", "utf8");
> resNode.setProperty("jcr:data", new FileInputStream(new
File("hi.txt")));
> session.save();