Java Code Examples for com.sun.xml.internal.ws.util.ByteArrayBuffer#write()

The following examples show how to use com.sun.xml.internal.ws.util.ByteArrayBuffer#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: MimeMultipartParser.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] asByteArray() {
    if (buf == null) {
        ByteArrayBuffer baf = new ByteArrayBuffer();
        try {
            baf.write(part.readOnce());
        } catch(IOException ioe) {
            throw new WebServiceException(ioe);
        } finally {
            if (baf != null) {
                try {
                    baf.close();
                } catch (IOException ex) {
                    Logger.getLogger(MimeMultipartParser.class.getName()).log(Level.FINE, null, ex);
                }
            }
        }
        buf = baf.toByteArray();
    }
    return buf;
}
 
Example 2
Source File: MimeMultipartParser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] asByteArray() {
    if (buf == null) {
        ByteArrayBuffer baf = new ByteArrayBuffer();
        try {
            baf.write(part.readOnce());
        } catch(IOException ioe) {
            throw new WebServiceException(ioe);
        } finally {
            if (baf != null) {
                try {
                    baf.close();
                } catch (IOException ex) {
                    Logger.getLogger(MimeMultipartParser.class.getName()).log(Level.FINE, null, ex);
                }
            }
        }
        buf = baf.toByteArray();
    }
    return buf;
}
 
Example 3
Source File: HttpAdapter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private Packet decodePacket(@NotNull WSHTTPConnection con, @NotNull Codec codec) throws IOException {
    String ct = con.getRequestHeader("Content-Type");
    InputStream in = con.getInput();
    Packet packet = new Packet();
    packet.soapAction = fixQuotesAroundSoapAction(con.getRequestHeader("SOAPAction"));
    packet.wasTransportSecure = con.isSecure();
    packet.acceptableMimeTypes = con.getRequestHeader("Accept");
    packet.addSatellite(con);
    addSatellites(packet);
    packet.isAdapterDeliversNonAnonymousResponse = true;
    packet.component = this;
    packet.transportBackChannel = new Oneway(con);
    packet.webServiceContextDelegate = con.getWebServiceContextDelegate();
    packet.setState(Packet.State.ServerRequest);
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        buf.write(in);
        in.close();
        dump(buf, "HTTP request", con.getRequestHeaders());
        in = buf.newInputStream();
    }
    codec.decode(in, ct, packet);
    return packet;
}
 
Example 4
Source File: MimeMultipartParser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] asByteArray() {
    if (buf == null) {
        ByteArrayBuffer baf = new ByteArrayBuffer();
        try {
            baf.write(part.readOnce());
        } catch(IOException ioe) {
            throw new WebServiceException(ioe);
        } finally {
            if (baf != null) {
                try {
                    baf.close();
                } catch (IOException ex) {
                    Logger.getLogger(MimeMultipartParser.class.getName()).log(Level.FINE, null, ex);
                }
            }
        }
        buf = baf.toByteArray();
    }
    return buf;
}
 
Example 5
Source File: HttpAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private Packet decodePacket(@NotNull WSHTTPConnection con, @NotNull Codec codec) throws IOException {
    String ct = con.getRequestHeader("Content-Type");
    InputStream in = con.getInput();
    Packet packet = new Packet();
    packet.soapAction = fixQuotesAroundSoapAction(con.getRequestHeader("SOAPAction"));
    packet.wasTransportSecure = con.isSecure();
    packet.acceptableMimeTypes = con.getRequestHeader("Accept");
    packet.addSatellite(con);
    addSatellites(packet);
    packet.isAdapterDeliversNonAnonymousResponse = true;
    packet.component = this;
    packet.transportBackChannel = new Oneway(con);
    packet.webServiceContextDelegate = con.getWebServiceContextDelegate();
    packet.setState(Packet.State.ServerRequest);
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        buf.write(in);
        in.close();
        dump(buf, "HTTP request", con.getRequestHeaders());
        in = buf.newInputStream();
    }
    codec.decode(in, ct, packet);
    return packet;
}
 
Example 6
Source File: HttpAdapter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private Packet decodePacket(@NotNull WSHTTPConnection con, @NotNull Codec codec) throws IOException {
    String ct = con.getRequestHeader("Content-Type");
    InputStream in = con.getInput();
    Packet packet = new Packet();
    packet.soapAction = fixQuotesAroundSoapAction(con.getRequestHeader("SOAPAction"));
    packet.wasTransportSecure = con.isSecure();
    packet.acceptableMimeTypes = con.getRequestHeader("Accept");
    packet.addSatellite(con);
    addSatellites(packet);
    packet.isAdapterDeliversNonAnonymousResponse = true;
    packet.component = this;
    packet.transportBackChannel = new Oneway(con);
    packet.webServiceContextDelegate = con.getWebServiceContextDelegate();
    packet.setState(Packet.State.ServerRequest);
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        buf.write(in);
        in.close();
        dump(buf, "HTTP request", con.getRequestHeaders());
        in = buf.newInputStream();
    }
    codec.decode(in, ct, packet);
    return packet;
}
 
