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.tsg.cms.BlogPostController.java

@RequestMapping(value = "/blogPost", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody/* w  w  w  .j  ava2s .co  m*/
public BlogPostContainer createBlogPost(@RequestBody BlogPost blogPost) {

    blogPost.setUserIdFK(999);
    return blogPostDao.addBlogPost(blogPost);

}

From source file:com.tribuo.backend.controllers.VentasController.java

/**
 *
 * @param p//from w w  w  .j ava  2s.  com
 * @return
 */
@RequestMapping(value = "/insert", method = RequestMethod.POST)
public ResponseEntity<Void> insertUsuario(@RequestBody Ventas p) {
    se.registerVenta(p);
    return new ResponseEntity<>(HttpStatus.CREATED);
}

From source file:org.openbaton.vnfm.api.RestApplication.java

/**
 * Adds a new VNF software Image to the image repository
 *
 * @param application : Application to add
 * @param vnfrId : ID of VNFR to add the App
 * @return Application: The Application filled with values from the core
 *///  w  w w  . j av a2s .  co m
@RequestMapping(value = "", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public Application create(@PathVariable("vnfrId") String vnfrId, @RequestBody Application application)
        throws NotFoundException {
    application.setVnfr_id(vnfrId);
    application = applicationManagement.add(application);
    return application;
}

From source file:io.pivotal.ecosystem.service.HelloControllerTest.java

@Test
public void testIt() {
    ResponseEntity<String> greeting = helloController.greeting(USER);
    assertNotNull(greeting);//ww w  .ja v a 2s.c o m
    assertEquals("Sorry, I don't think we've met.", greeting.getBody());
    assertEquals(HttpStatus.UNAUTHORIZED, greeting.getStatusCode());

    ResponseEntity<User> in = helloController.createUser(new User(USER, ROLE));

    assertNotNull(in);
    assertEquals(HttpStatus.CREATED, in.getStatusCode());
    User u = in.getBody();
    assertNotNull(u);
    assertEquals(USER, u.getName());
    assertNotNull(u.getPassword());

    greeting = helloController.greeting(USER);
    assertNotNull(greeting);
    assertEquals("Hello, foo !", greeting.getBody());
    assertEquals(HttpStatus.OK, greeting.getStatusCode());

    ResponseEntity<Void> out = helloController.deleteUser(USER);
    assertNotNull(out);
    assertEquals(HttpStatus.OK, out.getStatusCode());

    greeting = helloController.greeting(USER);
    assertNotNull(greeting);
    assertEquals("Sorry, I don't think we've met.", greeting.getBody());
    assertEquals(HttpStatus.UNAUTHORIZED, greeting.getStatusCode());
}

From source file:edu.eci.arsw.pacm.controllers.PacmRESTController.java

@RequestMapping(path = "/{salanum}/atacantes", method = RequestMethod.PUT)
public ResponseEntity<?> agregarAtacante(@PathVariable(name = "salanum") String salanum,
        @RequestBody Player p) {/*from  w  w w  .j  a  v a 2 s .  co m*/
    synchronized (services) {
        try {
            if (services.getAtacantes(Integer.parseInt(salanum)).size() < 4) {
                services.registrarJugadorAtacante(Integer.parseInt(salanum), p);
            }

        } catch (ServicesException ex) {
            Logger.getLogger(PacmRESTController.class.getName()).log(Level.SEVERE, null, ex);
            return new ResponseEntity<>(ex.getLocalizedMessage(), HttpStatus.BAD_REQUEST);
        }
        return new ResponseEntity<>(HttpStatus.CREATED);
    }
}

From source file:com.tribuo.backend.controllers.TiendasController.java

/**
 *
 * @param p// w w w . j av a 2s.  co  m
 * @return
 */
@RequestMapping(value = "/insert", method = RequestMethod.POST)
public ResponseEntity<Void> insertTienda(@RequestBody Tiendas p) {
    se.createTienda(p);
    return new ResponseEntity<>(HttpStatus.CREATED);
}

From source file:com.tribuo.backend.controllers.MarcasController.java

/**
 *
 * @param marca/*  ww w  .  j av a2  s  .c  o  m*/
 * @return
 */
@RequestMapping(value = "/insert", method = RequestMethod.POST)
public ResponseEntity<Void> insertMarca(@RequestBody Marcas marca) {
    se.createMarca(marca);
    return new ResponseEntity<>(HttpStatus.CREATED);
}

From source file:org.moserp.product.rest.ProductRestTest.java

@Test
public void createProduct() {
    ResponseEntity<Object> response = restTemplate.postForEntity(testEnvironment.createRestUri("/products"),
            new Product("My Product"), null);
    assertEquals("Status", HttpStatus.CREATED, response.getStatusCode());
    String productUri = response.getHeaders().getLocation().toString();
    assertNotNull("productUri", productUri);
    assertNotNull(productUtil.getByUri(productUri));
}

From source file:com.tribuo.backend.controllers.ComprasController.java

/**
 *
 * @param compra//from  ww  w. j  a va  2 s .  c  om
 * @return
 */
@RequestMapping(value = "/insert", method = RequestMethod.POST)
public ResponseEntity<Void> insertCompra(@RequestBody Compras compra) {
    se.registerCompra(compra);
    return new ResponseEntity<>(HttpStatus.CREATED);
}

From source file:com.seabee.snapdragon.controller.StaticPageController.java

@RequestMapping(value = "/new", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public void addStaticPage(@Valid @RequestBody StaticPage page) {
    // take in a new StaticPage object
    // add to the database
    dao.addStaticPage(page);//from  ww w .j  av a  2 s  .co  m
}