Search in sources :

Example 26 with UserAccountBean

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);
}
Also used : UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) Date(java.util.Date)

Example 27 with UserAccountBean

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");
}
Also used : StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException)

Example 28 with UserAccountBean

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);
        }
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) Date(java.util.Date)

Example 29 with UserAccountBean

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");
}
Also used : StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException)

Example 30 with UserAccountBean

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);
        }
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) Date(java.util.Date)

Aggregations

UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)152 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)64 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)56 ArrayList (java.util.ArrayList)52 HashMap (java.util.HashMap)38 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)36 StudyUserRoleBean (org.akaza.openclinica.bean.login.StudyUserRoleBean)35 Date (java.util.Date)32 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)32 Locale (java.util.Locale)30 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)18 Iterator (java.util.Iterator)16 InsufficientPermissionException (org.akaza.openclinica.web.InsufficientPermissionException)16 ResponseEntity (org.springframework.http.ResponseEntity)16 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)15 Validator (org.akaza.openclinica.control.form.Validator)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 Role (org.akaza.openclinica.bean.core.Role)11 DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)10 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)10