Java Code Examples for com.sun.xml.internal.messaging.saaj.util.ByteOutputStream#write()

The following examples show how to use com.sun.xml.internal.messaging.saaj.util.ByteOutputStream#write() . 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: BMMimeMultipart.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(OutputStream os)
        throws IOException, MessagingException {

    // inputStream was not null
    if (in != null) {
        contentType.setParameter("boundary", this.boundary);
    }

    String bnd = "--" + contentType.getParameter("boundary");
    for (int i = 0; i < parts.size(); i++) {
        OutputUtil.writeln(bnd, os); // put out boundary
        ((MimeBodyPart)parts.get(i)).writeTo(os);
        OutputUtil.writeln(os); // put out empty line
    }

    if (in != null) {
        OutputUtil.writeln(bnd, os); // put out boundary
        if ((os instanceof ByteOutputStream) && lazyAttachments) {
            ((ByteOutputStream)os).write(in);
        } else {
            ByteOutputStream baos = new ByteOutputStream(in.available());
            baos.write(in);
            baos.writeTo(os);
            // reset the inputstream so that we can support a
            //getAttachment later
            in = baos.newInputStream();
        }

        // this will endup writing the end boundary
    } else {
    // put out last boundary
        OutputUtil.writeAsAscii(bnd, os);
        OutputUtil.writeAsAscii("--", os);
    }
}
 
Example 2
Source File: AttachmentPartImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void setRawContent(InputStream content, String contentType)
    throws SOAPException {
    if (mimePart != null) {
        mimePart.close();
        mimePart = null;
    }
    dataHandler = null;
    try {
        InternetHeaders hdrs = new InternetHeaders();
        hdrs.setHeader("Content-Type", contentType);
        //TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
        // Ctor with inputStream causes problems based on whether the InputStream has
        // markSupported()==true or false
        ByteOutputStream bos = new ByteOutputStream();
        bos.write(content);
        rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
        setMimeHeader("Content-Type", contentType);
    } catch (Exception e) {
        log.log(Level.SEVERE, "SAAJ0576.soap.attachment.setrawcontent.exception", e);
        throw new SOAPExceptionImpl(e.getLocalizedMessage());
    } finally {
        try {
            content.close();
        } catch (IOException ex) {
            throw new SOAPException(ex);
        }
    }
}
 
Example 3
Source File: BMMimeMultipart.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(OutputStream os)
        throws IOException, MessagingException {

    // inputStream was not null
    if (in != null) {
        contentType.setParameter("boundary", this.boundary);
    }

    String bnd = "--" + contentType.getParameter("boundary");
    for (int i = 0; i < parts.size(); i++) {
        OutputUtil.writeln(bnd, os); // put out boundary
        ((MimeBodyPart)parts.get(i)).writeTo(os);
        OutputUtil.writeln(os); // put out empty line
    }

    if (in != null) {
        OutputUtil.writeln(bnd, os); // put out boundary
        if ((os instanceof ByteOutputStream) && lazyAttachments) {
            ((ByteOutputStream)os).write(in);
        } else {
            ByteOutputStream baos = new ByteOutputStream(in.available());
            baos.write(in);
            baos.writeTo(os);
            // reset the inputstream so that we can support a
            //getAttachment later
            in = baos.newInputStream();
        }

        // this will endup writing the end boundary
    } else {
    // put out last boundary
        OutputUtil.writeAsAscii(bnd, os);
        OutputUtil.writeAsAscii("--", os);
    }
}
 
Example 4
Source File: AttachmentPartImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void setRawContent(InputStream content, String contentType)
    throws SOAPException {
    if (mimePart != null) {
        mimePart.close();
        mimePart = null;
    }
    dataHandler = null;
    try {
        InternetHeaders hdrs = new InternetHeaders();
        hdrs.setHeader("Content-Type", contentType);
        //TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
        // Ctor with inputStream causes problems based on whether the InputStream has
        // markSupported()==true or false
        ByteOutputStream bos = new ByteOutputStream();
        bos.write(content);
        rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
        setMimeHeader("Content-Type", contentType);
    } catch (Exception e) {
        log.log(Level.SEVERE, "SAAJ0576.soap.attachment.setrawcontent.exception", e);
        throw new SOAPExceptionImpl(e.getLocalizedMessage());
    } finally {
        try {
            content.close();
        } catch (IOException ex) {
            throw new SOAPException(ex);
        }
    }
}
 
