Skip to content

Commit 9d9c9e2

Browse files
Merge pull request #711 from samply/release-v0.17.3
Release v0.17.3
2 parents 993a97f + 2591dc6 commit 9d9c9e2

File tree

10 files changed

+170
-73
lines changed

10 files changed

+170
-73
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## v0.17.3
4+
5+
### Bugfixes
6+
7+
* Fix Content Negotiation ([#710](https://github.com/samply/blaze/pull/710))
8+
9+
The full changelog can be found [here](https://github.com/samply/blaze/milestone/41?closed=1).
10+
311
## v0.17.2
412

513
### Bugfixes

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The goal of this project is to provide a FHIR® Store with an internal CQL Evalu
1414

1515
Blaze passes all [Touchstone FHIR 4.0.1 Basic Tests][12] and almost all [CQL Tests][3]. Please refer to the [Conformance](docs/conformance.md) section and report any issues you encounter during evaluation.
1616

17-
Latest release: [v0.17.2][5]
17+
Latest release: [v0.17.3][5]
1818

1919
## Quick Start
2020

@@ -72,7 +72,7 @@ Unless required by applicable law or agreed to in writing, software distributed
7272

7373
[3]: <https://cql.hl7.org/tests.html>
7474
[4]: <https://alexanderkiel.gitbook.io/blaze/deployment>
75-
[5]: <https://github.com/samply/blaze/releases/tag/v0.17.2>
75+
[5]: <https://github.com/samply/blaze/releases/tag/v0.17.3>
7676
[6]: <https://www.yourkit.com/java/profiler/>
7777
[7]: <https://www.yourkit.com/.net/profiler/>
7878
[8]: <https://www.yourkit.com/youmonitor/>

docs/deployment/docker-deployment.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Blaze should log something like this:
2727
2021-06-27T11:02:37.834Z ee086ef908c1 main INFO [blaze.core:64] - JVM version: 16.0.2
2828
2021-06-27T11:02:37.834Z ee086ef908c1 main INFO [blaze.core:65] - Maximum available memory: 1738 MiB
2929
2021-06-27T11:02:37.835Z ee086ef908c1 main INFO [blaze.core:66] - Number of available processors: 8
30-
2021-06-27T11:02:37.836Z ee086ef908c1 main INFO [blaze.core:67] - Successfully started Blaze version 0.17.2 in 8.2 seconds
30+
2021-06-27T11:02:37.836Z ee086ef908c1 main INFO [blaze.core:67] - Successfully started Blaze version 0.17.3 in 8.2 seconds
3131
```
3232

3333
In order to test connectivity, query the health endpoint:
@@ -47,7 +47,7 @@ that should return:
4747
```json
4848
{
4949
"name": "Blaze",
50-
"version": "0.17.2"
50+
"version": "0.17.3"
5151
}
5252
```
5353

docs/deployment/manual-deployment.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
The installation works under Windows, Linux and macOS. The only dependency is an installed OpenJDK 11. Blaze is tested with [AdoptOpenJDK][1].
44

5-
Blaze runs on the JVM and comes as single JAR file. Download the most recent version [here](https://github.com/samply/blaze/releases/tag/v0.17.2). Look for `blaze-0.17.2-standalone.jar`.
5+
Blaze runs on the JVM and comes as single JAR file. Download the most recent version [here](https://github.com/samply/blaze/releases/tag/v0.17.3). Look for `blaze-0.17.3-standalone.jar`.
66

77
After the download, you can start blaze with the following command (Linux, macOS):
88

99
```sh
10-
java -jar blaze-0.17.2-standalone.jar -m blaze.core
10+
java -jar blaze-0.17.3-standalone.jar -m blaze.core
1111
```
1212

1313
Blaze will run with an in-memory, volatile database for testing and demo purposes.
@@ -17,14 +17,14 @@ Blaze can be run with durable storage by setting the environment variables `STOR
1717
Under Linux/macOS:
1818

1919
```sh
20-
STORAGE=standalone java -jar blaze-0.17.2-standalone.jar -m blaze.core
20+
STORAGE=standalone java -jar blaze-0.17.3-standalone.jar -m blaze.core
2121
```
2222

2323
Under Windows, you need to set the Environment variables in the PowerShell before starting Blaze:
2424

2525
```powershell
2626
$Env:STORAGE="standalone"
27-
java -jar blaze-0.17.2-standalone.jar -m blaze.core
27+
java -jar blaze-0.17.3-standalone.jar -m blaze.core
2828
```
2929

3030
This will create three directories called `index`, `transaction` and `resource` inside the current working directory, one for each database part used.
@@ -42,7 +42,7 @@ The output should look like this:
4242
2021-06-27T11:02:37.834Z ee086ef908c1 main INFO [blaze.core:64] - JVM version: 16.0.2
4343
2021-06-27T11:02:37.834Z ee086ef908c1 main INFO [blaze.core:65] - Maximum available memory: 1738 MiB
4444
2021-06-27T11:02:37.835Z ee086ef908c1 main INFO [blaze.core:66] - Number of available processors: 8
45-
2021-06-27T11:02:37.836Z ee086ef908c1 main INFO [blaze.core:67] - Successfully started Blaze version 0.17.2 in 8.2 seconds
45+
2021-06-27T11:02:37.836Z ee086ef908c1 main INFO [blaze.core:67] - Successfully started Blaze version 0.17.3 in 8.2 seconds
4646
```
4747

4848
In order to test connectivity, query the health endpoint:
@@ -62,7 +62,7 @@ that should return:
6262
```json
6363
{
6464
"name": "Blaze",
65-
"version": "0.17.2"
65+
"version": "0.17.3"
6666
}
6767
```
6868

modules/rest-api/src/blaze/rest_api/capabilities.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
:copyright
118118
#fhir/markdown"Copyright 2019 - 2022 The Samply Community\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."
119119
:kind #fhir/code"instance"
120-
:date #fhir/dateTime"2022-05-07"
120+
:date #fhir/dateTime"2022-05-10"
121121
:software
122122
{:name "Blaze"
123123
:version version}

modules/rest-api/src/blaze/rest_api/middleware/output.clj

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
[blaze.fhir.spec :as fhir-spec]
55
[clojure.data.xml :as xml]
66
[clojure.java.io :as io]
7-
[clojure.string :as str]
87
[muuntaja.parse :as parse]
98
[prometheus.alpha :as prom]
109
[ring.util.response :as ring]
@@ -42,38 +41,48 @@
4241
(generate-xml* body)))
4342

4443

45-
(defn- encode-response-json [response]
44+
(defn- encode-response-json [response content-type]
4645
(-> (update response :body generate-json)
47-
(ring/content-type "application/fhir+json;charset=utf-8")))
46+
(ring/content-type content-type)))
4847

4948

50-
(defn- encode-response-xml [response]
49+
(defn- encode-response-xml [response content-type]
5150
(-> (update response :body generate-xml)
52-
(ring/content-type "application/fhir+xml;charset=utf-8")))
53-
54-
55-
(defn- json-format? [format]
56-
(or (str/includes? format "json") (#{"*/*" "application/*" "text/*"} format)))
51+
(ring/content-type content-type)))
5752

5853

5954
(defn- format-key [format]
60-
(cond
61-
(json-format? format) :json
62-
(str/includes? format "xml") :xml))
55+
(condp = format
56+
"application/fhir+json" :fhir+json
57+
"application/fhir+xml" :fhir+xml
58+
"application/json" :json
59+
"application/xml" :xml
60+
"text/json" :text-json
61+
"text/xml" :text-xml
62+
"*/*" :fhir+json
63+
"application/*" :fhir+json
64+
"text/*" :text-json
65+
"json" :fhir+json
66+
"xml" :fhir+xml
67+
nil))
6368

6469

6570
(defn- request-format
6671
[{{:strs [accept]} :headers {format "_format"} :query-params}]
6772
(or (some-> format format-key)
68-
(if-let [first-accept (first (parse-accept accept))]
69-
(format-key first-accept)
70-
:json)))
73+
(if-let [accept (parse-accept accept)]
74+
(some format-key accept)
75+
:fhir+json)))
7176

7277

7378
(defn- encode-response [opts request response]
7479
(case (request-format request)
75-
:json (encode-response-json response)
76-
:xml (encode-response-xml response)
80+
:fhir+json (encode-response-json response "application/fhir+json;charset=utf-8")
81+
:fhir+xml (encode-response-xml response "application/fhir+xml;charset=utf-8")
82+
:json (encode-response-json response "application/json;charset=utf-8")
83+
:xml (encode-response-xml response "application/xml;charset=utf-8")
84+
:text-json (encode-response-json response "text/json;charset=utf-8")
85+
:text-xml (encode-response-xml response "text/xml;charset=utf-8")
7786
(when (:accept-all? opts) (dissoc response :body))))
7887

7988

modules/rest-api/test/blaze/rest_api/middleware/output_test.clj

Lines changed: 122 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
(ns blaze.rest-api.middleware.output-test
22
(:require
3+
[blaze.fhir.spec :as fhir-spec]
34
[blaze.fhir.spec-spec]
45
[blaze.rest-api.middleware.output :refer [wrap-output]]
56
[blaze.test-util :as tu]
67
[blaze.test-util.ring :refer [call]]
8+
[clojure.data.xml :as xml]
9+
[clojure.java.io :as io]
710
[clojure.spec.test.alpha :as st]
811
[clojure.test :as test :refer [are deftest is testing]]
912
[juxt.iota :refer [given]]
1013
[ring.util.response :as ring]
11-
[taoensso.timbre :as log])
12-
(:import
13-
[java.nio.charset StandardCharsets]))
14+
[taoensso.timbre :as log]))
1415

1516

1617
(st/instrument)
@@ -34,74 +35,153 @@
3435
(respond (ring/response {:fhir/type :fhir/Patient :id "0"})))))
3536

3637

37-
(defn- bytes->str [^bytes bs]
38-
(String. bs StandardCharsets/UTF_8))
38+
(defn- parse-json [body]
39+
(fhir-spec/conform-json (fhir-spec/parse-json body)))
3940

4041

4142
(deftest json-test
4243
(testing "JSON is the default"
4344
(testing "without accept header"
4445
(given (call resource-handler {})
45-
[:body bytes->str] := "{\"id\":\"0\",\"resourceType\":\"Patient\"}"))
46+
[:headers "Content-Type"] := "application/fhir+json;charset=utf-8"
47+
[:body parse-json] := {:fhir/type :fhir/Patient :id "0"}))
4648

4749
(testing "with accept header"
48-
(are [accept] (given (call resource-handler {:headers {"accept" accept}})
49-
[:body bytes->str] := "{\"id\":\"0\",\"resourceType\":\"Patient\"}")
50-
"*/*"
51-
"application/*"
52-
"text/*")))
50+
(are [accept content-type]
51+
(given (call resource-handler {:headers {"accept" accept}})
52+
[:headers "Content-Type"] := content-type
53+
[:body parse-json] := {:fhir/type :fhir/Patient :id "0"})
54+
"*/*" "application/fhir+json;charset=utf-8"
55+
"application/*" "application/fhir+json;charset=utf-8"
56+
"text/*" "text/json;charset=utf-8")))
5357

5458
(testing "possible accept headers"
55-
(are [accept]
59+
(are [accept content-type]
5660
(given (call resource-handler {:headers {"accept" accept}})
57-
[:body bytes->str] := "{\"id\":\"0\",\"resourceType\":\"Patient\"}")
58-
"application/fhir+json"
59-
"application/json"
60-
"text/json"
61-
"application/fhir+xml;q=0.9, application/fhir+json;q=1.0"))
61+
[:headers "Content-Type"] := content-type
62+
[:body parse-json] := {:fhir/type :fhir/Patient :id "0"})
63+
"application/fhir+json" "application/fhir+json;charset=utf-8"
64+
"application/json" "application/json;charset=utf-8"
65+
"text/json" "text/json;charset=utf-8"
66+
"application/fhir+xml;q=0.9, application/fhir+json;q=1.0" "application/fhir+json;charset=utf-8"))
6267

6368
(testing "_format overrides"
64-
(are [accept format]
69+
(are [accept format content-type]
6570
(given (call resource-handler
6671
{:headers {"accept" accept}
6772
:query-params {"_format" format}})
68-
[:body bytes->str] := "{\"id\":\"0\",\"resourceType\":\"Patient\"}")
69-
"application/fhir+xml" "application/fhir+json"
70-
"application/fhir+xml" "application/json"
71-
"application/fhir+xml" "text/json"
72-
"application/fhir+xml" "json"
73-
"*/*" "application/fhir+json"
74-
"*/*" "application/json"
75-
"*/*" "text/json"
76-
"*/*" "json")))
73+
[:headers "Content-Type"] := content-type
74+
[:body parse-json] := {:fhir/type :fhir/Patient :id "0"})
75+
"application/fhir+xml"
76+
"application/fhir+json"
77+
"application/fhir+json;charset=utf-8"
78+
79+
"application/fhir+xml"
80+
"application/json"
81+
"application/json;charset=utf-8"
82+
83+
"application/fhir+xml"
84+
"text/json"
85+
"text/json;charset=utf-8"
86+
87+
"application/fhir+xml"
88+
"json"
89+
"application/fhir+json;charset=utf-8"
90+
91+
"*/*"
92+
"application/fhir+json"
93+
"application/fhir+json;charset=utf-8"
94+
95+
"*/*"
96+
"application/json"
97+
"application/json;charset=utf-8"
98+
99+
"*/*"
100+
"text/json"
101+
"text/json;charset=utf-8"
102+
103+
"*/*"
104+
"json"
105+
"application/fhir+json;charset=utf-8")))
106+
107+
108+
(defn- parse-xml [body]
109+
(with-open [reader (io/reader body)]
110+
(fhir-spec/conform-xml (xml/parse reader))))
77111

78112

79113
(deftest xml-test
80114
(testing "possible accept headers"
81-
(are [accept]
115+
(are [accept content-type]
82116
(given (call resource-handler {:headers {"accept" accept}})
83-
[:body bytes->str] :=
84-
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><Patient xmlns=\"http://hl7.org/fhir\"><id value=\"0\"/></Patient>")
117+
[:headers "Content-Type"] := content-type
118+
[:body parse-xml] := {:fhir/type :fhir/Patient :id "0"})
85119
"application/fhir+xml"
120+
"application/fhir+xml;charset=utf-8"
121+
86122
"application/xml"
123+
"application/xml;charset=utf-8"
124+
87125
"text/xml"
88-
"application/fhir+json;q=0.9, application/fhir+xml;q=1.0"))
126+
"text/xml;charset=utf-8"
127+
128+
"application/fhir+json;q=0.9, application/fhir+xml;q=1.0"
129+
"application/fhir+xml;charset=utf-8"
130+
131+
;; Safari
132+
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
133+
"application/xml;charset=utf-8"
134+
135+
;; Chrome
136+
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
137+
"application/xml;charset=utf-8"
138+
139+
;; Edge
140+
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
141+
"application/xml;charset=utf-8"
142+
143+
;; Firefox
144+
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"
145+
"application/xml;charset=utf-8"))
89146

90147
(testing "_format overrides"
91-
(are [accept format]
148+
(are [accept format content-type]
92149
(given (call resource-handler
93150
{:headers {"accept" accept}
94151
:query-params {"_format" format}})
95-
[:body bytes->str] :=
96-
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><Patient xmlns=\"http://hl7.org/fhir\"><id value=\"0\"/></Patient>")
97-
"application/fhir+json" "application/fhir+xml"
98-
"application/fhir+json" "application/xml"
99-
"application/fhir+json" "text/xml"
100-
"application/fhir+json" "xml"
101-
"*/*" "application/fhir+xml"
102-
"*/*" "application/xml"
103-
"*/*" "text/xml"
104-
"*/*" "xml")))
152+
[:headers "Content-Type"] := content-type
153+
[:body parse-xml] := {:fhir/type :fhir/Patient :id "0"})
154+
"application/fhir+json"
155+
"application/fhir+xml"
156+
"application/fhir+xml;charset=utf-8"
157+
158+
"application/fhir+json"
159+
"application/xml"
160+
"application/xml;charset=utf-8"
161+
162+
"application/fhir+json"
163+
"text/xml"
164+
"text/xml;charset=utf-8"
165+
166+
"application/fhir+json"
167+
"xml"
168+
"application/fhir+xml;charset=utf-8"
169+
170+
"*/*"
171+
"application/fhir+xml"
172+
"application/fhir+xml;charset=utf-8"
173+
174+
"*/*"
175+
"application/xml"
176+
"application/xml;charset=utf-8"
177+
178+
"*/*"
179+
"text/xml"
180+
"text/xml;charset=utf-8"
181+
182+
"*/*"
183+
"xml"
184+
"application/fhir+xml;charset=utf-8")))
105185

106186

107187
(deftest not-acceptable-test

0 commit comments

Comments
 (0)