View Javadoc
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    * Created with IntelliJ IDEA.
9    * User: maheswarang
10   * Date: 7/29/13
11   * Time: 8:44 PM
12   * To change this template use File | Settings | File Templates.
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  }