com.sun.xml.internal.ws.server.UnsupportedMediaException Java Examples

The following examples show how to use com.sun.xml.internal.ws.server.UnsupportedMediaException. 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: StreamSOAPCodec.java    From openjdk-jdk9 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 #2
Source File: SOAPBindingCodec.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void decode(ReadableByteChannel in, String contentType, Packet packet) {
    if (contentType == null) {
        throw new UnsupportedMediaException();
    }

    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #3
Source File: StreamSOAPCodec.java    From openjdk-8 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 #4
Source File: SOAPBindingCodec.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void decode(ReadableByteChannel in, String contentType, Packet packet) {
    if (contentType == null) {
        throw new UnsupportedMediaException();
    }

    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #5
Source File: StreamSOAPCodec.java    From openjdk-8-source 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 #6
Source File: SOAPBindingCodec.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void decode(ReadableByteChannel in, String contentType, Packet packet) {
    if (contentType == null) {
        throw new UnsupportedMediaException();
    }

    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #7
Source File: StreamSOAPCodec.java    From hottub 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 #8
Source File: SOAPBindingCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void decode(ReadableByteChannel in, String contentType, Packet packet) {
    if (contentType == null) {
        throw new UnsupportedMediaException();
    }

    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #9
Source File: StreamSOAPCodec.java    From TencentKona-8 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 #10
Source File: SOAPBindingCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void decode(ReadableByteChannel in, String contentType, Packet packet) {
    if (contentType == null) {
        throw new UnsupportedMediaException();
    }

    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #11
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 #12
Source File: StreamSOAPCodec.java    From openjdk-jdk8u 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 #13
Source File: SOAPBindingCodec.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void decode(ReadableByteChannel in, String contentType, Packet packet) {
    if (contentType == null) {
        throw new UnsupportedMediaException();
    }

    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #14
Source File: SOAPBindingCodec.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void decode(ReadableByteChannel in, String contentType, Packet packet) {
    if (contentType == null) {
        throw new UnsupportedMediaException();
    }

    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #15
Source File: SOAPBindingCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void decode(ReadableByteChannel in, String contentType, Packet packet) {
    if (contentType == null) {
        throw new UnsupportedMediaException();
    }

    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #16
Source File: StreamSOAPCodec.java    From jdk8u60 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 #17
Source File: MtomCodec.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
    //TODO shouldn't we check for SOAP1.1/SOAP1.2 and throw
    //TODO UnsupportedMediaException like StreamSOAPCodec
    String charset = null;
    String ct = mpp.getRootPart().getContentType();
    if (ct != null) {
        charset = new ContentTypeImpl(ct).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);
    }

    // we'd like to reuse those reader objects but unfortunately decoder may be reused
    // before the decoded message is completely used.
    XMLStreamReader mtomReader = new MtomXMLStreamReaderEx( mpp,
        XMLStreamReaderFactory.create(null, mpp.getRootPart().asInputStream(), charset, true)
    );

    packet.setMessage(codec.decode(mtomReader, new MimeAttachmentSet(mpp)));
    packet.setMtomFeature(mtomFeature);
    packet.setContentType(mpp.getContentType());
}
 
Example #18
Source File: MtomCodec.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
    //TODO shouldn't we check for SOAP1.1/SOAP1.2 and throw
    //TODO UnsupportedMediaException like StreamSOAPCodec
    String charset = null;
    String ct = mpp.getRootPart().getContentType();
    if (ct != null) {
        charset = new ContentTypeImpl(ct).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);
    }

    // we'd like to reuse those reader objects but unfortunately decoder may be reused
    // before the decoded message is completely used.
    XMLStreamReader mtomReader = new MtomXMLStreamReaderEx( mpp,
        XMLStreamReaderFactory.create(null, mpp.getRootPart().asInputStream(), charset, true)
    );

    packet.setMessage(codec.decode(mtomReader, new MimeAttachmentSet(mpp)));
    packet.setMtomFeature(mtomFeature);
    packet.setContentType(mpp.getContentType());
}
 
Example #19
Source File: SOAPBindingCodec.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void decode(InputStream in, String contentType, Packet packet) throws IOException {
    if (contentType == null) {
        contentType = xmlMimeType;
    }
    packet.setContentType(new ContentTypeImpl(contentType));
    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            // parse the multipart portion and then decide whether it's MTOM or SwA
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (!ignoreContentNegotiationProperty && packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #20
Source File: MtomCodec.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
    //TODO shouldn't we check for SOAP1.1/SOAP1.2 and throw
    //TODO UnsupportedMediaException like StreamSOAPCodec
    String charset = null;
    String ct = mpp.getRootPart().getContentType();
    if (ct != null) {
        charset = new ContentTypeImpl(ct).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);
    }

    // we'd like to reuse those reader objects but unfortunately decoder may be reused
    // before the decoded message is completely used.
    XMLStreamReader mtomReader = new MtomXMLStreamReaderEx( mpp,
        XMLStreamReaderFactory.create(null, mpp.getRootPart().asInputStream(), charset, true)
    );

    packet.setMessage(codec.decode(mtomReader, new MimeAttachmentSet(mpp)));
    packet.setMtomFeature(mtomFeature);
    packet.setContentType(mpp.getContentType());
}
 
Example #21
Source File: SOAPBindingCodec.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void decode(InputStream in, String contentType, Packet packet) throws IOException {
    if (contentType == null) {
        contentType = xmlMimeType;
    }
    packet.setContentType(new ContentTypeImpl(contentType));
    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            // parse the multipart portion and then decide whether it's MTOM or SwA
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (!ignoreContentNegotiationProperty && packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #22
Source File: SOAPBindingCodec.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void decode(InputStream in, String contentType, Packet packet) throws IOException {
    if (contentType == null) {
        contentType = xmlMimeType;
    }
    packet.setContentType(new ContentTypeImpl(contentType));
    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            // parse the multipart portion and then decide whether it's MTOM or SwA
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (!ignoreContentNegotiationProperty && packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #23
Source File: MtomCodec.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
    //TODO shouldn't we check for SOAP1.1/SOAP1.2 and throw
    //TODO UnsupportedMediaException like StreamSOAPCodec
    String charset = null;
    String ct = mpp.getRootPart().getContentType();
    if (ct != null) {
        charset = new ContentTypeImpl(ct).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);
    }

    // we'd like to reuse those reader objects but unfortunately decoder may be reused
    // before the decoded message is completely used.
    XMLStreamReader mtomReader = new MtomXMLStreamReaderEx( mpp,
        XMLStreamReaderFactory.create(null, mpp.getRootPart().asInputStream(), charset, true)
    );

    packet.setMessage(codec.decode(mtomReader, new MimeAttachmentSet(mpp)));
    packet.setMtomFeature(mtomFeature);
    packet.setContentType(mpp.getContentType());
}
 
Example #24
Source File: MtomCodec.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
    //TODO shouldn't we check for SOAP1.1/SOAP1.2 and throw
    //TODO UnsupportedMediaException like StreamSOAPCodec
    String charset = null;
    String ct = mpp.getRootPart().getContentType();
    if (ct != null) {
        charset = new ContentTypeImpl(ct).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);
    }

    // we'd like to reuse those reader objects but unfortunately decoder may be reused
    // before the decoded message is completely used.
    XMLStreamReader mtomReader = new MtomXMLStreamReaderEx( mpp,
        XMLStreamReaderFactory.create(null, mpp.getRootPart().asInputStream(), charset, true)
    );

    packet.setMessage(codec.decode(mtomReader, new MimeAttachmentSet(mpp)));
    packet.setMtomFeature(mtomFeature);
    packet.setContentType(mpp.getContentType());
}
 
Example #25
Source File: SOAPBindingCodec.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void decode(InputStream in, String contentType, Packet packet) throws IOException {
    if (contentType == null) {
        contentType = xmlMimeType;
    }
    packet.setContentType(new ContentTypeImpl(contentType));
    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            // parse the multipart portion and then decide whether it's MTOM or SwA
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (!ignoreContentNegotiationProperty && packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #26
Source File: SOAPBindingCodec.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void decode(InputStream in, String contentType, Packet packet) throws IOException {
    if (contentType == null) {
        contentType = xmlMimeType;
    }
    packet.setContentType(new ContentTypeImpl(contentType));
    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            // parse the multipart portion and then decide whether it's MTOM or SwA
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (!ignoreContentNegotiationProperty && packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #27
Source File: SOAPBindingCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void decode(InputStream in, String contentType, Packet packet) throws IOException {
    if (contentType == null) {
        contentType = xmlMimeType;
    }
    packet.setContentType(new ContentTypeImpl(contentType));
    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            // parse the multipart portion and then decide whether it's MTOM or SwA
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (!ignoreContentNegotiationProperty && packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example #28
Source File: MtomCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
    //TODO shouldn't we check for SOAP1.1/SOAP1.2 and throw
    //TODO UnsupportedMediaException like StreamSOAPCodec
    String charset = null;
    String ct = mpp.getRootPart().getContentType();
    if (ct != null) {
        charset = new ContentTypeImpl(ct).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);
    }

    // we'd like to reuse those reader objects but unfortunately decoder may be reused
    // before the decoded message is completely used.
    XMLStreamReader mtomReader = new MtomXMLStreamReaderEx( mpp,
        XMLStreamReaderFactory.create(null, mpp.getRootPart().asInputStream(), charset, true)
    );

    packet.setMessage(codec.decode(mtomReader, new MimeAttachmentSet(mpp)));
    packet.setMtomFeature(mtomFeature);
    packet.setContentType(mpp.getContentType());
}
 
Example #29
Source File: MtomCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
    //TODO shouldn't we check for SOAP1.1/SOAP1.2 and throw
    //TODO UnsupportedMediaException like StreamSOAPCodec
    String charset = null;
    String ct = mpp.getRootPart().getContentType();
    if (ct != null) {
        charset = new ContentTypeImpl(ct).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);
    }

    // we'd like to reuse those reader objects but unfortunately decoder may be reused
    // before the decoded message is completely used.
    XMLStreamReader mtomReader = new MtomXMLStreamReaderEx( mpp,
        XMLStreamReaderFactory.create(null, mpp.getRootPart().asInputStream(), charset, true)
    );

    packet.setMessage(codec.decode(mtomReader, new MimeAttachmentSet(mpp)));
    packet.setMtomFeature(mtomFeature);
    packet.setContentType(mpp.getContentType());
}
 
Example #30
Source File: SOAPBindingCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void decode(InputStream in, String contentType, Packet packet) throws IOException {
    if (contentType == null) {
        contentType = xmlMimeType;
    }
    packet.setContentType(new ContentTypeImpl(contentType));
    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            // parse the multipart portion and then decide whether it's MTOM or SwA
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (!ignoreContentNegotiationProperty && packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}