Example usage for org.springframework.http HttpStatus NON_AUTHORITATIVE_INFORMATION

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

Introduction

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

Prototype

HttpStatus NON_AUTHORITATIVE_INFORMATION

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

Click Source Link

Document

203 Non-Authoritative Information .

Usage

From source file:com.github.woki.payments.adyen.simulator.web.controller.PaymentController.java

@RequestMapping(value = { "/pal/servlet/Payment/v30/authorise",
        "/pal/servlet/Payment/v30/authorise3d" }, method = RequestMethod.POST)
public ResponseEntity<PaymentResponse> authorize(@RequestBody PaymentRequest request) {
    PaymentResponse res = new PaymentResponse();
    if ("gimme_500".equals(request.getReference())) {
        res.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
        return new ResponseEntity<>(res, HttpStatus.INTERNAL_SERVER_ERROR);
    }/*from  w w  w  . j  av  a 2s  .c o  m*/
    if ("gimme_400".equals(request.getReference())) {
        res.setStatus(HttpStatus.BAD_REQUEST.value());
        return new ResponseEntity<>(res, HttpStatus.BAD_REQUEST);
    }
    if ("gimme_422".equals(request.getReference())) {
        res.setStatus(HttpStatus.UNPROCESSABLE_ENTITY.value());
        return new ResponseEntity<>(res, HttpStatus.UNPROCESSABLE_ENTITY);
    }
    if ("gimme_401".equals(request.getReference())) {
        res.setStatus(HttpStatus.UNAUTHORIZED.value());
        return new ResponseEntity<>(res, HttpStatus.UNAUTHORIZED);
    }
    if ("gimme_403".equals(request.getReference())) {
        res.setStatus(HttpStatus.FORBIDDEN.value());
        return new ResponseEntity<>(res, HttpStatus.FORBIDDEN);
    }
    if ("gimme_404".equals(request.getReference())) {
        res.setStatus(HttpStatus.NOT_FOUND.value());
        return new ResponseEntity<>(res, HttpStatus.NOT_FOUND);
    }
    if ("gimme_200".equals(request.getReference())) {
        res.setStatus(HttpStatus.OK.value());
        return new ResponseEntity<>(res, HttpStatus.OK);
    }
    res.setStatus(HttpStatus.NON_AUTHORITATIVE_INFORMATION.value());
    return new ResponseEntity<>(res, HttpStatus.NON_AUTHORITATIVE_INFORMATION);
}

From source file:com.hemou.android.account.AccountUtils.java

/**
 * Is the given {@link Exception} due to a 401 Unauthorized API response?
 * //from   ww  w  .  j a  va  2  s  .c  o  m
 * @param e
 * @return true if 401, false otherwise
 */
public static boolean isUnauthorized(final Exception e) {
    Log.e(TAG, "Exception occured[" + Thread.currentThread().getId() + "]:{type:" + e.getClass().getName() + ","
            + e.getLocalizedMessage() + "}");
    String errorMess = e.getMessage();

    if (!StringUtils.isEmpty(errorMess) && (errorMess.contains("The authorization has expired")
            || errorMess.contains("401 Unauthorized") || errorMess.contains("403 Forbidden")))
        return true;

    if (e instanceof NotAuthorizedException) {
        Log.e(TAG, "?...");
        return true;
    }
    //      if (e instanceof ResourceAccessException)
    //         return true;
    if (e instanceof HttpClientErrorException) {
        HttpClientErrorException expt = (HttpClientErrorException) e;
        HttpStatus status = expt.getStatusCode();
        if (Arrays.asList(HttpStatus.UNAUTHORIZED, HttpStatus.NETWORK_AUTHENTICATION_REQUIRED,
                HttpStatus.NON_AUTHORITATIVE_INFORMATION, HttpStatus.PROXY_AUTHENTICATION_REQUIRED,
                //403??????
                HttpStatus.FORBIDDEN).contains(status))
            return true;
    }

    return false;
}