I'm newbie in Liferay and I need to parse some XML documents to put them into Liferay. By now, I'm able to create and add the JournalArticles into Liferay. The problem I'm facing is that those xml have images or documents and I'm not able to upload them.
For images, I'm getting the url from the xml, I create an inputStream and then I create a Map from the inputStream. This map is put in the method JournalArticleLocalServiceUtil, but when the Journal is created, the image is not uploaded/attached. The code is the next:
JournalArticle newJournalArticle = JournalArticleLocalServiceUtil.addArticle(
userId,
groupId,
exampleArticle.getFolderId(),
exampleArticle.getClassNameId(),
exampleArticle.getClassPK(),
"",
true,
1D,
titleMap,
null,
journalContent,
exampleArticle.getType(),
exampleArticle.getStructureId(),
exampleArticle.getTemplateId(),
exampleArticle.getLayoutUuid(),
c.get(Calendar.MONTH),
c.get(Calendar.DAY_OF_MONTH),
c.get(Calendar.YEAR),
c.get(Calendar.HOUR),
c.get(Calendar.MINUTE),
0, 0, 0, 0, 0, true,
0, 0, 0, 0, 0, true,
true,
false, (false or true, the image is not uploaded)
null,
null,
imageMap, -> image map created before
articleURL,
serviceContext);
newJournalArticle.persist();
If the map is created correctly, with this code should be uploaded? Or in liferay I need to upload the files to documents and media and then attach them to the Journal somehow?
For documents I've been seeking but it's not clear, how do I upload documents to attach them to a Journal? Should I use DLAppLocalServiceUtil or getUploadPortletRequest to upload files?
I hope someone could guide me. Thank you!
EDIT Well, images must be uploaded to documents and media first. This can be done with the methods found here: http://liferayiseasy.blogspot.in/2015/07/folder-and-file-upload-programmatically.html
Now, I must link the images uploaded to the articles created.
Regards.
imageMap
? What is the key? – glwelInstanceId + "_" + elName + elLanguage
– glw