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);
}
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);
}
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);
}
}
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);
}
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);
}
Aggregations