use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.
the class ViewSectionDataEntryServlet method mayProceed.
/**
* Checks whether the user has the correct privilege
*/
@Override
public void mayProceed(HttpServletRequest request, HttpServletResponse response) throws InsufficientPermissionException {
mayAccess(request);
UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
StudyUserRoleBean currentRole = (StudyUserRoleBean) request.getSession().getAttribute("userRole");
locale = LocaleResolver.getLocale(request);
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.StudyUserRoleBean in project OpenClinica by OpenClinica.
the class BaseVSValidatorImplementation method verifyRole.
public boolean verifyRole(UserAccountBean user, int study_id, int site_id, Role excluded_role, Errors errors) {
// TODO Auto-generated method stub
// check for site role & user permission if ok -> return yes,
//if no-> check for study permissions & role
StudyUserRoleBean role = null;
if (site_id > -1) {
role = user.getRoleByStudy(site_id);
if (role.getId() != 0) {
if (excluded_role == null || (excluded_role != null && !role.getRole().equals(excluded_role))) {
return true;
}
}
}
role = user.getRoleByStudy(study_id);
if (role.getId() != 0) {
if (excluded_role == null || (excluded_role != null && !role.getRole().equals(excluded_role))) {
return true;
}
}
errors.reject("studyEventTransferValidator.insufficient_permissions", "You do not have sufficient privileges to proceed with this operation.");
return false;
}
use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.
the class BaseVSValidatorImplementation method verifyRole.
public boolean verifyRole(UserAccountBean user, int study_id, int site_id, Errors errors) {
// TODO Auto-generated method stub
// check for site role & user permission if ok -> return yes,
//if no-> check for study permissions & role
StudyUserRoleBean role = null;
if (site_id > -1) {
role = user.getRoleByStudy(site_id);
if (role.getId() != 0) {
return true;
}
}
role = user.getRoleByStudy(study_id);
if (role.getId() != 0) {
return true;
}
errors.reject("studyEventTransferValidator.insufficient_permissions", "You do not have sufficient privileges to proceed with this operation.");
return false;
}
use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.
the class CreateStudyServlet method confirmStudy1.
/**
* Validates the first section of study and save it into study bean
*
* @param request
* @param response
* @throws Exception
*/
private void confirmStudy1() throws Exception {
Validator v = new Validator(request);
FormProcessor fp = new FormProcessor(request);
v.addValidation("name", Validator.NO_BLANKS);
v.addValidation("uniqueProId", Validator.NO_BLANKS);
v.addValidation("description", Validator.NO_BLANKS);
v.addValidation("prinInvestigator", Validator.NO_BLANKS);
v.addValidation("sponsor", Validator.NO_BLANKS);
v.addValidation("secondProId", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255);
v.addValidation("collaborators", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 1000);
v.addValidation("protocolDescription", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 1000);
errors = v.validate();
// check to see if name and uniqueProId are unique, tbh
StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
ArrayList<StudyBean> allStudies = (ArrayList<StudyBean>) studyDAO.findAll();
for (StudyBean thisBean : allStudies) {
if (fp.getString("name").trim().equals(thisBean.getName())) {
MessageFormat mf = new MessageFormat("");
mf.applyPattern(respage.getString("brief_title_existed"));
Object[] arguments = { fp.getString("name").trim() };
Validator.addError(errors, "name", mf.format(arguments));
}
if (fp.getString("uniqueProId").trim().equals(thisBean.getIdentifier())) {
Validator.addError(errors, "uniqueProId", resexception.getString("unique_protocol_id_existed"));
}
}
if (fp.getString("name").trim().length() > 100) {
Validator.addError(errors, "name", resexception.getString("maximum_lenght_name_100"));
}
if (fp.getString("uniqueProId").trim().length() > 30) {
Validator.addError(errors, "uniqueProId", resexception.getString("maximum_lenght_unique_protocol_30"));
}
if (fp.getString("description").trim().length() > 255) {
Validator.addError(errors, "description", resexception.getString("maximum_lenght_brief_summary_255"));
}
if (fp.getString("prinInvestigator").trim().length() > 255) {
Validator.addError(errors, "prinInvestigator", resexception.getString("maximum_lenght_principal_investigator_255"));
}
if (fp.getString("sponsor").trim().length() > 255) {
Validator.addError(errors, "sponsor", resexception.getString("maximum_lenght_sponsor_255"));
}
if (fp.getString("officialTitle").trim().length() > 255) {
Validator.addError(errors, "officialTitle", resexception.getString("maximum_lenght_official_title_255"));
}
StudyBean studyBean = createStudyBean();
if (errors.isEmpty()) {
logger.info("no errors in the first section");
request.setAttribute("studyPhaseMap", studyPhaseMap);
request.setAttribute("statuses", Status.toActiveArrayList());
logger.info("setting arrays to request, size of list: " + Status.toArrayList().size());
if (request.getParameter("Save") != null && request.getParameter("Save").length() > 0) {
StudyDAO sdao = new StudyDAO(sm.getDataSource());
studyBean.setOwner(ub);
studyBean.setCreatedDate(new Date());
studyBean.setStatus(Status.PENDING);
studyBean = (StudyBean) sdao.create(studyBean);
StudyBean newstudyBean = (StudyBean) sdao.findByName(studyBean.getName());
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
String selectedUserIdStr = fp.getString("selectedUser");
int selectedUserId = 0;
if (selectedUserIdStr != null && selectedUserIdStr.length() > 0) {
selectedUserId = Integer.parseInt(fp.getString("selectedUser"));
}
if (selectedUserId > 0) {
UserAccountBean user = (UserAccountBean) udao.findByPK(selectedUserId);
StudyUserRoleBean sub = new StudyUserRoleBean();
sub.setRole(Role.COORDINATOR);
sub.setStudyId(newstudyBean.getId());
sub.setStatus(Status.AVAILABLE);
sub.setOwner(ub);
udao.createStudyUserRole(user, sub);
if (ub.getId() != selectedUserId) {
sub = new StudyUserRoleBean();
sub.setRole(Role.COORDINATOR);
sub.setStudyId(newstudyBean.getId());
sub.setStatus(Status.AVAILABLE);
sub.setOwner(ub);
udao.createStudyUserRole(ub, sub);
}
} else {
StudyUserRoleBean sub = new StudyUserRoleBean();
sub.setRole(Role.COORDINATOR);
sub.setStudyId(newstudyBean.getId());
sub.setStatus(Status.AVAILABLE);
sub.setOwner(ub);
udao.createStudyUserRole(ub, sub);
}
// response.sendRedirect(request.getContextPath() +
// Page.MANAGE_STUDY_MODULE);
addPageMessage(respage.getString("the_new_study_created_succesfully_current"));
forwardPage(Page.STUDY_LIST_SERVLET);
} else {
session.setAttribute("newStudy", studyBean);
forwardPage(Page.CREATE_STUDY2);
}
} else {
session.setAttribute("newStudy", studyBean);
logger.info("has validation errors in the first section");
request.setAttribute("formMessages", errors);
// request.setAttribute("facRecruitStatusMap", facRecruitStatusMap);
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
Collection users = udao.findAllByRole("coordinator", "director");
request.setAttribute("users", users);
forwardPage(Page.CREATE_STUDY1);
}
}
use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.
the class RequestStudyServlet method processRequest.
@Override
public void processRequest() throws Exception {
String action = request.getParameter("action");
StudyDAO sdao = new StudyDAO(sm.getDataSource());
ArrayList studies = sdao.findAllByStatus(Status.AVAILABLE);
ArrayList roles = Role.toArrayList();
// admin is not a user role, only used for
roles.remove(Role.ADMIN);
// tomcat
request.setAttribute("roles", roles);
request.setAttribute("studies", studies);
if (StringUtil.isBlank(action)) {
request.setAttribute("newRole", new StudyUserRoleBean());
forwardPage(Page.REQUEST_STUDY);
} else {
if ("confirm".equalsIgnoreCase(action)) {
confirm();
} else if ("submit".equalsIgnoreCase(action)) {
submit();
} else {
logger.info("here...");
forwardPage(Page.REQUEST_STUDY);
}
}
}
Aggregations