Skip to content

Commit ffe9cac

Browse files
committed
CMR-10502 refactors index.json to config.json
1 parent de0e855 commit ffe9cac

File tree

28 files changed

+72
-71
lines changed

28 files changed

+72
-71
lines changed

Generics.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ Each setting consists of a key, which is the name for the Generic which must be
2929

3030
./{CMR-Root}/schemas/order-option/v0.0.1/
3131
README.md
32-
index.json
32+
config.json
3333
metadata.json
3434
schema.json
3535

3636
CMR will search for Generic definitions using the lower case value of the key (name) and the version number prefixed with a "v". Inside the directory there must be 4 files, three of which are directly read by CMR:
3737

3838
* README.md - for humans
39-
* index.json - Search/Index configuration settings, must comply with [Index Schema][schema-index].
39+
* config.json - Search/Index/Validation configuration settings, must comply with [Config Schema][schema-config].
4040
* metadata.json - sample record, may be called by system-int-tests
4141
* schema.json - A schema document conforming to [JSON Schema][schema].
4242

@@ -103,5 +103,5 @@ Copyright © 2014-2022 United States Government as represented by the Administra
103103

104104
[schema]: https://json-schema.org "JSON Schema definition"
105105
[schema-other]: https://git.earthdata.nasa.gov/scm/emfd/otherschemas.git "Generic Schema Repository"
106-
[schema-index]: https://git.earthdata.nasa.gov/projects/EMFD/repos/otherschemas/browse/Index "Index configuration definition"
106+
[schema-config]: https://git.earthdata.nasa.gov/projects/EMFD/repos/otherschemas/browse/Config " "Generics Configuration definition"
107107
[semver]: https://semver.org "Information on semantic versioning"

common-lib/src/cmr/common/generics.clj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"Return the specific schema given the schema keyword name and version number.
7070
Throw an error if the file can't be read.
7171
Parameters:
72-
* file-name: [metadata | index | schema]
72+
* file-name: [metadata | config | schema]
7373
* generic-keyword: [:grid | ...]
7474
* generic-version: 0.0.1
7575
Returns: string"
@@ -101,21 +101,21 @@
101101
"Cached - Return the specific schema given the schema keyword name and version number.
102102
Throw an error if the file can't be read.
103103
Parameters:
104-
* file-name: [metadata | index | schema]
104+
* file-name: [metadata | config | schema]
105105
* generic-keyword: [:grid | ...]
106106
* generic-version: 0.0.1
107107
Returns: string"
108108
(memoize read-schema-file*))
109109

110-
(defn read-schema-index
111-
"Return the schema index configuration file given the schema name and version
110+
(defn read-schema-config
111+
"Return the schema config file given the schema name and version
112112
number. Throw an error if the file can't be read.
113113
Parameters:
114114
* generic-keyword: [:grid | ...]
115115
* generic-version: 0.0.1
116116
Returns: string"
117117
[generic-keyword generic-version]
118-
(read-schema-file "index" generic-keyword generic-version))
118+
(read-schema-file "config" generic-keyword generic-version))
119119

120120
(defn read-schema-specification
121121
"Return the schema specification file given the schema name and version number.
@@ -151,35 +151,35 @@
151151
schema-obj (js-validater/json-string->json-schema schema-file)]
152152
(js-validater/validate-json schema-obj raw-json throw?))))
153153

154-
(defn validate-index-against-schema
154+
(defn validate-config-against-schema
155155
"Validate a document, returns an array of errors if there are problems
156156
Parameters:
157157
* raw-json, json as a string to validate
158158
Returns: list of errors or nil"
159159
[raw-json]
160-
(validate-metadata-against-schema raw-json :index "0.0.1"))
160+
(validate-metadata-against-schema raw-json :config "0.0.1"))
161161

162162
(defn- approved-generic-concept-prefixes*
163163
"Return the active list of approved generic content types with the defined
164-
prefix in the :SubConceptType field found in the index.json file. If field is
164+
prefix in the :SubConceptType field found in the config.json file. If field is
165165
not defined, then X is used.
166166
Parameters: none, based off approved-documents?
167167
Return: {doc-type \"concept-prefix\"}"
168168
[]
169169
(reduce (fn [data item]
170170
(let [generic-keyword (first item)
171-
index-raw (read-schema-index generic-keyword (second item))
172-
parse-errors (validate-index-against-schema index-raw)]
171+
config-raw (read-schema-config generic-keyword (second item))
172+
parse-errors (validate-config-against-schema config-raw)]
173173
(when-not (some? parse-errors)
174174
(assoc data
175175
generic-keyword
176-
(get (json/parse-string index-raw true) :SubConceptType "X")))))
176+
(get (json/parse-string config-raw true) :SubConceptType "X")))))
177177
{}
178178
(latest-approved-documents)))
179179

