From 6bf1938b4a5f2ba3c1c2faf6aed81055e484f19a Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji Date: Tue, 25 Feb 2020 17:15:40 -0800 Subject: [PATCH 1/5] Updated Git ignore Updated Git ignore --- .gitignore | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..1aa0dab06 --- /dev/null +++ b/.gitignore @@ -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 From dc10735f59beef8a630f0bb8f88c732136c3a8b1 Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji Date: Tue, 25 Feb 2020 17:19:52 -0800 Subject: [PATCH 2/5] Fixing 10.3 bug in util.py Fixing 10.3 bug in util.py Reference: https://github.com/cdluc3/ezid-service/issues/65 --- code/util.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/code/util.py b/code/util.py index a7f97b7bd..a787723f1 100644 --- a/code/util.py +++ b/code/util.py @@ -6,6 +6,7 @@ # # Author: # Greg Janee +# Rushiraj Nenuji # # License: # Copyright (c) 2010, Regents of the University of California @@ -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{6}(?:\d{5})(?:\d{4})?|[bcdfghjkmnpqrstvwxz]\d{4})/)([!-~]+)$") _arkPattern2 = re.compile("\./|/\.") _arkPattern3 = re.compile("([./])[./]+") _arkPattern4 = re.compile("^[./]|[./]$") @@ -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) @@ -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): """ From 008b9954045c0839126d83f4e149b6ba17e6978d Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji Date: Tue, 25 Feb 2020 17:54:11 -0800 Subject: [PATCH 3/5] Fixing some linux 2 paths Fixing some linux 2 paths --- settings/ezid.conf | 2 +- settings/staging.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/settings/ezid.conf b/settings/ezid.conf index c130f6cad..e42904643 100644 --- a/settings/ezid.conf +++ b/settings/ezid.conf @@ -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 diff --git a/settings/staging.py b/settings/staging.py index 00efba490..ff1339bcf 100644 --- a/settings/staging.py +++ b/settings/staging.py @@ -4,6 +4,6 @@ DEBUG = False -ALLOWED_HOSTS = ["ids-ezid-stg.cdlib.org"] +ALLOWED_HOSTS = ["uc3-ezidx2-stg.cdlib.org"] injectSecrets(DEPLOYMENT_LEVEL) From 295d5eaf099650772bf6283dee80b713df5bfa72 Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji Date: Wed, 26 Feb 2020 16:27:54 -0800 Subject: [PATCH 4/5] Loading the shoulder database locally Loading the shoulder database locally Reference: https://github.com/cdluc3/ezid-service/issues/80 --- settings/ezid.conf | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/settings/ezid.conf b/settings/ezid.conf index e42904643..eb6effe1e 100644 --- a/settings/ezid.conf +++ b/settings/ezid.conf @@ -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/ From 7551e0a7cce838b794f3425b2f1baae3d190afad Mon Sep 17 00:00:00 2001 From: Rushiraj Nenuji Date: Mon, 2 Mar 2020 15:34:51 -0800 Subject: [PATCH 5/5] Updating arkPattern regular expression Updating arkPattern regular expression --- code/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/util.py b/code/util.py index a787723f1..7239c88c4 100644 --- a/code/util.py +++ b/code/util.py @@ -57,7 +57,7 @@ def validateDoi (doi): if len(doi) > maxIdentifierLength-4: return None return doi.upper() -_arkPattern1 = re.compile("((?:\d{6}(?:\d{5})(?:\d{4})?|[bcdfghjkmnpqrstvwxz]\d{4})/)([!-~]+)$") +_arkPattern1 = re.compile("((?:\d{5}(?:\d{4})?|[bcdfghjkmnpqrstvwxz]\d{4})/)([!-~]+)$") _arkPattern2 = re.compile("\./|/\.") _arkPattern3 = re.compile("([./])[./]+") _arkPattern4 = re.compile("^[./]|[./]$")