List of usage examples for javax.xml.bind JAXB unmarshal
public static <T> T unmarshal(Source xml, Class<T> type)
From source file:gov.nist.healthcare.ttt.parsing.Parsing.java
public static String getWsseHeaderFromMTOM(String mtom) throws IOException, MessagingException { SOAPWithAttachment swa = Parsing.parseMtom(mtom); String wsseHeader = null;/*from w ww. ja v a 2s . c o m*/ Envelope env = (Envelope) JAXB.unmarshal(new StringReader(swa.getSoap()), Envelope.class); List<Object> headers = env.getHeader().getAny(); if (headers == null) { return null; } Iterator it = headers.iterator(); while (it.hasNext()) { Element header = (Element) it.next(); if (header.getLocalName().equals(ELEMENT_NAME_WSSE_SECURITY) && header.getNamespaceURI().equals(NAMESPACE_WSSE)) { wsseHeader = MiscUtil.xmlToString(header); break; } } return wsseHeader; }
From source file:ca.uhn.hl7v2.testpanel.model.conn.InboundConnectionList.java
public static InboundConnectionList fromXml(Controller theController, String theXml) { InboundConnectionList retVal = JAXB.unmarshal(new StringReader(theXml), InboundConnectionList.class); retVal.myController = theController; for (InboundConnection next : retVal.getConnections()) { next.setController(theController); }/*from w ww. jav a 2 s .c o m*/ return retVal; }
From source file:ca.uhn.hl7v2.testpanel.model.conn.OutboundConnectionList.java
public static OutboundConnectionList fromXml(Controller theController, String theXml) { OutboundConnectionList retVal = JAXB.unmarshal(new StringReader(theXml), OutboundConnectionList.class); for (OutboundConnection next : retVal.getConnections()) { next.setController(theController); }/* w w w . jav a 2 s . c om*/ return retVal; }
From source file:it.geosolutions.geobatch.unredd.script.test.utils.ResourceLoader.java
public void loadResources(GeoStoreClient geostore) throws FileNotFoundException, IOException { deleteAllResources(geostore);/*from www. j a va 2 s .co m*/ File geostoreDir = loadFile("georepo/resources"); for (File resFile : geostoreDir.listFiles((FilenameFilter) new PrefixFileFilter("resource"))) { Resource res = JAXB.unmarshal(resFile, Resource.class); LOGGER.info("LOADED " + res.getCategory().getName() + " : " + res.getName()); String basename = FilenameUtils.getBaseName(resFile.getName()); String sid = basename.substring(basename.indexOf("_") + 1); String dataFileName = "data_" + sid + ".txt"; File dataFile = new File(geostoreDir, dataFileName); String data = IOUtils.toString(new FileReader(dataFile)); RESTResource restRes = FlowUtil.copyResource(res); restRes.setData(data); LOGGER.info("INSERTING " + res.getCategory().getName() + " : " + res.getName()); geostore.insert(restRes); } }
From source file:net.javacrumbs.airline.server.VanillaTest.java
@Test public void testGetFlightsXml() throws AirlineException, DatatypeConfigurationException, TransformerException { GetFlightsRequest request = JAXB.unmarshal(getStream("request1.xml"), GetFlightsRequest.class); GetFlightsResponse response = endpoint.getFlights(request); DOMResult domResponse = new DOMResult(); JAXB.marshal(response, domResponse); XMLUnit.setIgnoreWhitespace(true);//from ww w.j ava 2 s . co m XMLAssert.assertXMLEqual(getDocument("response1.xml"), (Document) domResponse.getNode()); }
From source file:bigbluej.Client.java
private <T> T fromXml(Class<T> clazz, String input) { System.out.println("xml> " + input); return JAXB.unmarshal(new StringReader(input), clazz); }
From source file:se.inera.intyg.intygstjanst.web.integration.GetCertificateResponderImpl.java
protected void setCertificateBody(CertificateHolder certificate, GetCertificateResponseType response) { try {// w ww . j ava2 s .c o m RegisterCertificateType jaxbObject = JAXB.unmarshal( new StringReader(certificate.getOriginalCertificate()), RegisterCertificateType.class); response.setIntyg(jaxbObject.getIntyg()); response.getIntyg().getStatus() .addAll(CertificateStateHolderConverter.toIntygsStatusType(certificate.getCertificateStates())); } catch (Exception e) { LOGGER.error("Error while converting in GetCertificate for id: {} with stacktrace: {}", certificate.getId(), e.getStackTrace()); Throwables.propagate(e); } }
From source file:net.sourceforge.mavenhippo.ContentTypeDefinitionFinder.java
@SuppressWarnings("unchecked") private ContentTypeBean generateContentTypeIfPossible(File xml) { ContentTypeBean result = null;/*w w w .java2s .co m*/ try { Node unmarshaled = JAXB.unmarshal(xml, Node.class); Property primaryTypeProperty = unmarshaled.getPropertyByName(PropertyName.JCR_PRIMARY_TYPE); if (primaryTypeProperty != null && NodeType.TEMPLATE_TYPE.equals(primaryTypeProperty.getSingleValue()) && StringUtils.isBlank(unmarshaled.getMerge())) { result = new ContentTypeBean(unmarshaled, namespaces.inverseBidiMap()); } } catch (DataBindingException e) { log.info("\"" + xml.getName() + "\" is being ignored."); } return result; }
From source file:no.digipost.api.useragreements.client.response.ResponseUtils.java
public static <T> Stream<T> unmarshallEntities(final HttpResponse response, final Class<T> returnType) { return streamXmlDocumentsOf(getResponseEntityContent(response)).peek(RESPONSE_PAYLOAD_LOG::trace) .map(xml -> {//from w ww .j a v a 2 s . c o m try { return JAXB.unmarshal(new ByteArrayInputStream(xml.getBytes()), returnType); } catch (IllegalStateException | DataBindingException e) { throw new UnexpectedResponseException(response.getStatusLine(), ErrorCode.GENERAL_ERROR, xml, e); } }); }
From source file:it.geosolutions.unredd.stats.model.config.ConfigTest.java
public void testLoad00() throws IOException { File file = ctx.getResource("classpath:testStat00.xml").getFile(); assertNotNull("test file not found", file); StatisticConfiguration cfg = JAXB.unmarshal(file, StatisticConfiguration.class); assertNotNull("Error unmarshalling file", cfg); boolean check = StatisticChecker.check(cfg); System.out.println("Check is " + check); }