Skip to content

Commit

Permalink
dbio: log message with changing owner, name; handle InvalidUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
RayPlante committed Nov 19, 2024
1 parent aab2614 commit 27430d5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/nistoar/midas/dbio/wsgi/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,10 @@ def do_PUT(self, path):
try:
prec = self.svc.get_record(self._id)
if path == "owner":
self.log.info("Reassigning ownership of %s from %s to %s", self._id, prec.owner, name)
prec.reassign(name)
else:
self.log.info("Changing short name of %s from %s to %s", self._id, prec.name, name)
setattr(prec, path, name)
if not prec.authorized(dbio.ACLs.ADMIN):
raise dbio.NotAuthorized(self._dbcli.user_id, "change record "+path)
Expand All @@ -328,6 +330,9 @@ def do_PUT(self, path):
except dbio.ObjectNotFound as ex:
return self.send_error_resp(404, "ID not found",
"Record with requested identifier not found", self._id)
except dbio.InvalidUpdate as ex:
return self.send_error_resp(400, "Invalid Input",
"Invalid value provided for %s: %s" % (path, str(ex)), self._id)

if format.name == "text":
return self.send_ok(getattr(prec, path), contenttype=format.ctype)
Expand Down

0 comments on commit 27430d5

Please sign in to comment.