Liferay DLFileEntryLocalServiceUtil.addFileEntry不会创建AssetEntry记录

时间:2013-11-29 10:44:40

标签: java liferay portlet

我有一个自定义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(","));
}

3 个答案:

答案 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'这个服务,也许你的问题就解决了。