com.googlecode.objectify.Objectify Java Examples

The following examples show how to use com.googlecode.objectify.Objectify. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectifyGalleryStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * get moderation actions associated with given reportId
 * @param reportId
 */
@Override
public List<GalleryModerationAction> getModerationActions(final long reportId){
  final List<GalleryModerationAction> moderationActions = new ArrayList<GalleryModerationAction>();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        Key<GalleryAppReportData> galleryReportKey = galleryReportKey(reportId);
        for (GalleryModerationActionData moderationActionData : datastore.query(GalleryModerationActionData.class)
            .ancestor(galleryReportKey).order("-date")) {
          GalleryModerationAction moderationAction = new GalleryModerationAction(reportId, moderationActionData.galleryId,
              moderationActionData.emailId, moderationActionData.moderatorId, moderationActionData.actionType,
              moderationActionData.moderatorName, moderationActionData.emailPreview, moderationActionData.date);
          moderationActions.add(moderationAction);
        }
      }
    });
  } catch (ObjectifyException e) {
      throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo.getCommentReports", e);
  }
  return moderationActions;
}
 
Example #2
Source File: ObjectifyGalleryStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a wrapped class which contains a list of most downloaded
 * gallery apps and total number of results in database
 * @param start starting index of apps you want
 * @param count number of apps you want
 * @return list of {@link GalleryApp}
 */
@Override
public GalleryAppListResult getMostDownloadedApps(int start, final int count) {
  final List<GalleryApp> apps = new ArrayList<GalleryApp>();
  // If I try to run this in runjobwithretries, it tells me can't run
  // non-ancestor query as a transaction. ObjectifyStorageio has some samples
  // of not using transactions (run with) so I grabbed.

  Objectify datastore = ObjectifyService.begin();
  for (GalleryAppData appData:datastore.query(GalleryAppData.class).order("-numDownloads").filter("active", true).offset(start).limit(count)) {
    GalleryApp gApp = new GalleryApp();
    makeGalleryApp(appData, gApp);
    apps.add(gApp);
  }
  int totalCount = datastore.query(GalleryAppData.class).order("-numDownloads").filter("active", true).count();
  return new GalleryAppListResult(apps, totalCount);
}
 
Example #3
Source File: ObjectifyGalleryStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * get num likes of a gallery app
 *
 * @param galleryId
 *          id of gallery app
 * @return the num of like
 */
public int getNumLikes(final long galleryId) {
  final Result<Integer> num = new Result<Integer>();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        Key<GalleryAppData> galleryKey = galleryKey(galleryId);
        //num.t = datastore.query(GalleryAppLikeData.class).ancestor(galleryKey).count();
        GalleryAppData galleryAppData = datastore.find(galleryKey);
        num.t = galleryAppData.numLikes;
      }
    });
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null,
        "error in galleryStorageIo.getNumLike", e);
  }
  return num.t;
}
 
Example #4
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public byte[] downloadRawUserFile(final String userId, final String fileName) {
  final Result<byte[]> result = new Result<byte[]>();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        UserFileData ufd = datastore.find(userFileKey(userKey(userId), fileName));
        if (ufd != null) {
          result.t = ufd.content;
        } else {
          throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId, fileName),
              new FileNotFoundException(fileName));
        }
      }
    }, true);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId, fileName), e);
  }
  return result.t;
}
 
Example #5
Source File: ObjectifyGalleryStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * adds a comment to a gallery app
 * @param galleryId id of gallery app that was commented on
 * @param userId id of user who commented
 * @param comment comment
 * @return the id of the new comment
 */
@Override
public long addComment(final long galleryId, final String userId, final String comment) {
  final Result<Long> theDate = new Result<Long>();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        GalleryCommentData commentData = new GalleryCommentData();
        long date = System.currentTimeMillis();
        commentData.comment = comment;
        commentData.userId = userId;
        commentData.galleryKey = galleryKey(galleryId);
        commentData.dateCreated = date;
        theDate.t = date;

        datastore.put(commentData);
      }
    });
  } catch (ObjectifyException e) {
     throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo.addComment", e);
  }
  return theDate.t;
}
 
Example #6
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public void deleteUserFile(final String userId, final String fileName) {
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        Key<UserFileData> ufdKey = userFileKey(userKey(userId), fileName);
        if (datastore.find(ufdKey) != null) {
          datastore.delete(ufdKey);
        }
      }
    }, true);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId, fileName), e);
  }
}
 
Example #7
Source File: ObjectifyGalleryStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Records that an app has been downloaded
 * @param galleryId the id of gallery app that was downloaded
 */
