Search in sources :

Example 1 with ResourcePermission

use of com.liferay.portal.kernel.model.ResourcePermission in project liferay-db-setup-core by ableneo.

the class SetupPermissions method deleteAllPortletPermissions.

private static void deleteAllPortletPermissions(final ResourcePermissions.Resource resource) {
    try {
        long companyId = SetupConfigurationThreadLocal.getRunInCompanyId();
        List<ResourcePermission> resourcePermissions = ResourcePermissionLocalServiceUtil.getResourcePermissions(companyId, resource.getResourceId(), ResourceConstants.SCOPE_COMPANY, String.valueOf(companyId));
        for (ResourcePermission resourcePermission : resourcePermissions) {
            ResourcePermissionLocalServiceUtil.deleteResourcePermission(resourcePermission);
        }
    } catch (SystemException e) {
        LOG.error(String.format("could not delete permissions for resource :%1$s", resource.getResourceId()), e);
    }
}
Also used : SystemException(com.liferay.portal.kernel.exception.SystemException) ResourcePermission(com.liferay.portal.kernel.model.ResourcePermission)

Example 2 with ResourcePermission

use of com.liferay.portal.kernel.model.ResourcePermission in project liferay-imex by jpdacunha.

the class ImportRolePermissionsServiceImpl method reinitAction.

private void reinitAction(Role role) throws SystemException {
    long roleId = role.getRoleId();
    List<ResourcePermission> liste = resourcePermissionLocalService.getRoleResourcePermissions(roleId);
    for (ResourcePermission resourcePermission : liste) {
        if (resourcePermission.getScope() != ResourceConstants.SCOPE_INDIVIDUAL) {
            resourcePermissionLocalService.deleteResourcePermission(resourcePermission);
        }
    }
}
Also used : ResourcePermission(com.liferay.portal.kernel.model.ResourcePermission)

Aggregations

ResourcePermission (com.liferay.portal.kernel.model.ResourcePermission)2 SystemException (com.liferay.portal.kernel.exception.SystemException)1