@Override public AttachmentMarshaller getAttachmentMarshaller() { if (xmlMarshaller.getAttachmentMarshaller() == null) { return null; } return ((AttachmentMarshallerAdapter) xmlMarshaller.getAttachmentMarshaller()).getAttachmentMarshaller(); }
public AttachmentMarshaller getAttachmentMarshaller() { if (xmlMarshaller.getAttachmentMarshaller() == null) { return null; } return ((AttachmentMarshallerAdapter) xmlMarshaller.getAttachmentMarshaller()).getAttachmentMarshaller(); }
public void serialize(XMLDocument xmlDocument, OutputStream outputStream, Object options) throws IOException { XMLMarshaller xmlMarshaller = getXmlMarshaller(); XMLAttachmentMarshaller attachmentMarshaller = xmlMarshaller.getAttachmentMarshaller(); //temporarily null out the attachment marshaller as it should not be used during serialization xmlMarshaller.setAttachmentMarshaller(null); OutputStreamWriter writer = new OutputStreamWriter(outputStream, xmlMarshaller.getEncoding()); save(xmlDocument, writer, xmlMarshaller); xmlMarshaller.setAttachmentMarshaller(attachmentMarshaller); }
public void serialize(XMLDocument xmlDocument, OutputStream outputStream, Object options) throws IOException { XMLMarshaller xmlMarshaller = getXmlMarshaller(); XMLAttachmentMarshaller attachmentMarshaller = xmlMarshaller.getAttachmentMarshaller(); //temporarily null out the attachment marshaller as it should not be used during serialization xmlMarshaller.setAttachmentMarshaller(null); OutputStreamWriter writer = new OutputStreamWriter(outputStream, xmlMarshaller.getEncoding()); save(xmlDocument, writer, xmlMarshaller); xmlMarshaller.setAttachmentMarshaller(attachmentMarshaller); }
protected Node objectToXMLNode(Object object, Node rootNode, AbstractSession session,XMLDescriptor descriptor, boolean isXMLRoot) throws XMLMarshalException { DocumentPreservationPolicy docPresPolicy = xmlContext.getDocumentPreservationPolicy(session); if (docPresPolicy != null && docPresPolicy.shouldPreserveDocument()) { XMLRecord xmlRow = null; if (!isXMLRoot) { xmlRow = (XMLRecord) ((XMLObjectBuilder) descriptor.getObjectBuilder()).createRecordFor(object, xmlContext.getDocumentPreservationPolicy(session)); xmlRow.setMarshaller(this); if (getAttachmentMarshaller() != null) { xmlRow.setXOPPackage(getAttachmentMarshaller().isXOPPackage()); } if (xmlRow.getDOM().getNodeType() == Node.ELEMENT_NODE) { addDescriptorNamespacesToXMLRecord(descriptor, xmlRow); } } Document doc = objectToXML(object, rootNode, descriptor, xmlRow, isXMLRoot, docPresPolicy); if ((xmlRow != null) && (xmlRow.getDOM().getNodeType() == Node.DOCUMENT_FRAGMENT_NODE)) { return xmlRow.getDOM(); } else { return doc; } } MarshalRecord marshalRecord = new NodeRecord(); marshalRecord.setMarshaller(this); marshalRecord.getNamespaceResolver().setDOM(rootNode); marshal(object, marshalRecord, session, descriptor, isXMLRoot); return marshalRecord.getDocument(); }
/** * INTERNAL: * Convert the given object to an XML Document * @param object the object to marshal * @return the document which the specified object has been marshalled to * @param descriptor the XMLDescriptor for the object being marshalled * @throws XMLMarshalException if an error occurred during marshalling */ protected Document objectToXML(Object object, XMLDescriptor descriptor, boolean isXMLRoot) throws XMLMarshalException { AbstractSession session = xmlContext.getSession(descriptor); DocumentPreservationPolicy docPresPolicy = xmlContext.getDocumentPreservationPolicy(session); if (docPresPolicy != null && docPresPolicy.shouldPreserveDocument()) { XMLRecord xmlRow = null; if (!isXMLRoot) { xmlRow = (XMLRecord) ((XMLObjectBuilder) descriptor.getObjectBuilder()).createRecordFor(object, xmlContext.getDocumentPreservationPolicy(session)); xmlRow.setMarshaller(this); if (getAttachmentMarshaller() != null) { xmlRow.setXOPPackage(getAttachmentMarshaller().isXOPPackage()); } addDescriptorNamespacesToXMLRecord(descriptor, xmlRow); } return objectToXML(object, descriptor, xmlRow, isXMLRoot, docPresPolicy); } MarshalRecord marshalRecord = new NodeRecord(); marshalRecord.setMarshaller(this); marshal(object, marshalRecord, session, descriptor, isXMLRoot); return marshalRecord.getDocument(); }
if (getAttachmentMarshaller() != null) { xmlRow.setXOPPackage(getAttachmentMarshaller().isXOPPackage());
XMLRecord xmlRow = (XMLRecord) ((XMLObjectBuilder) descriptor.getObjectBuilder()).createRecord(localRootName, parent, session); xmlRow.setMarshaller(this); if (getAttachmentMarshaller() != null) { xmlRow.setXOPPackage(getAttachmentMarshaller().isXOPPackage());
if (isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { String id = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) element); element = id; } catch (ClassCastException cce) { c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(bytes, 0, bytes.length, this.mimeTypePolicy.getMimeType(parent), field.getLastXPathFragment().getLocalName(), field.getLastXPathFragment().getNamespaceURI()); } else if (getAttributeElementClass() == XMLBinaryDataHelper.getXMLBinaryDataHelper().DATA_HANDLER) { c_id = marshaller.getAttachmentMarshaller().addMtomAttachment((DataHandler) element, field.getLastXPathFragment().getLocalName(), field.getLastXPathFragment().getNamespaceURI()); if(c_id == null) { XMLBinaryDataHelper.EncodedData data = XMLBinaryDataHelper.getXMLBinaryDataHelper().getBytesForBinaryValue(element, marshaller, this.mimeTypePolicy.getMimeType(parent)); XMLBinaryDataHelper.EncodedData data = XMLBinaryDataHelper.getXMLBinaryDataHelper().getBytesForBinaryValue(element, marshaller, this.mimeTypePolicy.getMimeType(parent)); bytes = data.getData(); c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(bytes, 0, bytes.length, data.getMimeType(), field.getLastXPathFragment().getLocalName(), field.getLastXPathFragment().getNamespaceURI()); } else if (isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { String c_id = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) element); element = c_id; } catch (Exception ex) {
if (isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { String id = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) element); element = id; } catch (ClassCastException cce) { c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(bytes, 0, bytes.length, this.mimeTypePolicy.getMimeType(parent), field.getLastXPathFragment().getLocalName(), field.getLastXPathFragment().getNamespaceURI()); } else if (getAttributeElementClass() == XMLBinaryDataHelper.getXMLBinaryDataHelper().DATA_HANDLER) { c_id = marshaller.getAttachmentMarshaller().addMtomAttachment((DataHandler) element, field.getLastXPathFragment().getLocalName(), field.getLastXPathFragment().getNamespaceURI()); if(c_id == null) { XMLBinaryDataHelper.EncodedData data = XMLBinaryDataHelper.getXMLBinaryDataHelper().getBytesForBinaryValue(element, marshaller, this.mimeTypePolicy.getMimeType(parent)); XMLBinaryDataHelper.EncodedData data = XMLBinaryDataHelper.getXMLBinaryDataHelper().getBytesForBinaryValue(element, marshaller, this.mimeTypePolicy.getMimeType(parent)); bytes = data.getData(); c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(bytes, 0, bytes.length, data.getMimeType(), field.getLastXPathFragment().getLocalName(), field.getLastXPathFragment().getNamespaceURI()); } else if (isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { String c_id = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) element); element = c_id; } catch (Exception ex) {
if (isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { String id = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) element); element = id; } catch (ClassCastException cce) { c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(bytes, 0, bytes.length, this.mimeTypePolicy.getMimeType(parent), field.getLastXPathFragment().getLocalName(), field.getLastXPathFragment().getNamespaceURI()); } else if (getCollectionContentType() == XMLBinaryDataHelper.getXMLBinaryDataHelper().DATA_HANDLER) { c_id = marshaller.getAttachmentMarshaller().addMtomAttachment((DataHandler) element, field.getLastXPathFragment().getLocalName(), field.getLastXPathFragment().getNamespaceURI()); if(c_id == null) { XMLBinaryDataHelper.EncodedData data = XMLBinaryDataHelper.getXMLBinaryDataHelper().getBytesForBinaryValue(element, marshaller, this.mimeTypePolicy.getMimeType(parent)); XMLBinaryDataHelper.EncodedData data = XMLBinaryDataHelper.getXMLBinaryDataHelper().getBytesForBinaryValue(element, marshaller, this.mimeTypePolicy.getMimeType(parent)); bytes = data.getData(); c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(bytes, 0, bytes.length, data.getMimeType(), field.getLastXPathFragment().getLocalName(), field.getLastXPathFragment().getNamespaceURI()); } else if (isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { String c_id = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) element); element = c_id; } catch (Exception ex) {
XMLField field = (XMLField) getField(); if (field.getLastXPathFragment().isAttribute()) { if (isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { value = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) attributeValue); } else { value = marshaller.getAttachmentMarshaller().addSwaRefAttachment(bytes, 0, bytes.length); c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(// bytes, 0,// c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(// (DataHandler) attributeValue, elementName, namespaceUri); if(c_id == null) { c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(bytes, 0,// } else if (isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { c_id = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) attributeValue); } else { c_id = marshaller.getAttachmentMarshaller().addSwaRefAttachment(bytes, 0, bytes.length);
if (xmlBinaryDataMapping.isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { c_id = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) objectValue); if(c_id == null) { c_id = marshaller.getAttachmentMarshaller().addSwaRefAttachment(bytes, 0, bytes.length); if (objectValue.getClass() == ClassConstants.APBYTE) { bytes = (byte[]) objectValue; c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(bytes, 0, bytes.length, this.xmlBinaryDataMapping.getMimeType(object), lastFrag.getLocalName(), lastFrag.getNamespaceURI()); } else if (xmlBinaryDataMapping.getAttributeClassification() == XMLBinaryDataHelper.getXMLBinaryDataHelper().DATA_HANDLER) { c_id = marshaller.getAttachmentMarshaller().addMtomAttachment((DataHandler) objectValue, lastFrag.getLocalName(), lastFrag.getNamespaceURI()); if(c_id == null) { c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(bytes, 0, bytes.length, data.getMimeType(), lastFrag.getLocalName(), lastFrag.getNamespaceURI()); marshalRecord.closeStartElement(); if (xmlBinaryDataMapping.isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { if(c_id != null) { marshalRecord.characters(c_id);
XMLField field = (XMLField) getField(); if (field.getLastXPathFragment().isAttribute()) { if (isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { value = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) attributeValue); } else { value = marshaller.getAttachmentMarshaller().addSwaRefAttachment(bytes, 0, bytes.length); c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(// bytes, 0,// c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(// (DataHandler) attributeValue, elementName, namespaceUri); if(c_id == null) { c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(bytes, 0,// } else if (isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { c_id = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) attributeValue); } else { c_id = marshaller.getAttachmentMarshaller().addSwaRefAttachment(bytes, 0, bytes.length);
marshalRecord.closeStartElement(); if (xmlBinaryDataCollectionMapping.isSwaRef() && marshaller.getAttachmentMarshaller() != null) { c_id = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) objectValue); if(c_id == null) { c_id = marshaller.getAttachmentMarshaller().addSwaRefAttachment(bytes, 0, bytes.length); if (objectValue.getClass() == ClassConstants.APBYTE) { bytes = (byte[]) objectValue; c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(bytes, 0, bytes.length, this.xmlBinaryDataCollectionMapping.getMimeType(object), lastFrag.getLocalName(), lastFrag.getNamespaceURI()); } else if (xmlBinaryDataCollectionMapping.getAttributeClassification() == XMLBinaryDataHelper.getXMLBinaryDataHelper().DATA_HANDLER) { c_id = marshaller.getAttachmentMarshaller().addMtomAttachment((DataHandler) objectValue, lastFrag.getLocalName(), lastFrag.getNamespaceURI()); if(c_id == null) { c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(bytes, 0, bytes.length, // data.getMimeType(), lastFrag.getLocalName(), lastFrag.getNamespaceURI());
if (isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { value = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) attributeValue); } else { value = marshaller.getAttachmentMarshaller().addSwaRefAttachment(bytes, 0, bytes.length); c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(// bytes, 0,// c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(// (DataHandler) attributeValue, field.getLastXPathFragment().getLocalName(), field.getLastXPathFragment().getNamespaceURI()); if(c_id == null) { c_id = marshaller.getAttachmentMarshaller().addMtomAttachment(bytes, 0,// } else if (isSwaRef() && (marshaller.getAttachmentMarshaller() != null)) { c_id = marshaller.getAttachmentMarshaller().addSwaRefAttachment((DataHandler) attributeValue); } else { c_id = marshaller.getAttachmentMarshaller().addSwaRefAttachment(bytes, 0, bytes.length);
if (getAttachmentMarshaller() != null) { marshalRecord.setXOPPackage(getAttachmentMarshaller().isXOPPackage());