List of usage examples for javax.xml.bind JAXBException getMessage
public String getMessage()
From source file:ait.ffma.service.preservation.riskmanagement.api.riskanalysis.risk.RiskUtils.java
/** * @param in/*from ww w. j a v a 2 s . co 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:ait.ffma.service.preservation.riskmanagement.api.riskanalysis.risk.RiskUtils.java
/** * This method initializes a set of risk properties loaded from XML file. * /*from w ww.j ava 2 s .c o m*/ * @param xmlFile * The XML file containing properties definitions * @return property set in risk analysis format */ public static RiskAnalysis loadRiskPropertiesFromXML(String xmlFile) { try { JAXBContext jc = JAXBContext.newInstance(RiskAnalysis.class); Unmarshaller u = jc.createUnmarshaller(); InputStream in = RiskUtils.class.getResourceAsStream(xmlFile); ra = (RiskAnalysis) u.unmarshal(in); } catch (JAXBException e) { LOG.log(Level.SEVERE, e.getMessage()); return null; } // resetProperties(ra.getRiskFactors()); return ra; }
From source file:ait.ffma.service.preservation.riskmanagement.api.riskanalysis.risk.RiskUtils.java
/** * This method writes java object to XML file * //from w w w . j a va2 s . c o m * @param object * The Java object that should be converted to XML format * @param filePath * The path to the place where created XML file should be stored */ public static void storeRiskDataInXML(Object object, String filePath) { try { FileWriter fileWriter = new FileWriter(filePath); try { JAXBContext context = JAXBContext.newInstance(object.getClass()); Marshaller marshaller = context.createMarshaller(); marshaller.marshal(object, fileWriter); fileWriter.close(); } finally { fileWriter.close(); } } catch (JAXBException e) { LOG.log(Level.SEVERE, e.getMessage()); } catch (IOException e) { LOG.log(Level.SEVERE, e.getMessage()); } }
From source file:com.jaspersoft.jasperserver.rest.services.RESTAttribute.java
private String generateProfileAttributeReport(List<ProfileAttribute> atts) { try {/*ww w .j ava 2 s.co m*/ StringWriter sw = new StringWriter(); JAXBList<ProfileAttribute> lst; lst = new JAXBList<ProfileAttribute>(atts); Marshaller m = restUtils.getMarshaller(JAXBList.class, ProfileAttributeImpl.class); m.marshal(lst, sw); if (log.isDebugEnabled()) { log.debug("finished marshaling attributes: " + lst.size()); } return sw.toString(); } catch (JAXBException e) { throw new ServiceException(e.getMessage()); } }
From source file:ait.ffma.service.preservation.riskmanagement.api.riskanalysis.risk.RiskUtils.java
/** * This method returns risk analysis object. * @return/* w w w . j a va 2s .c o m*/ */ public static RiskAnalysis loadRiskAnalysis() { if (RiskUtils.ra == null || RiskUtils.getGeneralProperty("RiskAnalysis.ReloadXML").equalsIgnoreCase("true")) { try { JAXBContext jc = JAXBContext.newInstance(RiskAnalysis.class); Unmarshaller u = jc.createUnmarshaller(); InputStream in = RiskUtils.class .getResourceAsStream(RiskUtils.getGeneralProperty("Riskanalysis.XML")); ra = (RiskAnalysis) u.unmarshal(in); } catch (JAXBException e) { LOG.log(Level.SEVERE, e.getMessage()); return null; } RiskUtils.setGeneralProperty("RiskAnalysis.ReloadXML", "false"); } resetProperties(ra.getRiskFactors()); return ra; }
From source file:com.discogs.api.webservice.impl.HttpClientWebService.java
private Resp createResp(InputStream inputStream) { Resp resp = null;/*from w w w .j a v a 2 s. c o m*/ try { JAXBContext jaxbContext = JAXBContext.newInstance("com.discogs.api.model"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); resp = (Resp) unmarshaller.unmarshal(inputStream); } catch (JAXBException e) { logger.error(e.getMessage()); } return resp; }
From source file:be.fedict.trust.tsl.TSLParser.java
public void parseTrustedList() { TrustStatusListType trustStatusList; try {// w w w . ja va 2s. c o m trustStatusList = parseTslInputStream(); } catch (JAXBException e) { throw new RuntimeException("TSL parsing error: " + e.getMessage(), e); } LOG.debug("TSL parsed"); TSLSchemeInformationType tslSchemeInformation = trustStatusList.getSchemeInformation(); BigInteger tslSequenceNumber = tslSchemeInformation.getTSLSequenceNumber(); LOG.debug("TSL sequence number: " + tslSequenceNumber); for (TSLConsumer tslConsumer : this.tslConsumers) { tslConsumer.setTSLSequenceNumber(tslSequenceNumber); } }
From source file:gov.hhs.fha.nhinc.lift.proxy.client.TestClientHandshaker.java
@Override public boolean handshake(ProtocolWrapper wrapper, Client client) throws IOException { try {//from w ww .j a va 2 s .com log.debug("Initiating handshake."); // Need to send security info to server for validation. LiftConnectionRequestToken token = new LiftConnectionRequestToken(client.getToken().getRequest()); wrapper.sendLine(ProxyUtil.marshalToString(token)); String response = wrapper.readLine(); LiftConnectionResponseToken resp = (LiftConnectionResponseToken) ProxyUtil .unmarshalFromReader(new StringReader(response), LiftConnectionResponseToken.class); log.debug("Response to handshake: " + resp.getPermission()); // Return if was a good response or not. return resp.isPermitted(); } catch (JAXBException ex) { log.error("JAXB exception in handshake: " + ex.getMessage()); throw new IOException("JAXB exception in handshake: " + ex.getMessage()); } }
From source file:com.webcohesion.ofx4j.client.impl.LocalResourceFIDataStore.java
/** * Store the data somewhere./*from www . ja v a 2 s.co m*/ * * @param out The output stream. * @throws IOException If an error occurs. */ public void storeData(OutputStream out) throws IOException { try { FIDataList dataList = new FIDataList(); ArrayList<BaseFinancialInstitutionData> data = new ArrayList<BaseFinancialInstitutionData>(); for (FinancialInstitutionData datum : fiData.values()) { if (datum instanceof BaseFinancialInstitutionData) { data.add((BaseFinancialInstitutionData) datum); } } dataList.setData(data); JAXBContext.newInstance(FIDataList.class).createMarshaller().marshal(dataList, out); } catch (JAXBException e) { throw new IOException(e.getMessage()); } }
From source file:com.webcohesion.ofx4j.client.impl.LocalResourceFIDataStore.java
/** * Load the institution data from a specific stream. * * @param in The stream.// w w w .ja v a 2 s . c o m * @throws IOException If the resource is unreadable or malformed. */ public LocalResourceFIDataStore(InputStream in) throws IOException { Map<String, FinancialInstitutionData> fiData = new HashMap<String, FinancialInstitutionData>(); if (in != null) { try { FIDataList list = (FIDataList) JAXBContext.newInstance(FIDataList.class).createUnmarshaller() .unmarshal(in); if (list != null && list.getData() != null) { for (BaseFinancialInstitutionData fi : list.getData()) { fiData.put(fi.getId(), fi); } } } catch (JAXBException e) { throw new IOException(e.getMessage()); } if (LOG.isInfoEnabled()) { LOG.info(fiData.size() + " institutions loaded."); } } this.fiData = fiData; }