jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tomasz Łazarecki <tomasz.lazare...@gmail.com>
Subject Re: Can we add text files to jackrabbit repository
Date Wed, 05 May 2010 13:58:46 GMT
Yes you can.

Simply add you nodes as nt:file and nt:resource . Nt:file has name and
property of nt:resource.
Nt:resource has some useful properties that represents properties of a
"file" like data (input stream) , mime type  etc.


Example:

      Node fileNode = pathNode.addNode(fileNodeUid, NodeTypes.NT_FILE);
        // Now we are adding nt:resource
        Node resourceNode = fileNode.addNode(PropertyTypes.JCR_CONTENT,
                NodeTypes.NT_VRESOURCE);
        resourceNode.setProperty(PropertyTypes.JCR_RESOURCE_NAME, filename);
        resourceNode.setProperty(PropertyTypes.JCR_MIMETYPE, mimeType);
        resourceNode.setProperty(PropertyTypes.JCR_ENCODING, encoding);
        resourceNode.setProperty(PropertyTypes.JCR_LAST_MODIFIED, new Date()
                .getTime());
        resourceNode.setProperty(PropertyTypes.JCR_DATA, in);

PropertyTypes and NodeTypes are my custom classes with public static final
string variables because i'm using jackrabbit 1.6. You can wirite nt:file,
nt:resource, jcr:data, jcr:last_modified etc. instead. To check what kind of
properties you can set, you should look into jcr specyfication.  To add text
file you should add new nt:file with nt:resource with data containing input
stream to the text file and jcr:mimeType of "text/plain" . Remember to call
session.save() after adding nodes! To check new created nodes you should use
web dav api. Just write localhost:8080/jackrabbit/ in you browser.

Regards
Tomasz Łazarecki



.2010/5/5 Jenni P <jenni.sjr@gmail.com>

> Hi All,
>      I am new to the Jackrabbit repository. I want to add the text file to
> the jackrabbit repository. can we add text files to the repository. I tried
> the example to add the nodes to the repository. But how to check whether
> nodes are added or not in repository. where to check the nodes in my
> machine. please guide me. Thanks in advance.
>
> Thanks,
> jenni
>

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