Program: 115309
Project: 115309
Buggy source:
@Override public void processRequest() throws Exception {
  DatasetDAO dsdao=new DatasetDAO(sm.getDataSource());
  ArchivedDatasetFileDAO asdfdao=new ArchivedDatasetFileDAO(sm.getDataSource());
  FormProcessor fp=new FormProcessor(request);
  GenerateExtractFileService generateFileService=new GenerateExtractFileService(sm.getDataSource(),request,sm.getUserBean());
  String action=fp.getString("String_Node_Str");
  int datasetId=fp.getInt("String_Node_Str");
  int adfId=fp.getInt("String_Node_Str");
  if (datasetId == 0) {
    try {
      DatasetBean dsb=(DatasetBean)session.getAttribute("String_Node_Str");
      datasetId=dsb.getId();
      logger.info("String_Node_Str" + datasetId);
    }
 catch (    NullPointerException e) {
      e.printStackTrace();
      logger.info("String_Node_Str");
    }
  }
  DatasetBean db=(DatasetBean)dsdao.findByPK(datasetId);
  int currentstudyid=currentStudy.getId();
  int parentstudy=currentstudyid;
  StudyBean parentStudy=new StudyBean();
  if (currentStudy.getParentStudyId() > 0) {
    StudyDAO sdao=new StudyDAO(sm.getDataSource());
    parentStudy=(StudyBean)sdao.findByPK(currentStudy.getParentStudyId());
  }
  ExtractBean eb=generateFileService.generateExtractBean(db,currentStudy,parentStudy);
  if (StringUtil.isBlank(action)) {
    loadList(db,asdfdao,datasetId,fp,eb);
    forwardPage(Page.EXPORT_DATASETS);
  }
 else   if ("String_Node_Str".equalsIgnoreCase(action) && adfId > 0) {
    boolean success=false;
    ArchivedDatasetFileBean adfBean=(ArchivedDatasetFileBean)asdfdao.findByPK(adfId);
    File file=new File(adfBean.getFileReference());
    if (!file.canWrite()) {
      addPageMessage(respage.getString("String_Node_Str"));
    }
 else {
      success=file.delete();
      if (success) {
        asdfdao.deleteArchiveDataset(adfBean);
        addPageMessage(respage.getString("String_Node_Str"));
      }
 else {
        addPageMessage(respage.getString("String_Node_Str"));
      }
    }
    loadList(db,asdfdao,datasetId,fp,eb);
    forwardPage(Page.EXPORT_DATASETS);
  }
 else {
    logger.info("String_Node_Str" + action);
    String generateReport="String_Node_Str";
    String pattern="String_Node_Str" + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator;
    SimpleDateFormat sdfDir=new SimpleDateFormat(pattern);
    String generalFileDir=DATASET_DIR + db.getId() + File.separator+ sdfDir.format(new java.util.Date());
    String fileName="String_Node_Str";
    db.setName(db.getName().replaceAll("String_Node_Str","String_Node_Str"));
    Page finalTarget=Page.GENERATE_DATASET;
    finalTarget=Page.EXPORT_DATA_CUSTOM;
    long sysTimeBegin=System.currentTimeMillis();
    int fId=0;
    if ("String_Node_Str".equalsIgnoreCase(action)) {
      long sysTimeEnd=System.currentTimeMillis() - sysTimeBegin;
      String SASFileName=db.getName() + "String_Node_Str";
      generateFileService.createFile(SASFileName,generalFileDir,generateReport,db,sysTimeEnd,ExportFormatBean.TXTFILE,true);
      logger.info("String_Node_Str");
      request.setAttribute("String_Node_Str",generalFileDir + SASFileName);
      finalTarget.setFileName(generalFileDir + SASFileName);
      fileName=SASFileName;
    }
 else     if ("String_Node_Str".equalsIgnoreCase(action)) {
      String odmVersion=fp.getString("String_Node_Str");
      String ODMXMLFileName="String_Node_Str";
      HashMap answerMap=generateFileService.createODMFile(odmVersion,sysTimeBegin,generalFileDir,db,this.currentStudy,"String_Node_Str",eb,currentStudy.getId(),currentStudy.getParentStudyId(),"String_Node_Str",true);
      for (Iterator it=answerMap.entrySet().iterator(); it.hasNext(); ) {
        java.util.Map.Entry entry=(java.util.Map.Entry)it.next();
        Object key=entry.getKey();
        Object value=entry.getValue();
        ODMXMLFileName=(String)key;
        Integer fileID=(Integer)value;
        fId=fileID.intValue();
      }
      fileName=ODMXMLFileName;
      request.setAttribute("String_Node_Str",generalFileDir + ODMXMLFileName);
      System.out.println("String_Node_Str" + generalFileDir + ODMXMLFileName);
      if (fp.getString("String_Node_Str") != null) {
        XalanTriggerService xts=new XalanTriggerService();
        String propertiesPath=SQLInitServlet.getField("String_Node_Str");
        openZipFile(generalFileDir + ODMXMLFileName + "String_Node_Str");
        SimpleTrigger simpleTrigger=xts.generateXalanTrigger(propertiesPath + File.separator + "String_Node_Str",ODMXMLFileName,generalFileDir + "String_Node_Str",db.getId());
        scheduler=getScheduler();
        JobDetailBean jobDetailBean=new JobDetailBean();
        jobDetailBean.setGroup(xts.TRIGGER_GROUP_NAME);
        jobDetailBean.setName(simpleTrigger.getName());
        jobDetailBean.setJobClass(org.akaza.openclinica.web.job.XalanStatefulJob.class);
        jobDetailBean.setJobDataMap(simpleTrigger.getJobDataMap());
        jobDetailBean.setDurability(true);
        jobDetailBean.setVolatility(false);
        try {
          Date dateStart=scheduler.scheduleJob(jobDetailBean,simpleTrigger);
          logger.info("String_Node_Str" + dateStart.toString());
        }
 catch (        SchedulerException se) {
          se.printStackTrace();
        }
      }
    }
 else     if ("String_Node_Str".equalsIgnoreCase(action)) {
      String TXTFileName="String_Node_Str";
      HashMap answerMap=generateFileService.createTabFile(eb,sysTimeBegin,generalFileDir,db,currentstudyid,parentstudy,"String_Node_Str");
      for (Iterator it=answerMap.entrySet().iterator(); it.hasNext(); ) {
        java.util.Map.Entry entry=(java.util.Map.Entry)it.next();
        Object key=entry.getKey();
        Object value=entry.getValue();
        TXTFileName=(String)key;
        Integer fileID=(Integer)value;
        fId=fileID.intValue();
      }
      fileName=TXTFileName;
      request.setAttribute("String_Node_Str",generalFileDir + TXTFileName);
      System.out.println("String_Node_Str" + generalFileDir + TXTFileName);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(action)) {
      TabReportBean answer=new TabReportBean();
      eb=dsdao.getDatasetData(eb,currentstudyid,parentstudy);
      eb.getMetadata();
      eb.computeReport(answer);
      request.setAttribute("String_Node_Str",db);
      request.setAttribute("String_Node_Str",eb);
      finalTarget=Page.GENERATE_DATASET_HTML;
    }
 else     if ("String_Node_Str".equalsIgnoreCase(action)) {
      SPSSReportBean answer=new SPSSReportBean();
      eb=dsdao.getDatasetData(eb,currentstudyid,parentstudy);
      eb.getMetadata();
      eb.computeReport(answer);
      String DDLFileName="String_Node_Str";
      HashMap answerMap=generateFileService.createSPSSFile(db,eb,currentStudy,parentStudy,sysTimeBegin,generalFileDir,answer,"String_Node_Str");
      for (Iterator it=answerMap.entrySet().iterator(); it.hasNext(); ) {
        java.util.Map.Entry entry=(java.util.Map.Entry)it.next();
        Object key=entry.getKey();
        Object value=entry.getValue();
        DDLFileName=(String)key;
        Integer fileID=(Integer)value;
        fId=fileID.intValue();
      }
      request.setAttribute("String_Node_Str",generalFileDir + DDLFileName);
      System.out.println("String_Node_Str" + generalFileDir + DDLFileName);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(action)) {
      CommaReportBean answer=new CommaReportBean();
      eb=dsdao.getDatasetData(eb,currentstudyid,parentstudy);
      eb.getMetadata();
      eb.computeReport(answer);
      long sysTimeEnd=System.currentTimeMillis() - sysTimeBegin;
      String CSVFileName=db.getName() + "String_Node_Str";
      fId=generateFileService.createFile(CSVFileName,generalFileDir,answer.toString(),db,sysTimeEnd,ExportFormatBean.CSVFILE,true);
      fileName=CSVFileName;
      logger.info("String_Node_Str");
      request.setAttribute("String_Node_Str",generalFileDir + CSVFileName);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(action)) {
      long sysTimeEnd=System.currentTimeMillis() - sysTimeBegin;
      String excelFileName=db.getName() + "String_Node_Str";
      finalTarget=Page.GENERATE_EXCEL_DATASET;
      response.setHeader("String_Node_Str","String_Node_Str" + db.getName() + "String_Node_Str");
      request.setAttribute("String_Node_Str",generalFileDir + excelFileName);
      logger.info("String_Node_Str" + generalFileDir + excelFileName);
      fileName=excelFileName;
    }
    if (!finalTarget.equals(Page.GENERATE_EXCEL_DATASET) && !finalTarget.equals(Page.GENERATE_DATASET_HTML)) {
      finalTarget.setFileName("String_Node_Str" + "String_Node_Str");
      asdfdao=new ArchivedDatasetFileDAO(sm.getDataSource());
      ArchivedDatasetFileBean asdfBean=(ArchivedDatasetFileBean)asdfdao.findByPK(fId);
      ArrayList newFileList=new ArrayList();
      newFileList.add(asdfBean);
      ArrayList filterRows=ArchivedDatasetFileRow.generateRowsFromBeans(newFileList);
      EntityBeanTable table=fp.getEntityBeanTable();
      table.setSortingIfNotExplicitlySet(3,false);
      String[] columns={resword.getString("String_Node_Str"),resword.getString("String_Node_Str"),resword.getString("String_Node_Str"),resword.getString("String_Node_Str"),resword.getString("String_Node_Str")};
      table.setColumns(new ArrayList(Arrays.asList(columns)));
      table.hideColumnLink(0);
      table.hideColumnLink(1);
      table.hideColumnLink(2);
      table.hideColumnLink(3);
      table.hideColumnLink(4);
      request.setAttribute("String_Node_Str",db);
      request.setAttribute("String_Node_Str",asdfBean);
      table.setRows(filterRows);
      table.computeDisplay();
      request.setAttribute("String_Node_Str",table);
    }
    logger.info("String_Node_Str" + generalFileDir);
    logger.info("String_Node_Str" + finalTarget.getFileName());
    String del=CoreResources.getField("String_Node_Str");
    if (del.equalsIgnoreCase("String_Node_Str") || del.equals("String_Node_Str")) {
      File deleteFile=new File(generalFileDir + fileName);
      deleteFile.delete();
    }
    forwardPage(finalTarget);
  }
}

