Bug 5085: Returning an empty object instead of status 404 if a race has

no course attached (it's effectively an empty course)
This commit is contained in:
Steffen Schaefer committed 2019-10-09 14:40:09 +02:00
1 parent 27bbe314e6
commit 2cd884499e
1 file changed
+7 -6
@@ -142,14 +142,15 @@ public class CourseConfigurationResource extends AbstractSailingServerResource {
courseBase = courseDesginFinder.analyze();
}
final JSONObject jsonResult;
if (courseBase == null) {
return Response.status(Status.NOT_FOUND).entity("No course found for given race.").build();
jsonResult = new JSONObject();
} else {
final CourseConfiguration courseConfiguration = getService().getCourseAndMarkConfigurationFactory()
.createCourseConfigurationFromCourse(courseBase, regatta, tags);
jsonResult = courseConfigurationJsonSerializer.serialize(courseConfiguration);
}
final CourseConfiguration courseConfiguration = getService().getCourseAndMarkConfigurationFactory()
.createCourseConfigurationFromCourse(courseBase, regatta, tags);
return Response.ok(courseConfigurationJsonSerializer.serialize(courseConfiguration).toJSONString()).build();
return Response.ok(jsonResult.toJSONString()).build();
}
@GET