1 package org.kuali.ole.ncip.converter;
2
3 import com.thoughtworks.xstream.XStream;
4 import org.apache.log4j.Logger;
5 import org.kuali.ole.ncip.bo.OLECancelRequest;
6
7
8
9
10
11
12
13
14 public class OLECancelRequestConverter{
15 final Logger LOG = Logger.getLogger(OLECancelRequestConverter.class);
16 public String generateCancelRequestXml(OLECancelRequest oleCancelRequest){
17 XStream xStream = new XStream();
18 xStream.alias("cancelRequest",OLECancelRequest.class);
19 return xStream.toXML(oleCancelRequest);
20 }
21 public Object generateCancelRequestObject(String xml){
22 XStream xStream = new XStream();
23 xStream.alias("cancelRequest",OLECancelRequest.class);
24 return xStream.fromXML(xml);
25 }
26 public String generateCancelRequestJson(String xml) {
27 OLECancelRequest oleCancelRequest = (OLECancelRequest)generateCancelRequestObject(xml);
28 OleCirculationHandler xmlContentHandler = new OleCirculationHandler();
29 if(oleCancelRequest==null){
30 oleCancelRequest=new OLECancelRequest();
31 }
32 try{
33 return xmlContentHandler.marshalToJSON(oleCancelRequest);
34 }catch(Exception e){
35 LOG.error(e,e);
36 }
37 return null;
38 }
39 }