Skip to content

Commit

Permalink
reg: added example-content and tweaked OAIValidityTest
Browse files Browse the repository at this point in the history
test expects the example content to be deployed
  • Loading branch information
pdowler committed Apr 19, 2024
1 parent a5fc47d commit 1ac3203
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 11 deletions.
49 changes: 49 additions & 0 deletions reg/example-content/Identify.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<Identify>
<repositoryName>Example Repository</repositoryName>
<baseURL>https://www.example.net/reg/oai</baseURL>
<protocolVersion>2.0</protocolVersion>
<adminEmail>support@example.net</adminEmail>
<earliestDatestamp>2000-01-01T00:00:00Z</earliestDatestamp>
<deletedRecord>persistent</deletedRecord>
<granularity>YYYY-MM-DDThh:mm:ssZ</granularity>
<description>
<ri:Resource created="2020-01-02T03:04:05Z" status="active" updated="2020-01-02T03:04:05Z"
xmlns:ri="http://www.ivoa.net/xml/RegistryInterface/v1.0"
xmlns:vg="http://www.ivoa.net/xml/VORegistry/v1.0"
xmlns:vr="http://www.ivoa.net/xml/VOResource/v1.0"
xmlns:vs="http://www.ivoa.net/xml/VODataService/v1.1"
xsi:type="vg:Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<title >Example Registry</title>
<shortName>Example Registry</shortName>
<identifier>ivo://example.net/registry</identifier>
<curation xmlns="">
<publisher>Example Data Provider</publisher>
<contact>
<name>Responsible Person</name>
<address>Center of the Universe</address>
<email>responsible.person@example.net</email>
</contact>
</curation>
<content>
<subject>registry</subject>
<description>Example Registry</description>
<referenceURL>https://www.example.net/reg</referenceURL>
<type>Registry</type>
</content>
<capability standardID="ivo://ivoa.net/std/VOSI#capabilities">
<interface xsi:type="vs:ParamHTTP" role="std">
<accessURL use="full">https://www.example.net/reg/capabilities</accessURL>
</interface>
</capability>
<capability standardID="ivo://ivoa.net/std/Registry" xsi:type="vg:Harvest">
<interface role="std" xsi:type="vg:OAIHTTP">
<accessURL>https://www.example.net/reg/oai</accessURL>
</interface>
<maxRecords>100</maxRecords>
</capability>
<full>false</full>
<managedAuthority xmlns="">example.net</managedAuthority>
</ri:Resource>
</description>
</Identify>
15 changes: 15 additions & 0 deletions reg/example-content/ListMetadataFormats.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<ListMetadataFormats>
<metadataFormat>
<metadataPrefix>ivo_vor</metadataPrefix>
<schema>http://www.ivoa.net/xml/VOResource/v1.0</schema>
<metadataNamespace>http://www.ivoa.net/xml/VOResource/v1.0</metadataNamespace>
</metadataFormat>
<!-- currently unsupported so not fully OAI compliant
<metadataFormat>
<metadataPrefix>oai_dc</metadataPrefix>
<schema>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</schema>
<metadataNamespace>http://www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace>
</metadataFormat>
-->
</ListMetadataFormats>
7 changes: 7 additions & 0 deletions reg/example-content/ListSets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ListSets>
<set>
<setSpec>ivo_managed</setSpec>
<setName>ivo_managed</setName>
</set>
</ListSets>
28 changes: 28 additions & 0 deletions reg/example-content/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# example registry content

This example is for the _authority_ named `example.net`. To expose this content
and run the integration tests, the `reg` service needs to be configured with
```
org.opencadc.reg.authority = example.net
```
and the remaining files must be included in `/config/content` of the container.

## Identify.xml and example.net/registry.xml
These two files describe the registry itself. It's the same VOResource
record inside a different OAI _envelope_.

## example.net.xml
This file is the authority record.

## ListMetadataFormats.xml and ListSets.xml
These are static responses to OAI queries and can be used as-is.

