Program: 188202
Project: 188202
Buggy source:
public static SolrInputDocument aipToSolrInputDocument(AIP aip,List<String> ancestors,ModelService model,boolean safemode) throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException {
  SolrInputDocument doc=new SolrInputDocument();
  doc.addField(RodaConstants.INDEX_UUID,aip.getId());
  doc.addField(RodaConstants.AIP_ID,aip.getId());
  doc.addField(RodaConstants.AIP_PARENT_ID,aip.getParentId());
  doc.addField(RodaConstants.STATE,aip.getState().toString());
  doc.addField(RodaConstants.AIP_TYPE,aip.getType());
  doc.addField(RodaConstants.AIP_CREATED_ON,aip.getCreatedOn());
  doc.addField(RodaConstants.AIP_CREATED_BY,aip.getCreatedBy());
  doc.addField(RodaConstants.AIP_UPDATED_ON,aip.getUpdatedOn());
  doc.addField(RodaConstants.AIP_UPDATED_BY,aip.getUpdatedBy());
  doc.addField(RodaConstants.INGEST_SIP_IDS,aip.getIngestSIPIds());
  doc.addField(RodaConstants.INGEST_JOB_ID,aip.getIngestJobId());
  doc.addField(RodaConstants.INGEST_UPDATE_JOB_IDS,aip.getIngestUpdateJobIds());
  ArrayList<String> allJobIds=new ArrayList<>(aip.getIngestUpdateJobIds());
  allJobIds.add(aip.getIngestJobId());
  doc.addField(RodaConstants.ALL_INGEST_JOB_IDS,allJobIds);
  doc.addField(RodaConstants.AIP_ANCESTORS,ancestors);
  List<String> descriptiveMetadataIds=aip.getDescriptiveMetadata().stream().map(dm -> dm.getId()).collect(Collectors.toList());
  doc.addField(RodaConstants.AIP_DESCRIPTIVE_METADATA_ID,descriptiveMetadataIds);
  List<String> representationIds=aip.getRepresentations().stream().map(r -> r.getId()).collect(Collectors.toList());
  doc.addField(RodaConstants.AIP_REPRESENTATION_ID,representationIds);
  doc.addField(RodaConstants.AIP_HAS_REPRESENTATIONS,!representationIds.isEmpty());
  setPermissions(aip.getPermissions(),doc);
  doc.addField(RodaConstants.AIP_GHOST,aip.getGhost() != null ? aip.getGhost() : false);
  if (!safemode) {
    indexDescriptiveMetadataFields(model,aip.getId(),null,aip.getDescriptiveMetadata(),doc);
  }
  StorageService storage=model.getStorage();
  Long numberOfSubmissionFiles;
  try {
    Directory submissionDirectory=model.getSubmissionDirectory(aip.getId());
    numberOfSubmissionFiles=storage.countResourcesUnderDirectory(submissionDirectory.getStoragePath(),true);
  }
 catch (  NotFoundException e) {
    numberOfSubmissionFiles=0L;
  }
  Long numberOfDocumentationFiles;
  try {
    Directory documentationDirectory=model.getDocumentationDirectory(aip.getId());
    numberOfDocumentationFiles=storage.countResourcesUnderDirectory(documentationDirectory.getStoragePath(),true);
  }
 catch (  NotFoundException e) {
    numberOfDocumentationFiles=0L;
  }
  Long numberOfSchemaFiles;
  try {
    Directory schemasDirectory=model.getSchemasDirectory(aip.getId());
    numberOfSchemaFiles=storage.countResourcesUnderDirectory(schemasDirectory.getStoragePath(),true);
  }
 catch (  NotFoundException e) {
    numberOfSchemaFiles=0L;
  }
  doc.addField(RodaConstants.AIP_NUMBER_OF_SUBMISSION_FILES,numberOfSubmissionFiles);
  doc.addField(RodaConstants.AIP_NUMBER_OF_DOCUMENTATION_FILES,numberOfDocumentationFiles);
  doc.addField(RodaConstants.AIP_NUMBER_OF_SCHEMA_FILES,numberOfSchemaFiles);
  return doc;
}

