Program: 189331
Project: 189331
Buggy source:
/** 
 * Write a the provided submission and all associated action logs to the index writer. This method expects that the submission and action logs have been removed from the index, either through a specific delete, or a delete all in the case of rebuilding the index. This method is used to share code between the various index job implementations so that submissions are written the same no matter who indexes them first.
 * @param writer The index writer.
 * @param sub The submission to index.
 */
public void indexSubmission(IndexWriter writer,Submission sub) throws CorruptIndexException, IOException {
  StringBuilder searchText=new StringBuilder();
  long subId=sub.getId();
  String state=sub.getState().getDisplayName();
  searchText.append(state).append("String_Node_Str");
  long searchAssigned=0;
  String sortAssigned="String_Node_Str";
  if (sub.getAssignee() != null) {
    searchAssigned=sub.getAssignee().getId();
    sortAssigned=sub.getAssignee().getFormattedName(NameFormat.LAST_FIRST_MIDDLE_BIRTH);
    searchText.append(sortAssigned).append("String_Node_Str");
  }
  Date graduationSemester=null;
  if (sub.getGraduationYear() != null) {
    Calendar cal=Calendar.getInstance();
    cal.clear();
    cal.set(Calendar.YEAR,sub.getGraduationYear());
    if (sub.getGraduationMonth() != null)     cal.set(Calendar.MONTH,sub.getGraduationMonth());
    graduationSemester=cal.getTime();
  }
  Date defenseDate=sub.getDefenseDate();
  String department=sub.getDepartment();
  String program=sub.getProgram();
  String college=sub.getCollege();
  String major=sub.getMajor();
  searchText.append(department).append("String_Node_Str").append(program).append("String_Node_Str").append(college).append("String_Node_Str").append(major).append("String_Node_Str");
  String embargos="String_Node_Str";
  if (sub.getEmbargoTypes().size() > 0) {
    for (    EmbargoType embargo : sub.getEmbargoTypes())     embargos+=embargo.getName() + "String_Node_Str";
  }
  searchText.append(embargos).append("String_Node_Str");
  String degree=sub.getDegree();
  String documentType=sub.getDocumentType();
  searchText.append(degree).append("String_Node_Str").append(documentType).append("String_Node_Str");
  Date submissionDate=sub.getSubmissionDate();
  String studentName="String_Node_Str";
  if (sub.getStudentLastName() != null)   studentName+=sub.getStudentLastName() + "String_Node_Str";
  if (sub.getStudentFirstName() != null)   studentName+=sub.getStudentFirstName() + "String_Node_Str";
  if (sub.getStudentMiddleName() != null)   studentName+=sub.getStudentMiddleName() + "String_Node_Str";
  searchText.append(studentName).append("String_Node_Str");
  searchText.append(sub.getStudentFormattedName(NameFormat.LAST_FIRST_BIRTH)).append("String_Node_Str");
  searchText.append(sub.getStudentFormattedName(NameFormat.FIRST_LAST_BIRTH)).append("String_Node_Str");
  String studentEmail=sub.getSubmitter().getEmail();
  searchText.append(studentEmail).append("String_Node_Str");
  String institutionalIdentifier=sub.getSubmitter().getInstitutionalIdentifier();
  searchText.append(institutionalIdentifier).append("String_Node_Str");
  String documentTitle=sub.getDocumentTitle();
  String documentAbstract=sub.getDocumentAbstract();
  String documentKeywords=sub.getDocumentKeywords();
  searchText.append(documentTitle).append("String_Node_Str").append(documentAbstract).append("String_Node_Str").append(documentKeywords).append("String_Node_Str");
  String documentSubjects="String_Node_Str";
  for (  String subject : sub.getDocumentSubjects()) {
    documentSubjects+=subject + "String_Node_Str";
  }
  searchText.append(documentSubjects).append("String_Node_Str");
  String documentLanguage=null;
  if (sub.getDocumentLanguageLocale() != null) {
    Locale locale=sub.getDocumentLanguageLocale();
    searchText.append(locale.getDisplayName()).append("String_Node_Str");
    searchText.append(locale.getDisplayLanguage()).append("String_Node_Str");
    searchText.append(locale.getDisplayCountry()).append("String_Node_Str");
    searchText.append(locale.getDisplayVariant()).append("String_Node_Str");
    documentLanguage=locale.getDisplayName();
  }
  String publishedMaterial=sub.getPublishedMaterial();
  searchText.append(publishedMaterial).append("String_Node_Str");
  String primaryDocument=null;
  if (sub.getPrimaryDocument() != null) {
    primaryDocument=sub.getPrimaryDocument().getName();
    searchText.append(primaryDocument).append("String_Node_Str");
  }
  Date licenseAgreementDate=sub.getLicenseAgreementDate();
  Date approvalDate=sub.getApprovalDate();
  Date committeeApprovalDate=sub.getCommitteeApprovalDate();
  Date committeeEmbargoApprovalDate=sub.getCommitteeEmbargoApprovalDate();
  String committeeMembers="String_Node_Str";
  for (  CommitteeMember member : sub.getCommitteeMembers()) {
    committeeMembers+=member.getFormattedName(NameFormat.LAST_FIRST) + "String_Node_Str" + member.getFormattedRoles();
  }
  searchText.append(committeeMembers).append("String_Node_Str");
  String committeeContactEmail=sub.getCommitteeContactEmail();
  searchText.append(committeeContactEmail).append("String_Node_Str");
  String umiRelease;
  if (sub.getUMIRelease() == null) {
    umiRelease="String_Node_Str";
  }
 else   if (sub.getUMIRelease()) {
    umiRelease="String_Node_Str";
  }
 else {
    umiRelease="String_Node_Str";
  }
  String customActions="String_Node_Str";
  for (  CustomActionValue customActionValue : sub.getCustomActions()) {
    customActions+=customActionValue.getDefinition().getLabel() + "String_Node_Str";
  }
  searchText.append(customActions).append("String_Node_Str");
  String degreeLevel=null;
  if (sub.getDegreeLevel() != null)   degreeLevel=sub.getDegreeLevel().name();
  searchText.append(degreeLevel).append("String_Node_Str");
  String depositId=sub.getDepositId();
  searchText.append(depositId).append("String_Node_Str");
  String reviewerNotes=sub.getReviewerNotes();
  searchText.append(reviewerNotes).append("String_Node_Str");
  String lastEventEntry=null;
  Date lastEventTime=null;
  String orcid=sub.getOrcid();
  List<ActionLog> logs=indexer.subRepo.findActionLog(sub);
  if (logs.size() > 0) {
    lastEventEntry=logs.get(0).getEntry();
    lastEventTime=logs.get(0).getActionDate();
    searchText.append(lastEventEntry);
  }
  Document doc=new Document();
  doc.add(new NumericField("String_Node_Str",Field.Store.YES,true).setLongValue(subId));
  doc.add(new Field("String_Node_Str","String_Node_Str",Field.Store.YES,Index.NOT_ANALYZED));
  doc.add(new Field("String_Node_Str",searchText.toString(),Field.Store.NO,Index.ANALYZED_NO_NORMS));
  if (state != null)   doc.add(new Field("String_Node_Str",state,Field.Store.NO,Index.NOT_ANALYZED));
  doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(searchAssigned));
  if (sortAssigned != null)   doc.add(new Field("String_Node_Str",sortAssigned,Field.Store.NO,Index.NOT_ANALYZED));
  if (graduationSemester != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(graduationSemester.getTime()));
  if (defenseDate != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(defenseDate.getTime()));
  if (department != null)   doc.add(new Field("String_Node_Str",department,Field.Store.NO,Index.NOT_ANALYZED));
  if (program != null)   doc.add(new Field("String_Node_Str",program,Field.Store.NO,Index.NOT_ANALYZED));
  if (college != null)   doc.add(new Field("String_Node_Str",college,Field.Store.NO,Index.NOT_ANALYZED));
  if (major != null)   doc.add(new Field("String_Node_Str",major,Field.Store.NO,Index.NOT_ANALYZED));
  if (embargos != null) {
    for (    EmbargoType embargo : sub.getEmbargoTypes()) {
      doc.add(new Field("String_Node_Str",embargo.getName(),Field.Store.NO,Index.NOT_ANALYZED));
    }
  }
  if (degree != null)   doc.add(new Field("String_Node_Str",degree,Field.Store.NO,Index.NOT_ANALYZED));
  if (documentType != null)   doc.add(new Field("String_Node_Str",documentType,Field.Store.NO,Index.NOT_ANALYZED));
  if (submissionDate != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(submissionDate.getTime()));
  if (studentName != null)   doc.add(new Field("String_Node_Str",studentName,Field.Store.NO,Index.NOT_ANALYZED));
  if (studentEmail != null)   doc.add(new Field("String_Node_Str",studentEmail,Field.Store.NO,Index.NOT_ANALYZED));
  if (institutionalIdentifier != null)   doc.add(new Field("String_Node_Str",institutionalIdentifier,Field.Store.NO,Index.NOT_ANALYZED));
  if (documentTitle != null)   doc.add(new Field("String_Node_Str",documentTitle,Field.Store.NO,Index.NOT_ANALYZED));
  if (documentAbstract != null)   doc.add(new Field("String_Node_Str",documentAbstract,Field.Store.NO,Index.NOT_ANALYZED));
  if (documentKeywords != null)   doc.add(new Field("String_Node_Str",documentKeywords,Field.Store.NO,Index.NOT_ANALYZED));
  if (documentSubjects != null)   doc.add(new Field("String_Node_Str",documentSubjects,Field.Store.NO,Index.NOT_ANALYZED));
  if (documentLanguage != null)   doc.add(new Field("String_Node_Str",documentLanguage,Field.Store.NO,Index.NOT_ANALYZED));
  if (publishedMaterial != null)   doc.add(new Field("String_Node_Str",publishedMaterial,Field.Store.NO,Index.NOT_ANALYZED));
  if (primaryDocument != null)   doc.add(new Field("String_Node_Str",primaryDocument,Field.Store.NO,Index.NOT_ANALYZED));
  if (licenseAgreementDate != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(licenseAgreementDate.getTime()));
  if (approvalDate != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(approvalDate.getTime()));
  if (committeeApprovalDate != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(committeeApprovalDate.getTime()));
  if (committeeEmbargoApprovalDate != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(committeeEmbargoApprovalDate.getTime()));
  if (committeeMembers != null)   doc.add(new Field("String_Node_Str",committeeMembers,Field.Store.NO,Index.NOT_ANALYZED));
  if (committeeContactEmail != null)   doc.add(new Field("String_Node_Str",committeeContactEmail,Field.Store.NO,Index.NOT_ANALYZED));
  if (umiRelease != null)   doc.add(new Field("String_Node_Str",umiRelease,Field.Store.NO,Index.NOT_ANALYZED));
  for (  CustomActionValue customActionValue : sub.getCustomActions()) {
    doc.add(new Field("String_Node_Str",customActionValue.getDefinition().getLabel(),Field.Store.NO,Index.NOT_ANALYZED));
  }
  if (degreeLevel != null)   doc.add(new Field("String_Node_Str",degreeLevel,Field.Store.NO,Index.NOT_ANALYZED));
  if (depositId != null)   doc.add(new Field("String_Node_Str",depositId,Field.Store.NO,Index.NOT_ANALYZED));
  if (reviewerNotes != null)   doc.add(new Field("String_Node_Str",reviewerNotes,Field.Store.NO,Index.NOT_ANALYZED));
  if (lastEventEntry != null)   doc.add(new Field("String_Node_Str",lastEventEntry,Field.Store.NO,Index.NOT_ANALYZED));
  if (lastEventTime != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(lastEventTime.getTime()));
  if (orcid != null)   doc.add(new Field("String_Node_Str",orcid,Field.Store.NO,Index.NOT_ANALYZED));
  writer.addDocument(doc);
  for (  ActionLog log : logs) {
    Long logId=log.getId();
    String logEntry=log.getEntry();
    String logState=log.getSubmissionState().getDisplayName();
    long logSearchAssigned=0;
    String logSortAssigned=null;
    if (log.getPerson() != null) {
      logSearchAssigned=log.getPerson().getId();
      logSortAssigned=log.getPerson().getFormattedName(NameFormat.FIRST_LAST);
    }
    Date logTime=log.getActionDate();
    doc=new Document();
    doc.add(new NumericField("String_Node_Str",Field.Store.YES,true).setLongValue(subId));
    doc.add(new NumericField("String_Node_Str",Field.Store.YES,true).setLongValue(logId));
    doc.add(new Field("String_Node_Str","String_Node_Str",Field.Store.YES,Index.NOT_ANALYZED));
    if (logEntry != null)     doc.add(new Field("String_Node_Str",logEntry,Field.Store.NO,Index.ANALYZED_NO_NORMS));
    if (logState != null)     doc.add(new Field("String_Node_Str",logState,Field.Store.NO,Index.NOT_ANALYZED));
    doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(logSearchAssigned));
    if (logSortAssigned != null)     doc.add(new Field("String_Node_Str",logSortAssigned,Field.Store.NO,Index.NOT_ANALYZED));
    if (logEntry != null)     doc.add(new Field("String_Node_Str",logEntry,Field.Store.NO,Index.NOT_ANALYZED));
    if (logTime != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(logTime.getTime()));
    if (graduationSemester != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(graduationSemester.getTime()));
    if (defenseDate != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(defenseDate.getTime()));
    if (department != null)     doc.add(new Field("String_Node_Str",department,Field.Store.NO,Index.NOT_ANALYZED));
    if (program != null)     doc.add(new Field("String_Node_Str",program,Field.Store.NO,Index.NOT_ANALYZED));
    if (college != null)     doc.add(new Field("String_Node_Str",college,Field.Store.NO,Index.NOT_ANALYZED));
    if (major != null)     doc.add(new Field("String_Node_Str",major,Field.Store.NO,Index.NOT_ANALYZED));
    if (embargos != null) {
      for (      EmbargoType embargo : sub.getEmbargoTypes()) {
        doc.add(new Field("String_Node_Str",embargo.getName(),Field.Store.NO,Index.NOT_ANALYZED));
      }
    }
    if (degree != null)     doc.add(new Field("String_Node_Str",degree,Field.Store.NO,Index.NOT_ANALYZED));
    if (documentType != null)     doc.add(new Field("String_Node_Str",documentType,Field.Store.NO,Index.NOT_ANALYZED));
    if (submissionDate != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(submissionDate.getTime()));
    if (studentName != null)     doc.add(new Field("String_Node_Str",studentName,Field.Store.NO,Index.NOT_ANALYZED));
    if (studentEmail != null)     doc.add(new Field("String_Node_Str",studentEmail,Field.Store.NO,Index.NOT_ANALYZED));
    if (institutionalIdentifier != null)     doc.add(new Field("String_Node_Str",institutionalIdentifier,Field.Store.NO,Index.NOT_ANALYZED));
    if (documentAbstract != null)     doc.add(new Field("String_Node_Str",documentAbstract,Field.Store.NO,Index.NOT_ANALYZED));
    if (documentKeywords != null)     doc.add(new Field("String_Node_Str",documentKeywords,Field.Store.NO,Index.NOT_ANALYZED));
    if (documentSubjects != null)     doc.add(new Field("String_Node_Str",documentSubjects,Field.Store.NO,Index.NOT_ANALYZED));
    if (documentLanguage != null)     doc.add(new Field("String_Node_Str",documentLanguage,Field.Store.NO,Index.NOT_ANALYZED));
    if (publishedMaterial != null)     doc.add(new Field("String_Node_Str",publishedMaterial,Field.Store.NO,Index.NOT_ANALYZED));
    if (primaryDocument != null)     doc.add(new Field("String_Node_Str",primaryDocument,Field.Store.NO,Index.NOT_ANALYZED));
    if (licenseAgreementDate != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(licenseAgreementDate.getTime()));
    if (approvalDate != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(approvalDate.getTime()));
    if (committeeApprovalDate != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(committeeApprovalDate.getTime()));
    if (committeeEmbargoApprovalDate != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(committeeEmbargoApprovalDate.getTime()));
    if (committeeMembers != null)     doc.add(new Field("String_Node_Str",committeeMembers,Field.Store.NO,Index.NOT_ANALYZED));
    if (committeeContactEmail != null)     doc.add(new Field("String_Node_Str",committeeContactEmail,Field.Store.NO,Index.NOT_ANALYZED));
    if (umiRelease != null)     doc.add(new Field("String_Node_Str",umiRelease,Field.Store.NO,Index.NOT_ANALYZED));
    for (    CustomActionValue customActionValue : sub.getCustomActions()) {
      doc.add(new Field("String_Node_Str",customActionValue.getDefinition().getLabel(),Field.Store.NO,Index.NOT_ANALYZED));
    }
    if (degreeLevel != null)     doc.add(new Field("String_Node_Str",degreeLevel,Field.Store.NO,Index.NOT_ANALYZED));
    if (depositId != null)     doc.add(new Field("String_Node_Str",depositId,Field.Store.NO,Index.NOT_ANALYZED));
    if (reviewerNotes != null)     doc.add(new Field("String_Node_Str",reviewerNotes,Field.Store.NO,Index.NOT_ANALYZED));
    if (orcid != null)     doc.add(new Field("String_Node_Str",orcid,Field.Store.NO,Index.NOT_ANALYZED));
    writer.addDocument(doc);
    log.detach();
  }
}

