Example usage for org.springframework.http HttpStatus CREATED

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

Introduction

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

Prototype

HttpStatus CREATED

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

Click Source Link

Document

201 Created .

Usage

From source file:technology.tikal.ventas.service.almacen.SalidaService.java

@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public void crear(@PathVariable final Long pedidoId, @Valid @RequestBody final RegistroAlmacenTransient request,
        final BindingResult result, final HttpServletRequest httpRequest,
        final HttpServletResponse httpResponse) {
    if (result.hasErrors()) {
        throw new NotValidException(result);
    }//  w  w  w .  j  a v a  2 s  . c  om
    Salida nuevo = salidaController.crear(pedidoId, request);
    httpResponse.setHeader("Location", httpRequest.getRequestURI() + "/" + nuevo.getId());
}

From source file:plbtw.klmpk.barang.hilang.controller.LogController.java

@RequestMapping(method = RequestMethod.POST, produces = "application/json")
public CustomResponseMessage addLog(@RequestBody LogRequest logRequest) {
    try {//from  w ww .  j a va 2 s.  c  om
        Log log = new Log();
        log.setId(logRequest.getIdLog());
        log.setTimeRequest(logRequest.getTime_request());
        log.setStatus("");

        return new CustomResponseMessage(HttpStatus.CREATED, "Add Log berhasil");
    } catch (Exception ex) {
        return new CustomResponseMessage(HttpStatus.BAD_REQUEST, ex.toString());
    }

}

From source file:io.curly.gathering.mention.MentionController.java

@RequestMapping(value = "", method = { RequestMethod.PUT, RequestMethod.POST })
public Callable<HttpEntity<?>> mention(@Valid @RequestBody MentionBody body, @PathVariable String listId,
        @GitHubAuthentication User user, BindingResult bindingResult) {

    if (bindingResult.hasErrors()) {
        return () -> new ResponseEntity<Object>(new ModelErrors(bindingResult), HttpStatus.BAD_REQUEST);
    } else {/* w  ww  .  j a v a 2 s. co  m*/
        return () -> {
            interaction.mention(new Mention(body.getParticipant(), listId), user);
            return new ResponseEntity<>(HttpStatus.CREATED);
        };
    }
}

From source file:com.opensearchserver.hadse.index.IndexTest.java

@Test
public void t02_createDefaultIndex() {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));

    RestTemplate template = new RestTemplate();

    ResponseEntity<String> entity = template.exchange("http://localhost:8080/my_index", HttpMethod.PUT, null,
            String.class);

    assertEquals(HttpStatus.CREATED, entity.getStatusCode());
}

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

@POST
@Path("/arrange/{courseId}")
@Produces(MediaType.APPLICATION_JSON)/*from ww  w  . ja v  a 2s .  c o m*/
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:technology.tikal.ventas.service.almacen.SalidaDevolucionService.java

@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public void crear(@PathVariable final Long pedidoId, @Valid @RequestBody final RegistroAlmacenTransient request,
        final BindingResult result, final HttpServletRequest httpRequest,
        final HttpServletResponse httpResponse) {
    if (result.hasErrors()) {
        throw new NotValidException(result);
    }//  ww  w.ja  va2  s . c  o  m
    SalidaDevolucion nuevo = salidaDevolucionController.crear(pedidoId, request);
    httpResponse.setHeader("Location", httpRequest.getRequestURI() + "/" + nuevo.getId());
}

From source file:technology.tikal.ventas.service.almacen.EntradaDevolucionService.java

@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public void crear(@PathVariable final Long pedidoId, @Valid @RequestBody final RegistroAlmacenTransient request,
        final BindingResult result, final HttpServletRequest httpRequest,
        final HttpServletResponse httpResponse) {
    if (result.hasErrors()) {
        throw new NotValidException(result);
    }// ww w  . java2 s .c  o  m
    EntradaDevolucion nuevo = entradaDevolucionController.crear(pedidoId, request);
    httpResponse.setHeader("Location", httpRequest.getRequestURI() + "/" + nuevo.getId());
}

From source file:com.toptal.controller.SignupController.java

/**
 * Registers new user./*from   w w  w  .  j ava 2 s .c o m*/
 * @param user User.
 * @return Registered user.
 */
@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.CREATED)
public final User register(@RequestBody final User user) {
    this.validateIdAndName(user);
    user.setPassword(SecurityUtils.decode(user.getPassword()));
    final User result = this.dao.save(user);
    log.debug("Registered new user {}", result);
    return result;
}

From source file:com.baidu.terminator.manager.action.StubAction.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/{linkId}", method = RequestMethod.POST)
@ResponseBody//ww  w.  jav a2 s  . c  o m
public ResponseEntity<?> addStubData(@PathVariable int linkId, @Valid @RequestBody StubForm stubForm) {
    List<StubCondition> conditions = stubForm.getConditions();
    String response = stubForm.getResponse();

    StubData stubData = new StubData();
    stubData.setConditions(conditions);
    stubData.setOperator(stubForm.getOperator());
    stubData.setSequence(stubForm.getSequence());
    stubData.setResponse(response);
    stubData.setDelay(stubForm.getDelay());

    stubService.addStubData(linkId, stubData);
    return new ResponseEntity(stubData, HttpStatus.CREATED);
}

From source file:org.avidj.zuul.rs.ZuulTest.java

@Test
public void itShallCreateDeepReadLockOnRoot() {
    final Zuul zuul = createZuul();
    given().standaloneSetup(zuul).param("t", "r").param("s", "d").when().put("/s/1/").then()
            .statusCode(HttpStatus.CREATED.value());
    given().standaloneSetup(zuul).when().get("/s/1/").then().statusCode(HttpStatus.OK.value()).and()
            .body("key", hasItem(Collections.emptyList())).and().body("session", hasItem("1")).and()
            .body("type", hasItem("READ")).and().body("scope", hasItem("DEEP")).and().body("count", hasItem(1));
}