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
9
10
11
12
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 }