@Override
public void incrementDownloads(final long galleryId) {

  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        GalleryAppData galleryAppData = datastore.find(galleryKey(galleryId));
        if (galleryAppData != null) {
          galleryAppData.numDownloads = galleryAppData.numDownloads + 1;
          galleryAppData.unreadDownloads = galleryAppData.unreadDownloads + 1;
          datastore.put(galleryAppData);
        }
      }
    });
  } catch (ObjectifyException e) {
     throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo", e);
  }
}
 
Example #8
Source File: ObjectifyGalleryStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a wrapped class which contains a list of galleryApps
 * by a particular developer and total number of results in database
 * @param userId id of developer
 * @param start starting index of apps you want
 * @param count number of apps you want
 * @return list of {@link GalleryApp}
 */  @Override
public GalleryAppListResult getDeveloperApps(String userId, int start, final int count) {
  final List<GalleryApp> apps = new ArrayList<GalleryApp>();
  // if i try to run this in runjobwithretries it tells me can't run
  // non-ancestor query as a transaction. ObjectifyStorageio has some samples
  // of not using transactions (run with) so i grabbed

  Objectify datastore = ObjectifyService.begin();
  for (GalleryAppData appData:datastore.query(GalleryAppData.class).filter("userId",userId).filter("active", true).offset(start).limit(count)) {
    GalleryApp gApp = new GalleryApp();
    makeGalleryApp(appData, gApp);
    apps.add(gApp);
  }
  int totalCount = datastore.query(GalleryAppData.class).filter("userId",userId).filter("active", true).count();
  return new GalleryAppListResult(apps, totalCount);
}
 
Example #9
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
private FileData createProjectFile(Objectify datastore, Key<ProjectData> projectKey,
    FileData.RoleEnum role, String fileName) {
  FileData fd = datastore.find(projectFileKey(projectKey, fileName));
  if (fd == null) {
    fd = new FileData();
    fd.fileName = fileName;
    fd.projectKey = projectKey;
    fd.role = role;
    return fd;
  } else if (!fd.role.equals(role)) {
    throw CrashReport.createAndLogError(LOG, null,
        collectProjectErrorInfo(null, projectKey.getId(), fileName),
        new IllegalStateException("File role change is not supported"));
  }
  return null;
}
 
Example #10
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
private void removeFilesFromProject(Objectify datastore, long projectId,
    FileData.RoleEnum role, boolean changeModDate, String... fileNames) {
  Key<ProjectData> projectKey = projectKey(projectId);
  List<Key<FileData>> filesToRemove = new ArrayList<Key<FileData>>();
  for (String fileName : fileNames) {
    Key<FileData> key = projectFileKey(projectKey, fileName);
    memcache.delete(key.getString()); // Remove it from memcache (if it is there)
    FileData fd = datastore.find(key);
    if (fd != null) {
      if (fd.role.equals(role)) {
        filesToRemove.add(projectFileKey(projectKey, fileName));
      } else {
        throw CrashReport.createAndLogError(LOG, null,
            collectProjectErrorInfo(null, projectId, fileName),
            new IllegalStateException("File role change is not supported"));
      }
    }
  }
  datastore.delete(filesToRemove);  // batch delete
  if (changeModDate) {
    updateProjectModDate(datastore, projectId, false);
  }
}
 
Example #11
Source File: ObjectifyGalleryStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * mark an report as resolved
 * @param reportId the id of the app
 */
@Override
public boolean markReportAsResolved(final long reportId, final long galleryId){
  final Result<Boolean> success = new Result<Boolean>();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        datastore = ObjectifyService.begin();
        success.t = false;
        Key<GalleryAppData> galleryKey = galleryKey(galleryId);
        for (GalleryAppReportData reportData : datastore.query(GalleryAppReportData.class).ancestor(galleryKey)) {
          if(reportData.id == reportId){
            reportData.resolved = !reportData.resolved;
            datastore.put(reportData);
            success.t = true;
            break;
          }
        }
       }
    });
   } catch (ObjectifyException e) {
       throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo.markReportAsResolved", e);
   }
   return success.t;
}
 
Example #12
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public long getProjectAttributionId(final long projectId) {
  final Result<Long> attributionId = new Result<Long>();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        ProjectData pd = datastore.find(projectKey(projectId));
        if (pd != null) {
          attributionId.t = pd.attributionId;
        } else {
          attributionId.t = UserProject.FROMSCRATCH;
        }
      }
    }, true);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null,
        "error in getProjectAttributionId", e);
  }
  return attributionId.t;
}
 
Example #13
Source File: ObjectifyGalleryStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * check if gallery app is activated
 * @param galleryId the id of the gallery app
 */
