@Override Object mapAttachment(Attachment att, Object[] args) { return setter.put(att.asInputStream(), args); } }
public Object get(Object key) { if(key == null) return null; Object value = asMapIncludingInvocationProperties.get(key); //add the attachments from the Message to the corresponding attachment property if(key.equals(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS) || key.equals(MessageContext.INBOUND_MESSAGE_ATTACHMENTS)){ Map<String, DataHandler> atts = (Map<String, DataHandler>) value; if(atts == null) atts = new HashMap<String, DataHandler>(); AttachmentSet attSet = packet.getMessage().getAttachments(); for(Attachment att : attSet){ String cid = att.getContentId(); if (cid.indexOf("@jaxws.sun.com") == -1) { Object a = atts.get(cid); if (a == null) { a = atts.get("<" + cid + ">"); if (a == null) atts.put(att.getContentId(), att.asDataHandler()); } } else { atts.put(att.getContentId(), att.asDataHandler()); } } return atts; } return value; }
@SuppressWarnings("resource") private void writeNonMtomAttachments(AttachmentSet attachments, OutputStream out, String boundary) throws IOException { for (Attachment att : attachments) { DataHandler dh = att.asDataHandler(); if (dh instanceof StreamingDataHandler) { StreamingDataHandler sdh = (StreamingDataHandler) dh; // If DataHandler has href Content-ID, it is MTOM, so skip. if (sdh.getHrefCid() != null) continue; } // build attachment frame writeln("--" + boundary, out); writeMimeHeaders(att.getContentType(), att.getContentId(), out); att.writeTo(out); writeln(out); // write \r\n } }
@Override protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException { // TODO: handle attachments correctly Attachment root = mpp.getRootPart(); Codec rootCodec = getMimeRootCodec(packet); if (rootCodec instanceof RootOnlyCodec) { ((RootOnlyCodec)rootCodec).decode(root.asInputStream(),root.getContentType(),packet, new MimeAttachmentSet(mpp)); } else { rootCodec.decode(root.asInputStream(),root.getContentType(),packet); Map<String, Attachment> atts = mpp.getAttachmentParts(); for(Map.Entry<String, Attachment> att : atts.entrySet()) { packet.getMessage().getAttachments().add(att.getValue()); } } }
String cid = att.getContentId(); if(cid != null && cid.length() >0 && cid.charAt(0) != '<') cid = '<' + cid + '>'; writeln("Content-Id:" + cid, out); writeln("Content-Type: " + att.getContentType(), out); writeCustomMimeHeaders(att, out); writeln("Content-Transfer-Encoding: binary", out); att.writeTo(out);
@Override Object mapAttachment(Attachment att, Object[] args) { att.getContentType(); StringDataContentHandler sdh = new StringDataContentHandler(); try { String str = (String)sdh.getContent(new DataHandlerDataSource(att.asDataHandler())); return setter.put(str, args); } catch(Exception e) { throw new WebServiceException(e); } } }
public void add(Attachment att) { attMap.put('<'+att.getContentId()+'>', att); } }
@Override Object mapAttachment(Attachment att, Object[] args) { return setter.put(att.asByteArray(), args); } }
@Override Object mapAttachment(Attachment att, Object[] args) { return setter.put(att.asDataHandler(), args); } }
@Override protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException { // is this SwA or XOP? final String rootContentType = mpp.getRootPart().getContentType(); boolean isMTOM = isApplicationXopXml(rootContentType); packet.setMtomRequest(isMTOM); if(isMTOM) { xmlMtomCodec.decode(mpp,packet); } else if (isFastInfoset(rootContentType)) { if (packet.contentNegotiation == ContentNegotiation.none) throw noFastInfosetForDecoding(); useFastInfosetForEncoding = true; fiSwaCodec.decode(mpp,packet); } else if (isXml(rootContentType)) xmlSwaCodec.decode(mpp,packet); else { // TODO localize exception throw new IOException(""); } // checkDuplicateKnownHeaders(packet); }
@Override Object mapAttachment(Attachment att, Object[] args) { return setter.put(att.asSource(), args); } }
public void write(OutputStream os) throws IOException{ attachment.writeTo(os); }
@Override protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException { // TODO: handle attachments correctly Attachment root = mpp.getRootPart(); Codec rootCodec = getMimeRootCodec(packet); if (rootCodec instanceof RootOnlyCodec) { ((RootOnlyCodec)rootCodec).decode(root.asInputStream(),root.getContentType(),packet, new MimeAttachmentSet(mpp)); } else { rootCodec.decode(root.asInputStream(),root.getContentType(),packet); Map<String, Attachment> atts = mpp.getAttachmentParts(); for(Map.Entry<String, Attachment> att : atts.entrySet()) { packet.getMessage().getAttachments().add(att.getValue()); } } }
String cid = att.getContentId(); if(cid != null && cid.length() >0 && cid.charAt(0) != '<') cid = '<' + cid + '>'; writeln("Content-Id:" + cid, out); writeln("Content-Type: " + att.getContentType(), out); writeCustomMimeHeaders(att, out); writeln("Content-Transfer-Encoding: binary", out); att.writeTo(out);
void mapAttachment(Attachment att, Object[] args) { att.getContentType(); StringDataContentHandler sdh = new StringDataContentHandler(); try { String str = (String)sdh.getContent(new DataHandlerDataSource(att.asDataHandler())); setter.put(str, args); } catch(Exception e) { throw new WebServiceException(e); } } }
public void add(Attachment att) { attMap.put('<'+att.getContentId()+'>', att); } }
@Override Object mapAttachment(Attachment att, Object[] args) { return setter.put(att.asByteArray(), args); } }
@Override Object mapAttachment(Attachment att, Object[] args) { return setter.put(att.asDataHandler(), args); } }
@Override protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException { // is this SwA or XOP? final String rootContentType = mpp.getRootPart().getContentType(); boolean isMTOM = isApplicationXopXml(rootContentType); packet.setMtomRequest(isMTOM); if(isMTOM) { xmlMtomCodec.decode(mpp,packet); } else if (isFastInfoset(rootContentType)) { if (packet.contentNegotiation == ContentNegotiation.none) throw noFastInfosetForDecoding(); useFastInfosetForEncoding = true; fiSwaCodec.decode(mpp,packet); } else if (isXml(rootContentType)) xmlSwaCodec.decode(mpp,packet); else { // TODO localize exception throw new IOException(""); } // checkDuplicateKnownHeaders(packet); }
@Override Object mapAttachment(Attachment att, Object[] args) { return setter.put(att.asSource(), args); } }