Refactors Apache CXF support for REST

This commit is contained in:
Thai Nguyen 2016-10-20 17:47:34 +07:00
parent 15ab6c6326
commit b6e9223fed

View File

@ -45,8 +45,10 @@ public class Course {
@POST @POST
public Response createStudent(Student student) { public Response createStudent(Student student) {
if (students.contains(student)) { for (Student element : students) {
return Response.status(Response.Status.CONFLICT).build(); if (element.getId() == student.getId()) {
return Response.status(Response.Status.CONFLICT).build();
}
} }
students.add(student); students.add(student);
return Response.ok(student).build(); return Response.ok(student).build();
@ -62,7 +64,7 @@ public class Course {
students.remove(student); students.remove(student);
return Response.ok().build(); return Response.ok().build();
} }
private Student findById(int id) { private Student findById(int id) {
for (Student student : students) { for (Student student : students) {
if (student.getId() == id) { if (student.getId() == id) {