Program: 115314
Project: 115314
Buggy source:
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
  Locale locale=new Locale("String_Node_Str");
  ResourceBundleProvider.updateLocale(locale);
  ResourceBundle pageMessages=ResourceBundleProvider.getPageMessagesBundle();
  JobDataMap dataMap=context.getMergedJobDataMap();
  String alertEmail=dataMap.getString(EMAIL);
  try {
    int userAccountId=dataMap.getInt(USER_ID);
    String outputPath=dataMap.getString(POST_FILE_PATH);
    File output=new File(outputPath);
    if (!output.isDirectory()) {
      output.mkdirs();
    }
    TransformerFactory tFactory=TransformerFactory.newInstance();
    java.io.InputStream in=new java.io.FileInputStream(dataMap.getString(XSL_FILE_PATH));
    Transformer transformer=tFactory.newTransformer(new StreamSource(in));
    System.out.println("String_Node_Str");
    String endFile=outputPath + File.separator + dataMap.getString(POST_FILE_NAME);
    final long start=System.currentTimeMillis();
    transformer.transform(new StreamSource(dataMap.getString(XML_FILE_PATH)),new StreamResult(new FileOutputStream(endFile)));
    final long done=System.currentTimeMillis() - start;
    System.out.println("String_Node_Str" + done + "String_Node_Str");
    int epBeanId=dataMap.getInt(EXTRACT_PROPERTY);
    ExtractPropertyBean epBean=CoreResources.findExtractPropertyBeanById(epBeanId);
    ProcessingFunction function=epBean.getPostProcessing();
    String subject="String_Node_Str";
    String emailBody="String_Node_Str";
    int dsId=dataMap.getInt(DATASET_ID);
    ApplicationContext appContext=(ApplicationContext)context.getScheduler().getContext().get("String_Node_Str");
    mailSender=(OpenClinicaMailSender)appContext.getBean("String_Node_Str");
    dataSource=(DataSource)appContext.getBean("String_Node_Str");
    DatasetDAO dsdao=new DatasetDAO(dataSource);
    DatasetBean datasetBean=(DatasetBean)dsdao.findByPK(dsId);
    if (function != null) {
      function.setTransformFileName(outputPath + File.separator + dataMap.getString(POST_FILE_NAME));
      function.setODMXMLFileName(endFile);
      function.setXslFileName(dataMap.getString(XSL_FILE_PATH));
      ProcessingResultType message=function.run();
      final long done2=System.currentTimeMillis() - start;
      System.out.println("String_Node_Str" + done2 + "String_Node_Str"+ message.getCode());
      emailBody=message.getDescription();
      if (!("String_Node_Str").equals(message.getUrl()) && function.getClass().equals(org.akaza.openclinica.bean.service.PdfProcessingFunction.class)) {
        ArchivedDatasetFileBean fbFinal=generateFileRecord(dataMap.getString(POST_FILE_NAME) + "String_Node_Str",outputPath,datasetBean,done,new File(endFile).length(),ExportFormatBean.PDFFILE,userAccountId);
        emailBody=emailBody + "String_Node_Str" + message.getUrl()+ fbFinal.getId()+ "String_Node_Str"+ epBean.getLinkText()+ "String_Node_Str";
      }
      if (message.getCode().intValue() == 1) {
        subject="String_Node_Str" + datasetBean.getName();
      }
 else       if (message.getCode().intValue() == 2) {
        subject="String_Node_Str" + datasetBean.getName();
      }
 else       if (message.getCode().intValue() == 3) {
        subject="String_Node_Str" + datasetBean.getName();
      }
    }
 else {
      ArchivedDatasetFileBean fbFinal=generateFileRecord(dataMap.getString(POST_FILE_NAME),outputPath,datasetBean,done,new File(endFile).length(),ExportFormatBean.TXTFILE,userAccountId);
      subject="String_Node_Str" + datasetBean.getName();
      emailBody=datasetBean.getName() + "String_Node_Str";
      emailBody=emailBody + "String_Node_Str" + CoreResources.getField("String_Node_Str")+ "String_Node_Str"+ fbFinal.getId()+ "String_Node_Str";
    }
    String email=dataMap.getString(EMAIL);
    try {
      mailSender.sendEmail(email,EmailEngine.getAdminEmail(),subject,emailBody,true);
    }
 catch (    OpenClinicaSystemException ose) {
    }
    System.out.println("String_Node_Str" + email + "String_Node_Str"+ EmailEngine.getAdminEmail());
  }
 catch (  TransformerConfigurationException e) {
    sendErrorEmail(e.getMessage(),context);
    e.printStackTrace();
  }
catch (  FileNotFoundException e) {
    sendErrorEmail(e.getMessage(),context);
    e.printStackTrace();
  }
catch (  TransformerFactoryConfigurationError e) {
    sendErrorEmail(e.getMessage(),context);
    e.printStackTrace();
  }
catch (  TransformerException e) {
    sendErrorEmail(e.getMessage(),context);
    e.printStackTrace();
  }
catch (  Exception ee) {
    sendErrorEmail(ee.getMessage(),context);
    ee.printStackTrace();
  }
}

