View Javadoc
1   /*
2    * Copyright 2016 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.openehealth.ipf.boot.fhir;
18  
19  import ca.uhn.fhir.context.FhirVersionEnum;
20  import lombok.Getter;
21  import lombok.Setter;
22  import org.springframework.boot.context.properties.ConfigurationProperties;
23  import org.springframework.boot.context.properties.NestedConfigurationProperty;
24  import org.springframework.core.io.Resource;
25  import org.springframework.validation.annotation.Validated;
26  
27  import javax.validation.constraints.NotNull;
28  import javax.validation.constraints.Pattern;
29  import java.util.ArrayList;
30  import java.util.HashMap;
31  import java.util.List;
32  import java.util.Map;
33  
34  /**
35   *
36   */
37  @Validated
38  @ConfigurationProperties(prefix = "ipf.fhir")
39  public class IpfFhirConfigurationProperties {
40  
41      /**
42       * Which FHIR version to use
43       */
44      @Getter @Setter
45      private FhirVersionEnum fhirVersion = FhirVersionEnum.DSTU3;
46  
47      @NestedConfigurationProperty
48      @Getter
49      private final Servlet servlet = new Servlet();
50  
51      /**
52       * Path that serves as the base URI for the FHIR services.
53       */
54      @NotNull
55      @Getter @Setter
56      @Pattern(regexp = "/[^?#]*", message = "Path must start with /")
57      private String path = "/fhir";
58  
59      /**
60       * Resource containing NamingSystems used for mapping between namespaces
61       */
62      @Getter @Setter
63      private List<Resource> namingSystems = new ArrayList<>();
64  
65      /**
66       * Whether to create a cached PagingProvider
67       */
68      @Getter @Setter
69      private boolean caching;
70  
71  
72  
73      String getFhirMapping() {
74          String path = getPath();
75          return path.endsWith("/") ? path + "*" : path + "/*";
76      }
77  
78      public static class Servlet {
79  
80          /**
81           * Servlet init parameters to pass to the FHIR Servlet.
82           */
83          @Getter @Setter
84          private Map<String, String> init = new HashMap<>();
85  
86          /**
87           * Load on startup priority of the FHIR servlet.
88           */
89          @Getter @Setter
90          private int loadOnStartup = 1;
91  
92          /**
93           * Name of the servlet
94           */
95          @Getter @Setter
96          private String name = "FhirServlet";
97  
98          /**
99           * Number of concurrent paging requests that can be handled
100          */
101         @Getter @Setter
102         private int pagingRequests = 50;
103 
104         /**
105          * Default number of result entries to be returned if no _count parameter is specified in a search
106          */
107         @Getter @Setter
108         private int defaultPageSize = 50;
109 
110         /**
111          * Maximum number of result entries to be returned even if the _count parameter of a search demands for more
112          */
113         @Getter @Setter
114         private int maxPageSize = 100;
115 
116         /**
117          * Whether the Paging Provider cache is expected to be distributed, so that serialization of result
118          * bundles is necessary. In this case, FHIR endpoints must not use lazy-loading of results.
119          */
120         @Getter @Setter
121         private boolean distributedPagingProvider = false;
122 
123         /**
124          * Enable server-side request logging
125          */
126         @Getter @Setter
127         private boolean logging = false;
128 
129         /**
130          * Enable pretty-printing responses
131          */
132         @Getter @Setter
133         private boolean prettyPrint = true;
134 
135         /**
136          * Enable color-coding responses queried from a Web Browser
137          */
138         @Getter @Setter
139         private boolean responseHighlighting = true;
140 
141         /**
142          * Enable strict resource parsing
143          */
144         @Getter @Setter
145         private boolean strict = false;
146     }
147 }