org.springframework.http.ResponseEntity.created()

Here are the examples of the java api org.springframework.http.ResponseEntity.created() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

422 Examples 7

19 Source : MemberController.java
with MIT License
from woowacourse-teams

@PostMapping
public ResponseEnreplacedy<Void> createMember(@RequestBody @Valid final MemberCreateRequest memberCreateRequest) {
    final MemberResponse memberResponse = memberService.createMember(memberCreateRequest);
    return ResponseEnreplacedy.created(URI.create("/api/members/" + memberResponse.getId())).build();
}

19 Source : IndividualController.java
with MIT License
from Robinyo

@PostMapping("/individuals")
@PreAuthorize("hasAuthority('SCOPE_individual:post')")
public ResponseEnreplacedy<IndividualModel> create(@RequestBody Individual individual) throws ResponseStatusException {
    log.info("IndividualController POST /individuals");
    try {
        Individual enreplacedy = repository.save(individual);
        IndividualModel model = replacedembler.toModel(enreplacedy);
        logInfo(enreplacedy, model);
        return ResponseEnreplacedy.created(linkTo(methodOn(IndividualController.clreplaced).findById(enreplacedy.getId())).toUri()).body(model);
    } catch (Exception e) {
        log.error("{}", e.getLocalizedMessage());
        throw new ResponseStatusException(HttpStatus.BAD_REQUEST);
    }
}

19 Source : UserController.java
with MIT License
from gauravrmazra

@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEnreplacedy<ResponseVO<User>> createUser(@RequestBody User user) {
    User savedUser = userService.save(user);
    return ResponseEnreplacedy.created(URI.create("/" + savedUser.getUserId())).body(new ResponseVO<>(savedUser));
}

19 Source : DataSourceController.java
with Apache License 2.0
from etrace-io

@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation("新增数据源")
public ResponseEnreplacedy create(@RequestBody MetricDataSource metricDataSource) throws Exception {
    try {
        Long id = dataSourceService.create(metricDataSource);
        return ResponseEnreplacedy.created(new URI("/datasource/" + id)).body(id);
    } catch (Exception e) {
        throw new BadRequestException("新增数据源异常:" + e.getMessage());
    }
}

19 Source : MetaProjectController.java
with Apache License 2.0
from cai3178940

@Override
@PostMapping(value = "/save")
@ResponseStatus(HttpStatus.CREATED)
public ResponseEnreplacedy<MetaProjectShowVO> save(@Valid @RequestBody MetaProjectAddDTO metaProjectAddDTO) throws Exception {
    MetaProjectPO metaProjectPO = metaProjectService.save(metaProjectAddDTO);
    return ResponseEnreplacedy.created(new URI(apiPath + "/meta_project/" + metaProjectPO.getProjectId())).body(MetaProjectMapper.INSTANCE.toShowVO(metaProjectPO));
}

19 Source : MetaChartSourceController.java
with Apache License 2.0
from cai3178940

@Override
@PostMapping(value = "/with_items")
@ResponseStatus(HttpStatus.CREATED)
public ResponseEnreplacedy<MetaChartSourceShowVO> saveWithItems(@Valid @RequestBody MetaChartSourceWithItemsAddDTO addDTO) throws Exception {
    MetaChartSourcePO metaChartSource = metaChartSourceService.saveWithItems(addDTO);
    return ResponseEnreplacedy.created(new URI(apiPath + "/meta_chart_source/" + metaChartSource.getSourceId())).body(MetaChartSourceMapper.INSTANCE.toShowVO(metaChartSource));
}

19 Source : MetaChartSourceController.java
with Apache License 2.0
from cai3178940

@Override
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public ResponseEnreplacedy<MetaChartSourceShowVO> save(@Valid @RequestBody MetaChartSourceAddDTO metaChartSourceAddDTO) throws Exception {
    MetaChartSourcePO metaChartSource = metaChartSourceService.save(metaChartSourceAddDTO);
    return ResponseEnreplacedy.created(new URI(apiPath + "/meta_chart_source/" + metaChartSource.getSourceId())).body(MetaChartSourceMapper.INSTANCE.toShowVO(metaChartSource));
}

19 Source : ApiSpringSubResource.java
with MIT License
from avraampiperidis

