Search in sources :

Example 21 with BadRequestAlertException

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);
}
Also used : BadRequestAlertException(com.furyviewer.web.rest.errors.BadRequestAlertException) Movie(com.furyviewer.domain.Movie) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 22 with BadRequestAlertException

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);
}
Also used : BadRequestAlertException(com.furyviewer.web.rest.errors.BadRequestAlertException) MovieStats(com.furyviewer.domain.MovieStats) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 23 with BadRequestAlertException

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);
}
Also used : BadRequestAlertException(com.furyviewer.web.rest.errors.BadRequestAlertException) AchievementsAchievs(com.furyviewer.domain.AchievementsAchievs) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 24 with BadRequestAlertException

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());
    }
}
Also used : Artist(com.furyviewer.domain.Artist) BadRequestAlertException(com.furyviewer.web.rest.errors.BadRequestAlertException) ArtistTypeEnum(com.furyviewer.domain.enumeration.ArtistTypeEnum) ArtistType(com.furyviewer.domain.ArtistType) Timed(com.codahale.metrics.annotation.Timed)

Example 25 with BadRequestAlertException

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);
}
Also used : BadRequestAlertException(com.furyviewer.web.rest.errors.BadRequestAlertException) ReviewMovie(com.furyviewer.domain.ReviewMovie) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)28 BadRequestAlertException (com.furyviewer.web.rest.errors.BadRequestAlertException)28 URI (java.net.URI)27 Artist (com.furyviewer.domain.Artist)2 ArtistType (com.furyviewer.domain.ArtistType)2 Achievement (com.furyviewer.domain.Achievement)1 AchievementsAchievs (com.furyviewer.domain.AchievementsAchievs)1 ChapterSeen (com.furyviewer.domain.ChapterSeen)1 Company (com.furyviewer.domain.Company)1 Country (com.furyviewer.domain.Country)1 Episode (com.furyviewer.domain.Episode)1 FavouriteArtist (com.furyviewer.domain.FavouriteArtist)1 FavouriteMovie (com.furyviewer.domain.FavouriteMovie)1 FavouriteSeries (com.furyviewer.domain.FavouriteSeries)1 Genre (com.furyviewer.domain.Genre)1 HatredArtist (com.furyviewer.domain.HatredArtist)1 HatredMovie (com.furyviewer.domain.HatredMovie)1 HatredSeries (com.furyviewer.domain.HatredSeries)1 Movie (com.furyviewer.domain.Movie)1 MovieStats (com.furyviewer.domain.MovieStats)1