RE: Unable to interpret notification in Liferay 7.2.1 CE GA2

thumbnail
ali yeganeh, modified 5 Years ago. Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
Hi
In liferay 7.1 user and admin  can see notification generated by workflow .
Now i migrate from liferay 7.1 to  Liferay 7.2.1 CE GA2 and only admin can see notification generated by workflow
but user can't see notification generated by workflow, encountered an exception!!!!! (I've attached the exception)
How can i assign view permission to users for see their notification programmatically  in liferay 7.2.1 CE GA2 ?
thumbnail
Nader Jafari, modified 5 Years ago. Junior Member Posts: 84 Join Date: 8/24/11 Recent Posts
Hi
did you see source code of WorkflowTaskPermissionChecker.java:169 ?
What is null there?
thumbnail
ali yeganeh, modified 5 Years ago. Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
Hi
Because i don't define permission for user to see own notifications , this feature is added in liferay 7.2.1
In liferay 7.1 user and admin  can see notification generated by workflow and displaying the notifications is working properly.
Only i migrate from liferay 7.1 to  Liferay 7.2.1 CE GA2 and my code has not changed.
This feature probably added in this release.
Do you know how can i assign view permission to users for see their notification programmatically  in liferay 7.2.1 CE GA2 ?
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
It seems there is no asset renderer available.
        AssetRenderer<?> assetRenderer = workflowHandler.getAssetRenderer( classPK);
Line 169:            return assetRenderer.hasViewPermission(permissionChecker);
So, assetRenderer is null. Is this a custom asset?
thumbnail
ali yeganeh, modified 5 Years ago. Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
Christoph Rabel:

It seems there is no asset renderer available.
        AssetRenderer<?> assetRenderer = workflowHandler.getAssetRenderer( classPK);
Line 169:            return assetRenderer.hasViewPermission(permissionChecker);
So, assetRenderer is null. Is this a custom asset?

Hi dear Christoph
I have asset render &amp; asset render factory  ( attached their )
And finally i extend BaseWorkflowHandler class ( attached   )

what is the problem?
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
I don't know.
I would try to add logging. Is  getAssetRenderer in your ImportationAssetRendererFactory actually called? I suspect, no.
Maybe you could also try to implement getAssetRenderer in your WorkflowHandler? If it is registered correctly, it should at least output some logging/be visible in the stacktrace.
You could also check the result of calling AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(), I suspect, it returns null.
thumbnail
ali yeganeh, modified 5 Years ago. Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
Christoph Rabel:


Maybe you could also try to implement getAssetRenderer in your WorkflowHandler? If it is registered correctly, it should at least output some logging/be visible in the stacktrace.
You could also check the result of calling AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(), I suspect, it returns null.

Hi dear Christoph

Yes,  getAssetRenderer  method in WorkflowHandler class can logging/be visible in the stack trace.
And i checked AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(), it returns null.
Your guess was very accurate

What is your suggestion now?
thumbnail
ali yeganeh, modified 5 Years ago. Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
Hi everyone
How can handle this exception (Unable to interpret notification)   ?
Is there a solution for him?

 
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
It is likely not satisfactory, but I think you should debug your way through the WorkflowTaskPermissionChecker's hasAssetViewPermission() method.

You need to see what it is finding at each step along the way and why it is finding what it is.

There is some confusing code in the classes you've pasted in, you seem to be overriding some things I wouldn't think are necessary and hard-coding return values in other locations. It looks like you've spent a lot of time trying to get this all off the ground, it really shows.

I did see that you have a setGuestbookLocalService() method in your asset factory that takes your ImportationLocalService as a parameter, I'm guessing that some of this code started from the guestbook sample code. Have you tried deploying the guestbook code to see if its workflow is working? I'd hate to think you're banging your head trying to get your code working if the original fails too...
thumbnail
ali yeganeh, modified 5 Years ago. Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
Hi dear David H Nebinger

In liferay 7.1 users can see notification generated by workflow and displaying the notifications is working properly.
In liferay 7.2 When i assign administrator role to  regular user, my problem solved and notification is displayed
how can i assign view permission to users for see their notification programmatically  in liferay 7.2.1 CE GA2 ?
 
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Setting programmatically has nothing to do with the exception you're currently dealing with. Solve the issue with the exception, then the programmatic thing for notifications will likely resolve itself.
thumbnail
ali yeganeh, modified 5 Years ago. Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
Hi
Why i assign administrator role to  regular user, my problem solved and notification is displayed ?
May be this is a bug of liferay7.2 ?
thumbnail
Andrew Jardine, modified 5 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Maybe. I think the point that David is trying to make, and he's right, is that until the code executes without exception you can't know for sure. If the exception is being thrown BEFORE the lines where the permissions are set then that would explain why the user can't see their own notification (because the corresponding record is not yet in the table). That's why David is saying that you should eliminate the exception first. 

The administrator role is not a valid test. It surpasses all checks and is the equivalent of not having any permissions at all. Take David's advice. After 15,000 posts, I think it's safe to say he knows what he's doing emoticon
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
ali yeganeh:

Why i assign administrator role to  regular user, my problem solved and notification is displayed ?



Admin is not a good test case. Admins have all access to everything, no permission issues at all to deal with. You can't ever assume that just because something works for admin it will automatically work for everyone else.
thumbnail
ali yeganeh, modified 5 Years ago. Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
Hi dear David
I couldn't find the problem.
Could the exception be outside of the files I attached?
Please comment on the files I attached.
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
I don't see anything specifically wrong with the code, that's why I suggested debugging and stepping through the WorkflowTaskPermissionChecker's hasAssetViewPermission() method. You need to figure out why that code is returning null, triggering the NPE.
thumbnail
ali yeganeh, modified 5 Years ago. Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
David H Nebinger:

I don't see anything specifically wrong with the code, that's why I suggested debugging and stepping through the WorkflowTaskPermissionChecker's hasAssetViewPermission() method. You need to figure out why that code is returning null, triggering the NPE.
Hi dear David H Nebinger
I debugging the WorkflowTaskPermissionChecker's hasAssetViewPermission() method.
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Okay, so now you know that you're not getting an AssetRenderer using the WorkflowHandler's getAssetRenderer() method, so you have to drill down into that method to see where it is failing...


Note that I don't have any real answers for you, it is going to take these kinds of debugging actions to figure out where a failure point is. I don't have a magical answer for you here, we have to find the point of failure and see where it takes us.
thumbnail
ali yeganeh, modified 5 Years ago. Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
Hi dear David H Nebinger
According to the attachment file ( 5.jpg ) , class name isn't in map !!!
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
So given that, I went back to the ImportationAssetRendererFactory class and found the following:

@Override
public String getClassName()
{
  return ImportationAssetRendererFactory.CLASS_NAME;
}

The class name for your asset factory shouldn't be its own, it should be the class name for the asset to be rendered, so this should be returning Importation.class.getName() instead.


Check step 5 on https://portal.liferay.dev/docs/7-2/frameworks/-/knowledge_base/f/creating-a-factory-for-the-asset-renderer for verification of what I found.
thumbnail
ali yeganeh, modified 5 Years ago. Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
I wrote AssetRenderer and AssetRendererFactory classes from scratch according to the link and My problem solved  .

Dear David H Nebinger, Thank you very much  for taking the time to guide me .