From 693e583301aa4683e17325e61ddb766e3a80badb Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji <19696935+rushirajnenuji@users.noreply.github.com> Date: Fri, 17 Sep 2021 13:57:05 -0700 Subject: [PATCH 01/12] Checking in additional resourceTypes from newer DataCite versions Checking in additional resourceTypes from newer DataCite versions --- ezidapp/migrations/0001_initial.py | 14 ++++++++++++++ ezidapp/models/validation.py | 14 ++++++++++++++ impl/form_objects.py | 16 +++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) 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/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')), From 60506d3be5ecfbabc7d5b8d11cbe531f919740d4 Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji <19696935+rushirajnenuji@users.noreply.github.com> Date: Mon, 25 Oct 2021 18:33:38 -0700 Subject: [PATCH 02/12] Checking in API doc updates Checking in API doc updates --- templates/doc/apidoc.2.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/templates/doc/apidoc.2.rst b/templates/doc/apidoc.2.rst index 944aaa4d9..eef283a87 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/ @@ -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 From 6dbe28005f7f8954be7fe870725496ba66425969 Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji <19696935+rushirajnenuji@users.noreply.github.com> Date: Mon, 25 Oct 2021 19:08:42 -0700 Subject: [PATCH 03/12] Adding fix for proto super shoulder Issue #149 --- impl/nog/minter.py | 7 ++++++- settings/ezid.conf | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/impl/nog/minter.py b/impl/nog/minter.py index ae0a8488c..f4c9591c9 100755 --- a/impl/nog/minter.py +++ b/impl/nog/minter.py @@ -46,6 +46,7 @@ from __future__ import absolute_import, division, print_function import logging +import config import re import nog.bdb @@ -69,6 +70,7 @@ "n": 19, "p": 20, "q": 21, "r": 22, "s": 23, "t": 24, "v": 25, "w": 26, "x": 27, "z": 28, } +PROTO_SUPER_SHOULDER = config.get("shoulders.proto_super_shoulder") # fmt:on XDIG_STR = "0123456789bcdfghjkmnpqrstvwxz" ALPHA_COUNT = len(XDIG_STR) @@ -157,7 +159,10 @@ def create_minter_database(shoulder_ns, root_path=None, mask_str='eedk'): bdb_path = nog.bdb.get_path(shoulder_ns, root_path, is_new=True) with Minter(bdb_path, is_new=True, dry_run=False) as minter: - full_shoulder_str = '/'.join([shoulder_ns.naan_prefix, shoulder_ns.shoulder]) + shoulder_val = shoulder_ns.shoulder + if shoulder_ns.naan_prefix in PROTO_SUPER_SHOULDER and shoulder_val is None: + shoulder_val = PROTO_SUPER_SHOULDER[shoulder_ns.naan_prefix] + full_shoulder_str = '/'.join([shoulder_ns.naan_prefix, shoulder_val]) minter.create(full_shoulder_str, mask_str) return bdb_path diff --git a/settings/ezid.conf b/settings/ezid.conf index e7023b976..c8bf9d21b 100644 --- a/settings/ezid.conf +++ b/settings/ezid.conf @@ -134,6 +134,13 @@ minter_servers: main minter_num_attempts: 3 minter_reattempt_delay: 5 minter_cache_size: 10 +proto_super_shoulder:{ + "7286":"V1", # doi:10.7286/ + "4246":"doi:10.4246/P6", # doi:10.4246/ + "88435":"ark:/88435/dc", # ark:/88435/ + "10.15697":"doi:10.15697/FK2", # doi:10.15697/ + "ark:/12345/":"ark:/12345/fk8", # ark:/12345/ +} [minter_server_main] url: https://n2t.net/a/ezid/m From 4cf1a5783ecf8fc48630ff87de7be867d8700167 Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji <19696935+rushirajnenuji@users.noreply.github.com> Date: Mon, 25 Oct 2021 19:17:02 -0700 Subject: [PATCH 04/12] updating API doc html Reference: #118 updating API doc html --- templates/doc/apidoc.2.html | 22 +++++++++++----------- templates/doc/make-apidoc-html | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/templates/doc/apidoc.2.html b/templates/doc/apidoc.2.html index 44c4f394d..a294cf91f 100644 --- a/templates/doc/apidoc.2.html +++ b/templates/doc/apidoc.2.html @@ -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
 
@@ -2169,4 +2169,4 @@

OAI-PMH harvesting

"UUID" as appropriate.

