我尝试更新 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);
Run Code Online (Sandbox Code Playgroud)
我收到异常“javax.jcr.nodetype.ConstraintViolationException:项目受保护”。怎么了?
您所指的“jcr:content”通常是子节点的名称(通常为 nt:resource 或类似类型),而不是属性。因此,您的代码示例应该是:
// read value
Binary value = node.getNode("jcr:content").getProperty("jcr:data").getBinary();
// update value
Binary value = ...;
node.getNode("jcr:content").setProperty("jcr:data", value);
Run Code Online (Sandbox Code Playgroud)
另请参阅jackrabbit-jcr-commons 库的JcrUtils 类中的 putFile() 实用程序方法。
| 归档时间: |
|
| 查看次数: |
3743 次 |
| 最近记录: |