Fixed version (ground truth):
public static SolrInputDocument aipToSolrInputDocument(AIP aip,List<String> ancestors,ModelService model,boolean safemode) throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException {
  SolrInputDocument doc=new SolrInputDocument();
  doc.addField(RodaConstants.INDEX_UUID,aip.getId());
  doc.addField(RodaConstants.AIP_ID,aip.getId());
  doc.addField(RodaConstants.AIP_PARENT_ID,aip.getParentId());
  doc.addField(RodaConstants.STATE,aip.getState().toString());
  doc.addField(RodaConstants.AIP_TYPE,aip.getType());
  doc.addField(RodaConstants.AIP_CREATED_ON,aip.getCreatedOn());
  doc.addField(RodaConstants.AIP_CREATED_BY,aip.getCreatedBy());
  doc.addField(RodaConstants.AIP_UPDATED_ON,aip.getUpdatedOn());
  doc.addField(RodaConstants.AIP_UPDATED_BY,aip.getUpdatedBy());
  doc.addField(RodaConstants.INGEST_SIP_IDS,aip.getIngestSIPIds());
  doc.addField(RodaConstants.INGEST_JOB_ID,aip.getIngestJobId());
  doc.addField(RodaConstants.INGEST_UPDATE_JOB_IDS,aip.getIngestUpdateJobIds());
  doc.addField(RodaConstants.AIP_ANCESTORS,ancestors);
  List<String> descriptiveMetadataIds=aip.getDescriptiveMetadata().stream().map(dm -> dm.getId()).collect(Collectors.toList());
  doc.addField(RodaConstants.AIP_DESCRIPTIVE_METADATA_ID,descriptiveMetadataIds);
  List<String> representationIds=aip.getRepresentations().stream().map(r -> r.getId()).collect(Collectors.toList());
  doc.addField(RodaConstants.AIP_REPRESENTATION_ID,representationIds);
  doc.addField(RodaConstants.AIP_HAS_REPRESENTATIONS,!representationIds.isEmpty());
  setPermissions(aip.getPermissions(),doc);
  doc.addField(RodaConstants.AIP_GHOST,aip.getGhost() != null ? aip.getGhost() : false);
  if (!safemode) {
    indexDescriptiveMetadataFields(model,aip.getId(),null,aip.getDescriptiveMetadata(),doc);
  }
  StorageService storage=model.getStorage();
  Long numberOfSubmissionFiles;
  try {
    Directory submissionDirectory=model.getSubmissionDirectory(aip.getId());
    numberOfSubmissionFiles=storage.countResourcesUnderDirectory(submissionDirectory.getStoragePath(),true);
  }
 catch (  NotFoundException e) {
    numberOfSubmissionFiles=0L;
  }
  Long numberOfDocumentationFiles;
  try {
    Directory documentationDirectory=model.getDocumentationDirectory(aip.getId());
    numberOfDocumentationFiles=storage.countResourcesUnderDirectory(documentationDirectory.getStoragePath(),true);
  }
 catch (  NotFoundException e) {
    numberOfDocumentationFiles=0L;
  }
  Long numberOfSchemaFiles;
  try {
    Directory schemasDirectory=model.getSchemasDirectory(aip.getId());
    numberOfSchemaFiles=storage.countResourcesUnderDirectory(schemasDirectory.getStoragePath(),true);
  }
 catch (  NotFoundException e) {
    numberOfSchemaFiles=0L;
  }
  doc.addField(RodaConstants.AIP_NUMBER_OF_SUBMISSION_FILES,numberOfSubmissionFiles);
  doc.addField(RodaConstants.AIP_NUMBER_OF_DOCUMENTATION_FILES,numberOfDocumentationFiles);
  doc.addField(RodaConstants.AIP_NUMBER_OF_SCHEMA_FILES,numberOfSchemaFiles);
  return doc;
}