Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: RE: DLFileEntryLocalServiceUtil.updateFileEntry is saving the file as a
Hello, 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!
Hi,
You can use DLApplocalservice instead of DLFileEntryLocalService for saving the file.
Ex.
DLAppLocalServiceUtil.updateFileEntry(userId, fileEntryId, sourceFileName, mimeType, title, description, changeLog, majorVersion, file, serviceContext)
Hello 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 :(
You can set DDMFormValues in ServiceContext object with name as below
serviceContext.setAttribute(DDMFormValues.class.getName() + StringPool.POUND +
ddmStructure.getStructureId(), ddmFormValues);
Thank 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
Powered by Liferay™