@RequestMapping(method = RequestMethod.POST)
@Override
public ResponseEnreplacedy<D> createEnreplacedy(@RequestBody D enreplacedy) {
    return ResponseEnreplacedy.created(super.getNewPathSpring(super.create(enreplacedy))).build();
}

19 Source : ApiSpringResource.java
with MIT License
from avraampiperidis

@RequestMapping(method = RequestMethod.POST)
@Override
public ResponseEnreplacedy<T> createEnreplacedy(@RequestBody T enreplacedy) {
    return ResponseEnreplacedy.created(super.getNewPathSpring(super.baseCreate(enreplacedy))).body(enreplacedy);
}

19 Source : ApiSpringOneToOneResource.java
with MIT License
from avraampiperidis

@RequestMapping(method = RequestMethod.POST)
@Override
public ResponseEnreplacedy<D> createEnreplacedy(@RequestBody D enreplacedy) {
    if (super.getDetail() != null) {
        throw new EnreplacedyExistsException();
    }
    return ResponseEnreplacedy.created(super.getNewPathSpring(super.create(enreplacedy))).build();
}

18 Source : UserController.java
with MIT License
from woowacourse-teams

@NoValidate
@PostMapping
public ResponseEnreplacedy<Long> saveUser(@Valid @RequestBody UserCreateRequest request) {
    Long userId = userService.saveWithoutOAuthId(request);
    return ResponseEnreplacedy.created(URI.create(String.format("/api/users/%d", userId))).body(userId);
}

18 Source : RiderController.java
with MIT License
from woowacourse-teams

@PostMapping
public ResponseEnreplacedy<Void> create(@LoginMember final MemberResponse member, @Valid @RequestBody final RiderCreateRequest riderCreateRequest) {
    return ResponseEnreplacedy.created(URI.create("/api/riders/" + riderService.create(member, riderCreateRequest))).build();
}

18 Source : CertificationController.java
with MIT License
from woowacourse-teams

@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEnreplacedy<Void> create(@RequestPart(value = "certification_image") final MultipartFile file, @Valid final CertificationRequest certificationRequest, @LoginMember final MemberResponse memberResponse) {
    final Long certificationId = certificationService.create(file, certificationRequest);
    return ResponseEnreplacedy.created(URI.create(String.format("/api/certifications/%d", certificationId))).build();
}

18 Source : CustomerController.java
with Apache License 2.0
from wkorando

