|
8 | 8 | [cmr.common.services.errors :as errors] |
9 | 9 | [cmr.transmit.config :as config] |
10 | 10 | [cmr.transmit.connection :as conn] |
11 | | - [cmr.transmit.http-helper :as h] |
| 11 | + [cmr.transmit.http-helper :as http-helper] |
12 | 12 | [ring.util.codec :as codec])) |
13 | 13 |
|
14 | 14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
56 | 56 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
57 | 57 | ;; Request functions |
58 | 58 | (declare reset) |
59 | | -(h/defresetter reset :metadata-db) |
| 59 | +(http-helper/defresetter reset :metadata-db) |
60 | 60 |
|
61 | 61 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
62 | 62 | ;; Provider functions |
63 | 63 | (declare create-provider update-provider delete-provider) |
64 | | -(h/defcreator create-provider :metadata-db providers-url {:use-system-token? true}) |
65 | | -(h/defupdater update-provider :metadata-db provider-url {:use-system-token? true}) |
66 | | -(h/defdestroyer delete-provider :metadata-db provider-url {:use-system-token? true}) |
| 64 | +(http-helper/defcreator create-provider :metadata-db providers-url {:use-system-token? true}) |
| 65 | +(http-helper/defupdater update-provider :metadata-db provider-url {:use-system-token? true}) |
| 66 | +(http-helper/defdestroyer delete-provider :metadata-db provider-url {:use-system-token? true}) |
67 | 67 |
|
68 | 68 | (defn get-providers |
69 | 69 | "Returns the list of providers configured in the metadata db. Valid options are |
|
77 | 77 | ([context {:keys [raw? http-options token]}] |
78 | 78 | (let [token (or token (:token context)) |
79 | 79 | headers (when token {config/token-header token})] |
80 | | - (h/request context :metadata-db |
81 | | - {:url-fn providers-url |
| 80 | + (http-helper/request context :metadata-db |
| 81 | + {:url-fn providers-url |
82 | 82 | :method :get |
83 | 83 | :raw? raw? |
84 | | - :http-options (h/include-request-id context (merge {:accept :json |
85 | | - :headers headers} |
86 | | - http-options))})))) |
| 84 | + :http-options (http-helper/include-request-id context (merge {:accept :json |
| 85 | + :headers headers} |
| 86 | + http-options))})))) |
87 | 87 |
|
88 | 88 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
89 | 89 | ;; Concept functions |
90 | 90 | (declare save-concept) |
91 | | -(h/defcreator save-concept :metadata-db concepts-url {:use-system-token? true}) |
| 91 | +(http-helper/defcreator save-concept :metadata-db concepts-url {:use-system-token? true}) |
92 | 92 |
|
93 | 93 | (defn get-concept-id |
94 | 94 | "Returns a concept id for the given concept type, provider, and native id" |
95 | 95 | ([context concept-type provider-id native-id] |
96 | 96 | (get-concept-id context concept-type provider-id native-id nil)) |
97 | 97 | ([context concept-type provider-id native-id {:keys [raw? http-options]}] |
98 | | - (let [response (h/request context :metadata-db |
99 | | - {:url-fn #(concept-id-url % concept-type provider-id native-id) |
100 | | - :method :get |
101 | | - :raw? raw? |
102 | | - :use-system-token? true |
103 | | - :http-options (h/include-request-id context (merge {:accept :json} http-options))})] |
| 98 | + (let [response (http-helper/request context :metadata-db |
| 99 | + {:url-fn #(concept-id-url % concept-type provider-id native-id) |
| 100 | + :method :get |
| 101 | + :raw? raw? |
| 102 | + :use-system-token? true |
| 103 | + :http-options (http-helper/include-request-id context (merge {:accept :json} http-options))})] |
104 | 104 | (if raw? |
105 | 105 | response |
106 | 106 | (:concept-id response))))) |
|
115 | 115 | (find-concepts context params concept-type nil)) |
116 | 116 | ([context params concept-type {:keys [raw? http-options]}] |
117 | 117 | (-> context |
118 | | - (h/request :metadata-db |
119 | | - {:url-fn #(concept-search-url % concept-type) |
120 | | - :method :get |
121 | | - :raw? raw? |
122 | | - :use-system-token? true |
123 | | - :http-options (h/include-request-id context (merge {:accept :json} http-options params))}) |
| 118 | + (http-helper/request :metadata-db |
| 119 | + {:url-fn #(concept-search-url % concept-type) |
| 120 | + :method :get |
| 121 | + :raw? raw? |
| 122 | + :use-system-token? true |
| 123 | + :http-options (http-helper/include-request-id context (merge {:accept :json} http-options params))}) |
124 | 124 | finish-parse-concept))) |
125 | 125 |
|
126 | 126 | (defn get-concept |
|
132 | 132 | (get-concept context concept-id revision-id nil)) |
133 | 133 | ([context concept-id revision-id {:keys [raw? http-options]}] |
134 | 134 | (-> context |
135 | | - (h/request :metadata-db |
136 | | - {:url-fn #(concept-revision-url % concept-id revision-id) |
| 135 | + (http-helper/request :metadata-db |
| 136 | + {:url-fn #(concept-revision-url % concept-id revision-id) |
137 | 137 | :method :get |
138 | 138 | :raw? raw? |
139 | 139 | :use-system-token? true |
140 | | - :http-options (h/include-request-id context (merge {:accept :json} http-options))}) |
| 140 | + :http-options (http-helper/include-request-id context (merge {:accept :json} http-options))}) |
141 | 141 | finish-parse-concept))) |
142 | 142 |
|
143 | 143 | (defn get-latest-concept |
|
149 | 149 | (get-latest-concept context concept-id nil)) |
150 | 150 | ([context concept-id {:keys [raw? http-options]}] |
151 | 151 | (-> context |
152 | | - (h/request :metadata-db |
153 | | - {:url-fn #(latest-concept-url % concept-id) |
| 152 | + (http-helper/request :metadata-db |
| 153 | + {:url-fn #(latest-concept-url % concept-id) |
154 | 154 | :method :get |
155 | 155 | :raw? raw? |
156 | 156 | :use-system-token? true |
157 | | - :http-options (h/include-request-id context (merge {:accept :json} http-options))}) |
| 157 | + :http-options (http-helper/include-request-id context (merge {:accept :json} http-options))}) |
158 | 158 | finish-parse-concept))) |
159 | 159 |
|
160 | 160 | ;; Defines health check function |
161 | 161 | (declare get-metadata-db-health) |
162 | | -(h/defhealther get-metadata-db-health :metadata-db {:timeout-secs 2}) |
| 162 | +(http-helper/defhealther get-metadata-db-health :metadata-db {:timeout-secs 2}) |
163 | 163 |
|
164 | 164 |
|
165 | 165 | (defn get-subscription-cache-content |
166 | 166 | "Retrieves the cache contents of the ingest subscription cache." |
167 | 167 | ([context coll-concept-id] |
168 | 168 | (get-subscription-cache-content context coll-concept-id nil)) |
169 | 169 | ([context coll-concept-id {:keys [raw? http-options]}] |
170 | | - (let [ |
171 | | - conn (config/context->app-connection context :metadata-db) |
| 170 | + (let [conn (config/context->app-connection context :metadata-db) |
172 | 171 | request-url (str (conn/root-url conn) "/subscription/cache-content") |
173 | 172 | params (merge |
174 | 173 | (config/conn-params conn) |
|
178 | 177 | (ch/context->http-headers context) |
179 | 178 | {:client-id config/cmr-client-id}) |
180 | 179 | :throw-exceptions false |
181 | | - :http-options (h/include-request-id context {})}) |
| 180 | + :http-options (http-helper/include-request-id context {})}) |
182 | 181 | response (client/get request-url params) |
183 | 182 | {:keys [status body]} response |
184 | 183 | status (int status)] |
|
0 commit comments