Search in sources :

Example 71 with StudyUserRoleBean

use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.

the class BatchCRFMigrationController method runPreviewTest.

@SuppressWarnings("unchecked")
public ResponseEntity<HelperObject> runPreviewTest(TransferObject transferObject, HttpServletRequest request) throws Exception {
    HelperObject helperObject = new HelperObject();
    Locale locale = request.getLocale();
    resterms = ResourceBundleProvider.getTermsBundle(locale);
    UserAccountBean userAccountBean = getCurrentUser(request);
    ReportLog reportLog = new ReportLog();
    String studyOid = transferObject.getStudyOID();
    String sourceCrfVersion = transferObject.getSourceFormVersion();
    String targetCrfVersion = transferObject.getTargetFormVersion();
    ArrayList<String> studyEventDefnlist = transferObject.getStudyEventDefs();
    ArrayList<String> studyEventDefnlistFiltered = new ArrayList<String>();
    ArrayList<String> sitelist = transferObject.getSites();
    ArrayList<String> sitelistFiltered = new ArrayList<String>();
    FormLayoutBean sourceCrfVersionBean = fldao().findByOid(sourceCrfVersion);
    FormLayoutBean targetCrfVersionBean = fldao().findByOid(targetCrfVersion);
    StudyBean stBean = sdao().findByOid(studyOid);
    if (stBean == null || !stBean.getStatus().isAvailable() || stBean.getParentStudyId() != 0) {
        reportLog.getErrors().add(resterms.getString("The_OID_of_the_Target_Study_that_you_provided_is_invalid"));
        helperObject.setReportLog(reportLog);
        return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    }
    StudyUserRoleBean suRole = uadao().findRoleByUserNameAndStudyId(userAccountBean.getName(), stBean.getId());
    Role r = suRole.getRole();
    if (suRole == null || !(r.equals(Role.STUDYDIRECTOR) || r.equals(Role.COORDINATOR))) {
        reportLog.getErrors().add(resterms.getString("You_do_not_have_permission_to_perform_CRF_version_migration_in_this_study"));
        helperObject.setReportLog(reportLog);
        return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    }
    if (sourceCrfVersionBean == null || targetCrfVersionBean == null) {
        if (sourceCrfVersion.equals("-1") || targetCrfVersion.equals("-1")) {
            reportLog.getErrors().add(resterms.getString("Current_CRF_version_and_New_CRF_version_should_be_selected"));
        } else {
            reportLog.getErrors().add(resterms.getString("The_OID_of_the_CRF_Version_that_you_provided_is_invalid"));
        }
        helperObject.setReportLog(reportLog);
        return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    }
    if (sourceCrfVersionBean.getId() == targetCrfVersionBean.getId()) {
        reportLog.getErrors().add(resterms.getString("Current_CRF_version_and_New_CRF_version_can_not_be_same"));
        helperObject.setReportLog(reportLog);
        return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    }
    if (sourceCrfVersionBean.getCrfId() != targetCrfVersionBean.getCrfId() || !sourceCrfVersionBean.getStatus().isAvailable() || !targetCrfVersionBean.getStatus().isAvailable()) {
        reportLog.getErrors().add(resterms.getString("The_OID_of_the_CRF_Version_that_you_provided_is_invalid"));
        helperObject.setReportLog(reportLog);
        return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    }
    CRFBean cBean = (CRFBean) cdao().findByPK(sourceCrfVersionBean.getCrfId());
    if (sitelist.size() == 0) {
        ArrayList<StudyBean> listOfSites = (ArrayList<StudyBean>) sdao().findAllByParent(stBean.getId());
        sitelist.add(stBean.getOid());
        for (StudyBean s : listOfSites) {
            if (s.getStatus().isAvailable()) {
                sitelist.add(s.getOid());
            }
        }
    } else {
        for (String site : sitelist) {
            StudyBean siteBean = sdao().findByOid(site.trim());
            if (siteBean == null || getParentStudy(siteBean).getId() != stBean.getId()) {
                reportLog.getErrors().add(resterms.getString("The_OID_of_the_Site_that_you_provided_is_invalid"));
                helperObject.setReportLog(reportLog);
                return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
            } else if (siteBean.getStatus().isAvailable()) {
                sitelistFiltered.add(site);
            }
        }
        sitelist = sitelistFiltered;
    }
    if (studyEventDefnlist.size() == 0) {
        ArrayList<StudyEventDefinitionBean> listOfDefn = seddao().findAllByStudy(stBean);
        for (StudyEventDefinitionBean d : listOfDefn) {
            if (d.getStatus().isAvailable()) {
                studyEventDefnlist.add(d.getOid());
            }
        }
    } else {
        for (String studyEventDefn : studyEventDefnlist) {
            StudyEventDefinitionBean sedefnBean = seddao().findByOid(studyEventDefn);
            if (sedefnBean == null || sedefnBean.getStudyId() != stBean.getId()) {
                reportLog.getErrors().add(resterms.getString("The_OID_of_the_Event_that_you_provided_is_invalid"));
                helperObject.setReportLog(reportLog);
                return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
            } else if (sedefnBean.getStatus().isAvailable()) {
                studyEventDefnlistFiltered.add(studyEventDefn);
            }
        }
        studyEventDefnlist = studyEventDefnlistFiltered;
    }
    int eventCrfCount = ssdao().getTotalEventCrfCountForCrfMigration(sourceCrfVersionBean, targetCrfVersionBean, studyEventDefnlist, sitelist);
    reportLog.setEventCrfCount(eventCrfCount);
    int subjectCount = ssdao().getTotalCountStudySubjectForCrfMigration(sourceCrfVersionBean, targetCrfVersionBean, studyEventDefnlist, sitelist);
    reportLog.setSubjectCount(subjectCount);
    List<EventDefinitionCRFBean> crfMigrationDoesNotPerformList = edcdao().findAllCrfMigrationDoesNotPerform(sourceCrfVersionBean, targetCrfVersionBean, studyEventDefnlist, sitelist);
    for (EventDefinitionCRFBean crfMigrationDoesNotPerform : crfMigrationDoesNotPerformList) {
        StudyEventDefinitionBean seddBean = (StudyEventDefinitionBean) seddao().findByPK(crfMigrationDoesNotPerform.getStudyEventDefinitionId());
        StudyBean sssBean = (StudyBean) sdao().findByPK(crfMigrationDoesNotPerform.getStudyId());
        reportLog.getCanNotMigrate().add(resterms.getString("CRF_Version_Migration_cannot_be_performed_for") + " " + sssBean.getName() + " " + seddBean.getName() + ". " + resterms.getString("Both_CRF_versions_are_not_available_at_the_Site"));
    }
    List<EventCRFBean> eventCrfListToMigrate = ecdao().findAllCRFMigrationReportList(sourceCrfVersionBean, targetCrfVersionBean, studyEventDefnlist, sitelist);
    helperObject.setReportLog(reportLog);
    helperObject.setStBean(stBean);
    helperObject.setcBean(cBean);
    helperObject.setEventCrfListToMigrate(eventCrfListToMigrate);
    helperObject.setSourceCrfVersionBean(sourceCrfVersionBean);
    helperObject.setTargetCrfVersionBean(targetCrfVersionBean);
    helperObject.setUserAccountBean(userAccountBean);
    return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.OK);
}
Also used : Locale(java.util.Locale) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) Role(org.akaza.openclinica.bean.core.Role) HelperObject(org.akaza.openclinica.controller.helper.HelperObject) ReportLog(org.akaza.openclinica.controller.helper.ReportLog) ResponseEntity(org.springframework.http.ResponseEntity) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 72 with StudyUserRoleBean