@Override
public boolean isGalleryAppActivated(final long galleryId){
  final Result<Boolean> success = new Result<Boolean>();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
          datastore = ObjectifyService.begin();
          success.t = false;
          Key<GalleryAppData> galleryKey = galleryKey(galleryId);
          GalleryAppData appData = datastore.find(galleryKey);
          if(appData != null){
            if(appData.active){
              success.t = true;
            }
          }
       }
    });
  } catch (ObjectifyException e) {
     throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo.markReportAsResolved", e);
  }
  return success.t;
}
 
Example #14
Source File: ObjectifyGalleryStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * adds a report (flag) to a gallery app comment
 * @param commentId id of comment that was reported
 * @param userId id of user who commented
 * @param report report
 * @return the id of the new report
 */
@Override
public long addCommentReport(final long commentId, final String userId, final String report) {
  final Result<Long> theDate = new Result<Long>();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        GalleryCommentReportData reportData = new GalleryCommentReportData();
        long date = System.currentTimeMillis();
        reportData.report = report;
        reportData.userId = userId;
        reportData.galleryCommentKey = galleryCommentKey(commentId);
        reportData.dateCreated=date;
        theDate.t=date;
        datastore.put(reportData);
      }
    });
  } catch (ObjectifyException e) {
     throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo.addCommentReport", e);
  }
  return theDate.t;
}
 
Example #15
Source File: ObjectifyGalleryStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a list of reports (flags) for all comments
 * @return list of {@link GalleryCommentReport}
 */
@Override
public List<GalleryCommentReport> getCommentReports() {
  final List<GalleryCommentReport> reports = new ArrayList<GalleryCommentReport>();
  Objectify datastore = ObjectifyService.begin();
  for (GalleryCommentReportData reportData : datastore.query(GalleryCommentReportData.class).order("-dateCreated")) {
    User commenter = storageIo.getUser(reportData.userId);
    String name="unknown";
    if (commenter!= null) {
       name = commenter.getUserName();
    }
    GalleryCommentReport galleryCommentReport = new GalleryCommentReport(reportData.galleryCommentKey.getId(),
        reportData.userId,reportData.report,reportData.dateCreated);
    galleryCommentReport.setUserName(name);
    reports.add(galleryCommentReport);
  }
  return reports;
}
 
Example #16
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public List<String> getProjectOutputFiles(final String userId, final long projectId) {
 final Result<List<String>> result = new Result<List<String>>();
 try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        result.t = getProjectFiles(datastore, projectId, FileData.RoleEnum.TARGET);
      }
    }, false);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null,
        collectUserProjectErrorInfo(userId, projectId), e);
  }
  return result.t;
}
 
Example #17
Source File: ObjectifyGalleryStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the email with a particular emailId
 * @param emailId id of the email
 */  @Override
public Email getEmail(final long emailId) {
  final Result<Email> result = new Result<Email>();
  // if i try to run this in runjobwithretries it tells me can't run
  // non-ancestor query as a transaction. ObjectifyStorageio has some samples
  // of not using transactions (run with) so i grabbed
  Objectify datastore = ObjectifyService.begin();
  for (EmailData emailData : datastore.query(EmailData.class)
      .filter("id", emailId)/*.order("-datestamp")*/) {
    Email email = new Email(emailData.id, emailData.senderId, emailData.receiverId,
        emailData.title, emailData.body, emailData.datestamp);
    result.t = email;
    break;
  }
  return result.t;
}
 
Example #18
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public String downloadBackpack(final String backPackId) {
  final Result<Backpack> result = new Result<Backpack>();
  try {
    runJobWithRetries(new JobRetryHelper() {
        @Override
        public void run(Objectify datastore) {
          Backpack backPack = datastore.find(backpackdataKey(backPackId));
          if (backPack != null) {
            result.t = backPack;
          }
        }
      }, false);
  } catch (ObjectifyException e) {
    CrashReport.createAndLogError(LOG, null, null, e);
  }
  if (result.t != null) {
    return result.t.content;
  } else {
    return "[]";              // No shared backpack, return an empty backpack
  }
}
 
Example #19
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public void storeProjectSettings(final String userId, final long projectId,
    final String settings) {
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        ProjectData pd = datastore.find(projectKey(projectId));
        if (pd != null) {
          pd.settings = settings;
          datastore.put(pd);
        }
      }
    }, false);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null,
        collectUserProjectErrorInfo(userId, projectId), e);
  }
}
 
