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 @@

Authentication

The authentication realm is "EZID". For example, credentials can be added manually in Python as follows:

-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 @@

Authentication

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 @@

Request & response bodies

return re.sub("[%:\r\n]", lambda c: "%%%02X" % ord(c.group(0)), s) anvl = "\n".join("%s: %s" % (escape(name), escape(value)) for name, - value in metadata.items()).encode("UTF-8") + value in list(metadata.items())).encode("UTF-8")

Conversely, to parse a UTF-8 encoded string, anvl, producing a dictionary, metadata:

@@ -1360,13 +1360,13 @@

Server status

Python command line tool

-

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 @@

Python command line tool

follow.

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.txt
 

And 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
 
@@ -1802,7 +1802,7 @@

Batch processing

 #! /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 @@

OAI-PMH harvesting

"UUID" as appropriate.

-{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/templates/doc/apidoc.2.rst b/templates/doc/apidoc.2.rst index 944aaa4d9..1a8428632 100644 --- a/templates/doc/apidoc.2.rst +++ b/templates/doc/apidoc.2.rst @@ -27,7 +27,7 @@ .. _DataCite Metadata Scheme: http://schema.datacite.org/ .. _Dublin Core Metadata Element Set: http://dublincore.org/documents/dces/ .. _ERC: https://wiki.ucop.edu/display/Curation/ERC -.. _ezid.py: https://github.com/CDLUC3/ezid-client-tools/blob/master/ezid.py +.. _ezid3.py: https://github.com/CDLUC3/ezid-client-tools/blob/master/ezid3.py .. _gzip: http://www.gzip.org/ .. _libwww-perl: http://search.cpan.org/dist/libwww-perl/ .. _N2T: https://n2t.net/ @@ -195,8 +195,8 @@ methods of authentication: .. parsed-literal:: - 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`:hl2::`password`:hl2:")) @@ -205,11 +205,11 @@ methods of authentication: .. parsed-literal:: - 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`:hl2:", \ "`password`:hl2:") - 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 @@ -273,11 +273,11 @@ methods of authentication: .. parsed-literal:: - 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`:hl2: = 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`:hl2:) In Java, cookies can be manually captured and set using code @@ -362,7 +362,7 @@ a UTF-8 encoded string, `anvl`:hl1:, with the following code: return re.sub("[%:\\r\\n]", lambda c: "%%%02X" % ord(c.group(0)), s) `anvl`:hl2: = "\\n".join("%s: %s" % (escape(name), escape(value)) for name, - value in `metadata`:hl2:.items()).encode("UTF-8") + value in list(`metadata`:hl2:.items())).encode("UTF-8") Conversely, to parse a UTF-8 encoded string, `anvl`:hl1:, producing a dictionary, `metadata`:hl1:\: @@ -1352,7 +1352,7 @@ response will resemble the following: Python command line tool ------------------------ -ezid.py_ `\ `:ext-icon: is a command line tool, written in Python, +ezid3.py_ `\ `:ext-icon: 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 @@ -1360,7 +1360,7 @@ functionality. The general usage is: .. parsed-literal:: - % ezid.py `credentials`:hl2: `operation`:hl2: `[arguments...]`:hl2: + % ezid3.py `credentials`:hl2: `operation`:hl2: `[arguments...]`:hl2: Run the tool with no command line arguments for a complete usage statement; additional documentation is in the source code. To give a @@ -1371,7 +1371,7 @@ To mint a test ARK identifier and supply initial metadata: .. parsed-literal:: - % ezid.py `username`:hl2::`password`:hl2: mint ark:/99999/fk4 erc.who \ + % ezid3.py `username`:hl2::`password`:hl2: mint ark:/99999/fk4 erc.who \ 'Proust, Marcel' \\ erc.what 'Remembrance of Things Past' erc.when 1922 success: ark:/99999/fk4gt78tq @@ -1380,7 +1380,7 @@ To get identifier metadata: .. parsed-literal:: - % 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 @@ -1409,7 +1409,7 @@ invoking: .. parsed-literal:: - % ezid.py `username`:hl2::`password`:hl2: mint ark:/99999/fk4 @ metadata.txt + % ezid3.py `username`:hl2::`password`:hl2: mint ark:/99999/fk4 @ metadata.txt And if a metadata element value has the form "@\ `filename`:hl1:", the named file is read and treated as a single value. For example, if @@ -1419,7 +1419,7 @@ can be minted by invoking: .. parsed-literal:: - % ezid.py `username`:hl2::`password`:hl2: mint doi:10.5072/FK2 \ + % ezid3.py `username`:hl2::`password`:hl2: mint doi:10.5072/FK2 \ datacite @metadata.xml PHP examples @@ -1862,7 +1862,7 @@ ARK identifiers: #! /bin/bash for i in {1..100}; do - ezid.py `username`:hl2::`password`:hl2: mint ark:/99999/fk4 | \ + ezid3.py `username`:hl2::`password`:hl2: mint ark:/99999/fk4 | \ awk '{ print $2 }' done diff --git a/templates/doc/make-apidoc-html b/templates/doc/make-apidoc-html index 06b9a0089..0616899ee 100755 --- a/templates/doc/make-apidoc-html +++ b/templates/doc/make-apidoc-html @@ -32,7 +32,7 @@ version = m.group(1) outfile = infile[:-3] + "html" t = tempfile.NamedTemporaryFile() -if subprocess.call(["rst2html.py", infile, t.name]) != 0: +if subprocess.call(["rst2html", infile, t.name]) != 0: error("subprocess call failed") m = re.search("//BEGIN//

\n(.*)

//END//", t.read(), re.S) if not m: error("error parsing rst2html.py output")