-
-
Notifications
You must be signed in to change notification settings - Fork 14
Description
While investigating our collection of submission errors in MetacatUI, I discovered that it's possible submit an invalid resource map to Metacat and receive a 200 status without any error. I would expect that resource maps would be validated in the same way that sysmeta and EML objects are.
Here's a reproducible example:
-
Create an invalid resource map. In my case, I saved a
resource_map.xmlfile with the following text:
<?xml version="1.0" encod -
Create sysmeta for the object. I used this
sysmeta_template.rdf.xml:
<d1_v2.0:systemMetadata xmlns:d1_v2.0="http://ns.dataone.org/service/types/v2.0"
xmlns:d1="http://ns.dataone.org/service/types/v1">
<serialVersion>0</serialVersion>
<identifier>RESOURCE MAP ID HERE</identifier>
<formatId>http://www.openarchives.org/ore/terms</formatId>
<size>25</size>
<checksum algorithm="MD5">9614dd15192a58ae2a91a6243e70a992</checksum>
<submitter>http://orcid.org/0000-0002-1615-3963</submitter>
<rightsHolder>http://orcid.org/0000-0002-1615-3963</rightsHolder>
<accessPolicy>
<allow>
<subject>public</subject>
<permission>read</permission>
</allow>
<allow>
<subject>CN=arctic-data-admins,DC=dataone,DC=org</subject>
<permission>read</permission>
<permission>write</permission>
<permission>changePermission</permission>
</allow>
</accessPolicy>
<fileName>resource_map.xml</fileName>
</d1_v2.0:systemMetadata>
You'll want to the submitter to your ORCID
- Generate a PID, update the sysmeta template, then upload the resource map + sysmeta to a test node:
# 1. Set your token
TOKEN="your-token-here"
# 2. Generate the pid
PID="resource_map_urn:uuid:$(uuidgen)"
# 3. Make a copy of the sysmeta with the new PID
cp sysmeta_template.rdf.xml sysmeta.rdf.xml
sed -i '' "s/RESOURCE MAP ID HERE/$PID/" sysmeta.rdf.xml
echo "\nUploading bad resource map with PID: $PID"
echo "\nResource Map:\n"
cat resource_map.xml
echo "\n\nSysmeta:\n"
cat sysmeta.rdf.xml
echo "\n\n\n OUTPUT FROM CURL COMMAND: \n"
/opt/homebrew/opt/curl/bin/curl -i \
-X POST \
-H "Accept: */*" \
-H "Authorization: Bearer $TOKEN" \
-F "pid=$PID" \
-F "sysmeta=@sysmeta.rdf.xml;type=application/xml" \
-F "object=@resource_map.xml;type=application/xml" \
"https://dev.nceas.ucsb.edu/knb/d1/mn/v2/object"
echo "\n\n Done"- See that the server returns a
HTTP/1.1 200 200status along with the the PID for the resource map:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<identifier xmlns="http://ns.dataone.org/service/types/v1">resource_map_urn:uuid:7286F53A-D29B-4087-9CE8-DEE244EEE5F6</identifier>
The file then exists on the server, but of course, is not really a resource map, e.g.
Here's the code above as downloadable files (just remember to remove the .txt).
sysmeta_template.rdf.xml.txt
create_res_map.sh.txt
resource_map.xml.txt