Program: 188747
Project: 188747
Buggy source:
private Report executeOnRepresentation(IndexService index,ModelService model,StorageService storage,List<Representation> list) throws PluginException {
  List<String> newRepresentations=new ArrayList<String>();
  String aipId=null;
  Report report=PluginHelper.createPluginReport(this);
  String detailExtension="String_Node_Str";
  for (  Representation representation : list) {
    List<File> unchangedFiles=new ArrayList<File>();
    String newRepresentationID=UUID.randomUUID().toString();
    List<File> alteredFiles=new ArrayList<File>();
    List<File> newFiles=new ArrayList<File>();
    aipId=representation.getAipId();
    int pluginResultState=1;
    boolean notify=true;
    Report reportItem=PluginHelper.createPluginReportItem(this,representation.getId(),null);
    try {
      LOGGER.debug("String_Node_Str" + representation);
      boolean recursive=true;
      CloseableIterable<File> allFiles=model.listFilesUnder(representation.getAipId(),representation.getId(),recursive);
      for (      File file : allFiles) {
        LOGGER.debug("String_Node_Str" + file);
        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 (doPluginExecute(fileFormat,filePronom,fileMimetype,applicableTo,convertableTo,pronomToExtension,mimetypeToExtension)) {
            fileFormat=getNewFileFormat(fileFormat,filePronom,fileMimetype,applicableTo,pronomToExtension,mimetypeToExtension);
            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);
              if (!newRepresentations.contains(newRepresentationID)) {
                LOGGER.debug("String_Node_Str" + newRepresentationID + "String_Node_Str"+ aipId);
                boolean original=false;
                newRepresentations.add(newRepresentationID);
                model.createRepresentation(aipId,newRepresentationID,original,notify);
              }
              String newFileId=file.getId().replaceFirst("String_Node_Str","String_Node_Str" + outputFormat);
              File newFile=model.createFile(aipId,newRepresentationID,file.getPath(),newFileId,payload,notify);
              alteredFiles.add(file);
              newFiles.add(newFile);
              IOUtils.closeQuietly(directAccess);
              reportItem.setPluginState(PluginState.SUCCESS).setPluginDetails(result);
            }
 catch (            CommandException e) {
              detailExtension+=file.getId() + "String_Node_Str" + e.getOutput();
              pluginResultState=2;
              reportItem.setPluginState(PluginState.PARTIAL_SUCCESS).setPluginDetails(e.getMessage());
              LOGGER.debug("String_Node_Str" + fileFormat + "String_Node_Str"+ outputFormat+ "String_Node_Str"+ file.getId()+ "String_Node_Str"+ representation.getId()+ "String_Node_Str"+ representation.getAipId());
            }
          }
 else {
            unchangedFiles.add(file);
          }
        }
      }
      IOUtils.closeQuietly(allFiles);
      report.addReport(reportItem);
      if (alteredFiles.size() > 0) {
        createNewFilesOnRepresentation(storage,model,unchangedFiles,newRepresentationID,notify);
        boolean notifyReindex=false;
        AbstractConvertPluginUtils.reIndexingRepresentationAfterConversion(index,model,storage,aipId,newRepresentationID,notifyReindex);
      }
    }
 catch (    RuntimeException|NotFoundException|GenericException|RequestNotValidException|AuthorizationDeniedException|IOException|AlreadyExistsException|ValidationException|InvalidParameterException|SAXException|TikaException|XmlException e) {
      LOGGER.error("String_Node_Str" + representation.getId() + "String_Node_Str"+ e.getMessage(),e);
      pluginResultState=0;
      reportItem.setPluginState(PluginState.FAILURE).setPluginDetails(e.getMessage());
      report.addReport(reportItem);
    }
    LOGGER.debug("String_Node_Str" + representation.getId());
    boolean notifyEvent=false;
    createEvent(alteredFiles,newFiles,aipId,newRepresentationID,model,outputFormat,pluginResultState,detailExtension,notifyEvent);
  }
  try {
    model.notifyAIPUpdated(aipId);
  }
 catch (  RODAException e) {
    LOGGER.error("String_Node_Str",e);
  }
  return report;
}

