Ejemplo n.º 1
0
 private List<String> getUrisFromUserAccounts(Collection<UserAccount> proxyUsers) {
   List<String> list = new ArrayList<String>();
   for (UserAccount u : proxyUsers) {
     list.add(u.getUri());
   }
   return list;
 }
Ejemplo n.º 2
0
 private String assembleUserAccountLabel(UserAccount ua) {
   String last = ua.getLastName();
   String first = ua.getFirstName();
   if (last.isEmpty()) {
     return first;
   } else if (first.isEmpty()) {
     return last;
   } else {
     return last + ", " + first;
   }
 }
Ejemplo n.º 3
0
  /** Is there an Individual associated with this user? */
  private String getAssociatedIndividualUri() {
    UserAccount userAccount = LoginStatusBean.getCurrentUser(request);
    if (userAccount == null) {
      log.debug("Not logged in? Must be cancelling the password change");
      return null;
    }

    List<String> uris = Authenticator.getInstance(request).getAssociatedIndividualUris(userAccount);
    if (uris.isEmpty()) {
      log.debug("'" + userAccount.getEmailAddress() + "' is not associated with an individual.");
      return null;
    } else {
      String uri = uris.get(0);
      log.debug("'" + userAccount.getEmailAddress() + "' is associated with an individual: " + uri);
      return uri;
    }
  }
Ejemplo n.º 4
0
  public void updateAccount() {
    userAccount.setEmailAddress(emailAddress);
    userAccount.setFirstName(firstName);
    userAccount.setLastName(lastName);

    Individual profilePage = getProfilePage(userAccount);
    if (profilePage != null) {
      userAccountsDao.setProxyAccountsOnProfile(profilePage.getURI(), proxyUris);
    }

    strategy.setAdditionalProperties(userAccount);

    userAccountsDao.updateUserAccount(userAccount);

    strategy.notifyUser();
    confirmationCode = strategy.getConfirmationCode();
  }
Ejemplo n.º 5
0
  public static String createProfile(
      IndividualDao indDao,
      DataPropertyStatementDao dpsDao,
      String profileClassUri,
      UserAccount account)
      throws InsertException {
    IndividualImpl i = new IndividualImpl();
    i.setVClassURI(profileClassUri);
    String indUri = indDao.insertNewIndividual(i);

    addProp(dpsDao, indUri, URI_FOAF_FIRST_NAME, account.getFirstName());
    addProp(dpsDao, indUri, URI_FOAF_LAST_NAME, account.getLastName());

    String label = account.getLastName() + ", " + account.getFirstName();
    addProp(dpsDao, indUri, VitroVocabulary.LABEL, label);

    return indUri;
  }
Ejemplo n.º 6
0
  public final ResponseValues showPage() {
    Map<String, Object> body = new HashMap<String, Object>();

    if (isSubmit()) {
      body.put("emailAddress", emailAddress);
      body.put("firstName", firstName);
      body.put("lastName", lastName);
      body.put("proxies", buildOngoingProxyList());
    } else {
      body.put("emailAddress", userAccount.getEmailAddress());
      body.put("firstName", userAccount.getFirstName());
      body.put("lastName", userAccount.getLastName());
      body.put("proxies", buildOriginalProxyList());
    }
    body.put("formUrls", buildUrlsMap());
    body.put("myAccountUri", userAccount.getUri());
    body.put("profileTypes", buildProfileTypesString());

    // Could I do this without exposing this mechanism? But how to search
    // for an associated profile in AJAX?
    body.put("matchingProperty", SelfEditingConfiguration.getBean(vreq).getMatchingPropertyUri());

    if (userAccount.isExternalAuthOnly()) {
      body.put("externalAuthOnly", Boolean.TRUE);
    }
    if (!errorCode.isEmpty()) {
      body.put(errorCode, Boolean.TRUE);
    }
    if (!confirmationCode.isEmpty()) {
      body.put(confirmationCode, Boolean.TRUE);
    }
    if (isProxyPanelAuthorized()) {
      body.put("showProxyPanel", Boolean.TRUE);
    }

    strategy.addMoreBodyValues(body);

    return new TemplateResponseValues(TEMPLATE_NAME, body);
  }
Ejemplo n.º 7
0
  private ProxyInfo assembleProxyInfoForUser(UserAccount proxyUser) {
    String userUri = proxyUser.getUri();
    String label = assembleUserAccountLabel(proxyUser);
    String classLabel = "";
    String imageUrl =
        UrlBuilder.getUrl(
            PlaceholderUtil.getPlaceholderImagePathForType(vreq, VitroVocabulary.USERACCOUNT));

    // Does this user have a profile? Can we get better info?
    Individual proxyProfilePage = getProfilePage(proxyUser);
    if (proxyProfilePage != null) {
      String thumbUrl = proxyProfilePage.getThumbUrl();
      if ((thumbUrl != null) && (!thumbUrl.isEmpty())) {
        imageUrl = UrlBuilder.getUrl(thumbUrl);
      }
      classLabel = getMostSpecificTypeLabel(proxyProfilePage.getURI());
    }
    return new ProxyInfo(userUri, label, classLabel, imageUrl);
  }
Ejemplo n.º 8
0
  public String assembleWelcomeMessage() {
    if (!canSeeSiteAdminPage() && !isSelfEditorWithIndividual()) {
      // A special message for unrecognized self-editors:
      return i18n.text("logged_in_but_no_profile");
    }

    String greeting = i18n.text("unknown_user_name");
    int loginCount = 0;

    UserAccount userAccount = LoginStatusBean.getCurrentUser(request);
    if (userAccount != null) {
      loginCount = userAccount.getLoginCount();
      if (StringUtils.isNotEmpty(userAccount.getFirstName())) {
        greeting = userAccount.getFirstName();
      } else if (StringUtils.isNotEmpty(userAccount.getEmailAddress())) {
        greeting = userAccount.getEmailAddress();
      }
    }

    return i18n.text("login_welcome_message", greeting, loginCount);
  }
Ejemplo n.º 9
0
 boolean isExternalAuthOnly() {
   return (userAccount != null) && userAccount.isExternalAuthOnly();
 }
Ejemplo n.º 10
0
 private boolean emailIsChanged() {
   return !emailAddress.equals(userAccount.getEmailAddress());
 }