Liferay DLFileEntryLocalServiceUtil.addFileEntry不会创建AssetEntry记录
我有一个自定义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(",")); }
仅调用DLFileEntryLocalServiceUtil.addFileEntry
不够的
在addFileEntry
之后调用DLFileEntryLocalServiceUtil.updateStatus(userId, fileVersionId, WorkflowConstants.STATUS_APPROVED, emptyMap, serviceContext);
使用此方法,可以创建和发布AssetEntry
你在门户网站上检查了这个属性吗?
#asset.renderer.enabled.com.liferay.portlet.documentlibrary.asset.DLFileEntryAssetRendererFactory=