{
String id = request.getParameter(Constants.ID);
String oldPassword = request.getParameter(Constants.OLD_PASSWORD);
String newPassword = request.getParameter(Constants.NEW_PASSWORD);
Feedback feedback = null;
if(oldPassword==null || newPassword==null)
{
feedback = Feedback.REQUIRED_PARAMS_CHANGE_PASSWORD;
}
else if(oldPassword.equals(newPassword))
{
feedback = Feedback.PASSWORD_DID_NOT_MATCH;
}
User user = id!=null ? _userDao.get(Long.valueOf(id)) : null;
if(user==null)
{
feedback = Feedback.USER_NOT_FOUND;
}
if(Constants.XML.equals(mime))
{
writeXML(feedback==null ? user : feedback, request, response);
}
else if(Constants.JSON.equals(mime))
{
writeJSON(feedback==null ? user : feedback, request, response);
}
else
{
if(feedback==null)
feedback = Feedback.PASSWORD_CHANGED;
request.setAttribute(Constants.MSG, feedback.getMsg());
dispatchToView(user, request, response);
}
}