use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.

the class AccountController method getAccountByUserName.

/**
	 * @api {post} /pages/accounts/login Retrieve a user account
	 * @apiName getAccountByUserName
	 * @apiPermission admin
	 * @apiVersion 3.8.0
	 * @apiParam {String} username OC login Username.
	 * @apiParam {String} password OC login Password .
	 * @apiGroup User Account
	 * @apiDescription Retrieve a user account
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "username": "usera",
	 *                  "password": "password"
	 *                  }
	 * @apiErrorExample {json} Error-Response:
	 *                  HTTP/1.1 401 Bad Credentials
	 *                  {
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    HTTP/1.1 200 OK
	 *                    {
	 *                    "lastName": "User",
	 *                    "username": "root",
	 *                    "roles": [
	 *                    {"roleName": "director", "studyOID": "S_DEFAULTS1"},
	 *                    {"roleName": "Data Specialist", "studyOID": "S_JAPSTUDY_5293"}
	 *                    ],
	 *                    "firstName": "Root",
	 *                    "password": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
	 *                    "apiKey": "6e8b69f6fb774e899f9a6c349c5adace"
	 *                    }
	 */
@RequestMapping(value = "/login", method = RequestMethod.POST)
public ResponseEntity<HashMap> getAccountByUserName(@RequestBody HashMap<String, String> requestMap) throws Exception {
    System.out.println("I'm in getAccountByUserName");
    String userName = requestMap.get("username");
    String password = requestMap.get("password");
    Authentication authentication = new UsernamePasswordAuthenticationToken(userName, password);
    try {
        authentication = authenticationManager.authenticate(authentication);
    } catch (Exception bce) {
        return new ResponseEntity<HashMap>(new HashMap(), org.springframework.http.HttpStatus.UNAUTHORIZED);
    }
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    UserAccountDAO userAccountDAO = new UserAccountDAO(dataSource);
    StudyDAO studyDAO = new StudyDAO(dataSource);
    HashMap<String, Object> userDTO = new HashMap<String, Object>();
    UserAccountBean userAccountBean = (UserAccountBean) userAccountDAO.findByUserName(userName);
    if (null != userAccountBean) {
        userDTO.put("username", userName);
        userDTO.put("password", userAccountBean.getPasswd());
        userDTO.put("firstName", userAccountBean.getFirstName());
        userDTO.put("lastName", userAccountBean.getLastName());
        userDTO.put("apiKey", userAccountBean.getApiKey());
        ArrayList<HashMap<String, String>> rolesDTO = new ArrayList<>();
        for (StudyUserRoleBean role : (List<StudyUserRoleBean>) userAccountBean.getRoles()) {
            HashMap<String, String> map = new HashMap<String, String>();
            map.put("roleName", role.getRoleName());
            map.put("studyOID", ((StudyBean) studyDAO.findByPK(role.getStudyId())).getOid());
            rolesDTO.add(map);
        }
        userDTO.put("roles", rolesDTO);
    } else {
        return new ResponseEntity<HashMap>(new HashMap(), org.springframework.http.HttpStatus.UNAUTHORIZED);
    }
    return new ResponseEntity<HashMap>(userDTO, org.springframework.http.HttpStatus.OK);
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) ArrayList(java.util.ArrayList) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) BadCredentialsException(org.springframework.security.authentication.BadCredentialsException) ResponseEntity(org.springframework.http.ResponseEntity) Authentication(org.springframework.security.core.Authentication) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) ArrayList(java.util.ArrayList) List(java.util.List) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 73 with StudyUserRoleBean