@PostMapping(consumes = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
public ResponseEnreplacedy<?> createNewCustomer(@RequestBody Customer customer) throws URISyntaxException {
    try {
        Customer newCustomer = service.saveCustomer(customer);
        return ResponseEnreplacedy.created(new URI("/customers/" + newCustomer.getId())).build();
    } catch (RoomServiceException e) {
        return ResponseEnreplacedy.badRequest().body(new ErrorResponse(e.getErrorMessages()));
    }
}

18 Source : ConnectionResource.java
with Apache License 2.0
from viz-centric

/**
 * POST  /connections : Create a new connection.
 *
 * @param connectionDTO the connectionDTO to create
 * @return the ResponseEnreplacedy with status 201 (Created) and with body the new connectionDTO, or with status 400 (Bad Request) if the connection has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/connections")
@Timed
public ResponseEnreplacedy<ConnectionDTO> createConnection(@Valid @RequestBody ConnectionDTO connectionDTO) throws URISyntaxException {
    log.debug("REST request to save Connection : {}", connectionDTO);
    if (connectionDTO.getId() != null) {
        return ResponseEnreplacedy.badRequest().headers(HeaderUtil.createFailureAlert(ENreplacedY_NAME, "idexists", "A new connection cannot already have an ID")).body(null);
    }
    ConnectionDTO result = connectionService.save(connectionDTO);
    return ResponseEnreplacedy.created(new URI("/api/connections/" + result.getId())).headers(HeaderUtil.createEnreplacedyCreationAlert(ENreplacedY_NAME, result.getId().toString())).body(result);
}

18 Source : WebFluxMovieController.java
with Apache License 2.0
from toedter

@PostMapping("/movies")
public Mono<ResponseEnreplacedy<?>> newMovie(@RequestBody Mono<EnreplacedyModel<Movie>> movie) {
    return movie.flatMap(resource -> {
        int newMovieId = MOVIES.size() + 1;
        replacedert resource.getContent() != null;
        resource.getContent().setId("" + newMovieId);
        MOVIES.put(newMovieId, resource.getContent());
        return findOne(newMovieId);
    }).map(findOne -> ResponseEnreplacedy.created(findOne.getRequiredLink(IreplacedinkRelations.SELF).toUri()).build());
}

18 Source : ClocksController.java
with Apache License 2.0
from ticktok-io

private ResponseEnreplacedy<ClockResource> createdClockEnreplacedy(Clock clock, TickChannel channel) {
    ClockResource resource = clockResourceFactory.createWithChannel(clock, channel);
    return ResponseEnreplacedy.created(withAuthToken(resource.getLink("self").get().getHref(), userPrincipal())).body(resource);
}

18 Source : EmployeeController.java
with Apache License 2.0
from spring-projects

@PostMapping("/employees")
public ResponseEnreplacedy<EnreplacedyModel<Employee>> newEmployee(@RequestBody Employee employee) {
    Employee savedEmployee = repository.save(employee);
    return // 
    ResponseEnreplacedy.created(// 
    savedEmployee.getId().map(// 
    id -> linkTo(methodOn(EmployeeController.clreplaced).findOne(id)).toUri()).orElseThrow(// 
    () -> new RuntimeException("Failed to create for some reason"))).body(replacedembler.toModel(savedEmployee));
}

18 Source : AbstractRestController.java
with GNU Affero General Public License v3.0
from spacious-team

/**
 * @return response enreplacedy with http CREATE status, Location http header and body
 */
private ResponseEnreplacedy<Void> createEnreplacedy(Pojo object) throws URISyntaxException {
    Enreplacedy enreplacedy = saveAndFlush(object);
    return ResponseEnreplacedy.created(getLocationURI(converter.fromEnreplacedy(enreplacedy))).build();
}

18 Source : OrganisationController.java
with MIT License
from Robinyo

@PostMapping("/organisations")
public ResponseEnreplacedy<OrganisationModel> create(@RequestBody Organisation organisation) throws ResponseStatusException {
    log.info("OrganisationController POST /organisations");
    try {
        Organisation enreplacedy = repository.save(organisation);
        OrganisationModel model = replacedembler.toModel(enreplacedy);
        logInfo(enreplacedy, model);
        return ResponseEnreplacedy.created(linkTo(methodOn(OrganisationController.clreplaced).findById(enreplacedy.getId())).toUri()).body(model);
    } catch (Exception e) {
        log.error("{}", e.getLocalizedMessage());
        throw new ResponseStatusException(HttpStatus.BAD_REQUEST);
    }
}

18 Source : InvestorController.java
with MIT License
from PacktPublishing

@PatchMapping("/investors/{investorId}/stocks/{symbol}")
public ResponseEnreplacedy<Void> updateAStockOfTheInvestorPortfolio(@PathVariable String investorId, @PathVariable String symbol, @RequestBody Stock stockTobeUpdated) {
    Stock updatedStock = investorService.updateAStockByInvestorIdAndStock(investorId, symbol, stockTobeUpdated);
    if (updatedStock == null) {
        return ResponseEnreplacedy.noContent().build();
    }
    URI location = ServletUriComponentsBuilder.fromCurrentRequest().path(ID).buildAndExpand(updatedStock.getSymbol()).toUri();
    return ResponseEnreplacedy.created(location).build();
}

18 Source : RatingResource.java
with MIT License
from ls1intum

/**
 * Persist a new Rating
 *
 * @param resultId    - Id of result that is referenced with the rating that should be persisted
 * @param ratingValue - Value of the updated rating
 * @return inserted Rating
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/results/{resultId}/rating/{ratingValue}")
@PreAuthorize("hasAnyRole('USER', 'TA', 'INSTRUCTOR', 'ADMIN')")
public ResponseEnreplacedy<Rating> createRatingForResult(@PathVariable Long resultId, @Valid @PathVariable @Min(value = 1, message = "rating has to be between 1 and 5") @Max(value = 5, message = "rating has to be between 1 and 5") Integer ratingValue) throws URISyntaxException {
    if (!checkIfUserIsOwnerOfSubmission(resultId)) {
        return forbidden();
    }
    Rating savedRating = ratingService.saveRating(resultId, ratingValue);
    return ResponseEnreplacedy.created(new URI("/api/results/" + savedRating.getId() + "/rating")).body(savedRating);
}

18 Source : TodoController.java
with MIT License
from kchrusciel

@PutMapping("/{id}")
public ResponseEnreplacedy<Void> updateTodo(@RequestBody Todo todo, @PathVariable Long id) throws TodoNotFound {
    Todo todoById = todoService.getTodoById(id);
    if (todoById == null) {
        todoService.addNewTodo(todo);
        return ResponseEnreplacedy.created(URI.create(String.format("/todos/%d", id))).build();
    }
    todoService.update(todo);
    return ResponseEnreplacedy.noContent().build();
}

18 Source : ProductController.java
with MIT License
from gauravrmazra

@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEnreplacedy<ResponseVO<Product>> create(@RequestBody Product product) {
    Product savedProduct = productService.save(product);
    return ResponseEnreplacedy.created(URI.create("/" + product.getId())).body(new ResponseVO<>(savedProduct));
}

18 Source : ActionItemController.java
with Apache License 2.0
from FordLabs

@PostMapping("/api/team/{teamId}/action-item")
@PreAuthorize("@apiAuthorization.requestIsAuthorized(authentication, #teamId)")
@ApiOperation(value = "Creates an action item given a team id", notes = "createActionItemForTeam")
@ApiResponses(value = { @ApiResponse(code = 201, message = "Created", response = ResponseEnreplacedy.clreplaced) })
public ResponseEnreplacedy createActionItemForTeam(@PathVariable("teamId") String teamId, @RequestBody ActionItem actionItem) throws URISyntaxException {
    actionItem.setTeamId(teamId);
    ActionItem savedActionItem = actionItemRepository.save(actionItem);
    URI savedActionItemUri = new URI("/api/team/" + teamId + "/action-item/" + savedActionItem.getId());
    return ResponseEnreplacedy.created(savedActionItemUri).build();
}

18 Source : MetaMtmCascadeExtController.java
with Apache License 2.0
from cai3178940

@Override
@PostMapping(value = "/save")
@ResponseStatus(HttpStatus.CREATED)
public ResponseEnreplacedy<MetaMtmCascadeExtShowVO> save(@Valid @RequestBody MetaMtmCascadeExtAddDTO metaMtmCascadeExtAddDTO) throws Exception {
    MetaMtmCascadeExtPO metaMtmCascadeExt = metaMtmCascadeExtService.save(metaMtmCascadeExtAddDTO);
    return ResponseEnreplacedy.created(new URI(apiPath + "/metaMtmCascadeExt/" + metaMtmCascadeExt.getMtmCascadeExtId())).body(MetaMtmCascadeExtMapper.INSTANCE.toShowVO(metaMtmCascadeExt));
}

18 Source : MetaManyToManyController.java
with Apache License 2.0
from cai3178940

@Override
@PostMapping(value = "/save")
@ResponseStatus(HttpStatus.CREATED)
public ResponseEnreplacedy<MetaManyToManyShowVO> save(@Valid @RequestBody MetaManyToManyAddDTO metaManyToManyAddDTO) throws Exception {
    MetaManyToManyPO metaManyToManyPO = metaManyToManyService.save(metaManyToManyAddDTO);
    return ResponseEnreplacedy.created(new URI(apiPath + "/meta_mtm/" + metaManyToManyPO.getMtmId())).body(MetaManyToManyMapper.INSTANCE.toShowVO(metaManyToManyPO));
}

18 Source : MetaIndexController.java
with Apache License 2.0
from cai3178940

@Override
@PostMapping(value = "/save")
@ResponseStatus(HttpStatus.CREATED)
public ResponseEnreplacedy<MetaIndexShowVO> save(@Valid @RequestBody MetaIndexAddDTO metaIndexAddDTO) throws Exception {
    MetaIndexPO metaIndex = metaIndexService.save(metaIndexAddDTO);
    return ResponseEnreplacedy.created(new URI(apiPath + "/meta_index/" + metaIndex.getIndexId())).body(MetaIndexMapper.INSTANCE.toShowVO(metaIndex));
}

18 Source : MetaConstController.java
with Apache License 2.0
from cai3178940

@Override
@PostMapping(value = "/save")
@ResponseStatus(HttpStatus.CREATED)
public ResponseEnreplacedy<MetaConstShowVO> save(@Valid @RequestBody MetaConstAddDTO metaConstAddDTO) throws Exception {
    MetaConstPO metaConstPO = metaConstService.save(metaConstAddDTO);
    return ResponseEnreplacedy.created(new URI(apiPath + "/meta_const/" + metaConstPO.getConstId())).body(MetaConstMapper.INSTANCE.toShowVO(metaConstPO));
}

18 Source : CodeTemplateController.java
with Apache License 2.0
from cai3178940

@Override
@PostMapping(value = "/{templateId}/copy")
@ResponseStatus(HttpStatus.CREATED)
public ResponseEnreplacedy<CodeTemplateShowVO> copy(@PathVariable Integer templateId) throws Exception {
    CodeTemplatePO codeTemplate = codeTemplatereplacedembleAndCopyService.copyCodeTemplate(templateId);
    return ResponseEnreplacedy.created(new URI(apiPath + "/code_template/" + codeTemplate.getTemplateId())).body(CodeTemplateMapper.INSTANCE.toShowVO(codeTemplate));
}

18 Source : MetaDashboardController.java
with Apache License 2.0
from cai3178940

@Override
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public ResponseEnreplacedy<MetaDashboardShowVO> save(@Valid @RequestBody MetaDashboardAddDTO metaDashboardAddDTO) throws Exception {
    MetaDashboardPO metaDashboard = metaDashboardService.save(metaDashboardAddDTO);
    return ResponseEnreplacedy.created(new URI(apiPath + "/meta_dashboard/" + metaDashboard.getDashboardId())).body(MetaDashboardMapper.INSTANCE.toShowVO(metaDashboard));
}

18 Source : BookRestController.java
with Apache License 2.0
from andifalk

@PostMapping
public ResponseEnreplacedy<BookModel> createBook(@RequestBody @Valid BookModel bookModel, HttpServletRequest request) {
    Book book = bookService.save(new Book(bookModel.getIsbn(), bookModel.getreplacedle(), bookModel.getDescription(), bookModel.getAuthors()));
    URI uri = ServletUriComponentsBuilder.fromServletMapping(request).path("/books/" + book.getIdentifier()).build().toUri();
    return ResponseEnreplacedy.created(uri).body(bookModelreplacedembler.toModel(book));
}

17 Source : ProductResource.java
with Apache License 2.0
from xebialabs

/**
 * POST  /products : Create a new product.
 *
 * @param product the product to create
 * @return the ResponseEnreplacedy with status 201 (Created) and with body the new product, or with status 400 (Bad Request) if the product has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/products")
@Timed
public ResponseEnreplacedy<Product> createProduct(@Valid @RequestBody Product product) throws URISyntaxException {
    log.debug("REST request to save Product : {}", product);
    if (product.getId() != null) {
        throw new BadRequestAlertException("A new product cannot already have an ID", ENreplacedY_NAME, "idexists");
    }
    Product result = productService.save(product);
    return ResponseEnreplacedy.created(new URI("/api/products/" + result.getId())).headers(HeaderUtil.createEnreplacedyCreationAlert(ENreplacedY_NAME, result.getId().toString())).body(result);
}

17 Source : ProductOrderResource.java
with Apache License 2.0
from xebialabs

/**
 * POST  /product-orders : Create a new productOrder.
 *
 * @param productOrder the productOrder to create
 * @return the ResponseEnreplacedy with status 201 (Created) and with body the new productOrder, or with status 400 (Bad Request) if the productOrder has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/product-orders")
@Timed
public ResponseEnreplacedy<ProductOrder> createProductOrder(@Valid @RequestBody ProductOrder productOrder) throws URISyntaxException {
    log.debug("REST request to save ProductOrder : {}", productOrder);
    if (productOrder.getId() != null) {
        throw new BadRequestAlertException("A new productOrder cannot already have an ID", ENreplacedY_NAME, "idexists");
    }
    ProductOrder result = productOrderService.save(productOrder);
    return ResponseEnreplacedy.created(new URI("/api/product-orders/" + result.getId())).headers(HeaderUtil.createEnreplacedyCreationAlert(ENreplacedY_NAME, result.getId().toString())).body(result);
}

17 Source : OrderItemResource.java
with Apache License 2.0
from xebialabs

/**
 * POST  /order-items : Create a new orderItem.
 *
 * @param orderItem the orderItem to create
 * @return the ResponseEnreplacedy with status 201 (Created) and with body the new orderItem, or with status 400 (Bad Request) if the orderItem has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/order-items")
@Timed
public ResponseEnreplacedy<OrderItem> createOrderItem(@Valid @RequestBody OrderItem orderItem) throws URISyntaxException {
    log.debug("REST request to save OrderItem : {}", orderItem);
    if (orderItem.getId() != null) {
        throw new BadRequestAlertException("A new orderItem cannot already have an ID", ENreplacedY_NAME, "idexists");
    }
    OrderItem result = orderItemService.save(orderItem);
    return ResponseEnreplacedy.created(new URI("/api/order-items/" + result.getId())).headers(HeaderUtil.createEnreplacedyCreationAlert(ENreplacedY_NAME, result.getId().toString())).body(result);
}

17 Source : ShipmentResource.java
with Apache License 2.0
from xebialabs

/**
 * POST  /shipments : Create a new shipment.
 *
 * @param shipment the shipment to create
 * @return the ResponseEnreplacedy with status 201 (Created) and with body the new shipment, or with status 400 (Bad Request) if the shipment has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/shipments")
@Timed
public ResponseEnreplacedy<Shipment> createShipment(@Valid @RequestBody Shipment shipment) throws URISyntaxException {
    log.debug("REST request to save Shipment : {}", shipment);
    if (shipment.getId() != null) {
        throw new BadRequestAlertException("A new shipment cannot already have an ID", ENreplacedY_NAME, "idexists");
    }
    Shipment result = shipmentService.save(shipment);
    return ResponseEnreplacedy.created(new URI("/api/shipments/" + result.getId())).headers(HeaderUtil.createEnreplacedyCreationAlert(ENreplacedY_NAME, result.getId().toString())).body(result);
}

17 Source : InvoiceResource.java
with Apache License 2.0
from xebialabs

/**
 * POST  /invoices : Create a new invoice.
 *
 * @param invoice the invoice to create
 * @return the ResponseEnreplacedy with status 201 (Created) and with body the new invoice, or with status 400 (Bad Request) if the invoice has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/invoices")
@Timed
public ResponseEnreplacedy<Invoice> createInvoice(@Valid @RequestBody Invoice invoice) throws URISyntaxException {
    log.debug("REST request to save Invoice : {}", invoice);
    if (invoice.getId() != null) {
        throw new BadRequestAlertException("A new invoice cannot already have an ID", ENreplacedY_NAME, "idexists");
    }
    Invoice result = invoiceService.save(invoice);
    return ResponseEnreplacedy.created(new URI("/api/invoices/" + result.getId())).headers(HeaderUtil.createEnreplacedyCreationAlert(ENreplacedY_NAME, result.getId().toString())).body(result);
}

17 Source : RaceController.java
with MIT License
from woowacourse-teams

@PostMapping
public ResponseEnreplacedy<Void> create(@Valid @RequestBody final RaceCreateRequest request) {
    final Long id = raceService.create(request);
    return ResponseEnreplacedy.created(URI.create(String.format("/api/races/%d", id))).build();
}

17 Source : WebMvcMovieController.java
with Apache License 2.0
from toedter

@PostMapping("/movies")
public ResponseEnreplacedy<?> newMovie(@RequestBody EnreplacedyModel<Movie> movie) {
    int newMovieId = MOVIES.size() + 1;
    String newMovieIdString = "" + newMovieId;
    Movie movieContent = movie.getContent();
    replacedert movieContent != null;
    movieContent.setId(newMovieIdString);
    MOVIES.put(newMovieId, movieContent);
    Link link = linkTo(methodOn(getClreplaced()).findOne(newMovieId)).withSelfRel().expand();
    return ResponseEnreplacedy.created(link.toUri()).build();
}

17 Source : WebFluxMovieController.java
with Apache License 2.0
from toedter

@PostMapping("/moviesWithDirectors")
public Mono<ResponseEnreplacedy<?>> newMovieWithDirectors(@RequestBody Mono<EnreplacedyModel<MovieWithDirectors>> movie) {
    return movie.flatMap(resource -> {
        int newMovieId = MOVIES.size() + 1;
        replacedert resource.getContent() != null;
        resource.getContent().setId("" + newMovieId);
        MOVIES.put(newMovieId, resource.getContent());
        return findOne(newMovieId);
    }).map(findOne -> ResponseEnreplacedy.created(findOne.getRequiredLink(IreplacedinkRelations.SELF).toUri()).build());
}

17 Source : TeamResource.java
with MIT License
from tillias

/**
 * {@code POST  /teams} : Create a new team.
 *
 * @param team the team to create.
 * @return the {@link ResponseEnreplacedy} with status {@code 201 (Created)} and with body the new team, or with status {@code 400 (Bad Request)} if the team has already an ID.
 * @throws URISyntaxException if the Location URI syntax is incorrect.
 */
@PostMapping("/teams")
public ResponseEnreplacedy<Team> createTeam(@Valid @RequestBody Team team) throws URISyntaxException {
    log.debug("REST request to save Team : {}", team);
    if (team.getId() != null) {
        throw new BadRequestAlertException("A new team cannot already have an ID", ENreplacedY_NAME, "idexists");
    }
    Team result = teamRepository.save(team);
    return ResponseEnreplacedy.created(new URI("/api/teams/" + result.getId())).headers(HeaderUtil.createEnreplacedyCreationAlert(applicationName, true, ENreplacedY_NAME, result.getId().toString())).body(result);
}

17 Source : StatusResource.java
with MIT License
from tillias

/**
 * {@code POST  /statuses} : Create a new status.
 *
 * @param status the status to create.
 * @return the {@link ResponseEnreplacedy} with status {@code 201 (Created)} and with body the new status, or with status {@code 400 (Bad Request)} if the status has already an ID.
 * @throws URISyntaxException if the Location URI syntax is incorrect.
 */
@PostMapping("/statuses")
public ResponseEnreplacedy<Status> createStatus(@Valid @RequestBody Status status) throws URISyntaxException {
    log.debug("REST request to save Status : {}", status);
    if (status.getId() != null) {
        throw new BadRequestAlertException("A new status cannot already have an ID", ENreplacedY_NAME, "idexists");
    }
    Status result = statusRepository.save(status);
    return ResponseEnreplacedy.created(new URI("/api/statuses/" + result.getId())).headers(HeaderUtil.createEnreplacedyCreationAlert(applicationName, true, ENreplacedY_NAME, result.getId().toString())).body(result);
}

17 Source : MicroserviceResource.java
with MIT License
from tillias

/**
 * {@code POST  /microservices} : Create a new microservice.
 *
 * @param microservice the microservice to create.
 * @return the {@link ResponseEnreplacedy} with status {@code 201 (Created)} and with body the new microservice, or with status {@code 400 (Bad Request)} if the microservice has already an ID.
 * @throws URISyntaxException if the Location URI syntax is incorrect.
 */
@PostMapping("/microservices")
public ResponseEnreplacedy<Microservice> createMicroservice(@Valid @RequestBody Microservice microservice) throws URISyntaxException {
    log.debug("REST request to save Microservice : {}", microservice);
    if (microservice.getId() != null) {
        throw new BadRequestAlertException("A new microservice cannot already have an ID", ENreplacedY_NAME, "idexists");
    }
    Microservice result = microserviceRepository.save(microservice);
    return ResponseEnreplacedy.created(new URI("/api/microservices/" + result.getId())).headers(HeaderUtil.createEnreplacedyCreationAlert(applicationName, true, ENreplacedY_NAME, result.getId().toString())).body(result);
}

17 Source : OrderController.java
with Apache License 2.0
from teixeira-fernando

/**
 * Creates a new order.
 *
 * @param order The order to create.
 * @return The created order.
 */
@PostMapping("/order")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Expected order to a valid request", response = Product.clreplaced), @ApiResponse(code = 400, message = "There is a problem with the request parameters", response = Error.clreplaced), @ApiResponse(code = 500, message = "unexpected server error", response = Error.clreplaced) })
public ResponseEnreplacedy<Order> createOrder(@RequestBody OrderDto orderDto) {
    logger.info("Creating new order");
    try {
        // Create the new order
        Order newOrder = orderService.createOrder(orderDto);
        // Build a created response
        return ResponseEnreplacedy.created(new URI("/order/" + newOrder.getId())).body(newOrder);
    } catch (InvalidParameterException e) {
        return new ResponseEnreplacedy("A product included in the Order was not found in the inventory or there is not enough stock", HttpStatus.BAD_REQUEST);
    } catch (EmptyOrderException e) {
        return new ResponseEnreplacedy("The order does not contain any product", HttpStatus.BAD_REQUEST);
    } catch (StockUpdateException e) {
        return new ResponseEnreplacedy("Something went wrong when trying to communicate with the inventory service", HttpStatus.SERVICE_UNAVAILABLE);
    } catch (URISyntaxException e) {
        return ResponseEnreplacedy.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }
}

17 Source : PeopleRestService.java
with Apache License 2.0
from springdoc

@PostMapping(value = "/{email}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(description = "Create new person", responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = PersonDTO.clreplaced), mediaType = MediaType.APPLICATION_JSON_VALUE), headers = @Header(name = "Location"), responseCode = "201"), @ApiResponse(responseCode = "409", description = "Person with such e-mail already exists") })
public ResponseEnreplacedy<String> addPerson(@Parameter(description = "E-Mail", required = true) @PathVariable("email") final String email, @Parameter(description = "First Name", required = true) @RequestParam("firstName") final String firstName, @Parameter(description = "Last Name", required = true) @RequestParam("lastName") final String lastName) {
    final PersonDTO person = people.get(email);
    if (person != null) {
        return ResponseEnreplacedy.status(HttpStatus.CONFLICT).body("Person with such e-mail already exists");
    }
    people.put(email, new PersonDTO(email, firstName, lastName));
    final URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(UUID.randomUUID()).toUri();
    return ResponseEnreplacedy.created(location).build();
}

17 Source : EmployeeController.java
with Apache License 2.0
from spring-projects

@PostMapping("/employees")
public ResponseEnreplacedy<EnreplacedyModel<Employee>> newEmployee(@RequestBody Employee employee) {
    Employee savedEmployee = repository.save(employee);
    return // 
    savedEmployee.getId().map(id -> // 
    ResponseEnreplacedy.created(linkTo(methodOn(EmployeeController.clreplaced).findOne(id)).toUri()).body(replacedembler.toModel(savedEmployee))).orElse(ResponseEnreplacedy.notFound().build());
}

17 Source : UserController.java
with MIT License
from rieckpil

@PostMapping
public ResponseEnreplacedy<Void> createNewUser(@RequestBody @Valid User user, UriComponentsBuilder uriComponentsBuilder) {
    this.userService.storeNewUser(user);
    return ResponseEnreplacedy.created(uriComponentsBuilder.path("/api/users/{username}").build(user.getUsername())).build();
}

17 Source : CustomerController.java
with MIT License
from rieckpil

@PostMapping
public ResponseEnreplacedy<Void> createNewCustomer(@RequestBody Customer request, UriComponentsBuilder uriComponentsBuilder) {
    return ResponseEnreplacedy.created(uriComponentsBuilder.path("/api/customers/{id}").buildAndExpand("42").toUri()).build();
}

17 Source : InvestorController.java
with MIT License
from PacktPublishing

@PostMapping("/investors/{investorId}/stocks")
public ResponseEnreplacedy<Void> addNewStockToTheInvestorPortfolio(@PathVariable String investorId, @RequestBody Stock newStock) {
    Stock insertedStock = investorService.addNewStockToTheInvestorPortfolio(investorId, newStock);
    if (insertedStock == null) {
        return ResponseEnreplacedy.noContent().build();
    }
    URI location = ServletUriComponentsBuilder.fromCurrentRequest().path(ID).buildAndExpand(insertedStock.getSymbol()).toUri();
    return ResponseEnreplacedy.created(location).build();
}

17 Source : InvestorController.java
with MIT License
from PacktPublishing

@PutMapping("/investors/{investorId}/stocks")
public ResponseEnreplacedy<Void> updateAStockOfTheInvestorPortfolio(@PathVariable String investorId, @RequestBody Stock stockTobeUpdated) {
    Stock updatedStock = investorService.updateAStockByInvestorIdAndStock(investorId, stockTobeUpdated);
    if (updatedStock == null) {
        return ResponseEnreplacedy.noContent().build();
    }
    URI location = ServletUriComponentsBuilder.fromCurrentRequest().path(ID).buildAndExpand(updatedStock.getSymbol()).toUri();
    return ResponseEnreplacedy.created(location).build();
}

See More Examples