001/* 002 * #%L 003 * HAPI FHIR - Core Library 004 * %% 005 * Copyright (C) 2014 - 2024 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.rest.api; 021 022import java.nio.charset.Charset; 023import java.nio.charset.StandardCharsets; 024import java.util.Arrays; 025import java.util.Collections; 026import java.util.HashMap; 027import java.util.HashSet; 028import java.util.List; 029import java.util.Map; 030import java.util.Set; 031 032import static org.apache.commons.lang3.StringUtils.defaultIfBlank; 033 034public class Constants { 035 036 public static final String CT_TEXT_CSV = "text/csv"; 037 public static final String HEADER_REQUEST_ID = "X-Request-ID"; 038 public static final String HEADER_REQUEST_SOURCE = "X-Request-Source"; 039 public static final String CACHE_CONTROL_MAX_RESULTS = "max-results"; 040 public static final String CACHE_CONTROL_NO_CACHE = "no-cache"; 041 public static final String CACHE_CONTROL_NO_STORE = "no-store"; 042 public static final String CHARSET_NAME_UTF8 = "UTF-8"; 043 public static final Charset CHARSET_UTF8; 044 public static final String CHARSET_UTF8_CTSUFFIX = "; charset=" + CHARSET_NAME_UTF8; 045 /** 046 * Contains a standard set of headers which are used by FHIR / HAPI FHIR, and therefore 047 * would make a useful set for CORS AllowedHeader declarations 048 */ 049 public static final Set<String> CORS_ALLOWED_HEADERS; 050 /** 051 * Contains a standard set of HTTP Methods which are used by FHIR / HAPI FHIR, and therefore 052 * would make a useful set for CORS AllowedMethod declarations 053 */ 054 public static final Set<String> CORS_ALLWED_METHODS; 055 056 public static final String CT_FHIR_JSON = "application/json+fhir"; 057 public static final String CT_RDF_TURTLE = "application/x-turtle"; 058 /** 059 * The FHIR MimeType for JSON encoding in FHIR DSTU3+ 060 */ 061 public static final String CT_FHIR_JSON_NEW = "application/fhir+json"; 062 063 public static final String CT_FHIR_XML = "application/xml+fhir"; 064 065 /** 066 * The FHIR MimeType for XML encoding in FHIR DSTU3+ 067 */ 068 public static final String CT_FHIR_XML_NEW = "application/fhir+xml"; 069 070 public static final String CT_HTML = "text/html"; 071 public static final String CT_HTML_WITH_UTF8 = "text/html" + CHARSET_UTF8_CTSUFFIX; 072 public static final String CT_JSON = "application/json"; 073 public static final String CT_GRAPHQL = "application/graphql"; 074 public static final String CT_JSON_PATCH = "application/json-patch+json"; 075 public static final String CT_OCTET_STREAM = "application/octet-stream"; 076 public static final String CT_TEXT = "text/plain"; 077 public static final String CT_TEXT_WITH_UTF8 = CT_TEXT + CHARSET_UTF8_CTSUFFIX; 078 public static final String CT_TEXT_CDA = "text/xml+cda"; 079 public static final String CT_X_FORM_URLENCODED = "application/x-www-form-urlencoded"; 080 public static final String CT_XML = "application/xml"; 081 public static final String CT_XML_PATCH = "application/xml-patch+xml"; 082 public static final String ENCODING_GZIP = "gzip"; 083 public static final String EXTOP_PROCESS_MESSAGE = "$process-message"; // Used in messaging 084 public static final String EXTOP_VALIDATE = "$validate"; 085 public static final String EXTOP_VALIDATE_MODE = "mode"; 086 public static final String EXTOP_VALIDATE_PROFILE = "profile"; 087 public static final String EXTOP_VALIDATE_RESOURCE = "resource"; 088 public static final String FORMAT_HTML = "html"; 089 public static final String FORMAT_JSON = "json"; 090 public static final String FORMAT_NDJSON = "ndjson"; 091 public static final String FORMAT_XML = "xml"; 092 public static final String CT_RDF_TURTLE_LEGACY = "text/turtle"; 093 public static final String FORMAT_TURTLE = "ttl"; 094 095 /** 096 * "text/html" and "html" 097 */ 098 public static final Set<String> FORMATS_HTML; 099 100 public static final String FORMATS_HTML_JSON = "html/json"; 101 public static final String FORMATS_HTML_XML = "html/xml"; 102 public static final String FORMATS_HTML_TTL = "html/turtle"; 103 public static final String HEADER_ACCEPT = "Accept"; 104 public static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding"; 105 public static final String HEADER_ACCEPT_VALUE_JSON_NON_LEGACY = 106 CT_FHIR_JSON_NEW + ";q=1.0, " + CT_FHIR_JSON + ";q=0.9"; 107 public static final String HEADER_ACCEPT_VALUE_XML_NON_LEGACY = 108 CT_FHIR_XML_NEW + ";q=1.0, " + CT_FHIR_XML + ";q=0.9"; 109 public static final String HEADER_ACCEPT_VALUE_XML_OR_JSON_LEGACY = 110 CT_FHIR_XML + ";q=1.0, " + CT_FHIR_JSON + ";q=1.0"; 111 public static final String HEADER_ACCEPT_VALUE_XML_OR_JSON_NON_LEGACY = CT_FHIR_XML_NEW + ";q=1.0, " 112 + CT_FHIR_JSON_NEW + ";q=1.0, " + HEADER_ACCEPT_VALUE_XML_OR_JSON_LEGACY.replace("1.0", "0.9"); 113 public static final String HEADER_ALLOW = "Allow"; 114 public static final String HEADER_AUTHORIZATION = "Authorization"; 115 public static final String HEADER_AUTHORIZATION_VALPREFIX_BASIC = "Basic "; 116 public static final String HEADER_AUTHORIZATION_VALPREFIX_BEARER = "Bearer "; 117 public static final String HEADER_CACHE_CONTROL = "Cache-Control"; 118 public static final String HEADER_CLIENT_TIMEZONE = "Timezone"; 119 public static final String HEADER_CONTENT_DISPOSITION = "Content-Disposition"; 120 public static final String HEADER_CONTENT_ENCODING = "Content-Encoding"; 121 public static final String HEADER_CONTENT_LOCATION = "Content-Location"; 122 public static final String HEADER_CONTENT_LOCATION_LC = HEADER_CONTENT_LOCATION.toLowerCase(); 123 public static final String HEADER_CONTENT_TYPE = "Content-Type"; 124 public static final String HEADER_CONTENT_TYPE_LC = HEADER_CONTENT_TYPE.toLowerCase(); 125 public static final String HEADER_COOKIE = "Cookie"; 126 public static final String HEADER_CORS_ALLOW_METHODS = "Access-Control-Allow-Methods"; 127 public static final String HEADER_CORS_ALLOW_ORIGIN = "Access-Control-Allow-Origin"; 128 public static final String HEADER_CORS_EXPOSE_HEADERS = "Access-Control-Expose-Headers"; 129 public static final String HEADER_ETAG = "ETag"; 130 public static final String HEADER_ETAG_LC = HEADER_ETAG.toLowerCase(); 131 public static final String HEADER_IF_MATCH = "If-Match"; 132 public static final String HEADER_IF_MATCH_LC = HEADER_IF_MATCH.toLowerCase(); 133 public static final String HEADER_IF_MODIFIED_SINCE = "If-Modified-Since"; 134 public static final String HEADER_IF_MODIFIED_SINCE_LC = HEADER_IF_MODIFIED_SINCE.toLowerCase(); 135 public static final String HEADER_IF_NONE_EXIST = "If-None-Exist"; 136 public static final String HEADER_IF_NONE_EXIST_LC = HEADER_IF_NONE_EXIST.toLowerCase(); 137 public static final String HEADER_IF_NONE_MATCH = "If-None-Match"; 138 public static final String HEADER_IF_NONE_MATCH_LC = HEADER_IF_NONE_MATCH.toLowerCase(); 139 public static final String HEADER_LAST_MODIFIED = "Last-Modified"; 140 public static final String HEADER_LAST_MODIFIED_LOWERCASE = HEADER_LAST_MODIFIED.toLowerCase(); 141 public static final String HEADER_LOCATION = "Location"; 142 public static final String HEADER_LOCATION_LC = HEADER_LOCATION.toLowerCase(); 143 public static final String HEADER_ORIGIN = "Origin"; 144 public static final String HEADER_PREFER = "Prefer"; 145 public static final String HEADER_PREFER_HANDLING = "handling"; 146 public static final String HEADER_PREFER_HANDLING_STRICT = "strict"; 147 public static final String HEADER_PREFER_HANDLING_LENIENT = "lenient"; 148 public static final String HEADER_PREFER_RETURN = "return"; 149 public static final String HEADER_PREFER_RETURN_MINIMAL = "minimal"; 150 public static final String HEADER_PREFER_RETURN_REPRESENTATION = "representation"; 151 public static final String HEADER_PREFER_RETURN_OPERATION_OUTCOME = "OperationOutcome"; 152 public static final String HEADER_SUFFIX_CT_UTF_8 = "; charset=UTF-8"; 153 public static final String HEADERVALUE_CORS_ALLOW_METHODS_ALL = "GET, POST, PUT, DELETE, OPTIONS"; 154 public static final String HEADER_REWRITE_HISTORY = "X-Rewrite-History"; 155 public static final String HEADER_RETRY_ON_VERSION_CONFLICT = "X-Retry-On-Version-Conflict"; 156 public static final String HEADER_MAX_RETRIES = "max-retries"; 157 public static final String HEADER_RETRY = "retry"; 158 public static final Map<Integer, String> HTTP_STATUS_NAMES; 159 public static final String LINK_FHIR_BASE = "fhir-base"; 160 public static final String LINK_FIRST = "first"; 161 public static final String LINK_LAST = "last"; 162 public static final String LINK_NEXT = "next"; 163 public static final String LINK_PREVIOUS = "previous"; 164 public static final String LINK_SELF = "self"; 165 public static final String OPENSEARCH_NS_OLDER = "http://purl.org/atompub/tombstones/1.0"; 166 public static final String PARAM_ASYNC = "async"; // Used in messaging 167 public static final String PARAM_AT = "_at"; 168 public static final String PARAM_ID = "_id"; 169 /** 170 * Used in paging links 171 */ 172 public static final String PARAM_BUNDLETYPE = "_bundletype"; 173 174 public static final String PARAM_FILTER = "_filter"; 175 public static final String PARAM_CONTAINED = "_contained"; 176 public static final String PARAM_CONTAINED_TYPE = "_containedType"; 177 public static final String PARAM_CONTENT = "_content"; 178 public static final String PARAM_COUNT = "_count"; 179 public static final String PARAM_OFFSET = "_offset"; 180 public static final String PARAM_DELETE = "_delete"; 181 public static final String PARAM_ELEMENTS = "_elements"; 182 public static final String PARAM_ELEMENTS_EXCLUDE_MODIFIER = ":exclude"; 183 public static final String PARAM_FORMAT = "_format"; 184 public static final String PARAM_HAS = "_has"; 185 public static final String PARAM_HISTORY = "_history"; 186 public static final String PARAM_INCLUDE = "_include"; 187 /** 188 * @since 7.0.0 189 */ 190 public static final String PARAM_LANGUAGE = "_language"; 191 192 public static final String PARAM_INCLUDE_QUALIFIER_RECURSE = ":recurse"; 193 public static final String PARAM_INCLUDE_RECURSE = "_include" + PARAM_INCLUDE_QUALIFIER_RECURSE; 194 public static final String PARAM_INCLUDE_QUALIFIER_ITERATE = ":iterate"; 195 public static final String PARAM_INCLUDE_ITERATE = "_include" + PARAM_INCLUDE_QUALIFIER_ITERATE; 196 public static final String PARAM_LASTUPDATED = "_lastUpdated"; 197 public static final String PARAM_NARRATIVE = "_narrative"; 198 public static final String PARAM_PAGINGACTION = "_getpages"; 199 public static final String PARAM_PAGINGOFFSET = "_getpagesoffset"; 200 public static final String PARAM_PRETTY = "_pretty"; 201 public static final String PARAM_PRETTY_VALUE_FALSE = "false"; 202 public static final String PARAM_PRETTY_VALUE_TRUE = "true"; 203 public static final String PARAM_PROFILE = "_profile"; 204 public static final String PARAM_PID = "_pid"; 205 206 public static final String PARAM_QUERY = "_query"; 207 public static final String PARAM_RESPONSE_URL = "response-url"; // Used in messaging 208 public static final String PARAM_REVINCLUDE = "_revinclude"; 209 public static final String PARAM_REVINCLUDE_RECURSE = PARAM_REVINCLUDE + PARAM_INCLUDE_QUALIFIER_RECURSE; 210 public static final String PARAM_REVINCLUDE_ITERATE = PARAM_REVINCLUDE + PARAM_INCLUDE_QUALIFIER_ITERATE; 211 public static final String PARAM_SEARCH = "_search"; 212 public static final String PARAM_SECURITY = "_security"; 213 public static final String PARAM_SINCE = "_since"; 214 public static final String PARAM_SORT = "_sort"; 215 public static final String PARAM_SORT_ASC = "_sort:asc"; 216 public static final String PARAM_SORT_DESC = "_sort:desc"; 217 public static final String PARAM_SOURCE = "_source"; 218 public static final String PARAM_SUMMARY = "_summary"; 219 public static final String PARAM_TAG = "_tag"; 220 public static final String PARAM_LIST = "_list"; 221 public static final String PARAM_TAGS = "_tags"; 222 public static final String PARAM_TEXT = "_text"; 223 public static final String PARAM_VALIDATE = "_validate"; 224 public static final String PARAM_MDM = "_mdm"; 225 226 public static final String PARAMQUALIFIER_MISSING = ":missing"; 227 public static final String PARAMQUALIFIER_MISSING_FALSE = "false"; 228 public static final String PARAMQUALIFIER_MISSING_TRUE = "true"; 229 public static final String PARAMQUALIFIER_STRING_TEXT = ":text"; 230 public static final String PARAMQUALIFIER_STRING_CONTAINS = ":contains"; 231 public static final String PARAMQUALIFIER_STRING_EXACT = ":exact"; 232 public static final String PARAMQUALIFIER_TOKEN_TEXT = ":text"; 233 public static final String PARAMQUALIFIER_MDM = ":mdm"; 234 public static final String PARAMQUALIFIER_NICKNAME = ":nickname"; 235 public static final String PARAMQUALIFIER_TOKEN_OF_TYPE = ":of-type"; 236 public static final String PARAMQUALIFIER_TOKEN_NOT = ":not"; 237 public static final String PARAMQUALIFIER_TOKEN_IDENTIFIER = ":identifier"; 238 239 public static final int STATUS_HTTP_200_OK = 200; 240 public static final int STATUS_HTTP_201_CREATED = 201; 241 public static final int STATUS_HTTP_204_NO_CONTENT = 204; 242 public static final int STATUS_HTTP_304_NOT_MODIFIED = 304; 243 public static final int STATUS_HTTP_400_BAD_REQUEST = 400; 244 public static final int STATUS_HTTP_401_CLIENT_UNAUTHORIZED = 401; 245 public static final int STATUS_HTTP_403_FORBIDDEN = 403; 246 247 public static final int STATUS_HTTP_404_NOT_FOUND = 404; 248 public static final int STATUS_HTTP_405_METHOD_NOT_ALLOWED = 405; 249 public static final int STATUS_HTTP_409_CONFLICT = 409; 250 public static final int STATUS_HTTP_410_GONE = 410; 251 public static final int STATUS_HTTP_412_PRECONDITION_FAILED = 412; 252 public static final int STATUS_HTTP_422_UNPROCESSABLE_ENTITY = 422; 253 public static final int STATUS_HTTP_500_INTERNAL_ERROR = 500; 254 public static final int STATUS_HTTP_501_NOT_IMPLEMENTED = 501; 255 public static final String TAG_SUBSETTED_CODE = "SUBSETTED"; 256 public static final String TAG_SUBSETTED_SYSTEM_DSTU3 = "http://hl7.org/fhir/v3/ObservationValue"; 257 public static final String TAG_SUBSETTED_SYSTEM_R4 = "http://terminology.hl7.org/CodeSystem/v3-ObservationValue"; 258 public static final String URL_TOKEN_HISTORY = "_history"; 259 public static final String URL_TOKEN_METADATA = "metadata"; 260 public static final String OO_INFOSTATUS_PROCESSING = "processing"; 261 public static final String PARAM_GRAPHQL_QUERY = "query"; 262 public static final String HEADER_X_CACHE = "X-Cache"; 263 public static final String HEADER_X_SECURITY_CONTEXT = "X-Security-Context"; 264 public static final String POWERED_BY_HEADER = "X-Powered-By"; 265 public static final Charset CHARSET_US_ASCII; 266 public static final String PARAM_PAGEID = "_pageId"; 267 public static final String JAVA_VALIDATOR_DETAILS_SYSTEM = "http://hl7.org/fhir/java-core-messageId"; 268 public static final String PARAM_SEARCH_TOTAL_MODE = "_total"; 269 public static final String CAPABILITYSTATEMENT_WEBSOCKET_URL = 270 "http://hl7.org/fhir/StructureDefinition/capabilitystatement-websocket"; 271 public static final String PARAMETER_CASCADE_DELETE = "_cascade"; 272 public static final String PARAMETER_CASCADE_DELETE_MAX_ROUNDS = "_maxRounds"; 273 public static final String HEADER_CASCADE = "X-Cascade"; 274 public static final String HEADER_CASCADE_MAX_ROUNDS = "max-rounds"; 275 public static final String CASCADE_DELETE = "delete"; 276 public static final int MAX_RESOURCE_NAME_LENGTH = 100; 277 public static final String CACHE_CONTROL_PRIVATE = "private"; 278 public static final String CT_FHIR_NDJSON = "application/fhir+ndjson"; 279 public static final String CT_APP_NDJSON = "application/ndjson"; 280 public static final String CT_NDJSON = "ndjson"; 281 public static final Set<String> CTS_NDJSON; 282 public static final String HEADER_PREFER_RESPOND_ASYNC = "respond-async"; 283 public static final int STATUS_HTTP_412_PAYLOAD_TOO_LARGE = 413; 284 public static final String OPERATION_NAME_GRAPHQL = "$graphql"; 285 /** 286 * Note that this constant is used in a number of places including DB column lengths! Be careful if you decide to change it. 287 */ 288 public static final int REQUEST_ID_LENGTH = 16; 289 290 public static final int STATUS_HTTP_202_ACCEPTED = 202; 291 public static final String HEADER_X_PROGRESS = "X-Progress"; 292 public static final String HEADER_RETRY_AFTER = "Retry-After"; 293 /** 294 * Operation name for the $lastn operation 295 */ 296 public static final String OPERATION_LASTN = "$lastn"; 297 298 public static final String PARAM_FHIRPATH = "_fhirpath"; 299 public static final String PARAM_TYPE = "_type"; 300 301 /** 302 * {@link org.hl7.fhir.instance.model.api.IBaseResource#getUserData(String) User metadata key} used 303 * to store the partition ID (if any) associated with the given resource. Value for this 304 * key will be of type {@link ca.uhn.fhir.interceptor.model.RequestPartitionId}. 305 */ 306 public static final String RESOURCE_PARTITION_ID = Constants.class.getName() + "_RESOURCE_PARTITION_ID"; 307 308 public static final String PARTITION_IDS = "partitionIds"; 309 public static final String CT_APPLICATION_GZIP = "application/gzip"; 310 public static final String[] EMPTY_STRING_ARRAY = new String[0]; 311 public static final String SUBSCRIPTION_MULTITYPE_PREFIX = "["; 312 public static final String SUBSCRIPTION_MULTITYPE_SUFFIX = "]"; 313 public static final String SUBSCRIPTION_MULTITYPE_STAR = "*"; 314 public static final String SUBSCRIPTION_STAR_CRITERIA = 315 SUBSCRIPTION_MULTITYPE_PREFIX + SUBSCRIPTION_MULTITYPE_STAR + SUBSCRIPTION_MULTITYPE_SUFFIX; 316 public static final String INCLUDE_STAR = "*"; 317 public static final String PARAMQUALIFIER_TOKEN_IN = ":in"; 318 public static final String PARAMQUALIFIER_TOKEN_NOT_IN = ":not-in"; 319 public static final String PARAMQUALIFIER_TOKEN_ABOVE = ":above"; 320 public static final String PARAMQUALIFIER_TOKEN_BELOW = ":below"; 321 322 public static final List<String> VALID_MODIFIERS = Collections.unmodifiableList(Arrays.asList( 323 PARAMQUALIFIER_STRING_CONTAINS, 324 PARAMQUALIFIER_STRING_EXACT, 325 PARAMQUALIFIER_TOKEN_IN, 326 PARAM_INCLUDE_QUALIFIER_ITERATE, 327 PARAMQUALIFIER_MISSING, 328 PARAMQUALIFIER_TOKEN_NOT_IN, 329 PARAMQUALIFIER_TOKEN_OF_TYPE, 330 PARAM_INCLUDE_QUALIFIER_RECURSE, 331 PARAMQUALIFIER_TOKEN_TEXT)); 332 /** 333 * The number of characters in a UUID (36) 334 */ 335 public static final int UUID_LENGTH = 36; 336 337 public static final String BULK_DATA_ACCESS_IG_URL = 338 "http://hl7.org/fhir/uv/bulkdata/CapabilityStatement/bulk-data"; 339 340 /** 341 * Application configuration key used to enable or disable Hibernate Envers. 342 */ 343 public static final String HIBERNATE_INTEGRATION_ENVERS_ENABLED = "hibernate.integration.envers.enabled"; 344 345 static { 346 CHARSET_UTF8 = StandardCharsets.UTF_8; 347 CHARSET_US_ASCII = StandardCharsets.ISO_8859_1; 348 349 HashSet<String> ctsNdjson = new HashSet<>(); 350 ctsNdjson.add(CT_FHIR_NDJSON); 351 ctsNdjson.add(CT_APP_NDJSON); 352 ctsNdjson.add(CT_NDJSON); 353 CTS_NDJSON = Collections.unmodifiableSet(ctsNdjson); 354 355 HashMap<Integer, String> statusNames = new HashMap<>(); 356 statusNames.put(200, "OK"); 357 statusNames.put(201, "Created"); 358 statusNames.put(202, "Accepted"); 359 statusNames.put(203, "Non-Authoritative Information"); 360 statusNames.put(204, "No Content"); 361 statusNames.put(205, "Reset Content"); 362 statusNames.put(206, "Partial Content"); 363 statusNames.put(207, "Multi-Status"); 364 statusNames.put(208, "Already Reported"); 365 statusNames.put(226, "IM Used"); 366 statusNames.put(300, "Multiple Choices"); 367 statusNames.put(301, "Moved Permanently"); 368 statusNames.put(302, "Found"); 369 statusNames.put(303, "See Other"); 370 statusNames.put(304, "Not Modified"); 371 statusNames.put(305, "Use Proxy"); 372 statusNames.put(307, "Temporary Redirect"); 373 statusNames.put(308, "Permanent Redirect"); 374 statusNames.put(400, "Bad Request"); 375 statusNames.put(401, "Unauthorized"); 376 statusNames.put(402, "Payment Required"); 377 statusNames.put(403, "Forbidden"); 378 statusNames.put(404, "Not Found"); 379 statusNames.put(405, "Method Not Allowed"); 380 statusNames.put(406, "Not Acceptable"); 381 statusNames.put(407, "Proxy Authentication Required"); 382 statusNames.put(408, "Request Timeout"); 383 statusNames.put(409, "Conflict"); 384 statusNames.put(410, "Gone"); 385 statusNames.put(411, "Length Required"); 386 statusNames.put(412, "Precondition Failed"); 387 statusNames.put(413, "Payload Too Large"); 388 statusNames.put(414, "URI Too Long"); 389 statusNames.put(415, "Unsupported Media Type"); 390 statusNames.put(416, "Requested range not satisfiable"); 391 statusNames.put(417, "Expectation Failed"); 392 statusNames.put(418, "I'm a teapot"); 393 statusNames.put(419, "Insufficient Space On Resource"); 394 statusNames.put(420, "Method Failure"); 395 statusNames.put(421, "Destination Locked"); 396 statusNames.put(422, "Unprocessable Entity"); 397 statusNames.put(423, "Locked"); 398 statusNames.put(424, "Failed Dependency"); 399 statusNames.put(426, "Upgrade Required"); 400 statusNames.put(428, "Precondition Required"); 401 statusNames.put(429, "Too Many Requests"); 402 statusNames.put(431, "Request Header Fields Too Large"); 403 statusNames.put(500, "Internal Server Error"); 404 statusNames.put(501, "Not Implemented"); 405 statusNames.put(502, "Bad Gateway"); 406 statusNames.put(503, "Service Unavailable"); 407 statusNames.put(504, "Gateway Timeout"); 408 statusNames.put(505, "HTTP Version not supported"); 409 statusNames.put(506, "Variant Also Negotiates"); 410 statusNames.put(507, "Insufficient Storage"); 411 statusNames.put(508, "Loop Detected"); 412 statusNames.put(509, "Bandwidth Limit Exceeded"); 413 statusNames.put(510, "Not Extended"); 414 statusNames.put(511, "Network Authentication Required"); 415 HTTP_STATUS_NAMES = Collections.unmodifiableMap(statusNames); 416 417 Set<String> formatsHtml = new HashSet<>(); 418 formatsHtml.add(CT_HTML); 419 formatsHtml.add(FORMAT_HTML); 420 FORMATS_HTML = Collections.unmodifiableSet(formatsHtml); 421 422 // ********************************************************* 423 // Update CorsInterceptor's constructor documentation if you change these: 424 // ********************************************************* 425 HashSet<String> corsAllowedHeaders = new HashSet<>(); 426 corsAllowedHeaders.add("Accept"); 427 corsAllowedHeaders.add("Access-Control-Request-Headers"); 428 corsAllowedHeaders.add("Access-Control-Request-Method"); 429 corsAllowedHeaders.add("Cache-Control"); 430 corsAllowedHeaders.add("Content-Type"); 431 corsAllowedHeaders.add("Origin"); 432 corsAllowedHeaders.add("Prefer"); 433 corsAllowedHeaders.add("X-FHIR-Starter"); 434 corsAllowedHeaders.add("X-Requested-With"); 435 CORS_ALLOWED_HEADERS = Collections.unmodifiableSet(corsAllowedHeaders); 436 437 // ********************************************************* 438 // Update CorsInterceptor's constructor documentation if you change these: 439 // ********************************************************* 440 HashSet<String> corsAllowedMethods = new HashSet<>(); 441 corsAllowedMethods.addAll(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH")); 442 CORS_ALLWED_METHODS = Collections.unmodifiableSet(corsAllowedMethods); 443 } 444 445 public static String codeSystemWithDefaultDescription(String theSystem) { 446 return defaultIfBlank(theSystem, "(none)"); 447 } 448}