001
014
015 package com.liferay.portlet.rolesadmin.search;
016
017 import com.liferay.portal.kernel.dao.search.RowChecker;
018 import com.liferay.portal.model.Role;
019 import com.liferay.portal.service.PermissionLocalServiceUtil;
020 import com.liferay.portal.service.ResourceBlockLocalServiceUtil;
021 import com.liferay.portal.service.ResourcePermissionLocalServiceUtil;
022 import com.liferay.portal.service.ResourceTypePermissionLocalServiceUtil;
023 import com.liferay.portal.util.PropsValues;
024
025 import javax.portlet.RenderResponse;
026
027
031 public class ResourceActionRowChecker extends RowChecker {
032
033 public ResourceActionRowChecker(RenderResponse renderResponse) {
034 super(renderResponse);
035 }
036
037 @Override
038 public boolean isChecked(Object obj) {
039 try {
040 return doIsChecked(obj);
041 }
042 catch (Exception e) {
043 return false;
044 }
045 }
046
047 protected boolean doIsChecked(Object obj) throws Exception {
048 Object[] objArray = (Object[])obj;
049
050 Role role = (Role)objArray[0];
051 String actionId = (String)objArray[1];
052 String resourceName = (String)objArray[2];
053 Integer scope = (Integer)objArray[4];
054
055 if (PropsValues.PERMISSIONS_USER_CHECK_ALGORITHM == 6) {
056 if (ResourceBlockLocalServiceUtil.isSupported(resourceName)) {
057 return ResourceTypePermissionLocalServiceUtil.
058 hasEitherScopePermission(
059 role.getCompanyId(), resourceName, role.getRoleId(),
060 actionId);
061 }
062
063 return
064 ResourcePermissionLocalServiceUtil.hasScopeResourcePermission(
065 role.getCompanyId(), resourceName, scope, role.getRoleId(),
066 actionId);
067 }
068 else {
069 return PermissionLocalServiceUtil.hasRolePermission(
070 role.getRoleId(), role.getCompanyId(), resourceName, scope,
071 actionId);
072 }
073 }
074
075 }