Loading…
Loading…
Configure how xsd:duration values are formatted in SOAP responses on a per-operation and per-field basis. Set override modes and field-specific XPath
The Duration Handling Apply Service provides a mechanism for API publishers to configure the formatting of xsd:duration data types in SOAP responses on a per-operation basis. This allows for fine-grained control, overriding the system-wide default formatting to meet the specific requirements of different API consumers.
This service is an administrative function. It is called to apply configuration for a specific API operation. The configuration consists of two parts:
soapXPath in the response message.The applied configuration is persisted to the s2r_operation_mapping database table. During request processing, the runtime reads this configuration and applies it to format xsd:duration values in the SOAP response. The runtime resolves the formatting mode by following a precedence chain: a per-field override is used if present; otherwise, the per-operation override is used; if neither is set, the system default is applied.
Configuration can only be applied to operations belonging to a service version that is in a draft status and not yet active.
The service processes requests to update duration handling configuration through a single apply method. The process involves validation, merging new and existing settings, and persisting the result to the database.
The logical flow for applying configuration is as follows:
flowchart TD
subgraph "Duration Handling Apply Service"
A[Start] --> B{Receive Apply Request};
B --> C{Load Operation Metadata};
C --> D{Is Service Version Mutable?};
D -- No --> E[Fail: S2R-ADM-0410 Mapping Immutable];
D -- Yes --> F{Normalize Operation Override Mode};
F --> G[Validate Operation Override Mode];
G -- Invalid --> H[Fail: S2R-VAL-0498 Invalid Mode];
G -- Valid --> I{Read Existing Field Overrides from DB};
I --> J[Merge with New Field Overrides];
J --> K{Validate Merged Field Overrides};
K -- Invalid --> L[Fail: S2R-VAL-0498 Invalid Field/Mode];
K -- Valid --> M[Serialize Merged Map to JSON];
M --> N{Update Operation Mapping in DB};
N -- 0 Rows Updated --> O[Fail: S2R-ADM-0404 No Active Mapping];
N -- 1 Row Updated --> P[Construct ApplyResult];
P --> Q[Return Success];
end
subgraph "Inputs"
direction LR
In1[operationId]
In2[operationOverride]
In3[fieldOverrides]
end
subgraph "Outputs"
direction LR
Out1[ApplyResult]
Out2[ValidationException]
end
Inputs --> B;
E --> Out2;
H --> Out2;
L --> Out2;
O --> Out2;
Q --> Out1;Validate Mutability: The service first loads metadata for the specified operationId. It verifies that the operation's parent service version is not active and has a status of draft. If the operation is part of an active or non-draft version, it is considered immutable, and the request is rejected.
Normalize and Validate Modes: The top-level operationOverride mode is normalized (trimmed and converted to lowercase). It is then validated against a predefined set of allowed modes.
Merge Field Overrides: The service reads the existing map of field-specific overrides from the database. It then iterates through the fieldOverrides provided in the request, merging them with the existing map:
FieldEntry with a soapXPath and a valid mode will add a new override or update an existing one for that path.FieldEntry with a soapXPath and a null or blank mode will remove the override for that path.soapXPath must be non-blank, and each mode must be valid.Persist Changes: The normalized operationOverride and the final, merged map of field overrides (serialized as a JSONB string) are written to the s2r_operation_mapping table. The update targets the active mapping record for the given operationId.
Return Result: If the database update is successful, the service returns an ApplyResult object containing the final applied configuration, including the operation key and the merged map of field overrides.
IMPORTANT
Configuration for an operation can only be modified when its parent service version is in a draft state and is not active. Attempts to modify an operation in any other state will fail.
The component exposes its functionality through the DurationHandlingApplyService class.
Applies duration handling overrides for a specific operation. This method is transactional.
apply(UUID operationId, String operationOverride, List<FieldEntry> fieldOverrides)
| Name | Type | Required | Description |
|---|---|---|---|
operationId | UUID | Yes | The unique identifier for the operation to be configured. |
operationOverride | String | No | The operation-wide override mode for duration formatting. If null or an empty string, no operation-level override is set. The value is trimmed and converted to lowercase. It must be one of the valid modes. |
fieldOverrides | List<FieldEntry> | No | A list of FieldEntry objects for field-specific overrides. If null, existing field overrides are preserved. To clear all field overrides, pass an empty list and ensure any entries you wish to remove are passed with a null mode. See FieldEntry for details on adding, updating, and removing individual overrides. |
On success, returns an ApplyResult object.
| Field | Type | Description |
|---|---|---|
operationId | UUID | The ID of the operation that was updated. |
operationKey | String | The key of the operation that was updated. |
operationOverride | String | The normalized, applied operation-level override mode. null if not set. |
responseFieldOverrides | Map<String,String> | The complete, final map of field-specific overrides applied to the operation. |
The FieldEntry record defines a single field-specific override.
| Field | Type | Required | Description |
|---|---|---|---|
soapXPath | String | Yes | The XPath expression that uniquely identifies a field in the SOAP response. This value cannot be null or blank. |
mode | String | No | The formatting mode to apply for the field. If null or blank, any existing override for this soapXPath will be removed. Otherwise, it must be one of the valid modes. |
NOTE
The source refers to a DurationHandling.VALID_MODES collection for validating modes but does not specify the values it contains. An invalid mode will result in an S2R-VAL-0498 error.
When a call to the apply method fails, it throws an ApplyValidationException containing an error code and a descriptive message.
| Error Code | Trigger |
|---|---|
S2R-ADM-0410 | The request targeted an operation whose service version is active or not in draft status. The message is mapping-immutable: the operation's service version is not editable. |
S2R-ADM-0404 | The operationId provided does not correspond to any known operation. The message is operation-not-found: <operationId>. |
S2R-ADM-0404 | The operationId is valid, but no active mapping record exists for it in the database. The message is no-active-operation-mapping: <operationId>. |
S2R-VAL-0498 | The operationOverride or a FieldEntry.mode contains a value that is not a valid duration handling mode. The message is invalid-duration-handling-mode: must be one of ... or null. |
S2R-VAL-0498 | A FieldEntry object in the fieldOverrides list has a null or blank soapXPath. The message is invalid-duration-handling-field: soapXPath is required. |
S2R-VAL-0498 | An internal error occurred while serializing the final field override map to JSON. The message is invalid-duration-handling-field-map: <exception message>. |