From 250bc7b031443d0c296e71c9c571d883be6af023 Mon Sep 17 00:00:00 2001 From: Martha Mitran Date: Fri, 2 Feb 2024 10:45:46 -0800 Subject: [PATCH] Fix contentType request parameter in UploadTerminologyCommand (#5639) --- .../main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java | 3 ++- .../java/ca/uhn/fhir/cli/UploadTerminologyCommandTest.java | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java index 108d540b0c8..e073c2e2c60 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java @@ -36,6 +36,7 @@ import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.CountingInputStream; import org.apache.commons.lang3.StringUtils; @@ -268,7 +269,7 @@ public class UploadTerminologyCommand extends BaseRequestGeneratingCommand { byte[] bytes = theBytes; String fileName = theFileName; - String suffix = fileName.substring(fileName.lastIndexOf(".")); + String suffix = FilenameUtils.getExtension(fileName); if (bytes.length > ourTransferSizeLimit) { ourLog.info( diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/UploadTerminologyCommandTest.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/UploadTerminologyCommandTest.java index e7203deb3de..f0e08800425 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/UploadTerminologyCommandTest.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/UploadTerminologyCommandTest.java @@ -388,7 +388,6 @@ public class UploadTerminologyCommandTest { }, "-t", theIncludeTls, myBaseRestServerHelper )); - UploadTerminologyCommand uploadTerminologyCommand = new UploadTerminologyCommand(); verify(myTermLoaderSvc, times(1)).loadCustom(any(), myDescriptorListCaptor.capture(), any());