List of usage examples for javax.xml.bind Unmarshaller unmarshal
public Object unmarshal(javax.xml.stream.XMLEventReader reader) throws JAXBException;
From source file:com.photon.phresco.plugins.util.WarConfigProcessor.java
public WarConfigProcessor(File configFile) throws JAXBException, IOException { if (configFile.exists()) { JAXBContext jaxbContext = JAXBContext.newInstance(Assembly.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); assembly = (Assembly) jaxbUnmarshaller.unmarshal(configFile); } else {/* w ww. j a v a2 s . c o m*/ configFile.createNewFile(); assembly = new Assembly(); } file = configFile; }
From source file:ait.ffma.service.preservation.riskmanagement.api.riskanalysis.risk.RiskUtils.java
/** * @param in/* w w w.ja va 2 s . c o m*/ */ 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:nl.stil4m.ideal.executor.RequestExecutor.java
public <T extends Response> T execute(IdealRequest<T> request) throws FailedRequestException { try {/*from www . j a va2 s .c o m*/ HttpGet get = buildHttpRequest(request); HttpResponse httpResponse = httpClient.execute(get); JAXBContext jaxbContext = JAXBContext.newInstance(request.getResponseClass()); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); T response = (T) jaxbUnmarshaller.unmarshal(httpResponse.getEntity().getContent()); if (!response.succeeded()) { throw new FailedRequestException(request, response); } return response; } catch (IOException | JAXBException | URISyntaxException e) { throw new RequestExecutorException(e); } }
From source file:com.wso2telco.core.config.ConfigLoader.java
/** * Inits the m connect config./*from ww w .j a v a 2 s . com*/ * * @return the mobile connect config * @throws JAXBException the JAXB exception */ private MobileConnectConfig initMConnectConfig() throws JAXBException { String configPath = CarbonUtils.getCarbonConfigDirPath() + File.separator + "mobile-connect.xml"; File file = new File(configPath); JAXBContext ctx = JAXBContext.newInstance(MobileConnectConfig.class); Unmarshaller um = ctx.createUnmarshaller(); return (MobileConnectConfig) um.unmarshal(file); }
From source file:org.jasig.portlet.courses.dao.xml.MockGradesDaoImpl.java
@Override public CoursesByTerm getCoursesByTerm(PortletRequest request, String termCode) { try {//from w w w . j av a2 s .c om 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:com.virtualparadigm.packman.processor.JPackageManager.java
private static Collection<Package> unmarshallFromFile(String inputFilePath) { List<Package> installPackageList = null; try {//from w w w .java 2 s.c o m File inputFile = new File(inputFilePath); if (inputFile.exists()) { Unmarshaller unmarashaller = jaxbContext.createUnmarshaller(); List<String> lines = FileUtils.readLines(new File(inputFilePath)); installPackageList = new ArrayList<Package>(); for (String line : lines) { installPackageList.add((Package) unmarashaller.unmarshal(new StringReader(line))); } } } catch (Exception e) { logger.error("", e); } return installPackageList; }
From source file:gov.nih.nci.cabig.caaers.web.rule.ContextListener.java
private RuleUi load(String fileName) { InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); try {//from ww w . j a va 2s .c om Unmarshaller unmarshaller = JAXBContext.newInstance("com.semanticbits.rules.ui").createUnmarshaller(); RuleUi ruleUi = (RuleUi) unmarshaller.unmarshal(inputStream); return ruleUi; } catch (JAXBException e) { throw new CaaersSystemException(e.getMessage(), e); } finally { IOUtils.closeQuietly(inputStream); } }
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;/* ww w . j av a2 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:org.apache.falcon.regression.core.response.ServiceResponse.java
/** * Retrieves EntitiesResult from a message if possible. * @return EntitiesResult//from ww w .ja v a2 s. c om */ public EntityList getEntityList() { try { JAXBContext jc = JAXBContext.newInstance(EntityList.class); Unmarshaller u = jc.createUnmarshaller(); return (EntityList) u.unmarshal(new StringReader(message)); } catch (JAXBException e) { LOGGER.info("getEntityList() failed:\n" + ExceptionUtils.getStackTrace(e)); return null; } }
From source file:org.fcrepo.integration.api.AbstractResourceIT.java
protected ObjectProfile getObject(final String pid) throws ClientProtocolException, IOException, JAXBException { final HttpGet get = new HttpGet(serverAddress + "objects/" + pid); final HttpResponse resp = execute(get); final Unmarshaller um = context.createUnmarshaller(); return (ObjectProfile) um.unmarshal(resp.getEntity().getContent()); }