Message Boards

Groovy to Update JournalArticle

Iñigo Boyano, modified 3 Years ago.

Groovy to Update JournalArticle

Junior Member Posts: 96 Join Date: 2/4/14 Recent Posts
Hi, 

I have a lot of contents with images in a structre fields of Documents And Media. I've seen that if you put those images in a field type of Image, i can use the Adapted Images funcionality in order to resize images by screen size.

My problem is that all of the contents have to be republished in order to the structure change (Documents and Media to Images) of the contents have effect.

To do that, i'm developing a groovy to select all of this JournalArticles and republished it but when I use the JournalArticleLocalService API i found a few problems:

* The categories and related contents are missing after the update. I think i solved it getting the categories and links and put them in the service context.
* The content have a new version after update but the content is not  updated since when I load the page again I get the old html corresponding to the content with the structure with Documents and Media field. This is not appening when I open the content by control panel/content... and without change nothing i click on publish.

I'm using the following sentence by I have test a lot of JournalArticleLocalServiceUtil:
    updateArticle(long userId, long groupId, long folderId, java.lang.String articleId, double version, java.lang.String content, com.liferay.portal.kernel.service.ServiceContext serviceContext)

I want to copy this funcionality, publish the content with a new version in order to get que image loaded in the image structure field.

Kind regards, 

Iñigo