Program: 115167
Project: 115167
Buggy source:
@Override public void processRequest(HttpServletRequest request,HttpServletResponse response) throws Exception {
  FormProcessor fp=new FormProcessor(request);
  SessionManager sm=(SessionManager)request.getSession().getAttribute("String_Node_Str");
  EventCRFBean ecb=(EventCRFBean)request.getAttribute(INPUT_EVENT_CRF);
  SectionBean sb=(SectionBean)request.getAttribute(SECTION_BEAN);
  ArrayList<SectionBean> allSectionBeans;
  int siteId=fp.getInt("String_Node_Str");
  boolean isSubmitted=false;
  StudyEventDefinitionDAO sedao=new StudyEventDefinitionDAO(sm.getDataSource());
  EventDefinitionCRFDAO edao=new EventDefinitionCRFDAO(sm.getDataSource());
  EventDefinitionCRFDAO edcdao=new EventDefinitionCRFDAO(sm.getDataSource());
  StudyDAO studyDao=new StudyDAO(sm.getDataSource());
  StudyBean site=(StudyBean)studyDao.findByPK(siteId);
  ArrayList<StudyEventDefinitionBean> seds=new ArrayList<StudyEventDefinitionBean>();
  seds=sedao.findAllByStudy(site);
  CRFVersionDAO cvdao=new CRFVersionDAO(sm.getDataSource());
  CRFDAO cdao=new CRFDAO(sm.getDataSource());
  ArrayList<EventDefinitionCRFBean> edcs=new ArrayList();
  for (  StudyEventDefinitionBean sed : seds) {
    int defId=sed.getId();
    edcs.addAll(edcdao.findAllByDefinitionAndSiteIdAndParentStudyId(defId,siteId,site.getParentStudyId()));
  }
  Map eventDefinitionDefaultVersions=new LinkedHashMap();
  for (int i=0; i < edcs.size(); i++) {
    EventDefinitionCRFBean edc=edcs.get(i);
    ArrayList versions=(ArrayList)cvdao.findAllByCRF(edc.getCrfId());
    edc.setVersions(versions);
    CRFBean crf=(CRFBean)cdao.findByPK(edc.getCrfId());
    edc.setCrfName(crf.getName());
    if (crf.getStatus().equals(Status.AVAILABLE)) {
      edc.setOwner(crf.getOwner());
    }
    CRFVersionBean defaultVersion=(CRFVersionBean)cvdao.findByPK(edc.getDefaultVersionId());
    StudyEventDefinitionBean studyEventDefinitionBean=(StudyEventDefinitionBean)sedao.findByPK(edc.getStudyEventDefinitionId());
    edc.setDefaultVersionName(defaultVersion.getName());
    if (defaultVersion.getStatus().isAvailable()) {
      List list=(ArrayList)eventDefinitionDefaultVersions.get(studyEventDefinitionBean);
      if (list == null)       list=new ArrayList();
      list.add(defaultVersion);
      eventDefinitionDefaultVersions.put(studyEventDefinitionBean,list);
    }
  }
  String isIE=fp.getString("String_Node_Str");
  if ("String_Node_Str".equalsIgnoreCase(isIE)) {
    request.setAttribute("String_Node_Str","String_Node_Str");
  }
  SectionDAO sdao=new SectionDAO(sm.getDataSource());
  CRFVersionDAO crfVersionDAO=new CRFVersionDAO(sm.getDataSource());
  CRFDAO crfDao=new CRFDAO(sm.getDataSource());
  Map sedCrfBeans=null;
  for (Iterator it=eventDefinitionDefaultVersions.keySet().iterator(); it.hasNext(); ) {
    if (sedCrfBeans == null)     sedCrfBeans=new LinkedHashMap();
    StudyEventDefinitionBean sedBean=(StudyEventDefinitionBean)it.next();
    List crfVersions=(ArrayList)eventDefinitionDefaultVersions.get(sedBean);
    for (Iterator crfIt=crfVersions.iterator(); crfIt.hasNext(); ) {
      CRFVersionBean crfVersionBean=(CRFVersionBean)crfIt.next();
      allSectionBeans=new ArrayList<SectionBean>();
      ArrayList sectionBeans=new ArrayList();
      ItemGroupDAO itemGroupDao=new ItemGroupDAO(sm.getDataSource());
      List<ItemGroupBean> itemGroupBeans=itemGroupDao.findOnlyGroupsByCRFVersionID(crfVersionBean.getId());
      CRFBean crfBean=crfDao.findByVersionId(crfVersionBean.getId());
      if (itemGroupBeans.size() > 0) {
        DisplaySectionBeanHandler handler=new DisplaySectionBeanHandler(false,getDataSource(),getServletContext());
        handler.setCrfVersionId(crfVersionBean.getId());
        List<DisplaySectionBean> displaySectionBeans=handler.getDisplaySectionBeans();
        request.setAttribute("String_Node_Str",displaySectionBeans);
        CRFVersionBean crfverBean=(CRFVersionBean)crfVersionDAO.findByPK(crfVersionBean.getId());
        request.setAttribute("String_Node_Str",crfverBean);
        request.setAttribute("String_Node_Str",crfBean);
        request.setAttribute("String_Node_Str","String_Node_Str");
        PrintCRFBean printCrfBean=new PrintCRFBean();
        printCrfBean.setDisplaySectionBeans(displaySectionBeans);
        printCrfBean.setCrfVersionBean(crfVersionBean);
        printCrfBean.setCrfBean(crfBean);
        printCrfBean.setEventCrfBean(ecb);
        printCrfBean.setGrouped(true);
        List list=(ArrayList)sedCrfBeans.get(sedBean);
        if (list == null)         list=new ArrayList();
        list.add(printCrfBean);
        sedCrfBeans.put(sedBean,list);
        continue;
      }
      ecb=new EventCRFBean();
      ecb.setCRFVersionId(crfVersionBean.getId());
      CRFVersionBean version=(CRFVersionBean)crfVersionDAO.findByPK(crfVersionBean.getId());
      ArrayList sects=(ArrayList)sdao.findByVersionId(version.getId());
      for (int i=0; i < sects.size(); i++) {
        sb=(SectionBean)sects.get(i);
        int sectId=sb.getId();
        if (sectId > 0) {
          allSectionBeans.add((SectionBean)sdao.findByPK(sectId));
        }
      }
      request.setAttribute(INPUT_EVENT_CRF,ecb);
      request.setAttribute(SECTION_BEAN,sb);
      request.setAttribute(ALL_SECTION_BEANS,allSectionBeans);
      sectionBeans=super.getAllDisplayBeans(request);
      DisplaySectionBean dsb=super.getDisplayBean(false,false,request,isSubmitted);
      PrintCRFBean printCrfBean=new PrintCRFBean();
      printCrfBean.setAllSections(sectionBeans);
      printCrfBean.setDisplaySectionBean(dsb);
      printCrfBean.setEventCrfBean(ecb);
      printCrfBean.setCrfVersionBean(crfVersionBean);
      printCrfBean.setCrfBean(crfBean);
      printCrfBean.setGrouped(false);
      List list=(ArrayList)sedCrfBeans.get(sedBean);
      if (list == null)       list=new ArrayList();
      list.add(printCrfBean);
      sedCrfBeans.put(sedBean,list);
    }
  }
  StudyBean parentStudy=(StudyBean)studyDao.findByPK(site.getParentStudyId());
  String studyName=parentStudy.getName();
  String siteName=site.getName();
  request.setAttribute("String_Node_Str",sedCrfBeans);
  request.setAttribute("String_Node_Str",studyName);
  request.setAttribute("String_Node_Str",siteName);
  forwardPage(Page.VIEW_ALL_DEFAULT_CRF_VERSIONS_PRINT,request,response);
}

