Package com.google.ytd.model

Examples of com.google.ytd.model.AdminConfig


    String maxPhotoSizeMb = getParam("maxPhotoSizeMb");
    String photoSubmissionEnabled = getParam("photoSubmissionEnabled");
    String recaptchaPrivateKey = getParam("recaptchaPrivateKey");
    String recaptchaPublicKey = getParam("recaptchaPublicKey");

    AdminConfig adminConfig = adminConfigDao.getAdminConfig();

    // Use the name of the App Engine isntance for the client id.
    adminConfig.setClientId(Util.CLIENT_ID_PREFIX + SystemProperty.applicationId.get());

    if (developerKey != null) {
      adminConfig.setDeveloperKey(developerKey);
    }

    if (defaultTag != null) {
      adminConfig.setDefaultTag(defaultTag);
    }

    if (linkBackText != null) {
      adminConfig.setLinkBackText(linkBackText);
    }

    if (!util.isNullOrEmpty(moderationMode)) {
      adminConfig.setModerationMode(Integer.parseInt(moderationMode));
    }

    if (!util.isNullOrEmpty(brandingMode)) {
      adminConfig.setBrandingMode(Integer.parseInt(brandingMode));
    }

    if (!util.isNullOrEmpty(submissionMode)) {
      adminConfig.setSubmissionMode(Integer.parseInt(submissionMode));
    }

    if (newSubmissionAddress != null) {
      adminConfig.setNewSubmissionAddress(newSubmissionAddress);
    }

    if (loginInstruction != null) {
      adminConfig.setLoginInstruction(loginInstruction);
    }

    if (postSubmitMessage != null) {
      adminConfig.setPostSubmitMessage(postSubmitMessage);
    }

    if (moderationEmail != null) {
      adminConfig.setModerationEmail(moderationEmail.equalsIgnoreCase("true"));
    }

    if (fromAddress != null) {
      adminConfig.setFromAddress(fromAddress);
    }

    if (approvalEmailText != null) {
      adminConfig.setApprovalEmailText(approvalEmailText);
    }

    if (rejectionEmailText != null) {
      adminConfig.setRejectionEmailText(rejectionEmailText);
    }

    if (privateKeyBytes != null) {
      privateKeyBytes = privateKeyBytes.replace("-----BEGIN PRIVATE KEY-----", "");
      privateKeyBytes = privateKeyBytes.replace("-----END PRIVATE KEY-----", "");
      privateKeyBytes = privateKeyBytes.replace("\n", "");

      try {
        adminConfig.setPrivateKeyBytes(Base64.decode(privateKeyBytes));
      } catch (Base64DecoderException e) {
        LOG.log(Level.WARNING, "", e);
        adminConfig.setPrivateKeyBytes(new byte[0]);
      }
    }

    if (maxPhotoSizeMb != null) {
      adminConfig.setMaxPhotoSizeMb(Integer.parseInt(maxPhotoSizeMb));
    }

    if (photoSubmissionEnabled != null) {
      adminConfig.setPhotoSubmissionEnabled(photoSubmissionEnabled.equalsIgnoreCase("true"));
    }

    if (recaptchaPrivateKey != null) {
      adminConfig.setRecaptchaPrivateKey(recaptchaPrivateKey);
    }

    if (recaptchaPublicKey != null) {
      adminConfig.setRecaptchaPublicKey(recaptchaPublicKey);
    }

    adminConfig.setUpdated(new Date());
    adminConfig = adminConfigDao.save(adminConfig);

    return json;
  }
View Full Code Here


  }

  @Override
  @SuppressWarnings("unchecked")
  public AdminConfig getAdminConfig() {
    AdminConfig adminConfig = null;

    PersistenceManager pm = pmf.getPersistenceManager();

    try {
      Query query = pm.newQuery(AdminConfig.class);
      List<AdminConfig> adminConfigs = (List<AdminConfig>) query.execute();
      if (adminConfigs.size() > 0) {
        adminConfig = pm.detachCopy(adminConfigs.get(0));
      } else {
        LOG.info("No admin config found in datastore.  Creating a new one.");
        adminConfig = new AdminConfig();
        pm.makePersistent(adminConfig);
        adminConfig = pm.detachCopy(adminConfig);
      }
    } catch (JDOObjectNotFoundException e) {
      // this path can only occur when there is model class errors (model binary
View Full Code Here

  }

  @Override
  public boolean isUploadOnly() {
    boolean uploadOnly = false;
    AdminConfig adminConfig = getAdminConfig();
    if (adminConfig.getSubmissionMode() == AdminConfig.SubmissionModeType.NEW_ONLY.ordinal()) {
      uploadOnly = true;
    }
    return uploadOnly;
  }
View Full Code Here

        break;
    }
  }

  private void onApproved(VideoSubmission submission) {
    AdminConfig adminConfig = adminConfigDao.getAdminConfig();

    // Send notify email
    if (submission.getNotifyEmail() != null && adminConfig.isModerationEmail()) {
      emailUtil.sendUserModerationEmail(submission, ModerationStatus.APPROVED);
    }

  }
