/* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. All methods that expect a resource block permission model instance should use the {@link ResourceBlockPermission} interface instead. */ @Override public void persist() throws SystemException { if (this.isNew()) { ResourceBlockPermissionLocalServiceUtil.addResourceBlockPermission(this); } else { ResourceBlockPermissionLocalServiceUtil.updateResourceBlockPermission(this); } }
protected void initActionableDynamicQuery(ActionableDynamicQuery actionableDynamicQuery) { actionableDynamicQuery.setBaseLocalService( com.liferay.portal.service.ResourceBlockPermissionLocalServiceUtil.getService()); actionableDynamicQuery.setClass(ResourceBlockPermission.class); actionableDynamicQuery.setClassLoader(getClassLoader()); actionableDynamicQuery.setPrimaryKeyPropertyName("resourceBlockPermissionId"); }
@AfterClass public static void tearDownClass() throws Exception { ResourcePermissionLocalServiceUtil.deleteResourcePermission(_resourcePermission); ResourceBlockLocalServiceUtil.deleteResourceBlock(_resourceBlock); ResourceBlockPermissionLocalServiceUtil.deleteResourceBlockPermission(_resourceBlockPermission); }
@Override public ActionableDynamicQuery getActionableDynamicQuery() { ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery(); actionableDynamicQuery.setBaseLocalService( com.liferay.portal.service.ResourceBlockPermissionLocalServiceUtil.getService()); actionableDynamicQuery.setClass(ResourceBlockPermission.class); actionableDynamicQuery.setClassLoader(getClassLoader()); actionableDynamicQuery.setPrimaryKeyPropertyName("resourceBlockPermissionId"); return actionableDynamicQuery; }
protected Map<Long, Set<String>> getActionIds( long companyId, long[] roleIds, String className, long primKey, List<String> actionIds) throws PortalException, SystemException { if (ResourceBlockLocalServiceUtil.isSupported(className)) { return ResourceBlockPermissionLocalServiceUtil.getAvailableResourceBlockPermissionActionIds( roleIds, className, primKey, actionIds); } else { return ResourcePermissionLocalServiceUtil.getAvailableResourcePermissionActionIds( companyId, className, ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(primKey), roleIds, actionIds); } }
protected void doAddPermissionFields_6( long companyId, long groupId, String className, String classPK, Document doc) throws Exception { Group group = null; if (groupId > 0) { group = GroupLocalServiceUtil.getGroup(groupId); } List<Role> roles = ListUtil.copy(ResourceActionsUtil.getRoles(companyId, group, className, null)); if (groupId > 0) { List<Role> teamRoles = RoleLocalServiceUtil.getTeamRoles(groupId); roles.addAll(teamRoles); } long[] roleIdsArray = new long[roles.size()]; for (int i = 0; i < roleIdsArray.length; i++) { Role role = roles.get(i); roleIdsArray[i] = role.getRoleId(); } boolean[] hasResourcePermissions = null; if (ResourceBlockLocalServiceUtil.isSupported(className)) { ResourceBlockIdsBag resourceBlockIdsBag = ResourceBlockLocalServiceUtil.getResourceBlockIdsBag( companyId, groupId, className, roleIdsArray); long actionId = ResourceBlockLocalServiceUtil.getActionId(className, ActionKeys.VIEW); List<Long> resourceBlockIds = resourceBlockIdsBag.getResourceBlockIds(actionId); hasResourcePermissions = new boolean[roleIdsArray.length]; for (long resourceBlockId : resourceBlockIds) { for (int i = 0; i < roleIdsArray.length; i++) { int count = ResourceBlockPermissionLocalServiceUtil.getResourceBlockPermissionsCount( resourceBlockId, roleIdsArray[i]); hasResourcePermissions[i] = (count > 0); } } } else { hasResourcePermissions = ResourcePermissionLocalServiceUtil.hasResourcePermissions( companyId, className, ResourceConstants.SCOPE_INDIVIDUAL, classPK, roleIdsArray, ActionKeys.VIEW); } List<Long> roleIds = new ArrayList<Long>(); List<String> groupRoleIds = new ArrayList<String>(); for (int i = 0; i < hasResourcePermissions.length; i++) { if (!hasResourcePermissions[i]) { continue; } Role role = roles.get(i); if ((role.getType() == RoleConstants.TYPE_ORGANIZATION) || (role.getType() == RoleConstants.TYPE_SITE)) { groupRoleIds.add(groupId + StringPool.DASH + role.getRoleId()); } else { roleIds.add(role.getRoleId()); } } doc.addKeyword(Field.ROLE_ID, roleIds.toArray(new Long[roleIds.size()])); doc.addKeyword(Field.GROUP_ROLE_ID, groupRoleIds.toArray(new String[groupRoleIds.size()])); }