Example #20
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public User getUserFromEmail(String email) {
  String emaillower = email.toLowerCase();
  LOG.info("getUserFromEmail: email = " + email + " emaillower = " + emaillower);
  Objectify datastore = ObjectifyService.begin();
  String newId = UUID.randomUUID().toString();
  // First try lookup using entered case (which will be the case for Google Accounts)
  UserData user = datastore.query(UserData.class).filter("email", email).get();
  if (user == null) {
    LOG.info("getUserFromEmail: first attempt failed using " + email);
    // Now try lower case version
    user = datastore.query(UserData.class).filter("emaillower", emaillower).get();
    if (user == null) {       // Finally, create it (in lower case)
      LOG.info("getUserFromEmail: second attempt failed using " + emaillower);
      user = createUser(datastore, newId, email);
    }
  }
  User retUser = new User(user.id, email, user.name, user.link, 0, user.tosAccepted,
    false, user.type, user.sessionid);
  retUser.setPassword(user.password);
  return retUser;
}
 
Example #21
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
private UserData createUser(Objectify datastore, String userId, String email) {
  String emaillower = null;
  if (email != null) {
    emaillower = email.toLowerCase();
  }
  UserData userData = new UserData();
  userData.id = userId;
  userData.tosAccepted = false;
  userData.settings = "";
  userData.email = email == null ? "" : email;
  userData.name = User.getDefaultName(email);
  userData.type = User.USER;
  userData.link = "";
  userData.emaillower = email == null ? "" : emaillower;
  userData.emailFrequency = User.DEFAULT_EMAIL_NOTIFICATION_FREQUENCY;
  datastore.put(userData);
  return userData;
}
 
Example #22
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public void setTosAccepted(final String userId) {
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        UserData userData = datastore.find(userKey(userId));
        if (userData != null) {
          userData.tosAccepted = true;
          datastore.put(userData);
        }
      }
    }, true);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId), e);
  }
}
 
Example #23
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public void setUserEmail(final String userId, String inputemail) {
  final String email = inputemail.toLowerCase();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        UserData userData = datastore.find(userKey(userId));
        if (userData != null) {
          userData.email = email;
          datastore.put(userData);
        }
      }
    }, true);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId), e);
  }
}
 
Example #24
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public List<Long> getProjects(final String userId) {
  final List<Long> projects = new ArrayList<Long>();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        Key<UserData> userKey = userKey(userId);
        for (UserProjectData upd : datastore.query(UserProjectData.class).ancestor(userKey)) {
          projects.add(upd.projectId);
        }
      }
    }, false);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId), e);
  }

  return projects;
}
 
Example #25
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public void setUserEmailFrequency(final String userId, final int emailFrequency) {
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        String cachekey = User.usercachekey + "|" + userId;
        memcache.delete(cachekey);  // Flush cached copy prior to update
        UserData userData = datastore.find(userKey(userId));
        if (userData != null) {
          userData.emailFrequency = emailFrequency;
          datastore.put(userData);
        }
      }
    }, true);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId), e);
  }
}
 
Example #26
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public void setProjectGalleryId(final String userId, final long projectId,final long galleryId) {
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        ProjectData projectData = datastore.find(projectKey(projectId));
        if (projectData != null) {
          projectData.galleryId = galleryId;
          datastore.put(projectData);
        }
      }
    }, true);
  } catch (ObjectifyException e) {
     throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId), e);
  }
}
 
Example #27
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public void setUserPassword(final String userId, final String password) {
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        String cachekey = User.usercachekey + "|" + userId;
        memcache.delete(cachekey);  // Flush cached copy prior to update
        UserData userData = datastore.find(userKey(userId));
        if (userData != null) {
          userData.password = password;
          datastore.put(userData);
        }
      }
    }, true);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId), e);
  }
}
 
Example #28
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public String loadSettings(final String userId) {
  final Result<String> settings = new Result<String>();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        UserData userData = datastore.find(UserData.class, userId);
        if (userData != null) {
          settings.t = userData.settings;
        } else {
          settings.t = "";
        }
      }
    }, false);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId), e);
  }
  return settings.t;
}
 
Example #29
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public String getUserName(final String userId) {
  final Result<String> name = new Result<String>();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        UserData userData = datastore.find(UserData.class, userId);
        if (userData != null) {
          name.t = userData.name;
        } else {
          name.t = "unknown";
        }
      }
    }, true);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId), e);
  }
  return name.t;
}
 
Example #30
Source File: ObjectifyStorageIo.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public String getUserLink(final String userId) {
  final Result<String> link = new Result<String>();
  try {
    runJobWithRetries(new JobRetryHelper() {
      @Override
      public void run(Objectify datastore) {
        UserData userData = datastore.find(UserData.class, userId);
        if (userData != null) {
          link.t = userData.link;
        } else {
          link.t = "unknown";
        }
      }
    }, true);
  } catch (ObjectifyException e) {
    throw CrashReport.createAndLogError(LOG, null, collectUserErrorInfo(userId), e);
  }
  return link.t;
}