Search in sources :

Example 11 with BadRequestAlertException

use of com.dubion.web.rest.errors.BadRequestAlertException in project dubion by valsamiq.

the class BandResource method createBand.

/**
 * POST  /bands : Create a new band.
 *
 * @param band the band to create
 * @return the ResponseEntity with status 201 (Created) and with body the new band, or with status 400 (Bad Request) if the band has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/bands")
@Timed
public ResponseEntity<Band> createBand(@RequestBody Band band) throws URISyntaxException {
    log.debug("REST request to save Band : {}", band);
    if (band.getId() != null) {
        throw new BadRequestAlertException("A new band cannot already have an ID", ENTITY_NAME, "idexists");
    }
    Band result = bandService.save(band);
    return ResponseEntity.created(new URI("/api/band/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : BadRequestAlertException(com.dubion.web.rest.errors.BadRequestAlertException) Band(com.dubion.domain.Band) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 12 with BadRequestAlertException

use of com.dubion.web.rest.errors.BadRequestAlertException 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);
}
Also used : BadRequestAlertException(com.dubion.web.rest.errors.BadRequestAlertException) Country(com.dubion.domain.Country) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 13 with BadRequestAlertException

use of com.dubion.web.rest.errors.BadRequestAlertException in project dubion by valsamiq.

the class RatingSongResource method createRatingSong.

/**
 * POST  /rating-songs : Create a new ratingSong.
 *
 * @param ratingSong the ratingSong to create
 * @return the ResponseEntity with status 201 (Created) and with body the new ratingSong, or with status 400 (Bad Request) if the ratingSong has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/rating-songs")
@Timed
public ResponseEntity<RatingSong> createRatingSong(@RequestBody RatingSong ratingSong) throws URISyntaxException {
    log.debug("REST request to save RatingSong : {}", ratingSong);
    if (ratingSong.getId() != null) {
        throw new BadRequestAlertException("A new ratingSong cannot already have an ID", ENTITY_NAME, "idexists");
    }
    RatingSong result = ratingSongRepository.save(ratingSong);
    return ResponseEntity.created(new URI("/api/rating-songs/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : BadRequestAlertException(com.dubion.web.rest.errors.BadRequestAlertException) RatingSong(com.dubion.domain.RatingSong) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 14 with BadRequestAlertException

use of com.dubion.web.rest.errors.BadRequestAlertException in project dubion by valsamiq.

the class ReviewResource method createReview.

/**
 * POST  /reviews : Create a new review.
 *
 * @param review the review to create
 * @return the ResponseEntity with status 201 (Created) and with body the new review, or with status 400 (Bad Request) if the review has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/reviews")
@Timed
public ResponseEntity<Review> createReview(@RequestBody Review review) throws URISyntaxException {
    log.debug("REST request to save Review : {}", review);
    if (review.getId() != null) {
        throw new BadRequestAlertException("A new review cannot already have an ID", ENTITY_NAME, "idexists");
    }
    Review result = reviewRepository.save(review);
    return ResponseEntity.created(new URI("/api/reviews/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : BadRequestAlertException(com.dubion.web.rest.errors.BadRequestAlertException) Review(com.dubion.domain.Review) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 15 with BadRequestAlertException

use of com.dubion.web.rest.errors.BadRequestAlertException in project dubion by valsamiq.

the class SexResource method createSex.

/**
 * POST  /sexes : Create a new sex.
 *
 * @param sex the sex to create
 * @return the ResponseEntity with status 201 (Created) and with body the new sex, or with status 400 (Bad Request) if the sex has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/sexes")
@Timed
public ResponseEntity<Sex> createSex(@RequestBody Sex sex) throws URISyntaxException {
    log.debug("REST request to save Sex : {}", sex);
    if (sex.getId() != null) {
        throw new BadRequestAlertException("A new sex cannot already have an ID", ENTITY_NAME, "idexists");
    }
    Sex result = sexRepository.save(sex);
    return ResponseEntity.created(new URI("/api/sexes/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : BadRequestAlertException(com.dubion.web.rest.errors.BadRequestAlertException) Sex(com.dubion.domain.Sex) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)24 BadRequestAlertException (com.dubion.web.rest.errors.BadRequestAlertException)24 URI (java.net.URI)24 Album (com.dubion.domain.Album)1 Alpha (com.dubion.domain.Alpha)1 Artist (com.dubion.domain.Artist)1 Band (com.dubion.domain.Band)1 BandPrueba (com.dubion.domain.BandPrueba)1 Beta (com.dubion.domain.Beta)1 Country (com.dubion.domain.Country)1 FavouriteAlbum (com.dubion.domain.FavouriteAlbum)1 FavouriteBand (com.dubion.domain.FavouriteBand)1 FavouriteSong (com.dubion.domain.FavouriteSong)1 Gamma (com.dubion.domain.Gamma)1 Genre (com.dubion.domain.Genre)1 Instrument (com.dubion.domain.Instrument)1 Label (com.dubion.domain.Label)1 RatingAlbum (com.dubion.domain.RatingAlbum)1 RatingArtist (com.dubion.domain.RatingArtist)1 RatingBand (com.dubion.domain.RatingBand)1