## example.net
This directory contains records for all the resources to be published. In this
example there is only the registry record itself, but other files can be added.

If resource identifiers (`ivo://{authority}/{name}`) have multiple path components,
those should be reflected in the structure under the _authority_ directory.

For example, the `ivo://example.net/registry` record is in `example.net/registry.xml`
and the `ivo://example.net/foo/bar` record would be in `example.net/foo/bar.xml`.
38 changes: 38 additions & 0 deletions reg/example-content/example.net.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<GetRecord>
<record>
<header>
<identifier>ivo://example.net</identifier>
<datestamp>2020-01-02T03:04:05Z</datestamp>
<setSpec>ivo_managed</setSpec>
</header>
<metadata>
<ri:Resource created="2020-01-02T03:04:05Z" status="active"
updated="2020-01-02T03:04:05Z"
xmlns:ri="http://www.ivoa.net/xml/RegistryInterface/v1.0"
xmlns:vg="http://www.ivoa.net/xml/VORegistry/v1.0"
xmlns:vr="http://www.ivoa.net/xml/VOResource/v1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="vg:Authority" >
<title xmlns="">Example Data Provider</title>
<shortName xmlns="">EG</shortName>
<identifier xmlns="">ivo://example.net</identifier>
<curation xmlns="">
<publisher>Example Data Provider</publisher>
<contact>
<name>Responsible Person</name>
<address>Center of the Universe</address>
<email>responsible.person@example.net</email>
</contact>
</curation>
<content xmlns="">
<subject>virtual observatory</subject>
<description>authority for EG</description>
<referenceURL>https://www.example.net/</referenceURL>
<type>Other</type>
<contentLevel>General</contentLevel>
</content>
<managingOrg xmlns="">Example Data Provider</managingOrg>
</ri:Resource>
</metadata>
</record>
</GetRecord>
10 changes: 10 additions & 0 deletions reg/example-content/example.net/deleted.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<GetRecord>
<record>
<header status="deleted">
<identifier>ivo://example.net/deleted</identifier>
<datestamp>2021-01-02T03:04:05Z</datestamp>
<setSpec>ivo_managed</setSpec>
</header>
</record>
</GetRecord>
50 changes: 50 additions & 0 deletions reg/example-content/example.net/registry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<GetRecord>
<record>
<header>
<identifier>ivo://example.net/registry</identifier>
<datestamp>2020-01-02T03:04:05Z</datestamp>
<setSpec>ivo_managed</setSpec>
</header>
<metadata>
<ri:Resource created="2020-01-02T03:04:05Z" status="active"
updated="2020-01-02T03:04:05Z"
xmlns:ri="http://www.ivoa.net/xml/RegistryInterface/v1.0"
xmlns:vg="http://www.ivoa.net/xml/VORegistry/v1.0"
xmlns:vr="http://www.ivoa.net/xml/VOResource/v1.0"
xmlns:vs="http://www.ivoa.net/xml/VODataService/v1.1" xsi:type="vg:Registry"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<title>Example Registry</title>
<shortName>Example Registry</shortName>
<identifier>ivo://example.net/registry</identifier>
<curation>
<publisher>Example Data Provider</publisher>
<contact>
<name>Responsible Person</name>
<address>Center of the Universe</address>
<email>responsible.person@example.net</email>
</contact>
</curation>
<content>
<subject>registry</subject>
<description>Example Registry</description>
<referenceURL>https://example.net/reg</referenceURL>
<type>Registry</type>
</content>
<capability standardID="ivo://ivoa.net/std/VOSI#capabilities">
<interface xsi:type="vs:ParamHTTP" role="std">
<accessURL use="full">https://example.net/reg/capabilities</accessURL>
</interface>
</capability>
<capability standardID="ivo://ivoa.net/std/Registry" xsi:type="vg:Harvest">
<interface role="std" xsi:type="vg:OAIHTTP">
<accessURL>https://example.net/reg/oai</accessURL>
</interface>
<maxRecords>100</maxRecords>
</capability>
<full>false</full>
<managedAuthority>example.net</managedAuthority>
</ri:Resource>
</metadata>
</record>
</GetRecord>
20 changes: 9 additions & 11 deletions reg/src/intTest/java/org/opencadc/reg/OAIValidityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@

