jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jenni Pothu" <Jen...@virtusa.com>
Subject RE: Can we add text files to jackrabbit repository
Date Fri, 07 May 2010 03:50:22 GMT
Hi Tomasz,
    Thank you very much Tomasz. The example is very helpful. 

-----Original Message-----
From: Tomasz Łazarecki [mailto:tomasz.lazarecki@gmail.com] 
Sent: Wednesday, May 05, 2010 7:29 PM
To: users@jackrabbit.apache.org
Subject: Re: Can we add text files to jackrabbit repository

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.


      Node fileNode = pathNode.addNode(fileNodeUid, NodeTypes.NT_FILE);
        // Now we are adding nt:resource
        Node resourceNode = fileNode.addNode(PropertyTypes.JCR_CONTENT,
        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()
        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.

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


This message, including any attachments, contains confidential information 
intended for a specific individual and purpose, and is intended for the addressee only. Any
unauthorized disclosure, use, dissemination, copying, or distribution of 
this message or any of its attachments or the information contained in this e-mail, or the
taking of any action based on it, is strictly prohibited. If you are not the intended recipient,
please notify the sender immediately by return e-mail and delete this message.


View raw message