我有一个自定义 portlet,它提供了一个用户可以上传文件的表单。上传的文件应存储在文档和媒体 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(","));
}