Fixed version (ground truth):
/** 
 * Write a the provided submission and all associated action logs to the index writer. This method expects that the submission and action logs have been removed from the index, either through a specific delete, or a delete all in the case of rebuilding the index. This method is used to share code between the various index job implementations so that submissions are written the same no matter who indexes them first.
 * @param writer The index writer.
 * @param sub The submission to index.
 */
public void indexSubmission(IndexWriter writer,Submission sub) throws CorruptIndexException, IOException {
  StringBuilder searchText=new StringBuilder();
  long subId=sub.getId();
  String state=sub.getState().getDisplayName();
  searchText.append(state).append("String_Node_Str");
  long searchAssigned=0;
  String sortAssigned="String_Node_Str";
  if (sub.getAssignee() != null) {
    searchAssigned=sub.getAssignee().getId();
    sortAssigned=sub.getAssignee().getFormattedName(NameFormat.LAST_FIRST_MIDDLE_BIRTH);
    searchText.append(sortAssigned).append("String_Node_Str");
  }
  Date graduationSemester=null;
  if (sub.getGraduationYear() != null) {
    Calendar cal=Calendar.getInstance();
    cal.clear();
    cal.set(Calendar.YEAR,sub.getGraduationYear());
    if (sub.getGraduationMonth() != null)     cal.set(Calendar.MONTH,sub.getGraduationMonth());
    graduationSemester=cal.getTime();
  }
  Date defenseDate=sub.getDefenseDate();
  String department=sub.getDepartment();
  String program=sub.getProgram();
  String college=sub.getCollege();
  String major=sub.getMajor();
  searchText.append(department).append("String_Node_Str").append(program).append("String_Node_Str").append(college).append("String_Node_Str").append(major).append("String_Node_Str");
  String embargos="String_Node_Str";
  if (sub.getEmbargoTypes().size() > 0) {
    for (    EmbargoType embargo : sub.getEmbargoTypes())     embargos+=embargo.getName() + "String_Node_Str";
  }
  searchText.append(embargos).append("String_Node_Str");
  String degree=sub.getDegree();
  String documentType=sub.getDocumentType();
  searchText.append(degree).append("String_Node_Str").append(documentType).append("String_Node_Str");
  Date submissionDate=sub.getSubmissionDate();
  String studentName="String_Node_Str";
  if (sub.getStudentLastName() != null)   studentName+=sub.getStudentLastName() + "String_Node_Str";
  if (sub.getStudentFirstName() != null)   studentName+=sub.getStudentFirstName() + "String_Node_Str";
  if (sub.getStudentMiddleName() != null)   studentName+=sub.getStudentMiddleName() + "String_Node_Str";
  searchText.append(studentName).append("String_Node_Str");
  searchText.append(sub.getStudentFormattedName(NameFormat.LAST_FIRST_BIRTH)).append("String_Node_Str");
  searchText.append(sub.getStudentFormattedName(NameFormat.FIRST_LAST_BIRTH)).append("String_Node_Str");
  String studentEmail=sub.getSubmitter().getEmail();
  searchText.append(studentEmail).append("String_Node_Str");
  String institutionalIdentifier=sub.getSubmitter().getInstitutionalIdentifier();
  searchText.append(institutionalIdentifier).append("String_Node_Str");
  String documentTitle=sub.getDocumentTitle();
  String documentAbstract=sub.getDocumentAbstract();
  String documentKeywords=sub.getDocumentKeywords();
  searchText.append(documentTitle).append("String_Node_Str").append(documentAbstract).append("String_Node_Str").append(documentKeywords).append("String_Node_Str");
  String documentSubjects="String_Node_Str";
  for (  String subject : sub.getDocumentSubjects()) {
    documentSubjects+=subject + "String_Node_Str";
  }
  searchText.append(documentSubjects).append("String_Node_Str");
  String documentLanguage=null;
  if (sub.getDocumentLanguageLocale() != null) {
    Locale locale=sub.getDocumentLanguageLocale();
    searchText.append(locale.getDisplayName()).append("String_Node_Str");
    searchText.append(locale.getDisplayLanguage()).append("String_Node_Str");
    searchText.append(locale.getDisplayCountry()).append("String_Node_Str");
    searchText.append(locale.getDisplayVariant()).append("String_Node_Str");
    documentLanguage=locale.getDisplayName();
  }
  String publishedMaterial=sub.getPublishedMaterial();
  searchText.append(publishedMaterial).append("String_Node_Str");
  String primaryDocument=null;
  if (sub.getPrimaryDocument() != null) {
    primaryDocument=sub.getPrimaryDocument().getName();
    searchText.append(primaryDocument).append("String_Node_Str");
  }
  Date licenseAgreementDate=sub.getLicenseAgreementDate();
  Date approvalDate=sub.getApprovalDate();
  Date committeeApprovalDate=sub.getCommitteeApprovalDate();
  Date committeeEmbargoApprovalDate=sub.getCommitteeEmbargoApprovalDate();
  String committeeMembers="String_Node_Str";
  for (  CommitteeMember member : sub.getCommitteeMembers()) {
    committeeMembers+=member.getFormattedName(NameFormat.LAST_FIRST) + "String_Node_Str" + member.getFormattedRoles();
  }
  searchText.append(committeeMembers).append("String_Node_Str");
  String committeeContactEmail=sub.getCommitteeContactEmail();
  searchText.append(committeeContactEmail).append("String_Node_Str");
  String umiRelease;
  if (sub.getUMIRelease() == null) {
    umiRelease="String_Node_Str";
  }
 else   if (sub.getUMIRelease()) {
    umiRelease="String_Node_Str";
  }
 else {
    umiRelease="String_Node_Str";
  }
  String customActions="String_Node_Str";
  for (  CustomActionValue customActionValue : sub.getCustomActions()) {
    customActions+=customActionValue.getDefinition().getLabel() + "String_Node_Str";
  }
  searchText.append(customActions).append("String_Node_Str");
  String degreeLevel=null;
  if (sub.getDegreeLevel() != null)   degreeLevel=sub.getDegreeLevel().name();
  searchText.append(degreeLevel).append("String_Node_Str");
  String depositId=sub.getDepositId();
  searchText.append(depositId).append("String_Node_Str");
  String reviewerNotes=sub.getReviewerNotes();
  searchText.append(reviewerNotes).append("String_Node_Str");
  String lastEventEntry=null;
  Date lastEventTime=null;
  String orcid=sub.getSubmitter().getOrcid();
  List<ActionLog> logs=indexer.subRepo.findActionLog(sub);
  if (logs.size() > 0) {
    lastEventEntry=logs.get(0).getEntry();
    lastEventTime=logs.get(0).getActionDate();
    searchText.append(lastEventEntry);
  }
  Document doc=new Document();
  doc.add(new NumericField("String_Node_Str",Field.Store.YES,true).setLongValue(subId));
  doc.add(new Field("String_Node_Str","String_Node_Str",Field.Store.YES,Index.NOT_ANALYZED));
  doc.add(new Field("String_Node_Str",searchText.toString(),Field.Store.NO,Index.ANALYZED_NO_NORMS));
  if (state != null)   doc.add(new Field("String_Node_Str",state,Field.Store.NO,Index.NOT_ANALYZED));
  doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(searchAssigned));
  if (sortAssigned != null)   doc.add(new Field("String_Node_Str",sortAssigned,Field.Store.NO,Index.NOT_ANALYZED));
  if (graduationSemester != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(graduationSemester.getTime()));
  if (defenseDate != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(defenseDate.getTime()));
  if (department != null)   doc.add(new Field("String_Node_Str",department,Field.Store.NO,Index.NOT_ANALYZED));
  if (program != null)   doc.add(new Field("String_Node_Str",program,Field.Store.NO,Index.NOT_ANALYZED));
  if (college != null)   doc.add(new Field("String_Node_Str",college,Field.Store.NO,Index.NOT_ANALYZED));
  if (major != null)   doc.add(new Field("String_Node_Str",major,Field.Store.NO,Index.NOT_ANALYZED));
  if (embargos != null) {
    for (    EmbargoType embargo : sub.getEmbargoTypes()) {
      doc.add(new Field("String_Node_Str",embargo.getName(),Field.Store.NO,Index.NOT_ANALYZED));
    }
  }
  if (degree != null)   doc.add(new Field("String_Node_Str",degree,Field.Store.NO,Index.NOT_ANALYZED));
  if (documentType != null)   doc.add(new Field("String_Node_Str",documentType,Field.Store.NO,Index.NOT_ANALYZED));
  if (submissionDate != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(submissionDate.getTime()));
  if (studentName != null)   doc.add(new Field("String_Node_Str",studentName,Field.Store.NO,Index.NOT_ANALYZED));
  if (studentEmail != null)   doc.add(new Field("String_Node_Str",studentEmail,Field.Store.NO,Index.NOT_ANALYZED));
  if (institutionalIdentifier != null)   doc.add(new Field("String_Node_Str",institutionalIdentifier,Field.Store.NO,Index.NOT_ANALYZED));
  if (documentTitle != null)   doc.add(new Field("String_Node_Str",documentTitle,Field.Store.NO,Index.NOT_ANALYZED));
  if (documentAbstract != null)   doc.add(new Field("String_Node_Str",documentAbstract,Field.Store.NO,Index.NOT_ANALYZED));
  if (documentKeywords != null)   doc.add(new Field("String_Node_Str",documentKeywords,Field.Store.NO,Index.NOT_ANALYZED));
  if (documentSubjects != null)   doc.add(new Field("String_Node_Str",documentSubjects,Field.Store.NO,Index.NOT_ANALYZED));
  if (documentLanguage != null)   doc.add(new Field("String_Node_Str",documentLanguage,Field.Store.NO,Index.NOT_ANALYZED));
  if (publishedMaterial != null)   doc.add(new Field("String_Node_Str",publishedMaterial,Field.Store.NO,Index.NOT_ANALYZED));
  if (primaryDocument != null)   doc.add(new Field("String_Node_Str",primaryDocument,Field.Store.NO,Index.NOT_ANALYZED));
  if (licenseAgreementDate != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(licenseAgreementDate.getTime()));
  if (approvalDate != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(approvalDate.getTime()));
  if (committeeApprovalDate != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(committeeApprovalDate.getTime()));
  if (committeeEmbargoApprovalDate != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(committeeEmbargoApprovalDate.getTime()));
  if (committeeMembers != null)   doc.add(new Field("String_Node_Str",committeeMembers,Field.Store.NO,Index.NOT_ANALYZED));
  if (committeeContactEmail != null)   doc.add(new Field("String_Node_Str",committeeContactEmail,Field.Store.NO,Index.NOT_ANALYZED));
  if (umiRelease != null)   doc.add(new Field("String_Node_Str",umiRelease,Field.Store.NO,Index.NOT_ANALYZED));
  for (  CustomActionValue customActionValue : sub.getCustomActions()) {
    doc.add(new Field("String_Node_Str",customActionValue.getDefinition().getLabel(),Field.Store.NO,Index.NOT_ANALYZED));
  }
  if (degreeLevel != null)   doc.add(new Field("String_Node_Str",degreeLevel,Field.Store.NO,Index.NOT_ANALYZED));
  if (depositId != null)   doc.add(new Field("String_Node_Str",depositId,Field.Store.NO,Index.NOT_ANALYZED));
  if (reviewerNotes != null)   doc.add(new Field("String_Node_Str",reviewerNotes,Field.Store.NO,Index.NOT_ANALYZED));
  if (lastEventEntry != null)   doc.add(new Field("String_Node_Str",lastEventEntry,Field.Store.NO,Index.NOT_ANALYZED));
  if (lastEventTime != null)   doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(lastEventTime.getTime()));
  if (orcid != null)   doc.add(new Field("String_Node_Str",orcid,Field.Store.NO,Index.NOT_ANALYZED));
  writer.addDocument(doc);
  for (  ActionLog log : logs) {
    Long logId=log.getId();
    String logEntry=log.getEntry();
    String logState=log.getSubmissionState().getDisplayName();
    long logSearchAssigned=0;
    String logSortAssigned=null;
    if (log.getPerson() != null) {
      logSearchAssigned=log.getPerson().getId();
      logSortAssigned=log.getPerson().getFormattedName(NameFormat.FIRST_LAST);
    }
    Date logTime=log.getActionDate();
    doc=new Document();
    doc.add(new NumericField("String_Node_Str",Field.Store.YES,true).setLongValue(subId));
    doc.add(new NumericField("String_Node_Str",Field.Store.YES,true).setLongValue(logId));
    doc.add(new Field("String_Node_Str","String_Node_Str",Field.Store.YES,Index.NOT_ANALYZED));
    if (logEntry != null)     doc.add(new Field("String_Node_Str",logEntry,Field.Store.NO,Index.ANALYZED_NO_NORMS));
    if (logState != null)     doc.add(new Field("String_Node_Str",logState,Field.Store.NO,Index.NOT_ANALYZED));
    doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(logSearchAssigned));
    if (logSortAssigned != null)     doc.add(new Field("String_Node_Str",logSortAssigned,Field.Store.NO,Index.NOT_ANALYZED));
    if (logEntry != null)     doc.add(new Field("String_Node_Str",logEntry,Field.Store.NO,Index.NOT_ANALYZED));
    if (logTime != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(logTime.getTime()));
    if (graduationSemester != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(graduationSemester.getTime()));
    if (defenseDate != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(defenseDate.getTime()));
    if (department != null)     doc.add(new Field("String_Node_Str",department,Field.Store.NO,Index.NOT_ANALYZED));
    if (program != null)     doc.add(new Field("String_Node_Str",program,Field.Store.NO,Index.NOT_ANALYZED));
    if (college != null)     doc.add(new Field("String_Node_Str",college,Field.Store.NO,Index.NOT_ANALYZED));
    if (major != null)     doc.add(new Field("String_Node_Str",major,Field.Store.NO,Index.NOT_ANALYZED));
    if (embargos != null) {
      for (      EmbargoType embargo : sub.getEmbargoTypes()) {
        doc.add(new Field("String_Node_Str",embargo.getName(),Field.Store.NO,Index.NOT_ANALYZED));
      }
    }
    if (degree != null)     doc.add(new Field("String_Node_Str",degree,Field.Store.NO,Index.NOT_ANALYZED));
    if (documentType != null)     doc.add(new Field("String_Node_Str",documentType,Field.Store.NO,Index.NOT_ANALYZED));
    if (submissionDate != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(submissionDate.getTime()));
    if (studentName != null)     doc.add(new Field("String_Node_Str",studentName,Field.Store.NO,Index.NOT_ANALYZED));
    if (studentEmail != null)     doc.add(new Field("String_Node_Str",studentEmail,Field.Store.NO,Index.NOT_ANALYZED));
    if (institutionalIdentifier != null)     doc.add(new Field("String_Node_Str",institutionalIdentifier,Field.Store.NO,Index.NOT_ANALYZED));
    if (documentAbstract != null)     doc.add(new Field("String_Node_Str",documentAbstract,Field.Store.NO,Index.NOT_ANALYZED));
    if (documentKeywords != null)     doc.add(new Field("String_Node_Str",documentKeywords,Field.Store.NO,Index.NOT_ANALYZED));
    if (documentSubjects != null)     doc.add(new Field("String_Node_Str",documentSubjects,Field.Store.NO,Index.NOT_ANALYZED));
    if (documentLanguage != null)     doc.add(new Field("String_Node_Str",documentLanguage,Field.Store.NO,Index.NOT_ANALYZED));
    if (publishedMaterial != null)     doc.add(new Field("String_Node_Str",publishedMaterial,Field.Store.NO,Index.NOT_ANALYZED));
    if (primaryDocument != null)     doc.add(new Field("String_Node_Str",primaryDocument,Field.Store.NO,Index.NOT_ANALYZED));
    if (licenseAgreementDate != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(licenseAgreementDate.getTime()));
    if (approvalDate != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(approvalDate.getTime()));
    if (committeeApprovalDate != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(committeeApprovalDate.getTime()));
    if (committeeEmbargoApprovalDate != null)     doc.add(new NumericField("String_Node_Str",Field.Store.NO,true).setLongValue(committeeEmbargoApprovalDate.getTime()));
    if (committeeMembers != null)     doc.add(new Field("String_Node_Str",committeeMembers,Field.Store.NO,Index.NOT_ANALYZED));
    if (committeeContactEmail != null)     doc.add(new Field("String_Node_Str",committeeContactEmail,Field.Store.NO,Index.NOT_ANALYZED));
    if (umiRelease != null)     doc.add(new Field("String_Node_Str",umiRelease,Field.Store.NO,Index.NOT_ANALYZED));
    for (    CustomActionValue customActionValue : sub.getCustomActions()) {
      doc.add(new Field("String_Node_Str",customActionValue.getDefinition().getLabel(),Field.Store.NO,Index.NOT_ANALYZED));
    }
    if (degreeLevel != null)     doc.add(new Field("String_Node_Str",degreeLevel,Field.Store.NO,Index.NOT_ANALYZED));
    if (depositId != null)     doc.add(new Field("String_Node_Str",depositId,Field.Store.NO,Index.NOT_ANALYZED));
    if (reviewerNotes != null)     doc.add(new Field("String_Node_Str",reviewerNotes,Field.Store.NO,Index.NOT_ANALYZED));
    if (orcid != null)     doc.add(new Field("String_Node_Str",orcid,Field.Store.NO,Index.NOT_ANALYZED));
    writer.addDocument(doc);
    log.detach();
  }
}