All, I'm trying to version binary content and running into some problems. I can get the initial version in to the JCR just fine, but getting it back out is a different story all together.
Here is the code I'm doing to get binary data into the initial version: //start code Node root = session.getRootNode(); Node customerNode = createNodeIfNotThere(root, created.getProject ().getCustomer().getId().toString()); Node projectNode = createNodeIfNotThere(customerNode, created.getProject().getId().toString()); Node resourceNode = createNodeIfNotThere(projectNode, created.getId ().toString()); Node version1Node = resourceNode.addNode(constants.getJCR_CONTENT(), constants.getNT_RESOURCE()); version1Node.setProperty(constants.getJCR_MIMETYPE(), created.getContentType()); Calendar lastModified = Calendar.getInstance(); lastModified.setTimeInMillis(created.getModifiedDate().getTime()); version1Node.setProperty(constants.getJCR_LASTMODIFIED(), lastModified); version1Node.setProperty(constants.getJCR_DATA(), created.getFileInput ().getInputStream()); version1Node.addMixin(constants.getMIX_VERSIONABLE()); session.save(); version1Node.checkin(); //end code The createNodeIfNotThere method is probably pretty self expanatory, but it creates a node as a child of the provided node with the provided name. Here is the code I'm doing to try and get the binary data back out: //start code Node root = session.getRootNode(); Node customerNode = root.getNode(resource.getProject().getCustomer ().getId().toString()); Node projectNode = customerNode.getNode(resource.getProject().getId ().toString()); Node resourceNode = projectNode.getNode(resource.getId().toString()); Node contentNode = resourceNode.getNode(constants.getJCR_CONTENT()); VersionHistory versionHistory = contentNode.getVersionHistory(); Version jcrVersion = versionHistory.getAllVersions().nextVersion(); Node frozen = jcrVersion.getNode(constants.getJCR_FROZENNODE()); Property property = frozen.getProperty(constants.getJCR_DATA()); return property.getStream(); //end code This seems right based on some previous messages I've read about this topic, however the line that gets the JCR_DATA property throws a javax.jcr.PathNotFoundException. Anyone have any ideas? Am I doing something glaringly wrong here? thanks, -jeff
