Search in sources :

Example 1 with FavouriteAlbum

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

the class FavouriteAlbumResource method getFavouriteAlbum.

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

Example 2 with FavouriteAlbum

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

the class FavouriteAlbumResource method updateFavouriteAlbum.

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

Example 3 with FavouriteAlbum

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

the class FavouriteAlbumResource method createFavouriteAlbum.

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

Aggregations

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