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.osiam.resources.exception.OsiamExceptionHandler.java
private ErrorResponse produceErrorResponse(String message, HttpStatus status, ErrorMessageTransformer transformer) { if (transformer != null) { message = transformer.transform(message); }//w w w .ja v a 2 s .c o m return new ErrorResponse(status.value(), message); }
From source file:com.envision.envservice.rest.UserCaseCommentResource.java
@GET @Path("{caseId}/{id}") @Produces(MediaType.APPLICATION_JSON)// ww w . ja v a2 s. co m public Response queryByCaseId(@PathParam("caseId") int caseId, @PathParam("id") int id) throws UnsupportedEncodingException { HttpStatus status = HttpStatus.OK; String response = JSON.toJSONString(userCaseCommentService.queryByCaseId(caseId, id), JSONFilter.NULL_UNDERLINE_FILTERS); return Response.status(status.value()).entity(response).build(); }
From source file:au.id.hazelwood.sos.web.controller.framework.GlobalExceptionHandlerUnitTest.java
@SuppressWarnings("unchecked") private void assertResponseEntity(ResponseEntity<Object> responseEntity, HttpStatus status, String message) { assertThat(responseEntity.getStatusCode(), is(status)); Map<String, Object> body = (Map<String, Object>) responseEntity.getBody(); assertThat(body, hasEntry("status", Object.class.cast(status.value()))); assertThat(body, hasEntry("message", Object.class.cast(message))); }
From source file:com.envision.envservice.rest.UserCaseResource.java
@GET @Path("/has_unread/{userId}") @Produces(MediaType.APPLICATION_JSON)/* w w w . ja v a2 s.co m*/ public Response hasUnread(@PathParam("userId") String userId) { HttpStatus status = HttpStatus.OK; String response = JSONObject.toJSONString(userCaseService.queryUnread(userId), JSONFilter.UNDERLINEFILTER); return Response.status(status.value()).entity(response).build(); }
From source file:com.neiljbrown.brighttalk.channels.reportingapi.client.spring.ApiResponseErrorHandler.java
/** * {@inheritDoc}//from w w w.jav a 2s . c om * <p> * This implementation handles the HTTP error response by throwing an {@link ApiErrorResponseException} which includes * an {@link ApiError error} if the response body contained an API error entity. */ @Override public void handleError(ClientHttpResponse response) throws ApiErrorResponseException, IOException { HttpStatus statusCode = getHttpStatusCode(response); ApiError apiError = this.extractErrorResponse(response); throw new ApiErrorResponseException(statusCode.value(), response.getStatusText(), response.getHeaders(), getCharset(response), getResponseBody(response), apiError); }
From source file:com.envision.envservice.rest.LeaveWordResource.java
@GET @Produces(MediaType.APPLICATION_JSON)/*w ww. j a v a 2 s . com*/ public Response queryOwn() throws Exception { HttpStatus status = HttpStatus.OK; String response = JSONObject.toJSONString(leaveWordService.queryOwnLeaveWord(), JSONFilter.NULLFILTER); return Response.status(status.value()).entity(response).build(); }
From source file:org.mitre.openid.connect.view.JsonErrorView.java
@Override protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {//from w ww . j a v a2s . co m response.setContentType(MediaType.APPLICATION_JSON_VALUE); HttpStatus code = (HttpStatus) model.get(HttpCodeView.CODE); if (code == null) { code = HttpStatus.INTERNAL_SERVER_ERROR; // default to 500 } response.setStatus(code.value()); try { Writer out = response.getWriter(); String errorTitle = (String) model.get(ERROR); if (Strings.isNullOrEmpty(errorTitle)) { errorTitle = "mitreid_error"; } String errorMessage = (String) model.get(ERROR_MESSAGE); JsonObject obj = new JsonObject(); obj.addProperty("error", errorTitle); obj.addProperty("error_description", errorMessage); gson.toJson(obj, out); } catch (IOException e) { logger.error("IOException in JsonErrorView.java: ", e); } }
From source file:org.mitre.oauth2.view.TokenApiView.java
@Override protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {// w w w .j a v a2s.c o m response.setContentType(MediaType.APPLICATION_JSON_VALUE); HttpStatus code = (HttpStatus) model.get(HttpCodeView.CODE); if (code == null) { code = HttpStatus.OK; // default to 200 } response.setStatus(code.value()); try { Writer out = response.getWriter(); Object obj = model.get(JsonEntityView.ENTITY); gson.toJson(obj, out); } catch (IOException e) { logger.error("IOException in JsonEntityView.java: ", e); } }
From source file:org.swarmcom.jsynapse.TestBase.java
public void postAndCheckStatus(String path, Resource req, HttpStatus status) throws Exception { try (InputStream request = req.getInputStream()) { mockMvc.perform(post(path).contentType(APPLICATION_JSON).content(IOUtils.toString(request))) .andExpect(status().is(status.value())).andReturn(); }//from www. jav a2s .c o m }
From source file:org.swarmcom.jsynapse.TestBase.java
public void putAndCheckStatus(String path, Resource req, HttpStatus status) throws Exception { try (InputStream request = req.getInputStream()) { mockMvc.perform(put(path).contentType(APPLICATION_JSON).content(IOUtils.toString(request))) .andExpect(status().is(status.value())).andReturn(); }/*from w w w .j a v a 2 s .c om*/ }