Package com.google.testing.testify.risk.frontend.model

Examples of com.google.testing.testify.risk.frontend.model.UserInfo


  @Override
  public boolean isWhitelisted() {
    if (isInternalUser()) {
      return true;
    }
    UserInfo user = getCurrentUserInfo(pmf.getPersistenceManager(), false);
    if (user == null) {
      return false;
    }
    return user.getIsWhitelisted();
  }
View Full Code Here


    log.info("Getting starred projects for current user.");

    PersistenceManager pm = pmf.getPersistenceManager();
    List<Long> starredProjects = Lists.newArrayList();
    try {
      UserInfo userInfo = getCurrentUserInfo(pm, true);

      // Copy list items over since we cannot return the server-side list type to client-side code.
      if (userInfo != null) {
        for (long projectId : userInfo.getStarredProjects()) {
          starredProjects.add(projectId);
        }
      }
    } finally  {
      pm.close();
View Full Code Here

  public void starProject(long projectId) {
    log.info("Starring project: " + projectId);

    PersistenceManager pm = pmf.getPersistenceManager();
    try {
      UserInfo userInfo = getCurrentUserInfo(pm, true);
      if (userInfo != null) {
        userInfo.starProject(projectId);
        pm.makePersistent(userInfo);
      }
    } finally  {
      pm.close();
    }
View Full Code Here

  public void unstarProject(long projectId) {
    log.info("Unstarring project: " + projectId);

    PersistenceManager pm = pmf.getPersistenceManager();
    try {
      UserInfo userInfo = getCurrentUserInfo(pm, true);
      if (userInfo != null) {
        userInfo.unstarProject(projectId);
        pm.makePersistent(userInfo);
      }
    } finally  {
      pm.close();
    }
View Full Code Here

    Query jdoQuery = pm.newQuery(UserInfo.class);
    jdoQuery.declareParameters("String userIdParam");
    jdoQuery.setFilter("userId == userIdParam");

    log.info("Querying for user " + currentEmail + " by id " + loggedInUserId);
    UserInfo user = queryAndReturnFirst(jdoQuery, loggedInUserId);
    if (user != null) {
      // Update email address if missing or different.
      if (!currentEmail.equals(user.getCurrentEmail())) {
        log.info("Adding or updating email for " + currentEmail + "  id " + loggedInUserId);
        user.setCurrentEmail(currentEmail);
        pm.makePersistent(user);
      }
    } else {
      // Try to find by email instead.
      log.info("Querying for user " + currentEmail + " by email instead.");
      jdoQuery = pm.newQuery(UserInfo.class);
      jdoQuery.declareParameters("String currentEmailParam");
      jdoQuery.setFilter("currentEmail == currentEmailParam");

      user = queryAndReturnFirst(jdoQuery, currentEmail);
      if (user != null) {
        // Add the user's user ID since we now know it.
        if (user.getUserId() == null || user.getUserId().equals("")) {
          log.info("Adding user ID for " + currentEmail + ".");
          user.setUserId(appEngineUser.getUserId());
          pm.makePersistent(user);
        } else {
          log.severe("Found a user by email but user ID was set to a different ID.");
          user = null;
        }
      }
    }
    if (user == null) {
      log.info("Tried to get info for " + loggedInUserId + " but no entry was found.");
      if (createIfMissing) {
        log.info("Creating new UserInfo for user: " + loggedInUserId);
        user = new UserInfo();
        user.setUserId(loggedInUserId);
        user.setCurrentEmail(currentEmail);
        pm.makePersistent(user);
      }
    }
    return user;
  }
View Full Code Here

TOP

Related Classes of com.google.testing.testify.risk.frontend.model.UserInfo

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.