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 17 commits into
base: integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
235c099
nistoar.nsd.client: add authentication options
RayPlante Nov 16, 2024
0d67fb8
nsd.service: add get_person_by_*() functions to aid in encapsulation
RayPlante Nov 18, 2024
b1b331d
dbio: add reassign() to ProtectedRecord to change ownership with vali…
RayPlante Nov 19, 2024
93ef868
dbio.wsgi.project: allow name to get GET/PUT as plain text:
RayPlante Nov 19, 2024
4d1cfdb
dbio: support owner reassignment in web API
RayPlante Nov 19, 2024
226c67d
mds3: when retrieving landingPage value, it too may be unset
RayPlante Nov 19, 2024
aab2614
update mds3 tests with change to ProjectNameHandler
RayPlante Nov 19, 2024
27430d5
dbio: log message with changing owner, name; handle InvalidUpdate
RayPlante Nov 19, 2024
c8b3f38
dbio.mongo: bug fix: pass in people svc; add warnings, message
RayPlante Nov 19, 2024
2507cdc
dbio.wsgi.project: implicitly support content-type,
RayPlante Nov 19, 2024
c99d04e
dbio.wsgi.project: tweak in-line doc to list new /owner ep capability
RayPlante Nov 19, 2024
0d811e1
dbio: correct reassign() doc: raises InvalidUpdate
RayPlante Nov 19, 2024
8639b5b
dbio: record change to name, owner via ProjectService, requiring ADMI…
RayPlante Nov 20, 2024
a3823af
dbio: make groups rename-able
RayPlante Nov 21, 2024
4c22476
dbio: allow reassign on creation, make sure fact is clear in status
RayPlante Nov 21, 2024
e4e2a01
dbio: get owner reassignment to work with standalone midasserver
RayPlante Nov 27, 2024
8659017
quiet down pymongo in the log
RayPlante Dec 6, 2024
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
5 changes: 5 additions & 0 deletions docker/midasserver/midas-dmpdapnsd_conf.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
logfile: midas.log
loglevel: DEBUG
loglevelsfor :
pymongo: INFO
dbio:
factory: fsbased
people_service:
factory: mongo
db_url: "mongodb://oarop:oarop@mongodb:27017/midas"
about:
title: "MIDAS Authoring Services"
describedBy: "http://localhost:9091/midas/docs"
Expand Down
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