我有一个自定义portlet,它提供了一个用户可以上传文件的表单。上传的文件应存储在Documents and Media Portlet中。我正在使用DLFileEntryLocalServiceUtil.addFileEntry
创建文件条目。该文件已成功上载,并且DLFileEntry
表中的记录已创建,但在AssetEntry
表中未创建新记录。我想Liferay应该自动创建它,我错了吗?
哪里可能是错误?
这是我的代码:
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
对象(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(","));
}
答案 0 :(得分:2)
仅调用DLFileEntryLocalServiceUtil.addFileEntry
addFileEntry
致电DLFileEntryLocalServiceUtil.updateStatus(userId, fileVersionId, WorkflowConstants.STATUS_APPROVED, emptyMap, serviceContext);
后
使用此方法创建并发布AssetEntry
答案 1 :(得分:0)
您是否在门户中检查了此属性 -
#asset.renderer.enabled.com.liferay.portlet.documentlibrary.asset.DLFileEntryAssetRendererFactory=
答案 2 :(得分:0)
你可以使用'com.liferay.document.library.kernel.service.DLAppServiceUtil'这个服务,也许你的问题就解决了。