コード例 #1
0
 private FacebookAccount lookupFacebookAccount(String key) {
   try {
     FacebookAccount facebookAccount =
         facebookSystem.lookupFacebookAccount(SystemViewpoint.getInstance(), key);
     return facebookAccount;
   } catch (ParseException e) {
     throw new RuntimeException("Could not parse the key " + key + " as a user guid", e);
   } catch (NotFoundException e) {
     throw new RuntimeException(
         "Could not find the user or facebook account for the user with guid " + key, e);
   }
 }
コード例 #2
0
  public ExternalAccountView getExternalAccountView(
      Viewpoint viewpoint, ExternalAccount externalAccount) {
    ExternalAccountView view;
    if (externalAccount.getAccountType() == ExternalAccountType.FACEBOOK) {
      view =
          new ExternalAccountView(externalAccount, facebookSystem.getProfileLink(externalAccount));
    } else {
      view = new ExternalAccountView(externalAccount);
    }

    loadThumbnails(viewpoint, view);

    return view;
  }
コード例 #3
0
  public Set<ExternalAccountView> getExternalAccountViews(Viewpoint viewpoint, User user) {
    // Right now we ignore the viewpoint, so this method is pretty pointless.
    // but if people use it, future code will work properly.

    // be sure the account is attached... the external accounts are lazy-loaded
    if (!em.contains(user.getAccount()))
      throw new RuntimeException("detached account in getExternalAccounts()");

    Set<ExternalAccount> accounts = user.getAccount().getExternalAccounts();
    // logger.debug("{} external accounts for user {}", accounts.size(), user);

    Set<ExternalAccountView> accountViews = new HashSet<ExternalAccountView>();
    for (ExternalAccount account : accounts) {
      if (account.getAccountType() == ExternalAccountType.FACEBOOK) {
        accountViews.add(new ExternalAccountView(account, facebookSystem.getProfileLink(account)));
      } else {
        accountViews.add(new ExternalAccountView(account));
      }
    }

    return accountViews;
  }