Record Class FOCommHelper.FOResult

java.lang.Object
java.lang.Record
org.ametys.web.cache.FOCommHelper.FOResult
Record Components:
uri - the requested URI (FO URI + path)
code - the HTTP response code, -1 if the request failed.
reason - the HTTP response reason phrase, can be null.
body - the HTTP response body, can be null.
exception - the exception that occurred in case of failure to communicate with the remote server, null in case of success
Enclosing class:
FOCommHelper

public static record FOCommHelper.FOResult(URI uri, int code, String reason, byte[] body, Throwable exception) extends Record
Result of a request to a front-office
  • Constructor Details

    • FOResult

      public FOResult(URI uri, int code, String reason, byte[] body, Throwable exception)
      Creates an instance of a FOResult record class.
      Parameters:
      uri - the value for the uri record component
      code - the value for the code record component
      reason - the value for the reason record component
      body - the value for the body record component
      exception - the value for the exception record component
  • Method Details

    • of

      protected static FOCommHelper.FOResult of(org.apache.hc.core5.http.ClassicHttpRequest request, org.apache.hc.core5.http.ClassicHttpResponse response) throws org.apache.hc.core5.http.HttpException, IOException
      Build a FOCommHelper.FOResult from a request and response object
      Parameters:
      request - the HTTP request object
      response - the HTTP response object
      Returns:
      an FOCommHelper.FOResult describing the request and response
      Throws:
      org.apache.hc.core5.http.HttpException - if an error occurs while handling the response
      IOException - if an error occurs while reading the response
    • of

      public static FOCommHelper.FOResult of(org.apache.hc.core5.http.ClassicHttpRequest request, Throwable e) throws org.apache.hc.core5.http.HttpException
      Build a FOCommHelper.FOResult representing a failed request a request
      Parameters:
      request - the HTTP request object
      e - the exception that occurred
      Returns:
      an FOCommHelper.FOResult describing the request and failed response
      Throws:
      org.apache.hc.core5.http.HttpException - if an error occurs while handling the response
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • uri

      public URI uri()
      Returns the value of the uri record component.
      Returns:
      the value of the uri record component
    • code

      public int code()
      Returns the value of the code record component.
      Returns:
      the value of the code record component
    • reason

      public String reason()
      Returns the value of the reason record component.
      Returns:
      the value of the reason record component
    • body

      public byte[] body()
      Returns the value of the body record component.
      Returns:
      the value of the body record component
    • exception

      public Throwable exception()
      Returns the value of the exception record component.
      Returns:
      the value of the exception record component