public void setTheseUsersAsShared(List<String> usernames, Experiment experiment) { Set<User> newSharedList = new HashSet<User>(); for (String username : usernames) { if (!username.equals("false")) { User user = userDAO.getUser(username); newSharedList.add(user); } } experiment.setSharedList(newSharedList); update(experiment); }
public String execute() { getUser().setFullName(userToEdit.getFullName()); getUser().setEmail(userToEdit.getEmail()); getUser().setInstitution(userToEdit.getInstitution()); getUser().setResearchInterest(userToEdit.getResearchInterest()); getUser().setShowEmail(userToEdit.getShowEmail()); if (file != null && filename != null) { if (contentType.equals("image/jpeg") || contentType.equals("image/gif") || contentType.equals("image/png")) { try { Photo photo = photoService.createPhoto(file); getUser().setPhoto(photo); System.out.println("Set photo"); } catch (IOException e) { log.info(e); addFieldError("uploadFile", "Oops, the photo upload failed for some reason"); } } else { addFieldError("uploadFile", "Photo must be a jpeg, png, or gif"); log.info("Uploaded invalid photo file: " + filename); } } if (userToEdit.getPassword() != null && userToEdit.getPassword().trim().length() > 0) { if (!userToEdit.getPassword().equals(passwordConfirm)) { addFieldError("userToEdit.password", "Passwords do not match"); log.debug("Mismatched passwords"); return ERROR; } getUser().setPassword(getUserToEdit().getPassword().trim()); try { getUser().encryptPassword(); } catch (NoSuchAlgorithmException e) { log.error(e.getMessage()); addFieldError("userToEdit.password", "Failed to encrypt password"); return ERROR; } } userDAO.update(getUser()); return SUCCESS; }