Program: 188789
Project: 188789
Buggy source:
private Report executeOnFile(IndexService index,ModelService model,StorageService storage,List<File> list,IndexedPreservationAgent agent) throws PluginException {
  int pluginResultState=1;
  Set<String> aipSet=new HashSet<String>();
  boolean notify=true;
  String newRepresentationID=null;
  String newFileId=null;
  ArrayList<File> newFiles=new ArrayList<File>();
  String detailExtension="String_Node_Str";
  Report report=PluginHelper.createPluginReport(this);
  ReportItem reportItem=null;
  for (  File file : list) {
    try {
      LOGGER.debug("String_Node_Str" + file.getId());
      newRepresentationID=UUID.randomUUID().toString();
      reportItem=PluginHelper.createPluginReportItem(this,"String_Node_Str",file.getId(),null);
      if (!file.isDirectory()) {
        IndexedFile ifile=index.retrieve(IndexedFile.class,IdUtils.getFileId(file));
        String fileMimetype=ifile.getFileFormat().getMimeType();
        String filePronom=ifile.getFileFormat().getPronom();
        String fileFormat=ifile.getId().substring(ifile.getId().lastIndexOf('.') + 1);
        List<String> applicableTo=getApplicableTo();
        Map<String,List<String>> pronomToExtension=getPronomToExtension();
        Map<String,List<String>> mimetypeToExtension=getMimetypeToExtension();
        if (((!getInputFormat().isEmpty() && fileFormat.equalsIgnoreCase(getInputFormat())) || (getInputFormat().isEmpty())) && (applicableTo.size() == 0 || (filePronom != null && pronomToExtension.containsKey(filePronom)) || (fileMimetype != null && mimetypeToExtension.containsKey(fileMimetype)) || (applicableTo.contains(fileFormat)))) {
          if (applicableTo.size() > 0) {
            if (filePronom != null && !filePronom.isEmpty() && pronomToExtension.get(filePronom) != null && !pronomToExtension.get(filePronom).contains(fileFormat)) {
              fileFormat=pronomToExtension.get(filePronom).get(0);
            }
 else             if (fileMimetype != null && !fileMimetype.isEmpty() && mimetypeToExtension.get(fileMimetype) != null && !mimetypeToExtension.get(fileMimetype).contains(fileFormat)) {
              fileFormat=mimetypeToExtension.get(fileMimetype).get(0);
            }
          }
          StoragePath fileStoragePath=ModelUtils.getFileStoragePath(file);
          DirectResourceAccess directAccess=storage.getDirectAccess(fileStoragePath);
          LOGGER.debug("String_Node_Str" + fileFormat + "String_Node_Str"+ outputFormat+ "String_Node_Str"+ file.getId());
          try {
            Path pluginResult=Files.createTempFile("String_Node_Str","String_Node_Str" + getOutputFormat());
            String result=executePlugin(directAccess.getPath(),pluginResult,fileFormat);
            ContentPayload payload=new FSPathContentPayload(pluginResult);
            StoragePath storagePath=ModelUtils.getRepresentationStoragePath(file.getAipId(),file.getRepresentationId());
            LOGGER.debug("String_Node_Str" + newRepresentationID + "String_Node_Str"+ file.getAipId());
            boolean original=false;
            model.createRepresentation(file.getAipId(),newRepresentationID,original,model.getStorage(),storagePath);
            newFileId=file.getId().replaceFirst("String_Node_Str","String_Node_Str" + outputFormat);
            model.deleteFile(file.getAipId(),newRepresentationID,file.getPath(),file.getId(),notify);
            File f=model.createFile(file.getAipId(),newRepresentationID,file.getPath(),newFileId,payload,notify);
            newFiles.add(f);
            aipSet.add(file.getAipId());
            reportItem=PluginHelper.setPluginReportItemInfo(reportItem,file.getId(),new Attribute(RodaConstants.REPORT_ATTR_OUTCOME,PluginState.SUCCESS.toString()),new Attribute(RodaConstants.REPORT_ATTR_OUTCOME_DETAILS,result));
          }
 catch (          CommandException e) {
            detailExtension+=file.getId() + "String_Node_Str" + e.getOutput();
            pluginResultState=2;
            reportItem=PluginHelper.setPluginReportItemInfo(reportItem,file.getId(),new Attribute(RodaConstants.REPORT_ATTR_OUTCOME,PluginState.PARTIAL_SUCCESS.toString()),new Attribute(RodaConstants.REPORT_ATTR_OUTCOME_DETAILS,e.getMessage()));
            LOGGER.debug("String_Node_Str" + fileFormat + "String_Node_Str"+ outputFormat+ "String_Node_Str"+ file.getId()+ "String_Node_Str"+ file.getRepresentationId()+ "String_Node_Str"+ file.getAipId());
          }
        }
      }
    }
 catch (    RuntimeException|NotFoundException|GenericException|RequestNotValidException|AuthorizationDeniedException|ValidationException|IOException|AlreadyExistsException e) {
      LOGGER.error("String_Node_Str" + file.getId() + "String_Node_Str"+ e.getMessage(),e);
      pluginResultState=0;
      reportItem=PluginHelper.setPluginReportItemInfo(reportItem,file.getId(),new Attribute(RodaConstants.REPORT_ATTR_OUTCOME,PluginState.FAILURE.toString()),new Attribute(RodaConstants.REPORT_ATTR_OUTCOME_DETAILS,e.getMessage()));
    }
    boolean notifyEvent=false;
    createEvent(Arrays.asList(file),newFiles,file.getAipId(),newRepresentationID,model,outputFormat,pluginResultState,detailExtension,agent,notifyEvent);
    report.addItem(reportItem);
  }
  try {
    AbstractConvertPluginUtils.reIndexPlugins(model,aipSet);
  }
 catch (  Throwable e) {
    LOGGER.debug("String_Node_Str");
  }
  return report;
}