Fixed version (ground truth):
private Report executeOnRepresentation(IndexService index,ModelService model,StorageService storage,List<Representation> list) throws PluginException {
  List<String> newRepresentations=new ArrayList<String>();
  String aipId=null;
  Report report=PluginHelper.createPluginReport(this);
  String detailExtension="String_Node_Str";
  for (  Representation representation : list) {
    List<File> unchangedFiles=new ArrayList<File>();
    String newRepresentationID=UUID.randomUUID().toString();
    List<File> alteredFiles=new ArrayList<File>();
    List<File> newFiles=new ArrayList<File>();
    aipId=representation.getAipId();
    PluginState pluginResultState=PluginState.SUCCESS;
    boolean notify=true;
    Report reportItem=PluginHelper.createPluginReportItem(this,representation.getId(),null);
    try {
      LOGGER.debug("String_Node_Str" + representation);
      boolean recursive=true;
      CloseableIterable<File> allFiles=model.listFilesUnder(representation.getAipId(),representation.getId(),recursive);
      for (      File file : allFiles) {
        LOGGER.debug("String_Node_Str" + file);
        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 (doPluginExecute(fileFormat,filePronom,fileMimetype,applicableTo,convertableTo,pronomToExtension,mimetypeToExtension)) {
            fileFormat=getNewFileFormat(fileFormat,filePronom,fileMimetype,applicableTo,pronomToExtension,mimetypeToExtension);
            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);
              if (!newRepresentations.contains(newRepresentationID)) {
                LOGGER.debug("String_Node_Str" + newRepresentationID + "String_Node_Str"+ aipId);
                boolean original=false;
                newRepresentations.add(newRepresentationID);
                model.createRepresentation(aipId,newRepresentationID,original,notify);
              }
              String newFileId=file.getId().replaceFirst("String_Node_Str","String_Node_Str" + outputFormat);
              File newFile=model.createFile(aipId,newRepresentationID,file.getPath(),newFileId,payload,notify);
              alteredFiles.add(file);
              newFiles.add(newFile);
              IOUtils.closeQuietly(directAccess);
              reportItem.setPluginState(PluginState.SUCCESS).setPluginDetails(result);
            }
 catch (            CommandException e) {
              detailExtension+=file.getId() + "String_Node_Str" + e.getOutput();
              pluginResultState=PluginState.PARTIAL_SUCCESS;
              reportItem.setPluginState(PluginState.PARTIAL_SUCCESS).setPluginDetails(e.getMessage());
              LOGGER.debug("String_Node_Str" + fileFormat + "String_Node_Str"+ outputFormat+ "String_Node_Str"+ file.getId()+ "String_Node_Str"+ representation.getId()+ "String_Node_Str"+ representation.getAipId());
            }
          }
 else {
            unchangedFiles.add(file);
          }
        }
      }
      IOUtils.closeQuietly(allFiles);
      report.addReport(reportItem);
      if (alteredFiles.size() > 0) {
        createNewFilesOnRepresentation(storage,model,unchangedFiles,newRepresentationID,notify);
        boolean notifyReindex=false;
        AbstractConvertPluginUtils.reIndexingRepresentationAfterConversion(index,model,storage,aipId,newRepresentationID,notifyReindex);
      }
    }
 catch (    RuntimeException|NotFoundException|GenericException|RequestNotValidException|AuthorizationDeniedException|IOException|AlreadyExistsException|ValidationException|InvalidParameterException|SAXException|TikaException|XmlException e) {
      LOGGER.error("String_Node_Str" + representation.getId() + "String_Node_Str"+ e.getMessage(),e);
      pluginResultState=PluginState.FAILURE;
      reportItem.setPluginState(PluginState.FAILURE).setPluginDetails(e.getMessage());
      report.addReport(reportItem);
    }
    LOGGER.debug("String_Node_Str" + representation.getId());
    boolean notifyEvent=false;
    createEvent(alteredFiles,newFiles,aipId,newRepresentationID,model,outputFormat,pluginResultState,detailExtension,notifyEvent);
  }
  try {
    model.notifyAIPUpdated(aipId);
  }
 catch (  RODAException e) {
    LOGGER.error("String_Node_Str",e);
  }
  return report;
}