private boolean isAuthorisedToRead(Policy policy, User user, ProjectInstance projectInstance) { if (user == null) { return isWorldAllowedOperation(projectInstance, MetaProjectConstants.OPERATION_READ); } else if (isAdminUser(user)) { return true; } else return policy.isOperationAuthorized( user, MetaProjectConstants.OPERATION_READ, projectInstance); }
private boolean isAuthorisedToDisplayInList( Policy policy, User user, ProjectInstance projectInstance) { Operation operation = MetaProjectConstants.OPERATION_DISPLAY_IN_PROJECT_LIST; if (user == null) { return isWorldAllowedOperation(projectInstance, operation); } else { return isAdminUser(user) || policy.isOperationAuthorized(user, operation, projectInstance); } }
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; }