Skip to content

Commit

Permalink
Revert "CMR-7765 add Format and MimeType to umm t umm s (#1522)"
Browse files Browse the repository at this point in the history
CMR-7765 not yet verified at the time of release branch creation.

This reverts commit cbf54cc.
  • Loading branch information
jwteague committed Apr 11, 2022
1 parent 6a03d8c commit e1e9370
Show file tree
Hide file tree
Showing 25 changed files with 24 additions and 3,403 deletions.
4 changes: 2 additions & 2 deletions ingest-app/src/cmr/ingest/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
(defconfig service-umm-version
"Defines the latest service umm version accepted by ingest - it's the latest official version.
This environment variable needs to be manually set when newer UMM version becomes official"
{:default "1.5.0"})
{:default "1.4.1"})

(defconfig tool-umm-version
"Defines the latest tool umm version accepted by ingest - it's the latest official version.
This environment variable needs to be manually set when newer UMM version becomes official"
{:default "1.2.0"})
{:default "1.1.1"})

(defconfig subscription-umm-version
"Defines the latest subscription umm version accepted by ingest - it's the latest official version.
Expand Down
17 changes: 4 additions & 13 deletions ingest-app/src/cmr/ingest/services/ingest_service/service.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[cmr.common.util :refer [defn-timed]]
[cmr.common.services.errors :as errors]
[cmr.common-app.services.kms-fetcher :as kms-fetcher]
[cmr.common.validations.core :as cm-validation]
[cmr.ingest.services.messages :as msg]
[cmr.ingest.validation.validation :as validation]
[cmr.transmit.metadata-db2 :as mdb2]
Expand Down Expand Up @@ -34,18 +33,10 @@
"Create a kms match validator for use by validation-service"
[context]
(let [kms-index (kms-fetcher/get-kms-index context)]
[{:RelatedURLs [(validation/match-kms-keywords-validation
kms-index
:related-urls
msg/related-url-content-type-type-subtype-not-matching-kms-keywords)
(cm-validation/every [{:Format (validation/match-kms-keywords-validation-single
kms-index
:granule-data-format
msg/getdata-format-not-matches-kms-keywords)}
{:MimeType (validation/match-kms-keywords-validation-single
kms-index
:mime-type
msg/mime-type-not-matches-kms-keywords)}])]}]))
[{:RelatedURLs (validation/match-kms-keywords-validation
kms-index
:related-urls
msg/related-url-content-type-type-subtype-not-matching-kms-keywords)}]))

(defn- validate-all-fields
"Check all fields that need to be validated. Currently this is the Related URL Content Type, Type, and
Expand Down
18 changes: 4 additions & 14 deletions ingest-app/src/cmr/ingest/services/ingest_service/tool.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[cmr.common.util :refer [defn-timed]]
[cmr.common.services.errors :as errors]
[cmr.common-app.services.kms-fetcher :as kms-fetcher]
[cmr.common.validations.core :as cm-validation]
[cmr.ingest.services.messages :as msg]
[cmr.ingest.validation.validation :as validation]
[cmr.transmit.metadata-db2 :as mdb2]
Expand All @@ -27,19 +26,10 @@
"Create a kms match validator for use by validation-tool"
[context]
(let [kms-index (kms-fetcher/get-kms-index context)]
[{:RelatedURLs [(validation/match-kms-keywords-validation
kms-index
:related-urls
msg/related-url-content-type-type-subtype-not-matching-kms-keywords)
(cm-validation/every [{:Format (validation/match-kms-keywords-validation-single
kms-index
:granule-data-format
msg/getdata-format-not-matches-kms-keywords)}
{:MimeType (validation/match-kms-keywords-validation-single
kms-index
:mime-type
msg/mime-type-not-matches-kms-keywords)}])]

[{:RelatedURLs (validation/match-kms-keywords-validation
kms-index
:related-urls
msg/related-url-content-type-type-subtype-not-matching-kms-keywords)
:URL (validation/match-kms-keywords-validation-single
kms-index
:related-urls
Expand Down
2 changes: 1 addition & 1 deletion ingest-app/src/cmr/ingest/services/messages.clj
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"Error message when relatedurl-mimetype is
not in the KMS."
[relatedurl-mime-type]
(format "MimeType [%s] was not a valid keyword."
(format "Mime Type [%s] was not a valid keyword."
relatedurl-mime-type))

(defn directory-name-not-matches-kms-keywords
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
:ValueType "https://schema.org/startDate"}
{:ValueName "bbox"
:ValueType "https://schema.org/box"}]}
:MetadataSpecification {:URL "https://cdn.earthdata.nasa.gov/umm/tool/v1.2.0"
:MetadataSpecification {:URL "https://cdn.earthdata.nasa.gov/umm/tool/v1.1.1"
:Name "UMM-T"
:Version "1.2.0"}})
:Version "1.1.1"}})

(defn- tool
"Returns a UMM-T record from the given attribute map."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,84 +257,3 @@
"Very Closed Search"
2
(second errors)))))

