Search in sources :

Example 1 with BadRequestAlertException

use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.

the class FavouriteMovieResource method createFavouriteMovie.

/**
 * POST  /favourite-movies : Create a new favouriteMovie.
 *
 * @param favouriteMovie the favouriteMovie to create
 * @return the ResponseEntity with status 201 (Created) and with body the new favouriteMovie, or with status 400 (Bad Request) if the favouriteMovie has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/favourite-movies")
@Timed
public ResponseEntity<FavouriteMovie> createFavouriteMovie(@RequestBody FavouriteMovie favouriteMovie) throws URISyntaxException {
    log.debug("REST request to save FavouriteMovie : {}", favouriteMovie);
    if (favouriteMovie.getId() != null) {
        throw new BadRequestAlertException("A new favouriteMovie cannot already have an ID", ENTITY_NAME, "idexists");
    }
    Optional<FavouriteMovie> favoriteMovieExisting = favouriteMovieRepository.findByMovieAndUserLogin(favouriteMovie.getMovie(), SecurityUtils.getCurrentUserLogin());
    if (favoriteMovieExisting.isPresent()) {
        favouriteMovie = favoriteMovieExisting.get();
        favouriteMovie.setLiked(!favouriteMovie.isLiked());
    } else {
        favouriteMovie.setLiked(true);
    }
    favouriteMovie.setDate(ZonedDateTime.now());
    favouriteMovie.setUser(userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get());
    FavouriteMovie result = favouriteMovieRepository.save(favouriteMovie);
    return ResponseEntity.created(new URI("/api/favourite-movies/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : BadRequestAlertException(com.furyviewer.web.rest.errors.BadRequestAlertException) URI(java.net.URI) FavouriteMovie(com.furyviewer.domain.FavouriteMovie) Timed(com.codahale.metrics.annotation.Timed)

Example 2 with BadRequestAlertException

use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.

the class ArtistTypeResource method createArtistType.

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

Example 3 with BadRequestAlertException

use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.

the class AchievementResource method createAchievement.

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

Example 4 with BadRequestAlertException

use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.

the class ArtistResource method createArtist.

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

Example 5 with BadRequestAlertException

use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.

the class SeasonResource method createSeason.

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