コード例 #1
0
  /**
   * Check if a user is the owner or shared owner of a run
   *
   * @param user the signed in user
   * @param runId the run id
   * @return whether the user is an owner of the run
   */
  private boolean isUserOwnerOfRun(User user, Long runId) {
    boolean result = false;

    if (user != null && runId != null) {
      try {
        // get the run
        Run run = runService.retrieveById(runId);

        if (run != null) {
          // get the owners and shared owners
          Set<User> owners = run.getOwners();
          Set<User> sharedowners = run.getSharedowners();

          if (owners.contains(user) || sharedowners.contains(user)) {
            // the user is the owner or a shared owner
            result = true;
          }
        }
      } catch (ObjectNotFoundException e) {
        e.printStackTrace();
      }
    }

    return result;
  }