View Javadoc
1   package org.kuali.ole.handler;
2   
3   import com.thoughtworks.xstream.XStream;
4   import org.kuali.ole.bo.serachRetrieve.OleSRUDublin;
5   import org.kuali.ole.bo.serachRetrieve.OleSRUDublinRecord;
6   
7   /**
8    * Created with IntelliJ IDEA.
9    * User: srirams
10   * Date: 7/6/13
11   * Time: 6:21 PM
12   * To change this template use File | Settings | File Templates.
13   */
14  public class OleSRUDublinRecordResponseHandler {
15  
16      public OleSRUDublinRecord fromXML(String fileContent) {
17          XStream xStream = new XStream();
18          xStream.alias("dublincore", OleSRUDublinRecord.class);
19          xStream.alias("dublin", OleSRUDublin.class);
20          Object object = xStream.fromXML(fileContent);
21          return (OleSRUDublinRecord) object;
22      }
23  
24      public String toXML(OleSRUDublinRecord oleSRUDublinRecord) {
25          StringBuffer stringBuffer = new StringBuffer();
26          XStream xStream = new XStream();
27          xStream.alias("dublincore", OleSRUDublinRecord.class);
28          xStream.alias("dublin", OleSRUDublin.class);
29          String xml = xStream.toXML(oleSRUDublinRecord);
30          xml = xml.replace("<dublincore>", "");
31          xml = xml.replace("</dublincore>", "");
32          xml = xml.replace("<dublin>", "");
33          xml = xml.replace("</dublin>", "");
34          stringBuffer.append(xml);
35          return stringBuffer.toString();
36      }
37  }