use of org.jboss.resteasy.spi.ResteasyConfiguration in project resteasy by resteasy.
the class AbstractPatchMethodFilter method readFilterDisabledFlag.
protected FilterFlag readFilterDisabledFlag(ContainerRequestContext requestContext) {
if (requestContext.getMethod().equals("PATCH") && (MediaType.APPLICATION_JSON_PATCH_JSON_TYPE.isCompatible(requestContext.getMediaType()) || APPLICATION_JSON_MERGE_PATCH_JSON_TYPE.isCompatible(requestContext.getMediaType()))) {
ResteasyConfiguration context = ResteasyContext.getContextData(ResteasyConfiguration.class);
boolean disabled = false;
boolean legacyFilter = false;
if (context == null) {
disabled = Boolean.getBoolean(ResteasyContextParameters.RESTEASY_PATCH_FILTER_DISABLED);
if (!disabled) {
legacyFilter = Boolean.getBoolean(ResteasyContextParameters.RESTEASY_PATCH_FILTER_LEGACY);
}
} else {
disabled = Boolean.parseBoolean(context.getParameter(ResteasyContextParameters.RESTEASY_PATCH_FILTER_DISABLED));
if (!disabled) {
legacyFilter = Boolean.parseBoolean(context.getParameter(ResteasyContextParameters.RESTEASY_PATCH_FILTER_LEGACY));
}
}
if (disabled) {
return FilterFlag.SKIP;
}
if (legacyFilter) {
return FilterFlag.JACKSON;
}
return FilterFlag.JSONP;
}
// if it's not PATCH method, we always skip the filter
return FilterFlag.SKIP;
}
use of org.jboss.resteasy.spi.ResteasyConfiguration in project resteasy by resteasy.
the class SynchronousDispatcher method writeException.
public void writeException(HttpRequest request, HttpResponse response, Throwable e, Consumer<Throwable> onComplete) {
if (!bufferExceptionEntityRead) {
bufferExceptionEntityRead = true;
ResteasyConfiguration context = ResteasyContext.getContextData(ResteasyConfiguration.class);
if (context != null) {
String s = context.getParameter("resteasy.buffer.exception.entity");
if (s != null) {
bufferExceptionEntity = Boolean.parseBoolean(s);
}
}
}
if (response.isCommitted() && response.suppressExceptionDuringChunkedTransfer()) {
LogMessages.LOGGER.debug(Messages.MESSAGES.responseIsCommitted());
onComplete.accept(null);
return;
}
Response handledResponse = new ExceptionHandler(providerFactory, unwrappedExceptions).handleException(request, e);
if (handledResponse == null)
throw new UnhandledException(e);
if (!bufferExceptionEntity) {
response.getOutputHeaders().add("resteasy.buffer.exception.entity", "false");
}
try {
ServerResponseWriter.writeNomapResponse(((BuiltResponse) handledResponse), request, response, providerFactory, onComplete);
} catch (Exception e1) {
throw new UnhandledException(e1);
} finally {
RESTEasyTracingLogger tracingLogger = RESTEasyTracingLogger.getInstance(request);
tracingLogger.log("FINISHED", response.getStatus());
tracingLogger.flush(response.getOutputHeaders());
}
}
use of org.jboss.resteasy.spi.ResteasyConfiguration in project resteasy by resteasy.
the class GZIPDecodingInterceptor method getMaxSize.
private int getMaxSize() {
if (maxSize != -1) {
return maxSize;
}
int size = -1;
ResteasyConfiguration context = ResteasyContext.getContextData(ResteasyConfiguration.class);
if (context != null) {
String s = context.getParameter(ResteasyContextParameters.RESTEASY_GZIP_MAX_INPUT);
if (s != null) {
try {
size = Integer.parseInt(s);
} catch (NumberFormatException e) {
LogMessages.LOGGER.invalidFormat(ResteasyContextParameters.RESTEASY_GZIP_MAX_INPUT, Integer.toString(DEFAULT_MAX_SIZE));
}
}
}
if (size == -1) {
size = DEFAULT_MAX_SIZE;
}
return size;
}
Aggregations