From dec5ed8b358195a1576a65d69ea66116cb3870af Mon Sep 17 00:00:00 2001 From: Adrian Damian Date: Fri, 6 Oct 2023 16:06:05 -0700 Subject: [PATCH] Support for recursive deletes --- vault/build.gradle | 6 ++-- .../java/org/opencadc/vault/NodesTest.java | 2 ++ .../org/opencadc/vault/VaultInitAction.java | 17 +++++++++++ vault/src/main/webapp/META-INF/context.xml | 13 ++++++++ vault/src/main/webapp/WEB-INF/web.xml | 30 +++++++++++++++++++ vault/src/main/webapp/capabilities.xml | 10 +++++++ 6 files changed, 75 insertions(+), 3 deletions(-) diff --git a/vault/build.gradle b/vault/build.gradle index 86b736b0c..7fd069259 100644 --- a/vault/build.gradle +++ b/vault/build.gradle @@ -30,7 +30,7 @@ def git_url = 'https://github.com/opencadc/vos' dependencies { compile 'javax.servlet:javax.servlet-api:[3.1,4.0)' - compile 'org.opencadc:cadc-util:[1.9.5,2.0)' + compile 'org.opencadc:cadc-util:[1.9.10,2.0)' compile 'org.opencadc:cadc-log:[1.1.6,2.0)' compile 'org.opencadc:cadc-gms:[1.0.5,)' compile 'org.opencadc:cadc-rest:[1.3.16,)' @@ -38,10 +38,10 @@ dependencies { compile 'org.opencadc:cadc-vos-server-alt:[2.0,)' compile 'org.opencadc:cadc-vosi:[1.3.2,)' compile 'org.opencadc:cadc-uws:[1.0,)' - compile 'org.opencadc:cadc-uws-server:[1.2.12,)' + compile 'org.opencadc:cadc-uws-server:[1.2.19,)' compile 'org.opencadc:cadc-access-control:[1.1.1,2.0)' compile 'org.opencadc:cadc-cdp:[1.2.3,)' - compile 'org.opencadc:cadc-registry:[1.5.15,)' + compile 'org.opencadc:cadc-registry:[1.7.4,)' compile 'org.opencadc:cadc-inventory:[0.9.4,1.0)' compile 'org.opencadc:cadc-inventory-db:[0.15.0,1.0)' diff --git a/vault/src/intTest/java/org/opencadc/vault/NodesTest.java b/vault/src/intTest/java/org/opencadc/vault/NodesTest.java index 71bb1178b..2a4a317da 100644 --- a/vault/src/intTest/java/org/opencadc/vault/NodesTest.java +++ b/vault/src/intTest/java/org/opencadc/vault/NodesTest.java @@ -71,6 +71,7 @@ import java.net.URI; import org.apache.log4j.Level; import org.apache.log4j.Logger; +import org.opencadc.gms.GroupURI; /** * Test the nodes endpoint. @@ -86,6 +87,7 @@ public class NodesTest extends org.opencadc.conformance.vos.NodesTest { } public NodesTest() { + //super(URI.create("ivo://opencadc.org/vault"), "vault-test.pem", new GroupURI(URI.create("ivo://cadc.nrc.ca/gms?CADC_TEST_GROUP2")), "vault-test-auth.pem"); super(URI.create("ivo://opencadc.org/vault"), "vault-test.pem"); } } diff --git a/vault/src/main/java/org/opencadc/vault/VaultInitAction.java b/vault/src/main/java/org/opencadc/vault/VaultInitAction.java index bc9dc89f5..c22083be8 100644 --- a/vault/src/main/java/org/opencadc/vault/VaultInitAction.java +++ b/vault/src/main/java/org/opencadc/vault/VaultInitAction.java @@ -71,6 +71,7 @@ import ca.nrc.cadc.rest.InitAction; import ca.nrc.cadc.util.MultiValuedProperties; import ca.nrc.cadc.util.PropertiesReader; +import ca.nrc.cadc.uws.server.impl.InitDatabaseUWS; import java.net.URI; import java.net.URISyntaxException; import java.util.Map; @@ -93,6 +94,7 @@ public class VaultInitAction extends InitAction { private static final Logger log = Logger.getLogger(VaultInitAction.class); static final String JNDI_DATASOURCE = "jdbc/nodes"; // context.xml + static final String JNDI_UWS_DATASOURCE = "jdbc/uws"; // context.xml // config keys private static final String VAULT_KEY = "org.opencadc.vault"; @@ -119,6 +121,7 @@ public VaultInitAction() { public void doInit() { initConfig(); initDatabase(); + initUWSDatabase(); initNodePersistence(); } @@ -215,6 +218,20 @@ private void initDatabase() { } } + private void initUWSDatabase() { + log.info("initUWSDatabase: START"); + try { + // Init UWS database + DataSource uws = DBUtil.findJNDIDataSource(JNDI_UWS_DATASOURCE); + InitDatabaseUWS uwsi = new InitDatabaseUWS(uws, null, "uws"); + uwsi.doInit(); + log.info("initDatabase: " + JNDI_UWS_DATASOURCE + " uws OK"); + + } catch (Exception ex) { + throw new RuntimeException("check/init uws database failed", ex); + } + } + protected void initNodePersistence() { jndiNodePersistence = componentID + ".nodePersistence"; try { diff --git a/vault/src/main/webapp/META-INF/context.xml b/vault/src/main/webapp/META-INF/context.xml index cbc72f2e0..e5775723b 100644 --- a/vault/src/main/webapp/META-INF/context.xml +++ b/vault/src/main/webapp/META-INF/context.xml @@ -15,4 +15,17 @@ removeAbandoned="false" testOnBorrow="true" validationQuery="select 123" /> + + + diff --git a/vault/src/main/webapp/WEB-INF/web.xml b/vault/src/main/webapp/WEB-INF/web.xml index af0394c10..90476792e 100644 --- a/vault/src/main/webapp/WEB-INF/web.xml +++ b/vault/src/main/webapp/WEB-INF/web.xml @@ -23,6 +23,7 @@ ca.nrc.cadc.rest ca.nrc.cadc.util ca.nrc.cadc.vosi + ca.nrc.cadc.uws @@ -62,6 +63,30 @@ 2 + + + RecursiveDeleteNodeServlet + ca.nrc.cadc.uws.server.JobServlet + + get + ca.nrc.cadc.uws.web.GetAction + + + post + ca.nrc.cadc.uws.web.PostAction + + + delete + ca.nrc.cadc.uws.web.DeleteAction + + + ca.nrc.cadc.uws.server.JobManager + org.opencadc.vault.RecursiveDeleteNodeJobManager + + 3 + + + CapabilitiesServlet @@ -107,6 +132,11 @@ /nodes/* + + RecursiveDeleteNodeServlet + /recursiveDelete/* + + AvailabilityServlet diff --git a/vault/src/main/webapp/capabilities.xml b/vault/src/main/webapp/capabilities.xml index fb145630e..d24f1a220 100644 --- a/vault/src/main/webapp/capabilities.xml +++ b/vault/src/main/webapp/capabilities.xml @@ -41,6 +41,16 @@ + + + https://replace.me.com/vault/recursiveDelete + + + + + + +