use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.

the class AccountController method addActiveStudyRole.

private UserAccountBean addActiveStudyRole(UserAccountBean createdUserAccountBean, int studyId, Role r, UserAccountBean ownerUserAccount) {
    StudyUserRoleBean studyUserRole = new StudyUserRoleBean();
    studyUserRole.setStudyId(studyId);
    studyUserRole.setRoleName(r.getName());
    studyUserRole.setStatus(Status.AUTO_DELETED);
    studyUserRole.setOwner(ownerUserAccount);
    createdUserAccountBean.addRole(studyUserRole);
    createdUserAccountBean.setLockCounter(3);
    createdUserAccountBean.setAccountNonLocked(false);
    return createdUserAccountBean;
}
Also used : StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean)

Example 74 with StudyUserRoleBean

use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.

the class CoreSecureController method process.

private void process(HttpServletRequest request, HttpServletResponse response) throws OpenClinicaException, UnsupportedEncodingException {
    request.setCharacterEncoding("UTF-8");
    response.setHeader("Content-Encoding", "gzip");
    HttpSession session = request.getSession();
    // BWP >> 1/8/2008
    try {
        // YW 10-03-2007 <<
        session.setMaxInactiveInterval(Integer.parseInt(SQLInitServlet.getField("max_inactive_interval")));
    // YW >>
    } catch (NumberFormatException nfe) {
        // BWP>>3600 is the datainfo.properties maxInactiveInterval on
        // 1/8/2008
        session.setMaxInactiveInterval(3600);
    }
    // If the session already has a value with key SUPPORT_URL don't reset
    if (session.getAttribute(SUPPORT_URL) == null) {
        session.setAttribute(SUPPORT_URL, SQLInitServlet.getSupportURL());
    }
    UserAccountBean ub = (UserAccountBean) session.getAttribute(USER_BEAN_NAME);
    StudyBean currentStudy = (StudyBean) session.getAttribute("study");
    StudyUserRoleBean currentRole = (StudyUserRoleBean) session.getAttribute("userRole");
    // Set current language preferences
    Locale locale = LocaleResolver.getLocale(request);
    ResourceBundleProvider.updateLocale(locale);
    resadmin = ResourceBundleProvider.getAdminBundle(locale);
    resaudit = ResourceBundleProvider.getAuditEventsBundle(locale);
    resexception = ResourceBundleProvider.getExceptionsBundle(locale);
    resformat = ResourceBundleProvider.getFormatBundle(locale);
    restext = ResourceBundleProvider.getTextsBundle(locale);
    resterm = ResourceBundleProvider.getTermsBundle(locale);
    resword = ResourceBundleProvider.getWordsBundle(locale);
    respage = ResourceBundleProvider.getPageMessagesBundle(locale);
    resworkflow = ResourceBundleProvider.getWorkflowBundle(locale);
    try {
        String userName = request.getRemoteUser();
        ServletContext context = getServletContext();
        // BWP 1/8/08<< the sm variable may already be set with a mock
        // object,
        // from the perspective of
        // JUnit servlets tests
        /*
             * if(sm==null && (!StringUtil.isBlank(userName))) {//check if user
             * logged in, then create a new sessionmanger to get ub //create a
             * new sm in order to get a new ub object sm = new
             * SessionManager(ub, userName); }
             */
        // BWP 01/08 >>
        // sm = new SessionManager(ub, userName);
        SessionManager sm = new SessionManager(ub, userName, SpringServletAccess.getApplicationContext(context));
        ub = sm.getUserBean();
        request.getSession().setAttribute("sm", sm);
        session.setAttribute("userBean", ub);
        StudyDAO sdao = new StudyDAO(getDataSource());
        if (currentStudy == null || currentStudy.getId() <= 0) {
            if (ub.getId() > 0 && ub.getActiveStudyId() > 0) {
                StudyParameterValueDAO spvdao = new StudyParameterValueDAO(getDataSource());
                currentStudy = (StudyBean) sdao.findByPK(ub.getActiveStudyId());
                ArrayList studyParameters = spvdao.findParamConfigByStudy(currentStudy);
                currentStudy.setStudyParameters(studyParameters);
                StudyConfigService scs = new StudyConfigService(getDataSource());
                if (currentStudy.getParentStudyId() <= 0) {
                    // top study
                    scs.setParametersForStudy(currentStudy);
                } else {
                    // YW <<
                    currentStudy.setParentStudyName(((StudyBean) sdao.findByPK(currentStudy.getParentStudyId())).getName());
                    // YW >>
                    scs.setParametersForSite(currentStudy);
                }
                // set up the panel here, tbh
                panel.reset();
                /*
                     * panel.setData("Study", currentStudy.getName());
                     * panel.setData("Summary", currentStudy.getSummary());
                     * panel.setData("Start Date",
                     * sdf.format(currentStudy.getDatePlannedStart()));
                     * panel.setData("End Date",
                     * sdf.format(currentStudy.getDatePlannedEnd()));
                     * panel.setData("Principal Investigator",
                     * currentStudy.getPrincipalInvestigator());
                     */
                session.setAttribute(STUDY_INFO_PANEL, panel);
            } else {
                currentStudy = new StudyBean();
            }
            // The above line is moved here since currentstudy's value is set in else block and could change
            session.setAttribute("study", currentStudy);
        } else if (currentStudy.getId() > 0) {
            // restored
            if (currentStudy.getParentStudyId() > 0) {
                currentStudy.setParentStudyName(((StudyBean) sdao.findByPK(currentStudy.getParentStudyId())).getName());
            }
        // YW >>
        }
        if (currentStudy.getParentStudyId() > 0) {
            /*
                 * The Role decription will be set depending on whether the user
                 * logged in at study lever or site level. issue-2422
                 */
            List roles = Role.toArrayList();
            for (Iterator it = roles.iterator(); it.hasNext(); ) {
                Role role = (Role) it.next();
                switch(role.getId()) {
                    case 2:
                        role.setDescription("site_Study_Coordinator");
                        break;
                    case 3:
                        role.setDescription("site_Study_Director");
                        break;
                    case 4:
                        role.setDescription("site_investigator");
                        break;
                    case 5:
                        role.setDescription("site_Data_Entry_Person");
                        break;
                    case 6:
                        role.setDescription("site_monitor");
                        break;
                    case 7:
                        role.setDescription("site_Data_Entry_Person2");
                        break;
                    default:
                }
            }
        } else {
            /*
                 * If the current study is a site, we will change the role
                 * description. issue-2422
                 */
            List roles = Role.toArrayList();
            for (Iterator it = roles.iterator(); it.hasNext(); ) {
                Role role = (Role) it.next();
                switch(role.getId()) {
                    case 2:
                        role.setDescription("Study_Coordinator");
                        break;
                    case 3:
                        role.setDescription("Study_Director");
                        break;
                    case 4:
                        role.setDescription("Investigator");
                        break;
                    case 5:
                        role.setDescription("Data_Entry_Person");
                        break;
                    case 6:
                        role.setDescription("Monitor");
                        break;
                    default:
                }
            }
        }
        if (currentRole == null || currentRole.getId() <= 0) {
            // kept as "invalid" -- YW 06-21-2007
            if (ub.getId() > 0 && currentStudy.getId() > 0 && !currentStudy.getStatus().getName().equals("removed")) {
                currentRole = ub.getRoleByStudy(currentStudy.getId());
                if (currentStudy.getParentStudyId() > 0) {
                    // Checking if currentStudy has been removed or not will
                    // ge good enough -- YW 10-17-2007
                    StudyUserRoleBean roleInParent = ub.getRoleByStudy(currentStudy.getParentStudyId());
                    // inherited role from parent study, pick the higher
                    // role
                    currentRole.setRole(Role.max(currentRole.getRole(), roleInParent.getRole()));
                }
            // logger.info("currentRole:" + currentRole.getRoleName());
            } else {
                currentRole = new StudyUserRoleBean();
            }
            session.setAttribute("userRole", currentRole);
        } else // active study has been removed.
        if (currentRole.getId() > 0 && (currentStudy.getStatus().equals(Status.DELETED) || currentStudy.getStatus().equals(Status.AUTO_DELETED))) {
            currentRole.setRole(Role.INVALID);
            currentRole.setStatus(Status.DELETED);
            session.setAttribute("userRole", currentRole);
        }
        // YW 06-19-2007 >>
        request.setAttribute("isAdminServlet", getAdminServlet());
        // logger.info(rq_names);
        if (!request.getRequestURI().endsWith("ResetPassword")) {
            passwdTimeOut(request, response, ub);
        }
        mayProceed(request, response);
        //   pingJobServer(request);
        processRequest(request, response);
    } catch (InconsistentStateException ise) {
        ise.printStackTrace();
        LOGGER.warn("InconsistentStateException: org.akaza.openclinica.control.CoreSecureController: ", ise);
        unlockCRFOnError(request);
        addPageMessage(ise.getOpenClinicaMessage(), request);
        forwardPage(ise.getGoTo(), request, response);
    } catch (InsufficientPermissionException ipe) {
        ipe.printStackTrace();
        LOGGER.warn("InsufficientPermissionException: org.akaza.openclinica.control.CoreSecureController: ", ipe);
        unlockCRFOnError(request);
        // addPageMessage(ipe.getOpenClinicaMessage());
        forwardPage(ipe.getGoTo(), request, response);
    } catch (Exception e) {
        LOGGER.error("Error processing request", e);
        unlockCRFOnError(request);
        forwardPage(Page.ERROR, request, response);
    }
}
Also used : Locale(java.util.Locale) HttpSession(javax.servlet.http.HttpSession) SessionManager(org.akaza.openclinica.core.SessionManager) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) ArrayList(java.util.ArrayList) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException) InconsistentStateException(org.akaza.openclinica.web.InconsistentStateException) ServletException(javax.servlet.ServletException) OpenClinicaException(org.akaza.openclinica.exception.OpenClinicaException) MessagingException(javax.mail.MessagingException) MailException(org.springframework.mail.MailException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) InconsistentStateException(org.akaza.openclinica.web.InconsistentStateException) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException) Role(org.akaza.openclinica.bean.core.Role) StudyConfigService(org.akaza.openclinica.dao.service.StudyConfigService) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) Iterator(java.util.Iterator) ServletContext(javax.servlet.ServletContext) List(java.util.List) ArrayList(java.util.ArrayList) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 75 with StudyUserRoleBean

