Program: 188748
Project: 188748
Buggy source:
private Report executeOnAIP(IndexService index,ModelService model,StorageService storage,List<AIP> list) throws PluginException {
  Report report=PluginHelper.createPluginReport(this);
  String detailExtension="String_Node_Str";
  for (  AIP aip : list) {
    LOGGER.debug("String_Node_Str" + aip.getId());
    List<String> newRepresentations=new ArrayList<String>();
    String newRepresentationID=null;
    boolean notify=true;
    for (    Representation representation : aip.getRepresentations()) {
      List<File> alteredFiles=new ArrayList<File>();
      List<File> newFiles=new ArrayList<File>();
      List<File> unchangedFiles=new ArrayList<File>();
      newRepresentationID=UUID.randomUUID().toString();
      int pluginResultState=1;
      Report reportItem=PluginHelper.createPluginReportItem(this,representation.getId(),null);
      try {
        LOGGER.debug("String_Node_Str" + representation);
        boolean recursive=true;
        CloseableIterable<File> allFiles=model.listFilesUnder(aip.getId(),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,ifile.getId().length());
            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"+ aip.getId());
                  boolean original=false;
                  newRepresentations.add(newRepresentationID);
                  model.createRepresentation(aip.getId(),newRepresentationID,original,notify);
                }
                String newFileId=file.getId().replaceFirst("String_Node_Str","String_Node_Str" + outputFormat);
                File f=model.createFile(aip.getId(),newRepresentationID,file.getPath(),newFileId,payload,notify);
                alteredFiles.add(file);
                newFiles.add(f);
                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"+ aip.getId());
              }
            }
 else {
              unchangedFiles.add(file);
            }
          }
        }
        IOUtils.closeQuietly(allFiles);
        if (alteredFiles.size() > 0) {
          createNewFilesOnRepresentation(storage,model,unchangedFiles,newRepresentationID,notify);
        }
      }
 catch (      RuntimeException|NotFoundException|GenericException|RequestNotValidException|AuthorizationDeniedException|IOException|AlreadyExistsException e) {
        LOGGER.error("String_Node_Str" + aip.getId() + "String_Node_Str"+ e.getMessage(),e);
        pluginResultState=0;
        reportItem.setPluginState(PluginState.FAILURE).setPluginDetails(e.getMessage());
      }
      LOGGER.debug("String_Node_Str" + representation.getId());
      boolean notifyEvent=false;
      createEvent(alteredFiles,newFiles,aip.getId(),newRepresentationID,model,outputFormat,pluginResultState,detailExtension,notifyEvent);
      report.addReport(reportItem);
    }
    try {
      for (      String repId : newRepresentations) {
        boolean inotify=false;
        AbstractConvertPluginUtils.reIndexingRepresentationAfterConversion(index,model,storage,aip.getId(),repId,inotify);
      }
      model.notifyAIPUpdated(aip.getId());
    }
 catch (    Exception e) {
      LOGGER.debug("String_Node_Str" + newRepresentationID);
    }
  }
  return report;
}

Fixed version (ground truth):
private Report executeOnAIP(IndexService index,ModelService model,StorageService storage,List<AIP> list) throws PluginException {
  Report report=PluginHelper.createPluginReport(this);
  String detailExtension="String_Node_Str";
  for (  AIP aip : list) {
    LOGGER.debug("String_Node_Str" + aip.getId());
    List<String> newRepresentations=new ArrayList<String>();
    String newRepresentationID=null;
    boolean notify=true;
    for (    Representation representation : aip.getRepresentations()) {
      List<File> alteredFiles=new ArrayList<File>();
      List<File> newFiles=new ArrayList<File>();
      List<File> unchangedFiles=new ArrayList<File>();
      newRepresentationID=UUID.randomUUID().toString();
      PluginState pluginResultState=PluginState.SUCCESS;
      Report reportItem=PluginHelper.createPluginReportItem(this,representation.getId(),null);
      try {
        LOGGER.debug("String_Node_Str" + representation);
        boolean recursive=true;
        CloseableIterable<File> allFiles=model.listFilesUnder(aip.getId(),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,ifile.getId().length());
            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"+ aip.getId());
                  boolean original=false;
                  newRepresentations.add(newRepresentationID);
                  model.createRepresentation(aip.getId(),newRepresentationID,original,notify);
                }
                String newFileId=file.getId().replaceFirst("String_Node_Str","String_Node_Str" + outputFormat);
                File f=model.createFile(aip.getId(),newRepresentationID,file.getPath(),newFileId,payload,notify);
                alteredFiles.add(file);
                newFiles.add(f);
                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"+ aip.getId());
              }
            }
 else {
              unchangedFiles.add(file);
            }
          }
        }
        IOUtils.closeQuietly(allFiles);
        if (alteredFiles.size() > 0) {
          createNewFilesOnRepresentation(storage,model,unchangedFiles,newRepresentationID,notify);
        }
      }
 catch (      RuntimeException|NotFoundException|GenericException|RequestNotValidException|AuthorizationDeniedException|IOException|AlreadyExistsException e) {
        LOGGER.error("String_Node_Str" + aip.getId() + "String_Node_Str"+ e.getMessage(),e);
        pluginResultState=PluginState.FAILURE;
        reportItem.setPluginState(PluginState.FAILURE).setPluginDetails(e.getMessage());
      }
      LOGGER.debug("String_Node_Str" + representation.getId());
      boolean notifyEvent=false;
      createEvent(alteredFiles,newFiles,aip.getId(),newRepresentationID,model,outputFormat,pluginResultState,detailExtension,notifyEvent);
      report.addReport(reportItem);
    }
    try {
      for (      String repId : newRepresentations) {
        boolean inotify=false;
        AbstractConvertPluginUtils.reIndexingRepresentationAfterConversion(index,model,storage,aip.getId(),repId,inotify);
      }
      model.notifyAIPUpdated(aip.getId());
    }
 catch (    Exception e) {
      LOGGER.debug("String_Node_Str" + newRepresentationID);
    }
  }
  return report;
}