Fixed version (ground truth):
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
  Locale locale=new Locale("String_Node_Str");
  ResourceBundleProvider.updateLocale(locale);
  ResourceBundle pageMessages=ResourceBundleProvider.getPageMessagesBundle();
  JobDataMap dataMap=context.getMergedJobDataMap();
  String alertEmail=dataMap.getString(EMAIL);
  try {
    ApplicationContext appContext=(ApplicationContext)context.getScheduler().getContext().get("String_Node_Str");
    mailSender=(OpenClinicaMailSender)appContext.getBean("String_Node_Str");
    dataSource=(DataSource)appContext.getBean("String_Node_Str");
    DatasetDAO dsdao=new DatasetDAO(dataSource);
    int userAccountId=dataMap.getInt(USER_ID);
    String outputPath=dataMap.getString(POST_FILE_PATH);
    String generalFileDir=dataMap.getString(XML_FILE_PATH);
    long sysTimeBegin=System.currentTimeMillis();
    userAccountDao=new UserAccountDAO(dataSource);
    UserAccountBean userBean=(UserAccountBean)userAccountDao.findByPK(userAccountId);
    generateFileService=new GenerateExtractFileService(dataSource,userBean);
    studyDao=new StudyDAO(dataSource);
    StudyBean currentStudy=(StudyBean)studyDao.findByPK(userBean.getActiveStudyId());
    StudyBean parentStudy=(StudyBean)studyDao.findByPK(currentStudy.getParentStudyId());
    int dsId=dataMap.getInt(DATASET_ID);
    DatasetBean datasetBean=(DatasetBean)dsdao.findByPK(dsId);
    ExtractBean eb=generateFileService.generateExtractBean(datasetBean,currentStudy,parentStudy);
    datasetBean.setName(datasetBean.getName().replaceAll("String_Node_Str","String_Node_Str"));
    System.out.println("String_Node_Str");
    HashMap answerMap=generateFileService.createODMFile("String_Node_Str",sysTimeBegin,generalFileDir,datasetBean,currentStudy,"String_Node_Str",eb,currentStudy.getId(),currentStudy.getParentStudyId(),"String_Node_Str",false);
    String ODMXMLFileName="String_Node_Str";
    int fId=0;
    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();
    }
    File output=new File(outputPath);
    if (!output.isDirectory()) {
      output.mkdirs();
    }
    TransformerFactory tFactory=TransformerFactory.newInstance();
    java.io.InputStream in=new java.io.FileInputStream(dataMap.getString(XSL_FILE_PATH));
    Transformer transformer=tFactory.newTransformer(new StreamSource(in));
    String xmlFilePath=generalFileDir + ODMXMLFileName;
    String endFile=outputPath + File.separator + dataMap.getString(POST_FILE_NAME);
    final long start=System.currentTimeMillis();
    transformer.transform(new StreamSource(xmlFilePath),new StreamResult(new FileOutputStream(endFile)));
    final long done=System.currentTimeMillis() - start;
    System.out.println("String_Node_Str" + done + "String_Node_Str");
    int epBeanId=dataMap.getInt(EXTRACT_PROPERTY);
    ExtractPropertyBean epBean=CoreResources.findExtractPropertyBeanById(epBeanId);
    ProcessingFunction function=epBean.getPostProcessing();
    String subject="String_Node_Str";
    String emailBody="String_Node_Str";
    if (function != null) {
      function.setTransformFileName(outputPath + File.separator + dataMap.getString(POST_FILE_NAME));
      function.setODMXMLFileName(endFile);
      function.setXslFileName(dataMap.getString(XSL_FILE_PATH));
      ProcessingResultType message=function.run();
      final long done2=System.currentTimeMillis() - start;
      System.out.println("String_Node_Str" + done2 + "String_Node_Str"+ message.getCode());
      emailBody=message.getDescription();
      if (!("String_Node_Str").equals(message.getUrl()) && function.getClass().equals(org.akaza.openclinica.bean.service.PdfProcessingFunction.class)) {
        ArchivedDatasetFileBean fbFinal=generateFileRecord(dataMap.getString(POST_FILE_NAME) + "String_Node_Str",outputPath,datasetBean,done,new File(endFile).length(),ExportFormatBean.PDFFILE,userAccountId);
        emailBody=emailBody + "String_Node_Str" + message.getUrl()+ fbFinal.getId()+ "String_Node_Str"+ epBean.getLinkText()+ "String_Node_Str";
      }
      if (message.getCode().intValue() == 1) {
        subject="String_Node_Str" + datasetBean.getName();
      }
 else       if (message.getCode().intValue() == 2) {
        subject="String_Node_Str" + datasetBean.getName();
      }
 else       if (message.getCode().intValue() == 3) {
        subject="String_Node_Str" + datasetBean.getName();
      }
    }
 else {
      ArchivedDatasetFileBean fbFinal=generateFileRecord(dataMap.getString(POST_FILE_NAME),outputPath,datasetBean,done,new File(endFile).length(),ExportFormatBean.TXTFILE,userAccountId);
      subject="String_Node_Str" + datasetBean.getName();
      emailBody=datasetBean.getName() + "String_Node_Str";
      emailBody=emailBody + "String_Node_Str" + CoreResources.getField("String_Node_Str")+ "String_Node_Str"+ fbFinal.getId()+ "String_Node_Str";
    }
    String email=dataMap.getString(EMAIL);
    try {
      mailSender.sendEmail(email,EmailEngine.getAdminEmail(),subject,emailBody,true);
    }
 catch (    OpenClinicaSystemException ose) {
    }
    System.out.println("String_Node_Str" + email + "String_Node_Str"+ EmailEngine.getAdminEmail());
  }
 catch (  TransformerConfigurationException e) {
    sendErrorEmail(e.getMessage(),context);
    e.printStackTrace();
  }
catch (  FileNotFoundException e) {
    sendErrorEmail(e.getMessage(),context);
    e.printStackTrace();
  }
catch (  TransformerFactoryConfigurationError e) {
    sendErrorEmail(e.getMessage(),context);
    e.printStackTrace();
  }
catch (  TransformerException e) {
    sendErrorEmail(e.getMessage(),context);
    e.printStackTrace();
  }
catch (  Exception ee) {
    sendErrorEmail(ee.getMessage(),context);
    ee.printStackTrace();
  }
}