Example 7
Source File: MimeMultipartParser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] asByteArray() {
    if (buf == null) {
        ByteArrayBuffer baf = new ByteArrayBuffer();
        try {
            baf.write(part.readOnce());
        } catch(IOException ioe) {
            throw new WebServiceException(ioe);
        } finally {
            if (baf != null) {
                try {
                    baf.close();
                } catch (IOException ex) {
                    Logger.getLogger(MimeMultipartParser.class.getName()).log(Level.FINE, null, ex);
                }
            }
        }
        buf = baf.toByteArray();
    }
    return buf;
}
 
Example 8
Source File: HttpAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private Packet decodePacket(@NotNull WSHTTPConnection con, @NotNull Codec codec) throws IOException {
    String ct = con.getRequestHeader("Content-Type");
    InputStream in = con.getInput();
    Packet packet = new Packet();
    packet.soapAction = fixQuotesAroundSoapAction(con.getRequestHeader("SOAPAction"));
    packet.wasTransportSecure = con.isSecure();
    packet.acceptableMimeTypes = con.getRequestHeader("Accept");
    packet.addSatellite(con);
    addSatellites(packet);
    packet.isAdapterDeliversNonAnonymousResponse = true;
    packet.component = this;
    packet.transportBackChannel = new Oneway(con);
    packet.webServiceContextDelegate = con.getWebServiceContextDelegate();
    packet.setState(Packet.State.ServerRequest);
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        buf.write(in);
        in.close();
        dump(buf, "HTTP request", con.getRequestHeaders());
        in = buf.newInputStream();
    }
    codec.decode(in, ct, packet);
    return packet;
}
 
Example 9
Source File: HttpAdapter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private Packet decodePacket(@NotNull WSHTTPConnection con, @NotNull Codec codec) throws IOException {
    String ct = con.getRequestHeader("Content-Type");
    InputStream in = con.getInput();
    Packet packet = new Packet();
    packet.soapAction = fixQuotesAroundSoapAction(con.getRequestHeader("SOAPAction"));
    packet.wasTransportSecure = con.isSecure();
    packet.acceptableMimeTypes = con.getRequestHeader("Accept");
    packet.addSatellite(con);
    addSatellites(packet);
    packet.isAdapterDeliversNonAnonymousResponse = true;
    packet.component = this;
    packet.transportBackChannel = new Oneway(con);
    packet.webServiceContextDelegate = con.getWebServiceContextDelegate();
    packet.setState(Packet.State.ServerRequest);
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        buf.write(in);
        in.close();
        dump(buf, "HTTP request", con.getRequestHeaders());
        in = buf.newInputStream();
    }
    codec.decode(in, ct, packet);
    return packet;
}
 
Example 10
Source File: MimeMultipartParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] asByteArray() {
    if (buf == null) {
        ByteArrayBuffer baf = new ByteArrayBuffer();
        try {
            baf.write(part.readOnce());
        } catch(IOException ioe) {
            throw new WebServiceException(ioe);
        } finally {
            if (baf != null) {
                try {
                    baf.close();
                } catch (IOException ex) {
                    Logger.getLogger(MimeMultipartParser.class.getName()).log(Level.FINE, null, ex);
                }
            }
        }
        buf = baf.toByteArray();
    }
    return buf;
}
 
Example 11
Source File: MimeMultipartParser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] asByteArray() {
    if (buf == null) {
        ByteArrayBuffer baf = new ByteArrayBuffer();
        try {
            baf.write(part.readOnce());
        } catch(IOException ioe) {
            throw new WebServiceException(ioe);
        } finally {
            if (baf != null) {
                try {
                    baf.close();
                } catch (IOException ex) {
                    Logger.getLogger(MimeMultipartParser.class.getName()).log(Level.FINE, null, ex);
                }
            }
        }
        buf = baf.toByteArray();
    }
    return buf;
}
 
Example 12
Source File: MimeMultipartParser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] asByteArray() {
    if (buf == null) {
        ByteArrayBuffer baf = new ByteArrayBuffer();
        try {
            baf.write(part.readOnce());
        } catch(IOException ioe) {
            throw new WebServiceException(ioe);
        } finally {
            if (baf != null) {
                try {
                    baf.close();
                } catch (IOException ex) {
                    Logger.getLogger(MimeMultipartParser.class.getName()).log(Level.FINE, null, ex);
                }
            }
        }
        buf = baf.toByteArray();
    }
    return buf;
}
 
