Package com.google.ytd.model

Examples of com.google.ytd.model.Assignment


   *          The video to remove.
   * @return true if the video was removed; false otherwise.
   */
  private boolean removeFromPlaylist(VideoSubmission videoSubmission) {
    long assignmentId = videoSubmission.getAssignmentId();
    Assignment assignment = assignmentDao.getAssignmentById(assignmentId);

    if (assignment == null) {
      LOG.warning(String.format("Couldn't find assignment id '%d' for video id '%s'.", assignmentId,
          videoSubmission.getId()));
      return false;
    }

    String playlistId = assignment.getPlaylistId();
    if (util.isNullOrEmpty(playlistId)) {
      LOG.warning(String.format("Assignment id '%d' does not have an associated playlist.",
          assignmentId));
      return false;
    }
View Full Code Here


    }

    adminYouTubeApi.setAuthSubToken(token);

    long assignmentId = videoSubmission.getAssignmentId();
    Assignment assignment = assignmentDao.getAssignmentById(assignmentId);

    if (assignment == null) {
      LOG.warning(String.format("Couldn't find assignment id '%d' for video id '%s'.", assignmentId,
              videoSubmission.getId()));
      return;
    }

    String playlistId = assignment.getPlaylistId();
    if (util.isNullOrEmpty(playlistId)) {
      LOG.warning(String.format("Assignment id '%d' does not have an associated playlist.",
          assignmentId));
      return;
    }
View Full Code Here

    if (util.isNullOrEmpty(title)) {
      throw new IllegalArgumentException("Missing required param: title");
    }

    Assignment assignment = new Assignment();
    assignment.setStatus(AssignmentStatus.valueOf(status.toUpperCase()));
    assignment.setDescription(description);
    assignment.setCategory(category);
    assignment.setLoginInstruction(loginInstruction);
    assignment.setPostSubmitMessage(postSubmitMessage);
    assignment.setTitle(title);

    assignment = assignmentDao.newAssignment(assignment, title, channelId);

    json.put("id", assignment.getId());

    return json;
  }
