Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Use fetch-depth:0 to fetch all history for all tags to make Spotless Ratcheting work.
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
uses: gradle/gradle-build-action@v3
with:
arguments: clean build test
- name: Docker build
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## deployable containers have a semantic and build tag
# semantic version tag: major.minor
# build version tag: timestamp
VERSION="1.3.0"
VERSION="1.4.0"
TAGS="${VERSION} ${VERSION}-$(date -u +"%Y%m%dT%H%M%S")"
unset VERSION
28 changes: 17 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ repositories {
mavenLocal()
}

sourceCompatibility = '11'

dependencies {
implementation 'com.opencsv:opencsv:[5.9,6.0)'
implementation 'org.freemarker:freemarker:[2.3.31,2.4.0)'
Expand Down Expand Up @@ -46,8 +48,6 @@ dependencies {
testImplementation 'org.seleniumhq.selenium:selenium-java:[3.14,4.0)'
}

sourceCompatibility = 11

spotless {
// optional: only format files which have changed since origin/main
ratchetFrom 'origin/main'
Expand Down Expand Up @@ -77,20 +77,20 @@ check.dependsOn spotlessCheck
// Create Java Code Coverage Reports
jacocoTestReport {
reports {
xml.enabled true
html.enabled true
xml.required = true
html.required = true
}
}
check.dependsOn jacocoTestReport

// Create JavaDoc
javadoc {
destinationDir = file("${buildDir}/docs/javadoc")
destinationDir = file("${layout.buildDirectory}/docs/javadoc")
}

// Create Java Documentation using Dokka for Github Markdown and HTML
tasks.dokkaGfm.configure {
outputDirectory.set(file("${buildDir}/docs/dokka/gfm"))
outputDirectory.set(file("${layout.buildDirectory}/docs/dokka/gfm"))
dokkaSourceSets {
register("main") {
sourceRoots.from(file("src/main/java"))
Expand All @@ -99,7 +99,7 @@ tasks.dokkaGfm.configure {
}

tasks.dokkaHtml.configure {
outputDirectory.set(file("${buildDir}/docs/dokka/html"))
outputDirectory.set(file("${layout.buildDirectory}/docs/dokka/html"))
dokkaSourceSets {
register("main") {
sourceRoots.from(file("src/main/java"))
Expand All @@ -116,7 +116,7 @@ tasks.dokkaHtml.configure {


war {
archiveName 'storage.war'
archiveFileName = 'storage.war'
}

ext {
Expand All @@ -136,17 +136,17 @@ configurations {

idea {
module {
//and some extra test source dirs
// add integration test dir
testSourceDirs += file('src/intTest/java')
}
}

['firefox', 'chrome'].each { driver ->
task "intTest${driver.capitalize()}"(type: Test) { driverTest ->
tasks.register("intTest${driver.capitalize()}", Test) { driverTest ->
testClassesDirs = sourceSets.intTest.output.classesDirs
classpath = sourceSets.intTest.runtimeClasspath
reports {
html.destination = reporting.file("$name/html")
html.outputLocation = reporting.file("$name/html")
}
dependencies {
intTestImplementation 'junit:junit:[4.12,5.0)'
Expand Down Expand Up @@ -182,6 +182,12 @@ idea {
systemProperty 'user.name', project.intTest_user_name
}

if (!project.hasProperty('intTest_home_root')) {
System.err.println("Using default home.root (-PintTest_home_root=/ for vault, or -PintTest_home_root=/home for cavern). Default is / (vault).")
} else {
systemProperty 'home.root', project.intTest_home_root
}

if (!project.hasProperty('intTest_user_password')) {
System.err.println("Please set the intTest_user_password property (-PintTest_user_password=1234pw).")
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.LocalAuthority;
import ca.nrc.cadc.util.StringUtil;
import java.io.IOException;
import java.net.URI;
import org.apache.commons.configuration2.CombinedConfiguration;
import org.apache.commons.configuration2.Configuration;
import org.apache.commons.configuration2.PropertiesConfiguration;
Expand All @@ -85,10 +87,6 @@
import org.apache.log4j.Logger;
import org.opencadc.token.Client;

import java.io.IOException;
import java.net.URI;
import java.net.URL;

public class StorageConfiguration {
private static final Logger LOGGER = LogManager.getLogger(StorageConfiguration.class);
public static final String FIRST_PARTY_COOKIE_NAME = "__Host-storage-ui-auth";
Expand All @@ -105,9 +103,9 @@ public StorageConfiguration() {
combinedConfiguration.addConfiguration(new SystemConfiguration());

final Parameters parameters = new Parameters();
final FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class)
.configure(parameters.properties().setFileName(filePath));
final FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>(
PropertiesConfiguration.class)
.configure(parameters.properties().setFileName(filePath));

try {
combinedConfiguration.addConfiguration(builder.getConfiguration());
Expand All @@ -118,26 +116,27 @@ public StorageConfiguration() {
this.configuration = combinedConfiguration;
}


public String getDefaultServiceName() {
return lookup(StorageConfigurationKey.DEFAULT_SERVICE_NAME);
}

public String[] getServiceNames() {
return lookupStringArray(StorageConfigurationKey.SERVICE_NAME);
return lookupStringArray(
StorageConfigurationKey.SERVICE_NAME.propertyName, StorageConfigurationKey.SERVICE_NAME.required);
}

public URI getGMSServiceURI() {
final LocalAuthority localAuthority = new LocalAuthority();
return localAuthority.getServiceURI(Standards.GMS_SEARCH_10.toASCIIString());
return localAuthority.getResourceID(Standards.GMS_SEARCH_10);
}

public String getTokenCacheURLString() {
return lookup(StorageConfigurationKey.TOKEN_CACHE_URL);
}

public String getThemeName() {
return lookup(StorageConfigurationKey.THEME_NAME, "canfar");
final String propertyValue = configuration.getString(StorageConfigurationKey.THEME_NAME.propertyName);
return propertyValue == null ? "canfar" : propertyValue;
}

public String getOIDCClientID() {
Expand All @@ -161,15 +160,21 @@ public String getOIDCScope() {
}

public boolean isOIDCConfigured() {
return StringUtil.hasText(getOIDCClientID()) && StringUtil.hasText(getOIDCClientSecret())
&& StringUtil.hasText(getOIDCCallbackURI()) && StringUtil.hasText(getOIDCScope())
&& StringUtil.hasText(getTokenCacheURLString());
return StringUtil.hasText(getOIDCClientID())
&& StringUtil.hasText(getOIDCClientSecret())
&& StringUtil.hasText(getOIDCCallbackURI())
&& StringUtil.hasText(getOIDCScope())
&& StringUtil.hasText(getTokenCacheURLString());
}

public Client getOIDCClient() throws IOException {
return new Client(getOIDCClientID(), getOIDCClientSecret(),
new URL(getOIDCCallbackURI()), new URL(getOIDCRedirectURI()),
getOIDCScope().split(" "), getTokenCacheURLString());
return new Client(
getOIDCClientID(),
getOIDCClientSecret(),
URI.create(getOIDCCallbackURI()).toURL(),
URI.create(getOIDCRedirectURI()).toURL(),
getOIDCScope().split(" "),
getTokenCacheURLString());
}

public GMSClient getGMSClient() {
Expand All @@ -188,44 +193,28 @@ String lookup(final StorageConfigurationKey key) {
return lookup(key.propertyName, key.required);
}

String lookup(final StorageConfigurationKey key, final String defaultValue) {
return lookup(key.propertyName, defaultValue);
}

public String lookup(final String propertyName, final boolean required) {
final String propertyValue = configuration.getString(propertyName);
if (propertyValue == null && required) {
throw new IllegalStateException(
"Required value " + propertyName + " not found in application config.");
throw new IllegalStateException("Required value " + propertyName + " not found in application config.");
}

return propertyValue;
}

public boolean lookupFlag(final String propertyName, final boolean required) {
if (required && !configuration.containsKey(propertyName)) {
throw new IllegalStateException(
"Required value " + propertyName + " not found in application config.");
throw new IllegalStateException("Required value " + propertyName + " not found in application config.");
}

return configuration.getBoolean(propertyName, false);
}

String lookup(final String propertyName, final String defaultValue) {
final String propertyValue = configuration.getString(propertyName);
return propertyValue == null ? defaultValue : propertyValue;
}

String[] lookupStringArray(final StorageConfigurationKey key) {
return lookupStringArray(key.propertyName, key.required);
}

public String[] lookupStringArray(final String key, final boolean required) {
final String[] propertyValues = configuration.getStringArray(key);

if (propertyValues == null && required) {
throw new IllegalStateException(
"Required value " + key + " not found in application config.");
throw new IllegalStateException("Required value " + key + " not found in application config.");
}

return propertyValues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,18 @@ public class VOSpaceServiceConfig {

private final Features features;

// The link to the group management service. Set as a URI in case it will be looked up as a Registry entry instead.
private final URI groupManagementLinkURI;

// Default provided, can be overridden
public String homeDir;

public VOSpaceServiceConfig(String name, URI resourceID, URI nodeResourceID, final Features features) {
public VOSpaceServiceConfig(
String name,
URI resourceID,
URI nodeResourceID,
final Features features,
final URI groupManagementLinkURI) {

// Validation for required properties
if (!StringUtil.hasLength(name)) {
Expand All @@ -105,6 +113,8 @@ public VOSpaceServiceConfig(String name, URI resourceID, URI nodeResourceID, fin

// Set default for optional properties
this.homeDir = "/";

this.groupManagementLinkURI = groupManagementLinkURI;
}

public String getName() {
Expand All @@ -119,6 +129,10 @@ public URI getNodeResourceID() {
return this.nodeResourceID;
}

public URI getGroupManagementLinkURI() {
return this.groupManagementLinkURI;
}

public boolean supportsBatchDownloads() {
return this.features.supportsBatchDownloads;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public class VOSpaceServiceConfigManager {
public static final String SERVICE_NAME_RESOURCE_ID_PROPERTY_KEY_FORMAT = "%s%s.service.resourceid";
public static final String SERVICE_NODE_RESOURCE_ID_PROPERTY_KEY_FORMAT = "%s%s.node.resourceid";
public static final String SERVICE_USER_HOME_PROPERTY_KEY_FORMAT = "%s%s.user.home";
public static final String SERVICE_GROUP_MANAGEMENT_URI_KEY_FORMAT = "%s%s.service.groupManagementURI";
public static final String SERVICE_FEATURE_BATCH_UPLOAD_PROPERTY_KEY_FORMAT = "%s%s.service.features.batchUpload";
public static final String SERVICE_FEATURE_BATCH_DOWNLOAD_PROPERTY_KEY_FORMAT =
"%s%s.service.features.batchDownload";
Expand Down Expand Up @@ -144,9 +145,21 @@ private void loadServices() {
storageServiceName);
final String userHomeStr = applicationConfiguration.lookup(userHomePrefixKey, true);

final String groupManagementURIPrefixKey = String.format(
VOSpaceServiceConfigManager.SERVICE_GROUP_MANAGEMENT_URI_KEY_FORMAT,
VOSpaceServiceConfigManager.KEY_BASE,
storageServiceName);
final String groupManagementURIPrefixKeyStr =
applicationConfiguration.lookup(groupManagementURIPrefixKey, true);

// At this point, the values have been validated
final VOSpaceServiceConfig voSpaceServiceConfig = new VOSpaceServiceConfig(
storageServiceName, vospaceResourceID, nodeResourceID, getFeatures(storageServiceName));
storageServiceName,
vospaceResourceID,
nodeResourceID,
getFeatures(storageServiceName),
URI.create(groupManagementURIPrefixKeyStr));

voSpaceServiceConfig.homeDir = userHomeStr;

this.serviceConfigMap.put(storageServiceName, voSpaceServiceConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ Representation representFolderItem(
// Used to populate VOSpace service dropdown
dataModel.put("vospaceServices", getVOSpaceServiceList());

// Group Manager link
dataModel.put("groupManagerLinkURI", this.currentService.getGroupManagementLinkURI());

final String httpUsername = getDisplayName();

if (httpUsername != null) {
Expand Down
Loading
Loading