I use the inputstream from the file to create an instance of 
javax.jcr.Binary, and set that, not just the inputstream.  I dont know if 
the code that reads the text contents uses the mime type to know how to 
read the data, but I would say it probably does.

        Node file = appNode.addNode(documentId, "nt:file");
                    Node resource = file.addNode("jcr:content", 
"ed:docreftype");
                    InputStream in = new FileInputStream(fileName);
 
                    Binary binary = 
session.getValueFactory().createBinary(in);
                    binary.dispose();

                    resource.setProperty("jcr:data", binary);
                    String mimeType = null;
                    if (fileName.endsWith(".txt")) {
                        mimeType = "text/plain";
                    }
                    else if (fileName.endsWith(".xls")) {
                        mimeType = "application/vnd.ms-excel";
                    }
                    else if (fileName.endsWith(".ppt")) {
                        mimeType = "application/mspowerpoint";
                    }
                    else {
                        mimeType = "application/octet-stream";
                    }

                        resource.setProperty("jcr:mimeType", mimeType);

Ross

"Jenni Pothu" <[email protected]> wrote on 12/05/2010 09:23:49 PM:

> From: "Jenni Pothu" <[email protected]>
> To: <[email protected]>
> Date: 12/05/2010 09:24 PM
> Subject: Not returning any result when I am doing text search from 
> added file from jackrabbit
> 
> Hi All,
> 
>                 I am attaching the file to blogEntry node and blogEntry
> node is added into repository. Now I want to search the content from the
> added file.
> 
> 
> 
>      I have node like blogEntry and I am adding file to that node like
> below
> 
>                                                 //getting the
> blogEntryNode form method getBlogEntryNode(blogTitle, session);
> 
> Node blogEntryNode = getBlogEntryNode(blogTitle, session);
> 
> Node NewblogEntry = blogEntryNode.addNode("NewblogEntry", "nt:file");
> 
>                   Node resNode = NewblogEntry.addNode("jcr:content",
> "nt:resource");
> 
>                   resNode.setProperty("jcr:data", file);
> 
> 
> 
> here file is of type Inputstream.
> 
> 
> 
> When I am searching with the  query like Query query =
> queryManager.createQuery
> 
>                   ("//blogEntry/NewblogEntry(*, nt:file)[jcr:contains(.,
> '"+sometext+"')]",Query.XPATH);
> 
> Here sometext is any content which I want to search in the file.
> 
> 
> 
> My query not returning any result. Is my query correct. Please correct
> me if anything wrong in the code. 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.
> 
> 
--------------------------------------------------------------------------------------------
--
This message contains privileged and confidential information only 
for use by the intended recipient.  If you are not the intended 
recipient of this message, you must not disseminate, copy or use 
it in any manner.  If you have received this message in error, 
please advise the sender by reply e-mail.  Please ensure all 
e-mail attachments are scanned for viruses prior to opening or 
using.

Reply via email to