use of io.micronaut.scheduling.annotation.ExecuteOn in project Building-Microservices-with-Micronaut by PacktPublishing.
the class OwnerResource method updateOwner.
/**
* {@code PUT /owners} : Updates an existing owner.
*
* @param ownerDTO the ownerDTO to update.
* @return the {@link HttpResponse} with status {@code 200 (OK)} and with body the updated ownerDTO,
* or with status {@code 400 (Bad Request)} if the ownerDTO is not valid,
* or with status {@code 500 (Internal Server Error)} if the ownerDTO couldn't be updated.
* @throws URISyntaxException if the Location URI syntax is incorrect.
*/
@Put("/owners")
@ExecuteOn(TaskExecutors.IO)
@ContinueSpan
public HttpResponse<OwnerDTO> updateOwner(@Body OwnerDTO ownerDTO) throws URISyntaxException {
log.debug("REST request to update Owner : {}", ownerDTO);
if (ownerDTO.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
OwnerDTO result = ownerService.save(ownerDTO);
return HttpResponse.ok(result).headers(headers -> HeaderUtil.createEntityUpdateAlert(headers, applicationName, true, ENTITY_NAME, ownerDTO.getId().toString()));
}
use of io.micronaut.scheduling.annotation.ExecuteOn in project Building-Microservices-with-Micronaut by PacktPublishing.
the class PetResource method updatePet.
/**
* {@code PUT /pets} : Updates an existing pet.
*
* @param petDTO the petDTO to update.
* @return the {@link HttpResponse} with status {@code 200 (OK)} and with body the updated petDTO,
* or with status {@code 400 (Bad Request)} if the petDTO is not valid,
* or with status {@code 500 (Internal Server Error)} if the petDTO couldn't be updated.
* @throws URISyntaxException if the Location URI syntax is incorrect.
*/
@Put("/pets")
@ExecuteOn(TaskExecutors.IO)
@ContinueSpan
public HttpResponse<PetDTO> updatePet(@Body PetDTO petDTO) throws URISyntaxException {
log.debug("REST request to update Pet : {}", petDTO);
if (petDTO.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
PetDTO result = petService.save(petDTO);
return HttpResponse.ok(result).headers(headers -> HeaderUtil.createEntityUpdateAlert(headers, applicationName, true, ENTITY_NAME, petDTO.getId().toString()));
}
use of io.micronaut.scheduling.annotation.ExecuteOn in project Building-Microservices-with-Micronaut by PacktPublishing.
the class PetResource method createPet.
/**
* {@code POST /pets} : Create a new pet.
*
* @param petDTO the petDTO to create.
* @return the {@link HttpResponse} with status {@code 201 (Created)} and with body the new petDTO, or with status {@code 400 (Bad Request)} if the pet has already an ID.
* @throws URISyntaxException if the Location URI syntax is incorrect.
*/
@Post("/pets")
@ExecuteOn(TaskExecutors.IO)
@ContinueSpan
public HttpResponse<PetDTO> createPet(@Body PetDTO petDTO) throws URISyntaxException {
log.debug("REST request to save Pet : {}", petDTO);
if (petDTO.getId() != null) {
throw new BadRequestAlertException("A new pet cannot already have an ID", ENTITY_NAME, "idexists");
}
PetDTO result = petService.save(petDTO);
URI location = new URI("/api/pets/" + result.getId());
return HttpResponse.created(result).headers(headers -> {
headers.location(location);
HeaderUtil.createEntityCreationAlert(headers, applicationName, true, ENTITY_NAME, result.getId().toString());
});
}
use of io.micronaut.scheduling.annotation.ExecuteOn in project Building-Microservices-with-Micronaut by PacktPublishing.
the class PetTypeResource method createPetType.
/**
* {@code POST /pet-types} : Create a new petType.
*
* @param petTypeDTO the petTypeDTO to create.
* @return the {@link HttpResponse} with status {@code 201 (Created)} and with body the new petTypeDTO, or with status {@code 400 (Bad Request)} if the petType has already an ID.
* @throws URISyntaxException if the Location URI syntax is incorrect.
*/
@Post("/pet-types")
@ExecuteOn(TaskExecutors.IO)
@ContinueSpan
public HttpResponse<PetTypeDTO> createPetType(@Body PetTypeDTO petTypeDTO) throws URISyntaxException {
log.debug("REST request to save PetType : {}", petTypeDTO);
if (petTypeDTO.getId() != null) {
throw new BadRequestAlertException("A new petType cannot already have an ID", ENTITY_NAME, "idexists");
}
PetTypeDTO result = petTypeService.save(petTypeDTO);
URI location = new URI("/api/pet-types/" + result.getId());
return HttpResponse.created(result).headers(headers -> {
headers.location(location);
HeaderUtil.createEntityCreationAlert(headers, applicationName, true, ENTITY_NAME, result.getId().toString());
});
}
use of io.micronaut.scheduling.annotation.ExecuteOn in project Building-Microservices-with-Micronaut by PacktPublishing.
the class VisitResource method createVisit.
/**
* {@code POST /visits} : Create a new visit.
*
* @param visitDTO the visitDTO to create.
* @return the {@link HttpResponse} with status {@code 201 (Created)} and with body the new visitDTO, or with status {@code 400 (Bad Request)} if the visit has already an ID.
* @throws URISyntaxException if the Location URI syntax is incorrect.
*/
@Post("/visits")
@ExecuteOn(TaskExecutors.IO)
@ContinueSpan
public HttpResponse<VisitDTO> createVisit(@Body VisitDTO visitDTO) throws URISyntaxException {
log.debug("REST request to save Visit : {}", visitDTO);
if (visitDTO.getId() != null) {
throw new BadRequestAlertException("A new visit cannot already have an ID", ENTITY_NAME, "idexists");
}
VisitDTO result = visitService.save(visitDTO);
URI location = new URI("/api/visits/" + result.getId());
return HttpResponse.created(result).headers(headers -> {
headers.location(location);
HeaderUtil.createEntityCreationAlert(headers, applicationName, true, ENTITY_NAME, result.getId().toString());
});
}
Aggregations