Fixed version (ground truth):
@Override public void processRequest(HttpServletRequest request,HttpServletResponse response) throws Exception {
  FormProcessor fp=new FormProcessor(request);
  SessionManager sm=(SessionManager)request.getSession().getAttribute("String_Node_Str");
  EventCRFBean ecb=(EventCRFBean)request.getAttribute(INPUT_EVENT_CRF);
  SectionBean sb=(SectionBean)request.getAttribute(SECTION_BEAN);
  ArrayList<SectionBean> allSectionBeans;
  boolean isSubmitted=false;
  StudyEventDefinitionDAO sedao=new StudyEventDefinitionDAO(sm.getDataSource());
  EventDefinitionCRFDAO edao=new EventDefinitionCRFDAO(sm.getDataSource());
  EventDefinitionCRFDAO edcdao=new EventDefinitionCRFDAO(sm.getDataSource());
  StudyDAO studyDao=new StudyDAO(sm.getDataSource());
  StudyBean currentStudy=(StudyBean)request.getSession().getAttribute("String_Node_Str");
  ArrayList<StudyEventDefinitionBean> seds=new ArrayList<StudyEventDefinitionBean>();
  seds=sedao.findAllByStudy(currentStudy);
  CRFVersionDAO cvdao=new CRFVersionDAO(sm.getDataSource());
  CRFDAO cdao=new CRFDAO(sm.getDataSource());
  ArrayList<EventDefinitionCRFBean> edcs=new ArrayList();
  for (  StudyEventDefinitionBean sed : seds) {
    int defId=sed.getId();
    edcs.addAll(edcdao.findAllByDefinition(currentStudy,defId));
  }
  Map eventDefinitionDefaultVersions=new LinkedHashMap();
  for (int i=0; i < edcs.size(); i++) {
    EventDefinitionCRFBean edc=edcs.get(i);
    ArrayList versions=(ArrayList)cvdao.findAllByCRF(edc.getCrfId());
    edc.setVersions(versions);
    CRFBean crf=(CRFBean)cdao.findByPK(edc.getCrfId());
    edc.setCrfName(crf.getName());
    if (crf.getStatus().equals(Status.AVAILABLE)) {
      edc.setOwner(crf.getOwner());
    }
    CRFVersionBean defaultVersion=(CRFVersionBean)cvdao.findByPK(edc.getDefaultVersionId());
    StudyEventDefinitionBean studyEventDefinitionBean=(StudyEventDefinitionBean)sedao.findByPK(edc.getStudyEventDefinitionId());
    edc.setDefaultVersionName(defaultVersion.getName());
    if (defaultVersion.getStatus().isAvailable()) {
      List list=(ArrayList)eventDefinitionDefaultVersions.get(studyEventDefinitionBean);
      if (list == null)       list=new ArrayList();
      list.add(defaultVersion);
      eventDefinitionDefaultVersions.put(studyEventDefinitionBean,list);
    }
  }
  String isIE=fp.getString("String_Node_Str");
  if ("String_Node_Str".equalsIgnoreCase(isIE)) {
    request.setAttribute("String_Node_Str","String_Node_Str");
  }
  SectionDAO sdao=new SectionDAO(sm.getDataSource());
  CRFVersionDAO crfVersionDAO=new CRFVersionDAO(sm.getDataSource());
  CRFDAO crfDao=new CRFDAO(sm.getDataSource());
  Map sedCrfBeans=null;
  for (Iterator it=eventDefinitionDefaultVersions.keySet().iterator(); it.hasNext(); ) {
    if (sedCrfBeans == null)     sedCrfBeans=new LinkedHashMap();
    StudyEventDefinitionBean sedBean=(StudyEventDefinitionBean)it.next();
    List crfVersions=(ArrayList)eventDefinitionDefaultVersions.get(sedBean);
    for (Iterator crfIt=crfVersions.iterator(); crfIt.hasNext(); ) {
      CRFVersionBean crfVersionBean=(CRFVersionBean)crfIt.next();
      allSectionBeans=new ArrayList<SectionBean>();
      ArrayList sectionBeans=new ArrayList();
      ItemGroupDAO itemGroupDao=new ItemGroupDAO(sm.getDataSource());
      List<ItemGroupBean> itemGroupBeans=itemGroupDao.findOnlyGroupsByCRFVersionID(crfVersionBean.getId());
      CRFBean crfBean=crfDao.findByVersionId(crfVersionBean.getId());
      if (itemGroupBeans.size() > 0) {
        DisplaySectionBeanHandler handler=new DisplaySectionBeanHandler(false,getDataSource(),getServletContext());
        handler.setCrfVersionId(crfVersionBean.getId());
        List<DisplaySectionBean> displaySectionBeans=handler.getDisplaySectionBeans();
        request.setAttribute("String_Node_Str",displaySectionBeans);
        CRFVersionBean crfverBean=(CRFVersionBean)crfVersionDAO.findByPK(crfVersionBean.getId());
        request.setAttribute("String_Node_Str",crfverBean);
        request.setAttribute("String_Node_Str",crfBean);
        request.setAttribute("String_Node_Str","String_Node_Str");
        PrintCRFBean printCrfBean=new PrintCRFBean();
        printCrfBean.setDisplaySectionBeans(displaySectionBeans);
        printCrfBean.setCrfVersionBean(crfVersionBean);
        printCrfBean.setCrfBean(crfBean);
        printCrfBean.setEventCrfBean(ecb);
        printCrfBean.setGrouped(true);
        List list=(ArrayList)sedCrfBeans.get(sedBean);
        if (list == null)         list=new ArrayList();
        list.add(printCrfBean);
        sedCrfBeans.put(sedBean,list);
        continue;
      }
      ecb=new EventCRFBean();
      ecb.setCRFVersionId(crfVersionBean.getId());
      CRFVersionBean version=(CRFVersionBean)crfVersionDAO.findByPK(crfVersionBean.getId());
      ArrayList sects=(ArrayList)sdao.findByVersionId(version.getId());
      for (int i=0; i < sects.size(); i++) {
        sb=(SectionBean)sects.get(i);
        int sectId=sb.getId();
        if (sectId > 0) {
          allSectionBeans.add((SectionBean)sdao.findByPK(sectId));
        }
      }
      request.setAttribute(INPUT_EVENT_CRF,ecb);
      request.setAttribute(SECTION_BEAN,sb);
      request.setAttribute(ALL_SECTION_BEANS,allSectionBeans);
      sectionBeans=super.getAllDisplayBeans(request);
      DisplaySectionBean dsb=super.getDisplayBean(false,false,request,isSubmitted);
      PrintCRFBean printCrfBean=new PrintCRFBean();
      printCrfBean.setAllSections(sectionBeans);
      printCrfBean.setDisplaySectionBean(dsb);
      printCrfBean.setEventCrfBean(ecb);
      printCrfBean.setCrfVersionBean(crfVersionBean);
      printCrfBean.setCrfBean(crfBean);
      printCrfBean.setGrouped(false);
      List list=(ArrayList)sedCrfBeans.get(sedBean);
      if (list == null)       list=new ArrayList();
      list.add(printCrfBean);
      sedCrfBeans.put(sedBean,list);
    }
  }
  request.setAttribute("String_Node_Str",sedCrfBeans);
  request.setAttribute("String_Node_Str",currentStudy.getName());
  forwardPage(Page.VIEW_ALL_DEFAULT_CRF_VERSIONS_PRINT,request,response);
}