Example usage for org.springframework.http HttpStatus value

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

Introduction

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

Prototype

int value

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

Click Source Link

Usage

From source file:com.pkstudio.hive.exceptions.rest.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);//  www .j a va  2  s  .co  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);
    }

    List<FieldError> fieldErrors = re.getFieldErrors();
    if (fieldErrors != null) {
        m.put(getFieldErrorsKey(), fieldErrors);
    }

    return m;
}

From source file:com.envision.envservice.rest.EvaluationPeriodResource.java

@GET
@Path("/addEvaluationPeriod")
@Produces(MediaType.APPLICATION_JSON)/*w  ww  . j a v  a2 s.  co  m*/
public Response addEvaluationPeriod() throws Exception {
    HttpStatus status = HttpStatus.CREATED;
    String response = StringUtils.EMPTY;
    response = evaluationPeriodService.addEvaluationPeriod().toString();
    return Response.status(status.value()).entity(response).build();

}

From source file:com.envision.envservice.rest.UserCasePriseResource.java

@GET
@Path("/user/{userId}")
@Produces(MediaType.APPLICATION_JSON)//from w  w  w  . j  a  v a  2  s  .c  o m
public Response queryPriseCollect(@PathParam("userId") String userId) {
    HttpStatus status = HttpStatus.CREATED;
    String response = userCasePriseService.queryPriseCollect(userId).toJSONString();

    return Response.status(status.value()).entity(response).build();
}

From source file:cucumber.api.spring.test.web.servlet.StatusResultMatchersStepdefs.java

@Then("^the response status should be \"(.*?)\"$")
public void the_repsonse_status_should_be(String reasonPhrase) throws Throwable {
    for (HttpStatus status : HttpStatus.values()) {
        if (status.getReasonPhrase().equalsIgnoreCase(reasonPhrase)) {
            mockMvcStepdefs.getResultActions().andExpect(status().is(status.value()));
            return;
        }// www  .ja va 2 s  . c  o m
    }
    throw new IllegalArgumentException("No matching status code found for reason phrase: " + reasonPhrase);
}

From source file:it.reply.orchestrator.exception.GlobalControllerExceptionHandler.java

/**
 * Convert the exception into {@link Error} object.
 * /*from   www. j av  a2  s  .c  om*/
 * @param ex
 *          the exception to be handled
 * @param headers
 *          {@code HttpHeaders} instance
 * @param status
 *          {@code HttpStatus} instance
 * @return the error response
 */
private ResponseEntity<Object> handleResponse(Exception ex, HttpHeaders headers, HttpStatus status) {
    Error error = new Error().withCode(status.value()).withTitle(status.getReasonPhrase())
            .withMessage(ex.getMessage());

    return new ResponseEntity<Object>(error, headers, status);

}

From source file:com.envision.envservice.rest.CommentTopResource.java

@POST
@Consumes(MediaType.APPLICATION_JSON)/*from w w  w  . j  av a2s.  c  om*/
@Produces(MediaType.APPLICATION_JSON)
public Response commentTop(CommentTopVo commentTopVo) throws ServiceException {
    HttpStatus status = HttpStatus.CREATED;
    String response = StringUtils.EMPTY;
    commentTopService.commentTop(commentTopVo.getComment_id());

    return Response.status(status.value()).entity(response).build();
}

From source file:com.envision.envservice.rest.UserCasePriseResource.java

@POST
@Path("/cancel/{caseId}")
@Produces(MediaType.APPLICATION_JSON)/*from   ww w . j a  v  a 2  s  .c o m*/
public Response cancelPrise(@PathParam("caseId") int caseId) throws Exception {
    HttpStatus status = HttpStatus.ACCEPTED;
    String response = StringUtils.EMPTY;

    userCasePriseService.cancelPrise(caseId);

    return Response.status(status.value()).entity(response).build();
}

From source file:com.envision.envservice.rest.CourseResource.java

@POST
@Path("/arrange/{courseId}")
@Produces(MediaType.APPLICATION_JSON)/*  w w  w .j  av a 2s  .  c  om*/
public Response arrange(@PathParam("courseId") int courseId) throws ServiceException {
    HttpStatus status = HttpStatus.CREATED;
    String response = StringUtils.EMPTY;

    courseService.arrange(courseId);

    return Response.status(status.value()).entity(response).build();
}

From source file:br.com.modoagil.asr.rest.support.ResponseBuilder.java

/**
 * Ajusta a mensagem de reposta com a propriedade {@code status}
 *
 * @param status/*from ww w.j a  v  a 2 s  .com*/
 *            {@link HttpStatus}
 * @return {@link Response}
 */
public ResponseBuilder<E> status(final HttpStatus status) {
    ReflectionUtil.setField(this.response, "status",
            status == null ? HttpStatus.EXPECTATION_FAILED.value() : status.value());
    return this;
}

From source file:eu.modaclouds.sla.service.rest.AbstractSLARest.java

protected MessageResponse createMessage(HttpStatus status, String text) {
    MessageResponse message = new MessageResponse();
    message.setCode(status.value());
    message.setMessage(text);/*from   w  w w.  j  a v  a 2 s.c  o  m*/
    return message;
}