diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/i18n/HapiLocalizer.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/i18n/HapiLocalizer.java index cde0ac32595..61919db00fc 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/i18n/HapiLocalizer.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/i18n/HapiLocalizer.java @@ -24,9 +24,12 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.text.MessageFormat; import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.ResourceBundle; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; /** @@ -95,4 +98,17 @@ public class HapiLocalizer { return retVal; } } + + + public Set getAllKeys(){ + HashSet retVal = new HashSet(); + for (ResourceBundle nextBundle : myBundle) { + Enumeration keysEnum = nextBundle.getKeys(); + while (keysEnum.hasMoreElements()) { + retVal.add(keysEnum.nextElement()); + } + } + return retVal; + } + } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/interceptor/LoggingInterceptor.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/interceptor/LoggingInterceptor.java index e325f551024..bf2aa33a80c 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/interceptor/LoggingInterceptor.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/interceptor/LoggingInterceptor.java @@ -47,14 +47,14 @@ public class LoggingInterceptor implements IClientInterceptor { private boolean myLogResponseSummary = true; /** - * Constructor + * Constructor for client logging interceptor */ public LoggingInterceptor() { super(); } /** - * Constructor + * Constructor for client logging interceptor * * @param theVerbose * If set to true, all logging is enabled diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptor.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptor.java index 8babecec29f..a9f0bdbf2da 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptor.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptor.java @@ -137,6 +137,13 @@ public class LoggingInterceptor extends InterceptorAdapter { private Logger myLogger = ourLog; private String myMessageFormat = "${operationType} - ${idOrResourceName}"; + /** + * Constructor for server logging interceptor + */ + public LoggingInterceptor() { + super(); + } + /** * Get the log message format to be used when logging exceptions */ diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/i18n/HapiLocalizerTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/i18n/HapiLocalizerTest.java new file mode 100644 index 00000000000..f99798fde73 --- /dev/null +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/i18n/HapiLocalizerTest.java @@ -0,0 +1,25 @@ +package ca.uhn.fhir.i18n; + +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertThat; + +import java.util.Set; + +import org.junit.Test; + +public class HapiLocalizerTest { + + + @Test + public void testAllKeys() { + HapiLocalizer svc = new HapiLocalizer(); + Set allKeys = svc.getAllKeys(); + assertThat(allKeys, not(empty())); + + for (String next : allKeys) { + svc.getMessage(next); + } + } + +} diff --git a/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java index 9f9f9afc45d..c78a7b7a4c7 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java @@ -17,6 +17,7 @@ import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.term.IHapiTerminologyLoaderSvc; import ca.uhn.fhir.rest.client.IGenericClient; import ca.uhn.fhir.rest.client.interceptor.BearerTokenAuthInterceptor; +import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; public class UploadTerminologyCommand extends BaseCommand { @@ -59,6 +60,10 @@ public class UploadTerminologyCommand extends BaseCommand { opt.setRequired(false); options.addOption(opt); + opt = new Option("v", "verbose", false, "Verbose output"); + opt.setRequired(false); + options.addOption(opt); + return options; } @@ -85,7 +90,6 @@ public class UploadTerminologyCommand extends BaseCommand { String bearerToken = theCommandLine.getOptionValue("b"); - IGenericClient client = super.newClient(ctx, targetServer); IBaseParameters inputParameters; if (ctx.getVersion().getVersion() == FhirVersionEnum.DSTU3) { @@ -102,6 +106,10 @@ public class UploadTerminologyCommand extends BaseCommand { if (isNotBlank(bearerToken)) { client.registerInterceptor(new BearerTokenAuthInterceptor(bearerToken)); } + + if (theCommandLine.hasOption('v')) { + client.registerInterceptor(new LoggingInterceptor(true)); + } ourLog.info("Beginning upload - This may take a while..."); IBaseParameters response = client diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvc.java index db10be4c5fa..7ab6b5b1d45 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvc.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvc.java @@ -45,6 +45,7 @@ import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; import org.apache.commons.csv.QuoteMode; import org.apache.commons.io.IOUtils; +import org.apache.commons.io.input.BOMInputStream; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; import org.springframework.beans.factory.annotation.Autowired; @@ -174,7 +175,7 @@ public class TerminologyLoaderSvc implements IHapiTerminologyLoaderSvc { Reader reader = null; CSVParser parsed = null; try { - reader = new InputStreamReader(zis, Charsets.UTF_8); + reader = new InputStreamReader(new BOMInputStream(zis), Charsets.UTF_8); CSVFormat format = CSVFormat.newFormat(theDelimiter).withFirstRecordAsHeader(); if (theQuoteMode != null) { format = format.withQuote('"').withQuoteMode(theQuoteMode);