public synchronized Set<ProjectId> getProjects() { try { READ_LOCK.lock(); MetaProject metaProject = getMetaProject(); Set<ProjectInstance> projectInstances = metaProject.getProjects(); Set<ProjectId> result = new HashSet<ProjectId>(projectInstances.size()); for (ProjectInstance pi : projectInstances) { String projectName = pi.getName(); result.add(ProjectId.get(projectName)); } return result; } finally { READ_LOCK.unlock(); } }
public List<ProjectDetails> getListableReadableProjects(UserId userId) { Policy policy = metaproject.getPolicy(); User user = policy.getUserByName(userId.getUserName()); List<ProjectDetails> result = new ArrayList<ProjectDetails>(); for (ProjectInstance projectInstance : metaproject.getProjects()) { final String name = projectInstance.getName(); if (name != null && ProjectId.isWelFormedProjectId(name)) { final ProjectId projectId = ProjectId.get(name); if (isAuthorisedToReadAndList(policy, user, projectInstance)) { OWLAPIProjectDocumentStore ds = OWLAPIProjectDocumentStore.getProjectDocumentStore(projectId); if (ds.exists()) { final ProjectDetails projectDetails = createProjectDetailsFromProjectInstance(projectInstance); result.add(projectDetails); } } } } return result; }