use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.
the class RequestAccountServlet method submitAccount.
/**
* Gets user basic info and set email to the administrator
*
* @param request
* @param response
*/
private void submitAccount() throws Exception {
String otherStudy = request.getParameter("otherStudy");
String studyName = request.getParameter("studyName");
UserAccountBean ubForm = (UserAccountBean) session.getAttribute("newUserBean");
logger.info("Sending email...");
// YW << <<
StringBuffer email = new StringBuffer("From: " + ubForm.getEmail() + "\n");
email.append("Sent: " + new Date() + "\n");
email.append("To: " + SQLInitServlet.getField("adminEmail") + "\n");
email.append("Subject: Request Account\n\n\n");
email.append("Dear Admin, \n\n");
email.append(ubForm.getFirstName() + " is requesting for an account on the OpenClinica system running at " + SQLInitServlet.getField("sysURL") + ". \n\n");
email.append("His/her information is shown as follows: \n\n");
email.append(resword.getString("name") + ": " + ubForm.getFirstName() + " " + ubForm.getLastName());
email.append("\n" + resword.getString("user_name") + ": " + ubForm.getName());
email.append("\n" + resword.getString("email") + ": " + ubForm.getEmail());
email.append("\n" + resword.getString("institutional_affiliation") + ": " + ubForm.getInstitutionalAffiliation());
email.append("\n" + resword.getString("default_active_study") + ":" + studyName + ", id:" + ubForm.getActiveStudyId());
email.append("\n" + resword.getString("other_study") + otherStudy);
email.append("\n" + resword.getString("user_role_requested") + ubForm.getActiveStudyRoleName());
String emailBody = email.toString();
// YW >>
logger.info("Sending email...begin" + emailBody);
sendEmail(EmailEngine.getAdminEmail(), ubForm.getEmail().trim(), "request account", emailBody, false);
session.removeAttribute("newUserBean");
forwardPage(Page.LOGIN);
}
use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.
the class PrintAllSiteEventCRFServlet method mayProceed.
/**
* Checks whether the user has the correct privilege
*/
@Override
public void mayProceed(HttpServletRequest request, HttpServletResponse response) throws InsufficientPermissionException {
locale = LocaleResolver.getLocale(request);
UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
StudyUserRoleBean currentRole = (StudyUserRoleBean) request.getSession().getAttribute("userRole");
if (ub.isSysAdmin()) {
return;
}
if (SubmitDataServlet.mayViewData(ub, currentRole)) {
return;
}
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + respage.getString("change_study_contact_sysadmin"), request);
throw new InsufficientPermissionException(Page.MENU_SERVLET, resexception.getString("not_director"), "1");
}
use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.
the class RestoreStudyUserRoleServlet method processRequest.
@Override
public void processRequest() throws Exception {
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
String name = request.getParameter("name");
String studyIdString = request.getParameter("studyId");
if (StringUtil.isBlank(name) || StringUtil.isBlank(studyIdString)) {
addPageMessage(respage.getString("please_choose_a_user_to_restore_his_role"));
forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
} else {
String action = request.getParameter("action");
UserAccountBean user = (UserAccountBean) udao.findByUserName(name);
if ("confirm".equalsIgnoreCase(action)) {
int studyId = Integer.valueOf(studyIdString.trim()).intValue();
request.setAttribute("user", user);
StudyUserRoleBean uRole = udao.findRoleByUserNameAndStudyId(name, studyId);
request.setAttribute("uRole", uRole);
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyBean study = (StudyBean) sdao.findByPK(studyId);
request.setAttribute("uStudy", study);
forwardPage(Page.RESTORE_USER_ROLE_IN_STUDY);
} else {
// restore role
FormProcessor fp = new FormProcessor(request);
String userName = fp.getString("name");
int studyId = fp.getInt("studyId");
int roleId = fp.getInt("roleId");
StudyUserRoleBean sur = new StudyUserRoleBean();
sur.setName(userName);
sur.setRole(Role.get(roleId));
sur.setStudyId(studyId);
sur.setStatus(Status.AVAILABLE);
sur.setUpdater(ub);
sur.setUpdatedDate(new Date());
udao.updateStudyUserRole(sur, userName);
addPageMessage(sendEmail(user, sur));
forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
}
}
}
use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.
the class PrintCRFServlet method mayProceed.
// < ResourceBundlerespage,resexception;
/**
* Checks whether the user has the correct privilege
*/
@Override
public void mayProceed(HttpServletRequest request, HttpServletResponse response) throws InsufficientPermissionException {
locale = LocaleResolver.getLocale(request);
// <
// resexception=ResourceBundle.getBundle("org.akaza.openclinica.i18n.exceptions",locale);
// < respage =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.page_messages",locale);
UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
StudyUserRoleBean currentRole = (StudyUserRoleBean) request.getSession().getAttribute("userRole");
if (ub.isSysAdmin()) {
return;
}
if (SubmitDataServlet.mayViewData(ub, currentRole)) {
return;
}
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + respage.getString("change_study_contact_sysadmin"), request);
throw new InsufficientPermissionException(Page.MENU_SERVLET, resexception.getString("not_director"), "1");
}
use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.
the class RemoveStudyUserRoleServlet method processRequest.
@Override
public void processRequest() throws Exception {
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
String name = request.getParameter("name");
String studyIdString = request.getParameter("studyId");
if (StringUtil.isBlank(name) || StringUtil.isBlank(studyIdString)) {
addPageMessage(respage.getString("please_choose_a_user_to_remove_his_role"));
forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
} else {
String action = request.getParameter("action");
UserAccountBean user = (UserAccountBean) udao.findByUserName(name);
if ("confirm".equalsIgnoreCase(action)) {
int studyId = Integer.valueOf(studyIdString.trim()).intValue();
request.setAttribute("user", user);
StudyUserRoleBean uRole = udao.findRoleByUserNameAndStudyId(name, studyId);
request.setAttribute("uRole", uRole);
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyBean study = (StudyBean) sdao.findByPK(studyId);
request.setAttribute("uStudy", study);
forwardPage(Page.REMOVE_USER_ROLE_IN_STUDY);
} else {
// remove role
FormProcessor fp = new FormProcessor(request);
String userName = fp.getString("name");
int studyId = fp.getInt("studyId");
int roleId = fp.getInt("roleId");
StudyUserRoleBean sur = new StudyUserRoleBean();
sur.setName(userName);
sur.setRole(Role.get(roleId));
sur.setStudyId(studyId);
sur.setStatus(Status.DELETED);
sur.setUpdater(ub);
sur.setUpdatedDate(new Date());
udao.updateStudyUserRole(sur, userName);
addPageMessage(sendEmail(user, sur));
forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
}
}
}
Aggregations