Skip to content

Commit dc88707

Browse files
committed
CMR-10556: adding a few more fields for the external process
1 parent d95cd31 commit dc88707

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

metadata-db-app/src/cmr/metadata_db/services/subscriptions.clj

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,19 @@
264264

265265
(defn create-notification-message-body
266266
"Create the notification when a subscription exists.
267-
* At this time only concept-id of the granule is needed as an external subscription process will
268-
pull other values meaning this code will not need to translate the XML or JSON to find values for
269-
the subscription process.
267+
* At this time concept-id, revision-id, granule-ur, and location are all that is needed of the
268+
granule is needed as an external subscription process will pull other values meaning this code
269+
will not need to translate the XML or JSON to find values for the subscription process.
270270
* This function exists so that it can be tested as the output is expected in external software:
271-
'subscription_worker'
272-
* Returns a String containing JSON with the granule concept id."
271+
'subscription_worker'
272+
* Returns a String containing JSON."
273273
[concept]
274-
(format "{\"concept-id\": \"%s\"}" (:concept-id concept)))
274+
(let [granule-ur-str (get-in concept [:extra-fields :granule-ur])
275+
concept-id-str (:concept-id concept)
276+
revision-id-str (get concept :revision-id "1")
277+
location-str (get-location-message-str concept)]
278+
(format "{\"concept-id\": \"%s\", \"revision-id\": \"%s\", \"granule-ur\": \"%s\", %s}"
279+
concept-id-str revision-id-str granule-ur-str location-str)))
275280

276281
(defn create-message-attributes
277282
"Create the notification message attributes so that the notifications can be

metadata-db-app/test/cmr/metadata_db/test/services/subscriptions_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@
506506
(let [message-str (.body message)
507507
message (json/decode message-str true)]
508508
(is (= "G12345-PROV1" (:concept-id message)))
509-
(is (= '(:concept-id) (keys message)) "expected output for external subscription_worker")
509+
(is (= '(:concept-id :revision-id :granule-ur :location) (keys message)) "expected output for external subscription_worker")
510510
(is (some? (queue/delete-messages sqs-client queue-url messages)))))))
511511

512512
(deftest publish-subscription-notification-test

0 commit comments

Comments
 (0)