Example usage for org.springframework.http HttpStatus value

List of usage examples for org.springframework.http HttpStatus value

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus value.

Prototype

int value

To view the source code for org.springframework.http HttpStatus value.

Click Source Link

Usage

From source file:com.design.perpetual.ecobeethermostat.app.enums.ErrorCode.java

public static boolean hasError(HttpStatus status) {
    ErrorCode[] enums = ErrorCode.class.getEnumConstants();
    for (ErrorCode code : enums) {
        if (code.getErrorCode() == status.value()) {
            return true;
        }//from  w  ww . j  av  a2s.com
    }
    return false;
}

From source file:fi.hsl.parkandride.itest.AbstractIntegrationTest.java

public static ResponseSpecification assertResponse(HttpStatus status, Class<?> exClass) {
    Matcher<Integer> statusMatcher = (status == null) ? is(greaterThanOrEqualTo(HttpStatus.BAD_REQUEST.value()))
            : is(status.value());//w w  w  . jav a2s  .  com
    return new ResponseSpecBuilder().expectStatusCode(statusMatcher).expectBody("status", statusMatcher)
            .expectBody("exception", is(exClass.getCanonicalName()))
            .expectBody("timestamp", new ISO8601UTCTimestampMatcher()).build();
}

From source file:org.trustedanalytics.utils.errorhandling.ErrorLogger.java

public static void logAndSendErrorResponse(Logger logger, HttpServletResponse response, HttpStatus status,
        String reason, Exception ex) throws IOException {
    long errorId = ErrorIdGenerator.getNewId();
    String errorMessage = ErrorFormatter.formatErrorMessage(reason, errorId);

    logger.error(errorMessage, ex);/*  w w  w . j  a va2 s. c o m*/
    response.sendError(status.value(), errorMessage);
}

From source file:org.trustedanalytics.user.common.WebErrorHandlers.java

private static void logAndSendErrorResponse(HttpServletResponse response, HttpStatus status, String reason,
        Exception ex) throws IOException {
    long errorId = generateErrorId();
    String errorMessage = ErrorFormatter.formatErrorMessage(reason, errorId);

    LOGGER.error(errorMessage, ex);//from www. ja va 2 s  . com
    response.sendError(status.value(), errorMessage);
}

From source file:net.greghaines.jesque.web.controller.JesqueController.java

private static ModelAndView errorModelAndView(final String viewName, final Throwable t,
        final HttpStatus status) {
    final ModelAndView model = new ModelAndView(viewName);
    model.addObject("errorCode", status.value());
    model.addObject("errorName", toNiceCase(status.name()));
    model.addObject("errorType", t.getClass().getName());
    model.addObject("errorMessage", t.getMessage());
    model.addObject("stackTrace", JesqueUtils.createBacktrace(t).toArray(new String[0]));
    return model;
}

From source file:org.fineract.module.stellar.StellarBridgeTestHelpers.java

public static void makePaymentExpectStatus(final String fromTenant, final String fromTenantApiKey,
        final String toTenant, final String assetCode, final BigDecimal transferAmount,
        final HttpStatus expectStatus) {
    final String payment = getPaymentPayload(assetCode, transferAmount, TEST_ADDRESS_DOMAIN, toTenant);

    given().header(CONTENT_TYPE_HEADER).header(API_KEY_HEADER_LABEL, fromTenantApiKey)
            .header(TENANT_ID_HEADER_LABEL, fromTenant).header(ENTITY_HEADER_LABEL, ENTITY_HEADER_VALUE)
            .header(ACTION_HEADER_LABEL, ACTION_HEADER_VALUE).body(payment)
            .post("/modules/stellarbridge/payments/").then().assertThat().statusCode(expectStatus.value());
}

From source file:org.cloudifysource.rest.util.HttpException.java

public HttpException(HttpStatus status) {
    super("Http error code " + status.value());
    this.status = status;
}

From source file:org.cloudifysource.rest.util.HttpException.java

public HttpException(HttpStatus status, String message) {
    super("Http error code " + status.value() + ". Cause: " + message);
    this.status = status;
}

From source file:com.boundlessgeo.geoserver.api.exceptions.AppExceptionHandler.java

@ExceptionHandler(Exception.class)
public @ResponseBody JSONObj error(Exception e, HttpServletResponse response) {

    HttpStatus status = status(e);
    response.setStatus(status.value());

    // log at warning if 500, else debug
    LOG.log(status == HttpStatus.INTERNAL_SERVER_ERROR ? Level.WARNING : Level.FINE, e.getMessage(), e);
    return IO.error(new JSONObj(), e);
}

From source file:com.onedrive.api.exception.OneDriveException.java

public OneDriveException(ErrorResponse errorResponse, HttpHeaders headers, HttpStatus status, Throwable cause) {
    super(status.value() + " [" + status.getReasonPhrase() + "] " + errorResponse.toString(), cause);
    this.errorResponse = errorResponse;
    this.headers = headers;
    this.status = status;
}