com.sun.xml.internal.ws.api.pipe.ContentType Java Examples

The following examples show how to use com.sun.xml.internal.ws.api.pipe.ContentType. 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: MimeCodec.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public ContentType getStaticContentType(Packet packet) {
    ContentType ct = (ContentType) packet.getInternalContentType();
    if ( ct != null ) return ct;
    Message msg = packet.getMessage();
    boolean hasAttachments = !msg.getAttachments().isEmpty();
    Codec rootCodec = getMimeRootCodec(packet);

    if (hasAttachments) {
        String boundary = "uuid:" + UUID.randomUUID().toString();
        String boundaryParameter = "boundary=\"" + boundary + "\"";
        // TODO use primaryEncoder to get type
        String messageContentType =  MULTIPART_RELATED_MIME_TYPE +
                "; type=\"" + rootCodec.getMimeType() + "\"; " +
                boundaryParameter;
        ContentTypeImpl impl = new ContentTypeImpl(messageContentType, packet.soapAction, null);
        impl.setBoundary(boundary);
        impl.setBoundaryParameter(boundaryParameter);
        packet.setContentType(impl);
        return impl;
    } else {
        ct = rootCodec.getStaticContentType(packet);
        packet.setContentType(ct);
        return ct;
    }
}
 
Example #2
Source File: StreamSOAPCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void decode(InputStream in, String contentType, Packet packet, AttachmentSet att ) throws IOException {
    List<String> expectedContentTypes = getExpectedContentTypes();
    if (contentType != null && !isContentTypeSupported(contentType,expectedContentTypes)) {
        throw new UnsupportedMediaException(contentType, expectedContentTypes);
    }
    com.oracle.webservices.internal.api.message.ContentType pct = packet.getInternalContentType();
    ContentTypeImpl cti = (pct != null && pct instanceof ContentTypeImpl) ?
            (ContentTypeImpl)pct : new ContentTypeImpl(contentType);
    String charset = cti.getCharSet();
    if (charset != null && !Charset.isSupported(charset)) {
        throw new UnsupportedMediaException(charset);
    }
    if (charset != null) {
        packet.invocationProperties.put(DECODED_MESSAGE_CHARSET, charset);
    } else {
        packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);
    }
    packet.setMessage(streamDecoder.decode(in, charset, att, soapVersion));
}
 
Example #3
Source File: XMLHTTPBindingCodec.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private ContentType encode(MessageDataSource mds, OutputStream out) {
    try {
        final boolean isFastInfoset = XMLMessage.isFastInfoset(
                mds.getDataSource().getContentType());
        DataSource ds = transformDataSource(mds.getDataSource(),
                isFastInfoset, useFastInfosetForEncoding, features);

        InputStream is = ds.getInputStream();
        byte[] buf = new byte[1024];
        int count;
        while((count=is.read(buf)) != -1) {
            out.write(buf, 0, count);
        }
        return new ContentTypeImpl(ds.getContentType());
    } catch(IOException ioe) {
        throw new WebServiceException(ioe);
    }
}
 
Example #4
Source File: XMLHTTPBindingCodec.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ContentType getStaticContentType(Packet packet) {
    ContentType ct;
    if (packet.getInternalMessage() instanceof MessageDataSource) {
        final MessageDataSource mds = (MessageDataSource)packet.getInternalMessage();
        if (mds.hasUnconsumedDataSource()) {
            ct = getStaticContentType(mds);
            return (ct != null)
                ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
                : null;
        }
    }

    ct = super.getStaticContentType(packet);
    return (ct != null)
        ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
        : null;
}
 
Example #5
Source File: MtomCodec.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static ContentType getStaticContentTypeStatic(Packet packet, SOAPVersion version) {
    ContentType ct = (ContentType) packet.getInternalContentType();
    if ( ct != null ) return ct;

    String uuid = UUID.randomUUID().toString();
    String boundary = "uuid:" + uuid;
    String rootId = "<rootpart*"+uuid+"@example.jaxws.sun.com>";
    String soapActionParameter = SOAPVersion.SOAP_11.equals(version) ?  null : createActionParameter(packet);

    String boundaryParameter = "boundary=\"" + boundary +"\"";
    String messageContentType = MULTIPART_RELATED_MIME_TYPE +
            ";start=\""+rootId +"\"" +
            ";type=\"" + XOP_XML_MIME_TYPE + "\";" +
            boundaryParameter +
            ";start-info=\"" + version.contentType +
            (soapActionParameter == null? "" : soapActionParameter) +
            "\"";

    ContentTypeImpl ctImpl = SOAPVersion.SOAP_11.equals(version) ?
            new ContentTypeImpl(messageContentType, (packet.soapAction == null)?"":packet.soapAction, null) :
            new ContentTypeImpl(messageContentType, null, null);
    ctImpl.setBoundary(boundary);
    ctImpl.setRootId(rootId);
    packet.setContentType(ctImpl);
    return ctImpl;
}
 
