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:com.wiiyaya.consumer.web.main.controller.ExceptionController.java
private ModelAndView prepareExceptionInfo(HttpServletRequest request, HttpStatus httpStatus, String errorCode, String errorMessage) {/*from www . j a v a 2 s .com*/ Map<String, Object> models = new LinkedHashMap<>(); models.put("statusCode", httpStatus.value()); models.put("errorCode", errorCode); models.put("errorMessage", errorMessage); ModelAndView modelAndView = new ModelAndView(); if (noNeedWrapper(request)) { modelAndView.setView(DEFAULT_JSON_VIEW); modelAndView.addAllObjects(models); return modelAndView; } else { modelAndView.setViewName("error"); modelAndView.addAllObjects(models); return modelAndView; } }
From source file:org.entitypedia.games.common.api.handlers.DefaultExceptionDetailsResolver.java
private String definitionFor(HttpStatus status) { return "status=" + status.value() + ", msg=" + DEFAULT_EXCEPTION_MESSAGE_VALUE; }
From source file:com.novation.eligibility.rest.spring.web.servlet.handler.DefaultRestErrorResolver.java
private String definitionFor(HttpStatus status) { return status.value() + ", " + DEFAULT_EXCEPTION_MESSAGE_VALUE; }
From source file:com.envision.envservice.rest.AssessmentResource.java
/** * //w w w. j a v a 2 s. c o m * */ @GET @Path("queryLast/{cycleId}") @Produces(MediaType.APPLICATION_JSON) public Response queryLast(@PathParam("cycleId") String cycleId) { HttpStatus status = HttpStatus.OK; AsBo ab = assessmentService.queryLast(cycleId); String response = JSONObject.toJSONString(ab, JSONFilter.UNDERLINEFILTER); return Response.status(status.value()).entity(response).build(); }
From source file:com.envision.envservice.rest.AssessmentResource.java
/** * /*from www. j a v a2s .c o m*/ * */ @GET @Path("queryNext/{cycleId}") @Produces(MediaType.APPLICATION_JSON) public Response queryNext(@PathParam("cycleId") String cycleId) { HttpStatus status = HttpStatus.OK; AsBo ab = assessmentService.queryNext(cycleId); String response = JSONObject.toJSONString(ab, JSONFilter.UNDERLINEFILTER); return Response.status(status.value()).entity(response).build(); }
From source file:dk.clanie.bitcoin.client.BitcoindJsonRpcErrorHandler.java
/** * Parses the response body, deserializing it into an BitcoinJsonRpcErrorResponse object. * <p>/*w w w . java 2 s.c o m*/ * If parsing fails an BitcoinException containing the given HTTP error code is thrown. * * @param response * @param statusCode * @return BitcoinJsonRpcErrorResponse * @throws BitcoinException */ private BitcoindErrorResponse parseResponse(ClientHttpResponse response, HttpStatus statusCode) { String body = new String(getResponseBody(response), getCharset(response)); try { return objectMapper.readValue(body, BitcoindErrorResponse.class); } catch (IOException ioe) { throw new BitcoinException("Received an HTTP " + statusCode.value() + " " + statusCode.getReasonPhrase() + ". Response parsing failed.", ioe); } }
From source file:com.envision.envservice.rest.UserCasePriseResource.java
@POST @Consumes(MediaType.APPLICATION_JSON)//w w w.j a v a 2 s. com @Produces(MediaType.APPLICATION_JSON) public Response prise(UserCasePriseBo userCasePrise) throws Exception { HttpStatus status = HttpStatus.CREATED; String response = StringUtils.EMPTY; if (!checkParam(userCasePrise)) { status = HttpStatus.BAD_REQUEST; response = FailResult.toJson(Code.PARAM_ERROR, "?"); } else { userCasePriseService.prise(userCasePrise); } return Response.status(status.value()).entity(response).build(); }
From source file:org.n52.web.BaseController.java
private void writeExceptionResponse(WebException e, HttpServletResponse response, HttpStatus status) { if (status == INTERNAL_SERVER_ERROR) { LOGGER.error("An exception occured.", e); } else {/*from ww w .j av a2s . c o m*/ LOGGER.debug("An exception occured.", e); } // TODO consider using a 'suppress_response_codes=true' parameter and always return 200 OK response.setStatus(status.value()); response.setContentType(APPLICATION_JSON.getMimeType()); ObjectMapper objectMapper = createObjectMapper(); ObjectWriter writer = objectMapper.writerWithType(ExceptionResponse.class); ExceptionResponse exceptionResponse = createExceptionResponse(e, status); try { writer.writeValue(response.getOutputStream(), exceptionResponse); } catch (IOException ioe) { LOGGER.error("Could not process error message.", e); } }
From source file:cn.org.once.cstack.volumes.VolumeControllerTestIT.java
private void deleteVolume(Integer id, HttpStatus status) throws Exception { logger.info("Delete Volume : " + id); ResultActions resultats = mockMvc//from w w w.j a v a 2s . co m .perform(delete("/volume/" + id).session(session).contentType(MediaType.APPLICATION_JSON)); resultats.andExpect(status().is(status.value())); }
From source file:com.envision.envservice.rest.UserCaseCommentResource.java
@POST @Path("{id}") @Consumes(MediaType.APPLICATION_JSON)// ww w . ja v a 2 s . c o m @Produces(MediaType.APPLICATION_JSON) public Response add(@PathParam("id") int id, UserCaseCommentBo userCaseComment) throws Exception { HttpStatus status = HttpStatus.CREATED; String response = StringUtils.EMPTY; if (!checkParam(userCaseComment)) { status = HttpStatus.BAD_REQUEST; response = FailResult.toJson(Code.PARAM_ERROR, "?"); } else { userCaseCommentService.add(id, userCaseComment); } return Response.status(status.value()).entity(response).build(); }