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 059ffe784..7cc2d4cde 100644 --- a/vault/src/intTest/java/org/opencadc/vault/NodesTest.java +++ b/vault/src/intTest/java/org/opencadc/vault/NodesTest.java @@ -67,6 +67,7 @@ package org.opencadc.vault; +import ca.nrc.cadc.util.FileUtil; import ca.nrc.cadc.util.Log4jInit; import java.net.URI; import org.apache.log4j.Level; @@ -87,6 +88,10 @@ 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"); + enablePermissionTests(new GroupURI(URI.create("ivo://cadc.nrc.ca/gms?opencadc-vospace-test")), + FileUtil.getFileFromResource("vault-auth-test.pem", NodesTest.class)); + // vault does not check the actual groups in the permission props tests, hence they can be made up. + enablePermissionPropsTest(new GroupURI(URI.create("ivo://myauth/gms?gr1")), new GroupURI(URI.create("ivo://myauth/gms?gr2"))); } } diff --git a/vault/src/main/java/org/opencadc/vault/NodePersistenceImpl.java b/vault/src/main/java/org/opencadc/vault/NodePersistenceImpl.java index 63bf5ec96..a9784731b 100644 --- a/vault/src/main/java/org/opencadc/vault/NodePersistenceImpl.java +++ b/vault/src/main/java/org/opencadc/vault/NodePersistenceImpl.java @@ -99,13 +99,14 @@ import org.opencadc.inventory.db.SQLGenerator; import org.opencadc.vospace.ContainerNode; import org.opencadc.vospace.DataNode; -import org.opencadc.vospace.LinkNode; import org.opencadc.vospace.Node; import org.opencadc.vospace.NodeNotSupportedException; import org.opencadc.vospace.NodeProperty; import org.opencadc.vospace.VOS; import org.opencadc.vospace.db.NodeDAO; import org.opencadc.vospace.server.NodePersistence; +import org.opencadc.vospace.server.Views; +import org.opencadc.vospace.server.transfers.TransferGenerator; /** * @@ -243,6 +244,16 @@ public Set getImmutableProps() { return immutableProps; } + @Override + public Views getViews() { + throw new UnsupportedOperationException("TODO"); + } + + @Override + public TransferGenerator getTransferGenerator() { + throw new UnsupportedOperationException("TODO"); + } + /** * Get a node by name. Concept: The caller uses this to navigate the path * from the root node to the target, checking permissions and deciding what diff --git a/vault/src/main/java/org/opencadc/vault/RecursiveDeleteNodeJobManager.java b/vault/src/main/java/org/opencadc/vault/RecursiveDeleteNodeJobManager.java new file mode 100644 index 000000000..b438dbeaa --- /dev/null +++ b/vault/src/main/java/org/opencadc/vault/RecursiveDeleteNodeJobManager.java @@ -0,0 +1,113 @@ +/* +************************************************************************ +******************* CANADIAN ASTRONOMY DATA CENTRE ******************* +************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** +* +* (c) 2023. (c) 2023. +* Government of Canada Gouvernement du Canada +* National Research Council Conseil national de recherches +* Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 +* All rights reserved Tous droits réservés +* +* NRC disclaims any warranties, Le CNRC dénie toute garantie +* expressed, implied, or énoncée, implicite ou légale, +* statutory, of any kind with de quelque nature que ce +* respect to the software, soit, concernant le logiciel, +* including without limitation y compris sans restriction +* any warranty of merchantability toute garantie de valeur +* or fitness for a particular marchande ou de pertinence +* purpose. NRC shall not be pour un usage particulier. +* liable in any event for any Le CNRC ne pourra en aucun cas +* damages, whether direct or être tenu responsable de tout +* indirect, special or general, dommage, direct ou indirect, +* consequential or incidental, particulier ou général, +* arising from the use of the accessoire ou fortuit, résultant +* software. Neither the name de l'utilisation du logiciel. Ni +* of the National Research le nom du Conseil National de +* Council of Canada nor the Recherches du Canada ni les noms +* names of its contributors may de ses participants ne peuvent +* be used to endorse or promote être utilisés pour approuver ou +* products derived from this promouvoir les produits dérivés +* software without specific prior de ce logiciel sans autorisation +* written permission. préalable et particulière +* par écrit. +* +* This file is part of the Ce fichier fait partie du projet +* OpenCADC project. OpenCADC. +* +* OpenCADC is free software: OpenCADC est un logiciel libre ; +* you can redistribute it and/or vous pouvez le redistribuer ou le +* modify it under the terms of modifier suivant les termes de +* the GNU Affero General Public la “GNU Affero General Public +* License as published by the License” telle que publiée +* Free Software Foundation, par la Free Software Foundation +* either version 3 of the : soit la version 3 de cette +* License, or (at your option) licence, soit (à votre gré) +* any later version. toute version ultérieure. +* +* OpenCADC is distributed in the OpenCADC est distribué +* hope that it will be useful, dans l’espoir qu’il vous +* but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE +* without even the implied GARANTIE : sans même la garantie +* warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ +* or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF +* PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence +* General Public License for Générale Publique GNU Affero +* more details. pour plus de détails. +* +* You should have received Vous devriez avoir reçu une +* a copy of the GNU Affero copie de la Licence Générale +* General Public License along Publique GNU Affero avec +* with OpenCADC. If not, see OpenCADC ; si ce n’est +* . pas le cas, consultez : +* . +* +* $Revision: 4 $ +* +************************************************************************ +*/ + +package org.opencadc.vault; + +import ca.nrc.cadc.auth.AuthenticationUtil; +import ca.nrc.cadc.uws.server.JobExecutor; +import ca.nrc.cadc.uws.server.JobPersistence; +import ca.nrc.cadc.uws.server.JobUpdater; +import ca.nrc.cadc.uws.server.SimpleJobManager; +import ca.nrc.cadc.uws.server.ThreadPoolExecutor; +import ca.nrc.cadc.uws.server.impl.PostgresJobPersistence; +import org.apache.log4j.Logger; +import org.opencadc.vospace.server.async.RecursiveDeleteNodeRunner; + +/** + * + * @author pdowler, majorb, yeunga, adriand + */ +public class RecursiveDeleteNodeJobManager extends SimpleJobManager { + private static final Logger log = Logger.getLogger(RecursiveDeleteNodeJobManager.class); + + private static final Long MAX_EXEC_DURATION = Long.valueOf(12 * 7200L); // 24 hours? + private static final Long MAX_DESTRUCTION = Long.valueOf(7 * 24 * 3600L); // 1 week + private static final Long MAX_QUOTE = Long.valueOf(12 * 7200L); // same as exec + + protected static JobPersistence jp; + + static { + log.info("Creating shared (postgres) job manager"); + jp = new PostgresJobPersistence(AuthenticationUtil.getIdentityManager()); + } + + public RecursiveDeleteNodeJobManager() { + super(); + // jp is instantiated in parent org.opencadc.cavern.JobManager + JobUpdater ju = jp; + super.setJobPersistence(jp); + + JobExecutor jobExec = new ThreadPoolExecutor(ju, RecursiveDeleteNodeRunner.class, 3); + super.setJobExecutor(jobExec); + + super.setMaxExecDuration(MAX_EXEC_DURATION); + super.setMaxDestruction(MAX_DESTRUCTION); + super.setMaxQuote(MAX_QUOTE); + } +} diff --git a/vault/src/main/java/org/opencadc/vault/VaultInitAction.java b/vault/src/main/java/org/opencadc/vault/VaultInitAction.java index bc9dc89f5..b33bb9d87 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,8 +218,22 @@ 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"; + jndiNodePersistence = appName + "-" + NodePersistence.class.getName(); try { Context ctx = new InitialContext(); try { diff --git a/vault/src/main/resources/VOSpacePlugins.properties b/vault/src/main/resources/VOSpacePlugins.properties new file mode 100644 index 000000000..7d3e00421 --- /dev/null +++ b/vault/src/main/resources/VOSpacePlugins.properties @@ -0,0 +1,12 @@ +# +# Configuration information for the vospace storage interface +# + +# Define the class that implements the interface TransferGenerator +# This class will be loaded at runtime to handle transfer requests. +# ca.nrc.cadc.vos.transfers.TransferGenerator = +ca.nrc.cadc.vos.server.transfers.TransferGenerator = ca.nrc.cadc.vospace.transfers.ADTransferGenerator + +# Define an optional class that implements the interface NodePersistence +# This class will be loaded at runtime to node persistence operations. +ca.nrc.cadc.vos.server.NodePersistence = ca.nrc.cadc.vospace.VOSpaceNodePersistence \ No newline at end of file diff --git a/vault/src/main/resources/Views.properties b/vault/src/main/resources/Views.properties new file mode 100644 index 000000000..cde5e1e1b --- /dev/null +++ b/vault/src/main/resources/Views.properties @@ -0,0 +1,72 @@ +############################################################################### +# +# Views.properties +# +# Defines the views available in this instance of VOSpace. These are loaded +# upon the loading of class ca.nrc.cadc.vos.ViewFactory into the VM. +# +# The names of the views to be defined must be listed under the 'views' key +# and separated by a space. For example: +# views = ... +# +# For each view name listed, three settings must be defined +# uri = The URI of the view +# alias = The alias (or shortcut) name of the view +# class = The implementing class of the view +# +# Additionally, two optional settings may be defined: +# accepts = true/false, true if this services accepts the view +# provides = true/false, true if this service provides the view +# +# For example: +# .uri = ivo://cadc.nrc.ca/vospace/core#dataview +# .alias = data +# .class = ca.nrc.cadc.vos.DataView +# .accepts = false +# .provides = true +# +# Notes: +# - View classes must extend class ca.nrc.cadc.vos.AbstractView +# - There cannot be a duplicate of any aliases or URIs in any of the +# view definitions +# +############################################################################### + +#views = data rss manifest cutout header +views = data + +# data view definition +data.uri = ivo://cadc.nrc.ca/vospace/view#data +data.alias = data +data.class = org.opencadc.vospace.server.DataView +data.accepts = false +data.provides = true + +# rss view definition +rss.uri = ivo://cadc.nrc.ca/vospace/view#rss +rss.alias = rss +rss.class = ca.nrc.cadc.vos.server.RssView +rss.accepts = false +rss.provides = true + +# manifest view definition +manifest.uri = ivo://cadc.nrc.ca/vospace/view#manifest +manifest.alias = manifest +manifest.class = ca.nrc.cadc.vos.server.ManifestView +manifest.accepts = false +manifest.provides = true + +# cutout view definition +cutout.uri = ivo://cadc.nrc.ca/vospace/view#cutout +cutout.alias = cutout +cutout.class = ca.nrc.cadc.vospace.CutoutView +cutout.accepts = false +cutout.provides = true + +# header view definition +header.uri = ivo://cadc.nrc.ca/vospace/view#header +header.alias = header +header.class = ca.nrc.cadc.vospace.HeaderView +header.accepts = false +header.provides = true + 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 + + + + + + +