Skip to content

Commit

Permalink
fix origin publishing, ignore WCMP2s from other GDCs
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Sep 26, 2024
1 parent 4db6b1a commit 7f0cac0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions wis2-gdc-management/wis2_gdc/registrar.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def get_wcmp2(self, wnm: dict, topic: str) -> Union[dict, None]:
message = {}
message_failure_reason = None

centre_id = topic.split('/')[3]
if centre_id.endswith('global-discovery-catalogue'):
msg = 'WCMP2 record republished from another GDC; not processing'
LOGGER.info(msg)
return None

try:
LOGGER.debug('Fetching canonical URL')
self.wcmp2_url = list(filter(lambda d: d['rel'] == 'canonical',
Expand Down Expand Up @@ -101,8 +107,6 @@ def get_wcmp2(self, wnm: dict, topic: str) -> Union[dict, None]:
'unknown', 'failed_total',
[BROKER_URL, CENTRE_ID])

centre_id = topic.split('/')[3]

LOGGER.debug(f'WCMP2 access failed: {message_failure_reason}')
message['id'] = str(uuid.uuid4())
message['message'] = str(message_failure_reason)
Expand Down Expand Up @@ -234,8 +238,10 @@ def register(self, metadata: Union[dict, str], topic: str = None) -> None:

api_url = f"{API_URL_DOCKER}/collections/wis2-discovery-metadata/items/{self.metadata['id']}" # noqa

publish_report_topic = f'origin/a/wis2/{CENTRE_ID}/metadata'

message = create_message(
topic='foo/bar',
topic=publish_report_topic,
content_type='application/geo+json',
url=api_url,
identifier=str(uuid.uuid4()),
Expand All @@ -247,8 +253,7 @@ def register(self, metadata: Union[dict, str], topic: str = None) -> None:
message = json.dumps(message).replace(API_URL_DOCKER, API_URL)

LOGGER.info('Publishing updated record to GDC broker')
publish_report_topic = f'origin/a/wis2/{CENTRE_ID}/metadata'
self.broker.pub(publish_report_topic, json.dumps(ets_results))
self.broker.pub(publish_report_topic, message)

def delete_record(self, topic: str, wnm: dict) -> None:
"""
Expand Down

0 comments on commit 7f0cac0

Please sign in to comment.