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