Skip to content

Commit b6e9223

Browse files
committed
Refactors Apache CXF support for REST
1 parent 15ab6c6 commit b6e9223

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation

‎apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ public Student getStudent(@PathParam("studentId") int studentId) {
4545

4646
@POST
4747
public Response createStudent(Student student) {
48-
if (students.contains(student)) {
49-
return Response.status(Response.Status.CONFLICT).build();
48+
for (Student element : students) {
49+
if (element.getId() == student.getId()) {
50+
return Response.status(Response.Status.CONFLICT).build();
51+
}
5052
}
5153
students.add(student);
5254
return Response.ok(student).build();
@@ -62,7 +64,7 @@ public Response deleteStudent(@PathParam("studentId") int studentId) {
6264
students.remove(student);
6365
return Response.ok().build();
6466
}
65-
67+
6668
private Student findById(int id) {
6769
for (Student student : students) {
6870
if (student.getId() == id) {

0 commit comments

Comments
 (0)