From e1c61f8480be67745589819e7466fdc3b1dfdced Mon Sep 17 00:00:00 2001 From: Brendan Johan Lee Date: Sat, 2 Nov 2019 12:25:41 +0100 Subject: [PATCH] Fix error in the code for permissions The existing documentation defines a _guestbookModelResourcePermision without annotating it. Then continues to try to use GuestBookPermission to get permssions, which of course will not work. --- .../02-implementing-a-guestbook-asset-renderer.markdown | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/en/developer/tutorials/articles/02-developing-a-web-application/09-assets/03-implementing-asset-renderers/02-implementing-a-guestbook-asset-renderer.markdown b/en/developer/tutorials/articles/02-developing-a-web-application/09-assets/03-implementing-asset-renderers/02-implementing-a-guestbook-asset-renderer.markdown index 50a203f0901..c41fd762e63 100644 --- a/en/developer/tutorials/articles/02-developing-a-web-application/09-assets/03-implementing-asset-renderers/02-implementing-a-guestbook-asset-renderer.markdown +++ b/en/developer/tutorials/articles/02-developing-a-web-application/09-assets/03-implementing-asset-renderers/02-implementing-a-guestbook-asset-renderer.markdown @@ -284,6 +284,7 @@ Follow these steps to create the `GuestbookAssetRendererFactory`: public static final String CLASS_NAME = Guestbook.class.getName(); public static final String TYPE = "guestbook"; private Logger logger = Logger.getLogger(this.getClass().getName()); + @Reference(target = "(model.class.name=com.liferay.docs.guestbook.model.Guestbook)") private ModelResourcePermission _guestbookModelResourcePermission; } ``` @@ -336,16 +337,14 @@ Follow these steps to create the `GuestbookAssetRendererFactory`: } ``` -3. Implement the `hasPermission` method via the `GuestbookPermission` class: +3. Implement the `hasPermission` method: ```java @Override public boolean hasPermission(PermissionChecker permissionChecker, long classPK, String actionId) throws Exception { - Guestbook guestbook = _guestbookLocalService.getGuestbook(classPK); - long groupId = guestbook.getGroupId(); - return GuestbookPermission.contains(permissionChecker, groupId, + return _guestbookModelResourcePermission.contains(permissionChecker, guestbook.getGuestbookId(), actionId); } ```