Skip to content

Commit

Permalink
Return href information for h5path requests (HDFGroup#235)
Browse files Browse the repository at this point in the history
Specifically, this is useful for H5Ovisit in the REST VOL.

Also fix getObjectIdByPath not passing the values of
`follow_soft_links` and `follow_external_links` to recursive calls
  • Loading branch information
mattjala authored Jun 15, 2023
1 parent 7f342a5 commit eb37d04
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
30 changes: 29 additions & 1 deletion hsds/domain_sn.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,35 @@ async def GET_Domain(request):

# client may not know class of object retrieved via path
obj_json["class"] = getObjectClass(obj_id)
# Not bothering with hrefs for h5path lookups...

hrefs = []
hrefs.append({"rel": "self", "href": getHref(request, "/")})
if "root" in domain_json:
root_uuid = domain_json["root"]
href = getHref(request, "/datasets")
hrefs.append({"rel": "database", "href": href})
href = getHref(request, "/groups")
hrefs.append({"rel": "groupbase", "href": href})
href = getHref(request, "/datatypes")
hrefs.append({"rel": "typebase", "href": href})
href = getHref(request, "/groups/" + root_uuid)
hrefs.append({"rel": "root", "href": href})
href = getHref(request, "/")
hrefs.append({"rel": "home", "href": href})

hrefs.append({"rel": "acls", "href": getHref(request, "/acls")})
parent_domain = getParentDomain(domain)
if not parent_domain or getPathForDomain(parent_domain) == "/":
is_toplevel = True
else:
is_toplevel = False
log.debug(f"href parent domain: {parent_domain}")
if not is_toplevel:
href = getHref(request, "/", domain=parent_domain)
hrefs.append({"rel": "parent", "href": href})

obj_json["hrefs"] = hrefs

resp = await jsonResponse(request, obj_json)
log.response(request, resp=resp)
return resp
Expand Down
16 changes: 12 additions & 4 deletions hsds/servicenode_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ async def getObjectIdByPath(app, obj_id, h5path, bucket=None, refresh=False, dom
log.debug(msg)
obj_id, domain, link_json = await getObjectIdByPath(
app, ext_domain_json["root"], link_json["h5path"],
bucket=bucket, refresh=refresh, domain=domain)
bucket=bucket, refresh=refresh, domain=domain,
follow_soft_links=follow_soft_links,
follow_external_links=follow_external_links)
else:
msg = "Cannot follow external link by relative path"
log.warn(msg)
Expand All @@ -303,7 +305,9 @@ async def getObjectIdByPath(app, obj_id, h5path, bucket=None, refresh=False, dom
# If relative path, keep parent object the same
obj_id, domain, link_json = await getObjectIdByPath(
app, obj_id, path_from_link, bucket=bucket,
refresh=refresh, domain=domain)
refresh=refresh, domain=domain,
follow_soft_links=follow_soft_links,
follow_external_links=follow_external_links)
else:
if not domain:
msg = "Soft link with absolute path used with no domain given"
Expand All @@ -316,7 +320,9 @@ async def getObjectIdByPath(app, obj_id, h5path, bucket=None, refresh=False, dom

obj_id, domain, link_json = await getObjectIdByPath(
app, domain_json["root"], path_from_link,
bucket=bucket, refresh=refresh, domain=domain)
bucket=bucket, refresh=refresh, domain=domain,
follow_soft_links=follow_soft_links,
follow_external_links=follow_external_links)

elif link_json["class"] == "H5L_TYPE_HARD":
obj_id = link_json["id"]
Expand Down Expand Up @@ -356,7 +362,9 @@ async def getObjectIdByPath(app, obj_id, h5path, bucket=None, refresh=False, dom

obj_id, domain, link_json = await getObjectIdByPath(
app, parent_id, link_json["h5path"],
bucket=bucket, refresh=refresh, domain=domain)
bucket=bucket, refresh=refresh, domain=domain,
follow_soft_links=follow_soft_links,
follow_external_links=follow_external_links)

return obj_id, domain, link_json

Expand Down

0 comments on commit eb37d04

Please sign in to comment.