-{% endblock %} +{% endblock %} \ No newline at end of file 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") From 67ae36b8e51ac074d989a66dc4d2d27924d9edad Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji <19696935+rushirajnenuji@users.noreply.github.com> Date: Mon, 25 Oct 2021 19:37:28 -0700 Subject: [PATCH 05/12] updating conf set up updating conf set up --- impl/nog/minter.py | 9 ++++++++- settings/ezid.conf | 7 ------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/impl/nog/minter.py b/impl/nog/minter.py index f4c9591c9..690ca1d89 100755 --- a/impl/nog/minter.py +++ b/impl/nog/minter.py @@ -70,7 +70,14 @@ "n": 19, "p": 20, "q": 21, "r": 22, "s": 23, "t": 24, "v": 25, "w": 26, "x": 27, "z": 28, } -PROTO_SUPER_SHOULDER = config.get("shoulders.proto_super_shoulder") +# PROTO_SUPER_SHOULDER = config.get("shoulders.proto_super_shoulder") +PROTO_SUPER_SHOULDER ={ + "7286":"V1", # doi:10.7286/ + "4246":"P6", # doi:10.4246/ + "88435":"dc", # ark:/88435/ + "15697":"FK2", # doi:10.15697/ + "12345":"fk8", # ark:/12345/ +} # fmt:on XDIG_STR = "0123456789bcdfghjkmnpqrstvwxz" ALPHA_COUNT = len(XDIG_STR) diff --git a/settings/ezid.conf b/settings/ezid.conf index c8bf9d21b..e7023b976 100644 --- a/settings/ezid.conf +++ b/settings/ezid.conf @@ -134,13 +134,6 @@ minter_servers: main minter_num_attempts: 3 minter_reattempt_delay: 5 minter_cache_size: 10 -proto_super_shoulder:{ - "7286":"V1", # doi:10.7286/ - "4246":"doi:10.4246/P6", # doi:10.4246/ - "88435":"ark:/88435/dc", # ark:/88435/ - "10.15697":"doi:10.15697/FK2", # doi:10.15697/ - "ark:/12345/":"ark:/12345/fk8", # ark:/12345/ -} [minter_server_main] url: https://n2t.net/a/ezid/m From 25b28171751c8eed1334a6733f0009a45382d957 Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji <19696935+rushirajnenuji@users.noreply.github.com> Date: Mon, 25 Oct 2021 19:50:12 -0700 Subject: [PATCH 06/12] removing unused config import removing unused config import --- impl/nog/minter.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/impl/nog/minter.py b/impl/nog/minter.py index 690ca1d89..b5e459c34 100755 --- a/impl/nog/minter.py +++ b/impl/nog/minter.py @@ -46,7 +46,6 @@ from __future__ import absolute_import, division, print_function import logging -import config import re import nog.bdb @@ -442,4 +441,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 From ea6825985bb0e6de5d084a7abc8532cccde4f0ea Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji <19696935+rushirajnenuji@users.noreply.github.com> Date: Mon, 25 Oct 2021 20:06:57 -0700 Subject: [PATCH 07/12] Removing minter changes, fixing ezid.py mintIdentifier function Removing minter changes, fixing ezid.py mintIdentifier function reference: #149 --- impl/ezid.py | 19 +++++++++++++++++-- impl/nog/minter.py | 13 +------------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/impl/ezid.py b/impl/ezid.py index 13b113073..11005e61c 100644 --- a/impl/ezid.py +++ b/impl/ezid.py @@ -59,6 +59,16 @@ def loadConfig(): _paused = False + +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 _incrementCount(d, k): d[k] = d.get(k, 0) + 1 @@ -207,10 +217,15 @@ def _mintIdentifier(shoulder, user, metadata={}): identifier = minter.mint_id(shoulder_model) logger.debug('Minter returned identifier: {}'.format(identifier)) + # proto super shoulder fix + prefix_val = shoulder_model.prefix + if shoulder_model.prefix in PROTO_SUPER_SHOULDER: + prefix_val = PROTO_SUPER_SHOULDER[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/nog/minter.py b/impl/nog/minter.py index b5e459c34..333304b57 100755 --- a/impl/nog/minter.py +++ b/impl/nog/minter.py @@ -69,14 +69,6 @@ "n": 19, "p": 20, "q": 21, "r": 22, "s": 23, "t": 24, "v": 25, "w": 26, "x": 27, "z": 28, } -# PROTO_SUPER_SHOULDER = config.get("shoulders.proto_super_shoulder") -PROTO_SUPER_SHOULDER ={ - "7286":"V1", # doi:10.7286/ - "4246":"P6", # doi:10.4246/ - "88435":"dc", # ark:/88435/ - "15697":"FK2", # doi:10.15697/ - "12345":"fk8", # ark:/12345/ -} # fmt:on XDIG_STR = "0123456789bcdfghjkmnpqrstvwxz" ALPHA_COUNT = len(XDIG_STR) @@ -165,10 +157,7 @@ def create_minter_database(shoulder_ns, root_path=None, mask_str='eedk'): bdb_path = nog.bdb.get_path(shoulder_ns, root_path, is_new=True) with Minter(bdb_path, is_new=True, dry_run=False) as minter: - shoulder_val = shoulder_ns.shoulder - if shoulder_ns.naan_prefix in PROTO_SUPER_SHOULDER and shoulder_val is None: - shoulder_val = PROTO_SUPER_SHOULDER[shoulder_ns.naan_prefix] - full_shoulder_str = '/'.join([shoulder_ns.naan_prefix, shoulder_val]) + full_shoulder_str = '/'.join([shoulder_ns.naan_prefix, shoulder_ns.shoulder]) minter.create(full_shoulder_str, mask_str) return bdb_path From 405a3cf1fb097d875933516b7150c9ba704fb29c Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji <19696935+rushirajnenuji@users.noreply.github.com> Date: Wed, 3 Nov 2021 13:21:41 -0700 Subject: [PATCH 08/12] Moving the proto super shoulder to common settings Moving the proto super shoulder to common settings --- impl/ezid.py | 7 ++++--- settings/common.py | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/impl/ezid.py b/impl/ezid.py index 11005e61c..6393feda5 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 @@ -217,10 +218,10 @@ def _mintIdentifier(shoulder, user, metadata={}): identifier = minter.mint_id(shoulder_model) logger.debug('Minter returned identifier: {}'.format(identifier)) - # proto super shoulder fix + # proto super shoulder check prefix_val = shoulder_model.prefix - if shoulder_model.prefix in PROTO_SUPER_SHOULDER: - prefix_val = PROTO_SUPER_SHOULDER[shoulder_model.prefix] + if shoulder_model.prefix in django.conf.settings.PROTO_SUPER_SHOULDER: + prefix_val = django.conf.settings.PROTO_SUPER_SHOULDER[shoulder_model.prefix] if shoulder_model.prefix.startswith('doi:'): identifier = prefix_val + identifier.upper() 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 From a174052b7e9812704602155b056968d4c391e545 Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji <19696935+rushirajnenuji@users.noreply.github.com> Date: Wed, 3 Nov 2021 13:23:41 -0700 Subject: [PATCH 09/12] Cleaning up PSS look up table from EZID module Cleaning up PSS look up table from EZID module --- impl/ezid.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/impl/ezid.py b/impl/ezid.py index 6393feda5..4ef94a572 100644 --- a/impl/ezid.py +++ b/impl/ezid.py @@ -60,16 +60,6 @@ def loadConfig(): _paused = False - -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 _incrementCount(d, k): d[k] = d.get(k, 0) + 1 From d67593fabc0a1ee37ed01166e07c8b94a86f18bb Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji <19696935+rushirajnenuji@users.noreply.github.com> Date: Wed, 3 Nov 2021 13:36:03 -0700 Subject: [PATCH 10/12] Updating Py2 to Py3 examples Updating Py2 to Py3 examples --- templates/doc/apidoc.2.html | 10 +++++----- templates/doc/apidoc.2.rst | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/templates/doc/apidoc.2.html b/templates/doc/apidoc.2.html index a294cf91f..bcb9b9e0d 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 diff --git a/templates/doc/apidoc.2.rst b/templates/doc/apidoc.2.rst index eef283a87..434f10d5c 100644 --- a/templates/doc/apidoc.2.rst +++ b/templates/doc/apidoc.2.rst @@ -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 From 8514b137099dcf344571902b9f34127310878b5c Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji <19696935+rushirajnenuji@users.noreply.github.com> Date: Wed, 3 Nov 2021 13:41:54 -0700 Subject: [PATCH 11/12] Cleaning up the PSS check to be more Pythonic Cleaning up the PSS check to be more Pythonic --- impl/ezid.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/impl/ezid.py b/impl/ezid.py index 4ef94a572..2ede5e9e9 100644 --- a/impl/ezid.py +++ b/impl/ezid.py @@ -209,9 +209,7 @@ def _mintIdentifier(shoulder, user, metadata={}): logger.debug('Minter returned identifier: {}'.format(identifier)) # proto super shoulder check - prefix_val = shoulder_model.prefix - if shoulder_model.prefix in django.conf.settings.PROTO_SUPER_SHOULDER: - prefix_val = django.conf.settings.PROTO_SUPER_SHOULDER[shoulder_model.prefix] + prefix_val = django.conf.settings.PROTO_SUPER_SHOULDER.get(shoulder_model.prefix, shoulder_model.prefix) if shoulder_model.prefix.startswith('doi:'): identifier = prefix_val + identifier.upper() From 1fdc801d77f99e46cdbbb5085e0ec34500b7733f Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji <19696935+rushirajnenuji@users.noreply.github.com> Date: Wed, 3 Nov 2021 14:33:29 -0700 Subject: [PATCH 12/12] Updating batch processing examples to utilize ezid3 Updating batch processing examples to utilize ezid3 --- templates/doc/apidoc.2.html | 2 +- templates/doc/apidoc.2.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/doc/apidoc.2.html b/templates/doc/apidoc.2.html index bcb9b9e0d..151f8ed99 100644 --- a/templates/doc/apidoc.2.html +++ b/templates/doc/apidoc.2.html @@ -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 diff --git a/templates/doc/apidoc.2.rst b/templates/doc/apidoc.2.rst index 434f10d5c..1a8428632 100644 --- a/templates/doc/apidoc.2.rst +++ b/templates/doc/apidoc.2.rst @@ -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