Class RequestPartitionHeaderUtil

java.lang.Object
ca.uhn.fhir.rest.server.messaging.RequestPartitionHeaderUtil

public final class RequestPartitionHeaderUtil extends Object
Utility class for parsing and validating partition information from HTTP request headers.

This class provides methods to convert the X-Request-Partition-IDs header value into a RequestPartitionId object that can be used by the application to determine which partition(s) to operate on.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static ca.uhn.fhir.interceptor.model.RequestPartitionId
    fromHeader(String thePartitionHeaderValue, ca.uhn.fhir.interceptor.model.IDefaultPartitionSettings theDefaultPartitionSettings)
     
    static ca.uhn.fhir.interceptor.model.RequestPartitionId
    fromHeader(String theSourceName, String thePartitionHeaderValue, ca.uhn.fhir.interceptor.model.IDefaultPartitionSettings theDefaultPartitionSettings)
    Parses the X-Request-Partition-IDs header value and converts it to a RequestPartitionId object.
    static ca.uhn.fhir.interceptor.model.RequestPartitionId
    fromHeaderFirstPartitionOnly(String thePartitionHeaderValue, ca.uhn.fhir.interceptor.model.IDefaultPartitionSettings theDefaultPartitionSettings)
     
    static ca.uhn.fhir.interceptor.model.RequestPartitionId
    fromHeaderFirstPartitionOnly(String theSourceName, String thePartitionHeaderValue, ca.uhn.fhir.interceptor.model.IDefaultPartitionSettings theDefaultPartitionSettings)
    Parses the X-Request-Partition-IDs header value and converts it to a RequestPartitionId object, including only the first partition ID from the header.
    static <T> void
    setRequestPartitionIdFromHeaderIfNotAlreadySet(IMessage<T> theMessage, ca.uhn.fhir.interceptor.model.IDefaultPartitionSettings theDefaultPartitionSettings)
    Sets the partition ID on a message payload from the X-Request-Partition-IDs header if it's not already set.
    static void
    validateHeader(String thePartitionHeaderValue)
     
    static void
    validateHeader(String theSourceName, String thePartitionHeaderValue)
    Validates the syntax of the X-Request-Partition-IDs header value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • fromHeader

      @Nullable public static ca.uhn.fhir.interceptor.model.RequestPartitionId fromHeader(@Nonnull String theSourceName, @Nullable String thePartitionHeaderValue, @Nullable ca.uhn.fhir.interceptor.model.IDefaultPartitionSettings theDefaultPartitionSettings)
      Parses the X-Request-Partition-IDs header value and converts it to a RequestPartitionId object.
      Parameters:
      theSourceName - The name of the source of the value, used for error messages
      thePartitionHeaderValue - The value of the X-Request-Partition-IDs header, may be null
      theDefaultPartitionSettings - Settings that provide the default partition ID
      Returns:
      A RequestPartitionId object representing the partition(s) specified in the header, or null if the header is null
      Throws:
      ca.uhn.fhir.rest.server.exceptions.InvalidRequestException - If the header value is invalid
    • fromHeader

      @Nullable public static ca.uhn.fhir.interceptor.model.RequestPartitionId fromHeader(@Nullable String thePartitionHeaderValue, @Nullable ca.uhn.fhir.interceptor.model.IDefaultPartitionSettings theDefaultPartitionSettings)
    • fromHeaderFirstPartitionOnly

      @Nullable public static ca.uhn.fhir.interceptor.model.RequestPartitionId fromHeaderFirstPartitionOnly(@Nonnull String theSourceName, @Nullable String thePartitionHeaderValue, @Nullable ca.uhn.fhir.interceptor.model.IDefaultPartitionSettings theDefaultPartitionSettings)
      Parses the X-Request-Partition-IDs header value and converts it to a RequestPartitionId object, including only the first partition ID from the header. This useful when using the RequestPartitionId for a write operation.
      Parameters:
      theSourceName - The name of the source of the value, used for error messages
      thePartitionHeaderValue - The value of the X-Request-Partition-IDs header, may be null
      theDefaultPartitionSettings - Settings that provide the default partition ID
      Returns:
      A RequestPartitionId object representing the first partition specified in the header, or null if the header is null
      Throws:
      ca.uhn.fhir.rest.server.exceptions.InvalidRequestException - If the header value is invalid
    • fromHeaderFirstPartitionOnly

      @Nullable public static ca.uhn.fhir.interceptor.model.RequestPartitionId fromHeaderFirstPartitionOnly(@Nullable String thePartitionHeaderValue, @Nullable ca.uhn.fhir.interceptor.model.IDefaultPartitionSettings theDefaultPartitionSettings)
    • validateHeader

      public static void validateHeader(String theSourceName, String thePartitionHeaderValue)
      Validates the syntax of the X-Request-Partition-IDs header value.

      This method checks if the header value can be successfully parsed into a RequestPartitionId object. It does not validate whether the partition IDs actually exist in the system.

      Parameters:
      theSourceName - The name of the source of the value, used for error messages
      thePartitionHeaderValue - The value of the X-Request-Partition-IDs header to validate
      Throws:
      ca.uhn.fhir.rest.server.exceptions.InvalidRequestException - If the header value is invalid
    • validateHeader

      public static void validateHeader(String thePartitionHeaderValue)
    • setRequestPartitionIdFromHeaderIfNotAlreadySet

      public static <T> void setRequestPartitionIdFromHeaderIfNotAlreadySet(@Nonnull IMessage<T> theMessage, @Nullable ca.uhn.fhir.interceptor.model.IDefaultPartitionSettings theDefaultPartitionSettings)
      Sets the partition ID on a message payload from the X-Request-Partition-IDs header if it's not already set.
      Type Parameters:
      T - The type of the payload, which must have methods for getting and setting a partition ID
      Parameters:
      theMessage - The message containing the payload and headers
      theDefaultPartitionSettings - Settings that provide the default partition ID