(deftest related-url-format-mimetype-check
(testing "Check valid and invalid Format and MimeType in RelatedURLs at ingest."
(let [related-urls-valid [{"URL" "https://example.gov/good"
"URLContentType" "PublicationURL"
"Type" "VIEW RELATED INFORMATION"
"Subtype" "HOW-TO"
"Format" "ASCII"
"MimeType" "application/xml"}]
related-urls-invalid1 [{"URL" "https://example.gov/one-error"
"URLContentType" "PublicationURL"
"Type" "VIEW RELATED INFORMATION"
"Subtype" "HOW-TO"
"Format" "invalid"
"MimeType" "application/xml"}]
related-urls-invalid2 [{"URL" "https://example.gov/one-error"
"URLContentType" "PublicationURL"
"Type" "VIEW RELATED INFORMATION"
"Subtype" "HOW-TO"
"Format" "ASCII"
"MimeType" "invalid"}]
related-urls-invalid3 [{"URL" "https://example.gov/two-errors"
"URLContentType" "PublicationURL"
"Type" "VIEW RELATED INFORMATION"
"Subtype" "HOW-TO"
"Format" "invalid"
"MimeType" "invalid"}]
concept-src1 (service-util/make-service-concept)
concept-result1 (as-> concept-src1 intermediate
(json/parse-string (:metadata intermediate))
(assoc intermediate "RelatedURLs" related-urls-valid)
(json/generate-string intermediate)
(assoc concept-src1 :metadata intermediate)
(ingest/ingest-concept intermediate))
concept-src2 (service-util/make-service-concept)
concept-result2 (as-> concept-src2 intermediate
(json/parse-string (:metadata intermediate))
(assoc intermediate "RelatedURLs" related-urls-invalid1)
(json/generate-string intermediate)
(assoc concept-src2 :metadata intermediate)
(ingest/ingest-concept intermediate))
concept-src3 (service-util/make-service-concept)
concept-result3 (as-> concept-src3 intermediate
(json/parse-string (:metadata intermediate))
(assoc intermediate "RelatedURLs" related-urls-invalid2)
(json/generate-string intermediate)
(assoc concept-src3 :metadata intermediate)
(ingest/ingest-concept intermediate))
concept-src4 (service-util/make-service-concept)
concept-result4 (as-> concept-src4 intermediate
(json/parse-string (:metadata intermediate))
(assoc intermediate "RelatedURLs" related-urls-invalid3)
(json/generate-string intermediate)
(assoc concept-src4 :metadata intermediate)
(ingest/ingest-concept intermediate))
status1 (:status concept-result1)
errors1 (:errors concept-result1)
status2 (:status concept-result2)
errors2 (:errors concept-result2)
status3 (:status concept-result3)
errors3 (:errors concept-result3)
status4 (:status concept-result4)
errors4 (:errors concept-result4)]
;; The first RelatedURLs contains a valid Format and MimeType so no errors.
(is (= 201 status1))
(is (= 0 (count errors1)))

;; The second RelatedURLs contains an invalid Format, so the result contains one error.
(is (= 400 status2))
(is (= 1 (count errors2)))
(is (= [{:path ["RelatedUrLs" 0 "Format"], :errors ["Format [invalid] was not a valid keyword."]}] errors2))

;; The third RelatedURLs contains an invalid MimeType, so the result contains one error.
(is (= 400 status3))
(is (= 1 (count errors3)))
(is (= [{:path ["RelatedUrLs" 0 "MimeType"], :errors ["MimeType [invalid] was not a valid keyword."]}] errors3))

;; The last RelatedURLs contains an invalid Format and an invalid MimeType, so the result contains two errors.
(is (= 400 status4))
(is (= 2 (count errors4)))
(is (= [{:path ["RelatedUrLs" 0 "Format"], :errors ["Format [invalid] was not a valid keyword."]} {:path ["RelatedUrLs" 0 "MimeType"], :errors ["MimeType [invalid] was not a valid keyword."]}] errors4)))))
Original file line number Diff line number Diff line change
Expand Up @@ -265,85 +265,3 @@
(is (= 3 (count errors1)))
(is (= 400 status2))
(is (= 2 (count errors2))))))

