use of com.dubion.domain.Country in project dubion by valsamiq.
the class CountryResource method createCountry.
/**
* POST /countries : Create a new country.
*
* @param country the country to create
* @return the ResponseEntity with status 201 (Created) and with body the new country, or with status 400 (Bad Request) if the country has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/countries")
@Timed
public ResponseEntity<Country> createCountry(@RequestBody Country country) throws URISyntaxException {
log.debug("REST request to save Country : {}", country);
if (country.getId() != null) {
throw new BadRequestAlertException("A new country cannot already have an ID", ENTITY_NAME, "idexists");
}
Country result = countryRepository.save(country);
return ResponseEntity.created(new URI("/api/countries/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.dubion.domain.Country in project dubion by valsamiq.
the class CountryResource method getCountry.
/**
* GET /countries/:id : get the "id" country.
*
* @param id the id of the country to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the country, or with status 404 (Not Found)
*/
@GetMapping("/countries/{id}")
@Timed
public ResponseEntity<Country> getCountry(@PathVariable Long id) {
log.debug("REST request to get Country : {}", id);
Country country = countryRepository.findOne(id);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(country));
}
use of com.dubion.domain.Country in project dubion by valsamiq.
the class CountryResource method updateCountry.
/**
* PUT /countries : Updates an existing country.
*
* @param country the country to update
* @return the ResponseEntity with status 200 (OK) and with body the updated country,
* or with status 400 (Bad Request) if the country is not valid,
* or with status 500 (Internal Server Error) if the country couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/countries")
@Timed
public ResponseEntity<Country> updateCountry(@RequestBody Country country) throws URISyntaxException {
log.debug("REST request to update Country : {}", country);
if (country.getId() == null) {
return createCountry(country);
}
Country result = countryRepository.save(country);
return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, country.getId().toString())).body(result);
}
Aggregations