package nginx.clojure.jersey.spring.example;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Path("students")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class StudentResource {

	@Autowired
	private StudentService studentService;
	
	public StudentResource() {
	}
	
	@POST
    public Student create(Student student) {
        return studentService.save(student);
    }
	
    @PUT
    @Path("{id}")
    public Student update(@PathParam("id") String id, Student student) {
    	if (studentService.find(student.getId()) == null) {
    		return null;
    	}
        return studentService.save(student);
    }
    
    @GET
    @Path("{id}")
    public Student find(@PathParam("id") String id) {
    	return studentService.find(id);
    }
    
    @DELETE
    @Path("{id}")
    public Response delete(@PathParam("id") String id) {
         if (studentService.remove(id) == null) {
        	 return Response.status(302).build();
         } else {
        	 return Response.status(201).build();
         }
    }

}

@@ -624,18 +624,17 @@
 ervice;%0A
-%09
 %0A
+
 %09public 
@@ -660,21 +660,17 @@
 %0A%09%7D%0A
-%09
 %0A
+
 %09@POST%0A
-    
+%09
 publ
@@ -706,24 +706,18 @@
 dent) %7B%0A
-        
+%09%09
 return s
@@ -749,29 +749,19 @@
 t);%0A
-    %7D%0A%09%0A    
+%09%7D%0A%0A%09
 @PUT%0A
-    
+%09
 @Pat
@@ -762,36 +762,33 @@
 %0A%09@Path(%22%7Bid%7D%22)%0A
-    
+%09
 public Student u
@@ -840,20 +840,17 @@
 dent) %7B%0A
-    
+%09
 %09if (stu
@@ -894,20 +894,17 @@
 null) %7B%0A
-    
+%09
 %09%09return
@@ -914,23 +914,14 @@
 ll;%0A
-    %09%7D%0A        
+%09%09%7D%0A%09%09
 retu
@@ -957,32 +957,19 @@
 t);%0A
-    %7D%0A    %0A    
+%09%7D%0A%0A%09
 @GET%0A
-    
+%09
 @Pat
@@ -974,28 +974,25 @@
 ath(%22%7Bid%7D%22)%0A
-    
+%09
 public Stude
@@ -1029,20 +1029,17 @@
 g id) %7B%0A
-    
+%09
 %09return 
@@ -1067,31 +1067,21 @@
 d);%0A
-    %7D%0A    %0A    
+%09%7D%0A%0A%09
 @DELETE%0A
     
@@ -1076,20 +1076,17 @@
 @DELETE%0A
-    
+%09
 @Path(%22%7B
@@ -1091,20 +1091,17 @@
 %22%7Bid%7D%22)%0A
-    
+%09
 public R
@@ -1145,25 +1145,18 @@
 g id) %7B%0A
-         
+%09%09
 if (stud
@@ -1188,26 +1188,19 @@
 null) %7B%0A
-        %09 
+%09%09%09
 return R
@@ -1232,36 +1232,22 @@
 ();%0A
-         %7D else %7B%0A        %09 
+%09%09%7D else %7B%0A%09%09%09
 retu
@@ -1283,23 +1283,13 @@
 ();%0A
-         %7D%0A    
+%09%09%7D%0A%09
 %7D%0A%0A%7D

Fix format of example code