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.envision.envservice.rest.AssessmentCyclesResource.java

@GET
@Path("/addAssessmentCycles")
@Produces(MediaType.APPLICATION_JSON)//w ww .ja va 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:org.avidj.zuul.rs.ZuulTest.java

@Test
public void itShallCreateShallowWriteLockOnRoot() {
    final Zuul zuul = createZuul();
    given().standaloneSetup(zuul).param("t", "w").param("s", "s").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("WRITE")).and().body("scope", hasItem("SHALLOW")).and()
            .body("count", hasItem(1));
}

From source file:org.openbaton.autoscaling.api.RestExecutionInterface.java

/**
 * Activates autoscaling for the passed NSR
 *
 * @param msg : NSR in payload to add for autoscaling
 *//* w  w  w  . j a va 2  s  . c om*/
@RequestMapping(value = "INSTANTIATE_FINISH", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public void activate(@RequestBody String msg) throws NotFoundException {
    log.debug("========================");
    log.debug("msg=" + msg);
    JsonParser jsonParser = new JsonParser();
    JsonObject json = jsonParser.parse(msg).getAsJsonObject();
    Gson mapper = new GsonBuilder().create();
    Action action = mapper.fromJson(json.get("action"), Action.class);
    log.debug("ACTION=" + action);
    NetworkServiceRecord nsr = mapper.fromJson(json.get("payload"), NetworkServiceRecord.class);
    log.debug("NSR=" + nsr);
    //        detectionEngine.activate(nsr);
}

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

@GET
@Path("/addEvaluationPeriod")
@Produces(MediaType.APPLICATION_JSON)/*from  ww  w . java 2  s.c  o  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.tribuo.backend.controllers.SucursalesController.java

/**
 *
 * @param p//from  w  w w.  j a  v  a 2 s  .  c om
 * @return
 */
@RequestMapping(value = "/insert", method = RequestMethod.POST)
public ResponseEntity<Void> insertSucursal(@RequestBody Sucursales p) {
    se.createSucursal(p);
    return new ResponseEntity<>(HttpStatus.CREATED);
}

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

@RequestMapping(method = RequestMethod.POST, value = "", consumes = ApplicationMediaType.TYPE_VALUE, produces = ApplicationMediaType.TYPE_VALUE)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody/*from   w w  w.  java2  s .co m*/
Type create(@RequestBody TypeInput typeInput) {
    return this.typeRepository.create(typeInput.getName(), typeInput.getShortName());
}

From source file:net.smktarunabhakti.penjualan.ui.controller.BarangController.java

@RequestMapping(value = "/barang", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public void create(@RequestBody @Valid Barang x, HttpServletRequest request, HttpServletResponse response) {
    appService.simpanBarang(x);//  w  ww.ja  v a  2 s.c o  m
    String requesturl = request.getRequestURL().toString();
    URI uri = new UriTemplate("{requestUrl}/{id}").expand(requesturl, x.getId());
    response.setHeader("location", uri.toASCIIString());
}

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

@RequestMapping(value = "/users", method = RequestMethod.PUT)
ResponseEntity<User> updateUser(@RequestBody User user) {
    if (!userStore.userExists(user.getName())) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }//from w  w  w. ja v  a  2s  .  c om
    setPassword(user);
    userStore.save(user);
    return new ResponseEntity<>(user, HttpStatus.CREATED);
}

From source file:edu.eci.arsw.msgbroker.STOMPMessagesHandler.java

@RequestMapping(value = "/puntos", method = RequestMethod.POST)
public ResponseEntity<?> manejadorPostRecursoXX(@RequestBody Point pt) {
    try {/*from w w  w.  j a  v a  2 s  . c  o m*/
        //registrar dato
        agregarPunto(pt);
        msgt.convertAndSend("/topic/newpoint", pt);
        return new ResponseEntity<>(HttpStatus.CREATED);
    } catch (Exception ex) {
        Logger.getLogger(STOMPMessagesHandler.class.getName()).log(Level.SEVERE, null, ex);
        return new ResponseEntity<>("Error bla bla bla", HttpStatus.FORBIDDEN);
    }
}

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

@RequestMapping(method = RequestMethod.POST)
@Transactional(readOnly = false)//from  w  w  w . j  av  a  2 s .c o  m
public ResponseEntity<Void> saveItem(@RequestBody @Valid Item item) {
    Integer lastCode = itemRepository.findLastCode();
    String code = "M-" + String.format("%08d", (lastCode + 1));
    item.setCode(code);
    item = itemRepository.save(item);
    URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(item.getId())
            .toUri();
    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(location);
    return new ResponseEntity<>(headers, HttpStatus.CREATED);
}