Example usage for com.liferay.portal.kernel.service ResourcePermissionLocalServiceUtil hasResourcePermission

List of usage examples for com.liferay.portal.kernel.service ResourcePermissionLocalServiceUtil hasResourcePermission

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service ResourcePermissionLocalServiceUtil hasResourcePermission.

Prototype

public static boolean hasResourcePermission(long companyId, String name, int scope, String primKey,
        long[] roleIds, String actionId) throws com.liferay.portal.kernel.exception.PortalException 

Source Link

Document

Returns true if the roles have permission at the scope to perform the action on resources of the type.

Usage

From source file:com.liferay.application.list.my.account.permissions.test.PanelAppMyAccountPermissionsTest.java

License:Open Source License

private boolean _hasMyAccountPermission(long companyId, String portletId) throws Exception {

    Role userRole = RoleLocalServiceUtil.getRole(companyId, RoleConstants.USER);

    return ResourcePermissionLocalServiceUtil.hasResourcePermission(companyId, portletId,
            ResourceConstants.SCOPE_COMPANY, String.valueOf(companyId), userRole.getRoleId(),
            ActionKeys.ACCESS_IN_CONTROL_PANEL);
}

From source file:com.liferay.exportimport.test.LayoutSetPrototypePropagationTest.java

License:Open Source License

@Ignore
@Test/*from  w  ww . j a  v a  2s .  c o m*/
public void testLayoutPermissionPropagationWithLinkEnabled() throws Exception {

    setLinkEnabled(true);

    Role role = RoleLocalServiceUtil.getRole(TestPropsValues.getCompanyId(), RoleConstants.POWER_USER);

    ResourcePermissionServiceUtil.setIndividualResourcePermissions(prototypeLayout.getGroupId(),
            prototypeLayout.getCompanyId(), Layout.class.getName(),
            String.valueOf(prototypeLayout.getPrimaryKey()), role.getRoleId(),
            new String[] { ActionKeys.CUSTOMIZE });

    prototypeLayout = updateModifiedDate(prototypeLayout, new Date(System.currentTimeMillis() + Time.MINUTE));

    CacheUtil.clearCache(prototypeLayout.getCompanyId());

    propagateChanges(group);

    Assert.assertTrue(ResourcePermissionLocalServiceUtil.hasResourcePermission(layout.getCompanyId(),
            Layout.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(layout.getPrimaryKey()),
            role.getRoleId(), ActionKeys.CUSTOMIZE));
}