Example #6
Source File: XMLCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
            String encoding = (String) packet.invocationProperties
            .get(XMLConstants.OUTPUT_XML_CHARACTER_ENCODING);

    XMLStreamWriter writer = null;

            if (encoding != null && encoding.length() > 0) {
        writer = XMLStreamWriterFactory.create(out, encoding);
    } else {
        writer = XMLStreamWriterFactory.create(out);
    }

    try {
        if (packet.getMessage().hasPayload()){
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.flush();
        }
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
 
Example #7
Source File: MtomCodec.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static ContentType getStaticContentTypeStatic(Packet packet, SOAPVersion version) {
    ContentType ct = (ContentType) packet.getInternalContentType();
    if ( ct != null ) return ct;

    String uuid = UUID.randomUUID().toString();
    String boundary = "uuid:" + uuid;
    String rootId = "<rootpart*"+uuid+"@example.jaxws.sun.com>";
    String soapActionParameter = SOAPVersion.SOAP_11.equals(version) ?  null : createActionParameter(packet);

    String boundaryParameter = "boundary=\"" + boundary +"\"";
    String messageContentType = MULTIPART_RELATED_MIME_TYPE +
            ";start=\""+rootId +"\"" +
            ";type=\"" + XOP_XML_MIME_TYPE + "\";" +
            boundaryParameter +
            ";start-info=\"" + version.contentType +
            (soapActionParameter == null? "" : soapActionParameter) +
            "\"";

    ContentTypeImpl ctImpl = SOAPVersion.SOAP_11.equals(version) ?
            new ContentTypeImpl(messageContentType, (packet.soapAction == null)?"":packet.soapAction, null) :
            new ContentTypeImpl(messageContentType, null, null);
    ctImpl.setBoundary(boundary);
    ctImpl.setRootId(rootId);
    packet.setContentType(ctImpl);
    return ctImpl;
}
 
Example #8
Source File: XMLHTTPBindingCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ContentType getStaticContentType(Packet packet) {
    ContentType ct;
    if (packet.getInternalMessage() instanceof MessageDataSource) {
        final MessageDataSource mds = (MessageDataSource)packet.getInternalMessage();
        if (mds.hasUnconsumedDataSource()) {
            ct = getStaticContentType(mds);
            return (ct != null)
                ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
                : null;
        }
    }

    ct = super.getStaticContentType(packet);
    return (ct != null)
        ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
        : null;
}
 
Example #9
Source File: FastInfosetCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    Message message = packet.getMessage();
    if (message != null && message.hasPayload()) {
        final XMLStreamWriter writer = getXMLStreamWriter(out);
        try {
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.writeEndDocument();
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
    }

    return _contentType;
}
 
Example #10
Source File: XMLCodec.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
            String encoding = (String) packet.invocationProperties
            .get(XMLConstants.OUTPUT_XML_CHARACTER_ENCODING);

    XMLStreamWriter writer = null;

            if (encoding != null && encoding.length() > 0) {
        writer = XMLStreamWriterFactory.create(out, encoding);
    } else {
        writer = XMLStreamWriterFactory.create(out);
    }

    try {
        if (packet.getMessage().hasPayload()){
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.flush();
        }
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
 
Example #11
Source File: MtomCodec.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static ContentType getStaticContentTypeStatic(Packet packet, SOAPVersion version) {
    ContentType ct = (ContentType) packet.getInternalContentType();
    if ( ct != null ) return ct;

    String uuid = UUID.randomUUID().toString();
    String boundary = "uuid:" + uuid;
    String rootId = "<rootpart*"+uuid+"@example.jaxws.sun.com>";
    String soapActionParameter = SOAPVersion.SOAP_11.equals(version) ?  null : createActionParameter(packet);

    String boundaryParameter = "boundary=\"" + boundary +"\"";
    String messageContentType = MULTIPART_RELATED_MIME_TYPE +
            ";start=\""+rootId +"\"" +
            ";type=\"" + XOP_XML_MIME_TYPE + "\";" +
            boundaryParameter +
            ";start-info=\"" + version.contentType +
            (soapActionParameter == null? "" : soapActionParameter) +
            "\"";

    ContentTypeImpl ctImpl = SOAPVersion.SOAP_11.equals(version) ?
            new ContentTypeImpl(messageContentType, (packet.soapAction == null)?"":packet.soapAction, null) :
            new ContentTypeImpl(messageContentType, null, null);
    ctImpl.setBoundary(boundary);
    ctImpl.setRootId(rootId);
    packet.setContentType(ctImpl);
    return ctImpl;
}
 
Example #12
Source File: XMLHTTPBindingCodec.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ContentType getStaticContentType(Packet packet) {
    ContentType ct;
    if (packet.getInternalMessage() instanceof MessageDataSource) {
        final MessageDataSource mds = (MessageDataSource)packet.getInternalMessage();
        if (mds.hasUnconsumedDataSource()) {
            ct = getStaticContentType(mds);
            return (ct != null)
                ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
                : null;
        }
    }

    ct = super.getStaticContentType(packet);
    return (ct != null)
        ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
        : null;
}
 
Example #13
Source File: XMLHTTPBindingCodec.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ContentType getStaticContentType(Packet packet) {
    ContentType ct;
    if (packet.getInternalMessage() instanceof MessageDataSource) {
        final MessageDataSource mds = (MessageDataSource)packet.getInternalMessage();
        if (mds.hasUnconsumedDataSource()) {
            ct = getStaticContentType(mds);
            return (ct != null)
                ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
                : null;
        }
    }

    ct = super.getStaticContentType(packet);
    return (ct != null)
        ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
        : null;
}
 
Example #14
Source File: MtomCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static ContentType getStaticContentTypeStatic(Packet packet, SOAPVersion version) {
    ContentType ct = (ContentType) packet.getInternalContentType();
    if ( ct != null ) return ct;

    String uuid = UUID.randomUUID().toString();
    String boundary = "uuid:" + uuid;
    String rootId = "<rootpart*"+uuid+"@example.jaxws.sun.com>";
    String soapActionParameter = SOAPVersion.SOAP_11.equals(version) ?  null : createActionParameter(packet);

    String boundaryParameter = "boundary=\"" + boundary +"\"";
    String messageContentType = MULTIPART_RELATED_MIME_TYPE +
            ";start=\""+rootId +"\"" +
            ";type=\"" + XOP_XML_MIME_TYPE + "\";" +
            boundaryParameter +
            ";start-info=\"" + version.contentType +
            (soapActionParameter == null? "" : soapActionParameter) +
            "\"";

    ContentTypeImpl ctImpl = SOAPVersion.SOAP_11.equals(version) ?
            new ContentTypeImpl(messageContentType, (packet.soapAction == null)?"":packet.soapAction, null) :
            new ContentTypeImpl(messageContentType, null, null);
    ctImpl.setBoundary(boundary);
    ctImpl.setRootId(rootId);
    packet.setContentType(ctImpl);
    return ctImpl;
}
 
Example #15
Source File: FastInfosetCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    Message message = packet.getMessage();
    if (message != null && message.hasPayload()) {
        final XMLStreamWriter writer = getXMLStreamWriter(out);
        try {
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.writeEndDocument();
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
    }

    return _contentType;
}
 
Example #16
Source File: FastInfosetStreamSOAPCodec.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        final XMLStreamWriter writer = getXMLStreamWriter(out);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
    }
    return getContentType(packet.soapAction);
}
 
