Program: 129525
Project: 129525
Buggy source:
public void generateDocumentation(ExportFileResource resource,String targetPath,String... jobVersion) throws Exception {
  List<URL> picList=new ArrayList<URL>(5);
  String jobName=resource.getItem().getProperty().getLabel();
  String jobPath=resource.getItem().getProperty().getItem().getState().getPath();
  if (targetPath.endsWith(this.repositoryObjectType.toString().toLowerCase())) {
    targetPath=targetPath + IPath.SEPARATOR + jobPath+ IPath.SEPARATOR+ jobName;
  }
  String version="String_Node_Str";
  if (jobVersion != null && jobVersion.length == 1) {
    version=jobVersion[0];
  }
 else {
    version=resource.getItem().getProperty().getVersion();
  }
  targetPath=targetPath + "String_Node_Str" + version;
  File file=new File(targetPath);
  if (file.exists()) {
    FilesUtils.removeFolder(file,true);
  }
  file.mkdirs();
  handleXMLFile(resource,targetPath,jobVersion);
  String picFolderPath=checkPicDirIsExists(resource,targetPath);
  final Bundle b=Platform.getBundle("String_Node_Str");
  final URL xslFileUrl=FileLocator.toFileURL(FileLocator.find(b,new Path(IHTMLDocConstants.MAIN_XSL_FILE_PATH),null));
  File logoFile=new File(picFolderPath + File.separatorChar + IHTMLDocConstants.TALEND_LOGO_FILE_NAME);
  saveLogoImage(SWT.IMAGE_JPEG,logoFile);
  String xslFilePath=xslFileUrl.getPath();
  boolean isCheck=CorePlugin.getDefault().getPreferenceStore().getBoolean(ITalendCorePrefConstants.USE_CSS_TEMPLATE);
  String cssFile=CorePlugin.getDefault().getPreferenceStore().getString(ITalendCorePrefConstants.CSS_FILE_PATH);
  String temXslPath=null;
  if (isCheck && cssFile != null && !cssFile.equals("String_Node_Str")) {
    String tempFolderPath=checkTempDirIsExists(resource);
    temXslPath=tempFolderPath + File.separator + (new File(xslFilePath)).getName();
    File temXslFile=new File(temXslPath);
    if (temXslFile.exists()) {
      temXslFile.delete();
    }
    generateXslFile(xslFilePath,temXslPath,cssFile,null);
  }
  if (temXslPath != null) {
    File temFile=new File(temXslPath);
    if (!temFile.exists()) {
      temXslPath=xslFilePath;
    }
  }
 else {
    temXslPath=xslFilePath;
  }
  picList.add(logoFile.toURL());
  byte[] innerContent=null;
  ProcessType processType=null;
  if (resource.getItem() instanceof ProcessItem) {
    processType=((ProcessItem)resource.getItem()).getProcess();
    innerContent=(byte[])processType.getScreenshots().get("String_Node_Str");
  }
 else   if (resource.getItem() instanceof JobletProcessItem) {
    processType=((JobletProcessItem)resource.getItem()).getJobletProcess();
    innerContent=(byte[])processType.getScreenshots().get("String_Node_Str");
    ;
  }
  if (innerContent != null) {
    String picName=jobName + "String_Node_Str" + version+ IHTMLDocConstants.JOB_PREVIEW_PIC_SUFFIX;
    ImageUtils.save(innerContent,picFolderPath + File.separatorChar + picName,SWT.IMAGE_PNG);
    picList.add(new File(picFolderPath + File.separatorChar + picName).toURL());
    ByteArrayInputStream bais=new ByteArrayInputStream(innerContent);
    Image pdfImage=new Image(null,bais);
    int width=pdfImage.getImageData().width;
    int percent=22 * 32 * 100 / width;
    ImageUtils.save(ImageUtils.scale(pdfImage,percent),picFolderPath + File.separatorChar + "String_Node_Str"+ picName,SWT.IMAGE_PNG);
    picList.add(new File(picFolderPath + File.separatorChar + "String_Node_Str"+ picName).toURL());
    pdfImage.dispose();
  }
  for (  NodeType node : (List<NodeType>)processType.getNode()) {
    String uniqueName="String_Node_Str";
    for (    Object o : node.getElementParameter()) {
      if (o instanceof ElementParameterType) {
        if ("String_Node_Str".equals(((ElementParameterType)o).getName())) {
          uniqueName=((ElementParameterType)o).getValue();
          break;
        }
      }
    }
    byte[] screenshot=(byte[])processType.getScreenshots().get(uniqueName);
    if (screenshot != null && screenshot.length != 0) {
      String picName=IHTMLDocConstants.EXTERNAL_NODE_PREVIEW + uniqueName + IHTMLDocConstants.JOB_PREVIEW_PIC_SUFFIX;
      ImageUtils.save(screenshot,picFolderPath + File.separatorChar + picName,SWT.IMAGE_PNG);
      picList.add(new File(picFolderPath + File.separatorChar + picName).toURL());
      ByteArrayInputStream bais=new ByteArrayInputStream(screenshot);
      Image pdfImage=new Image(null,bais);
      int width=pdfImage.getImageData().width;
      int percent=22 * 32 * 100 / width;
      ImageUtils.save(ImageUtils.scale(pdfImage,percent),picFolderPath + File.separatorChar + "String_Node_Str"+ picName,SWT.IMAGE_PNG);
      picList.add(new File(picFolderPath + File.separatorChar + picName).toURL());
      pdfImage.dispose();
    }
  }
  Set keySet=picFilePathMap.keySet();
  for (  Object key : keySet) {
    String value=picFilePathMap.get(key);
    FileCopyUtils.copy(value,picFolderPath + File.separatorChar + key);
    picList.add(new File(picFolderPath + File.separatorChar + key).toURL());
  }
  List<URL> resultFiles=parseXml2HtmlPdf(targetPath,jobName + "String_Node_Str" + version,temXslPath);
  resource.addResources(resultFiles);
  resource.addResources(IHTMLDocConstants.PIC_FOLDER_NAME,picList);
  HTMLDocUtils.deleteTempFiles();
  targetConnectionMap=null;
  sourceConnectionMap=null;
}

