@Override public Reader readFrom( final Class<Reader> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, String> httpHeaders, final InputStream inputStream) throws IOException { final EntityInputStream entityStream = EntityInputStream.create(inputStream); if (entityStream.isEmpty()) { return new BufferedReader(new InputStreamReader( new ByteArrayInputStream(new byte[0]), MessageUtils.getCharset(mediaType))); } return new BufferedReader(new InputStreamReader(entityStream, getCharset(mediaType))); }
/** * Create an entity input stream instance wrapping the original input stream. * <p/> * In case the original entity stream is already of type {@code EntityInputStream}, * the stream is returned without wrapping. * * @param inputStream input stream. * @return entity input stream. */ public static EntityInputStream create(InputStream inputStream) { if (inputStream instanceof EntityInputStream) { return (EntityInputStream) inputStream; } return new EntityInputStream(inputStream); }
void close(boolean force) { if (buffered && !force) { return; } try { super.close(); } finally { buffered = false; setWrappedStream(null); } } }
ReaderInterceptorExecutor.this); final EntityInputStream input = new EntityInputStream(context.getInputStream()); if (input.isEmpty() && !context.getHeaders().containsKey(HttpHeaders.CONTENT_TYPE)) { return null; } else {
ReaderInterceptorExecutor.this); final EntityInputStream input = new EntityInputStream(context.getInputStream()); if (input.isEmpty() && !context.getHeaders().containsKey(HttpHeaders.CONTENT_TYPE)) { return null; } else {
@Override public Reader readFrom( final Class<Reader> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, String> httpHeaders, final InputStream inputStream) throws IOException { final EntityInputStream entityStream = EntityInputStream.create(inputStream); if (entityStream.isEmpty()) { return new BufferedReader(new InputStreamReader( new ByteArrayInputStream(new byte[0]), MessageUtils.getCharset(mediaType))); } return new BufferedReader(new InputStreamReader(entityStream, getCharset(mediaType))); }
ReaderInterceptorExecutor.this); final EntityInputStream input = new EntityInputStream(context.getInputStream()); if (input.isEmpty() && !context.getHeaders().containsKey(HttpHeaders.CONTENT_TYPE)) { return null; } else {
void close(boolean force) { if (buffered && !force) { return; } try { super.close(); } finally { buffered = false; setWrappedStream(null); } } }
/** * Create an entity input stream instance wrapping the original input stream. * <p/> * In case the original entity stream is already of type {@code EntityInputStream}, * the stream is returned without wrapping. * * @param inputStream input stream. * @return entity input stream. */ public static EntityInputStream create(InputStream inputStream) { if (inputStream instanceof EntityInputStream) { return (EntityInputStream) inputStream; } return new EntityInputStream(inputStream); }
@Override public final Object readFrom( Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream inputStream) throws IOException { final EntityInputStream entityStream = EntityInputStream.create(inputStream); if (entityStream.isEmpty()) { throw new NoContentException(LocalizationMessages.ERROR_READING_ENTITY_MISSING()); } try { return getUnmarshaller(type, mediaType) .unmarshal(getSAXSource(spf.get(), entityStream)); } catch (UnmarshalException ex) { throw new BadRequestException(ex); } catch (JAXBException ex) { throw new InternalServerErrorException(ex); } }
ReaderInterceptorExecutor.this); final EntityInputStream input = new EntityInputStream(context.getInputStream()); if (input.isEmpty() && !context.getHeaders().containsKey(HttpHeaders.CONTENT_TYPE)) { return null; } else {
void close(boolean force) { if (buffered && !force) { return; } try { super.close(); } finally { buffered = false; setWrappedStream(null); } } }
/** * Create an entity input stream instance wrapping the original input stream. * <p/> * In case the original entity stream is already of type {@code EntityInputStream}, * the stream is returned without wrapping. * * @param inputStream input stream. * @return entity input stream. */ public static EntityInputStream create(InputStream inputStream) { if (inputStream instanceof EntityInputStream) { return (EntityInputStream) inputStream; } return new EntityInputStream(inputStream); }
@Override public final JAXBElement<?> readFrom( Class<JAXBElement<?>> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream inputStream) throws IOException { final EntityInputStream entityStream = EntityInputStream.create(inputStream); if (entityStream.isEmpty()) { throw new NoContentException(LocalizationMessages.ERROR_READING_ENTITY_MISSING()); } final ParameterizedType pt = (ParameterizedType) genericType; final Class ta = (Class) pt.getActualTypeArguments()[0]; try { return readFrom(ta, mediaType, getUnmarshaller(ta, mediaType), entityStream); } catch (UnmarshalException ex) { throw new BadRequestException(ex); } catch (JAXBException ex) { throw new InternalServerErrorException(ex); } }
ReaderInterceptorExecutor.this); final EntityInputStream input = new EntityInputStream(context.getInputStream()); if (input.isEmpty() && !context.getHeaders().containsKey(HttpHeaders.CONTENT_TYPE)) { return null; } else {
void close(boolean force) { if (buffered && !force) { return; } try { super.close(); } finally { buffered = false; setWrappedStream(null); } } }