Example 13
Source File: HttpAdapter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private Packet decodePacket(@NotNull WSHTTPConnection con, @NotNull Codec codec) throws IOException {
    String ct = con.getRequestHeader("Content-Type");
    InputStream in = con.getInput();
    Packet packet = new Packet();
    packet.soapAction = fixQuotesAroundSoapAction(con.getRequestHeader("SOAPAction"));
    packet.wasTransportSecure = con.isSecure();
    packet.acceptableMimeTypes = con.getRequestHeader("Accept");
    packet.addSatellite(con);
    addSatellites(packet);
    packet.isAdapterDeliversNonAnonymousResponse = true;
    packet.component = this;
    packet.transportBackChannel = new Oneway(con);
    packet.webServiceContextDelegate = con.getWebServiceContextDelegate();
    packet.setState(Packet.State.ServerRequest);
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        buf.write(in);
        in.close();
        dump(buf, "HTTP request", con.getRequestHeaders());
        in = buf.newInputStream();
    }
    codec.decode(in, ct, packet);
    return packet;
}
 
Example 14
Source File: MimeMultipartParser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] asByteArray() {
    if (buf == null) {
        ByteArrayBuffer baf = new ByteArrayBuffer();
        try {
            baf.write(part.readOnce());
        } catch(IOException ioe) {
            throw new WebServiceException(ioe);
        } finally {
            if (baf != null) {
                try {
                    baf.close();
                } catch (IOException ex) {
                    Logger.getLogger(MimeMultipartParser.class.getName()).log(Level.FINE, null, ex);
                }
            }
        }
        buf = baf.toByteArray();
    }
    return buf;
}
 
Example 15
Source File: HttpTransportPipe.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
    con.readResponseCodeAndMessage();   // throws IOE
    recordCookies(request, con);

    InputStream responseStream = con.getInput();
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        if (responseStream != null) {
            buf.write(responseStream);
            responseStream.close();
        }
        dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
        responseStream = buf.newInputStream();
    }

    // Check if stream contains any data
    int cl = con.contentLength;
    InputStream tempIn = null;
    if (cl == -1) {                     // No Content-Length header
        tempIn = StreamUtils.hasSomeData(responseStream);
        if (tempIn != null) {
            responseStream = tempIn;
        }
    }
    if (cl == 0 || (cl == -1 && tempIn == null)) {
        if(responseStream != null) {
            responseStream.close();         // No data, so close the stream
            responseStream = null;
        }

    }

    // Allows only certain http status codes for a binding. For all
    // other status codes, throws exception
    checkStatusCode(responseStream, con); // throws ClientTransportException

    Packet reply = request.createClientResponse(null);
    reply.wasTransportSecure = con.isSecure();
    if (responseStream != null) {
        String contentType = con.getContentType();
        if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
            throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
        }
        codec.decode(responseStream, contentType, reply);
    }
    return reply;
}
 
Example 16
Source File: HttpTransportPipe.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
    con.readResponseCodeAndMessage();   // throws IOE
    recordCookies(request, con);

    InputStream responseStream = con.getInput();
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        if (responseStream != null) {
            buf.write(responseStream);
            responseStream.close();
        }
        dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
        responseStream = buf.newInputStream();
    }

    // Check if stream contains any data
    int cl = con.contentLength;
    InputStream tempIn = null;
    if (cl == -1) {                     // No Content-Length header
        tempIn = StreamUtils.hasSomeData(responseStream);
        if (tempIn != null) {
            responseStream = tempIn;
        }
    }
    if (cl == 0 || (cl == -1 && tempIn == null)) {
        if(responseStream != null) {
            responseStream.close();         // No data, so close the stream
            responseStream = null;
        }

    }

    // Allows only certain http status codes for a binding. For all
    // other status codes, throws exception
    checkStatusCode(responseStream, con); // throws ClientTransportException

    Packet reply = request.createClientResponse(null);
    reply.wasTransportSecure = con.isSecure();
    if (responseStream != null) {
        String contentType = con.getContentType();
        if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
            throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
        }
        codec.decode(responseStream, contentType, reply);
    }
    return reply;
}
 
