
Class RequestPartitionHeaderUtil
java.lang.Object
ca.uhn.fhir.rest.server.messaging.RequestPartitionHeaderUtil
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 aRequestPartitionId
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 aRequestPartitionId
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.
-
Field Details
-
HTTP_HEADER_SOURCE_NAME
- See Also:
-
-
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 aRequestPartitionId
object.- Parameters:
theSourceName
- The name of the source of the value, used for error messagesthePartitionHeaderValue
- The value of the X-Request-Partition-IDs header, may be nulltheDefaultPartitionSettings
- 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 aRequestPartitionId
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 messagesthePartitionHeaderValue
- The value of the X-Request-Partition-IDs header, may be nulltheDefaultPartitionSettings
- 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
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 messagesthePartitionHeaderValue
- 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
-
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 headerstheDefaultPartitionSettings
- Settings that provide the default partition ID
-