Program: 115140
Project: 115140
Buggy source:
@Override public void processRequest() throws Exception {
  resetPanel();
  panel.setStudyInfoShown(false);
  panel.setOrderedData(true);
  FormProcessor fp=new FormProcessor(request);
  String module=fp.getString(MODULE);
  session.setAttribute(MODULE,module);
  String action=request.getParameter("String_Node_Str");
  CRFVersionBean version=(CRFVersionBean)session.getAttribute("String_Node_Str");
  File xsdFile=new File(SpringServletAccess.getPropertiesDir(context) + "String_Node_Str");
  File xsdFile2=new File(SpringServletAccess.getPropertiesDir(context) + "String_Node_Str");
  if (StringUtil.isBlank(action)) {
    logger.info("String_Node_Str");
    request.setAttribute("String_Node_Str",version);
    forwardPage(Page.IMPORT_CRF_DATA);
  }
  if ("String_Node_Str".equalsIgnoreCase(action)) {
    String dir=SQLInitServlet.getField("String_Node_Str");
    if (!(new File(dir)).exists()) {
      logger.info("String_Node_Str" + dir);
      addPageMessage(respage.getString("String_Node_Str"));
      forwardPage(Page.IMPORT_CRF_DATA);
    }
    String theDir=dir + "String_Node_Str" + File.separator+ "String_Node_Str"+ File.separator;
    if (!(new File(theDir)).isDirectory()) {
      (new File(theDir)).mkdirs();
      logger.info("String_Node_Str" + theDir);
    }
    File f=null;
    try {
      f=uploadFile(theDir,version);
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str");
      e.printStackTrace();
    }
    if (f == null) {
      forwardPage(Page.IMPORT_CRF_DATA);
    }
    Mapping myMap=new Mapping();
    String ODM_MAPPING_DIRPath=CoreResources.ODM_MAPPING_DIR;
    myMap.loadMapping(ODM_MAPPING_DIRPath + File.separator + "String_Node_Str");
    Unmarshaller um1=new Unmarshaller(myMap);
    boolean fail=false;
    ODMContainer odmContainer=new ODMContainer();
    try {
      InputStreamReader isr=new InputStreamReader(new FileInputStream(f),"String_Node_Str");
      odmContainer=(ODMContainer)um1.unmarshal(isr);
      System.out.println("String_Node_Str" + odmContainer.getCrfDataPostImportContainer().getStudyOID());
      System.out.println("String_Node_Str" + odmContainer.getCrfDataPostImportContainer().getSubjectData().size());
      addPageMessage(respage.getString("String_Node_Str"));
    }
 catch (    Exception me1) {
      me1.printStackTrace();
      logger.info("String_Node_Str");
      logger.info("String_Node_Str");
      try {
        schemaValidator.validateAgainstSchema(f,xsdFile2);
        InputStreamReader isr=new InputStreamReader(new FileInputStream(f),"String_Node_Str");
        odmContainer=(ODMContainer)um1.unmarshal(isr);
      }
 catch (      Exception me2) {
        MessageFormat mf=new MessageFormat("String_Node_Str");
        mf.applyPattern(respage.getString("String_Node_Str"));
        Object[] arguments={me1.getMessage()};
        addPageMessage(mf.format(arguments));
        forwardPage(Page.IMPORT_CRF_DATA);
      }
    }
    List<String> errors=getImportCRFDataService().validateStudyMetadata(odmContainer,ub.getActiveStudyId());
    if (errors != null) {
      logger.info(errors.toString());
      for (      String error : errors) {
        addPageMessage(error);
      }
      if (errors.size() > 0) {
        forwardPage(Page.IMPORT_CRF_DATA);
      }
 else {
        addPageMessage(respage.getString("String_Node_Str"));
        addPageMessage(respage.getString("String_Node_Str"));
      }
    }
    System.out.println("String_Node_Str");
    List<EventCRFBean> eventCRFBeans=getImportCRFDataService().fetchEventCRFBeans(odmContainer,ub);
    ArrayList<Integer> permittedEventCRFIds=new ArrayList<Integer>();
    logger.info("String_Node_Str" + eventCRFBeans.toString());
    List<DisplayItemBeanWrapper> displayItemBeanWrappers=new ArrayList<DisplayItemBeanWrapper>();
    HashMap<String,String> totalValidationErrors=new HashMap<String,String>();
    HashMap<String,String> hardValidationErrors=new HashMap<String,String>();
    System.out.println("String_Node_Str" + eventCRFBeans.size());
    if (!eventCRFBeans.isEmpty()) {
      for (      EventCRFBean eventCRFBean : eventCRFBeans) {
        DataEntryStage dataEntryStage=eventCRFBean.getStage();
        Status eventCRFStatus=eventCRFBean.getStatus();
        logger.info("String_Node_Str" + eventCRFBean.getId() + "String_Node_Str"+ dataEntryStage.getName()+ "String_Node_Str"+ eventCRFStatus.getName());
        if (eventCRFStatus.equals(Status.AVAILABLE) || dataEntryStage.equals(DataEntryStage.INITIAL_DATA_ENTRY) || dataEntryStage.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE)|| dataEntryStage.equals(DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE)|| dataEntryStage.equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
          permittedEventCRFIds.add(new Integer(eventCRFBean.getId()));
        }
 else {
        }
      }
      if (eventCRFBeans.size() >= permittedEventCRFIds.size()) {
        addPageMessage(respage.getString("String_Node_Str"));
      }
 else {
        fail=true;
        addPageMessage(respage.getString("String_Node_Str"));
      }
      try {
        List<DisplayItemBeanWrapper> tempDisplayItemBeanWrappers=new ArrayList<DisplayItemBeanWrapper>();
        tempDisplayItemBeanWrappers=getImportCRFDataService().lookupValidationErrors(request,odmContainer,ub,totalValidationErrors,hardValidationErrors,permittedEventCRFIds);
        System.out.println("String_Node_Str" + tempDisplayItemBeanWrappers.size());
        System.out.println("String_Node_Str" + totalValidationErrors.size());
        displayItemBeanWrappers.addAll(tempDisplayItemBeanWrappers);
      }
 catch (      NullPointerException npe1) {
        fail=true;
        logger.debug("String_Node_Str");
        addPageMessage(respage.getString("String_Node_Str"));
        System.out.println("String_Node_Str");
      }
catch (      OpenClinicaException oce1) {
        fail=true;
        logger.debug("String_Node_Str" + oce1.getOpenClinicaMessage());
        addPageMessage(oce1.getOpenClinicaMessage());
        System.out.println("String_Node_Str");
      }
    }
 else {
      fail=true;
      addPageMessage(respage.getString("String_Node_Str"));
    }
    if (fail) {
      System.out.println("String_Node_Str");
      forwardPage(Page.IMPORT_CRF_DATA);
    }
 else {
      addPageMessage(respage.getString("String_Node_Str"));
      session.setAttribute("String_Node_Str",displayItemBeanWrappers);
      session.setAttribute("String_Node_Str",totalValidationErrors);
      session.setAttribute("String_Node_Str",hardValidationErrors);
      System.out.println("String_Node_Str" + totalValidationErrors.size());
      logger.debug("String_Node_Str" + totalValidationErrors.toString());
      SummaryStatsBean ssBean=getImportCRFDataService().generateSummaryStatsBean(odmContainer,displayItemBeanWrappers);
      session.setAttribute("String_Node_Str",ssBean);
      session.setAttribute("String_Node_Str",odmContainer.getCrfDataPostImportContainer().getSubjectData());
      System.out.println("String_Node_Str");
      forwardPage(Page.VERIFY_IMPORT_SERVLET);
    }
  }
}

