Java Code Examples for com.sun.xml.internal.ws.api.message.Attachment#writeTo()

The following examples show how to use com.sun.xml.internal.ws.api.message.Attachment#writeTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MtomCodec.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@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
    }
}
 
Example 2
Source File: MtomCodec.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@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
    }
}
 
Example 3
Source File: MtomCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@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
    }
}
 
Example 4
Source File: MtomCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@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
    }
}
 
Example 5
Source File: MtomCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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
    }
}
 
Example 6
Source File: MtomCodec.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@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
    }
}
 
Example 7
Source File: MtomCodec.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@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
    }
}
 
Example 8
Source File: MtomCodec.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@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
    }
}
 
Example 9
Source File: MimeCodec.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) throws IOException {
    Message msg = packet.getMessage();
    if (msg == null) {
        return null;
    }
    ContentTypeImpl ctImpl = (ContentTypeImpl)getStaticContentType(packet);
    String boundary = ctImpl.getBoundary();
    boolean hasAttachments = (boundary != null);
    Codec rootCodec = getMimeRootCodec(packet);
    if (hasAttachments) {
        writeln("--"+boundary, out);
        ContentType ct = rootCodec.getStaticContentType(packet);
        String ctStr = (ct != null) ? ct.getContentType() : rootCodec.getMimeType();
        writeln("Content-Type: " + ctStr, out);
        writeln(out);
    }
    ContentType primaryCt = rootCodec.encode(packet, out);

    if (hasAttachments) {
        writeln(out);
        // Encode all the attchments
        for (Attachment att : msg.getAttachments()) {
            writeln("--"+boundary, out);
            //SAAJ's AttachmentPart.getContentId() returns content id already enclosed with
            //angle brackets. For now put angle bracket only if its not there
            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);
            writeln(out);                    // write \r\n
            att.writeTo(out);
            writeln(out);                    // write \r\n
        }
        writeAsAscii("--"+boundary, out);
        writeAsAscii("--", out);
    }
    // TODO not returing correct multipart/related type(no boundary)
    return hasAttachments ? ctImpl : primaryCt;
}
 
Example 10
Source File: MimeCodec.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) throws IOException {
    Message msg = packet.getMessage();
    if (msg == null) {
        return null;
    }
    ContentTypeImpl ctImpl = (ContentTypeImpl)getStaticContentType(packet);
    String boundary = ctImpl.getBoundary();
    boolean hasAttachments = (boundary != null);
    Codec rootCodec = getMimeRootCodec(packet);
    if (hasAttachments) {
        writeln("--"+boundary, out);
        ContentType ct = rootCodec.getStaticContentType(packet);
        String ctStr = (ct != null) ? ct.getContentType() : rootCodec.getMimeType();
        writeln("Content-Type: " + ctStr, out);
        writeln(out);
    }
    ContentType primaryCt = rootCodec.encode(packet, out);

    if (hasAttachments) {
        writeln(out);
        // Encode all the attchments
        for (Attachment att : msg.getAttachments()) {
            writeln("--"+boundary, out);
            //SAAJ's AttachmentPart.getContentId() returns content id already enclosed with
            //angle brackets. For now put angle bracket only if its not there
            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);
            writeln(out);                    // write \r\n
            att.writeTo(out);
            writeln(out);                    // write \r\n
        }
        writeAsAscii("--"+boundary, out);
        writeAsAscii("--", out);
    }
    // TODO not returing correct multipart/related type(no boundary)
    return hasAttachments ? ctImpl : primaryCt;
}
 
