Liferay DLFileEntryLocalServiceUtil.addFileEntry不会创建AssetEntry记录 [英] Liferay DLFileEntryLocalServiceUtil.addFileEntry does not create AssetEntry record

查看:156
本文介绍了Liferay DLFileEntryLocalServiceUtil.addFileEntry不会创建AssetEntry记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义portlet,它提供了一个用户可以上传文件的表单。上传的文件应存储在Documents and Media Portlet中。我正在使用 DLFileEntryLocalServiceUtil.addFileEntry 创建文件条目。该文件已成功上载,并且 DLFileEntry 表中的记录已创建,但在 AssetEntry 表中未创建新记录。我想Liferay应该自动创建它,我错了吗?
哪里可能是错误?

I have a custom portlet which provides a form where the user can upload files. The uploaded file should be stored in the Documents and Media Portlet. I am creating the file entry using DLFileEntryLocalServiceUtil.addFileEntry. The file is succesfully uploaded and the record in DLFileEntry table is created, but in the AssetEntry table no new record is created. I suppose Liferay should create it automatically, am I wrong? Where could be the error?

这是我的代码:

DLFileEntry dlFileEntry = DLFileEntryLocalServiceUtil.addFileEntry(user.getUserId(),
    groupId,
    groupId, //repositoryId,
        folder.getFolderId(),
    fName,
    mimeType,
    title,
    "", //description
    "", //changeLog,
    0,  //fileEntryTypeId
    null,   //fieldsMaps
    file,
    null,   //inputstream
    file.length(),
    serviceContext);

我从 UploadPortletRequest 获取表单数据object( UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);

I get the form data from the UploadPortletRequest object ( UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest); )

我有以下 ServiceContext

ServiceContext serviceContext = new ServiceContext();
long[] assetCategoryIds = new long[assetCategoryIdsList.size()];
for (int i = 0; i < assetCategoryIdsList.size(); i++) {
    assetCategoryIds[i] = assetCategoryIdsList.get(i);
}
serviceContext.setAssetCategoryIds(assetCategoryIds);
serviceContext.setScopeGroupId(groupId);
if(!tagNames.equals("")) {
    serviceContext.setAssetTagNames(tagNames.split(","));
}


推荐答案

仅仅呼叫 DLFileEntryLocalServiceUtil.addFileEntry

之后> addFileEntry 致电 DLFileEntryLocalServiceUtil.updateStatus(userId,fileVersionId,WorkflowConstants.STATUS_APPROVED,emptyMap,serviceContext);

使用此方法 AssetEntry 已创建并发布

With this method the AssetEntry is created and published

这篇关于Liferay DLFileEntryLocalServiceUtil.addFileEntry不会创建AssetEntry记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