Search in sources :

Example 1 with Band

use of com.dubion.domain.Band 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 2 with Band

use of com.dubion.domain.Band in project dubion by valsamiq.

the class BandResource method getBand.

/**
 * GET  /bands/:id : get the "id" band.
 *
 * @param id the id of the band to retrieve
 * @return the ResponseEntity with status 200 (OK) and with body the band, or with status 404 (Not Found)
 */
@GetMapping("/bands/{id}")
@Timed
public ResponseEntity<Band> getBand(@PathVariable Long id) {
    log.debug("REST request to get Band : {}", id);
    Band band = bandService.findOne(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(band));
}
Also used : Band(com.dubion.domain.Band) Timed(com.codahale.metrics.annotation.Timed)

Example 3 with Band

use of com.dubion.domain.Band in project dubion by valsamiq.

the class BandResource method updateBand.

/**
 * PUT  /bands : Updates an existing band.
 *
 * @param band the band to update
 * @return the ResponseEntity with status 200 (OK) and with body the updated band,
 * or with status 400 (Bad Request) if the band is not valid,
 * or with status 500 (Internal Server Error) if the band couldn't be updated
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PutMapping("/bands")
@Timed
public ResponseEntity<Band> updateBand(@RequestBody Band band) throws URISyntaxException {
    log.debug("REST request to update Band : {}", band);
    if (band.getId() == null) {
        return createBand(band);
    }
    Band result = bandService.save(band);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, band.getId().toString())).body(result);
}
Also used : Band(com.dubion.domain.Band) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)3 Band (com.dubion.domain.Band)3 BadRequestAlertException (com.dubion.web.rest.errors.BadRequestAlertException)1 URI (java.net.URI)1