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.OLECirculationErrorMessage;
6   
7   /**
8    * Created with IntelliJ IDEA.
9    * User: sheiksalahudeenm
10   * Date: 9/4/13
11   * Time: 12:26 PM
12   * To change this template use File | Settings | File Templates.
13   */
14  public class OLECirculationErrorMessageConverter {
15      final Logger LOG = Logger.getLogger(OLECirculationErrorMessageConverter.class);
16  
17      public String generateCirculationErrorXml(OLECirculationErrorMessage oleCirculationErrorMessage){
18          XStream xstream = new XStream();
19          xstream.alias("response",OLECirculationErrorMessage.class);
20          String response  =xstream.toXML(oleCirculationErrorMessage);
21          if(LOG.isInfoEnabled()){
22              LOG.info("Circulation Error :"+response);
23          }
24          return  response;
25      }
26  
27  
28  
29      public OLECirculationErrorMessage getCirculationErrorObject(String xml){
30          XStream xstream = new XStream();
31          xstream.alias("response",OLECirculationErrorMessage.class);
32          OLECirculationErrorMessage oleCirculationErrorMessage   =(OLECirculationErrorMessage)xstream.fromXML(xml);
33          return oleCirculationErrorMessage;
34      }
35  
36      public String generateLookupUserJson(String xml) {
37          OLECirculationErrorMessage oleCirculationErrorMessage = (OLECirculationErrorMessage)getCirculationErrorObject(xml);
38          OleCirculationHandler xmlContentHandler = new OleCirculationHandler();
39          try{
40              return xmlContentHandler.marshalToJSON(oleCirculationErrorMessage);
41          }catch(Exception e){
42              LOG.error(e,e);
43          }
44          return null;
45      }
46  
47  
48  
49  
50  }