Source:
public void checkUpdateDataPermission(HttpServletRequest request) throws InsufficientPermissionException { Boolean auth = true; UserAccountBean userBean =(UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME); StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study"); int currentStudyParentId; if(currentStudy.getParentStudyId() == 0){ currentStudyParentId = currentStudy.getId(); }else{ currentStudyParentId = currentStudy.getParentStudyId(); } ArrayList userRoles = userBean.getRoles(); String submitted =(String) request.getParameter("submitted"); String checkInputs = (String)request.getParameter("checkInputs"); if(submitted !=null && submitted.equals("1") && checkInputs!=null && checkInputs.equals("1")) { for (int i = 0; i < userRoles.size(); i++) { StudyUserRoleBean studyRole = (StudyUserRoleBean) userRoles.get(i); if(studyRole.getRole().equals(Role.MONITOR) && studyRole.getStudyId() == currentStudy.getId()) { auth = false; break; } } String studyId = (String)request.getParameter("sid"); if(studyId !=null && Integer.parseInt(studyId) != currentStudyParentId && Integer.parseInt(studyId) != currentStudy.getId()) { auth = false; } } if(!auth) { addPageMessage(respage.getString("you_not_have_permission_update_a_CRF"), request); throw new InsufficientPermissionException(Page.MENU_SERVLET, resexception.getString("no_permission_to_perform_data_entry"), "1"); } }

Target:
public void checkUpdateDataPermission(HttpServletRequest request) throws InsufficientPermissionException { Boolean auth = true; UserAccountBean userBean =(UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME); StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study"); ArrayList userRoles = userBean.getRoles(); String submitted =(String) request.getParameter("submitted"); String checkInputs = (String)request.getParameter("checkInputs"); if(submitted !=null && submitted.equals("1") && checkInputs!=null && checkInputs.equals("1")) { for (int i = 0; i < userRoles.size(); i++) { StudyUserRoleBean studyRole = (StudyUserRoleBean) userRoles.get(i); if(studyRole.getRole().equals(Role.MONITOR) && studyRole.getStudyId() == currentStudy.getId()) { auth = false; break; } } boolean currentStudyIsStudy = false; if(currentStudy.getParentStudyId() == 0){ currentStudyIsStudy = true; } String studyId = (String)request.getParameter("sid"); StudyDAO studydao = new StudyDAO(getDataSource()); StudyBean studyIdStudy = (StudyBean)studydao.findByPK(Integer.parseInt(studyId)); boolean studyIdIsStudy = false; if(studyIdStudy.getParentStudyId() == 0){ studyIdIsStudy = true; } if(currentStudyIsStudy && studyIdIsStudy){ if(currentStudy.getId() != studyIdStudy.getId()){ auth = false; } }else if(!currentStudyIsStudy && studyIdIsStudy){ if(currentStudy.getParentStudyId() != studyIdStudy.getId()){ auth = false; } }else if(currentStudyIsStudy && !studyIdIsStudy){ if(currentStudy.getId() != studyIdStudy.getParentStudyId()){ auth = false; } }else{ if(currentStudy.getParentStudyId() != studyIdStudy.getParentStudyId()){ auth = false; } } } if(!auth) { addPageMessage(respage.getString("you_not_have_permission_update_a_CRF"), request); throw new InsufficientPermissionException(Page.MENU_SERVLET, resexception.getString("no_permission_to_perform_data_entry"), "1"); } }