Skip to content

Commit

Permalink
Merge pull request #164 from CDLUC3/stage
Browse files Browse the repository at this point in the history
2.0.5 rc1
  • Loading branch information
rushirajnenuji authored Nov 3, 2021
2 parents 172a7ac + 1fdc801 commit b0e1695
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 39 deletions.
14 changes: 14 additions & 0 deletions ezidapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
],
Expand Down
14 changes: 14 additions & 0 deletions ezidapp/models/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 6 additions & 2 deletions impl/ezid.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import uuid

import django.core.exceptions
import django.conf
import django.db.transaction
import django.db.utils

Expand Down Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion impl/form_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
Expand Down
2 changes: 1 addition & 1 deletion impl/nog/minter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 17 additions & 17 deletions templates/doc/apidoc.2.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,17 @@ <h1>Authentication</h1>
The authentication realm is &quot;EZID&quot;. For example, credentials can
be added manually in Python as follows:</p>
<pre class="literal-block">
import base64, urllib2
r = urllib2.Request(&quot;https://ezid.cdlib.org/...&quot;)
import base64, urllib.request, urllib.error, urllib.parse
r = urllib.request..Request(&quot;https://ezid.cdlib.org/...&quot;)
r.add_header(&quot;Authorization&quot;, &quot;Basic &quot; + base64.b64encode(&quot;<span class="hl2">username</span>:<span class="hl2">password</span>&quot;))
</pre>
<p>But most programming libraries provide higher-level support for
authentication. For example, Python provides HTTPBasicAuthHandler:</p>
<pre class="literal-block">
import urllib2
h = urllib2.HTTPBasicAuthHandler()
import urllib.request, urllib.error, urllib.parse
h = urllib.request.HTTPBasicAuthHandler()
h.add_password(&quot;EZID&quot;, &quot;https://ezid.cdlib.org/&quot;, &quot;<span class="hl2">username</span>&quot;, &quot;<span class="hl2">password</span>&quot;)
o = urllib2.build_opener(h)
o = urllib.request.build_opener(h)
o.open(&quot;https://ezid.cdlib.org/...&quot;)
</pre>
<p>The downside of using higher-level authentication mechanisms is
Expand Down Expand Up @@ -241,11 +241,11 @@ <h1>Authentication</h1>
<p>In Python, cookies can be managed using <a class="reference external" href="http://docs.python.org/library/cookielib.html">cookielib</a> <span class="ext-icon"></span>,
or manually captured and set using code similar to the following:</p>
<pre class="literal-block">
import urllib2
c = urllib2.urlopen(&quot;https://ezid.cdlib.org/login&quot;)
import urllib.request, urllib.error, urllib.parse
c = urllib.request.urlopen(&quot;https://ezid.cdlib.org/login&quot;)
<span class="hl2">cookie</span> = c.headers[&quot;Set-Cookie&quot;].split(&quot;;&quot;)[0]
...
r = urllib2.Request(&quot;https://ezid.cdlib.org/...&quot;)
r = urllib.request.Request(&quot;<a class="reference external" href="https://ezid.cdlib.org/">https://ezid.cdlib.org/</a>...&quot;)
r.add_header(&quot;Cookie&quot;, <span class="hl2">cookie</span>)
</pre>
<p>In Java, cookies can be manually captured and set using code
Expand Down Expand Up @@ -319,7 +319,7 @@ <h1>Request &amp; response bodies</h1>
return re.sub(&quot;[%:\r\n]&quot;, lambda c: &quot;%%%02X&quot; % ord(c.group(0)), s)

<span class="hl2">anvl</span> = &quot;\n&quot;.join(&quot;%s: %s&quot; % (escape(name), escape(value)) for name,
value in <span class="hl2">metadata</span>.items()).encode(&quot;UTF-8&quot;)
value in list(<span class="hl2">metadata</span>.items())).encode(&quot;UTF-8&quot;)
</pre>
<p>Conversely, to parse a UTF-8 encoded string, <span class="hl1">anvl</span>, producing
a dictionary, <span class="hl1">metadata</span>:</p>
Expand Down Expand Up @@ -1360,27 +1360,27 @@ <h1>Server status</h1>
</div>
<div class="section" id="python-command-line-tool">
<h1>Python command line tool</h1>
<p><a class="reference external" href="https://github.com/CDLUC3/ezid-client-tools/blob/master/ezid.py">ezid.py</a> <span class="ext-icon"></span> is a command line tool, written in Python,
<p><a class="reference external" href="https://github.com/CDLUC3/ezid-client-tools/blob/master/ezid3.py">ezid3.py</a> <span class="ext-icon"></span> 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:</p>
<pre class="literal-block">
% ezid.py <span class="hl2">credentials</span> <span class="hl2">operation</span> <span class="hl2">[arguments...]</span>
% ezid3.py <span class="hl2">credentials</span> <span class="hl2">operation</span> <span class="hl2">[arguments...]</span>
</pre>
<p>Run the tool with no command line arguments for a complete usage
statement; additional documentation is in the source code. To give a
flavor of the tool's usage and capabilities here, a few examples
follow.</p>
<p>To mint a test ARK identifier and supply initial metadata:</p>
<pre class="literal-block">
% ezid.py <span class="hl2">username</span>:<span class="hl2">password</span> mint ark:/99999/fk4 erc.who 'Proust, Marcel' \
% ezid3.py <span class="hl2">username</span>:<span class="hl2">password</span> mint ark:/99999/fk4 erc.who 'Proust, Marcel' \
erc.what 'Remembrance of Things Past' erc.when 1922
success: ark:/99999/fk4gt78tq
</pre>
<p>To get identifier metadata:</p>
<pre class="literal-block">
% 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
Expand All @@ -1407,15 +1407,15 @@ <h1>Python command line tool</h1>
<p>Then a test ARK identifier with that metadata can be minted by
invoking:</p>
<pre class="literal-block">
% ezid.py <span class="hl2">username</span>:<span class="hl2">password</span> mint ark:/99999/fk4 &#64; metadata.txt
% ezid3.py <span class="hl2">username</span>:<span class="hl2">password</span> mint ark:/99999/fk4 &#64; metadata.txt
</pre>
<p>And if a metadata element value has the form &quot;&#64;<span class="hl1">filename</span>&quot;, the
named file is read and treated as a single value. For example, if
file metadata.xml contains a DataCite XML document, then a test DOI
identifier with that document as the value of the &quot;datacite&quot; element
can be minted by invoking:</p>
<pre class="literal-block">
% ezid.py <span class="hl2">username</span>:<span class="hl2">password</span> mint doi:10.5072/FK2 datacite &#64;metadata.xml
% ezid3.py <span class="hl2">username</span>:<span class="hl2">password</span> mint doi:10.5072/FK2 datacite &#64;metadata.xml
</pre>
</div>
<div class="section" id="php-examples">
Expand Down Expand Up @@ -1802,7 +1802,7 @@ <h1>Batch processing</h1>
<pre class="literal-block">
#! /bin/bash
for i in {1..100}; do
ezid.py <span class="hl2">username</span>:<span class="hl2">password</span> mint ark:/99999/fk4 | awk '{ print $2 }'
ezid3.py <span class="hl2">username</span>:<span class="hl2">password</span> mint ark:/99999/fk4 | awk '{ print $2 }'
done
</pre>
<p>Second, the <a class="reference external" href="https://github.com/CDLUC3/ezid-client-tools/blob/master/batch-register.py">batch-register.py</a> <span class="ext-icon"></span> script automates several
Expand Down Expand Up @@ -2169,4 +2169,4 @@ <h1>OAI-PMH harvesting</h1>
&quot;UUID&quot; as appropriate.</p>
</div>
</div>
{% endblock %}
{% endblock %}
34 changes: 17 additions & 17 deletions templates/doc/apidoc.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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:"))
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:\:
Expand Down Expand Up @@ -1352,15 +1352,15 @@ 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
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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion templates/doc/make-apidoc-html
Original file line number Diff line number Diff line change
Expand Up @@ -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//</p>\n(.*)<p>//END//", t.read(), re.S)
if not m: error("error parsing rst2html.py output")
Expand Down

0 comments on commit b0e1695

Please sign in to comment.