View Javadoc
1   package org.kuali.ole.docstore.common.exception;
2   
3   
4   import org.apache.log4j.Logger;
5   
6   import javax.xml.bind.JAXBContext;
7   import javax.xml.bind.JAXBElement;
8   import javax.xml.bind.Marshaller;
9   import javax.xml.bind.Unmarshaller;
10  import javax.xml.bind.annotation.*;
11  import javax.xml.transform.stream.StreamSource;
12  import java.io.ByteArrayInputStream;
13  import java.io.StringWriter;
14  import java.util.ArrayList;
15  import java.util.List;
16  
17  
18  /**
19   * <p>Java class for bibImportResponse complex type.
20   * <p/>
21   * <p>The following schema fragment specifies the expected content contained within this class.
22   * <p/>
23   * <pre>
24   * &lt;complexType name="bibImportResponse">
25   *   &lt;complexContent>
26   *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
27   *       &lt;sequence>
28   *         &lt;element name="bibImportResults" type="{}bibImportResult" maxOccurs="unbounded" minOccurs="0"/>
29   *       &lt;/sequence>
30   *     &lt;/restriction>
31   *   &lt;/complexContent>
32   * &lt;/complexType>
33   * </pre>
34   */
35  @XmlAccessorType(XmlAccessType.FIELD)
36  @XmlType(name = "bibImportResponse", propOrder = {
37          "bibImportResults"
38  })
39  
40  @XmlRootElement
41  public class BibImportResponse {
42  
43      private static final Logger LOG = Logger.getLogger(BibImportResponse.class);
44  
45      @XmlElement(nillable = true)
46      protected List<BibImportResult> bibImportResults;
47  
48  
49      public static String serialize(Object object) {
50          String result = null;
51          StringWriter sw = new StringWriter();
52          BibImportResponse bibImportResponse = (BibImportResponse) object;
53          try {
54              JAXBContext jaxbContext = JAXBContext.newInstance(BibImportResponse.class);
55              Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
56              jaxbMarshaller.marshal(bibImportResponse, sw);
57              result = sw.toString();
58          } catch (Exception e) {
59              LOG.error("Exception :", e);
60          }
61          return result;
62      }
63  
64      public static Object deserialize(String content) {
65  
66          JAXBElement<BibImportResponse> bibImportResponseElement = null;
67          try {
68              JAXBContext jaxbContext = JAXBContext.newInstance(BibImportResponse.class);
69              Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
70              ByteArrayInputStream input = new ByteArrayInputStream(content.getBytes("UTF-8"));
71              bibImportResponseElement = jaxbUnmarshaller.unmarshal(new StreamSource(input), BibImportResponse.class);
72          } catch (Exception e) {
73              LOG.error("Exception :", e);
74          }
75          return bibImportResponseElement.getValue();
76      }
77  
78      /**
79       * Gets the value of the bibImportResults property.
80       * <p/>
81       * <p/>
82       * This accessor method returns a reference to the live list,
83       * not a snapshot. Therefore any modification you make to the
84       * returned list will be present inside the JAXB object.
85       * This is why there is not a <CODE>set</CODE> method for the bibImportResults property.
86       * <p/>
87       * <p/>
88       * For example, to add a new item, do as follows:
89       * <pre>
90       *    getBibImportResults().add(newItem);
91       * </pre>
92       * <p/>
93       * <p/>
94       * <p/>
95       * Objects of the following type(s) are allowed in the list
96       * {@link BibImportResult }
97       */
98      public List<BibImportResult> getBibImportResults() {
99          if (bibImportResults == null) {
100             bibImportResults = new ArrayList<BibImportResult>();
101         }
102         return this.bibImportResults;
103     }
104 
105     public void setBibImportResults(List<BibImportResult> bibImportResults) {
106         this.bibImportResults = bibImportResults;
107     }
108 
109 }