List of usage examples for javax.xml.bind JAXBException getMessage
public String getMessage()
From source file:org.kitodo.dataformat.access.MetsXmlElementAccess.java
/** * Reads METS from an InputStream. JAXB is used to parse the XML. * /* www . ja v a 2 s . c o m*/ * @param in * InputStream to read from */ @Override public Workpiece read(InputStream in) throws IOException { try { JAXBContext jc = JAXBContext.newInstance(Mets.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); Mets mets = (Mets) unmarshaller.unmarshal(in); return new MetsXmlElementAccess(mets).workpiece; } catch (JAXBException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } else { throw new IOException(e.getMessage(), e); } } }
From source file:org.kitodo.dataformat.access.MetsXmlElementAccess.java
/** * Writes the contents of this workpiece as a METS file into an output * stream.//www . ja va 2 s.co m * * @param out * writable output stream * @throws IOException * if the output device has an error */ @Override public void save(Workpiece workpiece, OutputStream out) throws IOException { try { JAXBContext context = JAXBContext.newInstance(Mets.class); Marshaller marshal = context.createMarshaller(); marshal.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshal.marshal(new MetsXmlElementAccess(workpiece).toMets(), out); } catch (JAXBException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } else { throw new IOException(e.getMessage(), e); } } }
From source file:org.kuali.mobility.open311.dao.Open311DaoImpl.java
private void getAttributes(final String serviceCode) { if (serviceAttributes == null) serviceAttributes = new AttributesImpl(); jaxbDataMapper = new JAXBMapperImpl(); boolean isServiceBaseUrlAvailable = (getServiceBaseUrl() != null ? true : false); String serviceUrl = ""; if (isServiceBaseUrlAvailable) { serviceUrl = getServiceBaseUrl() + serviceCode + ".xml"; }//from w w w .j a v a 2s .co m try { JAXBContext jaxbContext = JAXBContext.newInstance(serviceAttributes.getClass()); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); if (isServiceBaseUrlAvailable) { // serviceAttributes = mapper.mapData(serviceAttributes, new URL(serviceUrl), getAttributeMappingFile()); // marshaller.marshal(serviceAttributes, System.out); serviceAttributes = jaxbDataMapper.mapData(serviceAttributes, serviceAttributes.getObjectFactory(), serviceUrl, true, getAttributeMappingFileJaxb()); marshaller.marshal(serviceAttributes, System.out); } else { serviceAttributes = jaxbDataMapper.mapData(serviceAttributes, serviceAttributes.getObjectFactory(), getServiceBaseFile(), false, getAttributeMappingFileJaxb()); marshaller.marshal(serviceAttributes, System.out); } if (serviceAttributes.getAttribute() != null) { for (Attribute a : serviceAttributes.getAttribute()) { Map<String, String> valueMap = null; if (a.getValues() != null) { valueMap = new LinkedHashMap<String, String>(); for (AttributeValue v : a.getValues()) { valueMap.put(v.getKey(), v.getName()); } } a.setvalueMap(valueMap); } } } catch (JAXBException e) { LOG.error(e.getMessage()); } catch (MalformedURLException e) { LOG.error(e.getMessage()); } catch (ClassNotFoundException e) { LOG.error(e.getMessage()); } catch (IOException e) { LOG.error(e.getMessage()); } }
From source file:org.marketcetera.marketdata.core.rpc.MarketDataRpcService.java
@Override public SnapshotPageResponse getSnapshotPage(RpcController inController, SnapshotPageRequest inRequest) throws ServiceException { RpcMarketdata.SnapshotPageResponse.Builder responseBuilder = RpcMarketdata.SnapshotPageResponse .newBuilder();/* w w w. ja v a2 s .com*/ try { serverServices.validateAndReturnSession(inRequest.getSessionId()); Instrument instrument = serverServices.unmarshall(inRequest.getInstrument().getPayload()); Content content = Content.valueOf(inRequest.getContent().name()); String provider = null; if (inRequest.hasProvider()) { provider = inRequest.getProvider(); } Deque<Event> events = serviceAdapter.getSnapshotPage(instrument, content, provider, new PageRequest(inRequest.getPage().getPage(), inRequest.getPage().getSize())); for (Event event : events) { responseBuilder.addPayload(serverServices.marshal(event)); } return responseBuilder.build(); } catch (JAXBException e) { return responseBuilder.setFailed(true).setMessage(e.getMessage() == null ? "" : e.getMessage()).build(); } }
From source file:org.motechproject.mobile.omp.manager.intellivr.IntellIVRServerImpl.java
public void init() { try {//from w w w .j av a 2 s . c o m jaxbc = JAXBContext.newInstance("org.motechproject.mobile.omp.manager.intellivr"); } catch (JAXBException e) { log.error(e.getMessage()); } }
From source file:org.nuxeo.launcher.NuxeoLauncher.java
/** * @since 5.6// w w w. ja v a 2 s . c o m */ protected void printXMLOutput() { try { JAXBContext jaxbContext = JAXBContext.newInstance(CommandSetInfo.class, CommandInfo.class, PackageInfo.class, MessageInfo.class); printXMLOutput(jaxbContext, cset); } catch (JAXBException e) { log.error("Output serialization failed: " + e.getMessage(), e); errorValue = EXIT_CODE_NOT_RUNNING; } }
From source file:org.nuxeo.launcher.NuxeoLauncher.java
/** * @since 5.6/* w ww. j av a 2s. co m*/ */ protected void printInstanceXMLOutput(InstanceInfo instance) { try { JAXBContext jaxbContext = JAXBContext.newInstance(InstanceInfo.class, DistributionInfo.class, PackageInfo.class, ConfigurationInfo.class, KeyValueInfo.class); printXMLOutput(jaxbContext, instance); } catch (JAXBException e) { log.error("Output serialization failed: " + e.getMessage()); log.debug(e, e); errorValue = EXIT_CODE_NOT_RUNNING; } }
From source file:org.onehippo.cms7.essentials.dashboard.utils.XmlUtils.java
public static XmlNode parseXml(final InputStream content) { try {/*from w ww.jav a 2 s. c o m*/ final JAXBContext context = JAXBContext.newInstance(XmlNode.class); final Unmarshaller unmarshaller = context.createUnmarshaller(); return (XmlNode) unmarshaller.unmarshal(content); } catch (JAXBException e) { if (log.isDebugEnabled()) { log.error("Error parsing XmlNode document", e.getMessage()); } } return null; }
From source file:org.onehippo.cms7.essentials.dashboard.utils.XmlUtils.java
public static XmlNode parseXml(final Path path) { try {/* w w w. ja va2 s. c o m*/ final JAXBContext context = JAXBContext.newInstance(XmlNode.class); final Unmarshaller unmarshaller = context.createUnmarshaller(); return (XmlNode) unmarshaller.unmarshal(path.toFile()); } catch (JAXBException e) { if (log.isDebugEnabled()) { log.error("Error parsing XmlNode document: " + path, e.getMessage()); } } return null; }
From source file:org.openbel.framework.tools.Backtrack.java
private String convert(final Document d) throws ConversionError { try {/*from w w w . j a v a 2 s.c om*/ return converter.toXML(d); } catch (JAXBException e) { e.printStackTrace(); final String name = d.getName(); final String msg = e.getMessage(); final Throwable cause = e; throw new ConversionError(name, msg, cause); } catch (IOException e) { final String name = d.getName(); final String msg = e.getMessage(); final Throwable cause = e; throw new ConversionError(name, msg, cause); } }