PUBLIC - Liferay Portal Community Edition
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-25150

Getting Recipients email adress from non regular roles in a state action for notification fails

    Details

    • Branch Version/s:
      6.1.x, 6.0.x
    • Backported to Branch:
      Committed
    • Similar Issues:
      Show 5 results 

      Description

      With such a definition, the notification fails after changing to Approved:
      <state>
      <name>approved</name>
      <actions>
      ...
      <notification>
      ...
      <recipients>
      ...
      <role>
      <role-type>site</role-type>
      <name>Site Content Reviewer</name>
      </role>
      ...
      </recipients>
      </notification>
      </actions>

      </state>

      Steps to reproduce it:
      1- Config Liferay to send emails and deploy kaleo web plugin
      2- Create a site role called "no_regular" (community role for 6.0.x)
      3- Modifiy/create a user using your email
      4- Assign that user to that role in the liferay.com site
      [Work in liferay.com for the points below]
      5- Import the attached workflow definition "single-approver-nonregular-role-when-approved-notification.xml"
      6- Select the workflow "Notificate non regular when approved" for web contents
      7- Create and send to publish one content
      8- With an administrator user, assign and approved the content

      Result:
      You won't receive any email and the following exception is thrown:

      18:37:42,239 ERROR [ParallelDestination:80] Unable to process message {destinationName=liferay/kaleo_graph_walker, response=null, responseDestinationName=null, responseId=null, payload=com.liferay.portal.workflow.kaleo.runtime.graph.PathElement@3cd12c3d, values={companyId=10136}}
      com.liferay.portal.kernel.messaging.MessageListenerException: com.liferay.portal.workflow.kaleo.runtime.notification.NotificationMessageSenderException: Unable to send mail message
      	at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:31)
      	at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:65)
      	at com.liferay.portal.kernel.messaging.ParallelDestination$1.run(ParallelDestination.java:77)
      	at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:669)
      	at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:580)
      	at java.lang.Thread.run(Unknown Source)
      Caused by: com.liferay.portal.workflow.kaleo.runtime.notification.NotificationMessageSenderException: Unable to send mail message
      	at com.liferay.portal.workflow.kaleo.runtime.notification.EmailNotificationSender.sendNotification(EmailNotificationSender.java:94)
      	at com.liferay.portal.workflow.kaleo.runtime.notification.NotificationUtil._sendKaleoNotification(NotificationUtil.java:77)
      	at com.liferay.portal.workflow.kaleo.runtime.notification.NotificationUtil.sendKaleoNotifications(NotificationUtil.java:44)
      	at com.liferay.portal.workflow.kaleo.runtime.graph.DefaultGraphWalker.follow(DefaultGraphWalker.java:81)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      	at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:86)
      	at com.liferay.portal.dao.jdbc.aop.DynamicDataSourceTransactionInterceptor.invoke(DynamicDataSourceTransactionInterceptor.java:46)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      	at $Proxy291.follow(Unknown Source)
      	at com.liferay.portal.workflow.kaleo.runtime.graph.messaging.PathElementMessageListener.doReceive(PathElementMessageListener.java:53)
      	at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:25)
      	... 5 more
      Caused by: java.lang.NullPointerException
      	at com.liferay.portal.workflow.kaleo.runtime.notification.EmailNotificationSender.getRoleRecipientAddresses(EmailNotificationSender.java:212)
      	at com.liferay.portal.workflow.kaleo.runtime.notification.EmailNotificationSender.getRecipients(EmailNotificationSender.java:178)
      	at com.liferay.portal.workflow.kaleo.runtime.notification.EmailNotificationSender.sendNotification(EmailNotificationSender.java:72)
      

      It's because on com.liferay.portal.workflow.kaleo.runtime.notification.EmailNotificationSender.getRoleRecipientAddresses(...), near line 180, the groupId is taken from the kaleoTaskInstanceToken, wich is null in this case (probably because we are in a State and not in a Task). Then the UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole(...) failed with a null pointer exception.

      Applying the commit you will receive one meail with the subject "New content has been published" and the following content:
      "Notification to users belong to a non-regular role after changing to the state Approved"

        Activity

        Hide
        Christophe Cariou added a comment -

        replacing :
        ---(line 180)--
        KaleoTaskInstanceToken kaleoTaskInstanceToken = executionContext.getKaleoTaskInstanceToken();
        List<UserGroupRole> userGroupRoles =UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole( kaleoTaskInstanceToken.getGroupId(), roleId);


        by


        KaleoInstanceToken kaleoInstanceToken = executionContext.getKaleoInstanceToken();
        List<UserGroupRole> userGroupRoles=UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole(kaleoInstanceToken.getGroupId(), roleId);


        In this way, we take the groupId from the kaleoInstanceToken, instead kaleoTaskInstanceToken, that is always filled.

        Tested on liferay 6.0.6 GA, with a modified kaleo-web from http://svn.liferay.com/browse/plugins/branches/6.0.6/webs/kaleo-web

        I think the bug exist in liferay 6.1 too.

        Show
        Christophe Cariou added a comment - replacing : --- (line 180) -- KaleoTaskInstanceToken kaleoTaskInstanceToken = executionContext.getKaleoTaskInstanceToken(); List<UserGroupRole> userGroupRoles =UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole( kaleoTaskInstanceToken.getGroupId(), roleId); by KaleoInstanceToken kaleoInstanceToken = executionContext.getKaleoInstanceToken(); List<UserGroupRole> userGroupRoles=UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole(kaleoInstanceToken.getGroupId(), roleId); In this way, we take the groupId from the kaleoInstanceToken, instead kaleoTaskInstanceToken, that is always filled. Tested on liferay 6.0.6 GA, with a modified kaleo-web from http://svn.liferay.com/browse/plugins/branches/6.0.6/webs/kaleo-web I think the bug exist in liferay 6.1 too.
        Hide
        Alberto Chaparro added a comment -

        Christophe is right, we should use kaleoInstanceToken instead of kaleoTaskInstanceToken due to the method (getRoleRecipientAddresses) can be called for taks but for workflow states too.

        Preparing the pull request...

        Show
        Alberto Chaparro added a comment - Christophe is right, we should use kaleoInstanceToken instead of kaleoTaskInstanceToken due to the method (getRoleRecipientAddresses) can be called for taks but for workflow states too. Preparing the pull request...
        Hide
        Tammy Fong added a comment -

        Committed on:
        Plugins 6.2.x GIT ID: e961db960082c3c294a7b518664494c4273d00ec.

        Show
        Tammy Fong added a comment - Committed on: Plugins 6.2.x GIT ID: e961db960082c3c294a7b518664494c4273d00ec.
        Hide
        Pani Gui (Inactive) added a comment -

        PASSED Manual Testing following the steps in the description.

        Reproduced on:
        Tomcat 7.0 + MySQL 5. Portal 6.1.20 EE GA2.

        Can not receive notification email and exception is thrown in the console.

        Fixed on:
        Tomcat 7.0 + MySQL 5. Portal 6.1.x EE GIT ID: d83490f875f72278c6aa1e4cf017095e0c54e1cf.
        Plugins 6.1.x EE GIT ID: a83d04cad695e8f21edf9ba4df6ce2cf92f31ef0.
        Tomcat 7.0 + MySQL 5. Portal 6.2.x GIT ID: c2dde1c4a6fd4640dc541648e004ca335fbd5ae2.
        Plugins 6.2.x GIT ID: 5db5794cf05bf3517c082b15f564cae24e2a6bc2.

        User can receive notification email and there is no error in the console.

        Show
        Pani Gui (Inactive) added a comment - PASSED Manual Testing following the steps in the description. Reproduced on: Tomcat 7.0 + MySQL 5. Portal 6.1.20 EE GA2. Can not receive notification email and exception is thrown in the console. Fixed on: Tomcat 7.0 + MySQL 5. Portal 6.1.x EE GIT ID: d83490f875f72278c6aa1e4cf017095e0c54e1cf. Plugins 6.1.x EE GIT ID: a83d04cad695e8f21edf9ba4df6ce2cf92f31ef0. Tomcat 7.0 + MySQL 5. Portal 6.2.x GIT ID: c2dde1c4a6fd4640dc541648e004ca335fbd5ae2. Plugins 6.2.x GIT ID: 5db5794cf05bf3517c082b15f564cae24e2a6bc2. User can receive notification email and there is no error in the console.
        Hide
        Michael Saechang added a comment -

        Thank you Pani for testing. Closing as 'Fixed'.

        Show
        Michael Saechang added a comment - Thank you Pani for testing. Closing as 'Fixed'.
        Hide
        Alberto Chaparro added a comment -

        I attach a workflow definition to test it for 6.0.x

        Show
        Alberto Chaparro added a comment - I attach a workflow definition to test it for 6.0.x
        Hide
        Pani Gui (Inactive) added a comment -

        PASSED Manual Testing following the steps in the description.

        Fixed on:
        Tomcat 6.0 + MySQL 5. Portal 6.0.x GIT ID: 6c7fee1857d83b40608a0f34a93b39c751fac5a1.
        Plugins 6.0.x GIT ID: be8f050e9594d7f6a9252a0a2c1b88f4e925608d.

        User can receive notification email and there is no error in the console.

        Show
        Pani Gui (Inactive) added a comment - PASSED Manual Testing following the steps in the description. Fixed on: Tomcat 6.0 + MySQL 5. Portal 6.0.x GIT ID: 6c7fee1857d83b40608a0f34a93b39c751fac5a1. Plugins 6.0.x GIT ID: be8f050e9594d7f6a9252a0a2c1b88f4e925608d. User can receive notification email and there is no error in the console.
        Hide
        Michael Saechang added a comment -

        Thank you for testing Pani. Closing as 'Fixed'.

        Show
        Michael Saechang added a comment - Thank you for testing Pani. Closing as 'Fixed'.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              2 years, 26 weeks, 4 days ago

              Development

                Structure Helper Panel