/** * Creates a project role level based restriction query. * <p/> * NOTE: This method should not be called with null or empty map (i.e if the user is not a member of any roles). If * the user is not a member of any roles, the right thing to do is not to call this method. * * @param projectIdToProjectRolesMap Map[Long,Collection[ProjectRole]] * @param roleLevelField the name of the lucene document field which represents the role level visibility * @return query */ Query createProjectRoleLevelQuery(final ProjectRoleManager.ProjectIdToProjectRoleIdsMap projectIdToProjectRolesMap, final String roleLevelField) { final BooleanQuery query = new BooleanQuery(); if ((projectIdToProjectRolesMap == null) || projectIdToProjectRolesMap.isEmpty()) { log.debug("Groups must be specified!"); return query; } for (final ProjectRoleManager.ProjectIdToProjectRoleIdsMap.Entry entry : projectIdToProjectRolesMap) { final Long projectId = entry.getProjectId(); final Collection<Long> projectRoles = entry.getProjectRoleIds(); for (final Long projectRoleId : projectRoles) { query.add(createFieldInProjectAndUserInRoleQuery(projectId, projectRoleId, roleLevelField), BooleanClause.Occur.SHOULD); } } return query; }
if (!projectIdToProjectRolesMap.isEmpty())