@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String userLogin = request.getParameter("login");
UserAccount userAccount = SessionUtil.getInstance().getUserAccountManager()
.getUserAccount(userLogin);
ContestManager contestManager = SessionUtil.getInstance().getContestManager();
if (userAccount != null) {
if (request.getParameter("password") != null && request.getParameter("password") != "") {
userAccount.setPassword(request.getParameter("password"));
userAccount.setPasswordHash(ServletUtil.encryptPassword(userAccount.getPassword()));
}
if (request.getParameter("contest") != null) {
userAccount.getContestIds().add(request.getParameter("contest"));
contestManager.registerUserForContest(request.getParameter("contest"), userLogin);
}
else if (request.getParameterValues("contests") != null) {
userAccount.getContestIds().clear();
for (String contest : request.getParameterValues("contests")) {
userAccount.getContestIds().add(contest);
contestManager.registerUserForContest(contest, userLogin);
}
} else {
userAccount.setContestIds(null);
}
SessionUtil.getInstance().getUserAccountManager().update(userAccount);
}
response.sendRedirect("accounts");