1 package org.kuali.ole.docstore.engine.service.rest;
2
3 import org.kuali.ole.docstore.common.exception.DocstoreException;
4 import org.kuali.ole.docstore.common.exception.DocstoreExceptionProcessor;
5 import org.kuali.ole.docstore.common.search.SearchParams;
6 import org.kuali.ole.docstore.common.search.SearchResponse;
7 import org.kuali.ole.docstore.common.service.DocstoreService;
8 import org.kuali.ole.docstore.service.BeanLocator;
9 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory;
11 import org.springframework.stereotype.Controller;
12 import org.springframework.web.bind.annotation.RequestBody;
13 import org.springframework.web.bind.annotation.RequestMapping;
14 import org.springframework.web.bind.annotation.RequestMethod;
15 import org.springframework.web.bind.annotation.ResponseBody;
16
17 import java.util.List;
18
19
20
21
22
23
24
25
26
27 @Controller
28 @RequestMapping("/search")
29 public class SearchRestController extends AbstractRestService {
30
31 private static final Logger LOG = LoggerFactory.getLogger(SearchRestController.class);
32
33 @Override
34 @RequestMapping(value = "/", method = RequestMethod.POST, consumes = "application/xml", produces = "application/xml")
35 @ResponseBody
36 public String search(@RequestBody String requestBody) {
37 DocstoreService ds = BeanLocator.getDocstoreService();
38 SearchParams searchParams = new SearchParams();
39 searchParams = (SearchParams) searchParams.deserialize(requestBody);
40 SearchResponse searchResponse = null;
41 try {
42 searchResponse = ds.search(searchParams);
43 } catch (DocstoreException e) {
44 LOG.error("SearchRestController Exception : ", e);
45 return DocstoreExceptionProcessor.toXml(e);
46 }
47 return searchResponse.serialize(searchResponse);
48 }
49
50 }