将各种类型的文档(ods、ms office、pdf)保存到 Jackrabbit 存储库中
我不确定选择什么方法来存储这些类型的文档,因为关键要求是收集尽可能多的元数据,并且 pdf、ods 和 MS Office 文档具有 各种类型的元数据 ...
这样,如果节点树具有“组/用户/类别/文档”或“类别/组/用户/文档”结构(我不是确定哪个更好),如果每个文档是 pdf/doc/odt/ppt 等,则每个文档都必须有一个属性“类型”,并且我每次都必须对此进行测试,以了解它具有哪些元数据类型, 正确的 ?在我看来非常无效。。
I'm not sure what approach to choose for storing those types of documents because the key requirement is to gather as much metadata as possible and pdf, ods and MS office documents have various types of metadata ...
So that if the node tree has a "group/user/category/document" or "category/group/user/document" structure (I'm not sure about that what is better), each document would have to have a property "type" if it is pdf/doc/odt/ppt etc., and I would have to test for this every time, to know which metadata types it has, right ? It seems to me very ineffective..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我个人会尽量避免构建层次结构以包含文件类型。这确实可行,但似乎是强迫和不自然的。
相反,我会将我的层次结构设计为最适合您的应用程序(例如,如果您有组和用户,那么可能是“组/用户”并将用户的文档存储在相应的用户节点下),并使用属性来捕获文件类型和附加元数据。
如果您使用“nt:file”约定将文件上传到 JCR,则每个文件都将用一个类型为“nt:file”的节点(根据文件名命名)表示。然后,该节点将包含一个名为“jcr:content”的子节点,并且约定是对该子节点使用“nt:resource”节点类型。在 JCR 2.0 中,“nt:resource”节点类型定义了以下属性定义:
请注意,JCR 实现允许将“jcr:mimeType”和“jcr:encoding”视为受保护,但 Jackrabbit 和 ModeShape 执行此操作(意味着您可以而且必须手动设置这些属性)。
以下是用于上传文件并设置“jcr:mimeType”属性的代码片段:
现在,开箱即用的“nt:file”和“nt:resource”节点类型不允许您设置它们所需要的属性不要定义。但是您可以使用 mixin 来绕过此限制,并将元数据直接存储在这些节点上。请参阅我的详细答案,描述如何在之前的其他问题。
I personally would try to avoid structuring your hierarchy to include the file type. That would work, but it seems forced and unnatural.
Instead, I would design my hierarchy to be the most natural for your application (e.g., if you have groups and users, then maybe "group/user" and store a user's documents under the respective user node), and use properties to capture the file type and additional metadata.
If you upload a file into JCR using the "nt:file" convention, each file would be represented with a node (named according to the file's name) with a type of "nt:file". That node would then contain a single child node named "jcr:content", and convention is to use the "nt:resource" node type for this child node. In JCR 2.0, the "nt:resource" node type defines these property definitions:
Note that JCR implementations are allowed to treat "jcr:mimeType" and "jcr:encoding" as protected, but neither Jackrabbit and ModeShape do this (meaning you can and must manually set these properties).
Here is a code snippet for uploading a file and setting the "jcr:mimeType" property:
Now, out of the box, the "nt:file" and "nt:resource" node types don't allow you to set properties that they don't define. But you can use mixins to get around this limitation, and store the metadata directly on these nodes. See my detailed answer describing how to do this on earlier other question.