180180
(def approved-generic-concept-prefixes
181181
"Cached - Return the active list of approved generic content types with the defined
182-
prefix in the :SubConceptType field found in the index.json file. If field is
182+
prefix in the :SubConceptType field found in the config.json file. If field is
183183
not defined, then X is used.
184184
Parameters: none, based off approved-documents?
185185
Return: {doc-type \"concept-prefix\"}"

indexer-app/src/cmr/indexer/data/concepts/generic.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
(meta-db/get-generic-associations-for-concept context concept))
102102
gen-name (csk/->kebab-case (get-in parsed-concept [:MetadataSpecification :Name] ""))
103103
gen-ver (get-in parsed-concept [:MetadataSpecification :Version])
104-
index-data-file (format "schemas/%s/v%s/index.json" gen-name gen-ver)
104+
index-data-file (format "schemas/%s/v%s/config.json" gen-name gen-ver)
105105
index-file-raw (slurp (io/resource index-data-file))
106106
index-data (json/parse-string index-file-raw true)
107107
schema-keys [:LongName
@@ -173,7 +173,7 @@
173173
version (generics/current-generic-version concept-type)
174174
gen-name (csk/->kebab-case (get-in parsed-concept [:MetadataSpecification :Name] ""))
175175
gen-ver (get-in parsed-concept [:MetadataSpecification :Version])
176-
index-data-file (format "schemas/%s/v%s/index.json" (name concept-type) version)
176+
index-data-file (format "schemas/%s/v%s/config.json" (name concept-type) version)
177177
index-file-raw (slurp (io/resource index-data-file))
178178
index-data (json/parse-string index-file-raw true)
179179
common-doc ;; fields common to all generic documents

indexer-app/src/cmr/indexer/data/index_set_generics.clj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Parameters:
1616
* raw-json, json as a string to validate"
1717
[raw-json]
18-
(let [schema-file (slurp (io/resource "schemas/index/v0.0.1/schema.json"))
18+
(let [schema-file (slurp (io/resource "schemas/config/v0.0.1/schema.json"))
1919
schema-obj (js-validater/json-string->json-schema schema-file)]
2020
(js-validater/validate-json schema-obj raw-json)))
2121

@@ -120,13 +120,13 @@
120120
if the file can't be read."
121121
[gen-name gen-version]
122122
(try
123-
(-> "schemas/%s/v%s/index.json"
123+
(-> "schemas/%s/v%s/config.json"
124124
(format (name gen-name) gen-version)
125125
(io/resource)
126126
(slurp))
127127
(catch Exception e
128128
(error
129-
(format (str "The index.json file for schema [%s] version [%s] cannot be found. Please make sure that it exists."
129+
(format (str "The config.json file for schema [%s] version [%s] cannot be found. Please make sure that it exists."
130130
(.getMessage e))
131131
gen-name
132132
gen-version)))))
@@ -140,7 +140,7 @@
140140
(try
141141
(validate-index-against-schema raw-json)
142142
(catch java.lang.NullPointerException npe
143-
(let [msg (format "%s : Null Pointer Exception while trying to validate index.json for %s."
143+
(let [msg (format "%s : Null Pointer Exception while trying to validate config.json for %s."
144144
(.getMessage npe)
145145
schema)]
146146
(error msg)
@@ -169,7 +169,7 @@
169169
{:generic-grid
170170
{:indexes []
171171
:mapping {:properties {:index-key-name {:type 'type'}}}}}
172-
If the matching index.json file is not valid, then that schema will be logged and skipped.
172+
If the matching config.json file is not valid, then that schema will be logged and skipped.
173173
"
174174
[]
175175
(reduce (fn [data gen-keyword]
@@ -191,7 +191,7 @@
191191
:settings generic-settings}]
192192
:mapping {:properties (reduce mapping->index-key base-indexes index-list)}})
193193
(do
194-
(error (format "Could not parse the index.json file for %s version %s."
194+
(error (format "Could not parse the config.json file for %s version %s."
195195
gen-name
196196
gen-ver))
197197
data))))
@@ -200,7 +200,7 @@
200200

201201
(comment
202202
;; Since the change to distribute schemas files as a JAR makes it hard to test
203-
;; a bad index.json, add the following line after the index-definition-str
203+
;; a bad config.json, add the following line after the index-definition-str
204204
;; declare in the let and run the function below
205205

206206
;index-definition-str (if (= :grid gen-keyword) "{bad-json}" index-definition-str)

ingest-app/src/cmr/ingest/validation/generic_document_validation.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
[concept-type version]
100100
(try
101101
(if (generics/approved-generic? concept-type version)
102-
(let [schema-json (generics/read-schema-index concept-type version)
102+
(let [schema-json (generics/read-schema-config concept-type version)
103103
schema (json/parse-string schema-json true)]
104104
(fn [context concept]
105105
(validate-with-schema context concept schema)))

schemas/resources/schemas/citation/v1.0.0/index.json renamed to schemas/resources/schemas/citation/v1.0.0/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"MetadataSpecification": {
3-
"URL": "https://cdn.earthdata.nasa.gov/generic/index/v0.0.1",
4-
"Name": "Generic-Index",
3+
"URL": "https://cdn.earthdata.nasa.gov/generic/config/v0.0.1",
4+
"Name": "Generic-Config",
55
"Version": "0.0.1"
66
},
77
"Generic": {

schemas/resources/schemas/collection-draft/v1.0.0/index.json renamed to schemas/resources/schemas/collection-draft/v1.0.0/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"MetadataSpecification": {
3-
"URL": "https://cdn.earthdata.nasa.gov/generic/index/v0.0.1",
4-
"Name": "Generic-Index",
3+
"URL": "https://cdn.earthdata.nasa.gov/generic/config/v0.0.1",
4+
"Name": "Generic-Config",
55
"Version": "0.0.1"
66
},
77
"Generic": {
File renamed without changes.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Index Schema
1+
# Config Schema
22

33
Define index fields that need to be indexed and the properties needed to create
44
these indexes.
5+
6+
Define validations on fields to be indexed.

schemas/resources/schemas/index/v0.0.1/metadata.json renamed to schemas/resources/schemas/config/v0.0.1/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"MetadataSpecification": {
3-
"URL": "https://cdn.earthdata.nasa.gov/generic/index/v0.0.1",
4-
"Name": "Generic-Index",
3+
"URL": "https://cdn.earthdata.nasa.gov/generic/config/v0.0.1",
4+
"Name": "Generic-Config",
55
"Version": "0.0.1"
66
},
77
"Generic": {

0 commit comments

Comments
 (0)