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

Article ID not included in service context when updating Journal Article from API

Details

    Description

      Steps to Reproduce:
      1. Start up a clean 7.2 bundle
      2. Go to Control Panel > Web Content and create folder "workflow"
      3. Edit the workflow folder and apply the single approval workflow
      4. Go to Control Panel > Workflow > Process Builder
      5. Click on Single approver workflow
      6. Select review node and click notification
      7. Paste the below script into the template textbox:

      <#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") />
      <#assign articleId = serviceContext.getAttribute("articleId") />
      <#assign article = journalArticleLocalService.getArticle(groupId?number, articleId) />
      <#assign title = article.getTitle() />
      ${userName} sent you a document ${title}.

      8. Start up POSTMAN https://www.postman.com/downloads/
      9. Change URL from GET to POST --> http://localhost:8080/o/headless-delivery/v1.0/structured-content-folders/39308/structured-contents
      10. Replace 39308 with your workflow folderid (I got the value from the journalfolder table)
      11. Go to Authorization tab and change type to Basic Auth and enter Test Test credentials
      12. Go to Body tab and copy paste the following:

      {
          "actions": {
          
          },
          "availableLanguages": [
              "en-US"
          ],
          "contentFields": [
              {
                  "contentFieldValue": {
                      "data": "<p>new sample content&nbsp;</p>"
                  },
                  "dataType": "html",
                  "label": "content",
                  "name": "content",
                  "nestedContentFields": [],
                  "repeatable": false
              }
          ],
          "contentStructureId": 38858,
         
          "customFields": [
             
          ],
         
          "friendlyUrlPath": "new-sample-content",
          
          "siteId": 20124,
          "subscribed": false,
        
          "title": "new sample content"
         
      }

      13. Change contentStructureId to the Basic Web Content Structure found in DDMStructure
      14. Send POSTMAN request
      15. Go to User Profile > Notifications and approve the content
      16. In Postman change URL to PUT --> http://localhost:8080/o/headless-delivery/v1.0/structured-contents/34376
      17. Replace 34376 with your journalarticle resourcePrimKey
      18. Go to Body tab and copy paste the following:

      {
          "actions": {
          
          },
          "availableLanguages": [
              "en-US"
          ],
          "contentFields": [
              {
                  "contentFieldValue": {
                      "data": "<p>new sample content&nbsp;</p>"
                  },
                  "dataType": "html",
                  "label": "content",
                  "name": "content",
                  "nestedContentFields": [],
                  "repeatable": false
              }
          ],
          "contentStructureId": 38858,
         
          "customFields": [
             
          ],
         
          "friendlyUrlPath": "new-sample-content",
          
          "siteId": 20124,
          "subscribed": false,
        
          "title": "new sample content"
         
      }

      19. Send POSTMAN request
      Expected Behavior: Request completes without errors
      Actual Behavior: Request completes but ServiceContext attribute for articleId is blank

      2022-01-10 19:39:28.365 ERROR [liferay/kaleo_graph_walker-1][ParallelDestination:59] Unable to process message {destinationName=liferay/kaleo_graph_walker, response=null, responseDestinationName=null, responseId=null, payl[email protected]6d0865b4, values={defaultLocale=en_US, companyId=20101, groupId=0, principalName=20130, [email protected]fd7a9d0}}
      com.liferay.portal.kernel.messaging.MessageListenerException: com.liferay.portal.workflow.kaleo.runtime.notification.NotificationMessageGenerationException: Unable to generate notification message
      	at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:32)
      	at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:74)
      	at com.liferay.portal.messaging.internal.ParallelDestination$1.run(ParallelDestination.java:56)
      	at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:753)
      	at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:665)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: com.liferay.portal.workflow.kaleo.runtime.notification.NotificationMessageGenerationException: Unable to generate notification message
      	at com.liferay.portal.workflow.kaleo.runtime.internal.notification.TemplateNotificationMessageGenerator.generateMessage(TemplateNotificationMessageGenerator.java:95)
      	at com.liferay.portal.workflow.kaleo.runtime.internal.util.NotificationHelperImpl.sendKaleoNotification(NotificationHelperImpl.java:70)
      	at com.liferay.portal.workflow.kaleo.runtime.internal.util.NotificationHelperImpl.sendKaleoNotifications(NotificationHelperImpl.java:55)
      	at com.liferay.portal.workflow.kaleo.runtime.internal.node.TaskNodeExecutor.doEnter(TaskNodeExecutor.java:149)
      	at com.liferay.portal.workflow.kaleo.runtime.node.BaseNodeExecutor.enter(BaseNodeExecutor.java:51)
      	at com.liferay.portal.workflow.kaleo.runtime.internal.graph.DefaultGraphWalker.follow(DefaultGraphWalker.java:70)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50)
      	at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:69)
      	at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
      	at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
      	at com.sun.proxy.$Proxy998.follow(Unknown Source)
      	at com.liferay.portal.workflow.kaleo.runtime.internal.graph.messaging.PathElementMessageListener.doReceive(PathElementMessageListener.java:56)
      	at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:26)
      	... 5 more
      Caused by: com.liferay.portal.kernel.template.TemplateException: Unable to process template Review Notificationcom.liferay.portal.workflow.kaleo.model.KaleoNode34350
      	at com.liferay.portal.template.BaseTemplate.processTemplate(BaseTemplate.java:140)
      	at com.liferay.portal.workflow.kaleo.runtime.internal.notification.TemplateNotificationMessageGenerator.generateMessage(TemplateNotificationMessageGenerator.java:90)
      	... 21 more
      Caused by: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:_==> serviceContext.getAttribute("articleId")  [in template "Review Notificationcom.liferay.portal.workflow.kaleo.model.KaleoNode34350" at line 1, column 148]__----_Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??_----__----_FTL stack trace ("~" means nesting-related):_	- Failed at: #assign articleId = serviceContext.ge...  [in template "Review Notificationcom.liferay.portal.workflow.kaleo.model.KaleoNode34350" at line 1, column 127]_---- [Sanitized]
      	at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134)
      	at freemarker.core.Assignment.accept(Assignment.java:139)
      	at freemarker.core.Environment.visit(Environment.java:331)
      	at freemarker.core.Environment.visit(Environment.java:337)
      	at freemarker.core.Environment.process(Environment.java:310)
      	at freemarker.template.Template.process(Template.java:383)
      	at com.liferay.portal.template.freemarker.internal.FreeMarkerTemplate.processTemplate(FreeMarkerTemplate.java:154)
      	at com.liferay.portal.template.BaseTemplate.processTemplate(BaseTemplate.java:135)
      	... 22 more
      

      Note
      A similar issue was fixed for the add method in the past - LPS-44090

      Attachments

        Activity

          People

            jonathan.mccann Jonathan McCann
            jonathan.mccann Jonathan McCann
            Kiyoshi Lee Kiyoshi Lee
            Jonathan McCann Jonathan McCann
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              46 weeks, 3 days ago

              Packages

                Version Package