Fixed version (ground truth):
public void generateDocumentation(ExportFileResource resource,String targetPath,String... jobVersion) throws Exception {
  List<URL> picList=new ArrayList<URL>(5);
  String jobName=resource.getItem().getProperty().getLabel();
  String jobPath=resource.getItem().getProperty().getItem().getState().getPath();
  if (jobName != null && !(jobName).equals(this.repositoryObjectType.toString().toLowerCase()) && targetPath.endsWith(this.repositoryObjectType.toString().toLowerCase())) {
    targetPath=targetPath + IPath.SEPARATOR + jobPath+ IPath.SEPARATOR+ jobName;
  }
  String version="String_Node_Str";
  if (jobVersion != null && jobVersion.length == 1) {
    version=jobVersion[0];
  }
 else {
    version=resource.getItem().getProperty().getVersion();
  }
  targetPath=targetPath + "String_Node_Str" + version;
  File file=new File(targetPath);
  if (file.exists()) {
    FilesUtils.removeFolder(file,true);
  }
  file.mkdirs();
  handleXMLFile(resource,targetPath,jobVersion);
  String picFolderPath=checkPicDirIsExists(resource,targetPath);
  final Bundle b=Platform.getBundle("String_Node_Str");
  final URL xslFileUrl=FileLocator.toFileURL(FileLocator.find(b,new Path(IHTMLDocConstants.MAIN_XSL_FILE_PATH),null));
  File logoFile=new File(picFolderPath + File.separatorChar + IHTMLDocConstants.TALEND_LOGO_FILE_NAME);
  saveLogoImage(SWT.IMAGE_JPEG,logoFile);
  String xslFilePath=xslFileUrl.getPath();
  boolean isCheck=CorePlugin.getDefault().getPreferenceStore().getBoolean(ITalendCorePrefConstants.USE_CSS_TEMPLATE);
  String cssFile=CorePlugin.getDefault().getPreferenceStore().getString(ITalendCorePrefConstants.CSS_FILE_PATH);
  String temXslPath=null;
  if (isCheck && cssFile != null && !cssFile.equals("String_Node_Str")) {
    String tempFolderPath=checkTempDirIsExists(resource);
    temXslPath=tempFolderPath + File.separator + (new File(xslFilePath)).getName();
    File temXslFile=new File(temXslPath);
    if (temXslFile.exists()) {
      temXslFile.delete();
    }
    generateXslFile(xslFilePath,temXslPath,cssFile,null);
  }
  if (temXslPath != null) {
    File temFile=new File(temXslPath);
    if (!temFile.exists()) {
      temXslPath=xslFilePath;
    }
  }
 else {
    temXslPath=xslFilePath;
  }
  picList.add(logoFile.toURL());
  byte[] innerContent=null;
  ProcessType processType=null;
  if (resource.getItem() instanceof ProcessItem) {
    processType=((ProcessItem)resource.getItem()).getProcess();
    innerContent=(byte[])processType.getScreenshots().get("String_Node_Str");
  }
 else   if (resource.getItem() instanceof JobletProcessItem) {
    processType=((JobletProcessItem)resource.getItem()).getJobletProcess();
    innerContent=(byte[])processType.getScreenshots().get("String_Node_Str");
    ;
  }
  if (innerContent != null) {
    String picName=jobName + "String_Node_Str" + version+ IHTMLDocConstants.JOB_PREVIEW_PIC_SUFFIX;
    ImageUtils.save(innerContent,picFolderPath + File.separatorChar + picName,SWT.IMAGE_PNG);
    picList.add(new File(picFolderPath + File.separatorChar + picName).toURL());
    ByteArrayInputStream bais=new ByteArrayInputStream(innerContent);
    Image pdfImage=new Image(null,bais);
    int width=pdfImage.getImageData().width;
    int percent=22 * 32 * 100 / width;
    ImageUtils.save(ImageUtils.scale(pdfImage,percent),picFolderPath + File.separatorChar + "String_Node_Str"+ picName,SWT.IMAGE_PNG);
    picList.add(new File(picFolderPath + File.separatorChar + "String_Node_Str"+ picName).toURL());
    pdfImage.dispose();
  }
  for (  NodeType node : (List<NodeType>)processType.getNode()) {
    String uniqueName="String_Node_Str";
    for (    Object o : node.getElementParameter()) {
      if (o instanceof ElementParameterType) {
        if ("String_Node_Str".equals(((ElementParameterType)o).getName())) {
          uniqueName=((ElementParameterType)o).getValue();
          break;
        }
      }
    }
    byte[] screenshot=(byte[])processType.getScreenshots().get(uniqueName);
    if (screenshot != null && screenshot.length != 0) {
      String picName=IHTMLDocConstants.EXTERNAL_NODE_PREVIEW + uniqueName + IHTMLDocConstants.JOB_PREVIEW_PIC_SUFFIX;
      ImageUtils.save(screenshot,picFolderPath + File.separatorChar + picName,SWT.IMAGE_PNG);
      picList.add(new File(picFolderPath + File.separatorChar + picName).toURL());
      ByteArrayInputStream bais=new ByteArrayInputStream(screenshot);
      Image pdfImage=new Image(null,bais);
      int width=pdfImage.getImageData().width;
      int percent=22 * 32 * 100 / width;
      ImageUtils.save(ImageUtils.scale(pdfImage,percent),picFolderPath + File.separatorChar + "String_Node_Str"+ picName,SWT.IMAGE_PNG);
      picList.add(new File(picFolderPath + File.separatorChar + picName).toURL());
      pdfImage.dispose();
    }
  }
  Set keySet=picFilePathMap.keySet();
  for (  Object key : keySet) {
    String value=picFilePathMap.get(key);
    FileCopyUtils.copy(value,picFolderPath + File.separatorChar + key);
    picList.add(new File(picFolderPath + File.separatorChar + key).toURL());
  }
  List<URL> resultFiles=parseXml2HtmlPdf(targetPath,jobName + "String_Node_Str" + version,temXslPath);
  resource.addResources(resultFiles);
  resource.addResources(IHTMLDocConstants.PIC_FOLDER_NAME,picList);
  HTMLDocUtils.deleteTempFiles();
  targetConnectionMap=null;
  sourceConnectionMap=null;
}