Example #17
Source File: XMLHTTPBindingCodec.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private ContentTypeImpl setAcceptHeader(Packet p, ContentType c) {
    ContentTypeImpl ctImpl = (ContentTypeImpl)c;
    if (p.contentNegotiation == ContentNegotiation.optimistic
            || p.contentNegotiation == ContentNegotiation.pessimistic) {
        ctImpl.setAcceptHeader(fiXmlAccept);
    } else {
        ctImpl.setAcceptHeader(xmlAccept);
    }
    p.setContentType(ctImpl);
    return ctImpl;
}
 
Example #18
Source File: XMLHTTPBindingCodec.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private ContentType getStaticContentType(MessageDataSource mds) {
    final String contentType = mds.getDataSource().getContentType();
    final boolean isFastInfoset = XMLMessage.isFastInfoset(contentType);

    if (!requiresTransformationOfDataSource(isFastInfoset,
            useFastInfosetForEncoding)) {
        return new ContentTypeImpl(contentType);
    } else {
        return null;
    }
}
 
Example #19
Source File: FastInfosetStreamSOAP11Codec.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected ContentType getContentType(String soapAction) {
    if (soapAction == null || soapAction.length() == 0) {
        return _defaultContentType;
    } else {
        return new ContentTypeImpl(_defaultContentType.getContentType(), soapAction);
    }
}
 