package org.opencadc.reg;

import ca.nrc.cadc.auth.AuthMethod;
import ca.nrc.cadc.net.HttpDownload;
import ca.nrc.cadc.reg.Capabilities;
import ca.nrc.cadc.reg.Capability;
import ca.nrc.cadc.reg.Interface;
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.RegistryClient;
import ca.nrc.cadc.util.Log4jInit;
import java.io.ByteArrayOutputStream;
import java.io.StringReader;
Expand All @@ -97,14 +95,11 @@
public class OAIValidityTest {
private static final Logger log = Logger.getLogger(OAIValidityTest.class);

private static final List<String> DELETED_RESOURCES = new ArrayList<String>();
private static final String DELETED_RESOURCE = "ivo://example.net/deleted";

static {
Log4jInit.setLevel("org.opencadc.reg.server", Level.INFO);
Log4jInit.setLevel("org.opencadc.reg", Level.INFO);
Log4jInit.setLevel("ca.nrc.cadc.reg", Level.INFO);
DELETED_RESOURCES.add("ivo://cadc.nrc.ca/hips2");
DELETED_RESOURCES.add("ivo://cadc.nrc.ca/tap");
DELETED_RESOURCES.add("ivo://cadc.nrc.ca/vospace");
}

final URL oaiEndpoint;
Expand Down Expand Up @@ -234,7 +229,7 @@ public void testListIdentifiers() {
log.info("testListIdentifiers: " + id + " status: " + status);
Assert.assertNotNull(id);

if (DELETED_RESOURCES.contains(id)) {
if (DELETED_RESOURCE.equals(id)) {
Assert.assertEquals("deleted", status);
} else {
Assert.assertNull(status);
Expand Down Expand Up @@ -277,7 +272,10 @@ public void testListIdentifiersEmpty() {
@Test
public void testListIdentifiersFromUntil() {
try {
URL u = new URL(oaiEndpoint.toExternalForm() + "?verb=ListIdentifiers&metadataPrefix=ivo_vor&from=2019-06-15T21:15:10Z&until=2019-06-15T21:15:20Z");
String from = "2020-01-01T00:00:00Z";
String until = "2020-02-02T00:00:00Z";
URL u = new URL(oaiEndpoint.toExternalForm() + "?verb=ListIdentifiers&metadataPrefix=ivo_vor"
+ "&from=" + from + "&until=" + until);
log.info(u.toExternalForm());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
HttpDownload get = new HttpDownload(u, bos);
Expand All @@ -304,7 +302,7 @@ public void testListIdentifiersFromUntil() {
@Test
public void testGetRecord() {
try {
URL u = new URL(oaiEndpoint.toExternalForm() + "?verb=GetRecord&metadataPrefix=ivo_vor&identifier=ivo://cadc.nrc.ca/argus");
URL u = new URL(oaiEndpoint.toExternalForm() + "?verb=GetRecord&metadataPrefix=ivo_vor&identifier=ivo://example.net/registry");
log.info(u.toExternalForm());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
HttpDownload get = new HttpDownload(u, bos);
Expand Down Expand Up @@ -348,7 +346,7 @@ public void testGetRecord() {
@Test
public void testGetDeletedRecord() {
try {
URL u = new URL(oaiEndpoint.toExternalForm() + "?verb=GetRecord&metadataPrefix=ivo_vor&identifier=ivo://cadc.nrc.ca/tap");
URL u = new URL(oaiEndpoint.toExternalForm() + "?verb=GetRecord&metadataPrefix=ivo_vor&identifier=" + DELETED_RESOURCE);
log.info(u.toExternalForm());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
HttpDownload get = new HttpDownload(u, bos);
Expand Down

0 comments on commit 1ac3203

Please sign in to comment.