From ba3bd35e7098d72cb3f05b90e3eeeacd7413be0e Mon Sep 17 00:00:00 2001 From: kim Date: Mon, 1 Apr 2024 08:32:42 -0800 Subject: [PATCH] reveals s3urls and additionalUrls for nisar products --- SearchAPI/CMR/Output/jsonlite.py | 5 ++++- SearchAPI/CMR/Output/jsonlite2.py | 4 ++-- SearchAPI/CMR/Translate/fields.py | 1 + SearchAPI/CMR/Translate/parse_cmr_response.py | 13 +++++++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/SearchAPI/CMR/Output/jsonlite.py b/SearchAPI/CMR/Output/jsonlite.py index e6b56117..660440a7 100644 --- a/SearchAPI/CMR/Output/jsonlite.py +++ b/SearchAPI/CMR/Output/jsonlite.py @@ -188,6 +188,9 @@ def getItem(self, p): result['opera']['validityStartDate'] = p.get('validityStartDate') if p.get('platform') == 'NISAR': - result['s3Urls'] = p.get('s3Urls', []) + result['nisar'] = { + 'additionalUrls': p.get('additionalUrls', []), + 's3Urls': p.get('s3Urls', []) + } return result diff --git a/SearchAPI/CMR/Output/jsonlite2.py b/SearchAPI/CMR/Output/jsonlite2.py index 2758f963..5cdff707 100644 --- a/SearchAPI/CMR/Output/jsonlite2.py +++ b/SearchAPI/CMR/Output/jsonlite2.py @@ -61,7 +61,7 @@ def getItem(self, p): if p.get('opera') is not None: result['s1o'] = p['opera'] - if p.get('platform') == 'NISAR': - result['s3du'] = p.get('s3Urls', []) + if p.get('nisar') is not None: + result['nsr'] = p['nisar'] return result diff --git a/SearchAPI/CMR/Translate/fields.py b/SearchAPI/CMR/Translate/fields.py index b9f5bebe..f639ff28 100644 --- a/SearchAPI/CMR/Translate/fields.py +++ b/SearchAPI/CMR/Translate/fields.py @@ -61,6 +61,7 @@ def get_field_paths(): 'track': attr_path('PATH_NUMBER'), 'pgeVersion': "./PGEVersionClass/PGEVersion", 'additionalUrls': "./OnlineAccessURLs", + 's3Urls': "./OnlineAccessURLs", # BURST FIELDS 'absoluteBurstID': attr_path('BURST_ID_ABSOLUTE'), diff --git a/SearchAPI/CMR/Translate/parse_cmr_response.py b/SearchAPI/CMR/Translate/parse_cmr_response.py index c4345cf9..08528328 100644 --- a/SearchAPI/CMR/Translate/parse_cmr_response.py +++ b/SearchAPI/CMR/Translate/parse_cmr_response.py @@ -221,9 +221,18 @@ def float_or_none(a): accessUrls = [url for url in get_all_vals('./OnlineAccessURLs/OnlineAccessURL/URL') if not url.endswith('.md5') and not url.startswith('s3://') and not 's3credentials' in url] OnlineResources = [url for url in get_all_vals('./OnlineResources/OnlineResource/URL') if not url.endswith('.md5') and not url.startswith('s3://') and not 's3credentials' in url] result['additionalUrls'] = list(set([*accessUrls, *OnlineResources])) + + accessUrls = get_all_vals('./OnlineAccessURLs/OnlineAccessURL/URL') + if accessUrls is None: + accessUrls = [] + resourceUrls = get_all_vals('./OnlineResources/OnlineResource/URL') + if resourceUrls is None: + resourceUrls = [] + result['s3Urls'] = list(set( - *[url for url in get_all_vals('./OnlineResources/OnlineAccessURL/URL') if not url.endswith('.md5') and (url.startswith('s3://') or 's3credentials' in url)], - *[url for url in get_all_vals('./OnlineResources/OnlineResource/URL') if not url.endswith('.md5') and (url.startswith('s3://') or 's3credentials' in url)] + [*[url for url in accessUrls if not url.endswith('.md5') and (url.startswith('s3://') or 's3credentials' in url)], + *[url for url in resourceUrls if not url.endswith('.md5') and (url.startswith('s3://') or 's3credentials' in url)] + ] )) return result