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.unioncast.mv.spring.ResponseEntity.java
/** * Create a new {@code ResponseEntity} with the given body and status code, and no headers. * @param body the entity body/* w w w. ja v a 2 s .co m*/ * @param statusCode the status code */ public ResponseEntity(T body, HttpStatus statusCode) { super(body); this.statusCode = statusCode.value(); }
From source file:eu.modaclouds.sla.service.rest.AbstractSLARest.java
protected Response buildResponsePOST(HttpStatus status, String message, String location) { return buildResponsePOST(status.value(), message, location); }
From source file:com.unioncast.mv.spring.ResponseEntity.java
/** * Create a new {@code HttpEntity} with the given headers and status code, and no body. * @param headers the entity headers/*from w w w . j a va 2s . c o m*/ * @param statusCode the status code */ public ResponseEntity(MultiValueMap<String, String> headers, HttpStatus statusCode) { super(headers); this.statusCode = statusCode.value(); }
From source file:io.spring.initializr.web.test.MockMvcClientHttpRequestFactory.java
@Override public ClientHttpRequest createRequest(final URI uri, final HttpMethod httpMethod) throws IOException { return new MockClientHttpRequest(httpMethod, uri) { @Override/*from w w w . jav a 2s. co m*/ public ClientHttpResponse executeInternal() throws IOException { try { MockHttpServletRequestBuilder requestBuilder = request(httpMethod, uri.toString()); requestBuilder.content(getBodyAsBytes()); requestBuilder.headers(getHeaders()); MockHttpServletResponse servletResponse = actions(requestBuilder).andReturn().getResponse(); HttpStatus status = HttpStatus.valueOf(servletResponse.getStatus()); if (status.value() >= 400) { requestBuilder = request(HttpMethod.GET, "/error") .requestAttr(RequestDispatcher.ERROR_STATUS_CODE, status.value()) .requestAttr(RequestDispatcher.ERROR_REQUEST_URI, uri.toString()); if (servletResponse.getErrorMessage() != null) { requestBuilder.requestAttr(RequestDispatcher.ERROR_MESSAGE, servletResponse.getErrorMessage()); } // Overwrites the snippets from the first request servletResponse = actions(requestBuilder).andReturn().getResponse(); } byte[] body = servletResponse.getContentAsByteArray(); HttpHeaders headers = getResponseHeaders(servletResponse); MockClientHttpResponse clientResponse = new MockClientHttpResponse(body, status); clientResponse.getHeaders().putAll(headers); return clientResponse; } catch (Exception ex) { throw new IllegalStateException(ex); } } }; }
From source file:com.envision.envservice.rest.AssessmentCyclesResource.java
@GET @Path("/addAssessmentCycles") @Produces(MediaType.APPLICATION_JSON)/*w w w .j a v a 2s. co m*/ public Response addAssessmentCycles() throws Exception { HttpStatus status = HttpStatus.CREATED; String response = StringUtils.EMPTY; response = acService.addAssessmentCycles().toString(); return Response.status(status.value()).entity(response).build(); }
From source file:com.github.tddts.jet.oauth.server.DefaultAuthHandler.java
@Override public void process(AuthHandlerCallback callback, List<NameValuePair> params) { if (params.isEmpty()) { callback.returnMessage(responseText); } else {// w w w . jav a 2s . co m HttpStatus status = authService.processAuthorization(params); String message = status.is2xxSuccessful() ? successMessage : status.getReasonPhrase(); callback.returnMessage(status.value(), message); } }
From source file:com.unioncast.mv.spring.ResponseEntity.java
/** * Create a new {@code HttpEntity} with the given body, headers, and status code. * @param body the entity body// w w w . ja va2 s . co m * @param headers the entity headers * @param statusCode the status code */ public ResponseEntity(T body, MultiValueMap<String, String> headers, HttpStatus statusCode) { super(body, headers); this.statusCode = statusCode.value(); }
From source file:se.skltp.cooperation.web.rest.exception.DefaultExceptionHandler.java
private void buildErrorMessage(HttpServletRequest request, Exception e, HttpStatus status, ProblemDetail error) {/*w w w . ja v a 2 s.c o m*/ try { error.setType(new URI("http://httpstatus.es/" + status.value())); } catch (URISyntaxException e1) { log.error("Unable to set error type", e); } error.setTitle(status.getReasonPhrase()); error.setStatus(status.value()); error.setDetail(e.getMessage()); String url = request.getRequestURL().toString(); if (request.getQueryString() != null) { url = url + "?" + request.getQueryString(); } error.setInstance(url); }
From source file:com.envision.envservice.rest.CommentTopResource.java
/** * ?// www . java 2s . co m * @Title: cancelCommentTop * @param commentId * @return Response * @throws ServiceException * @Date 201646 */ @GET @Produces(MediaType.APPLICATION_JSON) @Path("/cancel/{comment_id}") public Response cancelCommentTop(@PathParam("comment_id") int commentId) throws ServiceException { HttpStatus status = HttpStatus.OK; String response = StringUtils.EMPTY; commentTopService.cancelCommentTop(commentId); return Response.status(status.value()).entity(response).build(); }
From source file:com.phoenixnap.oss.ramlapisync.style.checkers.ResponseCodeDefinitionStyleChecker.java
@Override public Set<StyleIssue> checkActionStyle(RamlActionType key, RamlAction value, IssueLocation location, RamlRoot raml) {//from w ww.ja va2s .c om logger.debug("Checking Action: " + key); Set<StyleIssue> issues = new LinkedHashSet<>(); //Do we have a check for this verb? if (statusChecks.containsKey(key.name())) { List<HttpStatus> statuses = statusChecks.get(key.name()); if (!CollectionUtils.isEmpty(statuses)) { for (HttpStatus check : statuses) { if (value.getResponses() == null || !value.getResponses().containsKey(String.valueOf(check.value()))) { issues.add(new StyleIssue(location, String.format(DESCRIPTION, key, check.name(), check.value()), value.getResource(), value)); } } } } return issues; }