/** * Returns the entity after appropriate conversion to the requested type. This is useful only when the containing * {@link MultiPart} instance has been received, which causes the {@code providers} property to have been set. * * @param clazz desired class into which the entity should be converted. * @return entity after appropriate conversion to the requested type. * * @throws ProcessingException if an IO error arises during reading an entity. * @throws IllegalArgumentException if no {@link MessageBodyReader} can be found to perform the requested conversion. * @throws IllegalStateException if this method is called when the {@code providers} property has not been set or when the * entity instance is not the unconverted content of the body part entity. */ public <T> T getEntityAs(final Class<T> clazz) { if (entity == null || !(entity instanceof BodyPartEntity)) { throw new IllegalStateException(LocalizationMessages.ENTITY_HAS_WRONG_TYPE()); } if (clazz == BodyPartEntity.class) { return clazz.cast(entity); } final Annotation[] annotations = new Annotation[0]; final MessageBodyReader<T> reader = messageBodyWorkers.getMessageBodyReader(clazz, clazz, annotations, mediaType); if (reader == null) { throw new IllegalArgumentException(LocalizationMessages.NO_AVAILABLE_MBR(clazz, mediaType)); } try { return reader.readFrom(clazz, clazz, annotations, mediaType, headers, ((BodyPartEntity) entity).getInputStream()); } catch (final IOException ioe) { throw new ProcessingException(LocalizationMessages.ERROR_READING_ENTITY(String.class), ioe); } }
if (bodyEntity instanceof BodyPartEntity) { bodyClass = InputStream.class; bodyEntity = ((BodyPartEntity) bodyEntity).getInputStream();
stream = part.getEntityAs(BodyPartEntity.class).getInputStream(); mediaType, request.getHeaders(), ((BodyPartEntity) p.getEntity()).getInputStream());
/** * Returns the entity after appropriate conversion to the requested type. This is useful only when the containing * {@link MultiPart} instance has been received, which causes the {@code providers} property to have been set. * * @param clazz desired class into which the entity should be converted. * @return entity after appropriate conversion to the requested type. * * @throws ProcessingException if an IO error arises during reading an entity. * @throws IllegalArgumentException if no {@link MessageBodyReader} can be found to perform the requested conversion. * @throws IllegalStateException if this method is called when the {@code providers} property has not been set or when the * entity instance is not the unconverted content of the body part entity. */ public <T> T getEntityAs(final Class<T> clazz) { if (entity == null || !(entity instanceof BodyPartEntity)) { throw new IllegalStateException(LocalizationMessages.ENTITY_HAS_WRONG_TYPE()); } if (clazz == BodyPartEntity.class) { return clazz.cast(entity); } final Annotation[] annotations = new Annotation[0]; final MessageBodyReader<T> reader = messageBodyWorkers.getMessageBodyReader(clazz, clazz, annotations, mediaType); if (reader == null) { throw new IllegalArgumentException(LocalizationMessages.NO_AVAILABLE_MBR(clazz, mediaType)); } try { return reader.readFrom(clazz, clazz, annotations, mediaType, headers, ((BodyPartEntity) entity).getInputStream()); } catch (final IOException ioe) { throw new ProcessingException(LocalizationMessages.ERROR_READING_ENTITY(String.class), ioe); } }
/** * Returns the entity after appropriate conversion to the requested type. This is useful only when the containing * {@link MultiPart} instance has been received, which causes the {@code providers} property to have been set. * * @param clazz desired class into which the entity should be converted. * @return entity after appropriate conversion to the requested type. * * @throws ProcessingException if an IO error arises during reading an entity. * @throws IllegalArgumentException if no {@link MessageBodyReader} can be found to perform the requested conversion. * @throws IllegalStateException if this method is called when the {@code providers} property has not been set or when the * entity instance is not the unconverted content of the body part entity. */ public <T> T getEntityAs(final Class<T> clazz) { if (entity == null || !(entity instanceof BodyPartEntity)) { throw new IllegalStateException(LocalizationMessages.ENTITY_HAS_WRONG_TYPE()); } if (clazz == BodyPartEntity.class) { return clazz.cast(entity); } final Annotation[] annotations = new Annotation[0]; final MessageBodyReader<T> reader = messageBodyWorkers.getMessageBodyReader(clazz, clazz, annotations, mediaType); if (reader == null) { throw new IllegalArgumentException(LocalizationMessages.NO_AVAILABLE_MBR(clazz, mediaType)); } try { return reader.readFrom(clazz, clazz, annotations, mediaType, headers, ((BodyPartEntity) entity).getInputStream()); } catch (final IOException ioe) { throw new ProcessingException(LocalizationMessages.ERROR_READING_ENTITY(String.class), ioe); } }
/** * Returns the entity after appropriate conversion to the requested type. This is useful only when the containing * {@link MultiPart} instance has been received, which causes the {@code providers} property to have been set. * * @param clazz desired class into which the entity should be converted. * @return entity after appropriate conversion to the requested type. * * @throws ProcessingException if an IO error arises during reading an entity. * @throws IllegalArgumentException if no {@link MessageBodyReader} can be found to perform the requested conversion. * @throws IllegalStateException if this method is called when the {@code providers} property has not been set or when the * entity instance is not the unconverted content of the body part entity. */ public <T> T getEntityAs(final Class<T> clazz) { if (entity == null || !(entity instanceof BodyPartEntity)) { throw new IllegalStateException(LocalizationMessages.ENTITY_HAS_WRONG_TYPE()); } if (clazz == BodyPartEntity.class) { return clazz.cast(entity); } final Annotation[] annotations = new Annotation[0]; final MessageBodyReader<T> reader = messageBodyWorkers.getMessageBodyReader(clazz, clazz, annotations, mediaType); if (reader == null) { throw new IllegalArgumentException(LocalizationMessages.NO_AVAILABLE_MBR(clazz, mediaType)); } try { return reader.readFrom(clazz, clazz, annotations, mediaType, headers, ((BodyPartEntity) entity).getInputStream()); } catch (final IOException ioe) { throw new ProcessingException(LocalizationMessages.ERROR_READING_ENTITY(String.class), ioe); } }
/** * Returns the entity after appropriate conversion to the requested type. This is useful only when the containing * {@link MultiPart} instance has been received, which causes the {@code providers} property to have been set. * * @param clazz desired class into which the entity should be converted. * @return entity after appropriate conversion to the requested type. * * @throws ProcessingException if an IO error arises during reading an entity. * @throws IllegalArgumentException if no {@link MessageBodyReader} can be found to perform the requested conversion. * @throws IllegalStateException if this method is called when the {@code providers} property has not been set or when the * entity instance is not the unconverted content of the body part entity. */ public <T> T getEntityAs(final Class<T> clazz) { if (entity == null || !(entity instanceof BodyPartEntity)) { throw new IllegalStateException(LocalizationMessages.ENTITY_HAS_WRONG_TYPE()); } if (clazz == BodyPartEntity.class) { return clazz.cast(entity); } final Annotation[] annotations = new Annotation[0]; final MessageBodyReader<T> reader = messageBodyWorkers.getMessageBodyReader(clazz, clazz, annotations, mediaType); if (reader == null) { throw new IllegalArgumentException(LocalizationMessages.NO_AVAILABLE_MBR(clazz, mediaType)); } try { return reader.readFrom(clazz, clazz, annotations, mediaType, headers, ((BodyPartEntity) entity).getInputStream()); } catch (final IOException ioe) { throw new ProcessingException(LocalizationMessages.ERROR_READING_ENTITY(String.class), ioe); } }
if (bodyEntity instanceof BodyPartEntity) { bodyClass = InputStream.class; bodyEntity = ((BodyPartEntity) bodyEntity).getInputStream();
if (bodyEntity instanceof BodyPartEntity) { bodyClass = InputStream.class; bodyEntity = ((BodyPartEntity) bodyEntity).getInputStream();
if (bodyEntity instanceof BodyPartEntity) { bodyClass = InputStream.class; bodyEntity = ((BodyPartEntity) bodyEntity).getInputStream();
if (bodyEntity instanceof BodyPartEntity) { bodyClass = InputStream.class; bodyEntity = ((BodyPartEntity) bodyEntity).getInputStream();
stream = part.getEntityAs(BodyPartEntity.class).getInputStream(); mediaType, request.getHeaders(), ((BodyPartEntity) p.getEntity()).getInputStream());
stream = part.getEntityAs(BodyPartEntity.class).getInputStream(); mediaType, request.getHeaders(), ((BodyPartEntity) p.getEntity()).getInputStream());
stream = part.getEntityAs(BodyPartEntity.class).getInputStream(); mediaType, request.getHeaders(), ((BodyPartEntity) p.getEntity()).getInputStream());
stream = part.getEntityAs(BodyPartEntity.class).getInputStream(); mediaType, request.getHeaders(), ((BodyPartEntity) p.getEntity()).getInputStream());