Search in sources :

Example 1 with ResteasyConfiguration

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;
}
Also used : ResteasyConfiguration(org.jboss.resteasy.spi.ResteasyConfiguration)

Example 2 with ResteasyConfiguration

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());
    }
}
Also used : Response(jakarta.ws.rs.core.Response) HttpResponse(org.jboss.resteasy.spi.HttpResponse) BuiltResponse(org.jboss.resteasy.specimpl.BuiltResponse) UnhandledException(org.jboss.resteasy.spi.UnhandledException) BuiltResponse(org.jboss.resteasy.specimpl.BuiltResponse) RESTEasyTracingLogger(org.jboss.resteasy.tracing.RESTEasyTracingLogger) ResteasyConfiguration(org.jboss.resteasy.spi.ResteasyConfiguration) NotFoundException(jakarta.ws.rs.NotFoundException) UnhandledException(org.jboss.resteasy.spi.UnhandledException) IOException(java.io.IOException) CompletionException(java.util.concurrent.CompletionException) InternalServerErrorException(org.jboss.resteasy.spi.InternalServerErrorException)

Example 3 with ResteasyConfiguration

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;
}
Also used : ResteasyConfiguration(org.jboss.resteasy.spi.ResteasyConfiguration)

Aggregations

ResteasyConfiguration (org.jboss.resteasy.spi.ResteasyConfiguration)3 NotFoundException (jakarta.ws.rs.NotFoundException)1 Response (jakarta.ws.rs.core.Response)1 IOException (java.io.IOException)1 CompletionException (java.util.concurrent.CompletionException)1 BuiltResponse (org.jboss.resteasy.specimpl.BuiltResponse)1 HttpResponse (org.jboss.resteasy.spi.HttpResponse)1 InternalServerErrorException (org.jboss.resteasy.spi.InternalServerErrorException)1 UnhandledException (org.jboss.resteasy.spi.UnhandledException)1 RESTEasyTracingLogger (org.jboss.resteasy.tracing.RESTEasyTracingLogger)1