コード例 #1
0
 /**
  * Verifies the "completeness" of podcast resource sent over the wire
  *
  * @param podcast
  * @return
  */
 private boolean isFullUpdate(Podcast podcast) {
   return podcast.getId() == null
       || podcast.getFeed() == null
       || podcast.getLinkOnPodcastpedia() == null
       || podcast.getTitle() == null
       || podcast.getDescription() == null;
 }
コード例 #2
0
  /** ******************* Create related methods implementation ********************* */
  @Transactional("transactionManager")
  public Long createPodcast(Podcast podcast) throws AppException {

    validateInputForCreation(podcast);

    // verify existence of resource in the db (feed must be unique)
    PodcastEntity podcastByFeed = podcastDao.getPodcastByFeed(podcast.getFeed());
    if (podcastByFeed != null) {
      throw new AppException(
          Response.Status.CONFLICT.getStatusCode(),
          409,
          "Podcast with feed already existing in the database with the id " + podcastByFeed.getId(),
          "Please verify that the feed and title are properly generated",
          AppConstants.BLOG_POST_URL);
    }

    return podcastDao.createPodcast(new PodcastEntity(podcast));
  }
コード例 #3
0
 private void validateInputForCreation(Podcast podcast) throws AppException {
   if (podcast.getFeed() == null) {
     throw new AppException(
         Response.Status.BAD_REQUEST.getStatusCode(),
         400,
         "Provided data not sufficient for insertion",
         "Please verify that the feed is properly generated/set",
         AppConstants.BLOG_POST_URL);
   }
   if (podcast.getTitle() == null) {
     throw new AppException(
         Response.Status.BAD_REQUEST.getStatusCode(),
         400,
         "Provided data not sufficient for insertion",
         "Please verify that the title is properly generated/set",
         AppConstants.BLOG_POST_URL);
   }
   // etc...
 }