Skip to content

Commit

Permalink
Merge pull request #1 from CDLUC3/dev
Browse files Browse the repository at this point in the history
Fixing 10.3 bug
  • Loading branch information
rushirajnenuji authored Mar 4, 2020
2 parents d18a2ee + 7551e0a commit 46fe29d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
~$
\.map$
*.pyc
\.project$
\.DS_Store$
^dev/css/*$
\.old[0-9]*$
^ui_library$
^node_modules$
\.pydevproject$
templates/info/
settings/ezid.conf.shadow
static/javascripts/metadata_tooltips.js
24 changes: 18 additions & 6 deletions code/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
# Author:
# Greg Janee <[email protected]>
# Rushiraj Nenuji <[email protected]>
#
# License:
# Copyright (c) 2010, Regents of the University of California
Expand Down Expand Up @@ -56,7 +57,7 @@ def validateDoi (doi):
if len(doi) > maxIdentifierLength-4: return None
return doi.upper()

_arkPattern1 = re.compile("((?:\d{5}(?:\d{4})?|[b-k]\d{4})/)([!-~]+)$")
_arkPattern1 = re.compile("((?:\d{5}(?:\d{4})?|[bcdfghjkmnpqrstvwxz]\d{4})/)([!-~]+)$")
_arkPattern2 = re.compile("\./|/\.")
_arkPattern3 = re.compile("([./])[./]+")
_arkPattern4 = re.compile("^[./]|[./]$")
Expand Down Expand Up @@ -238,12 +239,16 @@ def doi2shadow (doi):
# Update: to prevent different DOIs from mapping to the same shadow
# ARK, we percent-encode characters (and only those characters) that
# would otherwise be removed by the ARK normalization process.
beta_numeric_char = "bcdfghjkmnpqrstvwxz"
doi_prefix = doi.split("/")[0]
i = len(doi_prefix) + 1
if doi[7] == "/":
i = 8
p = "b" + doi[3:i]
else:
i = 9
p = chr(ord("c")+ord(doi[3])-ord("1")) + doi[4:i]
if i == 9:
p = beta_numeric_char[(ord(doi[3])-ord("0"))] + doi[4:i]
elif i == 10:
p = beta_numeric_char[((ord(doi[3]) - ord("0")) * 10) + (ord(doi[4]) - ord("0"))] + doi[5:i]
s = doi[i:].replace("%", "%25").replace("-", "%2d").lower()
s = _arkPattern4.sub(lambda c: "%%%02x" % ord(c.group(0)), s)
s = _arkPattern3.sub(_percentEncodeCdr, s)
Expand All @@ -260,13 +265,20 @@ def shadow2doi (ark):
(e.g., "10.5060/FOO"). The returned identifier is in canonical
form.
"""
beta_numeric_char = "bcdfghjkmnpqrstvwxz"
if ark[0] == "b":
doi = "10." + ark[1:]
else:
doi = "10." + chr(ord("1")+ord(ark[0])-ord("c")) + ark[1:]
try:
if beta_numeric_char.find(ark[0]) > -1:
doi = "10." + str(beta_numeric_char.find(ark[0])) + ark[1:]
else:
raise Exception("Not a valid ark")
except:
print "Sorry, an error occured while converting shadow 2 doi"
return _hexDecodePattern.sub(lambda c: chr(int(c.group(1), 16)), doi).upper()

_shadowedDoiPattern = re.compile("ark:/[b-k]") # see _arkPattern1 above
_shadowedDoiPattern = re.compile("ark:/[bcdfghjkmnpqrstvwxz]") # see _arkPattern1 above

def normalizeIdentifier (identifier):
"""
Expand Down
13 changes: 6 additions & 7 deletions settings/ezid.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[DEFAULT]
{localdev}ezid_base_url: http://localhost:8000
{remotedev}ezid_base_url: http://localhost:8000
{staging}ezid_base_url: https://ids-ezid-stg.cdlib.org
{staging}ezid_base_url: https://uc3-ezidx2-stg.cdlib.org
{production}ezid_base_url: https://ezid.cdlib.org
default_doi_profile: datacite
default_ark_profile: erc
Expand Down Expand Up @@ -109,12 +109,11 @@ ark: https://n2t-stg.n2t.net
{production}ark: https://n2t.net

[shoulders]
# The URL below may be a file:// URL to load the shoulders from a
# local source. The username and password may be left empty if not
# required.
url: https://n2t.net/e/pop/ezid/master_shoulders.txt
username: ezid
password: (see shadow file)
# Loading the shoulders file from local storage
# Do not need any credentials, so the username and password are intentionally left blank
url: file:///apps/ezid/apps/apache/ezid-shoulders/master_shoulders.txt
username:
password:
ark_test: ark:/99999/fk4
doi_test: doi:10.5072/FK2
crossref_test: doi:10.15697/
Expand Down
2 changes: 1 addition & 1 deletion settings/staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

DEBUG = False

ALLOWED_HOSTS = ["ids-ezid-stg.cdlib.org"]
ALLOWED_HOSTS = ["uc3-ezidx2-stg.cdlib.org"]

injectSecrets(DEPLOYMENT_LEVEL)

0 comments on commit 46fe29d

Please sign in to comment.