Example #20
Source File: FastInfosetStreamSOAP12Codec.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected ContentType getContentType(String soapAction) {
    if (soapAction == null) {
        return _defaultContentType;
    } else {
        return new ContentTypeImpl(
                _defaultContentType.getContentType() + ";action=\""+soapAction+"\"");
    }
}
 
Example #21
Source File: FastInfosetStreamSOAP11Codec.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected ContentType getContentType(String soapAction) {
    if (soapAction == null || soapAction.length() == 0) {
        return _defaultContentType;
    } else {
        return new ContentTypeImpl(_defaultContentType.getContentType(), soapAction);
    }
}
 
Example #22
Source File: FastInfosetStreamSOAPCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        final XMLStreamWriter writer = getXMLStreamWriter(out);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
    }
    return getContentType(packet.soapAction);
}
 
Example #23
Source File: FastInfosetStreamSOAPCodec.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        final XMLStreamWriter writer = getXMLStreamWriter(out);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
    }
    return getContentType(packet.soapAction);
}
 
Example #24
Source File: StreamSOAPCodec.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        String encoding = getPacketEncoding(packet);
        packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);
        XMLStreamWriter writer = XMLStreamWriterFactory.create(out, encoding);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
        XMLStreamWriterFactory.recycle(writer);
    }
    return getContentType(packet);
}
 
Example #25
Source File: XMLHTTPBindingCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ContentType encode(Packet packet, OutputStream out) throws IOException {
    if (packet.getInternalMessage() instanceof MessageDataSource) {
        final MessageDataSource mds = (MessageDataSource)packet.getInternalMessage();
        if (mds.hasUnconsumedDataSource())
            return setAcceptHeader(packet, encode(mds, out));
    }

    return setAcceptHeader(packet, super.encode(packet, out));
}
 
Example #26
Source File: SOAPBindingCodec.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, WritableByteChannel buffer) {
    preEncode(packet);
    ContentType ct = getEncoder(packet).encode(packet, buffer);
    ct = setAcceptHeader(packet, (ContentTypeImpl)ct);
    postEncode();
    return ct;
}
 
Example #27
Source File: SOAPBindingCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, WritableByteChannel buffer) {
    preEncode(packet);
    ContentType ct = getEncoder(packet).encode(packet, buffer);
    ct = setAcceptHeader(packet, (ContentTypeImpl)ct);
    postEncode();
    return ct;
}
 
Example #28
Source File: XMLHTTPBindingCodec.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private ContentType getStaticContentType(MessageDataSource mds) {
    final String contentType = mds.getDataSource().getContentType();
    final boolean isFastInfoset = XMLMessage.isFastInfoset(contentType);

    if (!requiresTransformationOfDataSource(isFastInfoset,
            useFastInfosetForEncoding)) {
        return new ContentTypeImpl(contentType);
    } else {
        return null;
    }
}
 
Example #29
Source File: SOAPBindingCodec.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) throws IOException {
   preEncode(packet);
   ContentType ct = getEncoder(packet).encode(packet, out);
   ct = setAcceptHeader(packet, (ContentTypeImpl)ct);
   postEncode();
   return ct;
}
 
Example #30
Source File: StreamSOAP12Codec.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected ContentType getContentType(Packet packet) {
    ContentTypeImpl.Builder b = getContenTypeBuilder(packet);
    // TODO: set accept header
    if (packet.soapAction == null) {
        return b.build();
    } else {
        b.contentType = b.contentType + ";action="+fixQuotesAroundSoapAction(packet.soapAction);
        return b.build();
    }
}