diff --git a/vault/VERSION b/vault/VERSION index 5ff92dd7..44180daa 100644 --- a/vault/VERSION +++ b/vault/VERSION @@ -4,6 +4,6 @@ # tags with and without build number so operators use the versioned # tag but we always keep a timestamped tag in case a semantic tag gets # replaced accidentally -VER=1.0.4 +VER=1.0.5 TAGS="${VER} ${VER}-$(date --utc +"%Y%m%dT%H%M%S")" unset VER diff --git a/vault/build.gradle b/vault/build.gradle index e18c8d24..725f5c2c 100644 --- a/vault/build.gradle +++ b/vault/build.gradle @@ -54,7 +54,7 @@ dependencies { runtime 'org.opencadc:cadc-gms:[1.0.5,)' intTestCompile 'org.opencadc:cadc-test-vosi:[1.0.11,)' - intTestCompile 'org.opencadc:cadc-test-vos:[2.1.6,)' + intTestCompile 'org.opencadc:cadc-test-vos:[2.1.9,)' } configurations { diff --git a/vault/src/intTest/java/org/opencadc/vault/FilesTest.java b/vault/src/intTest/java/org/opencadc/vault/FilesTest.java index 5002c5fe..67d81ad4 100644 --- a/vault/src/intTest/java/org/opencadc/vault/FilesTest.java +++ b/vault/src/intTest/java/org/opencadc/vault/FilesTest.java @@ -67,10 +67,7 @@ package org.opencadc.vault; -import ca.nrc.cadc.util.FileUtil; import ca.nrc.cadc.util.Log4jInit; -import java.io.File; -import java.net.URI; import org.apache.log4j.Level; import org.apache.log4j.Logger; @@ -91,5 +88,6 @@ public FilesTest() { super(Constants.RESOURCE_ID, Constants.ADMIN_CERT); enableTestDataNodePermission(Constants.ALT_CERT); + enableTestPassthroughParams(true); } } diff --git a/vault/src/main/java/org/opencadc/vault/VaultInitAction.java b/vault/src/main/java/org/opencadc/vault/VaultInitAction.java index 1943f9cf..8ef75be2 100644 --- a/vault/src/main/java/org/opencadc/vault/VaultInitAction.java +++ b/vault/src/main/java/org/opencadc/vault/VaultInitAction.java @@ -476,7 +476,7 @@ private void initBackgroundWorkers() { if (str != null) { boolean enableDataNodeSizeWorker = Boolean.valueOf(str); if (!enableDataNodeSizeWorker) { - log.info("initBackgroundWorkers: DataNodeSizeWorker disabled"); + log.info("initBackgroundWorkers: " + DataNodeSizeSync.class.getSimpleName() + " disabled"); return; } } @@ -505,6 +505,7 @@ private void initBackgroundWorkers() { async.setOffline(offline); this.dataNodeSizeSyncThread = new Thread(async); dataNodeSizeSyncThread.setDaemon(true); + dataNodeSizeSyncThread.setName(DataNodeSizeSync.class.getSimpleName()); dataNodeSizeSyncThread.start(); // store in JNDI so availability can set offline @@ -513,10 +514,10 @@ private void initBackgroundWorkers() { try { ctx.unbind(jndiDataNodeSizeSync); } catch (NamingException ignore) { - log.debug("unbind previous JNDI key (" + jndiPreauthKeys + ") failed... ignoring"); + log.debug("unbind previous JNDI key (" + jndiDataNodeSizeSync + ") failed... ignoring"); } ctx.bind(jndiDataNodeSizeSync, async); - log.info("initBackgroundWorkers: created JNDI key: " + jndiDataNodeSizeSync); + log.info("initBackgroundWorkers: " + DataNodeSizeSync.class.getSimpleName() + " enabled; created JNDI key: " + jndiDataNodeSizeSync); } catch (Exception ex) { throw new RuntimeException("check/init ArtifactSync failed", ex); } diff --git a/vault/src/main/java/org/opencadc/vault/files/GetAction.java b/vault/src/main/java/org/opencadc/vault/files/GetAction.java index 8fc2bca5..7d740d7d 100644 --- a/vault/src/main/java/org/opencadc/vault/files/GetAction.java +++ b/vault/src/main/java/org/opencadc/vault/files/GetAction.java @@ -70,7 +70,9 @@ import ca.nrc.cadc.auth.AuthenticationUtil; import ca.nrc.cadc.net.TransientException; import java.net.HttpURLConnection; -import java.util.List; +import java.net.URI; +import java.net.URLEncoder; +import java.util.Iterator; import javax.security.auth.Subject; import org.apache.log4j.Logger; import org.opencadc.vault.VaultTransferGenerator; @@ -129,9 +131,37 @@ public void doAction() throws Exception { throw new TransientException("No location found for file " + Utils.getPath(node)); } Protocol proto = rn.protos.get(0); - String loc = proto.getEndpoint(); + URI redirect = URI.create(proto.getEndpoint()); + String loc = appendParams(redirect); log.debug("Location: " + loc); syncOutput.setHeader("Location", loc); syncOutput.setCode(HttpURLConnection.HTTP_SEE_OTHER); } + + // pass through request params to minoc + // TODO: this makes slightly better use of the StringBuilder than the code in raven + // should put this method into cadc-inventory-server, static in ProtocolsGenerator? + String appendParams(URI redirect) throws Exception { + StringBuilder sb = new StringBuilder(); + for (String param : syncInput.getParameterNames()) { + Iterator values = syncInput.getParameters(param).iterator(); + while (values.hasNext()) { + if (sb.length() > 0) { + sb.append("&"); + } + sb.append(param); + sb.append("="); + sb.append(URLEncoder.encode(values.next(), "UTF-8")); + } + } + if (sb.length() > 0) { + if (redirect.getQuery() != null) { + sb.insert(0, "&"); + } else { + sb.insert(0, "?"); + } + } + sb.insert(0, redirect.toASCIIString()); + return sb.toString(); + } } diff --git a/vault/src/main/webapp/service.yaml b/vault/src/main/webapp/service.yaml index 0ed9ed7a..99fc22e0 100644 --- a/vault/src/main/webapp/service.yaml +++ b/vault/src/main/webapp/service.yaml @@ -39,6 +39,51 @@ paths: description: Service busy default: description: Unexpected error + parameters: + - name: SUB + in: query + description: 'PROTOTYPE: SUB-region of a FITS file image using cfitsio syntax. Multiple SUB parameters are allowed and will generate MEF output in file order. Examples: entire extensions (SUB=[1]&SUB=[SCI,2]), or more general purpose (SUB=[SCI,3][400:500]).' + required: false + type: string + collectionFormat: multi + - name: POS + in: query + description: The positional regions to be extracted from the data (SODA-1.0). + required: false + type: string + - name: CIRCLE + in: query + description: The spatial region using the CIRCLE xtype defined in DALI (SODA-1.0). + required: false + type: string + - name: POLYGON + in: query + description: The spatial region using the POLYGON xtype defined in DALI (SODA-1.0). + required: false + type: string + - name: BAND + in: query + description: The wavelength interval(s) using the INTERVAL xtype defined in DALI (SODA-1.0). + required: false + type: string + - name: TIME + in: query + description: The time interval(s) using the INTERVAL xtype defined in DALI (SODA-1.0). + required: false + type: string + - name: POL + in: query + type: array + collectionFormat: multi + items: + type: string + description: The polarization state(s) (Stokes), supports multiple values (SODA-1.0). + required: false + - name: META + in: query + description: 'PROTOTYPE: extract METAdata (headers) from a file. A single parameter META=true is supported for FITS files. Output will be a plain text rendition of the headers.' + required: false + type: boolean head: description: | Get the metadata of the specified file.