jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Korbinian Bachl - privat <korbinian.ba...@whiskyworld.de>
Subject some doubts after my first hops
Date Wed, 25 Feb 2009 18:53:41 GMT
Hi,

some time ago I had a look at Brix (wicket-cms) and stumbled over
Jackrabbit and JCR. I had not much time till last weekend and decided
then to fight my way through the Jackrabbit-Docs and wiki.

I think I understood much of it, however versioning as well as the right
usage in production is not as clear as I hoped it would be.

I have an inhouse java app here (wicket based webapp with spring + jpa)
that creates files and want to store them in a JCR so I can change my
persitence based upon my needs. The files are recreated on a daily base
and so I thought that versioning is the way to go. So I created a basic
"saveFile" method:

public static void createVersionableFileNode(Node folderNode, File file,
String fileName, String mimeType, String encoding, Session session)
             throws RepositoryException, IOException {

         Node fileNode;
         Node resNode;
         //create the file node
         try {
             fileNode = folderNode.getNode(fileName);
             log.info("FileNode {} existiert bereits; versioning...",
file.getName());
         }
         catch (PathNotFoundException e) {
             fileNode = folderNode.addNode(fileName, JcrConstants.NT_FILE);
             log.info("FileNode {} existiert nicht; creation...",
file.getName());
             fileNode.addMixin(JcrConstants.MIX_VERSIONABLE);
         }

         //same for resNode
         try {
             resNode = fileNode.getNode(JcrConstants.JCR_CONTENT);
             log.info("ResNode existiert bereits");
         }
         catch (PathNotFoundException e) {
             resNode = fileNode.addNode(JcrConstants.JCR_CONTENT,
JcrConstants.NT_RESOURCE);
             log.info("ResNode wurde erstellt");
         }

         fileNode.checkout();

         //create the mandatory filecontent-child node
         resNode.setProperty(JcrConstants.JCR_MIMETYPE, mimeType);
         resNode.setProperty(JcrConstants.JCR_ENCODING, encoding);
         resNode.setProperty(JcrConstants.JCR_DATA, new
FileInputStream(file));
         Calendar lastModified = Calendar.getInstance();
         lastModified.setTimeInMillis(file.lastModified());
         resNode.setProperty(JcrConstants.JCR_LASTMODIFIED, lastModified);

         session.save();
         fileNode.checkin();
     }

In test all works perfect, but what worries me at the moment is following:

-> Why do I have to do soo much work for just saving a file? Did I miss
an easier approach?

-> In the Jackrabbit-Doc i haven't found a word about versioning and its
behaviours of childs (neither in the JCR spec) - so how will a
parent-Node that is versioned react when
a, a versioned child changes?
b, a non-versioned child changes?

-> I saw that there is also an OCM; When should one use it and when not?
Would my file-scenario make sense to take usage of the OCM?

Best,

Korbinian




Mime
View raw message