Example 11
Source File: MimeCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) throws IOException {
    Message msg = packet.getMessage();
    if (msg == null) {
        return null;
    }
    ContentTypeImpl ctImpl = (ContentTypeImpl)getStaticContentType(packet);
    String boundary = ctImpl.getBoundary();
    boolean hasAttachments = (boundary != null);
    Codec rootCodec = getMimeRootCodec(packet);
    if (hasAttachments) {
        writeln("--"+boundary, out);
        ContentType ct = rootCodec.getStaticContentType(packet);
        String ctStr = (ct != null) ? ct.getContentType() : rootCodec.getMimeType();
        writeln("Content-Type: " + ctStr, out);
        writeln(out);
    }
    ContentType primaryCt = rootCodec.encode(packet, out);

    if (hasAttachments) {
        writeln(out);
        // Encode all the attchments
        for (Attachment att : msg.getAttachments()) {
            writeln("--"+boundary, out);
            //SAAJ's AttachmentPart.getContentId() returns content id already enclosed with
            //angle brackets. For now put angle bracket only if its not there
            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);
            writeln(out);                    // write \r\n
            att.writeTo(out);
            writeln(out);                    // write \r\n
        }
        writeAsAscii("--"+boundary, out);
        writeAsAscii("--", out);
    }
    // TODO not returing correct multipart/related type(no boundary)
    return hasAttachments ? ctImpl : primaryCt;
}
 
Example 12
Source File: MimeCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) throws IOException {
    Message msg = packet.getMessage();
    if (msg == null) {
        return null;
    }
    ContentTypeImpl ctImpl = (ContentTypeImpl)getStaticContentType(packet);
    String boundary = ctImpl.getBoundary();
    boolean hasAttachments = (boundary != null);
    Codec rootCodec = getMimeRootCodec(packet);
    if (hasAttachments) {
        writeln("--"+boundary, out);
        ContentType ct = rootCodec.getStaticContentType(packet);
        String ctStr = (ct != null) ? ct.getContentType() : rootCodec.getMimeType();
        writeln("Content-Type: " + ctStr, out);
        writeln(out);
    }
    ContentType primaryCt = rootCodec.encode(packet, out);

    if (hasAttachments) {
        writeln(out);
        // Encode all the attchments
        for (Attachment att : msg.getAttachments()) {
            writeln("--"+boundary, out);
            //SAAJ's AttachmentPart.getContentId() returns content id already enclosed with
            //angle brackets. For now put angle bracket only if its not there
            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);
            writeln(out);                    // write \r\n
            att.writeTo(out);
            writeln(out);                    // write \r\n
        }
        writeAsAscii("--"+boundary, out);
        writeAsAscii("--", out);
    }
    // TODO not returing correct multipart/related type(no boundary)
    return hasAttachments ? ctImpl : primaryCt;
}
 
Example 13
Source File: MimeCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) throws IOException {
    Message msg = packet.getMessage();
    if (msg == null) {
        return null;
    }
    ContentTypeImpl ctImpl = (ContentTypeImpl)getStaticContentType(packet);
    String boundary = ctImpl.getBoundary();
    String rootId = ctImpl.getRootId();
    boolean hasAttachments = (boundary != null);
    Codec rootCodec = getMimeRootCodec(packet);
    if (hasAttachments) {
        writeln("--"+boundary, out);
        ContentType ct = rootCodec.getStaticContentType(packet);
        String ctStr = (ct != null) ? ct.getContentType() : rootCodec.getMimeType();
        if (rootId != null) writeln("Content-ID: " + rootId, out);
        writeln("Content-Type: " + ctStr, out);
        writeln(out);
    }
    ContentType primaryCt = rootCodec.encode(packet, out);

    if (hasAttachments) {
        writeln(out);
        // Encode all the attchments
        for (Attachment att : msg.getAttachments()) {
            writeln("--"+boundary, out);
            //SAAJ's AttachmentPart.getContentId() returns content id already enclosed with
            //angle brackets. For now put angle bracket only if its not there
            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);
            writeln(out);                    // write \r\n
            att.writeTo(out);
            writeln(out);                    // write \r\n
        }
        writeAsAscii("--"+boundary, out);
        writeAsAscii("--", out);
    }
    // TODO not returing correct multipart/related type(no boundary)
    return hasAttachments ? ctImpl : primaryCt;
}
 
