jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fernando Cabredo <fcabred...@yahoo.com>
Subject Versioning nt:file Types
Date Wed, 18 Mar 2009 14:25:50 GMT
Hi,

I have a file located at /pics/picture297.jpg and I would like to add my c://download/picture297.jpg
as a new version into the node.

I have the code below for the above problem.

             file = new File("c://download//picture297.jpg");
             Node root = session.getRootNode();
             Node fileNode = root.getNode("/pics/picture297.jpg");
             fileNode.checkout();
             fileNode.addMixin("mix:versionable");
             Node resNode = fileNode.addNode ("jcr:content", "nt:resource");
             resNode.setProperty ("jcr:mimeType", mimeType);
             resNode.setProperty ("jcr:encoding", "");
             resNode.setProperty ("jcr:data", new FileInputStream (file));
             Calendar lastModified = Calendar.getInstance ();
             lastModified.setTimeInMillis (file.lastModified ());
             resNode.setProperty ("jcr:lastModified", lastModified);
             session.save();

However, it is causing  the following errors:
   javax.jcr.ItemExistsException: /pics/picture297.jpg/jcr:content
    at org.apache.jackrabbit.rmi.server.ServerObject.getRepositoryException(ServerObject.java:110)
    at org.apache.jackrabbit.rmi.server.ServerNode.addNode(ServerNode.java:82)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

I would like also to list the file names of the different versions created on the node.

Any help will be much appreciated.

Thank you.


Fernando Cabredo


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