4

JCR 2.0 でノードを更新しようとしています

InputStream content = node.getProperty("jcr:content").getProperty("jcr:data").getBinary().getStream();

//TODO same with stream
Binary value = ...;

Node contentNode = node.getProperty("jcr:content");
contentNode.setProperty("jcr:content", value);

そして、「javax.jcr.nodetype.ConstraintViolationException: Item is protected」という例外が発生します。どうしたの?

4

1 に答える 1

4

The "jcr:content" you're referring to is typically the name of a child node (usually of type nt:resource, or something similar), rather than a property. Thus your code sample should rather be:

// read value
Binary value = node.getNode("jcr:content").getProperty("jcr:data").getBinary();

// update value
Binary value = ...;
node.getNode("jcr:content").setProperty("jcr:data", value);

See also the putFile() utility methods in the JcrUtils class of the jackrabbit-jcr-commons library.

于 2011-10-18T14:18:19.363 に答える