001
014
015 package com.liferay.portlet.enterpriseadmin.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.ResourcePermissionLocalServiceUtil;
021 import com.liferay.portal.util.PropsValues;
022
023 import javax.portlet.RenderResponse;
024
025
028 public class ResourceActionRowChecker extends RowChecker {
029
030 public ResourceActionRowChecker(RenderResponse renderResponse) {
031 super(renderResponse);
032 }
033
034 public boolean isChecked(Object obj) {
035 try {
036 return doIsChecked(obj);
037 }
038 catch (Exception e) {
039 return false;
040 }
041 }
042
043 protected boolean doIsChecked(Object obj) throws Exception {
044 Object[] objArray = (Object[])obj;
045
046 Role role = (Role)objArray[0];
047 String actionId = (String)objArray[1];
048 String resourceName = (String)objArray[2];
049 Integer scope = (Integer)objArray[4];
050
051 if (PropsValues.PERMISSIONS_USER_CHECK_ALGORITHM == 6) {
052 return
053 ResourcePermissionLocalServiceUtil.hasScopeResourcePermission(
054 role.getCompanyId(), resourceName, scope, role.getRoleId(),
055 actionId);
056 }
057 else {
058 return PermissionLocalServiceUtil.hasRolePermission(
059 role.getRoleId(), role.getCompanyId(), resourceName, scope,
060 actionId);
061 }
062 }
063
064 }