[英]Liferay DLFileEntryLocalServiceUtil.addFileEntry does not create AssetEntry record
I have a custom portlet which provides a form where the user can upload files.我有一个自定义 portlet,它提供了一个表单,用户可以在其中上传文件。 The uploaded file should be stored in the Documents and Media Portlet.
上传的文件应存储在文档和媒体 Portlet 中。 I am creating the file entry using
DLFileEntryLocalServiceUtil.addFileEntry
.我正在使用
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.该文件被成功地上传和记录
DLFileEntry
创建表,但在AssetEntry
表不会创建任何新的记录。 I suppose Liferay should create it automatically, am I wrong?我想 Liferay 应该自动创建它,我错了吗? Where could be the error?
错误可能在哪里?
This is my code:这是我的代码:
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);
I get the form data from the UploadPortletRequest
object ( UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
)我从
UploadPortletRequest
对象获取表单数据( UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
)
I have the following ServiceContext
:我有以下
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(","));
}
It's not enough calling only DLFileEntryLocalServiceUtil.addFileEntry
仅调用
DLFileEntryLocalServiceUtil.addFileEntry
不够的
After addFileEntry
call DLFileEntryLocalServiceUtil.updateStatus(userId, fileVersionId, WorkflowConstants.STATUS_APPROVED, emptyMap, serviceContext);
addFileEntry
调用DLFileEntryLocalServiceUtil.updateStatus(userId, fileVersionId, WorkflowConstants.STATUS_APPROVED, emptyMap, serviceContext);
With this method the AssetEntry
is created and published使用此方法创建并发布
AssetEntry
您是否在门户中检查过此属性 -
#asset.renderer.enabled.com.liferay.portlet.documentlibrary.asset.DLFileEntryAssetRendererFactory=
你可以使用'com.liferay.document.library.kernel.service.DLAppServiceUtil'这个服务,可能你的问题就解决了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.