use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.
the class MovieResource method createMovie.
/**
* POST /movies : Create a new movie.
*
* @param movie the movie to create
* @return the ResponseEntity with status 201 (Created) and with body the new movie, or with status 400 (Bad Request) if the movie has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/movies")
@Timed
public ResponseEntity<Movie> createMovie(@RequestBody Movie movie) throws URISyntaxException {
log.debug("REST request to save Movie : {}", movie);
if (movie.getId() != null) {
throw new BadRequestAlertException("A new movie cannot already have an ID", ENTITY_NAME, "idexists");
}
Movie result = movieRepository.save(movie);
return ResponseEntity.created(new URI("/api/movies/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.
the class MovieStatsResource method createMovieStats.
/**
* POST /movie-stats : Create a new movieStats.
*
* @param movieStats the movieStats to create
* @return the ResponseEntity with status 201 (Created) and with body the new movieStats, or with status 400 (Bad Request) if the movieStats has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/movie-stats")
@Timed
public ResponseEntity<MovieStats> createMovieStats(@RequestBody MovieStats movieStats) throws URISyntaxException {
log.debug("REST request to save MovieStats : {}", movieStats);
if (movieStats.getId() != null) {
throw new BadRequestAlertException("A new movieStats cannot already have an ID", ENTITY_NAME, "idexists");
}
Optional<MovieStats> aux = movieStatsRepository.findByUserAndMovieId(userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get(), movieStats.getMovie().getId());
if (aux.isPresent())
movieStats.setId(aux.get().getId());
movieStats.setUser(userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get());
movieStats.setDate(ZonedDateTime.now());
MovieStats result = movieStatsRepository.save(movieStats);
return ResponseEntity.created(new URI("/api/movie-stats/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.
the class AchievementsAchievsResource method createAchievementsAchievs.
/**
* POST /achievements-achievs : Create a new achievementsAchievs.
*
* @param achievementsAchievs the achievementsAchievs to create
* @return the ResponseEntity with status 201 (Created) and with body the new achievementsAchievs, or with status 400 (Bad Request) if the achievementsAchievs has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/achievements-achievs")
@Timed
public ResponseEntity<AchievementsAchievs> createAchievementsAchievs(@RequestBody AchievementsAchievs achievementsAchievs) throws URISyntaxException {
log.debug("REST request to save AchievementsAchievs : {}", achievementsAchievs);
if (achievementsAchievs.getId() != null) {
throw new BadRequestAlertException("A new achievementsAchievs cannot already have an ID", ENTITY_NAME, "idexists");
}
AchievementsAchievs result = achievementsAchievsRepository.save(achievementsAchievs);
return ResponseEntity.created(new URI("/api/achievements-achievs/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.
the class ArtistResource method findArtistByArtistType.
@GetMapping("/artist-types-name/{artistTypeStr}")
@Timed
public ResponseEntity<List<Artist>> findArtistByArtistType(@PathVariable String artistTypeStr) {
log.debug("REST request to get ArtistType : {}", artistTypeStr);
try {
ArtistTypeEnum ate = ArtistTypeEnum.valueOf(artistTypeStr.toUpperCase());
ArtistType artistType = artistTypeRepository.findByName(ate);
List<Artist> artists = artistRepository.findArtistByArtistType(artistType);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(artists));
} catch (IllegalArgumentException e) {
throw new BadRequestAlertException(e.getMessage(), ENTITY_NAME, e.getLocalizedMessage());
}
}
use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.
the class ReviewMovieResource method createReviewMovie.
/**
* POST /review-movies : Create a new reviewMovie.
*
* @param reviewMovie the reviewMovie to create
* @return the ResponseEntity with status 201 (Created) and with body the new reviewMovie, or with status 400 (Bad Request) if the reviewMovie has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/review-movies")
@Timed
public ResponseEntity<ReviewMovie> createReviewMovie(@RequestBody ReviewMovie reviewMovie) throws URISyntaxException {
log.debug("REST request to save ReviewMovie : {}", reviewMovie);
if (reviewMovie.getId() != null) {
throw new BadRequestAlertException("A new reviewMovie cannot already have an ID", ENTITY_NAME, "idexists");
}
reviewMovie.setDate(ZonedDateTime.now());
reviewMovie.setUser(userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get());
ReviewMovie result = reviewMovieRepository.save(reviewMovie);
return ResponseEntity.created(new URI("/api/review-movies/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Aggregations