Example 14
Source File: MimeCodec.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) throws IOException {
    Message msg = packet.getMessage();
    if (msg == null) {
        return null;
    }
    ContentTypeImpl ctImpl = (ContentTypeImpl)getStaticContentType(packet);
    String boundary = ctImpl.getBoundary();
    boolean hasAttachments = (boundary != null);
    Codec rootCodec = getMimeRootCodec(packet);
    if (hasAttachments) {
        writeln("--"+boundary, out);
        ContentType ct = rootCodec.getStaticContentType(packet);
        String ctStr = (ct != null) ? ct.getContentType() : rootCodec.getMimeType();
        writeln("Content-Type: " + ctStr, out);
        writeln(out);
    }
    ContentType primaryCt = rootCodec.encode(packet, out);

    if (hasAttachments) {
        writeln(out);
        // Encode all the attchments
        for (Attachment att : msg.getAttachments()) {
            writeln("--"+boundary, out);
            //SAAJ's AttachmentPart.getContentId() returns content id already enclosed with
            //angle brackets. For now put angle bracket only if its not there
            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);
            writeln(out);                    // write \r\n
            att.writeTo(out);
            writeln(out);                    // write \r\n
        }
        writeAsAscii("--"+boundary, out);
        writeAsAscii("--", out);
    }
    // TODO not returing correct multipart/related type(no boundary)
    return hasAttachments ? ctImpl : primaryCt;
}
 
Example 15
Source File: MimeCodec.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) throws IOException {
    Message msg = packet.getMessage();
    if (msg == null) {
        return null;
    }
    ContentTypeImpl ctImpl = (ContentTypeImpl)getStaticContentType(packet);
    String boundary = ctImpl.getBoundary();
    boolean hasAttachments = (boundary != null);
    Codec rootCodec = getMimeRootCodec(packet);
    if (hasAttachments) {
        writeln("--"+boundary, out);
        ContentType ct = rootCodec.getStaticContentType(packet);
        String ctStr = (ct != null) ? ct.getContentType() : rootCodec.getMimeType();
        writeln("Content-Type: " + ctStr, out);
        writeln(out);
    }
    ContentType primaryCt = rootCodec.encode(packet, out);

    if (hasAttachments) {
        writeln(out);
        // Encode all the attchments
        for (Attachment att : msg.getAttachments()) {
            writeln("--"+boundary, out);
            //SAAJ's AttachmentPart.getContentId() returns content id already enclosed with
            //angle brackets. For now put angle bracket only if its not there
            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);
            writeln(out);                    // write \r\n
            att.writeTo(out);
            writeln(out);                    // write \r\n
        }
        writeAsAscii("--"+boundary, out);
        writeAsAscii("--", out);
    }
    // TODO not returing correct multipart/related type(no boundary)
    return hasAttachments ? ctImpl : primaryCt;
}
 
Example 16
Source File: MimeCodec.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) throws IOException {
    Message msg = packet.getMessage();
    if (msg == null) {
        return null;
    }
    ContentTypeImpl ctImpl = (ContentTypeImpl)getStaticContentType(packet);
    String boundary = ctImpl.getBoundary();
    boolean hasAttachments = (boundary != null);
    Codec rootCodec = getMimeRootCodec(packet);
    if (hasAttachments) {
        writeln("--"+boundary, out);
        ContentType ct = rootCodec.getStaticContentType(packet);
        String ctStr = (ct != null) ? ct.getContentType() : rootCodec.getMimeType();
        writeln("Content-Type: " + ctStr, out);
        writeln(out);
    }
    ContentType primaryCt = rootCodec.encode(packet, out);

    if (hasAttachments) {
        writeln(out);
        // Encode all the attchments
        for (Attachment att : msg.getAttachments()) {
            writeln("--"+boundary, out);
            //SAAJ's AttachmentPart.getContentId() returns content id already enclosed with
            //angle brackets. For now put angle bracket only if its not there
            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);
            writeln(out);                    // write \r\n
            att.writeTo(out);
            writeln(out);                    // write \r\n
        }
        writeAsAscii("--"+boundary, out);
        writeAsAscii("--", out);
    }
    // TODO not returing correct multipart/related type(no boundary)
    return hasAttachments ? ctImpl : primaryCt;
}