use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.

the class SecureController method checkRoleByUserAndStudy.

public void checkRoleByUserAndStudy(UserAccountBean ub, int studyId, int siteId) {
    StudyUserRoleBean studyUserRole = ub.getRoleByStudy(studyId);
    StudyUserRoleBean siteUserRole = new StudyUserRoleBean();
    if (siteId != 0) {
        siteUserRole = ub.getRoleByStudy(siteId);
    }
    if (studyUserRole.getRole().equals(Role.INVALID) && siteUserRole.getRole().equals(Role.INVALID)) {
        addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
        forwardPage(Page.MENU_SERVLET);
        return;
    }
}
Also used : StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean)

Aggregations

StudyUserRoleBean (org.akaza.openclinica.bean.login.StudyUserRoleBean)76 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)35 ArrayList (java.util.ArrayList)34 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)28 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)23 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)22 Date (java.util.Date)16 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)16 Role (org.akaza.openclinica.bean.core.Role)15 HashMap (java.util.HashMap)14 Iterator (java.util.Iterator)12 InsufficientPermissionException (org.akaza.openclinica.web.InsufficientPermissionException)10 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)9 Validator (org.akaza.openclinica.control.form.Validator)6 SimpleDateFormat (java.text.SimpleDateFormat)4 HttpSession (javax.servlet.http.HttpSession)4 DatasetBean (org.akaza.openclinica.bean.extract.DatasetBean)4 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)4 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)4 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)4