Fixed version (ground truth):
@Override public void processRequest() throws Exception {
  DatasetDAO dsdao=new DatasetDAO(sm.getDataSource());
  ArchivedDatasetFileDAO asdfdao=new ArchivedDatasetFileDAO(sm.getDataSource());
  FormProcessor fp=new FormProcessor(request);
  GenerateExtractFileService generateFileService=new GenerateExtractFileService(sm.getDataSource(),request,sm.getUserBean());
  String action=fp.getString("String_Node_Str");
  int datasetId=fp.getInt("String_Node_Str");
  int adfId=fp.getInt("String_Node_Str");
  if (datasetId == 0) {
    try {
      DatasetBean dsb=(DatasetBean)session.getAttribute("String_Node_Str");
      datasetId=dsb.getId();
      logger.info("String_Node_Str" + datasetId);
    }
 catch (    NullPointerException e) {
      e.printStackTrace();
      logger.info("String_Node_Str");
    }
  }
  DatasetBean db=(DatasetBean)dsdao.findByPK(datasetId);
  int currentstudyid=currentStudy.getId();
  int parentstudy=currentstudyid;
  StudyBean parentStudy=new StudyBean();
  if (currentStudy.getParentStudyId() > 0) {
    StudyDAO sdao=new StudyDAO(sm.getDataSource());
    parentStudy=(StudyBean)sdao.findByPK(currentStudy.getParentStudyId());
  }
  ExtractBean eb=generateFileService.generateExtractBean(db,currentStudy,parentStudy);
  if (StringUtil.isBlank(action)) {
    loadList(db,asdfdao,datasetId,fp,eb);
    forwardPage(Page.EXPORT_DATASETS);
  }
 else   if ("String_Node_Str".equalsIgnoreCase(action) && adfId > 0) {
    boolean success=false;
    ArchivedDatasetFileBean adfBean=(ArchivedDatasetFileBean)asdfdao.findByPK(adfId);
    File file=new File(adfBean.getFileReference());
    if (!file.canWrite()) {
      addPageMessage(respage.getString("String_Node_Str"));
    }
 else {
      success=file.delete();
      if (success) {
        asdfdao.deleteArchiveDataset(adfBean);
        addPageMessage(respage.getString("String_Node_Str"));
      }
 else {
        addPageMessage(respage.getString("String_Node_Str"));
      }
    }
    loadList(db,asdfdao,datasetId,fp,eb);
    forwardPage(Page.EXPORT_DATASETS);
  }
 else {
    logger.info("String_Node_Str" + action);
    String generateReport="String_Node_Str";
    String pattern="String_Node_Str" + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator;
    SimpleDateFormat sdfDir=new SimpleDateFormat(pattern);
    String generalFileDir=DATASET_DIR + db.getId() + File.separator+ sdfDir.format(new java.util.Date());
    String fileName="String_Node_Str";
    db.setName(db.getName().replaceAll("String_Node_Str","String_Node_Str"));
    Page finalTarget=Page.GENERATE_DATASET;
    finalTarget=Page.EXPORT_DATA_CUSTOM;
    long sysTimeBegin=System.currentTimeMillis();
    int fId=0;
    if ("String_Node_Str".equalsIgnoreCase(action)) {
      long sysTimeEnd=System.currentTimeMillis() - sysTimeBegin;
      String SASFileName=db.getName() + "String_Node_Str";
      generateFileService.createFile(SASFileName,generalFileDir,generateReport,db,sysTimeEnd,ExportFormatBean.TXTFILE,true);
      logger.info("String_Node_Str");
      request.setAttribute("String_Node_Str",generalFileDir + SASFileName);
      finalTarget.setFileName(generalFileDir + SASFileName);
      fileName=SASFileName;
    }
 else     if ("String_Node_Str".equalsIgnoreCase(action)) {
      String odmVersion=fp.getString("String_Node_Str");
      String ODMXMLFileName="String_Node_Str";
      HashMap answerMap=generateFileService.createODMFile(odmVersion,sysTimeBegin,generalFileDir,db,this.currentStudy,"String_Node_Str",eb,currentStudy.getId(),currentStudy.getParentStudyId(),"String_Node_Str",true,true);
      for (Iterator it=answerMap.entrySet().iterator(); it.hasNext(); ) {
        java.util.Map.Entry entry=(java.util.Map.Entry)it.next();
        Object key=entry.getKey();
        Object value=entry.getValue();
        ODMXMLFileName=(String)key;
        Integer fileID=(Integer)value;
        fId=fileID.intValue();
      }
      fileName=ODMXMLFileName;
      request.setAttribute("String_Node_Str",generalFileDir + ODMXMLFileName);
      System.out.println("String_Node_Str" + generalFileDir + ODMXMLFileName);
      if (fp.getString("String_Node_Str") != null) {
        XalanTriggerService xts=new XalanTriggerService();
        String propertiesPath=SQLInitServlet.getField("String_Node_Str");
        openZipFile(generalFileDir + ODMXMLFileName + "String_Node_Str");
        SimpleTrigger simpleTrigger=xts.generateXalanTrigger(propertiesPath + File.separator + "String_Node_Str",ODMXMLFileName,generalFileDir + "String_Node_Str",db.getId());
        scheduler=getScheduler();
        JobDetailBean jobDetailBean=new JobDetailBean();
        jobDetailBean.setGroup(xts.TRIGGER_GROUP_NAME);
        jobDetailBean.setName(simpleTrigger.getName());
        jobDetailBean.setJobClass(org.akaza.openclinica.web.job.XalanStatefulJob.class);
        jobDetailBean.setJobDataMap(simpleTrigger.getJobDataMap());
        jobDetailBean.setDurability(true);
        jobDetailBean.setVolatility(false);
        try {
          Date dateStart=scheduler.scheduleJob(jobDetailBean,simpleTrigger);
          logger.info("String_Node_Str" + dateStart.toString());
        }
 catch (        SchedulerException se) {
          se.printStackTrace();
        }
      }
    }
 else     if ("String_Node_Str".equalsIgnoreCase(action)) {
      String TXTFileName="String_Node_Str";
      HashMap answerMap=generateFileService.createTabFile(eb,sysTimeBegin,generalFileDir,db,currentstudyid,parentstudy,"String_Node_Str");
      for (Iterator it=answerMap.entrySet().iterator(); it.hasNext(); ) {
        java.util.Map.Entry entry=(java.util.Map.Entry)it.next();
        Object key=entry.getKey();
        Object value=entry.getValue();
        TXTFileName=(String)key;
        Integer fileID=(Integer)value;
        fId=fileID.intValue();
      }
      fileName=TXTFileName;
      request.setAttribute("String_Node_Str",generalFileDir + TXTFileName);
      System.out.println("String_Node_Str" + generalFileDir + TXTFileName);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(action)) {
      TabReportBean answer=new TabReportBean();
      eb=dsdao.getDatasetData(eb,currentstudyid,parentstudy);
      eb.getMetadata();
      eb.computeReport(answer);
      request.setAttribute("String_Node_Str",db);
      request.setAttribute("String_Node_Str",eb);
      finalTarget=Page.GENERATE_DATASET_HTML;
    }
 else     if ("String_Node_Str".equalsIgnoreCase(action)) {
      SPSSReportBean answer=new SPSSReportBean();
      eb=dsdao.getDatasetData(eb,currentstudyid,parentstudy);
      eb.getMetadata();
      eb.computeReport(answer);
      String DDLFileName="String_Node_Str";
      HashMap answerMap=generateFileService.createSPSSFile(db,eb,currentStudy,parentStudy,sysTimeBegin,generalFileDir,answer,"String_Node_Str");
      for (Iterator it=answerMap.entrySet().iterator(); it.hasNext(); ) {
        java.util.Map.Entry entry=(java.util.Map.Entry)it.next();
        Object key=entry.getKey();
        Object value=entry.getValue();
        DDLFileName=(String)key;
        Integer fileID=(Integer)value;
        fId=fileID.intValue();
      }
      request.setAttribute("String_Node_Str",generalFileDir + DDLFileName);
      System.out.println("String_Node_Str" + generalFileDir + DDLFileName);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(action)) {
      CommaReportBean answer=new CommaReportBean();
      eb=dsdao.getDatasetData(eb,currentstudyid,parentstudy);
      eb.getMetadata();
      eb.computeReport(answer);
      long sysTimeEnd=System.currentTimeMillis() - sysTimeBegin;
      String CSVFileName=db.getName() + "String_Node_Str";
      fId=generateFileService.createFile(CSVFileName,generalFileDir,answer.toString(),db,sysTimeEnd,ExportFormatBean.CSVFILE,true);
      fileName=CSVFileName;
      logger.info("String_Node_Str");
      request.setAttribute("String_Node_Str",generalFileDir + CSVFileName);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(action)) {
      long sysTimeEnd=System.currentTimeMillis() - sysTimeBegin;
      String excelFileName=db.getName() + "String_Node_Str";
      finalTarget=Page.GENERATE_EXCEL_DATASET;
      response.setHeader("String_Node_Str","String_Node_Str" + db.getName() + "String_Node_Str");
      request.setAttribute("String_Node_Str",generalFileDir + excelFileName);
      logger.info("String_Node_Str" + generalFileDir + excelFileName);
      fileName=excelFileName;
    }
    if (!finalTarget.equals(Page.GENERATE_EXCEL_DATASET) && !finalTarget.equals(Page.GENERATE_DATASET_HTML)) {
      finalTarget.setFileName("String_Node_Str" + "String_Node_Str");
      asdfdao=new ArchivedDatasetFileDAO(sm.getDataSource());
      ArchivedDatasetFileBean asdfBean=(ArchivedDatasetFileBean)asdfdao.findByPK(fId);
      ArrayList newFileList=new ArrayList();
      newFileList.add(asdfBean);
      ArrayList filterRows=ArchivedDatasetFileRow.generateRowsFromBeans(newFileList);
      EntityBeanTable table=fp.getEntityBeanTable();
      table.setSortingIfNotExplicitlySet(3,false);
      String[] columns={resword.getString("String_Node_Str"),resword.getString("String_Node_Str"),resword.getString("String_Node_Str"),resword.getString("String_Node_Str"),resword.getString("String_Node_Str")};
      table.setColumns(new ArrayList(Arrays.asList(columns)));
      table.hideColumnLink(0);
      table.hideColumnLink(1);
      table.hideColumnLink(2);
      table.hideColumnLink(3);
      table.hideColumnLink(4);
      request.setAttribute("String_Node_Str",db);
      request.setAttribute("String_Node_Str",asdfBean);
      table.setRows(filterRows);
      table.computeDisplay();
      request.setAttribute("String_Node_Str",table);
    }
    logger.info("String_Node_Str" + generalFileDir);
    logger.info("String_Node_Str" + finalTarget.getFileName());
    String del=CoreResources.getField("String_Node_Str");
    if (del.equalsIgnoreCase("String_Node_Str") || del.equals("String_Node_Str")) {
      File deleteFile=new File(generalFileDir + fileName);
      deleteFile.delete();
    }
    forwardPage(finalTarget);
  }
}