Message Boards
DLFileEntryLocalServiceUtil.updateFileEntry is saving the file as a draft
DLFileEntryLocalServiceUtil.updateFileEntry is saving the file as a draft
New Member Posts: 16 Join Date: 11/25/19 Recent PostsHello, I need to put some DDMFormValues to a set of files that are already uploaded on my instance, and I found a way to do that with the DLFileEntryLocalServiceUtil.updateFileEntry method, as one of the parameters is a map with the DDMFormValues.
I've created a component that calls that method for each of the files that I need to update, and it's putting the metadata values, but the file is saved as a Draft, and the file entry's tags have been removed.
I suppose that maybe the tags should be in the DDMFormValues' map, but, how can I save the file as approved?
A portion of code of a try that i'm doing with a file: (I'm using DXP 7.1)
DLFileEntry dlFileEntry = DLFileEntryLocalServiceUtil.getDLFileEntry(43432);
File file = DLFileEntryLocalServiceUtil.getFile(dlFileEntry.getFileEntryId(), dlFileEntry.getVersion(), false);
InputStream is = DLFileEntryLocalServiceUtil.getFileAsStream(dlFileEntry.getFileEntryId(), dlFileEntry.getVersion());
ServiceContext serviceContext = new ServiceContext();
DLFileEntry dlFileEntryUpdated = DLFileEntryLocalServiceUtil.updateFileEntry(dlFileEntry.getUserId(), dlFileEntry.getFileEntryId(), dlFileEntry.getFileName(), dlFileEntry.getMimeType(), dlFileEntry.getTitle(), dlFileEntry.getDescription(), "TEST", false, dlFileEntry.getFileEntryTypeId(), ddmFormValuesMap, file, null, dlFileEntry.getSize(), serviceContext);
Thanks and regards!
RE: DLFileEntryLocalServiceUtil.updateFileEntry is saving the file as a dra (Answer)
Liferay Master Posts: 591 Join Date: 8/8/14 Recent PostsHi,
You can use DLApplocalservice instead of DLFileEntryLocalService for saving the file.
Ex.
DLAppLocalServiceUtil.updateFileEntry(userId, fileEntryId, sourceFileName, mimeType, title, description, changeLog, majorVersion, file, serviceContext)
RE: RE: DLFileEntryLocalServiceUtil.updateFileEntry is saving the file as a
New Member Posts: 16 Join Date: 11/25/19 Recent PostsHello Mohammed! Thanks for the suggestion. In this case, how could I set the DDMFormValues of the fileEntry? It doesn't appear in the parameter list, and they are the only reason of the update :(
RE: RE: DLFileEntryLocalServiceUtil.updateFileEntry is saving the file as a
Liferay Master Posts: 591 Join Date: 8/8/14 Recent PostsYou can set DDMFormValues in ServiceContext object with name as below
serviceContext.setAttribute(DDMFormValues.class.getName() + StringPool.POUND +
ddmStructure.getStructureId(), ddmFormValues);
RE: RE: DLFileEntryLocalServiceUtil.updateFileEntry is saving the file as a
New Member Posts: 16 Join Date: 11/25/19 Recent PostsThank you Mohammed, that solved the problem I was facing. However later I had other problems with the DDMFormValues and finally changed them for expando fields, that to me are less problematic to work with. Anyway, thanks for your help!
Regards