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:am.ik.categolj2.api.user.UserRestController.java

@RequestMapping(method = RequestMethod.POST, headers = Categolj2Headers.X_ADMIN)
public ResponseEntity<UserResource> postUsers(
        @Validated({ UserResource.Create.class, Default.class }) @RequestBody UserResource userResource) {
    User created = userService.create(beanMapper.map(userResource, User.class), userResource.getPassword());
    return new ResponseEntity<>(beanMapper.map(created, UserResource.class), HttpStatus.CREATED);
}

From source file:fr.esiea.windmeal.controller.crud.CrudProviderCtrl.java

@Secured("ROLE_USER")
@RequestMapping(method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
@ResponseStatus(HttpStatus.CREATED)
public void create(@RequestBody FoodProvider provider) throws ServiceException, DaoException {

    LOGGER.info("[Controller] Querying to create new provider : " + provider.toString() + "\"");
    crudService.insert(provider);/*from  w w  w  .  j ava 2s .com*/
}

From source file:com.springsource.html5expense.controllers.ExpenseController.java

@ResponseBody
@RequestMapping(value = "/expense", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.CREATED)
public Long createNewExpense(@RequestParam("description") String description,
        @RequestParam("amount") Double amount, @RequestParam("expenseTypeId") Long expenseTypeVal) {

    ExpenseType expenseType = expenseTypeService.getExpenseTypeById(expenseTypeVal);
    Expense expense = new Expense(description, expenseType, new Date(), amount);
    Long expenseId = expenseService.save(expense);
    return expenseId;
}

From source file:org.springsource.restbucks.payment.web.PaymentController.java

/**
 * Accepts a payment for an {@link Order}
 *
 * @param order  the {@link Order} to process the payment for. Retrieved from the path variable and converted into an
 *               {@link Order} instance by Spring Data's {@link DomainClassConverter}. Will be {@literal null} in case no
 *               {@link Order} with the given id could be found.
 * @param number the {@link CreditCardNumber} unmarshaled from the request payload.
 * @return/*from ww w. ja v a  2  s  . c  o m*/
 */
@RequestMapping(path = PaymentLinks.PAYMENT, method = PUT)
ResponseEntity<?> submitPayment(@PathVariable("id") Order order, @RequestBody CreditCardNumber number) {

    if (order == null || order.isPaid()) {
        return ResponseEntity.notFound().build();
    }

    CreditCardPayment payment = paymentService.pay(order, number);

    PaymentResource resource = new PaymentResource(order.getPrice(), payment.getCreditCard());
    resource.add(entityLinks.linkToSingleResource(order));

    return new ResponseEntity<>(resource, HttpStatus.CREATED);
}

From source file:io.github.microcks.web.JobController.java

@RequestMapping(value = "/jobs", method = RequestMethod.POST)
public ResponseEntity<ImportJob> createJob(@RequestBody ImportJob job) {
    log.debug("Creating new job: {}", job);
    job.setCreatedDate(new Date());
    return new ResponseEntity<>(jobRepository.save(job), HttpStatus.CREATED);
}

From source file:fr.esiea.esieaddress.controllers.crud.CrudContactCtrl.java

@Secured("ROLE_USER")
@RequestMapping(method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
@ResponseStatus(HttpStatus.CREATED)
public void create(@RequestBody Contact contact) throws ServiceException, DaoException {

    LOGGER.info("[Controller] Querying to create new contact : " + contact.toString() + "\"");
    crudService.insert(contact);/*from  w  w w  .  j  a  v a2s.  co  m*/
}

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

@RequestMapping(method = RequestMethod.DELETE, produces = "application/json")
public CustomResponseMessage deleteRole(@RequestBody RoleRequest roleRequest) {
    try {//from w  ww .  ja  va  2  s  .c  om
        roleService.deleteRole(roleRequest.getId());
        return new CustomResponseMessage(HttpStatus.CREATED, "Detele Successfull");
    } catch (Exception ex) {
        return new CustomResponseMessage(HttpStatus.BAD_REQUEST, ex.toString());
    }
}

From source file:no.ndla.taxonomy.service.SwaggerConfiguration.java

@Bean
public Docket api() {
    return new Docket(DocumentationType.SWAGGER_2).select()
            .apis(RequestHandlerSelectors.basePackage("no.ndla.taxonomy.service.rest.v1"))
            .paths(PathSelectors.regex("/v1/.*")).build().pathMapping("/").apiInfo(apiInfo())
            .securitySchemes(newArrayList(oauth())).securityContexts(newArrayList(securityContext()))
            .directModelSubstitute(URI.class, String.class).useDefaultResponseMessages(false)
            .produces(newHashSet(APPLICATION_JSON_UTF8.toString()))
            .consumes(newHashSet(APPLICATION_JSON_UTF8.toString()))
            .globalResponseMessage(RequestMethod.GET,
                    newArrayList(new ResponseMessageBuilder().code(HttpStatus.OK.value())
                            .message(HttpStatus.OK.getReasonPhrase()).build()))
            .globalResponseMessage(RequestMethod.PUT,
                    newArrayList(/*from  w w  w .  j a  va 2s .co m*/
                            new ResponseMessageBuilder().code(NO_CONTENT.value())
                                    .message(NO_CONTENT.getReasonPhrase()).build(),
                            new ResponseMessageBuilder().code(NOT_FOUND.value())
                                    .message(NOT_FOUND.getReasonPhrase()).build()))
            .globalResponseMessage(DELETE,
                    newArrayList(
                            new ResponseMessageBuilder().code(NO_CONTENT.value())
                                    .message(NO_CONTENT.getReasonPhrase()).build(),
                            new ResponseMessageBuilder().code(NOT_FOUND.value())
                                    .message(NOT_FOUND.getReasonPhrase()).build()))
            .globalResponseMessage(RequestMethod.POST,
                    newArrayList(
                            new ResponseMessageBuilder().code(HttpStatus.CREATED.value())
                                    .message(CREATED.getReasonPhrase())
                                    .headersWithDescription(singletonMap(LOCATION.toString(),
                                            new Header("Location", "Path to created resource",
                                                    new ModelRef("URI"))))
                                    .build(),
                            new ResponseMessageBuilder().code(HttpStatus.CONFLICT.value())
                                    .message(CONFLICT.getReasonPhrase()).build()));
}

From source file:com.epam.ta.reportportal.ws.controller.impl.WidgetController.java

@Override
@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody//from  www  .  j  a v  a 2 s.c  o  m
@ApiOperation("Create new widget")
public EntryCreatedRS createWidget(@PathVariable String projectName,
        @RequestBody @Validated(WidgetRQCustomValidator.class) WidgetRQ createWidgetRQ, Principal principal) {
    return createHandler.createWidget(createWidgetRQ, EntityUtils.normalizeProjectName(projectName),
            principal.getName());
}

From source file:de.sainth.recipe.backend.rest.controller.UserController.java

@Secured("ROLE_ADMIN")
@RequestMapping(method = RequestMethod.POST)
HttpEntity<User> add(@Valid @RequestBody User user) {
    User u = repository.save(user);/*from   w w  w .  ja va 2s. c om*/
    return new ResponseEntity<>(u, HttpStatus.CREATED);
}