1 package org.kuali.ole.deliver.rest;
2
3 import org.codehaus.jettison.json.JSONObject;
4 import org.kuali.asr.handler.*;
5 import org.kuali.ole.ncip.service.CirculationRestService;
6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.stereotype.Controller;
8 import org.springframework.web.bind.annotation.RequestBody;
9 import org.springframework.web.bind.annotation.RequestMapping;
10 import org.springframework.web.bind.annotation.RequestMethod;
11 import org.springframework.web.bind.annotation.ResponseBody;
12
13 import javax.ws.rs.core.MediaType;
14 import java.util.Map;
15
16
17
18
19 @Controller
20 @RequestMapping("/circ")
21 public class CirculationRestController {
22
23 @Autowired
24 private CirculationRestService circulationRestService;
25
26
27
28 @RequestMapping(method = RequestMethod.POST, value = "/renewItem", produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
29 @ResponseBody
30 public String renewItem(@RequestBody String body) throws Exception {
31 String responseString = "";
32 JSONObject jsonObject = new JSONObject(body);
33 Map renewParameters = new RenewItemRequestHandler().parseRequest(jsonObject);
34 responseString = getCirculationRestService().renewItems(renewParameters);
35 return responseString;
36 }
37
38 @RequestMapping(method = RequestMethod.POST, value = "/renewItemSIP2", produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
39 @ResponseBody
40 public String renewItemForSIP2(@RequestBody String body) throws Exception {
41 String responseString = "";
42 JSONObject jsonObject = new JSONObject(body);
43 Map renewParameters = new RenewItemRequestHandler().parseRequest(jsonObject);
44 responseString = getCirculationRestService().renewItemsSIP2(renewParameters);
45 return responseString;
46 }
47
48 @RequestMapping(method = RequestMethod.POST, value = "/checkoutItem", produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
49 @ResponseBody
50 public String checkoutItem(@RequestBody String body) throws Exception {
51 String responseString = "";
52 JSONObject jsonObject = new JSONObject(body);
53 Map checkoutParameters = new CheckoutItemRequestHandler().parseRequest(jsonObject);
54 responseString = getCirculationRestService().checkoutItem(checkoutParameters);
55 return responseString;
56 }
57
58 @RequestMapping(method = RequestMethod.POST, value = "/checkoutItemSIP2", produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
59 @ResponseBody
60 public String checkoutItemSIP2(@RequestBody String body) throws Exception {
61 String responseString = "";
62 JSONObject jsonObject = new JSONObject(body);
63 Map checkoutParameters = new CheckoutItemRequestHandler().parseRequest(jsonObject);
64 responseString = getCirculationRestService().checkoutItemSIP2(checkoutParameters);
65 return responseString;
66 }
67
68 @RequestMapping(method = RequestMethod.POST, value = "/checkinItem", produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
69 @ResponseBody
70 public String checkinItem(@RequestBody String body) throws Exception {
71 String responseString = "";
72 JSONObject jsonObject = new JSONObject(body);
73 Map checkinParameters = new CheckinItemRequestHandler().parseRequest(jsonObject);
74 responseString = getCirculationRestService().checkinItem(checkinParameters);
75 return responseString;
76 }
77
78 @RequestMapping(method = RequestMethod.POST, value = "/checkinItemSIP2", produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
79 @ResponseBody
80 public String checkinItemSIP2(@RequestBody String body) throws Exception {
81 String responseString = "";
82 JSONObject jsonObject = new JSONObject(body);
83 Map checkinParameters = new CheckinItemRequestHandler().parseRequest(jsonObject);
84 responseString = getCirculationRestService().checkinItemSIP2(checkinParameters);
85 return responseString;
86 }
87
88 public CirculationRestService getCirculationRestService() {
89 return circulationRestService;
90 }
91
92 public void setCirculationRestService(CirculationRestService circulationRestService) {
93 this.circulationRestService = circulationRestService;
94 }
95 }