如何将具有附加属性的文件添加到 Liferay 的文档库中

发布于 2024-10-24 04:01:57 字数 667 浏览 3 评论 0原文

我想弄清楚这一点,我在 中问这个问题Liferay 的论坛在这里 - 最后一个条目。

我唯一能想到的就是创建一个 Expando 用于FileEntry,看起来很复杂。谁知道这是否有意义。我不喜欢 Expando 功能,因为我无法通过休眠正确查询它们。

有人知道 Liferay 论坛中我的问题的答案吗?

问题是,

DLAppLocalServiceUtil.addFileEntry(...);
DLLocalServiceUtil.addFile(....);

不允许您存储有关文件的任何附加信息/属性。因此,必须直接使用 JackRabbit,而不是使用 Liferay 的 JCRHook。但是您失去了文档库带来的所有优势。

I'm trying to figure this out, I was asking this question in Liferay's forum here - the last entry.

And only thing I'm able to come up with is creating an Expando for FileEntry, which seems very complicated. Who knows if it makes sense. I don't like the expando feature since I couldn't query them via hibernate properly.

Does anybody know the answer for my question in that Liferay forum ?

The problem is that,

DLAppLocalServiceUtil.addFileEntry(...);
DLLocalServiceUtil.addFile(....);

doesn't let you store any additional information / properties about the file. As a result, one would have to use JackRabbit directly, instead of using Liferay's JCRHook. But you loose all the advantages that Document Library brings.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

智商已欠费 2024-10-31 04:01:57

是的,唯一的选择是使用 Expando AKA 自定义属性/字段。对于 fileEntry,您不需要以编程方式创建表和列,但您可以在“控制面板”>“控制面板”中进行设置。自定义字段。

之后,您可以选择如何填充扩展值。

fileEntry.getExpandoBridge().setAttribute("propName", "propValue")

或者如果你从视图层获取属性

<liferay-ui:custom-attributes-available className="<%= DLFileEntry.class.getName() %>">
    <liferay-ui:custom-attribute-list
        className="<%= DLFileEntry.class.getName() %>"
        classPK="<%= (fileVersion != null) ? fileVersion.getFileVersionId() : 0 %>"
        editable="<%= true %>"
        label="<%= true %>"
        />
</liferay-ui:custom-attributes-available>

,然后

ServiceContext serviceContext = ServiceContextFactory.getInstance(
            DLFileEntry.class.getName(), actionRequest);

serviceContext 被 actionRequest 中的参数填充,然后你只需调用

fileEntry.getExpandoBridge().setAttributes(serviceContext)

最后,你可能需要查询具有特定属性的 fileEntries

public Hits search() {
     Map<String, Serializable> attributes = new HashMap<String, Serializable>();
     attributes.put("propertyName", "propertyValue");

     SearchContext searchContext = new SearchContext();
     searchContext.setAttributes(attributes);
     Indexer indexer = IndexerRegistryUtil.getIndexer(FileEntry.class);
     return indexer.search(searchContext);
}

当然,这个解决方案可能看起来有点复杂,因为 Liferay 文档库不是 JCR 内容存储库,但它实际上是一个文档库,它通过 Hooks 为具体存储库实现提供抽象层,例如 JCRHook(其中文件存储到 jackrabbit 存储库)、CMIS 支持、迁移支持等。它还处理权限检查、文件版本控制、文档工作流程和资产管理。

因此,如果您打算做一些更复杂的事情,则必须查询属性/元数据、更改它们并扩展它们。您应该考虑直接使用 JCR 存储库...

Yep, the only option is to use Expando AKA custom properties/fields. In case of fileEntry you don't need to create table and columns programmatically but you can set it up in Control Panel > custom fields.

After that you have a few options how to populate the expando values.

fileEntry.getExpandoBridge().setAttribute("propName", "propValue")

or if you get the properties from view layer

<liferay-ui:custom-attributes-available className="<%= DLFileEntry.class.getName() %>">
    <liferay-ui:custom-attribute-list
        className="<%= DLFileEntry.class.getName() %>"
        classPK="<%= (fileVersion != null) ? fileVersion.getFileVersionId() : 0 %>"
        editable="<%= true %>"
        label="<%= true %>"
        />
</liferay-ui:custom-attributes-available>

and then

ServiceContext serviceContext = ServiceContextFactory.getInstance(
            DLFileEntry.class.getName(), actionRequest);

serviceContext gets populated by parameters in actionRequest and you then just call

fileEntry.getExpandoBridge().setAttributes(serviceContext)

Finally, you may need to query for fileEntries with particular properties

public Hits search() {
     Map<String, Serializable> attributes = new HashMap<String, Serializable>();
     attributes.put("propertyName", "propertyValue");

     SearchContext searchContext = new SearchContext();
     searchContext.setAttributes(attributes);
     Indexer indexer = IndexerRegistryUtil.getIndexer(FileEntry.class);
     return indexer.search(searchContext);
}

Of course, this solution may seem a little complicated, because Liferay Document Library is not a JCR content repository, but it's literally a document library that provides abstraction layer for concrete repo implementations via Hooks, such as JCRHook ( where files are stored into jackrabbit repository ), CMIS support, migration support etc. It also handles permissionChecking, fileVersioning, document workflow and asset management.

So if you intend to do something more complicated and you will have to query the properties/metadata, change them and expand them. You should consider using JCR repository directly...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文