def _get_or_create_identifiers(node): """ Note: ARKs include a leading slash. This is stripped here to avoid multiple consecutive slashes in internal URLs (e.g. /ids/ark/<ark>/). Frontend code that build ARK URLs is responsible for adding the leading slash. """ doi, metadata = _build_ezid_metadata(node) client = EzidClient(settings.EZID_USERNAME, settings.EZID_PASSWORD) try: resp = client.create_identifier(doi, metadata) return dict([each.strip('/') for each in pair.strip().split(':')] for pair in resp['success'].split('|')) except HTTPError as error: if 'identifier already exists' not in error.message.lower(): raise resp = client.get_identifier(doi) doi = resp['success'] suffix = doi.strip(settings.DOI_NAMESPACE) return { 'doi': doi.replace('doi:', ''), 'ark': '{0}{1}'.format(settings.ARK_NAMESPACE.replace('ark:', ''), suffix), }
def _get_or_create_identifiers(node): """ Note: ARKs include a leading slash. This is stripped here to avoid multiple consecutive slashes in internal URLs (e.g. /ids/ark/<ark>/). Frontend code that build ARK URLs is responsible for adding the leading slash. """ doi, metadata = _build_ezid_metadata(node) client = EzidClient(settings.EZID_USERNAME, settings.EZID_PASSWORD) try: resp = client.create_identifier(doi, metadata) return dict([each.strip("/") for each in pair.strip().split(":")] for pair in resp["success"].split("|")) except HTTPError as error: if "identifier already exists" not in error.message.lower(): raise resp = client.get_identifier(doi) doi = resp["success"] suffix = doi.strip(settings.DOI_NAMESPACE) return { "doi": doi.replace("doi:", ""), "ark": "{0}{1}".format(settings.ARK_NAMESPACE.replace("ark:", ""), suffix), }
def osf_admin_change_status_identifier(node, status): if node.get_identifier_value('doi') and node.get_identifier_value('ark'): doi, metadata = build_ezid_metadata(node) client = EzidClient(settings.EZID_USERNAME, settings.EZID_PASSWORD) client.change_status_identifier(status, doi, metadata)
def osf_admin_change_status_identifier(node, status): if node.get_identifier_value('doi') and node.get_identifier_value('ark'): doi, metadata = build_ezid_metadata(node) client = EzidClient(settings.EZID_USERNAME, settings.EZID_PASSWORD) client.change_status_identifier(status, doi, metadata)
def get_ezid_client(): from website.identifiers.client import EzidClient return EzidClient(settings.EZID_USERNAME, settings.EZID_PASSWORD)