public static QName getPayloadRootQName(Source source, TransformerHelper transformerHelper) throws TransformerException { if (source == null) { return null; } try { PayloadRootSourceCallback callback = new PayloadRootSourceCallback(); TraxUtils.doWithSource(source, callback); if (callback.result != null) { return callback.result; } else { // we have no other option than to transform DOMResult domResult = new DOMResult(); transformerHelper.transform(source, domResult); Document document = (Document) domResult.getNode(); return QNameUtils.getQNameForNode(document.getDocumentElement()); } } catch (TransformerException ex) { throw ex; } catch (Exception ex) { return null; } }
public Object unmarshal(Source source) { if (TraxUtils.isStaxSource(source)) { XMLStreamReader streamReader = TraxUtils.getXMLStreamReader(source); if (streamReader != null) { source = new StaxSource(streamReader); } else { XMLEventReader eventReader = TraxUtils.getXMLEventReader(source); if (eventReader != null) { source = new StaxSource(eventReader); } else { throw new IllegalArgumentException( "StAXSource contains neither XMLStreamReader nor XMLEventReader"); } } } try { return createUnmarshaller().unmarshal(source); } catch (JAXBException ex) { throw convertJaxbException(ex); } }
public void marshal(Object graph, Result result) { if (TraxUtils.isStaxResult(result)) { XMLStreamWriter streamWriter = TraxUtils.getXMLStreamWriter(result); if (streamWriter != null) { result = new StaxResult(streamWriter); } else { XMLEventWriter eventWriter = TraxUtils.getXMLEventWriter(result); if (eventWriter != null) { result = new StaxResult(eventWriter); } else { throw new IllegalArgumentException( "StAXResult contains neither XMLStreamWriter nor XMLEventWriter"); } } } try { createMarshaller().marshal(graph, result); } catch (JAXBException ex) { throw convertJaxbException(ex); } }
private Object unmarshalStaxSource(Unmarshaller jaxbUnmarshaller, Source staxSource) throws JAXBException { XMLStreamReader streamReader = TraxUtils.getXMLStreamReader(staxSource); if (streamReader != null) { return jaxbUnmarshaller.unmarshal(streamReader); } else { XMLEventReader eventReader = TraxUtils.getXMLEventReader(staxSource); if (eventReader != null) { return jaxbUnmarshaller.unmarshal(eventReader); } else { throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader"); } } }
private void marshalStaxResult(Marshaller jaxbMarshaller, Object graph, Result staxResult) throws JAXBException { XMLStreamWriter streamWriter = TraxUtils.getXMLStreamWriter(staxResult); if (streamWriter != null) { jaxbMarshaller.marshal(graph, streamWriter); } else { XMLEventWriter eventWriter = TraxUtils.getXMLEventWriter(staxResult); if (eventWriter != null) { jaxbMarshaller.marshal(graph, eventWriter); } else { throw new IllegalArgumentException("StAX Result contains neither XMLStreamWriter nor XMLEventConsumer"); } } }
/** * Returns the last modified date of the given {@link Source}. * * @param source the source * @return the last modified date, as a long */ static long getLastModified(Source source) { if (source instanceof DOMSource) { Document document = TraxUtils.getDocument((DOMSource) source); return document != null ? getLastModified(document.getDocumentURI()) : -1; } else { return getLastModified(source.getSystemId()); } }
try { Jaxb2ResultCallback callback = new Jaxb2ResultCallback(clazz, jaxbElement); TraxUtils.doWithResult(responsePayload, callback);
return unmarshalDomSource((DOMSource) source); else if (TraxUtils.isStaxSource(source)) { return unmarshalStaxSource(source);
marshalDomResult(graph, (DOMResult) result); else if (TraxUtils.isStaxResult(result)) { marshalStaxResult(graph, result);
/** * Returns the last modified date of the given {@link Source}. * * @param source the source * @return the last modified date, as a long */ static long getLastModified(Source source) { if (source instanceof DOMSource) { Document document = TraxUtils.getDocument((DOMSource) source); return document != null ? getLastModified(document.getDocumentURI()) : -1; } else { return getLastModified(source.getSystemId()); } }
try { Jaxb2ResultCallback callback = new Jaxb2ResultCallback(clazz, jaxbElement); TraxUtils.doWithResult(responsePayload, callback);
/** * Template method for handling <code>StaxSource</code>s. This implementation defers to * <code>unmarshalXmlStreamReader</code>, or <code>unmarshalXmlEventReader</code>. * * @param staxSource the <code>StaxSource</code> * @return the object graph * @throws XmlMappingException if the given source cannot be mapped to an object */ protected Object unmarshalStaxSource(Source staxSource) throws XmlMappingException { XMLStreamReader streamReader = TraxUtils.getXMLStreamReader(staxSource); if (streamReader != null) { return unmarshalXmlStreamReader(streamReader); } else { XMLEventReader eventReader = TraxUtils.getXMLEventReader(staxSource); if (eventReader != null) { return unmarshalXmlEventReader(eventReader); } else { throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader"); } } }
/** * Template method for handling <code>StaxResult</code>s. This implementation defers to * <code>marshalXMLSteamWriter</code>, or <code>marshalXMLEventConsumer</code>, depending on what is contained in * the <code>StaxResult</code>. * * @param graph the root of the object graph to marshal * @param staxResult a Spring-WS {@link StaxSource} or JAXP 1.4 {@link StAXSource} * @throws XmlMappingException if the given object cannot be marshalled to the result * @throws IllegalArgumentException if the <code>domResult</code> is empty * @see #marshalDomNode(Object,org.w3c.dom.Node) */ protected void marshalStaxResult(Object graph, Result staxResult) throws XmlMappingException { XMLStreamWriter streamWriter = TraxUtils.getXMLStreamWriter(staxResult); if (streamWriter != null) { marshalXmlStreamWriter(graph, streamWriter); } else { XMLEventWriter eventWriter = TraxUtils.getXMLEventWriter(staxResult); if (eventWriter != null) { marshalXmlEventWriter(graph, eventWriter); } else { throw new IllegalArgumentException("StaxResult contains neither XMLStreamWriter nor XMLEventConsumer"); } } }
public Object unmarshal(Source source, MimeContainer mimeContainer) throws XmlMappingException { try { Unmarshaller unmarshaller = createUnmarshaller(); if (mtomEnabled && mimeContainer != null) { unmarshaller.setAttachmentUnmarshaller(new Jaxb2AttachmentUnmarshaller(mimeContainer)); } if (TraxUtils.isStaxSource(source)) { return unmarshalStaxSource(unmarshaller, source); } else { return unmarshaller.unmarshal(source); } } catch (JAXBException ex) { throw convertJaxbException(ex); } }
public void marshal(Object graph, Result result, MimeContainer mimeContainer) throws XmlMappingException { try { Marshaller marshaller = createMarshaller(); if (mtomEnabled && mimeContainer != null) { marshaller.setAttachmentMarshaller(new Jaxb2AttachmentMarshaller(mimeContainer)); } if (TraxUtils.isStaxResult(result)) { marshalStaxResult(marshaller, graph, result); } else { marshaller.marshal(graph, result); } } catch (JAXBException ex) { throw convertJaxbException(ex); } }
public static QName getPayloadRootQName(Source source, TransformerHelper transformerHelper) throws TransformerException { if (source == null) { return null; } try { PayloadRootSourceCallback callback = new PayloadRootSourceCallback(); TraxUtils.doWithSource(source, callback); if (callback.result != null) { return callback.result; } else { // we have no other option than to transform DOMResult domResult = new DOMResult(); transformerHelper.transform(source, domResult); Document document = (Document) domResult.getNode(); return QNameUtils.getQNameForNode(document.getDocumentElement()); } } catch (TransformerException ex) { throw ex; } catch (Exception ex) { return null; } }
/** * Returns the last modified date of the given {@link Source}. * * @param source the source * @return the last modified date, as a long */ static long getLastModified(Source source) { if (source instanceof DOMSource) { Document document = TraxUtils.getDocument((DOMSource) source); return document != null ? getLastModified(document.getDocumentURI()) : -1; } else { return getLastModified(source.getSystemId()); } }
try { Jaxb2ResultCallback callback = new Jaxb2ResultCallback(clazz, jaxbElement); TraxUtils.doWithResult(responsePayload, callback);
public static QName getPayloadRootQName(Source source, TransformerHelper transformerHelper) throws TransformerException { if (source == null) { return null; } try { PayloadRootSourceCallback callback = new PayloadRootSourceCallback(); TraxUtils.doWithSource(source, callback); if (callback.result != null) { return callback.result; } else { // we have no other option than to transform DOMResult domResult = new DOMResult(); transformerHelper.transform(source, domResult); Document document = (Document) domResult.getNode(); return QNameUtils.getQNameForNode(document.getDocumentElement()); } } catch (TransformerException ex) { throw ex; } catch (Exception ex) { return null; } }
/** * Returns the last modified date of the given {@link Source}. * * @param source the source * @return the last modified date, as a long */ static long getLastModified(Source source) { if (source instanceof DOMSource) { Document document = TraxUtils.getDocument((DOMSource) source); return document != null ? getLastModified(document.getDocumentURI()) : -1; } else { return getLastModified(source.getSystemId()); } }