protected ActionForward doUpdate(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserForm user = (UserForm) form;
super.validateClientId(request, user);
ActionMessages msgs = new ActionMessages();
// ��֤�û����ϱ�
user.validateUserForm(request, msgs, false);
while (msgs.isEmpty()) {
UserBean loginUser = super.getLoginUser(request, response);
if(loginUser == null) {
msgs.add("user", new ActionMessage("error.user_not_login"));
break;
}
if(loginUser.getId() != user.getId()){
msgs.add("user", new ActionMessage("error.access_deny"));
break;
}
UserBean ubean = UserDAO.getUserByID(user.getId());
if (ubean == null || ubean.getStatus()!=UserBean.STATUS_NORMAL) {
msgs.add("id", new ActionMessage("error.user_not_available",
new Integer(user.getId())));
break;
}
if (!StringUtils.equals(ubean.getPassword(), user
.getPassword())){
msgs.add("password",
new ActionMessage("error.user_auth_failed"));
break;
}
ubean.setNickname(super.autoFiltrate(null, user.getNickname()));
if(user.getBirth()!=null && user.getBirth().before(new Date()))
ubean.setBirth(user.getBirth());
else if(ubean.getBirth()!=null)
ubean.setBirth(null);
ubean.setSex(user.getSex());
if (StringUtils.isNotEmpty(user.getResume()))
ubean.setResume(super.autoFiltrate(null, StringUtils.extractText(user.getResume())));
else
ubean.setResume(null);
if (!StringUtils.equals(ubean.getPassword(), user.getPassword2())
&& StringUtils.isNotEmpty(user.getPassword2()))
ubean.setPassword(user.getPassword2());
if (StringUtils.isNotEmpty(user.getEmail()))
ubean.setEmail(user.getEmail());
else
ubean.setEmail(null);
if (StringUtils.isNotEmpty(user.getHomePage()))
ubean.setHomePage(user.getHomePage());
else
ubean.setHomePage(null);
if (StringUtils.isNotEmpty(user.getMobile()))
ubean.setMobile(user.getMobile());
else
ubean.setMobile(null);
if (StringUtils.isNotEmpty(user.getMsn()))
ubean.setMsn(user.getMsn());
else
ubean.setMsn(null);
if (StringUtils.isNotEmpty(user.getQq()))
ubean.setQq(user.getQq());
else
ubean.setQq(null);
if(!StringUtils.equals(ubean.getProvince(), user.getProvince()))
ubean.setProvince(user.getProvince());
if(!StringUtils.equals(ubean.getCity(), user.getCity()))
ubean.setCity(user.getCity());
if(user.getRemovePortrait()==1)
ubean.setPortrait(null);
else{
String portrait_uri = handleUserPortrait(ubean.getId(), user.getPortrait());
if(StringUtils.isNotEmpty(portrait_uri))
ubean.setPortrait(portrait_uri);
}
try {
DLOGUserManager.update(ubean);
//����session�е��û�����
UserLoginManager.updateLoginUser(request, ubean);
} catch (Exception e) {
msgs.add("result", new ActionMessage("error.database", e
.getMessage()));
}
break;
}
if (!msgs.isEmpty()) {
saveMessages(request, msgs);
return mapping.findForward("edituser");
}
StringBuffer ext = new StringBuffer();