Class CommitterUtil

java.lang.Object
com.norconex.committer.core.CommitterUtil

public final class CommitterUtil extends Object

Committer-related utility methods.

  • Method Details

    • getContentAsString

      public static String getContentAsString(CommitterRequest req) throws CommitterException
      Gets the request content as a string. Only applicable to UpsertRequest instances.
      Parameters:
      req - committer request
      Returns:
      content as string, or null
      Throws:
      CommitterException - could not get content as string
    • extractSourceIdValue

      public static String extractSourceIdValue(CommitterRequest req, String sourceIdField)
      Extracts the source ID value. If the supplied source ID value argument is not blank, the value is obtained from the corresponding metadata field and that field is deleted. Otherwise the document reference is returned.
      Parameters:
      req - committer request
      sourceIdField - name of the metadata field holding the ID value or blank.
      Returns:
      the source id value
    • extractSourceIdValue

      public static String extractSourceIdValue(CommitterRequest req, String sourceIdField, boolean keepSourceIdField)
      Extracts the source ID value. If the supplied source ID value argument is not blank, the value is obtained from the corresponding metadata field. Otherwise the document reference is returned.
      Parameters:
      req - committer request
      sourceIdField - name of the metadata field holding the ID value or blank.
      keepSourceIdField - whether to keep the source ID field
      Returns:
      the source id value
    • applyTargetContent

      public static void applyTargetContent(CommitterRequest req, String targetContentField) throws CommitterException
      Applies the document content (input stream) to the target field name. If the targetContentField argument is null or blank, the document content is ignored (not set). Only applicable to UpsertRequest instances.
      Parameters:
      req - committer request
      targetContentField - name of the target field holding the document content.
      Throws:
      CommitterException - could not apply target content
    • applyTargetId

      public static void applyTargetId(CommitterRequest req, String sourceIdField, String targetIdField)
      Applies the source ID field value after extracting it using extractSourceIdValue(CommitterRequest, String), to the target ID ID field supplied. If targetIdField or source ID value, is null or blank, the document ID is ignored (not set).
      Parameters:
      req - committer request
      sourceIdField - name of the source field holding the document ID
      targetIdField - name of the target field holding the document ID