Class FileMessageResponse

java.lang.Object
com.trafficparrot.sdk.file.FileMessageResponse
All Implemented Interfaces:
Comparable<FileMessageResponse>

public class FileMessageResponse extends Object implements Comparable<FileMessageResponse>
  • Field Details

    • NO_TRANSFORMER

      public static final String NO_TRANSFORMER
      See Also:
    • destination

      public final Destination destination
    • fileMessageResponseTransformerClassName

      public final String fileMessageResponseTransformerClassName
    • fileName

      public final String fileName
      The name of the response file WRITTEN to the response directory - a transport output name, Handlebars-templated like text. Not to be confused with bodyFileName, which names a __files sidecar the body is READ from.
    • text

      public final String text
    • bodyFileName

      public final String bodyFileName
      A __files/<name> sidecar holding the response body, used instead of an inline text. Mutually exclusive with it - see validate().
    • bodyType

      public final MessageBodyType bodyType
    • resolvedText

      public final transient String resolvedText
      Content resolved from bodyFileName at load time. Held here rather than in text so the persisted model keeps bodyFileName set and text null (non-destructive). transient so the filesystem mapper never writes it to disk; set only via withResolvedText(String) and read via effectiveText(). The web-UI mapper re-includes it (via a mix-in) so the editor can display the content.
  • Constructor Details

  • Method Details

    • withResolvedText

      public FileMessageResponse withResolvedText(String resolvedText)
      Returns a copy with resolvedText set (the content read from bodyFileName at load time). Every persisted field is preserved so a subsequent save re-writes bodyFileName with null text, keeping the sidecar reference intact.
    • withResolvedBodyFile

      public FileMessageResponse withResolvedBodyFile(Path bodyFile, long bytes)
      Returns a copy whose body is the bodyFileName sidecar bodyFile, of bytes bytes, held by reference because it is too large to read into memory: createResponseMessage() copies it, and effectiveText() is null. Every persisted field is preserved, as by withResolvedText(String).
    • resolvedBodyFile

      public Optional<Path> resolvedBodyFile()
      The body file a reply is copied from, for a body too large to read into memory; empty otherwise. Read it, do not modify it: it is the mapping's __files sidecar.
    • resolvedBodyFileBytes

      public Long resolvedBodyFileBytes()
      The size of resolvedBodyFile() in bytes, or null when the body is not held by reference.
    • effectiveText

      public String effectiveText()
      The response body content to write: the file-resolved resolvedText when set, otherwise the inline text.
    • validate

      public void validate() throws IOException
      Throws:
      IOException
    • toString

      public String toString()
      A BYTES body is given by its length: it can be megabytes of base64, and every response sent is logged. A long inline text is given by its start and length.
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(FileMessageResponse other)
      Specified by:
      compareTo in interface Comparable<FileMessageResponse>
    • createResponseMessage

      public FileMessage createResponseMessage()
      A body file held by reference is copied as it is. A BYTES body is base64 (inline, or resolved from a __files sidecar), written as the exact bytes it encodes; any other body is written as its text.
    • hasTransformer

      public boolean hasTransformer()