Package com.google.ytd.model

Examples of com.google.ytd.model.PhotoSubmission


    if (util.isNullOrEmpty(adminNotes)) {
      // Essentially emptying the admin notes
      adminNotes = "";
    }

    PhotoSubmission submission = photoSubmissionDao.getSubmissionById(id);

    if (submission == null) {
      throw new IllegalArgumentException("The input photo submission id cannot be located.");
    }

    submission.setAdminNotes(adminNotes);
    submission.setUpdated(new Date());
    photoSubmissionDao.save(submission);

    return json;
  }
View Full Code Here


  }

  @Override
  public PhotoSubmission getSubmissionById(String id) {
    PersistenceManager pm = pmf.getPersistenceManager();
    PhotoSubmission submission = null;

    try {
      submission = pm.getObjectById(PhotoSubmission.class, id);
    } finally {
      pm.close();
View Full Code Here

  }

  @Override
  public void deleteSubmission(String id) {
    PersistenceManager pm = pmf.getPersistenceManager();
    PhotoSubmission submission = null;

    try {
      submission = pm.getObjectById(PhotoSubmission.class, id);

      // Delete all associated photo entries of this submission
View Full Code Here

    PhotoEntry entry = null;
    try {
      entry = pm.getObjectById(PhotoEntry.class, id);

      // Update the photo count of the corresponding submission
      PhotoSubmission photoSubmission = this.getSubmissionById(entry.getSubmissionId());
      photoSubmission.setNumberOfPhotos(photoSubmission.getNumberOfPhotos() - 1);
      this.save(photoSubmission);

      BlobKey blobKey = entry.getBlobKey();
      if (blobKey != null) {
        // Delete the image binary from blob store
View Full Code Here

        validSubmissionKeys.add(blobKey);
      }

      if (validSubmissionKeys.size() > 0) {
        // PhotoSubmission represents the metadata of a set of photo entries
        PhotoSubmission photoSubmission =
            new PhotoSubmission(Long.parseLong(assignmentId), articleUrl, author, email,
                phoneNumber, title, description, location, date, validSubmissionKeys.size());
       
        if (!util.isNullOrEmpty(latitude) && !util.isNullOrEmpty(longitude)) {
          try {
            photoSubmission.setLatitude(Double.parseDouble(latitude));
            photoSubmission.setLongitude(Double.parseDouble(longitude));
          } catch (NumberFormatException e) {
            LOG.log(Level.WARNING, "Couldn't parse lat/long.", e);
          }
        }
       
        pmfUtil.persistJdo(photoSubmission);
        String submissionId = photoSubmission.getId();

        for (BlobKey blobKey : validSubmissionKeys) {
          BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(blobKey);

          PhotoEntry photoEntry = new PhotoEntry(submissionId, blobKey, blobInfo.getContentType());
View Full Code Here

        throw new IllegalArgumentException("No image attachments were found in the email.");
      }
     
      String date = new DateTime().toUiString();
     
      PhotoSubmission photoSubmission = new PhotoSubmission(Long.parseLong(assignmentId), "",
          author, email, "", title, description, "", date, imageCount);
      pmfUtil.persistJdo(photoSubmission);
      String submissionId = photoSubmission.getId();

      imageCount = 0;
      for (BodyPart part : parts) {
        String partMimeType = part.getContentType().toLowerCase();
View Full Code Here

    // This code is much less efficient because we can't count on all the ids in
    // 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(
            "Couldn't move Picasa photo '%s' to album '%s'. Check AppEngine log for details.",
            entry.getPicasaUrl(), newAlbumUrl));
      }

      entry.setStatus(statusEnum);
      entry.setPicasaUrl(newPhotoUrl);
     
      photoSubmissionDao.save(entry);
     
      if (adminConfigDao.getAdminConfig().isModerationEmail()
          && !util.isNullOrEmpty(submission.getNotifyEmail())) {
        emailUtil.sendUserModerationEmail(submission, entry, statusEnum);
      }
    }

    return json;
View Full Code Here

        throw new IllegalArgumentException("Required parameter 'id' is null or empty.");
      }

      LOG.info(String.format("Moving photos in submission '%s' to Picasa.", photoSubmissionId));

      PhotoSubmission photoSubmission = photoSubmissionDao.getSubmissionById(photoSubmissionId);
      if (photoSubmission == null) {
        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();
      Double longitude = photoSubmission.getLongitude();

      for (PhotoEntry photoEntry : photoSubmissionDao.getAllPhotos(photoSubmissionId)) {
        String uploadUrl = picasaApi.getResumableUploadUrl(photoEntry, title, description, albumId,
            latitude, longitude);
View Full Code Here

     
      dataChunkDao.deleteChunks(photoEntryId);

      photoSubmissionDao.save(photoEntry);

      PhotoSubmission photoSubmission = photoSubmissionDao.getSubmissionById(
          photoEntry.getSubmissionId());
      emailUtil.sendNewSubmissionEmail(photoEntry, photoSubmission);
    } catch (IllegalArgumentException e) {
      // We don't want to send an error response here, since that will result
      // in the TaskQueue retrying and this is not a transient error.
View Full Code Here

TOP

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

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.