final String entityString = readFromAsString(entityStream, mediaType); if (entityString.isEmpty()) { throw new NoContentException(LocalizationMessages.ERROR_READING_ENTITY_MISSING()); return type.cast(constructor.newInstance(entityString)); } catch (Exception e) { throw new MessageBodyProcessingException(LocalizationMessages.ERROR_ENTITY_PROVIDER_BASICTYPES_CONSTRUCTOR(type)); throw new MessageBodyProcessingException(LocalizationMessages.ERROR_ENTITY_PROVIDER_BASICTYPES_UNKWNOWN(type));
if (clazz.isLocalClass()) { throw new InjectionException( LocalizationMessages.INJECTION_ERROR_LOCAL_CLASS_NOT_SUPPORTED(clazz.getName())); LocalizationMessages.INJECTION_ERROR_NONSTATIC_MEMBER_CLASS_NOT_SUPPORTED(clazz.getName())); throw new InjectionException(LocalizationMessages.INJECTION_ERROR_SUITABLE_CONSTRUCTOR_NOT_FOUND(clazz.getName())); LOGGER.warning(LocalizationMessages.MULTIPLE_MATCHING_CONSTRUCTORS_FOUND( selectedSize, maxParams, clazz.getName(), selected.toGenericString()));
} catch (final Exception e) { LOGGER.log(Level.FINE, LocalizationMessages.AUTODISCOVERABLE_CONFIGURATION_FAILED(autoDiscoverable.getClass()), e);
/** * Set the buffering output stream provider. If the committing output stream works in buffering mode * this method must be called before first bytes are written into this stream. * * @param streamProvider non-null stream provider callback. */ public void setStreamProvider(OutboundMessageContext.StreamProvider streamProvider) { if (isClosed) { throw new IllegalStateException(LocalizationMessages.OUTPUT_STREAM_CLOSED()); } Objects.nonNull(streamProvider); if (this.streamProvider != null) { LOGGER.log(Level.WARNING, LocalizationMessages.COMMITTING_STREAM_ALREADY_INITIALIZED()); } this.streamProvider = streamProvider; }
@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); } }
@Override public CacheControl fromString(String header) { throwIllegalArgumentExceptionIfNull(header, LocalizationMessages.CACHE_CONTROL_IS_NULL()); try { HttpHeaderReader reader = HttpHeaderReader.newInstance(header); CacheControl cacheControl = new CacheControl(); cacheControl.setNoTransform(false); // defaults to true while (reader.hasNext()) { readDirective(cacheControl, reader); if (reader.hasNextSeparator(',', true)) { reader.nextSeparator(','); } } return cacheControl; } catch (ParseException pe) { throw new IllegalArgumentException( "Error parsing cache control '" + header + "'", pe); } }
private void checkComponentClassNotNull(final Class<?> componentClass) { if (componentClass == null) { throw new IllegalArgumentException(LocalizationMessages.COMPONENT_CLASS_CANNOT_BE_NULL()); } }
private void checkProviderNotNull(final Object provider) { if (provider == null) { throw new IllegalArgumentException(LocalizationMessages.COMPONENT_CANNOT_BE_NULL()); } }
/** * Set the buffering output stream provider. If the committing output stream works in buffering mode * this method must be called before first bytes are written into this stream. * * @param streamProvider non-null stream provider callback. */ public void setStreamProvider(OutboundMessageContext.StreamProvider streamProvider) { if (isClosed) { throw new IllegalStateException(LocalizationMessages.OUTPUT_STREAM_CLOSED()); } Objects.nonNull(streamProvider); if (this.streamProvider != null) { LOGGER.log(Level.WARNING, LocalizationMessages.COMMITTING_STREAM_ALREADY_INITIALIZED()); } this.streamProvider = streamProvider; }
final EntityInputStream entityStream = EntityInputStream.create(inputStream); if (entityStream.isEmpty()) { throw new NoContentException(LocalizationMessages.ERROR_READING_ENTITY_MISSING());
@Override public CacheControl fromString(String header) { throwIllegalArgumentExceptionIfNull(header, LocalizationMessages.CACHE_CONTROL_IS_NULL()); try { HttpHeaderReader reader = HttpHeaderReader.newInstance(header); CacheControl cacheControl = new CacheControl(); cacheControl.setNoTransform(false); // defaults to true while (reader.hasNext()) { readDirective(cacheControl, reader); if (reader.hasNextSeparator(',', true)) { reader.nextSeparator(','); } } return cacheControl; } catch (ParseException pe) { throw new IllegalArgumentException( "Error parsing cache control '" + header + "'", pe); } }
private void checkComponentClassNotNull(final Class<?> componentClass) { if (componentClass == null) { throw new IllegalArgumentException(LocalizationMessages.COMPONENT_CLASS_CANNOT_BE_NULL()); } }
private void checkProviderNotNull(final Object provider) { if (provider == null) { throw new IllegalArgumentException(LocalizationMessages.COMPONENT_CANNOT_BE_NULL()); } }
public <T> Constructor<T> getConstructor(final Class<T> clazz) throws MultiException, NoSuchMethodException { if (clazz.isLocalClass()) { throw new NoSuchMethodException(LocalizationMessages.INJECTION_ERROR_LOCAL_CLASS_NOT_SUPPORTED(clazz.getName())); LocalizationMessages.INJECTION_ERROR_NONSTATIC_MEMBER_CLASS_NOT_SUPPORTED(clazz.getName())); throw new NoSuchMethodException(LocalizationMessages.INJECTION_ERROR_SUITABLE_CONSTRUCTOR_NOT_FOUND(clazz.getName())); Errors.warning(clazz, LocalizationMessages.MULTIPLE_MATCHING_CONSTRUCTORS_FOUND( selectedSize, maxParams, clazz.getName(), selected.toGenericString()));
final String entityString = readFromAsString(entityStream, mediaType); if (entityString.isEmpty()) { throw new NoContentException(LocalizationMessages.ERROR_READING_ENTITY_MISSING()); return type.cast(constructor.newInstance(entityString)); } catch (Exception e) { throw new MessageBodyProcessingException(LocalizationMessages.ERROR_ENTITY_PROVIDER_BASICTYPES_CONSTRUCTOR(type)); throw new MessageBodyProcessingException(LocalizationMessages.ERROR_ENTITY_PROVIDER_BASICTYPES_UNKWNOWN(type));
/** * Set the buffering output stream provider. If the committing output stream works in buffering mode * this method must be called before first bytes are written into this stream. * * @param streamProvider non-null stream provider callback. */ public void setStreamProvider(OutboundMessageContext.StreamProvider streamProvider) { if (isClosed) { throw new IllegalStateException(LocalizationMessages.OUTPUT_STREAM_CLOSED()); } Objects.nonNull(streamProvider); if (this.streamProvider != null) { LOGGER.log(Level.WARNING, LocalizationMessages.COMMITTING_STREAM_ALREADY_INITIALIZED()); } this.streamProvider = streamProvider; }
@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); } }
@Override public String toString(CacheControl header) { throwIllegalArgumentExceptionIfNull(header, LocalizationMessages.CACHE_CONTROL_IS_NULL());
private void checkComponentClassNotNull(final Class<?> componentClass) { if (componentClass == null) { throw new IllegalArgumentException(LocalizationMessages.COMPONENT_CLASS_CANNOT_BE_NULL()); } }
private void checkProviderNotNull(final Object provider) { if (provider == null) { throw new IllegalArgumentException(LocalizationMessages.COMPONENT_CANNOT_BE_NULL()); } }