List of usage examples for javax.xml.bind JAXBException getErrorCode
public String getErrorCode()
From source file:de.hybris.platform.b2b.punchout.PunchOutUtils.java
public static CXML unmarshallCXMLFromFile(final String relativeFilePath) throws FileNotFoundException { final InputStream fileInputStream = PunchOutUtils.class.getClassLoader() .getResourceAsStream(relativeFilePath); if (fileInputStream == null) { throw new FileNotFoundException("Could not find file [" + relativeFilePath + "]"); }/* w ww .ja va 2 s . c o m*/ try { final JAXBContext jaxbContext = JAXBContext.newInstance(CXML.class); final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); return (CXML) unmarshaller.unmarshal(fileInputStream); } catch (final JAXBException e) { throw new PunchOutException(e.getErrorCode(), e.getMessage()); } }
From source file:de.hybris.platform.b2b.punchout.PunchOutUtils.java
public static String marshallFromBeanTree(final CXML cxml) { final StringWriter writer = new StringWriter(); try {/* w w w.j a v a 2 s . c o m*/ final JAXBContext context = JAXBContext.newInstance(CXML.class); final Marshaller m = context.createMarshaller(); removeStandalone(m); setHeader(m); m.marshal(cxml, writer); } catch (final JAXBException e) { throw new PunchOutException(e.getErrorCode(), e.getMessage()); } final String xml = writer.toString(); return xml; }
From source file:net.emotivecloud.scheduler.drp4ost.DRP4OST.java
private OVFWrapper parse(String ovfXml) { OVFWrapper rv = null;/*from w w w .java2 s . c o m*/ StringBuilder cause = new StringBuilder(); try { rv = OVFWrapperFactory.parse(ovfXml); } catch (JAXBException e) { if (e instanceof PropertyException) { cause.append("Access to property failed: " + e.getErrorCode()); } else if (e instanceof MarshalException) { cause.append("Marshalling failed: " + e.getLocalizedMessage()); } else if (e instanceof UnmarshalException) { cause.append("Unmarshalling failed: " + e.getCause()); } else if (e instanceof ValidationException) { cause.append("XML Validation failed: " + e.getErrorCode()); } else { cause.append("Unespected " + e.getErrorCode()); cause.append(e.getClass().getName()); cause.append(": "); } cause.append(e.getMessage()); throw new DRPOSTException(cause.toString(), e, StatusCodes.XML_PROBLEM); } catch (OVFException e) { cause.append("Problems parsing OVF file: "); cause.append(e.getMessage()); throw new DRPOSTException(cause.toString(), e, StatusCodes.XML_PROBLEM); } return rv; }
From source file:net.emotivecloud.scheduler.drp4one.DRP4OVF.java
private OCAComputeWrapper parseOcaCompute(String s) { OCAComputeWrapper rv = null;/*from www. ja v a 2 s.c o m*/ StringBuilder cause = new StringBuilder(); try { rv = OCAComputeWrapperFactory.parse(s); } catch (SAXException se) { throw new DRPOneException("XML Parsing error", se, StatusCodes.INTERNAL); } catch (JAXBException e) { if (e instanceof PropertyException) { cause.append("Access to property failed: " + e.getErrorCode()); } else if (e instanceof MarshalException) { cause.append("Marshalling failed: " + e.getLocalizedMessage()); } else if (e instanceof UnmarshalException) { cause.append("Unmarshalling failed: " + e.getCause()); } else if (e instanceof ValidationException) { cause.append("XML Validation failed: " + e.getErrorCode()); } else { cause.append("Unespected " + e.getErrorCode()); cause.append(e.getClass().getName()); cause.append(": "); } cause.append(e.getMessage()); log.error(cause.toString()); if (log.isTraceEnabled()) { log.trace(cause, e); } throw new DRPOneException(cause.toString(), e, StatusCodes.ONE_FAILURE); } return rv; }
From source file:net.emotivecloud.scheduler.drp4one.DRP4OVF.java
private OCAComputeListWrapper parseOcaComputeList(String s) { OCAComputeListWrapper rv = null;//from w w w. j a v a 2s .c om StringBuilder cause = new StringBuilder(); try { rv = OCAComputeListWrapperFactory.parseList(s); } catch (SAXException se) { throw new DRPOneException("XML Parsing error", se, StatusCodes.INTERNAL); } catch (JAXBException e) { if (e instanceof PropertyException) { cause.append("Access to property failed: " + e.getErrorCode()); } else if (e instanceof MarshalException) { cause.append("Marshalling failed: " + e.getLocalizedMessage()); } else if (e instanceof UnmarshalException) { cause.append("Unmarshalling failed: " + e.getCause()); } else if (e instanceof ValidationException) { cause.append("XML Validation failed: " + e.getErrorCode()); } else { cause.append("Unespected " + e.getErrorCode()); cause.append(e.getClass().getName()); cause.append(": "); } cause.append(e.getMessage()); log.error(cause.toString()); if (log.isTraceEnabled()) { log.trace(cause, e); } throw new DRPOneException(cause.toString(), e, StatusCodes.ONE_FAILURE); } return rv; }
From source file:net.emotivecloud.scheduler.drp4one.DRP4OVF.java
private OVFWrapper parse(String ovfXml) throws DRPOneException { OVFWrapper rv = null;// w ww. jav a2 s . co m StringBuilder cause = new StringBuilder(); try { rv = OVFWrapperFactory.parse(ovfXml); } catch (JAXBException e) { if (e instanceof PropertyException) { cause.append("Access to property failed: " + e.getErrorCode()); } else if (e instanceof MarshalException) { cause.append("Marshalling failed: " + e.getLocalizedMessage()); } else if (e instanceof UnmarshalException) { cause.append("Unmarshalling failed: " + e.getCause()); } else if (e instanceof ValidationException) { cause.append("XML Validation failed: " + e.getErrorCode()); } else { cause.append("Unespected " + e.getErrorCode()); cause.append(e.getClass().getName()); cause.append(": "); } cause.append(e.getMessage()); log.error(cause.toString()); if (log.isTraceEnabled()) { log.trace(cause, e); } throw new DRPOneException(cause.toString(), e, StatusCodes.XML_PROBLEM); } catch (OVFException e) { cause.append("Problems parsing OVF file: "); cause.append(e.getMessage()); log.error(cause.toString()); if (log.isTraceEnabled()) { log.trace(cause, e); } throw new DRPOneException(cause.toString(), e, StatusCodes.XML_PROBLEM); } return rv; }