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:com.tsguild.upsproject.controller.HomeController.java

@ResponseBody
@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(value = "/plane", method = RequestMethod.POST)
public Plane createPlane(@RequestBody Plane incomingPlane) {
    dao.addPlane(incomingPlane);/*from   ww  w  . j a  v  a  2  s. c o  m*/
    return incomingPlane;
}

From source file:edu.eci.cosw.restcontrollers.RestControladorCalificarEstablecimiento.java

@RequestMapping(value = "/", method = RequestMethod.POST)
public ResponseEntity<?> registrarCalificacionEstablecimiento(@RequestBody Calificacion calificacion) {
    logica.calificarEstablecimiento(calificacion.getEnsayo().getCliente().getIdCliente(),
            calificacion.getEnsayo().getIdEnsayo(), calificacion.getCalificacionEstablecimiento(),
            calificacion.getDescripcion());
    return new ResponseEntity<>(HttpStatus.CREATED);
}

From source file:de.codecentric.boot.admin.controller.RegistryControllerTest.java

@Test
public void register() {
    ResponseEntity<Application> response = controller.register(new Application("http://localhost", "test"));
    assertEquals(HttpStatus.CREATED, response.getStatusCode());
    assertEquals("http://localhost", response.getBody().getUrl());
    assertEquals("test", response.getBody().getName());
}

From source file:edu.eci.cosw.restcontrollers.RestControladorRegistrarReserva.java

@RequestMapping(value = "/registrors", method = RequestMethod.POST)
public ResponseEntity<?> registrarReserva(@RequestBody Reservacion r) {
    HttpStatus hs;/*from w ww . j a v  a2  s .co  m*/
    String mens = "";
    try {
        mens = logica.registrarReserva(r.getSala().getEstablecimiento().getIdEstablecimiento(),
                r.getSala().getIdSala(), r.getFecha(), r.getHora(), r.getTiempo());
        hs = HttpStatus.CREATED;
    } catch (Exception ex) {
        mens = ex.getMessage();
        hs = HttpStatus.ALREADY_REPORTED;
    }
    //retorna el estado 201 en caso de que la operacin haya sido exitosa
    return new ResponseEntity<>(mens, hs);
}

From source file:org.openbaton.nfvo.api.RestConfiguration.java

/**
 * Adds a new Configuration to the Configurations repository
 *
 * @param configuration//from  w  w w. j a v  a2  s  .c o m
 * @return configuration
 */
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public Configuration create(@RequestBody @Valid Configuration configuration,
        @RequestHeader(value = "project-id", required = false) String projectId) {
    log.trace("Adding Configuration: " + configuration);
    configuration.setProjectId(projectId);
    log.debug("Adding Configuration");
    return configurationManagement.add(configuration);
}

From source file:com.arya.latihan.controller.SalesOrderController.java

@RequestMapping(method = RequestMethod.POST)
@Transactional(readOnly = false)/*from  www .ja v  a  2s .  c  om*/
public ResponseEntity<SalesOrder> saveSalesOrder(@Valid SalesOrder salesOrder) {
    salesOrder = salesOrderRepository.save(salesOrder);
    URI uri = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(salesOrder.getId())
            .toUri();
    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(uri);
    return new ResponseEntity<SalesOrder>(headers, HttpStatus.CREATED);
}

From source file:net.eusashead.hateoas.response.impl.PostResponseBuilderImplTest.java

@Test
public void testBuildUri() throws Exception {
    ResponseEntity<Void> response = builder.location("/url/to/entity").build();
    Assert.assertNotNull(response);/*from   www .j a va  2 s .  com*/
    Assert.assertEquals(HttpStatus.CREATED, response.getStatusCode());
    Assert.assertNull(response.getBody());
    Assert.assertNotNull(response.getHeaders().getLocation());
    Assert.assertEquals(new URI("/url/to/entity"), response.getHeaders().getLocation());
    Assert.assertNull(response.getHeaders().getETag());
    Assert.assertEquals(-1l, response.getHeaders().getLastModified());
    Assert.assertNull(response.getHeaders().getCacheControl());
    Assert.assertEquals(-1l, response.getHeaders().getExpires());
    Assert.assertEquals(-1l, response.getHeaders().getDate());
}

From source file:com.nebhale.cyclinglibrary.web.CollectionController.java

@RequestMapping(method = RequestMethod.POST, value = "", consumes = ApplicationMediaType.COLLECTION_VALUE, produces = ApplicationMediaType.COLLECTION_VALUE)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody/*w w  w  .j av  a 2 s  . c o  m*/
Collection create(@PathVariable Long typeId, @RequestBody CollectionInput collectionInput) {
    return this.collectionRepository.create(typeId, collectionInput.getName(), collectionInput.getShortName());
}

From source file:com.musala.controller.SitesController.java

@RequestMapping(value = { "/", "" }, method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.CREATED)
@ResponseBody//  w w  w.j a va 2 s .c o m
public SiteView create(@RequestBody SiteView site) {
    return conversionService.convert(siteService.save(site), SiteView.class);
}

From source file:com.arya.latihan.controller.CustomerController.java

@RequestMapping(method = RequestMethod.POST)
@Transactional(readOnly = false)/* ww w . ja  v  a  2s .  com*/
public ResponseEntity<Customer> saveCustomer(@Valid Customer customer) {
    customer = customerRepository.save(customer);
    URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}")
            .buildAndExpand(customer.getId()).toUri();
    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(location);
    return new ResponseEntity<Customer>(headers, HttpStatus.CREATED);
}