Search in sources :

Example 6 with BadRequestAlertException

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

the class RatingBandResource method createRatingBand.

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

Example 7 with BadRequestAlertException

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

the class SongResource method createSong.

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

Example 8 with BadRequestAlertException

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

the class UserResource method createUser.

/**
 * POST  /users  : Creates a new user.
 * <p>
 * Creates a new user if the login and email are not already used, and sends an
 * mail with an activation link.
 * The user needs to be activated on creation.
 *
 * @param managedUserVM the user to create
 * @return the ResponseEntity with status 201 (Created) and with body the new user, or with status 400 (Bad Request) if the login or email is already in use
 * @throws URISyntaxException if the Location URI syntax is incorrect
 * @throws BadRequestAlertException 400 (Bad Request) if the login or email is already in use
 */
@PostMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<User> createUser(@Valid @RequestBody ManagedUserVM managedUserVM) throws URISyntaxException {
    log.debug("REST request to save User : {}", managedUserVM);
    if (managedUserVM.getId() != null) {
        throw new BadRequestAlertException("A new user cannot already have an ID", "userManagement", "idexists");
    // Lowercase the user login before comparing with database
    } else if (userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase()).isPresent()) {
        throw new LoginAlreadyUsedException();
    } else if (userRepository.findOneByEmailIgnoreCase(managedUserVM.getEmail()).isPresent()) {
        throw new EmailAlreadyUsedException();
    } else {
        User newUser = userService.createUser(managedUserVM);
        mailService.sendCreationEmail(newUser);
        return ResponseEntity.created(new URI("/api/users/" + newUser.getLogin())).headers(HeaderUtil.createAlert("userManagement.created", newUser.getLogin())).body(newUser);
    }
}
Also used : BadRequestAlertException(com.dubion.web.rest.errors.BadRequestAlertException) User(com.dubion.domain.User) LoginAlreadyUsedException(com.dubion.web.rest.errors.LoginAlreadyUsedException) URI(java.net.URI) EmailAlreadyUsedException(com.dubion.web.rest.errors.EmailAlreadyUsedException) Secured(org.springframework.security.access.annotation.Secured) Timed(com.codahale.metrics.annotation.Timed)

Example 9 with BadRequestAlertException

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

the class AlbumResource method createAlbum.

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

Example 10 with BadRequestAlertException

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

the class BandPruebaResource method createBandPrueba.

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