Example 17
Source File: HttpTransportPipe.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
    con.readResponseCodeAndMessage();   // throws IOE
    recordCookies(request, con);

    InputStream responseStream = con.getInput();
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        if (responseStream != null) {
            buf.write(responseStream);
            responseStream.close();
        }
        dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
        responseStream = buf.newInputStream();
    }

    // Check if stream contains any data
    int cl = con.contentLength;
    InputStream tempIn = null;
    if (cl == -1) {                     // No Content-Length header
        tempIn = StreamUtils.hasSomeData(responseStream);
        if (tempIn != null) {
            responseStream = tempIn;
        }
    }
    if (cl == 0 || (cl == -1 && tempIn == null)) {
        if(responseStream != null) {
            responseStream.close();         // No data, so close the stream
            responseStream = null;
        }

    }

    // Allows only certain http status codes for a binding. For all
    // other status codes, throws exception
    checkStatusCode(responseStream, con); // throws ClientTransportException

    Packet reply = request.createClientResponse(null);
    reply.wasTransportSecure = con.isSecure();
    if (responseStream != null) {
        String contentType = con.getContentType();
        if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
            throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
        }
        codec.decode(responseStream, contentType, reply);
    }
    return reply;
}
 
Example 18
Source File: HttpTransportPipe.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
    con.readResponseCodeAndMessage();   // throws IOE
    recordCookies(request, con);

    InputStream responseStream = con.getInput();
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        if (responseStream != null) {
            buf.write(responseStream);
            responseStream.close();
        }
        dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
        responseStream = buf.newInputStream();
    }

    // Check if stream contains any data
    int cl = con.contentLength;
    InputStream tempIn = null;
    if (cl == -1) {                     // No Content-Length header
        tempIn = StreamUtils.hasSomeData(responseStream);
        if (tempIn != null) {
            responseStream = tempIn;
        }
    }
    if (cl == 0 || (cl == -1 && tempIn == null)) {
        if(responseStream != null) {
            responseStream.close();         // No data, so close the stream
            responseStream = null;
        }

    }

    // Allows only certain http status codes for a binding. For all
    // other status codes, throws exception
    checkStatusCode(responseStream, con); // throws ClientTransportException

    Packet reply = request.createClientResponse(null);
    reply.wasTransportSecure = con.isSecure();
    if (responseStream != null) {
        String contentType = con.getContentType();
        if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
            throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
        }
        codec.decode(responseStream, contentType, reply);
    }
    return reply;
}
 
Example 19
Source File: HttpTransportPipe.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
    con.readResponseCodeAndMessage();   // throws IOE
    recordCookies(request, con);

    InputStream responseStream = con.getInput();
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        if (responseStream != null) {
            buf.write(responseStream);
            responseStream.close();
        }
        dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
        responseStream = buf.newInputStream();
    }

    // Check if stream contains any data
    int cl = con.contentLength;
    InputStream tempIn = null;
    if (cl == -1) {                     // No Content-Length header
        tempIn = StreamUtils.hasSomeData(responseStream);
        if (tempIn != null) {
            responseStream = tempIn;
        }
    }
    if (cl == 0 || (cl == -1 && tempIn == null)) {
        if(responseStream != null) {
            responseStream.close();         // No data, so close the stream
            responseStream = null;
        }

    }

    // Allows only certain http status codes for a binding. For all
    // other status codes, throws exception
    checkStatusCode(responseStream, con); // throws ClientTransportException

    Packet reply = request.createClientResponse(null);
    reply.wasTransportSecure = con.isSecure();
    if (responseStream != null) {
        String contentType = con.getContentType();
        if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
            throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
        }
        codec.decode(responseStream, contentType, reply);
    }
    return reply;
}
 
Example 20
Source File: HttpTransportPipe.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
    con.readResponseCodeAndMessage();   // throws IOE
    recordCookies(request, con);

    InputStream responseStream = con.getInput();
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        if (responseStream != null) {
            buf.write(responseStream);
            responseStream.close();
        }
        dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
        responseStream = buf.newInputStream();
    }

    // Check if stream contains any data
    int cl = con.contentLength;
    InputStream tempIn = null;
    if (cl == -1) {                     // No Content-Length header
        tempIn = StreamUtils.hasSomeData(responseStream);
        if (tempIn != null) {
            responseStream = tempIn;
        }
    }
    if (cl == 0 || (cl == -1 && tempIn == null)) {
        if(responseStream != null) {
            responseStream.close();         // No data, so close the stream
            responseStream = null;
        }

    }

    // Allows only certain http status codes for a binding. For all
    // other status codes, throws exception
    checkStatusCode(responseStream, con); // throws ClientTransportException

    Packet reply = request.createClientResponse(null);
    reply.wasTransportSecure = con.isSecure();
    if (responseStream != null) {
        String contentType = con.getContentType();
        if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
            throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
        }
        codec.decode(responseStream, contentType, reply);
    }
    return reply;
}