use of org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException in project jersey by jersey.
the class ParameterValueHelper method getParameterValues.
/**
* Get the array of parameter values.
*
* @param valueProviders a list of value providers.
* @return array of parameter values provided by the value providers.
*/
public static Object[] getParameterValues(List<ParamValueFactoryWithSource<?>> valueProviders) {
final Object[] params = new Object[valueProviders.size()];
try {
int entityProviderIndex = -1;
int index = 0;
for (ParamValueFactoryWithSource<?> paramValProvider : valueProviders) {
// entity provider has to be called last; see JERSEY-2642
if (paramValProvider.getSource().equals(Parameter.Source.ENTITY)) {
entityProviderIndex = index++;
continue;
}
params[index++] = paramValProvider.get();
}
if (entityProviderIndex != -1) {
params[entityProviderIndex] = valueProviders.get(entityProviderIndex).get();
}
return params;
} catch (WebApplicationException e) {
throw e;
} catch (MessageBodyProviderNotFoundException e) {
throw new NotSupportedException(e);
} catch (ProcessingException e) {
throw e;
} catch (RuntimeException e) {
if (e.getCause() instanceof WebApplicationException) {
throw (WebApplicationException) e.getCause();
}
throw new MappableException("Exception obtaining parameters", e);
}
}
use of org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException in project jersey by jersey.
the class InboundEvent method readData.
/**
* Read event data as a given generic type.
*
* @param type generic type to be used for event data de-serialization.
* @param mediaType {@link MediaType media type} to be used for event data de-serialization.
* @return event data de-serialized as an instance of a given type.
* @throws javax.ws.rs.ProcessingException when provided type can't be read. The thrown exception wraps the original cause.
* @since 2.3
*/
public <T> T readData(GenericType<T> type, MediaType mediaType) {
final MediaType effectiveMediaType = mediaType == null ? this.mediaType : mediaType;
final MessageBodyReader reader = messageBodyWorkers.getMessageBodyReader(type.getRawType(), type.getType(), annotations, mediaType);
if (reader == null) {
throw new MessageBodyProviderNotFoundException(LocalizationMessages.EVENT_DATA_READER_NOT_FOUND());
}
return readAndCast(type, effectiveMediaType, reader);
}
Aggregations