Skip to content
Merged
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
23 changes: 22 additions & 1 deletion geordash/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,29 @@ def geonetwork_subportals():
headers = r[0]
cookies = r[1]
me = r[2]

gn_site = requests.get(gnurl + "srv/api/site", headers={"Accept": "application/json"})
information_site = {}
if gn_site.status_code == 200:
information_site = gn_site.json()
else:
app.logger.error(
f"Problem to detect the version of geonetwork with {gnurl}srv/api/site response {gn_site} \n"
f"Will try anyway to request the portal"
)

# default url of subportal sources
subportalapiurl = "srv/api/sources"
# safely get the version from json answer
if "4.4." in information_site.get('system/platform/version', "Nop"):
# url for 4.4.8
subportalapiurl = "srv/api/sources?type=subportal"
elif "4.2." in information_site.get('system/platform/version', "Nop"):
# url for 4.2.8
subportalapiurl = "srv/api/sources/subportal"

portals = requests.get(
gnurl + "srv/api/sources/subportal", cookies=cookies, headers=headers
gnurl + subportalapiurl, cookies=cookies, headers=headers
)
if portals.status_code != 200:
return portals.text
Expand Down
Loading