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(","));
}