List of usage examples for javax.xml.bind JAXB unmarshal
public static <T> T unmarshal(Source xml, Class<T> type)
From source file:io.personium.test.jersey.box.ServiceSchmaTest.java
$metadata_$metadata() { TResponse res = Http.request("box/$metadata-$metadata-get.txt") .with("path", "\\$metadata/\\$metadata") .with("col", "setodata") .with("accept", "application/xml") .with("token", PersoniumUnitConfig.getMasterToken()) .returns()/* w ww . j av a2s . c o m*/ .statusCode(HttpStatus.SC_OK) .debug(); // ??? String str = res.getBody(); Edmx edmx = JAXB.unmarshal(new StringReader(str), Edmx.class); Edmx checkBody = getRightEdmx(); assertTrue(checkBody.equals(edmx)); }
From source file:edu.harvard.hms.dbmi.i2b2.api.ont.ONTCell.java
/** * Get dirty state//from w w w. jav a2s . com * * @param client * HTTP Client * @param blob * Return data stored as Blob or Clob * @param type * Sets type of categories * @return Dirty state * @throws JAXBException * An XML Processing Exception occurred * @throws UnsupportedOperationException * An unsupported operation exception occurred * @throws I2B2InterfaceException * An error occurred on the i2b2 server * @throws IOException * An IO Exception occurred */ @SuppressWarnings("unchecked") public DirtyValueType getDirtyState(HttpClient client, boolean blob, String type) throws JAXBException, UnsupportedOperationException, I2B2InterfaceException, IOException { RequestMessageType rmt = createMinimumBaseMessage("/getDirtyState"); GetReturnType gst = ontOF.createGetReturnType(); gst.setBlob(blob); gst.setType(type); rmt.getMessageBody().getAny().add(ontOF.createGetDirtyState(gst)); // Mashall the XML to String and attach it to the post request StringWriter sw = new StringWriter(); ontMarshaller.marshal(ontOF.createRequest(rmt), sw); ResponseMessageType responseMT = JAXB.unmarshal(runRequest(client, sw.toString(), "/getDirtyState"), ResponseMessageType.class); if (!responseMT.getResponseHeader().getResultStatus().getStatus().getType().equals("DONE")) { throw new I2B2InterfaceException( responseMT.getResponseHeader().getResultStatus().getStatus().getValue()); } return ((JAXBElement<DirtyValueType>) responseMT.getMessageBody().getAny().get(0)).getValue(); }
From source file:ca.uhn.hl7v2.testpanel.model.msg.Hl7V2MessageCollection.java
public static Hl7V2MessageCollection fromXml(ProfileFileList theProfileFileList, String theContents) { XmlFormat xmlFormat = JAXB.unmarshal(new StringReader(theContents), XmlFormat.class); return fromXml(theProfileFileList, xmlFormat); }
From source file:edu.harvard.hms.dbmi.i2b2.api.crc.CRCCell.java
@SuppressWarnings("unchecked") private edu.harvard.hms.dbmi.i2b2.api.crc.xml.psm.ResponseType getPSMResponseType(InputStream inputStream) throws I2B2InterfaceException { edu.harvard.hms.dbmi.i2b2.api.crc.xml.psm.ResponseMessageType rmt = JAXB.unmarshal(inputStream, edu.harvard.hms.dbmi.i2b2.api.crc.xml.psm.ResponseMessageType.class); if (!rmt.getResponseHeader().getResultStatus().getStatus().getType().equals("DONE")) { throw new I2B2InterfaceException(rmt.getResponseHeader().getResultStatus().getStatus().getValue()); }// w w w . j a v a 2 s. c om return ((JAXBElement<edu.harvard.hms.dbmi.i2b2.api.crc.xml.psm.ResponseType>) rmt.getMessageBody().getAny() .get(0)).getValue(); }
From source file:edu.harvard.hms.dbmi.i2b2.api.ont.ONTCell.java
@SuppressWarnings("unchecked") private <T> T getType(T returnType, InputStream inputStream) throws I2B2InterfaceException { ResponseMessageType rmt = JAXB.unmarshal(inputStream, ResponseMessageType.class); String status = rmt.getResponseHeader().getResultStatus().getStatus().getType(); if (!(status.equals("SUCCESS") || status.equals("DONE"))) { throw new I2B2InterfaceException(rmt.getResponseHeader().getResultStatus().getStatus().getValue()); }/*w ww . j a va 2 s . c o m*/ return ((JAXBElement<T>) rmt.getMessageBody().getAny().get(0)).getValue(); }
From source file:edu.harvard.hms.dbmi.i2b2.api.crc.CRCCell.java
@SuppressWarnings("unchecked") private ResponseType getPDOResponseType(InputStream inputStream) throws I2B2InterfaceException { ResponseMessageType rmt = JAXB.unmarshal(inputStream, ResponseMessageType.class); if (!rmt.getResponseHeader().getResultStatus().getStatus().getType().equals("DONE")) { throw new I2B2InterfaceException(rmt.getResponseHeader().getResultStatus().getStatus().getValue()); }//from ww w.jav a2 s . c om return ((JAXBElement<ResponseType>) rmt.getMessageBody().getAny().get(0)).getValue(); }
From source file:edu.harvard.hms.dbmi.i2b2.api.ont.ONTCell.java
/** * Check for any errors and throw an exception if they occur * // w w w. j ava 2s .c o m * @param inputStream * XML stream for input * @throws I2B2InterfaceException * An error occurred on the i2b2 server */ private void checkForError(InputStream inputStream) throws I2B2InterfaceException { ResponseMessageType rmt = JAXB.unmarshal(inputStream, ResponseMessageType.class); String status = rmt.getResponseHeader().getResultStatus().getStatus().getType(); if (!(status.equals("SUCCESS") || status.equals("DONE"))) { throw new I2B2InterfaceException(rmt.getResponseHeader().getResultStatus().getStatus().getValue()); } }
From source file:edu.harvard.hms.dbmi.i2b2.api.pm.PMCell.java
/** * Returns an object of whatever type specified in the return type from the * given inputStream//w w w. j av a2s.c o m * * @param returnType * Type to return * @param inputStream * InputStream * @return Object * @throws I2B2InterfaceException * An error occurred on the i2b2 server */ @SuppressWarnings("unchecked") private <T> T getType(T returnType, InputStream inputStream) throws I2B2InterfaceException { // System.out.println(convertStreamToString(inputStream)); ResponseMessageType rmt = JAXB.unmarshal(inputStream, ResponseMessageType.class); String status = rmt.getResponseHeader().getResultStatus().getStatus().getType(); if (!(status.equals("SUCCESS") || status.equals("DONE"))) { throw new I2B2InterfaceException(rmt.getResponseHeader().getResultStatus().getStatus().getValue()); } return ((JAXBElement<T>) rmt.getMessageBody().getAny().get(0)).getValue(); }
From source file:org.apache.juddi.adminconsole.hub.JUDDIRequestsAsXML.java
public static Object getObjectJuddi(String method, String content) { StringReader sr = new StringReader(content); if (method.equalsIgnoreCase("save_ClientSubscriptionInfo")) { return JAXB.unmarshal(sr, SaveClientSubscriptionInfo.class); }/*from ww w . j a v a 2 s .co m*/ if (method.equalsIgnoreCase("invoke_SyncSubscription")) { return JAXB.unmarshal(sr, SyncSubscription.class); } if (method.equalsIgnoreCase("admin_SaveBusiness")) { return JAXB.unmarshal(sr, AdminSaveBusiness.class); } if (method.equalsIgnoreCase("admin_SaveTModel")) { //System.out.println(content); return JAXB.unmarshal(sr, AdminSaveTModel.class); } if (method.equalsIgnoreCase("admin_SaveSubscription")) { return JAXB.unmarshal(sr, AdminSaveSubscriptionRequest.class); } if (method.equalsIgnoreCase("set_ReplicationNodes")) { return JAXB.unmarshal(sr, ReplicationConfiguration.class); } return null; }
From source file:org.apache.juddi.adminconsole.hub.UddiAdminHub.java
private String invoke_SyncSubscription(HttpServletRequest parameters) { StringBuilder ret = new StringBuilder(); SyncSubscription sb = new SyncSubscription(); SyncSubscriptionDetail d = null;// w w w . ja v a2 s . c om try { StringReader sr = new StringReader(parameters.getParameter("invokeSyncSubscriptionXML").trim()); sb = (JAXB.unmarshal(sr, SyncSubscription.class)); sb.setAuthInfo(GetToken()); d = juddi.invokeSyncSubscription(sb); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; sb.setAuthInfo(GetToken()); try { d = juddi.invokeSyncSubscription(sb); } catch (Exception ex1) { return HandleException(ex); } } else { return HandleException(ex); } } if (d != null) { ret.append("<pre>"); StringWriter sw = new StringWriter(); JAXB.marshal(d, sw); sw.append(PrettyPrintXML(sw.toString())); ret.append("</pre>"); } else { ret.append("No data returned"); } return ret.toString(); }