(deftest related-url-format-mimetype-check
(testing "Check valid and invalid Format and MimeType in RelatedURLs at ingest."
(let [related-urls-valid [{"URL" "https://example.gov/good"
"URLContentType" "PublicationURL"
"Type" "VIEW RELATED INFORMATION"
"Subtype" "HOW-TO"
"Format" "ASCII"
"MimeType" "application/xml"}]
related-urls-invalid1 [{"URL" "https://example.gov/one-error"
"URLContentType" "PublicationURL"
"Type" "VIEW RELATED INFORMATION"
"Subtype" "HOW-TO"
"Format" "invalid"
"MimeType" "application/xml"}]
related-urls-invalid2 [{"URL" "https://example.gov/one-error"
"URLContentType" "PublicationURL"
"Type" "VIEW RELATED INFORMATION"
"Subtype" "HOW-TO"
"Format" "ASCII"
"MimeType" "invalid"}]
related-urls-invalid3 [{"URL" "https://example.gov/two-errors"
"URLContentType" "PublicationURL"
"Type" "VIEW RELATED INFORMATION"
"Subtype" "HOW-TO"
"Format" "invalid"
"MimeType" "invalid"}]
concept-src1 (tool-util/make-tool-concept)
concept-result1 (as-> concept-src1 intermediate
(json/parse-string (:metadata intermediate))
(assoc intermediate "RelatedURLs" related-urls-valid)
(json/generate-string intermediate)
(assoc concept-src1 :metadata intermediate)
(ingest/ingest-concept intermediate))
concept-src2 (tool-util/make-tool-concept)
concept-result2 (as-> concept-src2 intermediate
(json/parse-string (:metadata intermediate))
(assoc intermediate "RelatedURLs" related-urls-invalid1)
(json/generate-string intermediate)
(assoc concept-src2 :metadata intermediate)
(ingest/ingest-concept intermediate))
concept-src3 (tool-util/make-tool-concept)
concept-result3 (as-> concept-src3 intermediate
(json/parse-string (:metadata intermediate))
(assoc intermediate "RelatedURLs" related-urls-invalid2)
(json/generate-string intermediate)
(assoc concept-src3 :metadata intermediate)
(ingest/ingest-concept intermediate))
concept-src4 (tool-util/make-tool-concept)
concept-result4 (as-> concept-src4 intermediate
(json/parse-string (:metadata intermediate))
(assoc intermediate "RelatedURLs" related-urls-invalid3)
(json/generate-string intermediate)
(assoc concept-src4 :metadata intermediate)
(ingest/ingest-concept intermediate))
status1 (:status concept-result1)
errors1 (:errors concept-result1)
status2 (:status concept-result2)
errors2 (:errors concept-result2)
status3 (:status concept-result3)
errors3 (:errors concept-result3)
status4 (:status concept-result4)
errors4 (:errors concept-result4)]
;; The first RelatedURLs contains a valid Format and MimeType so no errors.
(is (= 201 status1))
(is (= 0 (count errors1)))

;; The second RelatedURLs contains an invalid Format, so the result contains one error.
(is (= 400 status2))
(is (= 1 (count errors2)))
(is (= [{:path ["RelatedUrLs" 0 "Format"], :errors ["Format [invalid] was not a valid keyword."]}] errors2))

;; The third RelatedURLs contains an invalid MimeType, so the result contains one error.
(is (= 400 status3))
(is (= 1 (count errors3)))
(is (= [{:path ["RelatedUrLs" 0 "MimeType"], :errors ["MimeType [invalid] was not a valid keyword."]}] errors3))

;; The last RelatedURLs contains an invalid Format and an invalid MimeType, so the result contains two errors.
(is (= 400 status4))
(is (= 2 (count errors4)))
(is (= [{:path ["RelatedUrLs" 0 "Format"], :errors ["Format [invalid] was not a valid keyword."]}
{:path ["RelatedUrLs" 0 "MimeType"], :errors ["MimeType [invalid] was not a valid keyword."]}] errors4)))))
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@
{:MimeType "application/x-hdf42"}
[422]
[{:path ["RelatedUrLs" 0 "MimeType"]
:errors ["MimeType [application/x-hdf42] was not a valid keyword."]}])
:errors ["Mime Type [application/x-hdf42] was not a valid keyword."]}])

(side/eval-form `(ingest-config/set-validate-umm-var-keywords! false))))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,8 @@
{:accept (mime-types/with-version mime-types/umm-json umm-version/current-service-version)}

"explicit UMM JSON version through suffix"
"1.5.0"
{:url-extension "umm_json_v1_5_0"})))
"1.4.1"
{:url-extension "umm_json_v1_4_1"})))

(testing "Searching with non-existent UMM JSON version"
(are3 [options]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@
{:accept (mime-types/with-version mime-types/umm-json umm-version/current-tool-version)}

"explicit UMM JSON version through suffix"
"1.2.0"
{:url-extension "umm_json_v1_2_0"})))
"1.1.1"
{:url-extension "umm_json_v1_1_1"})))

(testing "Searching with non-existent UMM JSON version"
(are3 [options]
Expand Down
Loading

0 comments on commit e1e9370

Please sign in to comment.