Class MultiPartReaderClientSide

  • All Implemented Interfaces:
    javax.ws.rs.ext.MessageBodyReader<MultiPart>
    Direct Known Subclasses:
    MultiPartReaderServerSide

    @Consumes("multipart/*")
    @Singleton
    @ConstrainedTo(CLIENT)
    public class MultiPartReaderClientSide
    extends java.lang.Object
    implements javax.ws.rs.ext.MessageBodyReader<MultiPart>
    MessageBodyReader implementation for MultiPart entities.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.logging.Logger LOGGER  
      private javax.inject.Provider<MessageBodyWorkers> messageBodyWorkers
      Injectable helper to look up appropriate MessageBodyReaders for our body parts.
      private org.jvnet.mimepull.MIMEConfig mimeConfig  
    • Constructor Summary

      Constructors 
      Constructor Description
      MultiPartReaderClientSide​(javax.ws.rs.ext.Providers providers)
      Accepts constructor injection of the configuration parameters for this application.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private org.jvnet.mimepull.MIMEConfig createMimeConfig​(MultiPartProperties properties)  
      private java.util.List<org.jvnet.mimepull.MIMEPart> getMimeParts​(org.jvnet.mimepull.MIMEMessage message)
      Get a list of mime part attachments from given mime message.
      boolean isReadable​(java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)  
      MultiPart readFrom​(java.lang.Class<MultiPart> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> headers, java.io.InputStream stream)
      Reads the entire list of body parts from the Input stream, using the appropriate provider implementation to de-serialize each body part's entity.
      protected MultiPart readMultiPart​(java.lang.Class<MultiPart> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> headers, java.io.InputStream stream)  
      private static javax.ws.rs.core.MediaType unquoteMediaTypeParameters​(javax.ws.rs.core.MediaType mediaType, java.lang.String... parameters)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final java.util.logging.Logger LOGGER
      • messageBodyWorkers

        @Inject
        private javax.inject.Provider<MessageBodyWorkers> messageBodyWorkers
        Injectable helper to look up appropriate MessageBodyReaders for our body parts.
      • mimeConfig

        private final org.jvnet.mimepull.MIMEConfig mimeConfig
    • Constructor Detail

      • MultiPartReaderClientSide

        public MultiPartReaderClientSide​(@Context
                                         javax.ws.rs.ext.Providers providers)
        Accepts constructor injection of the configuration parameters for this application.
    • Method Detail

      • createMimeConfig

        private org.jvnet.mimepull.MIMEConfig createMimeConfig​(MultiPartProperties properties)
      • isReadable

        public boolean isReadable​(java.lang.Class<?> type,
                                  java.lang.reflect.Type genericType,
                                  java.lang.annotation.Annotation[] annotations,
                                  javax.ws.rs.core.MediaType mediaType)
        Specified by:
        isReadable in interface javax.ws.rs.ext.MessageBodyReader<MultiPart>
      • readFrom

        public MultiPart readFrom​(java.lang.Class<MultiPart> type,
                                  java.lang.reflect.Type genericType,
                                  java.lang.annotation.Annotation[] annotations,
                                  javax.ws.rs.core.MediaType mediaType,
                                  javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> headers,
                                  java.io.InputStream stream)
                           throws java.io.IOException,
                                  javax.ws.rs.WebApplicationException
        Reads the entire list of body parts from the Input stream, using the appropriate provider implementation to de-serialize each body part's entity.
        Specified by:
        readFrom in interface javax.ws.rs.ext.MessageBodyReader<MultiPart>
        Parameters:
        type - the class of the object to be read (i.e. MultiPart.class).
        genericType - the type of object to be written.
        annotations - annotations on the resource method that returned this object.
        mediaType - media type (multipart/*) of this entity.
        headers - mutable map of HTTP headers for the entire response.
        stream - output stream to which the entity should be written.
        Throws:
        java.io.IOException - if an I/O error occurs.
        javax.ws.rs.WebApplicationException - If an HTTP error response needs to be produced (only effective if the response is not committed yet) or if the Content-Disposition header of a multipart/form-data body part cannot be parsed.
      • readMultiPart

        protected MultiPart readMultiPart​(java.lang.Class<MultiPart> type,
                                          java.lang.reflect.Type genericType,
                                          java.lang.annotation.Annotation[] annotations,
                                          javax.ws.rs.core.MediaType mediaType,
                                          javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> headers,
                                          java.io.InputStream stream)
                                   throws java.io.IOException,
                                          org.jvnet.mimepull.MIMEParsingException
        Throws:
        java.io.IOException
        org.jvnet.mimepull.MIMEParsingException
      • getMimeParts

        private java.util.List<org.jvnet.mimepull.MIMEPart> getMimeParts​(org.jvnet.mimepull.MIMEMessage message)
        Get a list of mime part attachments from given mime message. If an exception occurs during parsing the message the parsed mime parts are closed (any temporary files are deleted).
        Parameters:
        message - mime message to get mime parts from.
        Returns:
        list of mime part attachments.
      • unquoteMediaTypeParameters

        private static javax.ws.rs.core.MediaType unquoteMediaTypeParameters​(javax.ws.rs.core.MediaType mediaType,
                                                                             java.lang.String... parameters)