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
1 changed files with 5 additions and 3 deletions

View File

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