use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class SetUserRoleServlet method processRequest.
@Override
public void processRequest() throws Exception {
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
StudyDAO sdao = new StudyDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
int userId = fp.getInt("userId");
if (userId == 0) {
addPageMessage(respage.getString("please_choose_a_user_to_set_role_for"));
forwardPage(Page.LIST_USER_ACCOUNTS_SERVLET);
} else {
String action = request.getParameter("action");
UserAccountBean user = (UserAccountBean) udao.findByPK(userId);
ArrayList studies = (ArrayList) sdao.findAll();
ArrayList studiesHaveRole = (ArrayList) sdao.findAllByUser(user.getName());
studies.removeAll(studiesHaveRole);
HashSet<StudyBean> studiesNotHaveRole = new HashSet<StudyBean>();
HashSet<StudyBean> sitesNotHaveRole = new HashSet<StudyBean>();
for (int i = 0; i < studies.size(); i++) {
StudyBean study1 = (StudyBean) studies.get(i);
// TODO: implement equal() according to id
boolean hasStudy = false;
for (int j = 0; j < studiesHaveRole.size(); j++) {
StudyBean study2 = (StudyBean) studiesHaveRole.get(j);
if (study2.getId() == study1.getId()) {
hasStudy = true;
break;
}
}
if (!hasStudy) {
// YW 11-19-2007 <<
if (study1.getParentStudyId() > 0) {
sitesNotHaveRole.add(study1);
} else {
studiesNotHaveRole.add(study1);
}
// YW >>
}
}
Map roleMap = new LinkedHashMap();
for (Iterator it = getRoles().iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
// I added the below if statement , to exclude displaying on study level the newly added 'ReseachAssisstant2' role by default.
if (role.getId() != 7)
roleMap.put(role.getId(), role.getDescription());
}
Boolean changeRoles = request.getParameter("changeRoles") == null ? false : Boolean.parseBoolean(request.getParameter("changeRoles"));
int studyId = fp.getInt("studyId");
if (changeRoles) {
StudyBean study = (StudyBean) sdao.findByPK(studyId);
roleMap = new LinkedHashMap();
ResourceBundle resterm = org.akaza.openclinica.i18n.util.ResourceBundleProvider.getTermsBundle();
if (study.getParentStudyId() > 0) {
for (Iterator it = getRoles().iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
switch(role.getId()) {
// break;
case 4:
roleMap.put(role.getId(), resterm.getString("site_investigator").trim());
break;
case 5:
roleMap.put(role.getId(), resterm.getString("site_Data_Entry_Person").trim());
break;
case 6:
roleMap.put(role.getId(), resterm.getString("site_monitor").trim());
break;
case 7:
roleMap.put(role.getId(), resterm.getString("site_Data_Entry_Person2").trim());
break;
default:
}
}
} else {
for (Iterator it = getRoles().iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
switch(role.getId()) {
case 2:
roleMap.put(role.getId(), resterm.getString("Study_Coordinator").trim());
break;
case 3:
roleMap.put(role.getId(), resterm.getString("Study_Director").trim());
break;
case 4:
roleMap.put(role.getId(), resterm.getString("Investigator").trim());
break;
case 5:
roleMap.put(role.getId(), resterm.getString("Data_Entry_Person").trim());
break;
case 6:
roleMap.put(role.getId(), resterm.getString("Monitor").trim());
break;
default:
}
}
}
} else {
if (currentStudy.getParentStudyId() > 0) {
roleMap.remove(Role.COORDINATOR.getId());
roleMap.remove(Role.STUDYDIRECTOR.getId());
}
}
request.setAttribute("roles", roleMap);
request.setAttribute("studyId", studyId);
if ("confirm".equalsIgnoreCase(action) || changeRoles) {
// YW 11-19-2007 << re-order studiesNotHaveRole so that sites
// under their studies;
ArrayList finalStudiesNotHaveRole = new ArrayList();
Iterator iter_study = studiesNotHaveRole.iterator();
while (iter_study.hasNext()) {
StudyBean s = (StudyBean) iter_study.next();
finalStudiesNotHaveRole.add(s);
Iterator iter_site = sitesNotHaveRole.iterator();
while (iter_site.hasNext()) {
StudyBean site = (StudyBean) iter_site.next();
if (site.getParentStudyId() == s.getId()) {
finalStudiesNotHaveRole.add(site);
}
}
}
// YW >>
request.setAttribute("user", user);
request.setAttribute("studies", finalStudiesNotHaveRole);
StudyUserRoleBean uRole = new StudyUserRoleBean();
uRole.setFirstName(user.getFirstName());
uRole.setLastName(user.getLastName());
uRole.setUserName(user.getName());
request.setAttribute("uRole", uRole);
// ArrayList roles = Role.toArrayList();
// roles.remove(Role.ADMIN); // admin is not a user role, only used for tomcat
// if (currentStudy.getParentStudyId() > 0) {
// roles.remove(Role.COORDINATOR);
// roles.remove(Role.STUDYDIRECTOR);
// }
// request.setAttribute("roles", roles);
forwardPage(Page.SET_USER_ROLE);
} else {
// set role
String userName = fp.getString("name");
studyId = fp.getInt("studyId");
StudyBean userStudy = (StudyBean) sdao.findByPK(studyId);
int roleId = fp.getInt("roleId");
// new user role
StudyUserRoleBean sur = new StudyUserRoleBean();
sur.setName(userName);
sur.setRole(Role.get(roleId));
sur.setStudyId(studyId);
sur.setStudyName(userStudy.getName());
sur.setStatus(Status.AVAILABLE);
sur.setOwner(ub);
sur.setCreatedDate(new Date());
if (studyId > 0) {
udao.createStudyUserRole(user, sur);
addPageMessage(user.getFirstName() + " " + user.getLastName() + " (" + resword.getString("username") + ": " + user.getName() + ") " + respage.getString("has_been_granted_the_role") + " \"" + sur.getRole().getDescription() + "\" " + respage.getString("in_the_study_site") + " " + userStudy.getName() + ".");
}
ArrayList<String> pMessage = (ArrayList<String>) request.getAttribute(SecureController.PAGE_MESSAGE);
String url = response.encodeRedirectURL("ListUserAccounts" + "?alertmessage=" + URLEncoder.encode(pMessage.get(0), "UTF-8"));
response.sendRedirect(url);
// forwardPage(Page.LIST_USER_ACCOUNTS_SERVLET);
}
}
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class RemoveStudyServlet method processRequest.
@Override
public void processRequest() throws Exception {
StudyDAO sdao = new StudyDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
int studyId = fp.getInt("id");
StudyBean study = (StudyBean) sdao.findByPK(studyId);
// find all sites
ArrayList sites = (ArrayList) sdao.findAllByParent(studyId);
// find all user and roles in the study, include ones in sites
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
ArrayList userRoles = udao.findAllByStudyId(studyId);
// find all subjects in the study, include ones in sites
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
ArrayList subjects = ssdao.findAllByStudy(study);
// find all events in the study, include ones in sites
StudyEventDefinitionDAO sefdao = new StudyEventDefinitionDAO(sm.getDataSource());
ArrayList definitions = sefdao.findAllByStudy(study);
String action = request.getParameter("action");
if (studyId == 0) {
addPageMessage(respage.getString("please_choose_a_study_to_remove"));
forwardPage(Page.STUDY_LIST_SERVLET);
} else {
if ("confirm".equalsIgnoreCase(action)) {
request.setAttribute("studyToRemove", study);
request.setAttribute("sitesToRemove", sites);
request.setAttribute("userRolesToRemove", userRoles);
request.setAttribute("subjectsToRemove", subjects);
request.setAttribute("definitionsToRemove", definitions);
forwardPage(Page.REMOVE_STUDY);
} else {
logger.info("submit to remove the study");
// change all statuses to unavailable
StudyDAO studao = new StudyDAO(sm.getDataSource());
study.setOldStatus(study.getStatus());
study.setStatus(Status.DELETED);
study.setUpdater(ub);
study.setUpdatedDate(new Date());
studao.update(study);
// remove all sites
for (int i = 0; i < sites.size(); i++) {
StudyBean site = (StudyBean) sites.get(i);
if (!site.getStatus().equals(Status.DELETED)) {
site.setOldStatus(site.getStatus());
site.setStatus(Status.AUTO_DELETED);
site.setUpdater(ub);
site.setUpdatedDate(new Date());
sdao.update(site);
}
}
// remove all users and roles
for (int i = 0; i < userRoles.size(); i++) {
StudyUserRoleBean role = (StudyUserRoleBean) userRoles.get(i);
logger.info("remove user role" + role.getName());
if (!role.getStatus().equals(Status.DELETED)) {
role.setStatus(Status.AUTO_DELETED);
role.setUpdater(ub);
role.setUpdatedDate(new Date());
udao.updateStudyUserRole(role, role.getUserName());
}
}
// YW << bug fix for that current active study has been deleted
if (study.getId() == currentStudy.getId()) {
currentStudy.setStatus(Status.DELETED);
currentRole.setStatus(Status.DELETED);
} else // (auto-removed)
if (currentStudy.getParentStudyId() == study.getId()) {
currentStudy.setStatus(Status.AUTO_DELETED);
// we may need handle this later?
currentRole.setStatus(Status.DELETED);
}
// remove all subjects
for (int i = 0; i < subjects.size(); i++) {
StudySubjectBean subject = (StudySubjectBean) subjects.get(i);
if (!subject.getStatus().equals(Status.DELETED)) {
subject.setStatus(Status.AUTO_DELETED);
subject.setUpdater(ub);
subject.setUpdatedDate(new Date());
ssdao.update(subject);
}
}
// remove all study_group_class
// changed by jxu on 08-31-06, to fix the problem of no study_id
// in study_group table
StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
// YW 09-27-2007, enable status updating for StudyGroupClassBean
ArrayList groups = sgcdao.findAllByStudy(study);
for (int i = 0; i < groups.size(); i++) {
StudyGroupClassBean group = (StudyGroupClassBean) groups.get(i);
if (!group.getStatus().equals(Status.DELETED)) {
group.setStatus(Status.AUTO_DELETED);
group.setUpdater(ub);
group.setUpdatedDate(new Date());
sgcdao.update(group);
// all subject_group_map
ArrayList subjectGroupMaps = sgmdao.findAllByStudyGroupClassId(group.getId());
for (int j = 0; j < subjectGroupMaps.size(); j++) {
SubjectGroupMapBean sgMap = (SubjectGroupMapBean) subjectGroupMaps.get(j);
if (!sgMap.getStatus().equals(Status.DELETED)) {
sgMap.setStatus(Status.AUTO_DELETED);
sgMap.setUpdater(ub);
sgMap.setUpdatedDate(new Date());
sgmdao.update(sgMap);
}
}
}
}
ArrayList groupClasses = sgcdao.findAllActiveByStudy(study);
for (int i = 0; i < groupClasses.size(); i++) {
StudyGroupClassBean gc = (StudyGroupClassBean) groupClasses.get(i);
if (!gc.getStatus().equals(Status.DELETED)) {
gc.setStatus(Status.AUTO_DELETED);
gc.setUpdater(ub);
gc.setUpdatedDate(new Date());
sgcdao.update(gc);
}
}
// remove all event definitions and event
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
for (int i = 0; i < definitions.size(); i++) {
StudyEventDefinitionBean definition = (StudyEventDefinitionBean) definitions.get(i);
if (!definition.getStatus().equals(Status.DELETED)) {
definition.setStatus(Status.AUTO_DELETED);
definition.setUpdater(ub);
definition.setUpdatedDate(new Date());
sefdao.update(definition);
ArrayList edcs = (ArrayList) edcdao.findAllByDefinition(definition.getId());
for (int j = 0; j < edcs.size(); j++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) edcs.get(j);
if (!edc.getStatus().equals(Status.DELETED)) {
edc.setStatus(Status.AUTO_DELETED);
edc.setUpdater(ub);
edc.setUpdatedDate(new Date());
edcdao.update(edc);
}
}
ArrayList events = (ArrayList) sedao.findAllByDefinition(definition.getId());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
for (int j = 0; j < events.size(); j++) {
StudyEventBean event = (StudyEventBean) events.get(j);
if (!event.getStatus().equals(Status.DELETED)) {
event.setStatus(Status.AUTO_DELETED);
event.setUpdater(ub);
event.setUpdatedDate(new Date());
sedao.update(event);
ArrayList eventCRFs = ecdao.findAllByStudyEvent(event);
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
for (int k = 0; k < eventCRFs.size(); k++) {
EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(k);
if (!eventCRF.getStatus().equals(Status.DELETED)) {
eventCRF.setOldStatus(eventCRF.getStatus());
eventCRF.setStatus(Status.AUTO_DELETED);
eventCRF.setUpdater(ub);
eventCRF.setUpdatedDate(new Date());
ecdao.update(eventCRF);
ArrayList itemDatas = iddao.findAllByEventCRFId(eventCRF.getId());
for (int a = 0; a < itemDatas.size(); a++) {
ItemDataBean item = (ItemDataBean) itemDatas.get(a);
if (!item.getStatus().equals(Status.DELETED)) {
item.setOldStatus(item.getStatus());
item.setStatus(Status.AUTO_DELETED);
item.setUpdater(ub);
item.setUpdatedDate(new Date());
iddao.update(item);
}
}
}
}
}
}
}
}
// for definitions
DatasetDAO datadao = new DatasetDAO(sm.getDataSource());
ArrayList dataset = datadao.findAllByStudyId(study.getId());
for (int i = 0; i < dataset.size(); i++) {
DatasetBean data = (DatasetBean) dataset.get(i);
if (!data.getStatus().equals(Status.DELETED)) {
data.setStatus(Status.AUTO_DELETED);
data.setUpdater(ub);
data.setUpdatedDate(new Date());
datadao.update(data);
}
}
addPageMessage(resexception.getString("this_study_has_been_removed_succesfully"));
forwardPage(Page.STUDY_LIST_SERVLET);
}
}
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class ListSubjectServlet method processRequest.
@Override
public void processRequest() throws Exception {
SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
StudyDAO studyDao = new StudyDAO(sm.getDataSource());
UserAccountDAO uadao = new UserAccountDAO(sm.getDataSource());
ListSubjectTableFactory factory = new ListSubjectTableFactory();
factory.setSubjectDao(sdao);
factory.setStudySubjectDao(subdao);
factory.setUserAccountDao(uadao);
factory.setStudyDao(studyDao);
factory.setCurrentStudy(currentStudy);
String auditLogsHtml = factory.createTable(request, response).render();
request.setAttribute("listSubjectsHtml", auditLogsHtml);
forwardPage(Page.SUBJECT_LIST);
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class ViewStudyServlet method processRequest.
@Override
public void processRequest() throws Exception {
StudyDAO sdao = new StudyDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
int studyId = fp.getInt("id");
if (studyId == 0) {
addPageMessage(respage.getString("please_choose_a_study_to_view"));
forwardPage(Page.STUDY_LIST_SERVLET);
} else {
if (currentStudy.getId() != studyId && currentStudy.getParentStudyId() != studyId) {
checkRoleByUserAndStudy(ub, studyId, 0);
}
String viewFullRecords = fp.getString("viewFull");
StudyBean study = (StudyBean) sdao.findByPK(studyId);
StudyConfigService scs = new StudyConfigService(sm.getDataSource());
study = scs.setParametersForStudy(study);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String randomizationStatusInOC = spvdao.findByHandleAndStudy(study.getId(), "randomization").getValue();
String participantStatusInOC = spvdao.findByHandleAndStudy(study.getId(), "participantPortal").getValue();
if (participantStatusInOC == "")
participantStatusInOC = "disabled";
if (randomizationStatusInOC == "")
randomizationStatusInOC = "disabled";
RandomizationRegistrar randomizationRegistrar = new RandomizationRegistrar();
SeRandomizationDTO seRandomizationDTO = randomizationRegistrar.getCachedRandomizationDTOObject(study.getOid(), false);
if (seRandomizationDTO != null && seRandomizationDTO.getStatus().equalsIgnoreCase("ACTIVE") && randomizationStatusInOC.equalsIgnoreCase("enabled")) {
study.getStudyParameterConfig().setRandomization("enabled");
} else {
study.getStudyParameterConfig().setRandomization("disabled");
}
;
ParticipantPortalRegistrar participantPortalRegistrar = new ParticipantPortalRegistrar();
String pStatus = participantPortalRegistrar.getCachedRegistrationStatus(study.getOid(), session);
if (participantPortalRegistrar != null && pStatus.equalsIgnoreCase("ACTIVE") && participantStatusInOC.equalsIgnoreCase("enabled")) {
study.getStudyParameterConfig().setParticipantPortal("enabled");
} else {
study.getStudyParameterConfig().setParticipantPortal("disabled");
}
;
request.setAttribute("studyToView", study);
if ("yes".equalsIgnoreCase(viewFullRecords)) {
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
ArrayList sites = new ArrayList();
ArrayList userRoles = new ArrayList();
ArrayList subjects = new ArrayList();
if (this.currentStudy.getParentStudyId() > 0 && this.currentRole.getRole().getId() > 3) {
sites.add(this.currentStudy);
userRoles = udao.findAllUsersByStudy(currentStudy.getId());
subjects = ssdao.findAllByStudy(currentStudy);
} else {
sites = (ArrayList) sdao.findAllByParent(studyId);
userRoles = udao.findAllUsersByStudy(studyId);
subjects = ssdao.findAllByStudy(study);
}
// find all subjects in the study, include ones in sites
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
// StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
// ArrayList displayStudySubs = new ArrayList();
// for (int i = 0; i < subjects.size(); i++) {
// StudySubjectBean studySub = (StudySubjectBean) subjects.get(i);
// // find all events
// ArrayList events = sedao.findAllByStudySubject(studySub);
//
// // find all eventcrfs for each event
// EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
//
// DisplayStudySubjectBean dssb = new DisplayStudySubjectBean();
// dssb.setStudyEvents(events);
// dssb.setStudySubject(studySub);
// displayStudySubs.add(dssb);
// }
// find all events in the study, include ones in sites
ArrayList definitions = seddao.findAllByStudy(study);
for (int i = 0; i < definitions.size(); i++) {
StudyEventDefinitionBean def = (StudyEventDefinitionBean) definitions.get(i);
ArrayList crfs = (ArrayList) edcdao.findAllActiveParentsByEventDefinitionId(def.getId());
def.setCrfNum(crfs.size());
}
String moduleManager = CoreResources.getField("moduleManager");
request.setAttribute("moduleManager", moduleManager);
String portalURL = CoreResources.getField("portalURL");
request.setAttribute("portalURL", portalURL);
request.setAttribute("config", study);
request.setAttribute("sitesToView", sites);
request.setAttribute("siteNum", sites.size() + "");
request.setAttribute("userRolesToView", userRoles);
request.setAttribute("userNum", userRoles.size() + "");
// request.setAttribute("subjectsToView", displayStudySubs);
// request.setAttribute("subjectNum", subjects.size() + "");
request.setAttribute("definitionsToView", definitions);
request.setAttribute("defNum", definitions.size() + "");
forwardPage(Page.VIEW_FULL_STUDY);
} else {
forwardPage(Page.VIEW_STUDY);
}
}
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class ResetPasswordServlet method processRequest.
/**
* Tasks include:
* <ol>
* <li>Validation:
* <ol>
* <li>1. old password match database record
* <li>2. new password is follows requirements
* <li>4. two times entered passwords are same
* <li>5. all required fields are filled
* </ol>
* <li>Update ub - UserAccountBean - in session and database
* </ol>
*/
@Override
public void processRequest() throws Exception {
logger.info("Change expired password");
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
Validator v = new Validator(request);
errors.clear();
FormProcessor fp = new FormProcessor(request);
String mustChangePwd = request.getParameter("mustChangePwd");
String newPwd = fp.getString("passwd").trim();
String passwdChallengeQ = fp.getString("passwdChallengeQ");
String passwdChallengeA = fp.getString("passwdChallengeA");
if ("yes".equalsIgnoreCase(mustChangePwd)) {
addPageMessage(respage.getString("your_password_has_expired_must_change"));
} else {
addPageMessage(respage.getString("password_expired") + " " + respage.getString("if_you_do_not_want_change_leave_blank"));
}
request.setAttribute("mustChangePass", mustChangePwd);
String oldPwd = fp.getString("oldPasswd").trim();
// user bean from web
UserAccountBean ubForm = new UserAccountBean();
// form
ubForm.setPasswd(oldPwd);
ubForm.setPasswdChallengeQuestion(passwdChallengeQ);
ubForm.setPasswdChallengeAnswer(passwdChallengeA);
request.setAttribute("userBean1", ubForm);
SecurityManager sm = ((SecurityManager) SpringServletAccess.getApplicationContext(context).getBean("securityManager"));
if (!sm.isPasswordValid(ub.getPasswd(), oldPwd, getUserDetails())) {
Validator.addError(errors, "oldPasswd", resexception.getString("wrong_old_password"));
request.setAttribute("formMessages", errors);
forwardPage(Page.RESET_PASSWORD);
} else {
if (mustChangePwd.equalsIgnoreCase("yes")) {
v.addValidation("passwd", Validator.NO_BLANKS);
v.addValidation("passwd1", Validator.NO_BLANKS);
v.addValidation("passwdChallengeQ", Validator.NO_BLANKS);
v.addValidation("passwdChallengeA", Validator.NO_BLANKS);
v.addValidation("passwd", Validator.CHECK_DIFFERENT, "oldPasswd");
}
String newDigestPass = sm.encrytPassword(newPwd, getUserDetails());
List<String> pwdErrors = new ArrayList<String>();
if (!StringUtils.isEmpty(newPwd)) {
v.addValidation("passwd", Validator.IS_A_PASSWORD);
v.addValidation("passwd1", Validator.CHECK_SAME, "passwd");
ConfigurationDao configurationDao = SpringServletAccess.getApplicationContext(context).getBean(ConfigurationDao.class);
PasswordRequirementsDao passwordRequirementsDao = new PasswordRequirementsDao(configurationDao);
Locale locale = LocaleResolver.getLocale(request);
ResourceBundle resexception = ResourceBundleProvider.getExceptionsBundle(locale);
pwdErrors = PasswordValidator.validatePassword(passwordRequirementsDao, udao, ub.getId(), newPwd, newDigestPass, resexception);
}
errors = v.validate();
for (String err : pwdErrors) {
v.addError(errors, "passwd", err);
}
if (!errors.isEmpty()) {
logger.info("ResetPassword page has validation errors");
request.setAttribute("formMessages", errors);
forwardPage(Page.RESET_PASSWORD);
} else {
logger.info("ResetPassword page has no errors");
if (!StringUtils.isBlank(newPwd)) {
ub.setPasswd(newDigestPass);
ub.setPasswdTimestamp(new Date());
} else if ("no".equalsIgnoreCase(mustChangePwd)) {
ub.setPasswdTimestamp(new Date());
}
ub.setOwner(ub);
// when update ub, updator id is required
ub.setUpdater(ub);
ub.setPasswdChallengeQuestion(passwdChallengeQ);
ub.setPasswdChallengeAnswer(passwdChallengeA);
udao.update(ub);
ArrayList<String> pageMessages = new ArrayList<String>();
request.setAttribute(PAGE_MESSAGE, pageMessages);
addPageMessage(respage.getString("your_expired_password_reset_successfully"));
ub.incNumVisitsToMainMenu();
forwardPage(Page.MENU_SERVLET);
}
}
}
Aggregations