1 May 2009 02:32
OCM: Adding nodes externally (directly using the session)
Edgar Merino <donvodka <at> gmail.com>
2009-05-01 00:32:00 GMT
2009-05-01 00:32:00 GMT
Hello,
This is the scenario: I've got an OCM entity (wrapping a node, path
"/myNode"), I'm adding some resources (images) to the node using the jcr
Session directly (code below), however when I try to persist changes
(either using Session#save() or ObjectContentManager#save()) I get:
javax.jcr.RepositoryException: /: unable to update item.: failed to
write bundle: 9d42543e-87df-4b0e-82cf-a580e9922fa8. I need to add a list
of images (nt:file nodes) to myNode, I cannot use OCM's default mapping
of InputStream as a field in the mapped node, because I need all the
properties to be Serializable (and InputStream is not Serializable).
Are you able to see what am I doing wrong? thanks in advance,
Edgar Merino
<!-- CODE THAT GENERATES THE EXCEPTION -->
ObjectContentManager manager = ...; //retrieve manager
OCMNode myOCMNode = new OCMNode();
// ... fill properties ...
manager.insert(myOCMNode);
//obtain the session from the ObjectContentManager
Session session = manager.getSession();
Node entryNode = session.getRootNode().getNode("myNode");
Node fileNode = entryNode.addNode(fileName, "nt:file");
Node imageNode = fileNode.addNode("jcr:content", "nt:resource");
imageNode.setProperty("jcr:mimeType", mimeType);
(Continue reading)
RSS Feed