List of usage examples for org.springframework.http HttpStatus value
int value
To view the source code for org.springframework.http HttpStatus value.
Click Source Link
From source file:org.smigo.config.RestExceptionResolver.java
private ModelAndView getModelAndView(HttpServletResponse response, HttpStatus httpStatus, Object[] model) { if (response.getStatus() == 200) { response.setStatus(httpStatus.value()); }/* w w w . j a va2 s. c o m*/ ModelAndView jsonView = new ModelAndView(view); jsonView.addObject(model); return jsonView; }
From source file:net.ljcomputing.core.controler.ErrorInfo.java
/** * Instantiates a new error info./*from w ww .j a va 2s . c o m*/ * * @param timestamp the timestamp * @param status the status * @param path the path * @param exception the exception */ public ErrorInfo(String timestamp, HttpStatus status, String path, Exception exception) { this.timestamp = timestamp; this.status = Integer.valueOf(status.value()).toString(); this.error = status.getReasonPhrase(); this.path = path; if (exception instanceof ConstraintViolationException) { StringBuffer eb = new StringBuffer("The save failed validation as follows: "); for (ConstraintViolation<?> cv : ((ConstraintViolationException) exception).getConstraintViolations()) { eb.append(cv.getMessage() + ","); } eb.reverse().replace(0, 1, "").reverse(); this.message = eb.toString(); } else if (null != exception.getLocalizedMessage()) { this.message = exception.getLocalizedMessage(); } else if (null != exception.getMessage()) { this.message = exception.getMessage(); } else { this.message = "An error occured during processing: " + exception.toString(); } }
From source file:eu.modaclouds.sla.service.rest.AbstractSLARest.java
protected String printError(HttpStatus status, String text) { return printError(status.value(), text); }
From source file:eu.modaclouds.sla.service.rest.AbstractSLARest.java
protected String printMessage(HttpStatus status, String text) { return printMessage(status.value(), text); }
From source file:org.mitre.openid.connect.view.HttpCodeView.java
@Override protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {//from w ww . j a v a2s .co m HttpStatus code = (HttpStatus) model.get(CODE); if (code == null) { code = HttpStatus.OK; // default to 200 } response.setStatus(code.value()); }
From source file:eu.modaclouds.sla.service.rest.AbstractSLARest.java
protected Response buildResponse(HttpStatus status, String payload) { return buildResponse(status.value(), payload); }
From source file:com.yang.oa.commons.exception.MapRestErrorConverter.java
public Map convert(RestError re) { Map<String, Object> m = createMap(); HttpStatus status = re.getStatus(); m.put(getStatusKey(), status.value()); int code = re.getCode(); if (code > 0) { m.put(getCodeKey(), code);/*from ww w . j a v a2 s. c o m*/ } String message = re.getMessage(); if (message != null) { m.put(getMessageKey(), message); } String devMsg = re.getDeveloperMessage(); if (devMsg != null) { m.put(getDeveloperMessageKey(), devMsg); } String moreInfoUrl = re.getMoreInfoUrl(); if (moreInfoUrl != null) { m.put(getMoreInfoUrlKey(), moreInfoUrl); } return m; }
From source file:com.novation.eligibility.rest.spring.web.servlet.handler.MapRestErrorConverter.java
@Override public Map convert(RestError re) { Map<String, Object> m = createMap(); HttpStatus status = re.getStatus(); m.put(getStatusKey(), status.value()); int code = re.getCode(); if (code > 0) { m.put(getCodeKey(), code);/*w ww . ja v a2s. com*/ } String message = re.getMessage(); if (message != null) { m.put(getMessageKey(), message); } String devMsg = re.getDeveloperMessage(); if (devMsg != null) { m.put(getDeveloperMessageKey(), devMsg); } String moreInfoUrl = re.getMoreInfoUrl(); if (moreInfoUrl != null) { m.put(getMoreInfoUrlKey(), moreInfoUrl); } return m; }
From source file:com.unioncast.mv.spring.ResponseEntity.java
public ResponseEntity(HttpStatus statusCode) { super(); this.statusCode = statusCode.value(); }
From source file:org.trustedanalytics.utils.errorhandling.RestErrorHandler.java
@ExceptionHandler(Exception.class) public void handleException(Exception e, HttpServletResponse response) throws Exception { // Generate error reference id (to be used both in logs and in error sent from the service) long errorId = ErrorIdGenerator.getNewId(); // If the exception is annotated with @ResponseStatus rethrow it and let // the framework handle it - like the OrderNotFoundException example // at the start of this post. // AnnotationUtils is a Spring Framework utility class. ResponseStatus responseStatus = AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class); if (responseStatus != null) { ErrorLogger.logError("Controller error, reference id: " + errorId, e); response.sendError(responseStatus.value().value(), ErrorFormatter.formatErrorMessage(responseStatus.reason(), errorId)); return;//from w w w . j a v a2 s. co m } HttpStatus errorStatus = HttpStatus.INTERNAL_SERVER_ERROR; ErrorLogger.logError("Unhandled controller error, reference id: " + errorId, e); response.sendError(errorStatus.value(), ErrorFormatter.formatErrorMessage(errorStatus, errorId)); }