public List<Project> getUserProjects(User user) { ArrayList<Project> array = new ArrayList<Project>(); for (Project project : projectsById.values()) { Permission perm = project.getUserPermission(user); if (perm != null && (perm.isPermissionSet(Type.ADMIN) || perm.isPermissionSet(Type.READ))) { array.add(project); } } return array; }
public List<Project> getUserProjectsByRegex(User user, String regexPattern) { List<Project> array = new ArrayList<Project>(); Pattern pattern; try { pattern = Pattern.compile(regexPattern, Pattern.CASE_INSENSITIVE); } catch (PatternSyntaxException e) { logger.error("Bad regex pattern " + regexPattern); return array; } for (Project project : projectsById.values()) { Permission perm = project.getUserPermission(user); if (perm != null && (perm.isPermissionSet(Type.ADMIN) || perm.isPermissionSet(Type.READ))) { if (pattern.matcher(project.getName()).find()) { array.add(project); } } } return array; }