jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shanmugam Gopal" <haishanmu...@hotmail.com>
Subject How to check in a file node ??
Date Thu, 24 Aug 2006 15:21:51 GMT
Hai,

I have created a file node as below.

         File file = new File("C:\\gif\\Hello.html");
         MimeTable mt = MimeTable.getDefaultTable();
         String mimeType = mt.getContentTypeFor(file.getName());
         if (mimeType == null) {
           mimeType = "application/octet-stream";
         }

         Node hello = rootNode.addNode(file.getName(), "nt:file");
         hello.addMixin("mix:versionable");
         Node resourceNode = hello.addNode("jcr:content", "nt:resource");
         resourceNode.setProperty("jcr:mimeType", mimeType);
         resourceNode.setProperty("jcr:encoding", "");
         resourceNode.setProperty("jcr:data", new FileInputStream(file));
         Calendar lastModified = Calendar.getInstance();
         lastModified.setTimeInMillis(file.lastModified());
         resourceNode.setProperty("jcr:lastModified", lastModified);

For checking out that particular node, I have the following code.

             node.checkout();
             InputStream stream = node.getProperty(
                 "jcr:content/jcr:data").getStream();
             FileOutputStream fos = new FileOutputStream(
                 "C:\\checkin\\" + node.getName());
             byte[] content = new byte[stream.available()];
             stream.read(content);
             fos.write(content);
             fos.flush();
            fos.close();

Now, after making some changes to the file, I want to checkin back to the 
repository.

But If use node.setProperty("jcr:content/jcr:data", new 
FileInputStream(file)),
It throws some exception.

Anyone can suggest how to checkin a file node??

Regards,
Shan

_________________________________________________________________
NRIs: Send Money FREE! Go ahead and register now! 
http://ads.mediaturf.net/event.ng/Type=click&FlightID=20273&AdID=65989&TargetID=11172&Targets=11172&Values=202,414,1093,1264,3122&Redirect=http:%2F%2Fwww.icicinri.net%2Fmoney2india%2F%3Fm2i%3DBAC-MSN%26att%3DMSNTLM2I18CHAR%26rfr%3DMSNTLM2I18CHAR


Mime
View raw message