diff --git a/ezidapp/migrations/0001_initial.py b/ezidapp/migrations/0001_initial.py index 6b279fed4..766383cb9 100644 --- a/ezidapp/migrations/0001_initial.py +++ b/ezidapp/migrations/0001_initial.py @@ -492,17 +492,31 @@ class Migration(migrations.Migration): editable=False, choices=[ (b'A', b'Audiovisual'), + (b'B', b'Book'), + (b'Bc', b'BookChapter'), (b'C', b'Collection'), + (b'Cn', b'ComputationalNotebook'), + (b'Cp', b'ConferencePaper'), + (b'Cpr', b'ConferenceProceeding'), + (b'Dp', b'DataPaper'), (b'D', b'Dataset'), + (b'Di', b'Dissertation'), (b'E', b'Event'), (b'Im', b'Image'), (b'In', b'InteractiveResource'), + (b'J', b'Journal'), + (b'Ja', b'JournalArticle'), (b'M', b'Model'), + (b'O', b'OutputManagementPlan'), + (b'Pr', b'PeerReview'), (b'Z', b'Other'), (b'P', b'PhysicalObject'), + (b'Pre', b'Preprint'), + (b'R', b'Report'), (b'Se', b'Service'), (b'So', b'Software'), (b'Su', b'Sound'), + (b'St', b'Standard'), (b'T', b'Text'), (b'W', b'Workflow'), ], diff --git a/ezidapp/models/validation.py b/ezidapp/models/validation.py index 915641779..07125ec99 100644 --- a/ezidapp/models/validation.py +++ b/ezidapp/models/validation.py @@ -153,16 +153,30 @@ def publicationDate(date): resourceTypes = { "Audiovisual": "A", + "Book": "B", + "BookChapter": "Bc", "Collection": "C", + "ComputationalNotebook": "Cn", + "ConferencePaper": "Cp", + "ConferenceProceeding": "Cpr", + "DataPaper": "Dp", "Dataset": "D", + "Dissertation": "Di", "Event": "E", "Image": "Im", "InteractiveResource": "In", + "Journal": "J", + "JournalArticle": "Ja", "Model": "M", + "OutputManagementPlan": "O", + "PeerReview": "Pr", "PhysicalObject": "P", + "Preprint": "Pre", + "Report": "R", "Service": "Se", "Software": "So", "Sound": "Su", + "Standard": "St", "Text": "T", "Workflow": "W", "Other": "Z", diff --git a/impl/ezid.py b/impl/ezid.py index 13b113073..2ede5e9e9 100644 --- a/impl/ezid.py +++ b/impl/ezid.py @@ -17,6 +17,7 @@ import uuid import django.core.exceptions +import django.conf import django.db.transaction import django.db.utils @@ -207,10 +208,13 @@ def _mintIdentifier(shoulder, user, metadata={}): identifier = minter.mint_id(shoulder_model) logger.debug('Minter returned identifier: {}'.format(identifier)) + # proto super shoulder check + prefix_val = django.conf.settings.PROTO_SUPER_SHOULDER.get(shoulder_model.prefix, shoulder_model.prefix) + if shoulder_model.prefix.startswith('doi:'): - identifier = shoulder_model.prefix + identifier.upper() + identifier = prefix_val + identifier.upper() elif shoulder_model.prefix.startswith('ark:/'): - identifier = shoulder_model.prefix + identifier.lower() + identifier = prefix_val + identifier.lower() else: raise False, 'Expected ARK or DOI prefix, not "{}"'.format( shoulder_model.prefix diff --git a/impl/form_objects.py b/impl/form_objects.py index 67679b23d..053175ee5 100644 --- a/impl/form_objects.py +++ b/impl/form_objects.py @@ -40,16 +40,30 @@ RESOURCE_TYPES = ( ('', _("Select a type of object")), ('Audiovisual', _('Audiovisual')), + ('Book', _('Book')), + ('BookChapter', _('Book Chapter')), ('Collection', _('Collection')), + ('ComputationalNotebook', _('Computational Notebook')), + ('Conference Paper', _('Conference Paper')), + ('ConferenceProceeding', _('Conference Proceeding')), + ('DataPaper', _('Data Paper')), ('Dataset', _('Dataset')), + ('Dissertation', _('Dissertation')), ('Event', _('Event')), ('Image', _('Image')), ('InteractiveResource', _('Interactive Resource')), + ('Journal', _('Journal')), + ('JournalArticle', _('Journal Article')), ('Model', _('Model')), + ('OutputManagementPlan', _('Output Management Plan')), + ('PeerReview', _('Peer Review')), ('PhysicalObject', _('Physical Object')), + ('Preprint', _('Preprint')), + ('Report', _('Report')), ('Service', _('Service')), ('Software', _('Software')), - ('Sound', _('Sound')), + ('Standard', _('Standard')), + ('BookChapter', _('Book Chapter')), ('Text', _('Text')), ('Workflow', _('Workflow')), ('Other', _('Other')), diff --git a/impl/nog/minter.py b/impl/nog/minter.py index ae0a8488c..333304b57 100755 --- a/impl/nog/minter.py +++ b/impl/nog/minter.py @@ -430,4 +430,4 @@ def drand(self): self.state = (25214903917 * self.state + 11) & (2 ** 48 - 1) rnd = self.state / 2 ** 48 # log.debug("drand48 value={}".format(rnd)) - return rnd + return rnd \ No newline at end of file diff --git a/settings/common.py b/settings/common.py index fab8c4e34..dfd61c922 100644 --- a/settings/common.py +++ b/settings/common.py @@ -160,6 +160,14 @@ ("DATABASES", "search", "PORT"), ] +PROTO_SUPER_SHOULDER ={ + "doi:10.7286/":"doi:10.7286/V1", # doi:10.7286/ + "doi:10.4246/":"doi:10.4246/P6", # doi:10.4246/ + "ark:/88435/":"ark:/88435/dc", # ark:/88435/ + "doi:10.15697/":"doi:10.15697/FK2", # doi:10.15697/ + "ark:/12345/":"ark:/12345/fk8", # ark:/12345/ +} + def injectSecrets(deploymentLevel): import config_loader diff --git a/templates/doc/apidoc.2.html b/templates/doc/apidoc.2.html index 44c4f394d..151f8ed99 100644 --- a/templates/doc/apidoc.2.html +++ b/templates/doc/apidoc.2.html @@ -177,17 +177,17 @@
-import base64, urllib2 -r = urllib2.Request("https://ezid.cdlib.org/...") +import base64, urllib.request, urllib.error, urllib.parse +r = urllib.request..Request("https://ezid.cdlib.org/...") r.add_header("Authorization", "Basic " + base64.b64encode("username:password"))
But most programming libraries provide higher-level support for authentication. For example, Python provides HTTPBasicAuthHandler:
-import urllib2 -h = urllib2.HTTPBasicAuthHandler() +import urllib.request, urllib.error, urllib.parse +h = urllib.request.HTTPBasicAuthHandler() h.add_password("EZID", "https://ezid.cdlib.org/", "username", "password") -o = urllib2.build_opener(h) +o = urllib.request.build_opener(h) o.open("https://ezid.cdlib.org/...")
The downside of using higher-level authentication mechanisms is @@ -241,11 +241,11 @@
In Python, cookies can be managed using cookielib , or manually captured and set using code similar to the following:
-import urllib2 -c = urllib2.urlopen("https://ezid.cdlib.org/login") +import urllib.request, urllib.error, urllib.parse +c = urllib.request.urlopen("https://ezid.cdlib.org/login") cookie = c.headers["Set-Cookie"].split(";")[0] ... -r = urllib2.Request("https://ezid.cdlib.org/...") +r = urllib.request.Request("https://ezid.cdlib.org/...") r.add_header("Cookie", cookie)
In Java, cookies can be manually captured and set using code @@ -319,7 +319,7 @@
Conversely, to parse a UTF-8 encoded string, anvl, producing a dictionary, metadata:
@@ -1360,13 +1360,13 @@ezid.py is a command line tool, written in Python, +
ezid3.py is a command line tool, written in Python, that is capable of exercising all API functions. It serves as an example of how to use the API from Python, but it's also useful in its own right as an easy, scriptable means of accessing EZID functionality. The general usage is:
-% ezid.py credentials operation [arguments...] +% ezid3.py credentials operation [arguments...]
Run the tool with no command line arguments for a complete usage statement; additional documentation is in the source code. To give a @@ -1374,13 +1374,13 @@
To mint a test ARK identifier and supply initial metadata:
-% ezid.py username:password mint ark:/99999/fk4 erc.who 'Proust, Marcel' \ +% ezid3.py username:password mint ark:/99999/fk4 erc.who 'Proust, Marcel' \ erc.what 'Remembrance of Things Past' erc.when 1922 success: ark:/99999/fk4gt78tq
To get identifier metadata:
-% ezid.py -dt - view ark:/99999/fk4gt78tq +% ezid3.py -dt - view ark:/99999/fk4gt78tq success: ark:/99999/fk4gt78tq _created: 2013-05-17T18:17:14 _export: yes @@ -1407,7 +1407,7 @@Python command line tool
Then a test ARK identifier with that metadata can be minted by invoking:
-% ezid.py username:password mint ark:/99999/fk4 @ metadata.txt +% ezid3.py username:password mint ark:/99999/fk4 @ metadata.txtAnd if a metadata element value has the form "@filename", the named file is read and treated as a single value. For example, if @@ -1415,7 +1415,7 @@
Python command line tool
identifier with that document as the value of the "datacite" element can be minted by invoking:-% ezid.py username:password mint doi:10.5072/FK2 datacite @metadata.xml +% ezid3.py username:password mint doi:10.5072/FK2 datacite @metadata.xml
#! /bin/bash for i in {1..100}; do - ezid.py username:password mint ark:/99999/fk4 | awk '{ print $2 }' + ezid3.py username:password mint ark:/99999/fk4 | awk '{ print $2 }' done
Second, the batch-register.py script automates several @@ -2169,4 +2169,4 @@
//END//", t.read(), re.S) if not m: error("error parsing rst2html.py output")