Fixed version (ground truth):
private Report executeOnFile(IndexService index,ModelService model,StorageService storage,List<File> list,IndexedPreservationAgent agent) throws PluginException {
  int pluginResultState=1;
  Set<String> aipSet=new HashSet<String>();
  boolean notify=true;
  String newRepresentationID=null;
  String newFileId=null;
  ArrayList<File> newFiles=new ArrayList<File>();
  String detailExtension="String_Node_Str";
  Report report=PluginHelper.createPluginReport(this);
  ReportItem reportItem=null;
  for (  File file : list) {
    try {
      LOGGER.debug("String_Node_Str" + file.getId());
      newRepresentationID=UUID.randomUUID().toString();
      reportItem=PluginHelper.createPluginReportItem(this,"String_Node_Str",file.getId(),null);
      if (!file.isDirectory()) {
        IndexedFile ifile=index.retrieve(IndexedFile.class,IdUtils.getFileId(file));
        String fileMimetype=ifile.getFileFormat().getMimeType();
        String filePronom=ifile.getFileFormat().getPronom();
        String fileFormat=ifile.getId().substring(ifile.getId().lastIndexOf('.') + 1);
        List<String> applicableTo=getApplicableTo();
        List<String> convertableTo=getConvertableTo();
        Map<String,List<String>> pronomToExtension=getPronomToExtension();
        Map<String,List<String>> mimetypeToExtension=getMimetypeToExtension();
        if (((!getInputFormat().isEmpty() && fileFormat.equalsIgnoreCase(getInputFormat())) || (getInputFormat().isEmpty())) && (applicableTo.size() == 0 || (filePronom != null && pronomToExtension.containsKey(filePronom)) || (fileMimetype != null && mimetypeToExtension.containsKey(fileMimetype)) || (applicableTo.contains(fileFormat))) && (convertableTo.size() == 0 || convertableTo.contains(outputFormat))) {
          if (applicableTo.size() > 0) {
            if (filePronom != null && !filePronom.isEmpty() && pronomToExtension.get(filePronom) != null && !pronomToExtension.get(filePronom).contains(fileFormat)) {
              fileFormat=pronomToExtension.get(filePronom).get(0);
            }
 else             if (fileMimetype != null && !fileMimetype.isEmpty() && mimetypeToExtension.get(fileMimetype) != null && !mimetypeToExtension.get(fileMimetype).contains(fileFormat)) {
              fileFormat=mimetypeToExtension.get(fileMimetype).get(0);
            }
          }
          StoragePath fileStoragePath=ModelUtils.getFileStoragePath(file);
          DirectResourceAccess directAccess=storage.getDirectAccess(fileStoragePath);
          LOGGER.debug("String_Node_Str" + fileFormat + "String_Node_Str"+ outputFormat+ "String_Node_Str"+ file.getId());
          try {
            Path pluginResult=Files.createTempFile("String_Node_Str","String_Node_Str" + getOutputFormat());
            String result=executePlugin(directAccess.getPath(),pluginResult,fileFormat);
            ContentPayload payload=new FSPathContentPayload(pluginResult);
            StoragePath storagePath=ModelUtils.getRepresentationStoragePath(file.getAipId(),file.getRepresentationId());
            LOGGER.debug("String_Node_Str" + newRepresentationID + "String_Node_Str"+ file.getAipId());
            boolean original=false;
            model.createRepresentation(file.getAipId(),newRepresentationID,original,model.getStorage(),storagePath);
            newFileId=file.getId().replaceFirst("String_Node_Str","String_Node_Str" + outputFormat);
            model.deleteFile(file.getAipId(),newRepresentationID,file.getPath(),file.getId(),notify);
            File f=model.createFile(file.getAipId(),newRepresentationID,file.getPath(),newFileId,payload,notify);
            newFiles.add(f);
            aipSet.add(file.getAipId());
            reportItem=PluginHelper.setPluginReportItemInfo(reportItem,file.getId(),new Attribute(RodaConstants.REPORT_ATTR_OUTCOME,PluginState.SUCCESS.toString()),new Attribute(RodaConstants.REPORT_ATTR_OUTCOME_DETAILS,result));
          }
 catch (          CommandException e) {
            detailExtension+=file.getId() + "String_Node_Str" + e.getOutput();
            pluginResultState=2;
            reportItem=PluginHelper.setPluginReportItemInfo(reportItem,file.getId(),new Attribute(RodaConstants.REPORT_ATTR_OUTCOME,PluginState.PARTIAL_SUCCESS.toString()),new Attribute(RodaConstants.REPORT_ATTR_OUTCOME_DETAILS,e.getMessage()));
            LOGGER.debug("String_Node_Str" + fileFormat + "String_Node_Str"+ outputFormat+ "String_Node_Str"+ file.getId()+ "String_Node_Str"+ file.getRepresentationId()+ "String_Node_Str"+ file.getAipId());
          }
        }
      }
    }
 catch (    RuntimeException|NotFoundException|GenericException|RequestNotValidException|AuthorizationDeniedException|ValidationException|IOException|AlreadyExistsException e) {
      LOGGER.error("String_Node_Str" + file.getId() + "String_Node_Str"+ e.getMessage(),e);
      pluginResultState=0;
      reportItem=PluginHelper.setPluginReportItemInfo(reportItem,file.getId(),new Attribute(RodaConstants.REPORT_ATTR_OUTCOME,PluginState.FAILURE.toString()),new Attribute(RodaConstants.REPORT_ATTR_OUTCOME_DETAILS,e.getMessage()));
    }
    boolean notifyEvent=false;
    createEvent(Arrays.asList(file),newFiles,file.getAipId(),newRepresentationID,model,outputFormat,pluginResultState,detailExtension,agent,notifyEvent);
    report.addItem(reportItem);
  }
  try {
    AbstractConvertPluginUtils.reIndexPlugins(model,aipSet);
  }
 catch (  Throwable e) {
    LOGGER.debug("String_Node_Str");
  }
  return report;
}