Add graphql and _filter support

This commit is contained in:
jamesagnew
2019-08-13 08:18:02 -04:00
parent 447c2531c5
commit 657eaf7758
4 changed files with 37 additions and 17 deletions

View File

@@ -6,8 +6,8 @@ import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.server.ETagSupportEnum;
import com.google.common.annotations.VisibleForTesting;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Properties;
import java.util.Set;
@@ -16,6 +16,7 @@ import java.util.stream.Collectors;
import static org.apache.commons.lang3.StringUtils.*;
public class HapiProperties {
public static final String BINARY_STORAGE_ENABLED = "binary_storage.enabled";
static final String ALLOW_EXTERNAL_REFERENCES = "allow_external_references";
static final String ALLOW_MULTIPLE_DELETE = "allow_multiple_delete";
static final String ALLOW_PLACEHOLDER_REFERENCES = "allow_placeholder_references";
@@ -51,10 +52,10 @@ public class HapiProperties {
static final String ALLOW_CONTAINS_SEARCHES = "allow_contains_searches";
static final String ALLOW_OVERRIDE_DEFAULT_SEARCH_PARAMS = "allow_override_default_search_params";
static final String EMAIL_FROM = "email.from";
public static final String BINARY_STORAGE_ENABLED = "binary_storage.enabled";
private static final String VALIDATE_REQUESTS_ENABLED = "validation.requests.enabled";
private static final String VALIDATE_RESPONSES_ENABLED = "validation.responses.enabled";
private static final String FILTER_SEARCH_ENABLED = "filter_search.enabled";
private static final String GRAPHQL_ENABLED = "graphql.enabled";
private static Properties properties;
/*
@@ -77,7 +78,7 @@ public class HapiProperties {
public static Properties getProperties() {
if (properties == null) {
// Load the configurable properties file
try (InputStream in = HapiProperties.class.getClassLoader().getResourceAsStream(HAPI_PROPERTIES)){
try (InputStream in = HapiProperties.class.getClassLoader().getResourceAsStream(HAPI_PROPERTIES)) {
HapiProperties.properties = new Properties();
HapiProperties.properties.load(in);
} catch (Exception e) {
@@ -85,8 +86,8 @@ public class HapiProperties {
}
Properties overrideProps = loadOverrideProperties();
if(overrideProps != null) {
properties.putAll(overrideProps);
if (overrideProps != null) {
properties.putAll(overrideProps);
}
}
@@ -96,17 +97,17 @@ public class HapiProperties {
/**
* If a configuration file path is explicitly specified via -Dhapi.properties=<path>, the properties there will
* be used to override the entries in the default hapi.properties file (currently under WEB-INF/classes)
*
* @return properties loaded from the explicitly specified configuraiton file if there is one, or null otherwise.
*/
private static Properties loadOverrideProperties() {
String confFile = System.getProperty(HAPI_PROPERTIES);
if(confFile != null) {
if (confFile != null) {
try {
Properties props = new Properties();
props.load(new FileInputStream(confFile));
return props;
}
catch (Exception e) {
} catch (Exception e) {
throw new ConfigurationException("Could not load HAPI properties file: " + confFile, e);
}
}
@@ -287,8 +288,8 @@ public class HapiProperties {
public static Set<String> getSupportedResourceTypes() {
String[] types = defaultString(getProperty("supported_resource_types")).split(",");
return Arrays.stream(types)
.map(t->trim(t))
.filter(t->isNotBlank(t))
.map(t -> trim(t))
.filter(t -> isNotBlank(t))
.collect(Collectors.toSet());
}
@@ -358,7 +359,16 @@ public class HapiProperties {
}
public static boolean getValidateResponsesEnabled() {
return HapiProperties.getBooleanProperty(VALIDATE_REQUESTS_ENABLED, false);
return HapiProperties.getBooleanProperty(VALIDATE_RESPONSES_ENABLED, false);
}
public static boolean getFilterSearchEnabled() {
return HapiProperties.getBooleanProperty(FILTER_SEARCH_ENABLED, true);
}
public static boolean getGraphqlEnabled() {
return HapiProperties.getBooleanProperty(GRAPHQL_ENABLED, true);
}
}