@Override public ProjectDetails getProjectDetails(ProjectId projectId) throws UnknownProjectException { ProjectInstance pi = metaproject.getProject(projectId.getId()); if (pi == null) { throw new UnknownProjectException(projectId); } return createProjectDetailsFromProjectInstance(pi); }
private ProjectInstance getProjectInstance(ProjectId projectId) throws UnknownProjectException { try { READ_LOCK.lock(); MetaProject metaProject = getMetaProject(); ProjectInstance pi = metaProject.getProject(projectId.getId()); if (pi == null) { throw new UnknownProjectException(projectId); } return pi; } finally { READ_LOCK.unlock(); } }
/** * Detemines if the signed in user is the owner of the specified project * * @param projectId The project id * @return <code>true</code> if the project exists AND there is a user signed in AND the signed in * user is the owner of the project, otherwise <code>false</code>. */ protected boolean isSignedInUserProjectOwner(ProjectId projectId) { UserId userId = getUserInSession(); if (userId.isGuest()) { return false; } MetaProjectManager mpm = getMetaProjectManager(); MetaProject metaProject = mpm.getMetaProject(); ProjectInstance project = metaProject.getProject(projectId.getId()); if (project == null) { return false; } User owner = project.getOwner(); return owner != null && userId.getUserName().equals(owner.getName()); }