List of usage examples for javax.xml.bind JAXBContext createUnmarshaller
public abstract Unmarshaller createUnmarshaller() throws JAXBException;
From source file:org.zaizi.sensefy.api.dto.faceting.configuration.FacetConfigurer.java
public FacetConfigurer() throws JAXBException, FileNotFoundException { String configPath = System.getProperty(CONFIG_DIR_VAR); File facetConfigFile;/*w w w. ja v a 2 s. c o m*/ InputStream is = null; if (configPath != null) { // load from the environment variable facetConfigFile = new File(configPath + FACET_CONFIGURATION_XML); if (facetConfigFile.exists()) is = new FileInputStream(facetConfigFile); } if (is == null) { is = this.getClass().getResourceAsStream("/config/FacetConfiguration.xml"); // takes // the // default // one } JAXBContext jc = JAXBContext.newInstance(FacetConfigurationList.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); facetConfiguration = (FacetConfigurationList) unmarshaller.unmarshal(is); facetConfiguration.initMap(); }
From source file:gov.nih.nci.cacis.ip.xds.DefaultXdsMetadataSupplier.java
private CaCISRequest unMarshalcaCisRequest(String caCisRequest) throws JAXBException { final JAXBContext ctx = JAXBContext.newInstance(CaCISRequest.class); return (CaCISRequest) ctx.createUnmarshaller().unmarshal(new ByteArrayInputStream(caCisRequest.getBytes())); }
From source file:se.inera.intyg.intygstjanst.web.service.converter.SendMessageToCareConverterTest.java
private SendMessageToCareType getSendMessageToCareTypeFromFile(String fileName) throws Exception { JAXBContext jaxbContext = JAXBContext.newInstance(SendMessageToCareType.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); return unmarshaller.unmarshal(new StreamSource(new ClassPathResource(fileName).getInputStream()), SendMessageToCareType.class).getValue(); }
From source file:se.inera.intyg.intygstjanst.web.integration.stub.RevokeMedicalCertificateResponderStubTest.java
@Test public void testName() throws Exception { // read request from file JAXBContext jaxbContext = JAXBContext.newInstance(RevokeMedicalCertificateRequestType.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); RevokeMedicalCertificateRequestType request = unmarshaller.unmarshal(new StreamSource( new ClassPathResource("revoke-medical-certificate/revoke-medical-certificate-request.xml") .getInputStream()),/*from w ww . jav a 2s . c o m*/ RevokeMedicalCertificateRequestType.class).getValue(); stub.revokeMedicalCertificate(null, request); verify(store).makulera(UTLATANDE_ID, REVOKE_MESSAGE); }
From source file:org.omg.dmn.tck.marshaller._20160719.TestCasesTest.java
@SuppressWarnings({ "unchecked" }) protected final TestCases load(InputStream inputStream) throws JAXBException { JAXBContext context = JAXBContext.newInstance(TestCases.class); Unmarshaller um = context.createUnmarshaller(); Object obj = um.unmarshal(inputStream); if (obj instanceof JAXBElement<?>) { return ((JAXBElement<TestCases>) obj).getValue(); } else {/*from w w w.j a va 2 s. c om*/ return (TestCases) obj; } }
From source file:fr.mael.microrss.xml.RSSFeedParser.java
@Override public Feed parseFeedInfo(Feed feed) throws Exception { JAXBContext jc = JAXBContext.newInstance("fr.mael.microrss.xml.rss"); Unmarshaller unmarshaller = jc.createUnmarshaller(); Rss rss = (Rss) unmarshaller.unmarshal(new URL(feed.getUrl()).openStream()); String link = XMLUtil.readProperty("link", rss.getChannel().getTitleOrLinkOrDescription()); feed.setIcon(Tools.getImage(Tools.getBaseUrl(link) + "/favicon.ico")); feed.setTitle(XMLUtil.readProperty("title", rss.getChannel().getTitleOrLinkOrDescription())); return feed;//from www. j a va 2s. com }
From source file:org.jasig.portlet.courses.dao.xml.MockGradesDaoImpl.java
@Override public CoursesByTerm getCoursesByTerm(PortletRequest request, String termCode) { try {/* w w w .ja va 2s.c o m*/ JAXBContext jaxbContext = JAXBContext.newInstance(TermsAndCourses.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); this.summary = (TermsAndCourses) unmarshaller.unmarshal(mockData.getInputStream()); } catch (IOException e) { log.error("Failed to read mock data for CourseByTerm", e); } catch (JAXBException e) { log.error("Failed to unmarshall mock data for CourseByTerm", e); } return this.summary.getCoursesByTerm(termCode); }
From source file:be.fedict.trust.tsl.TSLParser.java
private Unmarshaller getUnmarshaller() throws JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); return unmarshaller; }
From source file:ait.ffma.service.preservation.riskmanagement.api.riskanalysis.risk.RiskUtils.java
/** * @param in//from w ww.jav a2 s . c om */ public static void setRiskAnalysis(InputStream in) { try { JAXBContext jc = JAXBContext.newInstance(RiskAnalysis.class); Unmarshaller u = jc.createUnmarshaller(); ra = (RiskAnalysis) u.unmarshal(in); } catch (JAXBException e) { LOG.log(Level.SEVERE, e.getMessage()); } resetProperties(ra.getRiskFactors()); }
From source file:org.openmrs.module.dhisreport.api.DHIS2ReportingServiceDXFTest.java
@Ignore @Test/* w w w. j av a2 s .c o m*/ public void postDhisReportTest() throws Exception { HttpDhis2Server server = new HttpDhis2Server(); server.setUsername("admin"); server.setPassword("district"); server.setUrl(new URL("http://apps.dhis2.org/dev")); service.setDhis2Server(server); ClassPathResource resource = new ClassPathResource("dvset.xml"); JAXBContext jaxbContext = JAXBContext.newInstance(DataValueSet.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); DataValueSet dvset = (DataValueSet) jaxbUnmarshaller.unmarshal(resource.getInputStream()); ImportSummary summary = service.postDataValueSet(dvset); JAXBContext importSummaryContext = JAXBContext.newInstance(ImportSummary.class); Marshaller jaxbmarshaller = importSummaryContext.createMarshaller(); jaxbmarshaller.marshal(summary, System.out); }