Fixed version (ground truth):
@Override public void processRequest() throws Exception {
  resetPanel();
  panel.setStudyInfoShown(false);
  panel.setOrderedData(true);
  FormProcessor fp=new FormProcessor(request);
  String module=fp.getString(MODULE);
  session.setAttribute(MODULE,module);
  String action=request.getParameter("String_Node_Str");
  CRFVersionBean version=(CRFVersionBean)session.getAttribute("String_Node_Str");
  File xsdFile=new File(SpringServletAccess.getPropertiesDir(context) + "String_Node_Str");
  File xsdFile2=new File(SpringServletAccess.getPropertiesDir(context) + "String_Node_Str");
  if (StringUtil.isBlank(action)) {
    logger.info("String_Node_Str");
    request.setAttribute("String_Node_Str",version);
    forwardPage(Page.IMPORT_CRF_DATA);
  }
  if ("String_Node_Str".equalsIgnoreCase(action)) {
    String dir=SQLInitServlet.getField("String_Node_Str");
    if (!(new File(dir)).exists()) {
      logger.info("String_Node_Str" + dir);
      addPageMessage(respage.getString("String_Node_Str"));
      forwardPage(Page.IMPORT_CRF_DATA);
    }
    String theDir=dir + "String_Node_Str" + File.separator+ "String_Node_Str"+ File.separator;
    if (!(new File(theDir)).isDirectory()) {
      (new File(theDir)).mkdirs();
      logger.info("String_Node_Str" + theDir);
    }
    File f=null;
    try {
      f=uploadFile(theDir,version);
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str");
      e.printStackTrace();
    }
    if (f == null) {
      forwardPage(Page.IMPORT_CRF_DATA);
    }
    Mapping myMap=new Mapping();
    String ODM_MAPPING_DIRPath=CoreResources.ODM_MAPPING_DIR;
    myMap.loadMapping(ODM_MAPPING_DIRPath + File.separator + "String_Node_Str");
    Unmarshaller um1=new Unmarshaller(myMap);
    boolean fail=false;
    ODMContainer odmContainer=new ODMContainer();
    try {
      InputStreamReader isr=new InputStreamReader(new FileInputStream(f),"String_Node_Str");
      odmContainer=(ODMContainer)um1.unmarshal(isr);
      System.out.println("String_Node_Str" + odmContainer.getCrfDataPostImportContainer().getStudyOID());
      System.out.println("String_Node_Str" + odmContainer.getCrfDataPostImportContainer().getSubjectData().size());
      addPageMessage(respage.getString("String_Node_Str"));
    }
 catch (    Exception me1) {
      me1.printStackTrace();
      logger.info("String_Node_Str");
      logger.info("String_Node_Str");
      try {
        schemaValidator.validateAgainstSchema(f,xsdFile2);
        InputStreamReader isr=new InputStreamReader(new FileInputStream(f),"String_Node_Str");
        odmContainer=(ODMContainer)um1.unmarshal(isr);
      }
 catch (      Exception me2) {
        MessageFormat mf=new MessageFormat("String_Node_Str");
        mf.applyPattern(respage.getString("String_Node_Str"));
        Object[] arguments={me1.getMessage()};
        addPageMessage(mf.format(arguments));
        forwardPage(Page.IMPORT_CRF_DATA);
      }
    }
    List<String> errors=getImportCRFDataService().validateStudyMetadata(odmContainer,ub.getActiveStudyId());
    if (errors != null) {
      logger.info(errors.toString());
      for (      String error : errors) {
        addPageMessage(error);
      }
      if (errors.size() > 0) {
        forwardPage(Page.IMPORT_CRF_DATA);
      }
 else {
        addPageMessage(respage.getString("String_Node_Str"));
        addPageMessage(respage.getString("String_Node_Str"));
      }
    }
    System.out.println("String_Node_Str");
    List<EventCRFBean> eventCRFBeans=getImportCRFDataService().fetchEventCRFBeans(odmContainer,ub);
    List<DisplayItemBeanWrapper> displayItemBeanWrappers=new ArrayList<DisplayItemBeanWrapper>();
    HashMap<String,String> totalValidationErrors=new HashMap<String,String>();
    HashMap<String,String> hardValidationErrors=new HashMap<String,String>();
    if (eventCRFBeans == null) {
      fail=true;
      addPageMessage(respage.getString("String_Node_Str"));
    }
 else {
      ArrayList<Integer> permittedEventCRFIds=new ArrayList<Integer>();
      logger.info("String_Node_Str" + eventCRFBeans.toString());
      System.out.println("String_Node_Str" + eventCRFBeans.size());
      if (!eventCRFBeans.isEmpty()) {
        for (        EventCRFBean eventCRFBean : eventCRFBeans) {
          DataEntryStage dataEntryStage=eventCRFBean.getStage();
          Status eventCRFStatus=eventCRFBean.getStatus();
          logger.info("String_Node_Str" + eventCRFBean.getId() + "String_Node_Str"+ dataEntryStage.getName()+ "String_Node_Str"+ eventCRFStatus.getName());
          if (eventCRFStatus.equals(Status.AVAILABLE) || dataEntryStage.equals(DataEntryStage.INITIAL_DATA_ENTRY) || dataEntryStage.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE)|| dataEntryStage.equals(DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE)|| dataEntryStage.equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
            permittedEventCRFIds.add(new Integer(eventCRFBean.getId()));
          }
 else {
          }
        }
        if (eventCRFBeans.size() >= permittedEventCRFIds.size()) {
          addPageMessage(respage.getString("String_Node_Str"));
        }
 else {
          fail=true;
          addPageMessage(respage.getString("String_Node_Str"));
        }
        try {
          List<DisplayItemBeanWrapper> tempDisplayItemBeanWrappers=new ArrayList<DisplayItemBeanWrapper>();
          tempDisplayItemBeanWrappers=getImportCRFDataService().lookupValidationErrors(request,odmContainer,ub,totalValidationErrors,hardValidationErrors,permittedEventCRFIds);
          System.out.println("String_Node_Str" + tempDisplayItemBeanWrappers.size());
          System.out.println("String_Node_Str" + totalValidationErrors.size());
          displayItemBeanWrappers.addAll(tempDisplayItemBeanWrappers);
        }
 catch (        NullPointerException npe1) {
          fail=true;
          logger.debug("String_Node_Str");
          addPageMessage(respage.getString("String_Node_Str"));
          System.out.println("String_Node_Str");
        }
catch (        OpenClinicaException oce1) {
          fail=true;
          logger.debug("String_Node_Str" + oce1.getOpenClinicaMessage());
          addPageMessage(oce1.getOpenClinicaMessage());
          System.out.println("String_Node_Str");
        }
      }
 else {
        fail=true;
        addPageMessage(respage.getString("String_Node_Str"));
      }
    }
    if (fail) {
      System.out.println("String_Node_Str");
      forwardPage(Page.IMPORT_CRF_DATA);
    }
 else {
      addPageMessage(respage.getString("String_Node_Str"));
      session.setAttribute("String_Node_Str",displayItemBeanWrappers);
      session.setAttribute("String_Node_Str",totalValidationErrors);
      session.setAttribute("String_Node_Str",hardValidationErrors);
      System.out.println("String_Node_Str" + totalValidationErrors.size());
      logger.debug("String_Node_Str" + totalValidationErrors.toString());
      SummaryStatsBean ssBean=getImportCRFDataService().generateSummaryStatsBean(odmContainer,displayItemBeanWrappers);
      session.setAttribute("String_Node_Str",ssBean);
      session.setAttribute("String_Node_Str",odmContainer.getCrfDataPostImportContainer().getSubjectData());
      System.out.println("String_Node_Str");
      forwardPage(Page.VERIFY_IMPORT_SERVLET);
    }
  }
}