0

I am trying to create a single file node for an image with name (say A.gif). Now, I want to re-use the file across multiple nodes. Is there a way to do this? As a workaround, I am re-creating file nodes for different paths in my repository, but this results in duplication of files.

4

4 回答 4

1

如果您使用的是jackrabbit,则复制文件节点(或者更确切地说复制二进制属性)很便宜,如果DataStore处于活动状态,则复制文件节点(或者更确切地说复制二进制属性)会很便宜。

该组件确保“大”二进制属性(具有可配置的大小阈值 IIRC)仅存储一次,基于其内容的摘要。

因此,在这种情况下,您可以多次复制同一个文件节点,而不必担心磁盘空间。

于 2012-03-28T20:47:14.007 回答
0

我不确定我是否理解你的问题。但是,我要做的是将文件存储在一个位置,然后使用path来自多个位置的属性来引用它。

假设您有以下节点结构

-content
 - articles
  - article1
  - article2
 - images
  - image1

您可以在每篇文章上设置一个名为的属性,该属性imagePath指向要显示的图像的路径,在本例中为/content/images/image1.

于 2012-03-28T07:21:02.850 回答
0

nt:linkedFile类型就是为这种用途而设计的。

于 2012-04-20T17:49:18.910 回答
0

为了完整起见,不要忘记引用

Node imageNode = rootNode.addNode("imageNode");
imageNode.addMixin(JcrConstants.MIX_REFERENCEABLE);

Node node1 = rootNode.addNode("1");
node1.setProperty("image", imageNode);

Node node2 = rootNode.addNode("2");
node2.setProperty("image", imageNode);

session.save();

PropertyIterator references = imageNode.getReferences();
while (references.hasNext()) {
    Property reference = references.nextProperty();
    System.out.println(reference.getPath());
}
于 2012-04-11T09:36:34.110 回答