View Full Code Here

    // the list being part of the same PhotoSubmission. I guess we could cache
    // here in the future.
    for (String id : ids.split(",")) {
      PhotoEntry entry = photoSubmissionDao.getPhotoEntry(id);
      PhotoSubmission submission = photoSubmissionDao.getSubmissionById(entry.getSubmissionId());
      Assignment assignment = assignmentDao.getAssignmentById(submission.getAssignmentId());

      if (entry.getBlobKey() != null || util.isNullOrEmpty(entry.getPicasaUrl())) {
        throw new IllegalStateException(String.format("Can't update the state of PhotoEntry id '%s'"
            + " because it has not yet been moved from App Engine to Picasa.", entry.getId()));
      }

      String newAlbumUrl;
      ModerationStatus statusEnum = ModerationStatus.valueOf(status);
      switch (statusEnum) {
        case APPROVED:
          newAlbumUrl = assignment.getApprovedAlbumUrl();
          break;
         
        case UNREVIEWED:
          newAlbumUrl = assignment.getUnreviewedAlbumUrl();
          break;
         
        default:
          newAlbumUrl = assignment.getRejectedAlbumUrl();
      }

      String newPhotoUrl = picasaApi.moveToNewAlbum(entry.getPicasaUrl(), newAlbumUrl);
      if (newPhotoUrl == null) {
        throw new IllegalStateException(String.format(
View Full Code Here

       
        // Add video to YouTube playlist if it isn't in it already.
        // This code is kind of ugly and is mostly copy/pasted from UpdateVideoSubmissionStatus
        // TODO: It should be refactored into a common helper method somewhere...
        if (!submission.isInPlaylist()) {
          Assignment assignment = assignmentDao.getAssignmentById(assignmentId);

          if (assignment == null) {
            log.warning(String.format("Couldn't find assignment id '%d' for video id '%s'.",
                assignmentId, videoId));
          } else {
            String playlistId = assignment.getPlaylistId();
            if (util.isNullOrEmpty(playlistId)) {
              log.warning(String.format("Assignment id '%d' does not have an associated playlist.",
                  assignmentId));
            } else {
              if (youTubeApiHelper.insertVideoIntoPlaylist(playlistId, videoId)) {
View Full Code Here

    String id = getParam("id");
    if (util.isNullOrEmpty(id)) {
      throw new IllegalArgumentException("Missing required param: id");
    }

    Assignment assignment = assignmentDao.getAssignmentById(id);

    String status = getParam("status");
    if (!util.isNullOrEmpty(status)) {
      assignment.setStatus(AssignmentStatus.valueOf(status.toUpperCase()));
    }
   
    String description = getParam("description");
    if (!util.isNullOrEmpty(description)) {
      assignment.setDescription(description);
    }
   
    String title = getParam("title");
    if (!util.isNullOrEmpty(title)) {
      assignment.setTitle(title);
    }
   
    String category = getParam("category");
    if (!util.isNullOrEmpty(category)) {
      assignment.setCategory(category);
    }
   
    String playlistId = getParam("playlistId");
    if (!util.isNullOrEmpty(playlistId)) {
      assignment.setPlaylistId(playlistId);
    }
   
    String approvedAlbumUrl = getParam("approvedAlbumUrl");
    if (!util.isNullOrEmpty(approvedAlbumUrl)) {
      assignment.setApprovedAlbumUrl(approvedAlbumUrl);
    }
   
    String rejectedAlbumUrl = getParam("rejectedAlbumUrl");
    if (!util.isNullOrEmpty(rejectedAlbumUrl)) {
      assignment.setRejectedAlbumUrl(rejectedAlbumUrl);
    }
   
    String unreviewedAlbumUrl = getParam("unreviewedAlbumUrl");
    if (!util.isNullOrEmpty(unreviewedAlbumUrl)) {
      assignment.setUnreviewedAlbumUrl(unreviewedAlbumUrl);
    }

    assignment = assignmentDao.save(assignment);

    return json;
View Full Code Here

        throw new IllegalArgumentException(String.format(
            "Unable to find PhotoSubmission with id '%s'.", photoSubmissionId));
      }

      String assignmentId = photoSubmission.getAssignmentId().toString();
      Assignment assignment = assignmentDao.getAssignmentById(assignmentId);
      if (assignment == null) {
        throw new IllegalArgumentException(String.format("Unable to find Assignment with id '%s'.",
            assignmentId));
      }

      String title = photoSubmission.getTitle();
      String description = String.format("%s\n\nSubmitted by %s",
          photoSubmission.getDescription(), photoSubmission.getAuthor());
      if (!util.isNullOrEmpty(photoSubmission.getArticleUrl())) {
        description += " in response to " + photoSubmission.getArticleUrl();
      }
     
      // It would be arguably more useful to store the album id separately, but we can parse it from
      // the album URL value.
      String albumUrl = assignment.getUnreviewedAlbumUrl();
      String albumId = albumUrl.substring(albumUrl.lastIndexOf("/") + 1);

      BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
     
      Double latitude = photoSubmission.getLatitude();
View Full Code Here

      String status = request.getParameter("status");
      if (util.isNullOrEmpty(status)) {
        throw new IllegalArgumentException("Required parameter 'status' is null or empty.");
      }
     
      Assignment assignment = assignmentDao.getAssignmentById(assignmentId);
      if (assignment == null) {
        throw new IllegalArgumentException(String.format("Could not find Assignment id '%s' in "
            + "datastore.", assignmentId));
      }
     
      String albumUrl;
      ModerationStatus statusEnum = ModerationStatus.valueOf(status);
      switch (statusEnum) {
        case APPROVED:
          albumUrl = picasaApi.createAlbum(title, description, false);
          if (util.isNullOrEmpty(albumUrl)) {
            throw new IllegalStateException("Unable to create 'APPROVED' album.");
          } else {
            assignment.setApprovedAlbumUrl(albumUrl);
          }
          break;
         
        case UNREVIEWED:
          albumUrl = picasaApi.createAlbum(title + " (Unreviewed)", description, true);
          if (util.isNullOrEmpty(albumUrl)) {
            throw new IllegalStateException("Unable to create 'UNREVIEWED' album.");
          } else {
            assignment.setUnreviewedAlbumUrl(albumUrl);
          }
          break;
         
        case REJECTED:
          albumUrl = picasaApi.createAlbum(title + " (Rejected)", description, true);
          if (util.isNullOrEmpty(albumUrl)) {
            throw new IllegalStateException("Unable to create 'REJECTED' album.");
          } else {
            assignment.setRejectedAlbumUrl(albumUrl);
          }
          break;
         
        default:
          throw new IllegalArgumentException(String.format("'%s' is not a valid value for the "
View Full Code Here

      String description = request.getParameter("description");
      if (util.isNullOrEmpty(description)) {
        throw new IllegalArgumentException("Required parameter 'description' is null or empty.");
      }

      Assignment assignment = assignmentDao.getAssignmentById(assignmentId);
      if (assignment == null) {
        throw new IllegalArgumentException(
            String.format("Could not find Assignment id '%s' in datastore.", assignmentId));
      }

      String token = adminConfigDao.getAdminConfig().getYouTubeAuthSubToken();
      if (util.isNullOrEmpty(token)) {
        throw new IllegalArgumentException(
            String.format("Could not create new playlist for assignment '%s' because no YouTube "
                + "AuthSub token was found in the config.", assignmentId));
      }
      youtubeApi.setAuthSubToken(token);

      if (util.isNullOrEmpty(adminConfigDao.getAdminConfig().getDeveloperKey())) {
        throw new IllegalArgumentException(
            String.format("Could not create new playlist for assignment '%s' because no YouTube "
                + "developer key was found in the config.", assignmentId));
      }

      String playlistId = youtubeApi.createPlaylist(title, description);
      if (util.isNullOrEmpty(playlistId)) {
        throw new IllegalStateException("Unable to create playlist.");
      } else {
        assignment.setPlaylistId(playlistId);
      }

      assignmentDao.save(assignment);

      if (!util.isNullOrEmpty(channelId)) {
View Full Code Here

TOP

Related Classes of com.google.ytd.model.Assignment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.