Skip to content

Commit

Permalink
chore: improve Content-Type negotiation rules flexibility tech-by-des…
Browse files Browse the repository at this point in the history
  • Loading branch information
shah committed Jun 28, 2024
1 parent 693cd73 commit 64d4ff9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class Request {
+ "FHIR-Validation-Strategy";
public static final String DATALAKE_API_URL = Configuration.Servlet.HeaderName.PREFIX
+ "DataLake-API-URL";
public static final String DATALAKE_API_CONTENT_TYPE = Configuration.Servlet.HeaderName.PREFIX
+ "DataLake-API-Content-Type";
}

public class Response {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -81,7 +82,9 @@ public String metadata(final Model model, HttpServletRequest request) {
return "metadata.xml";
}

@PostMapping(value = { "/Bundle", "/Bundle/" }, consumes = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = { "/Bundle", "/Bundle/" }, consumes = { MediaType.APPLICATION_JSON_VALUE,
MediaType.APPLICATION_JSON_VALUE + "+fhir" })
@Operation(summary = "Endpoint to to validate, store, and then forward a payload to SHIN-NY. If you want to validate a payload and not store it or forward it to SHIN-NY, use $validate.")
@ResponseBody
@Async
public Object validateBundleAndForward(final @RequestBody @Nonnull String payload,
Expand All @@ -91,6 +94,7 @@ public Object validateBundleAndForward(final @RequestBody @Nonnull String payloa
@RequestHeader(value = AppConfig.Servlet.HeaderName.Request.FHIR_STRUCT_DEFN_PROFILE_URI, required = false) String fhirProfileUrlHeader,
@RequestHeader(value = AppConfig.Servlet.HeaderName.Request.FHIR_VALIDATION_STRATEGY, required = false) String uaValidationStrategyJson,
@RequestHeader(value = AppConfig.Servlet.HeaderName.Request.DATALAKE_API_URL, required = false) String customDataLakeApi,
@RequestHeader(value = AppConfig.Servlet.HeaderName.Request.DATALAKE_API_CONTENT_TYPE, required = false) String dataLakeApiContentType,
@RequestParam(value = "immediate", required = false) boolean isSync,
@RequestParam(value = "include-request-in-outcome", required = false) boolean includeRequestInOutcome,
@RequestParam(value = "include-incoming-payload-in-db", required = false) boolean includeIncomingPayloadInDB,
Expand Down Expand Up @@ -182,6 +186,10 @@ public Object validateBundleAndForward(final @RequestBody @Nonnull String payloa
webClient.post()
.uri("?processingAgent=" + tenantId)
.body(BodyInserters.fromValue(payload))
.header("Content-Type",
Optional.ofNullable(
Optional.ofNullable(dataLakeApiContentType).orElse(request.getContentType()))
.orElse("application/json+fhir"))
.retrieve()
.bodyToMono(String.class)
.subscribe(response -> {
Expand Down Expand Up @@ -241,6 +249,7 @@ public Object validateBundleAndForward(final @RequestBody @Nonnull String payloa
}

@PostMapping(value = { "/Bundle/$validate", "/Bundle/$validate/" }, consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Endpoint to validate but not store or forward a payload to SHIN-NY. If you want to validate a payload, store it and then forward it to SHIN-NY, use /Bundle not /Bundle/$validate.")
@ResponseBody
public Object validateBundle(final @RequestBody @Nonnull String payload,
@RequestHeader(value = Configuration.Servlet.HeaderName.Request.TENANT_ID, required = true) String tenantId,
Expand Down

0 comments on commit 64d4ff9

Please sign in to comment.