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.github.wnameless.spring.papertrail.test.jpa.JpaTestController.java

@RequestMapping(value = "/after", method = RequestMethod.POST)
@ResponseBody
@ResponseStatus(HttpStatus.CREATED)
String after() {
    return "after";
}

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

/**
 * Adds a new Project to the Projects repository
 *
 * @param project//from   w w  w  . j  a va  2s. co m
 * @return project
 */
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public Project create(@RequestBody @Valid Project project) {
    log.info("Adding Project: " + project.getName());
    return projectManagement.add(project);
}

From source file:technology.tikal.ventas.service.pedimento.PedimentoBatchService.java

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

From source file:net.cpollet.shoppist.web.controller.ProductsController.java

@RequestMapping(value = "/api/v1/products", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody/*from  w w w. j  ava 2 s.c  om*/
public RestResponse createProduct(@RequestBody @Valid Product product) {
    product.setId(null);
    productRepository.save(product);

    return RestResponseBuilder.aRestResponse() //
            .withObject(product) //
            .build();
}

From source file:com.vividcode.imap.server.controller.UserController.java

@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody/*from   ww w .j  a  va2  s. com*/
public ValidatedResponse create(@RequestBody @Valid UserVO user) {
    userService.createUser(user);
    return new ValidatedResponse();
}

From source file:technology.tikal.accounts.service.imp.LoginServiceImp.java

@Override
@RequestMapping(produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public SessionInfo login(@Valid @RequestBody AuthenticationRequest request, BindingResult result) {
    if (result.hasErrors()) {
        throw new NotValidException(result);
    }/*from w  w  w.ja va  2  s  . c  o m*/
    return accountsController.createSession(request);
}

From source file:com.tsg.cms.StaticPageController.java

@RequestMapping(value = "/staticPage", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody//w w w  . jav  a  2 s  .c o m
public StaticPage createStaticPage(@RequestBody StaticPage staticPage) {

    if (staticPage.getCategoryIdFK() == -1) {
        staticPage.setCategoryIdFK(null);
    }
    if (staticPage.getStatus() == null) {
        staticPage.setStatus(Status.DRAFT);
    }

    staticPage.setUserIdFK(999);
    return staticPageDao.addStaticPage(staticPage);

}

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

/**
 * Adds a new VNF software VNFFG to the vnfForwardingGraphDescriptor repository
 *
 * @param vnfForwardingGraphDescriptor : VNFFG to add
 * @return vnfForwardingGraphDescriptor: The vnfForwardingGraphDescriptor filled with values from
 * the core/*from  w ww. j  a  v a 2s.c o m*/
 */
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public VNFForwardingGraphDescriptor create(
        @RequestBody @Valid VNFForwardingGraphDescriptor vnfForwardingGraphDescriptor) {
    return vnffgManagement.add(vnfForwardingGraphDescriptor);
}

From source file:com.tsguild.pumpingunitdb.controller.HomeController.java

@RequestMapping(value = "/unit", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody/*w w  w.j  a  v a2 s.  co m*/
public Unit createUnit(@Valid @RequestBody Unit unit) {

    dao.addUnit(unit);

    return unit;
}

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

/**
 * Adds a new VNF software Image to the image repository
 *
 * @param virtualNetworkFunctionDescriptor : VirtualNetworkFunctionDescriptor to add
 * @return VirtualNetworkFunctionDescriptor: The VirtualNetworkFunctionDescriptor filled with
 * values from the core/*from  w w  w .j  a va  2s  . c o  m*/
 */
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public VirtualNetworkFunctionDescriptor create(
        @RequestBody @Valid VirtualNetworkFunctionDescriptor virtualNetworkFunctionDescriptor,
        @RequestHeader(value = "project-id") String projectId) {
    return vnfdManagement.add(virtualNetworkFunctionDescriptor, projectId);
}