for (Project returnedProject : returnedProjects) {
// Only returns the projects that are either:
// * Starred by the user and have access (implicit or explicit).
// * Granted VIEW or EDIT access explicitly. (Ignore public projects.)
ProjectAccess access = userService.getAccessLevel(returnedProject);
// If explicit, add it. Otherwise, check starred access (and implicit access).
if (access.hasAccess(ProjectAccess.EXPLICIT_VIEW_ACCESS)) {
projectsToReturn.add(returnedProject);
} else if (access.hasAccess(ProjectAccess.VIEW_ACCESS)
&& starredProjects.contains(returnedProject.getProjectId())) {
projectsToReturn.add(returnedProject);
}
}