Skip to content

Commit

Permalink
Normalize configuration
Browse files Browse the repository at this point in the history
Resolves #606
  • Loading branch information
acoburn authored Dec 11, 2019
1 parent 8d44e49 commit 4f0d17d
Show file tree
Hide file tree
Showing 33 changed files with 117 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class BasicAuthFilter implements ContainerRequestFilter {
public static final String CONFIG_AUTH_REALM = "trellis.auth.realm";

/** The configuration key controlling the list of of admin WebID values. */
public static final String CONFIG_AUTH_ADMIN_USERS = "trellis.auth.adminusers";
public static final String CONFIG_AUTH_ADMIN_USERS = "trellis.auth.admin-users";

/** The admin role. */
public static final String ADMIN_ROLE = "admin";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class JwtAuthFilter implements ContainerRequestFilter {
private static final Logger LOGGER = getLogger(JwtAuthFilter.class);

/** The configuration key controlling the list of of admin WebID values. */
public static final String CONFIG_AUTH_ADMIN_USERS = "trellis.auth.adminusers";
public static final String CONFIG_AUTH_ADMIN_USERS = "trellis.auth.admin-users";

private final Set<String> admins;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,22 @@
@Priority(AUTHENTICATION)
public class OAuthFilter implements ContainerRequestFilter {

/** The configuration key controlling the list of of admin WebID values. */
public static final String CONFIG_AUTH_ADMIN_USERS = "trellis.auth.admin-users";
/** The configuration key controlling the realm used in a WWW-Authenticate header, or 'trellis' by default. */
public static final String CONFIG_AUTH_REALM = "trellis.auth.realm";
/** The configuration key controlling the OAuth Keystore path. */
public static final String CONFIG_AUTH_OAUTH_KEYSTORE_PATH = "trellis.auth.oauth.keystore.path";
public static final String CONFIG_AUTH_OAUTH_KEYSTORE_PATH = "trellis.auth.oauth.keystore-path";
/** The configuration key controlling the OAuth Keystore credentials. */
public static final String CONFIG_AUTH_OAUTH_KEYSTORE_CREDENTIALS = "trellis.auth.oauth.keystore.credentials";
public static final String CONFIG_AUTH_OAUTH_KEYSTORE_CREDENTIALS = "trellis.auth.oauth.keystore-credentials";
/** The configuration key controlling the OAuth Keystore ids. */
public static final String CONFIG_AUTH_OAUTH_KEYSTORE_IDS = "trellis.auth.oauth.keystore.ids";
public static final String CONFIG_AUTH_OAUTH_KEYSTORE_IDS = "trellis.auth.oauth.keystore-ids";
/** The configuration key controlling the OAuth HMAC shared secret. */
public static final String CONFIG_AUTH_OAUTH_SHARED_SECRET = "trellis.auth.oauth.sharedsecret";
public static final String CONFIG_AUTH_OAUTH_SHARED_SECRET = "trellis.auth.oauth.shared-secret";
/** The configuration key controlling the OAuth JWK URL. */
public static final String CONFIG_AUTH_OAUTH_JWK_URL = "trellis.auth.oauth.jwk";
/** The authentication scheme used by this module. */
public static final String SCHEME = "Bearer";
/** The configuration key controlling the list of of admin WebID values. */
public static final String CONFIG_AUTH_ADMIN_USERS = "trellis.auth.adminusers";
/** The admin role. */
public static final String ADMIN_ROLE = "admin";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
trellis.triplestore.ldp.type=true
trellis.triplestore.rdf.location=resources
trellis.file.memento.basepath=mementos
trellis.file.binary.basepath=binary
trellis.namespaces.path=namespaces.json
trellis.triplestore.ldp-type=true
trellis.triplestore.rdf-location=resources
trellis.file.memento-path=mementos
trellis.file.binary-path=binary
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public abstract class AbstractTrellisApplication<T extends TrellisConfiguration>
private static final Logger LOGGER = getLogger(AbstractTrellisApplication.class);

/** The configuration key controlling whether an application should initialize its own root resource. */
public static final String CONFIG_DROPWIZARD_INITIALIZE_ROOT = "trellis.dropwizard.initialize.root";
public static final String CONFIG_DROPWIZARD_INITIALIZE_ROOT = "trellis.dropwizard.initialize-root";

/**
* Get the Trellis {@link ServiceBundler}. This object collects the various
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
trellis.triplestore.ldp.type=true
trellis.triplestore.rdf.location=resources
trellis.file.memento.basepath=mementos
trellis.file.binary.basepath=binary
trellis.namespaces.path=namespaces.json
trellis.triplestore.ldp-type=true
trellis.triplestore.rdf-location=resources
trellis.file.memento-path=mementos
trellis.file.binary-path=binary
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@
public class FileBinaryService implements BinaryService {

/** The configuration key controlling the base filesystem path for the binary service. */
public static final String CONFIG_FILE_BINARY_BASE_PATH = "trellis.file.binary.basepath";
public static final String CONFIG_FILE_BINARY_PATH = "trellis.file.binary-path";

/** The configuration key controlling the levels of hierarchy in a binary storage layout. */
public static final String CONFIG_FILE_BINARY_HIERARCHY = "trellis.file.binary.hierarchy";
public static final String CONFIG_FILE_BINARY_HIERARCHY = "trellis.file.binary-hierarchy";

/** The configuration key controlling the length of each level of hierarchy in a filesystem layout. */
public static final String CONFIG_FILE_BINARY_LENGTH = "trellis.file.binary.length";
public static final String CONFIG_FILE_BINARY_LENGTH = "trellis.file.binary-length";

private static final Logger LOGGER = getLogger(FileBinaryService.class);
private static final int DEFAULT_HIERARCHY = 3;
Expand Down Expand Up @@ -96,7 +96,7 @@ public FileBinaryService(final IdentifierService idService, final String basePat
}

private FileBinaryService(final IdentifierService idService, final Config config) {
this(idService, config.getValue(CONFIG_FILE_BINARY_BASE_PATH, String.class),
this(idService, config.getValue(CONFIG_FILE_BINARY_PATH, String.class),
config.getOptionalValue(CONFIG_FILE_BINARY_HIERARCHY, Integer.class).orElse(DEFAULT_HIERARCHY),
config.getOptionalValue(CONFIG_FILE_BINARY_LENGTH, Integer.class).orElse(DEFAULT_LENGTH));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
public class FileMementoService implements MementoService {

/** The configuration key controlling the base filesystem path for memento storage. */
public static final String CONFIG_FILE_MEMENTO_BASE_PATH = "trellis.file.memento.basepath";
public static final String CONFIG_FILE_MEMENTO_PATH = "trellis.file.memento-path";

private static final Logger LOGGER = getLogger(FileMementoService.class);

Expand All @@ -55,7 +55,7 @@ public class FileMementoService implements MementoService {
* Create a file-based memento service.
*/
public FileMementoService() {
this(ConfigProvider.getConfig().getValue(CONFIG_FILE_MEMENTO_BASE_PATH, String.class));
this(ConfigProvider.getConfig().getValue(CONFIG_FILE_MEMENTO_PATH, String.class));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ class FileBinaryServiceTest {

@BeforeAll
static void setUpEverything() {
System.setProperty(FileBinaryService.CONFIG_FILE_BINARY_BASE_PATH, directory);
System.setProperty(FileBinaryService.CONFIG_FILE_BINARY_PATH, directory);
}

@AfterAll
static void cleanUp() {
System.clearProperty(FileBinaryService.CONFIG_FILE_BINARY_BASE_PATH);
System.clearProperty(FileBinaryService.CONFIG_FILE_BINARY_PATH);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void testList() {
assertTrue(dir.isDirectory(), "Resource directory isn't a valid directory");

try {
System.setProperty(FileMementoService.CONFIG_FILE_MEMENTO_BASE_PATH, dir.getAbsolutePath());
System.setProperty(FileMementoService.CONFIG_FILE_MEMENTO_PATH, dir.getAbsolutePath());

final MementoService svc = new FileMementoService();

Expand All @@ -125,7 +125,7 @@ void testList() {
svc.get(identifier, MAX).thenAccept(res -> assertEquals(time2, res.getModified(), "Incorrect date!"))
.toCompletableFuture().join();
} finally {
System.clearProperty(FileMementoService.CONFIG_FILE_MEMENTO_BASE_PATH);
System.clearProperty(FileMementoService.CONFIG_FILE_MEMENTO_PATH);
}
}

Expand Down Expand Up @@ -218,7 +218,7 @@ void testListNonExistent() {
final File dir = new File(getClass().getResource("/versions").getFile());

try {
System.setProperty(FileMementoService.CONFIG_FILE_MEMENTO_BASE_PATH, dir.getAbsolutePath());
System.setProperty(FileMementoService.CONFIG_FILE_MEMENTO_PATH, dir.getAbsolutePath());

final MementoService svc = new FileMementoService();
final IRI identifier = rdf.createIRI(TRELLIS_DATA_PREFIX + "nonexistent");
Expand All @@ -230,7 +230,7 @@ void testListNonExistent() {
assertEquals(MISSING_RESOURCE, svc.get(identifier, now()).toCompletableFuture().join(),
"Wrong response for missing resource!");
} finally {
System.clearProperty(FileMementoService.CONFIG_FILE_MEMENTO_BASE_PATH);
System.clearProperty(FileMementoService.CONFIG_FILE_MEMENTO_PATH);
}
}

Expand All @@ -239,7 +239,7 @@ void testListNone() {
final File dir = new File(getClass().getResource("/versions").getFile());

try {
System.setProperty(FileMementoService.CONFIG_FILE_MEMENTO_BASE_PATH, dir.getAbsolutePath());
System.setProperty(FileMementoService.CONFIG_FILE_MEMENTO_PATH, dir.getAbsolutePath());

final MementoService svc = new FileMementoService();
final IRI identifier = rdf.createIRI(TRELLIS_DATA_PREFIX + "empty");
Expand All @@ -251,7 +251,7 @@ void testListNone() {
assertTrue(svc.mementos(identifier).toCompletableFuture().join().isEmpty(),
"Memento list isn't empty!");
} finally {
System.clearProperty(FileMementoService.CONFIG_FILE_MEMENTO_BASE_PATH);
System.clearProperty(FileMementoService.CONFIG_FILE_MEMENTO_PATH);
}
}

Expand All @@ -265,7 +265,7 @@ void testNewVersionSystem() {
assertFalse(versionDir.exists(), "Version directory already exists!");

try {
System.setProperty(FileMementoService.CONFIG_FILE_MEMENTO_BASE_PATH, versionDir.getAbsolutePath());
System.setProperty(FileMementoService.CONFIG_FILE_MEMENTO_PATH, versionDir.getAbsolutePath());

final FileMementoService svc = new FileMementoService();

Expand All @@ -282,7 +282,7 @@ void testNewVersionSystem() {
assertEquals(2L, svc.mementos(identifier).toCompletableFuture().join().size(),
"Incorrect count of Mementos!");
} finally {
System.clearProperty(FileMementoService.CONFIG_FILE_MEMENTO_BASE_PATH);
System.clearProperty(FileMementoService.CONFIG_FILE_MEMENTO_PATH);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
trellis.file.memento.basepath=mementos
trellis.file.binary.basepath=binaries
trellis.file.memento-path=mementos
trellis.file.binary-path=binaries
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@
public class JenaIOService implements IOService {

/** The configuration key listing valid JSON-LD profile documents. */
public static final String CONFIG_IO_JSONLD_PROFILES = "trellis.io.jsonld.profiles";
public static final String CONFIG_IO_JSONLD_PROFILES = "trellis.io.jsonld-profiles";

/** The configuration key listing valid JSON-LD profile domains. */
public static final String CONFIG_IO_JSONLD_DOMAINS = "trellis.io.jsonld.domains";
public static final String CONFIG_IO_JSONLD_DOMAINS = "trellis.io.jsonld-domains";

private static final Logger LOGGER = getLogger(JenaIOService.class);
private static final JenaRDF rdf = new JenaRDF();
Expand Down
2 changes: 1 addition & 1 deletion components/namespaces/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ dependencies {
}

test {
systemProperty 'trellis.namespace.prefixes', 'dc11=http://purl.org/dc/elements/1.1/,,foo= , =bar,baz, = '
systemProperty 'trellis.namespaces.mapping', 'dc11=http://purl.org/dc/elements/1.1/,,foo= , =bar,baz, = '
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
@ApplicationScoped
public class SimpleNamespaceService implements NamespaceService {

public static final String CONFIG_NAMESPACE_PREFIXES = "trellis.namespace.prefixes";
public static final String CONFIG_NAMESPACES_MAPPING = "trellis.namespaces.mapping";

private final Map<String, String> namespaces = new HashMap<>();

Expand All @@ -63,7 +63,7 @@ public SimpleNamespaceService() {
namespaces.put("xsd", XSD.getNamespace());
namespaces.put("foaf", FOAF.getNamespace());
namespaces.put("vcard", VCARD.getNamespace());
getConfig().getOptionalValue(CONFIG_NAMESPACE_PREFIXES, String.class).map(SimpleNamespaceService::configToMap)
getConfig().getOptionalValue(CONFIG_NAMESPACES_MAPPING, String.class).map(SimpleNamespaceService::configToMap)
.ifPresent(data -> data.forEach(namespaces::put));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@
public class TriplestoreResourceService implements ResourceService {

/** The configuration key used to set where the RDF is stored. */
public static final String CONFIG_TRIPLESTORE_RDF_LOCATION = "trellis.triplestore.rdf.location";
public static final String CONFIG_TRIPLESTORE_RDF_LOCATION = "trellis.triplestore.rdf-location";
/** The configuration key used to set whether the LDP type should be included in the body of the RDF. */
public static final String CONFIG_TRIPLESTORE_LDP_TYPE = "trellis.triplestore.ldp.type";
public static final String CONFIG_TRIPLESTORE_LDP_TYPE = "trellis.triplestore.ldp-type";

private static final String MODIFIED = "modified";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,21 @@ public class WebAcFilter implements ContainerRequestFilter, ContainerResponseFil
* <p>Values defined here will be in addition to GET, HEAD and OPTIONS. Multiple methods should
* be separated with commas.
*/
public static final String CONFIG_WEBAC_METHOD_READABLE = "trellis.webac.method.readable";
public static final String CONFIG_WEBAC_READABLE_METHODS = "trellis.webac.readable-methods";
/**
* The configuration key controlling with HTTP methods should apply to the acl:Write.
*
* <p>Values defined here will be in addition to GET, HEAD and OPTIONS. Multiple methods should
* be separated with commas.
*/
public static final String CONFIG_WEBAC_METHOD_WRITABLE = "trellis.webac.method.writable";
public static final String CONFIG_WEBAC_WRITABLE_METHODS = "trellis.webac.writable-methods";
/**
* The configuration key controlling with HTTP methods should apply to the acl:Append.
*
* <p>Values defined here will be in addition to GET, HEAD and OPTIONS. Multiple methods should
* be separated with commas.
*/
public static final String CONFIG_WEBAC_METHOD_APPENDABLE = "trellis.webac.method.appendable";
public static final String CONFIG_WEBAC_APPENDABLE_METHODS = "trellis.webac.appendable-methods";

/** The configuration key controlling the realm used in a WWW-Authenticate header, or 'trellis' by default. */
public static final String CONFIG_WEBAC_REALM = "trellis.webac.realm";
Expand Down Expand Up @@ -164,11 +164,11 @@ public WebAcFilter(final WebAcService accessService, final List<String> challeng
.collect(toList());
this.baseUrl = baseUrl;
final Config config = getConfig();
config.getOptionalValue(CONFIG_WEBAC_METHOD_READABLE, String.class).ifPresent(r ->
config.getOptionalValue(CONFIG_WEBAC_READABLE_METHODS, String.class).ifPresent(r ->
stream(r.split(",")).map(String::trim).map(String::toUpperCase).forEach(readable::add));
config.getOptionalValue(CONFIG_WEBAC_METHOD_WRITABLE, String.class).ifPresent(w ->
config.getOptionalValue(CONFIG_WEBAC_WRITABLE_METHODS, String.class).ifPresent(w ->
stream(w.split(",")).map(String::trim).map(String::toUpperCase).forEach(writable::add));
config.getOptionalValue(CONFIG_WEBAC_METHOD_APPENDABLE, String.class).ifPresent(a ->
config.getOptionalValue(CONFIG_WEBAC_APPENDABLE_METHODS, String.class).ifPresent(a ->
stream(a.split(",")).map(String::trim).map(String::toUpperCase).forEach(appendable::add));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
public class WebAcService {

/** The configuration key controlling whether to check member resources at the AuthZ enforcement point. */
public static final String CONFIG_WEBAC_MEMBERSHIP_CHECK = "trellis.webac.membership.check";
public static final String CONFIG_WEBAC_MEMBERSHIP_CHECK = "trellis.webac.membership-check";

private static final Logger LOGGER = getLogger(WebAcService.class);
private static final CompletionStage<Void> DONE = CompletableFuture.completedFuture(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ class WebAcFilterTest {

@BeforeAll
static void setUpProperties() {
System.setProperty(WebAcFilter.CONFIG_WEBAC_METHOD_READABLE, "READ");
System.setProperty(WebAcFilter.CONFIG_WEBAC_METHOD_WRITABLE, "WRITE");
System.setProperty(WebAcFilter.CONFIG_WEBAC_METHOD_APPENDABLE, "APPEND");
System.setProperty(WebAcFilter.CONFIG_WEBAC_READABLE_METHODS, "READ");
System.setProperty(WebAcFilter.CONFIG_WEBAC_WRITABLE_METHODS, "WRITE");
System.setProperty(WebAcFilter.CONFIG_WEBAC_APPENDABLE_METHODS, "APPEND");
}

@AfterAll
static void cleanUpProperties() {
System.clearProperty(WebAcFilter.CONFIG_WEBAC_METHOD_READABLE);
System.clearProperty(WebAcFilter.CONFIG_WEBAC_METHOD_WRITABLE);
System.clearProperty(WebAcFilter.CONFIG_WEBAC_METHOD_APPENDABLE);
System.clearProperty(WebAcFilter.CONFIG_WEBAC_READABLE_METHODS);
System.clearProperty(WebAcFilter.CONFIG_WEBAC_WRITABLE_METHODS);
System.clearProperty(WebAcFilter.CONFIG_WEBAC_APPENDABLE_METHODS);
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
trellis.webac.membership.check=true
trellis.webac.membership-check=true
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
public class CacheControlFilter implements ContainerResponseFilter {

/** The configuration key for setting a cache-control max-age header. */
public static final String CONFIG_HTTP_CACHE_AGE = "trellis.http.cache.maxage";
public static final String CONFIG_HTTP_CACHE_MAX_AGE = "trellis.http.cache-max-age";
/** The configuration key for setting a cache-control must-revalidate header. */
public static final String CONFIG_HTTP_CACHE_REVALIDATE = "trellis.http.cache.revalidate";
public static final String CONFIG_HTTP_CACHE_REVALIDATE = "trellis.http.cache-revalidate";
/** The configuration key for setting a cache-control no-cache header. */
public static final String CONFIG_HTTP_CACHE_NOCACHE = "trellis.http.cache.nocache";
public static final String CONFIG_HTTP_CACHE_NOCACHE = "trellis.http.cache-nocache";

private final int cacheAge;
private final boolean revalidate;
Expand All @@ -57,7 +57,7 @@ public CacheControlFilter() {
}

private CacheControlFilter(final Config config) {
this(config.getOptionalValue(CONFIG_HTTP_CACHE_AGE, Integer.class).orElse(86400),
this(config.getOptionalValue(CONFIG_HTTP_CACHE_MAX_AGE, Integer.class).orElse(86400),
config.getOptionalValue(CONFIG_HTTP_CACHE_REVALIDATE, Boolean.class).orElse(Boolean.TRUE),
config.getOptionalValue(CONFIG_HTTP_CACHE_NOCACHE, Boolean.class).orElse(Boolean.FALSE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public class WebSubHeaderFilter implements ContainerResponseFilter {

/** The configuration key controlling the location of a web-sub-hub. */
public static final String CONFIG_HTTP_WEB_SUB_HUB = "trellis.http.websubhub";
public static final String CONFIG_HTTP_WEB_SUB_HUB = "trellis.http.web-sub-hub";

private final String hub;

Expand Down
Loading

0 comments on commit 4f0d17d

Please sign in to comment.