Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-72213

Remove the default web content translation causes errors when publishing to live

    Details

      Description

      Master and 7.0.x Use Case

      We need to remove the web content localization using the API because the UI has been changed and does not allow remove the default translation (see 6.2.x use case)

      1. Enable Staging in the default site Liferay (a.k.a. Guest)
      2. Create a Web Content in the default language.
      3. Publish to Live => Result
      4. From the Groovy Console run the next Groovy Script for removing the default translation, you will need to configure the right articleId in the script (You can get it from the WebContent Editor, see ID in the header when you are editing the Web Content)
        import com.liferay.portal.kernel.service.*;
        import com.liferay.portal.kernel.model.*;
        import com.liferay.portal.kernel.util.*;
        import com.liferay.journal.model.*;
        import com.liferay.journal.service.*;
        
        String siteFriendlyURL = "/guest";
        String articleId = "34102";
        
        try {
        	Group group = GroupLocalServiceUtil.getFriendlyURLGroup(PortalUtil.getCompanyId(actionRequest), siteFriendlyURL);
        
        	long groupId = group.getGroupId();
        
        	if(group.hasStagingGroup()){
        		groupId = group.getStagingGroup().getGroupId();
        	}
        
        	JournalArticle article = JournalArticleLocalServiceUtil.getArticle(groupId, articleId);
        
        	String defaultLanguageId = article.getDefaultLanguageId();
        
        	println "Content: " + article.getUrlTitle()
        	println "Available languageIds: " + article.getAvailableLanguageIds()
        	println "Default languageId: " + defaultLanguageId
        	println "... Removing " +  defaultLanguageId + " ..."
        
        	JournalArticleLocalServiceUtil.removeArticleLocale(groupId, articleId, article.getVersion(), defaultLanguageId);
        } catch (Exception e) {
        	e.printStackTrace(out)
        }
        
      5. Try to publish to live again =>

      Log file:

      13:21:22,131 WARN  [liferay/background_task-1][LayoutStagingBackgroundTaskExecutor:167] Unable to publish layout: com.liferay.journal.exception.ArticleTitleException: Title is null
      13:21:22,156 ERROR [liferay/background_task-1][BackgroundTaskMessageListener:165] Unable to execute background task
      com.liferay.exportimport.kernel.lar.PortletDataException: com.liferay.journal.exception.ArticleTitleException: Title is null
      ...
      

      6.2.x Use Case
      Steps to reproduce:

      1. Enable Staging in the default site Guest
      2. Create a Web Content in the default language
      3. Publish to Live => Result
      4. Edit the Web Content and change the default language from en_US to es_ES and without save the content remove the en_US translation
      5. Save the Web Content
      6. Try to publish again =>

      Log file:

      15:47:36,837 ERROR [liferay/background_task-2][BackgroundTaskMessageListener:133] Unable to execute background task
      com.liferay.portal.kernel.lar.PortletDataException: com.liferay.portlet.journal.ArticleTitleException
      	at com.liferay.portal.kernel.lar.BaseStagedModelDataHandler.importStagedModel(BaseStagedModelDataHandler.java:200)
      ...
      

      EXPECTED
      You can not remove the default translation of a web content.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  2 years, 13 weeks, 3 days ago

                  Packages

                  Version Package
                  6.2.X EE
                  7.0.0 DXP FP16
                  7.0.3 CE GA4
                  7.0.0 DXP SP4
                  7.0.X EE
                  7.1.X
                  Master