use of com.google.gerrit.server.git.WorkQueue.ProjectTask in project gerrit by GerritCodeReview.
the class TasksCollection method parse.
@Override
public TaskResource parse(ConfigResource parent, IdString id) throws ResourceNotFoundException, AuthException, PermissionBackendException {
CurrentUser user = self.get();
if (!user.isIdentifiedUser()) {
throw new AuthException("Authentication required");
}
int taskId;
try {
taskId = (int) Long.parseLong(id.get(), 16);
} catch (NumberFormatException e) {
throw new ResourceNotFoundException(id);
}
Task<?> task = workQueue.getTask(taskId);
if (task instanceof ProjectTask) {
try {
permissionBackend.user(user).project(((ProjectTask<?>) task).getProjectNameKey()).check(ProjectPermission.ACCESS);
return new TaskResource(task);
} catch (AuthException e) {
// Fall through and try view queue permission.
}
}
if (task != null) {
try {
permissionBackend.user(user).check(GlobalPermission.VIEW_QUEUE);
return new TaskResource(task);
} catch (AuthException e) {
// Fall through and return not found.
}
}
throw new ResourceNotFoundException(id);
}
Aggregations