View Full Code Here

   
    return json;
  }

  private boolean onRejected(VideoSubmission submission) {
    AdminConfig adminConfig = adminConfigDao.getAdminConfig();
    boolean success = false;

    // Set the YouTubeApiHelper with the admin auth token
    String token = adminConfig.getYouTubeAuthSubToken();
    if (util.isNullOrEmpty(token)) {
      LOG.warning(String.format("No AuthSub token found in admin config."));
    } else {
      adminYouTubeApi.setAuthSubToken(token);
    }

    // TODO: Handle removing the branding if a video goes from APPROVED to
    // REJECTED.

    // Remove video to YouTube playlist if it is in one.
    if (submission.isInPlaylist()) {
      if (removeFromPlaylist(submission)) {
        success = true;
        submission.setIsInPlaylist(false);
        submission = submissionDao.save(submission);
      }
    }

    // Notify the submitter of rejection if there is a notify email
    if (adminConfig.isModerationEmail()
        && !util.isNullOrEmpty(submission.getNotifyEmail())) {
      emailUtil.sendUserModerationEmail(submission, ModerationStatus.REJECTED);
    }
   
    return success;
View Full Code Here

   
    return success;
  }

  private boolean onApproved(VideoSubmission submission) {
    AdminConfig adminConfig = adminConfigDao.getAdminConfig();
    boolean success = false;

    // Turn branding on if applicable
    if (adminConfig.getBrandingMode() == BrandingModeType.ON.ordinal()) {
      String linkBackText = adminConfig.getLinkBackText();
      if (!util.isNullOrEmpty(linkBackText) && !util.isNullOrEmpty(submission.getArticleUrl())) {
        String prependText = linkBackText.replace("ARTICLE_URL", submission
            .getArticleUrl());

        if (!submission.getVideoDescription().contains(prependText)) {
          // We only want to update the video if the text isn't already there.
          updateVideoDescription(submission, prependText, adminConfig
              .getDefaultTag());
        }
      }

      // Flip the moderation bit to approved for new upload
      if (submission.getVideoSource() == VideoSource.NEW_UPLOAD) {
        adminYouTubeApi.updateModeration(submission.getVideoId(), true);
      }
    }

    // Add video to YouTube playlist if it isn't in it already.
    if (!submission.isInPlaylist()) {
      if (addToPlaylist(submission)) {
        success = true;
        submission.setIsInPlaylist(true);
        submission = submissionDao.save(submission);
      }
    }

    // Notify the submitter of approval if there is a notify email
    if (adminConfig.isModerationEmail()
        && (submission.getNotifyEmail() != null)) {
      emailUtil.sendUserModerationEmail(submission, ModerationStatus.APPROVED);
    }
   
    return success;
View Full Code Here

        // TODO: Throw a better Exception class here.
        throw new IllegalArgumentException("Unable to retrieve a Picasa username for "
            + "the authenticated user.");
      }

      AdminConfig adminConfig = adminConfigDao.getAdminConfig();
      adminConfig.setPicasaAuthSubToken(sessionToken);
      adminConfig.setPicasaUsername(picasaUsername);

      pm.makePersistent(adminConfig);

      resp.sendRedirect(util.addNamespaceParamIfNeeded("/admin#configuration"));
    } catch (ResourceNotFoundException e) {
View Full Code Here

 
          submission.setViewCount(viewCount);
          submission.setVideoSource(VideoSubmission.VideoSource.EXISTING_VIDEO);
          submission.setNotifyEmail(email);
 
          AdminConfig adminConfig = adminConfigDao.getAdminConfig();
          if (adminConfig.getModerationMode() == AdminConfig.ModerationModeType.NO_MOD.ordinal()) {
            // NO_MOD is set, auto approve all submission
            // TODO: This isn't enough, as the normal approval flow (adding the
            // branding, tags, emails,
            // etc.) isn't taking place.
            submission.setStatus(VideoSubmission.ModerationStatus.APPROVED);
           
            // 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' doesn't have an associated playlist.",
                      assignmentId));
                } else {
                  apiManager.setAuthSubToken(adminConfig.getYouTubeAuthSubToken());
                  if (apiManager.insertVideoIntoPlaylist(playlistId, videoId)) {
                    submission.setIsInPlaylist(true);
                  }
                }
              }
View Full Code Here

    if (submission == null) {
      throw new IllegalArgumentException("Can't find submission with id " + id);
    }
   
    if (submission.isInPlaylist()) {
      AdminConfig adminConfig = adminConfigDao.getAdminConfig();

      // Set the YouTubeApiHelper with the admin auth token
      String token = adminConfig.getYouTubeAuthSubToken();
      if (util.isNullOrEmpty(token)) {
        LOG.warning(String.format("No AuthSub token found in admin config."));
      } else {
        adminYouTubeApi.setAuthSubToken(token);
      }
View Full Code Here

  private Util util;

  public void sendPhotoEntryToAdmins(PhotoEntry photoEntry) {
    log.info(
        String.format("Sending photo from PhotoEntry id '%s' to admins...", photoEntry.getId()));
    AdminConfig adminConfig = adminConfigDao.getAdminConfig();

    MailService mailService = MailServiceFactory.getMailService();
    Message message = new Message();

    try {
      String fromAddress = adminConfig.getFromAddress();
      if (util.isNullOrEmpty(fromAddress)) {
        throw new IllegalArgumentException("No from address found in configuration.");
      }

      message.setSubject("Unable to submit photo to Picasa");
View Full Code Here

TOP

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

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.