Posts

Showing posts with the label permissions

Liferay NoSuchResourcePermissionException Error Fix

Image
  Permission Checking Error Fix How to fix "Someone may be trying to circumvent the permission checker" error in Liferay Overview Sometimes you may see notice strange errors on the portal related to permissions checking, similar to this one: 2023-10-10 07:37:39.152 ERROR [http-nio-8080-exec-1][MainServlet:1111] null com.liferay.portal.kernel.events.ActionException: java.lang.IllegalArgumentException: Someone may be trying to circumvent the permission checker: {companyId=224404, name=com.liferay.portal.kernel.model.Layout, primKey=9730, scope=4} This article explains how to find the reason and fix the issue. Problem If you check the stacktrace in more details - you'll see in the end, that the main reason is the missing ResourcePermission record for the resource on which permissions check is executed: Caused by: com.liferay.portal.kernel.exception.NoSuchResourcePermissionException: {companyId=224404, name=com.liferay.portal.kernel.model.Layout, primKey=9730, scope=4} at c...

Creation Resources Available for Guest Users

Image
Creation Resources Available for Guest Users Overview If you implement a public web-site on Liferay, you need it’s content to be publicly available. By default, when you invoke the Liferay API to create some resource (document, web content, etc.) - it’s not created in such a way. But it’s easy to make it work.  Implementation When you invoke the Liferay API to create some resource you need - you’ll notice it accepts the ServiceContext object.  To make the resource available for Guest user - use:   serviceContext.setAddGuestPermissions( true ); To make the resource available for Site Members - use:  serviceContext.setAddGroupPermissions( true ); This is a sample code for File Entry: ServiceContext serviceContext = new ServiceContext(); serviceContext.setUserId(userId); serviceContext.setScopeGroupId(groupId); if (setViewPermission) {   serviceContext.setAddGroupPermissions( true );   serviceContext.setAddGuest...