Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBIO: Enable reassignment of ownership of records #19

Open
wants to merge 15 commits into
base: integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 deletions python/nistoar/midas/dap/service/mds3.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from nistoar.pdr import def_schema_dir, def_etc_dir, constants as const
from nistoar.pdr.utils import build_mime_type_map, read_json
from nistoar.pdr.utils.prov import Agent, Action
from nistoar.nsd.client import NSDClient
from nistoar.nsd import NSDServerError

from . import validate
from .. import nerdstore
Expand Down Expand Up @@ -238,7 +238,7 @@ class DAPService(ProjectService):

def __init__(self, dbclient_factory: DBClientFactory, config: Mapping={}, who: Agent=None,
log: Logger=None, nerdstore: NERDResourceStorage=None, project_type=DAP_PROJECTS,
minnerdmver=(0, 6), fmcli=None, nsdcli=None):
minnerdmver=(0, 6), fmcli=None, nsdsvc=None):
"""
create the service
:param DBClientFactory dbclient_factory: the factory to create the DBIO service client from
Expand All @@ -253,8 +253,6 @@ def __init__(self, dbclient_factory: DBClientFactory, config: Mapping={}, who: A
subclass constructors.
:param FileManager fmcli: The FileManager client to use; if None, one will be constructed
from the configuration.
:param NSDClient nsdcli: The NSD client to use to look up people and organizations; if None,
one will be constructed from the configuration.
"""
super(DAPService, self).__init__(project_type, dbclient_factory, config, who, log,
_subsys="Digital Asset Publication Authoring System",
Expand All @@ -270,13 +268,6 @@ def __init__(self, dbclient_factory: DBClientFactory, config: Mapping={}, who: A
nerdstore = NERDResourceStorageFactory().open_storage(config.get("nerdstorage", {}), log)
self._store = nerdstore

self._nsdcli = nsdcli
if not self._nsdcli:
if not self.cfg.get('nsd', {}).get('service_endpoint'):
self.log.warning("NSD service is not configured; name lookups are not possible")
else:
self._nsdcli = self._make_nsd_client(config['nsd'])

self.cfg.setdefault('assign_doi', ASSIGN_DOI_REQUEST)
if not self.cfg.get('doi_naan') and self.cfg.get('assign_doi') != ASSIGN_DOI_NEVER:
raise ConfigurationException("Missing configuration: doi_naan")
Expand All @@ -296,11 +287,6 @@ def __init__(self, dbclient_factory: DBClientFactory, config: Mapping={}, who: A
def _make_fm_client(self, fmcfg):
return FileManager(fmcfg)

def _make_nsd_client(self, nsdcfg):
if not nsdcfg.get('service_endpoint'):
raise ConfigurationException("nsd config missing 'service_endpoint' parameter")
return NSDClient(nsdcfg['service_endpoint'])

def _choose_mediatype(self, fext):
defmt = 'application/octet-stream'

Expand Down Expand Up @@ -473,17 +459,16 @@ def _new_data_for(self, recid, meta=None, schemaid=None):
elif meta.get("contactName"):
out['contactPoint'] = self._moderate_contactPoint({"fn": meta["contactName"]}, doval=False)

ro = self.cfg.get('default_responsible_org', {})
if self._nsdcli and out.get('contactPoint', {}).get('hasEmail'):
ro = deepcopy(self.cfg.get('default_responsible_org', {}))
if self.dbcli.people_service and out.get('contactPoint', {}).get('hasEmail'):
ps = self.dbcli.people_service
try:
conrec = self._nsdcli.select_people(email=out.get['contactPoint']['hasEmail'])
conrec = ps.get_person_by_email(email=out['contactPoint']['hasEmail'])
except NSDServerError as ex:
self.log.warning("Unable to get org info on contact from NSD service: %s", str(ex))
except Exception as ex:
self.log.exception("Unexpected error while accessing NSD service: %s", str(ex))
else:
if len(conrec) > 0:
conrec = conrec[0]
if conrec:
ro['subunits'] = []
if not ro.get('title'):
Expand Down Expand Up @@ -614,7 +599,7 @@ def get_nerdm_data(self, id: str, part: str=None):
out = nerd.get_res_data()
if part in out:
out = out[part]
elif part in "description @type contactPoint title rights disclaimer".split():
elif part in "description @type contactPoint title rights disclaimer landingPage".split():
raise ObjectNotFound(prec.id, part, "%s property not set yet" % part)
else:
raise PartNotAccessible(prec.id, part, "Accessing %s not supported" % part)
Expand Down
Loading
Loading