Class MultiPartReaderClientSide
java.lang.Object
org.glassfish.jersey.media.multipart.internal.MultiPartReaderClientSide
- All Implemented Interfaces:
javax.ws.rs.ext.MessageBodyReader<MultiPart>
- Direct Known Subclasses:
MultiPartReaderServerSide
@Consumes("multipart/*")
@Singleton
@ConstrainedTo(CLIENT)
public class MultiPartReaderClientSide
extends Object
implements javax.ws.rs.ext.MessageBodyReader<MultiPart>
MessageBodyReader
implementation for MultiPart
entities.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Logger
private javax.inject.Provider
<MessageBodyWorkers> Injectable helper to look up appropriateMessageBodyReader
s for our body parts.private final org.jvnet.mimepull.MIMEConfig
-
Constructor Summary
ConstructorsConstructorDescriptionMultiPartReaderClientSide
(javax.ws.rs.ext.Providers providers) Accepts constructor injection of the configuration parameters for this application. -
Method Summary
Modifier and TypeMethodDescriptionprivate org.jvnet.mimepull.MIMEConfig
createMimeConfig
(MultiPartProperties properties) private List
<org.jvnet.mimepull.MIMEPart> getMimeParts
(org.jvnet.mimepull.MIMEMessage message) Get a list of mime part attachments from given mime message.boolean
isReadable
(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType) readFrom
(Class<MultiPart> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String, String> headers, 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
(Class<MultiPart> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String, String> headers, InputStream stream) private static javax.ws.rs.core.MediaType
unquoteMediaTypeParameters
(javax.ws.rs.core.MediaType mediaType, String... parameters)
-
Field Details
-
LOGGER
-
messageBodyWorkers
Injectable helper to look up appropriateMessageBodyReader
s for our body parts. -
mimeConfig
private final org.jvnet.mimepull.MIMEConfig mimeConfig
-
-
Constructor Details
-
MultiPartReaderClientSide
public MultiPartReaderClientSide(@Context javax.ws.rs.ext.Providers providers) Accepts constructor injection of the configuration parameters for this application.
-
-
Method Details
-
createMimeConfig
-
isReadable
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType) - Specified by:
isReadable
in interfacejavax.ws.rs.ext.MessageBodyReader<MultiPart>
-
readFrom
public MultiPart readFrom(Class<MultiPart> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String, String> headers, InputStream stream) throws IOException, javax.ws.rs.WebApplicationExceptionReads 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 interfacejavax.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:
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 amultipart/form-data
body part cannot be parsed.
-
readMultiPart
protected MultiPart readMultiPart(Class<MultiPart> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String, String> headers, InputStream stream) throws IOException, org.jvnet.mimepull.MIMEParsingException- Throws:
IOException
org.jvnet.mimepull.MIMEParsingException
-
getMimeParts
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, String... parameters)
-