Example 5
Source File: ASCIIUtility.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 * @deprecated
 *      this is an expensive operation that require an additional
 *      buffer reallocation just to get the array of an exact size.
 *      Unless you absolutely need the exact size array, don't use this.
 *      Use {@link ByteOutputStream} and {@link ByteOutputStream#write(InputStream)}.
 */
public static byte[] getBytes(InputStream is) throws IOException {
    ByteOutputStream bos = new ByteOutputStream();
    try {
        bos.write(is);
    } finally {
        is.close();
    }
    return bos.toByteArray();
}
 
Example 6
Source File: ASCIIUtility.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 * @deprecated
 *      this is an expensive operation that require an additional
 *      buffer reallocation just to get the array of an exact size.
 *      Unless you absolutely need the exact size array, don't use this.
 *      Use {@link ByteOutputStream} and {@link ByteOutputStream#write(InputStream)}.
 */
public static byte[] getBytes(InputStream is) throws IOException {
    ByteOutputStream bos = new ByteOutputStream();
    try {
        bos.write(is);
    } finally {
        is.close();
    }
    return bos.toByteArray();
}
 
Example 7
Source File: AttachmentPartImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public  void setBase64Content(InputStream content, String contentType)
    throws SOAPException {

    if (mimePart != null) {
        mimePart.close();
        mimePart = null;
    }
    dataHandler = null;
    InputStream decoded = null;
    try {
        decoded = MimeUtility.decode(content, "base64");
        InternetHeaders hdrs = new InternetHeaders();
        hdrs.setHeader("Content-Type", contentType);
        //TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
        // Ctor with inputStream causes problems based on the InputStream
        // has markSupported()==true
        ByteOutputStream bos = new ByteOutputStream();
        bos.write(decoded);
        rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
        setMimeHeader("Content-Type", contentType);
    } catch (Exception e) {
        log.log(Level.SEVERE, "SAAJ0578.soap.attachment.setbase64content.exception", e);
        throw new SOAPExceptionImpl(e.getLocalizedMessage());
    } finally {
        try {
            decoded.close();
        } catch (IOException ex) {
            throw new SOAPException(ex);
        }
    }
}
 
Example 8
Source File: AttachmentPartImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void setRawContent(InputStream content, String contentType)
    throws SOAPException {
    if (mimePart != null) {
        mimePart.close();
        mimePart = null;
    }
    dataHandler = null;
    try {
        InternetHeaders hdrs = new InternetHeaders();
        hdrs.setHeader("Content-Type", contentType);
        //TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
        // Ctor with inputStream causes problems based on whether the InputStream has
        // markSupported()==true or false
        ByteOutputStream bos = new ByteOutputStream();
        bos.write(content);
        rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
        setMimeHeader("Content-Type", contentType);
    } catch (Exception e) {
        log.log(Level.SEVERE, "SAAJ0576.soap.attachment.setrawcontent.exception", e);
        throw new SOAPExceptionImpl(e.getLocalizedMessage());
    } finally {
        try {
            content.close();
        } catch (IOException ex) {
            throw new SOAPException(ex);
        }
    }
}
 
Example 9
Source File: BMMimeMultipart.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(OutputStream os)
        throws IOException, MessagingException {

    // inputStream was not null
    if (in != null) {
        contentType.setParameter("boundary", this.boundary);
    }

    String bnd = "--" + contentType.getParameter("boundary");
    for (int i = 0; i < parts.size(); i++) {
        OutputUtil.writeln(bnd, os); // put out boundary
        ((MimeBodyPart)parts.get(i)).writeTo(os);
        OutputUtil.writeln(os); // put out empty line
    }

    if (in != null) {
        OutputUtil.writeln(bnd, os); // put out boundary
        if ((os instanceof ByteOutputStream) && lazyAttachments) {
            ((ByteOutputStream)os).write(in);
        } else {
            ByteOutputStream baos = new ByteOutputStream(in.available());
            baos.write(in);
            baos.writeTo(os);
            // reset the inputstream so that we can support a
            //getAttachment later
            in = baos.newInputStream();
        }

        // this will endup writing the end boundary
    } else {
    // put out last boundary
        OutputUtil.writeAsAscii(bnd, os);
        OutputUtil.writeAsAscii("--", os);
    }
}
 
Example 10
Source File: ASCIIUtility.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 * @deprecated
 *      this is an expensive operation that require an additional
 *      buffer reallocation just to get the array of an exact size.
 *      Unless you absolutely need the exact size array, don't use this.
 *      Use {@link ByteOutputStream} and {@link ByteOutputStream#write(InputStream)}.
 */
public static byte[] getBytes(InputStream is) throws IOException {
    ByteOutputStream bos = new ByteOutputStream();
    try {
        bos.write(is);
    } finally {
        is.close();
    }
    return bos.toByteArray();
}
 
Example 11
Source File: AttachmentPartImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public  void setBase64Content(InputStream content, String contentType)
    throws SOAPException {

    if (mimePart != null) {
        mimePart.close();
        mimePart = null;
    }
    dataHandler = null;
    InputStream decoded = null;
    try {
        decoded = MimeUtility.decode(content, "base64");
        InternetHeaders hdrs = new InternetHeaders();
        hdrs.setHeader("Content-Type", contentType);
        //TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
        // Ctor with inputStream causes problems based on the InputStream
        // has markSupported()==true
        ByteOutputStream bos = new ByteOutputStream();
        bos.write(decoded);
        rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
        setMimeHeader("Content-Type", contentType);
    } catch (Exception e) {
        log.log(Level.SEVERE, "SAAJ0578.soap.attachment.setbase64content.exception", e);
        throw new SOAPExceptionImpl(e.getLocalizedMessage());
    } finally {
        try {
                decoded.close();
        } catch (IOException ex) {
            throw new SOAPException(ex);
        }
    }
}
 
Example 12
Source File: AttachmentPartImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void setRawContent(InputStream content, String contentType)
    throws SOAPException {
    if (mimePart != null) {
        mimePart.close();
        mimePart = null;
    }
    dataHandler = null;
    try {
        InternetHeaders hdrs = new InternetHeaders();
        hdrs.setHeader("Content-Type", contentType);
        //TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
        // Ctor with inputStream causes problems based on whether the InputStream has
        // markSupported()==true or false
        ByteOutputStream bos = new ByteOutputStream();
        bos.write(content);
        rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
        setMimeHeader("Content-Type", contentType);
    } catch (Exception e) {
        log.log(Level.SEVERE, "SAAJ0576.soap.attachment.setrawcontent.exception", e);
        throw new SOAPExceptionImpl(e.getLocalizedMessage());
    } finally {
        try {
            content.close();
        } catch (IOException ex) {
            throw new SOAPException(ex);
        }
    }
}
 
Example 13
Source File: AttachmentPartImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public  void setBase64Content(InputStream content, String contentType)
    throws SOAPException {

    if (mimePart != null) {
        mimePart.close();
        mimePart = null;
    }
    dataHandler = null;
    InputStream decoded = null;
    try {
        decoded = MimeUtility.decode(content, "base64");
        InternetHeaders hdrs = new InternetHeaders();
        hdrs.setHeader("Content-Type", contentType);
        //TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
        // Ctor with inputStream causes problems based on the InputStream
        // has markSupported()==true
        ByteOutputStream bos = new ByteOutputStream();
        bos.write(decoded);
        rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
        setMimeHeader("Content-Type", contentType);
    } catch (Exception e) {
        log.log(Level.SEVERE, "SAAJ0578.soap.attachment.setbase64content.exception", e);
        throw new SOAPExceptionImpl(e.getLocalizedMessage());
    } finally {
        try {
                decoded.close();
        } catch (IOException ex) {
            throw new SOAPException(ex);
        }
    }
}
 
Example 14
Source File: ASCIIUtility.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 * @deprecated
 *      this is an expensive operation that require an additional
 *      buffer reallocation just to get the array of an exact size.
 *      Unless you absolutely need the exact size array, don't use this.
 *      Use {@link ByteOutputStream} and {@link ByteOutputStream#write(InputStream)}.
 */
public static byte[] getBytes(InputStream is) throws IOException {
    ByteOutputStream bos = new ByteOutputStream();
    try {
        bos.write(is);
    } finally {
        is.close();
    }
    return bos.toByteArray();
}
 
Example 15
Source File: BMMimeMultipart.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(OutputStream os)
        throws IOException, MessagingException {

    // inputStream was not null
    if (in != null) {
        contentType.setParameter("boundary", this.boundary);
    }

    String bnd = "--" + contentType.getParameter("boundary");
    for (int i = 0; i < parts.size(); i++) {
        OutputUtil.writeln(bnd, os); // put out boundary
        ((MimeBodyPart)parts.get(i)).writeTo(os);
        OutputUtil.writeln(os); // put out empty line
    }

    if (in != null) {
        OutputUtil.writeln(bnd, os); // put out boundary
        if ((os instanceof ByteOutputStream) && lazyAttachments) {
            ((ByteOutputStream)os).write(in);
        } else {
            ByteOutputStream baos = new ByteOutputStream(in.available());
            baos.write(in);
            baos.writeTo(os);
            // reset the inputstream so that we can support a
            //getAttachment later
            in = baos.newInputStream();
        }

        // this will endup writing the end boundary
    } else {
    // put out last boundary
        OutputUtil.writeAsAscii(bnd, os);
        OutputUtil.writeAsAscii("--", os);
    }
}
 
Example 16
Source File: AttachmentPartImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public  void setBase64Content(InputStream content, String contentType)
    throws SOAPException {

    if (mimePart != null) {
        mimePart.close();
        mimePart = null;
    }
    dataHandler = null;
    InputStream decoded = null;
    try {
        decoded = MimeUtility.decode(content, "base64");
        InternetHeaders hdrs = new InternetHeaders();
        hdrs.setHeader("Content-Type", contentType);
        //TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
        // Ctor with inputStream causes problems based on the InputStream
        // has markSupported()==true
        ByteOutputStream bos = new ByteOutputStream();
        bos.write(decoded);
        rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
        setMimeHeader("Content-Type", contentType);
    } catch (Exception e) {
        log.log(Level.SEVERE, "SAAJ0578.soap.attachment.setbase64content.exception", e);
        throw new SOAPExceptionImpl(e.getLocalizedMessage());
    } finally {
        try {
            decoded.close();
        } catch (IOException ex) {
            throw new SOAPException(ex);
        }
    }
}
 
Example 17
Source File: AttachmentPartImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public  void setBase64Content(InputStream content, String contentType)
    throws SOAPException {

    if (mimePart != null) {
        mimePart.close();
        mimePart = null;
    }
    dataHandler = null;
    InputStream decoded = null;
    try {
        decoded = MimeUtility.decode(content, "base64");
        InternetHeaders hdrs = new InternetHeaders();
        hdrs.setHeader("Content-Type", contentType);
        //TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
        // Ctor with inputStream causes problems based on the InputStream
        // has markSupported()==true
        ByteOutputStream bos = new ByteOutputStream();
        bos.write(decoded);
        rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
        setMimeHeader("Content-Type", contentType);
    } catch (Exception e) {
        log.log(Level.SEVERE, "SAAJ0578.soap.attachment.setbase64content.exception", e);
        throw new SOAPExceptionImpl(e.getLocalizedMessage());
    } finally {
        try {
                decoded.close();
        } catch (IOException ex) {
            throw new SOAPException(ex);
        }
    }
}
 
Example 18
Source File: ASCIIUtility.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 * @deprecated
 *      this is an expensive operation that require an additional
 *      buffer reallocation just to get the array of an exact size.
 *      Unless you absolutely need the exact size array, don't use this.
 *      Use {@link ByteOutputStream} and {@link ByteOutputStream#write(InputStream)}.
 */
public static byte[] getBytes(InputStream is) throws IOException {
    ByteOutputStream bos = new ByteOutputStream();
    try {
        bos.write(is);
    } finally {
        is.close();
    }
    return bos.toByteArray();
}
 
Example 19
Source File: AttachmentPartImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setRawContent(InputStream content, String contentType)
    throws SOAPException {
    if (mimePart != null) {
        mimePart.close();
        mimePart = null;
    }
    dataHandler = null;
    try {
        InternetHeaders hdrs = new InternetHeaders();
        hdrs.setHeader("Content-Type", contentType);
        //TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
        // Ctor with inputStream causes problems based on whether the InputStream has
        // markSupported()==true or false
        ByteOutputStream bos = new ByteOutputStream();
        bos.write(content);
        rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
        setMimeHeader("Content-Type", contentType);
    } catch (Exception e) {
        log.log(Level.SEVERE, "SAAJ0576.soap.attachment.setrawcontent.exception", e);
        throw new SOAPExceptionImpl(e.getLocalizedMessage());
    } finally {
        try {
            content.close();
        } catch (IOException ex) {
            throw new SOAPException(ex);
        }
    }
}
 
Example 20
Source File: AttachmentPartImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setRawContent(InputStream content, String contentType)
    throws SOAPException {
    if (mimePart != null) {
        mimePart.close();
        mimePart = null;
    }
    dataHandler = null;
    try {
        InternetHeaders hdrs = new InternetHeaders();
        hdrs.setHeader("Content-Type", contentType);
        //TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
        // Ctor with inputStream causes problems based on whether the InputStream has
        // markSupported()==true or false
        ByteOutputStream bos = new ByteOutputStream();
        bos.write(content);
        rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
        setMimeHeader("Content-Type", contentType);
    } catch (Exception e) {
        log.log(Level.SEVERE, "SAAJ0576.soap.attachment.setrawcontent.exception", e);
        throw new SOAPExceptionImpl(e.getLocalizedMessage());
    } finally {
        try {
            content.close();
        } catch (IOException ex) {
            throw new SOAPException(ex);
        }
    }
}