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.OLECheckOutItem;
6
7
8
9
10
11
12
13
14 public class OLECheckOutItemConverter {
15 final Logger LOG = Logger.getLogger(OLECheckOutItemConverter.class);
16 public String generateCheckOutItemXml(OLECheckOutItem oleCheckOutItem){
17 XStream xStream = new XStream();
18 xStream.alias("checkOutItem",OLECheckOutItem.class);
19 return xStream.toXML(oleCheckOutItem);
20 }
21
22 public Object generateCheckoutItemObject(String xml){
23 XStream xStream = new XStream();
24 xStream.alias("checkOutItem",OLECheckOutItem.class);
25 return xStream.fromXML(xml);
26 }
27 public String generateCheckOutItemJson(String xml) {
28 OLECheckOutItem oleCheckOutItem = (OLECheckOutItem)generateCheckoutItemObject(xml);
29 OleCirculationHandler xmlContentHandler = new OleCirculationHandler();
30 try{
31 return xmlContentHandler.marshalToJSON(oleCheckOutItem);
32 }catch(Exception e){
33 LOG.error(e,e);
34 }
35 return null;
36 }
37 }