Liferay DLFileEntryLocalServiceUtil.addFileEntry does not create AssetEntry record

戏子无情 提交于 2019-12-05 05:23:09

问题


I have a custom portlet which provides a form where the user can upload files. The uploaded file should be stored in the Documents and Media Portlet. I am creating the file entry using 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. I suppose Liferay should create it automatically, am I wrong? 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); )

I have the following 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(","));
}

回答1:


It's not enough calling only DLFileEntryLocalServiceUtil.addFileEntry

After addFileEntry call DLFileEntryLocalServiceUtil.updateStatus(userId, fileVersionId, WorkflowConstants.STATUS_APPROVED, emptyMap, serviceContext);

With this method the AssetEntry is created and published




回答2:


Did you check this property in your portal -

#asset.renderer.enabled.com.liferay.portlet.documentlibrary.asset.DLFileEntryAssetRendererFactory=



来源:https://stackoverflow.com/questions/20283885/liferay-dlfileentrylocalserviceutil-addfileentry-does-not-create-assetentry-reco

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!