コード例 #1
0
 @Override
 @Transactional(rollbackFor = {Throwable.class})
 public UserProfile updateProfile(final UserProfile userProfile) throws NoSuchUserException {
   // get the user by auth id
   UserProfile existingUser = getUserByAuthId(userProfile.getAuthId());
   if (existingUser == null) {
     throw new NoSuchUserException();
   }
   log.debug("Found a user with authID: {}, updating profile", userProfile.getAuthId());
   copyFields(userProfile, existingUser);
   hibernateTemplate.update(existingUser);
   return existingUser;
 }
コード例 #2
0
 /**
  * Copy fields for updating or display. Does <b>not</b> copy some fields:
  *
  * <ul>
  *   <li>ID: never overwrite IDs on hibernate objects
  *   <li>userAccountUri: these don't come down from display layer, so we don't want to overwrite
  *       with null
  *   <li>userProfileUri: these don't come down from display layer, so we don't want to overwrite
  *       with null
  *   <li>roles: don't want to overwrite a user's roles when updating their profile
  * </ul>
  *
  * @param source
  * @param destination
  */
 private void copyFields(UserProfile source, UserProfile destination) {
   destination.setAuthId(source.getAuthId());
   destination.setRealName(source.getRealName());
   destination.setGivenNames(source.getGivenNames());
   destination.setSurname(source.getSurname());
   destination.setTitle(source.getTitle());
   destination.setGender(source.getGender());
   destination.setEmail(source.getEmail());
   destination.setHomePage(source.getHomePage());
   destination.setWeblog(source.getWeblog());
   destination.setPublications(source.getPublications());
   destination.setDisplayName(source.getDisplayName());
   destination.setSuffix(source.getSuffix());
   destination.setPositionType(source.getPositionType());
   destination.setOrganizationName(source.getOrganizationName());
   destination.setOrganizationType(source.getOrganizationType());
   destination.setPostalAddress(source.getPostalAddress());
   destination.setCity(source.getCity());
   destination.setCountry(source.getCountry());
   destination.setBiography(source.getBiography());
   destination.setInterests(source.getInterests());
   destination.setResearchAreas(source.getResearchAreas());
   destination.setOrganizationVisibility(source.getOrganizationVisibility());
   destination.setAlertsJournals(source.getAlertsJournals());
 }
コード例 #3
0
  /**
   * Save the user's search
   *
   * @return
   */
  @Transactional(rollbackFor = {Throwable.class})
  @SuppressWarnings("unchecked")
  public String saveSearch() {
    final UserProfile user = getCurrentUser();

    if (user == null) {
      log.info("User is null for saving search");
      addActionError("You must be logged in");

      return ERROR;
    }

    // Make sure the user is authenticated, is this redundant?
    this.permissionsService.checkLogin(user.getAuthId());

    if (searchName == null || searchName.length() == 0) {
      addActionError("Search name must be specified.");
      return INPUT;
    }

    List<SavedSearchView> savedSearchViewList =
        userService.getSavedSearches(this.getCurrentUser().getID());

    for (SavedSearchView savedSearchView : savedSearchViewList) {
      if (savedSearchView.getSearchName().equals(this.searchName)) {
        addActionError("Search name must be unique.");
        return INPUT;
      }
    }

    userService.saveSearch(
        user.getID(), getSearchParameters(), searchName, this.weekly, this.monthly);

    return SUCCESS;
  }