001package ca.uhn.fhir.rest.server; 002 003/* 004 * #%L 005 * HAPI FHIR - Server Framework 006 * %% 007 * Copyright (C) 2014 - 2019 University Health Network 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import java.util.Collection; 024import java.util.Date; 025import java.util.List; 026 027import ca.uhn.fhir.context.FhirContext; 028import ca.uhn.fhir.rest.server.method.BaseMethodBinding; 029import ca.uhn.fhir.util.VersionUtil; 030import org.hl7.fhir.instance.model.api.IPrimitiveType; 031 032import static org.apache.commons.lang3.StringUtils.isBlank; 033 034public class RestulfulServerConfiguration { 035 036 private Collection<ResourceBinding> resourceBindings; 037 private List<BaseMethodBinding<?>> serverBindings; 038 private String implementationDescription; 039 private String serverVersion = VersionUtil.getVersion(); 040 private String serverName = "HAPI FHIR"; 041 private FhirContext fhirContext; 042 private IServerAddressStrategy serverAddressStrategy; 043 private IPrimitiveType<Date> myConformanceDate; 044 045 /** 046 * Constructor 047 */ 048 public RestulfulServerConfiguration() { 049 super(); 050 } 051 052 /** 053 * Get the resourceBindings 054 * @return the resourceBindings 055 */ 056 public Collection<ResourceBinding> getResourceBindings() { 057 return resourceBindings; 058 } 059 060 /** 061 * Set the resourceBindings 062 * @param resourceBindings the resourceBindings to set 063 */ 064 public RestulfulServerConfiguration setResourceBindings(Collection<ResourceBinding> resourceBindings) { 065 this.resourceBindings = resourceBindings; 066 return this; 067 } 068 069 /** 070 * Get the serverBindings 071 * @return the serverBindings 072 */ 073 public List<BaseMethodBinding<?>> getServerBindings() { 074 return serverBindings; 075 } 076 077 /** 078 * Set the theServerBindings 079 */ 080 public RestulfulServerConfiguration setServerBindings(List<BaseMethodBinding<?>> theServerBindings) { 081 this.serverBindings = theServerBindings; 082 return this; 083 } 084 085 /** 086 * Get the implementationDescription 087 * @return the implementationDescription 088 */ 089 public String getImplementationDescription() { 090 if (isBlank(implementationDescription)) { 091 return "HAPI FHIR"; 092 } 093 return implementationDescription; 094 } 095 096 /** 097 * Set the implementationDescription 098 * @param implementationDescription the implementationDescription to set 099 */ 100 public RestulfulServerConfiguration setImplementationDescription(String implementationDescription) { 101 this.implementationDescription = implementationDescription; 102 return this; 103 } 104 105 /** 106 * Get the serverVersion 107 * @return the serverVersion 108 */ 109 public String getServerVersion() { 110 return serverVersion; 111 } 112 113 /** 114 * Set the serverVersion 115 * @param serverVersion the serverVersion to set 116 */ 117 public RestulfulServerConfiguration setServerVersion(String serverVersion) { 118 this.serverVersion = serverVersion; 119 return this; 120 } 121 122 /** 123 * Get the serverName 124 * @return the serverName 125 */ 126 public String getServerName() { 127 return serverName; 128 } 129 130 /** 131 * Set the serverName 132 * @param serverName the serverName to set 133 */ 134 public RestulfulServerConfiguration setServerName(String serverName) { 135 this.serverName = serverName; 136 return this; 137 } 138 139 /** 140 * Gets the {@link FhirContext} associated with this server. For efficient processing, resource providers and plain providers should generally use this context if one is needed, as opposed to 141 * creating their own. 142 */ 143 public FhirContext getFhirContext() { 144 return this.fhirContext; 145 } 146 147 /** 148 * Set the fhirContext 149 * @param fhirContext the fhirContext to set 150 */ 151 public RestulfulServerConfiguration setFhirContext(FhirContext fhirContext) { 152 this.fhirContext = fhirContext; 153 return this; 154 } 155 156 /** 157 * Get the serverAddressStrategy 158 * @return the serverAddressStrategy 159 */ 160 public IServerAddressStrategy getServerAddressStrategy() { 161 return serverAddressStrategy; 162 } 163 164 /** 165 * Set the serverAddressStrategy 166 * @param serverAddressStrategy the serverAddressStrategy to set 167 */ 168 public void setServerAddressStrategy(IServerAddressStrategy serverAddressStrategy) { 169 this.serverAddressStrategy = serverAddressStrategy; 170 } 171 172 173 /** 174 * Get the date that will be specified in the conformance profile 175 * exported by this server. Typically this would be populated with 176 * an InstanceType. 177 */ 178 public IPrimitiveType<Date> getConformanceDate() { 179 return myConformanceDate; 180 } 181 182 /** 183 * Set the date that will be specified in the conformance profile 184 * exported by this server. Typically this would be populated with 185 * an InstanceType. 186 */ 187 public void setConformanceDate(IPrimitiveType<Date> theConformanceDate) { 188 myConformanceDate = theConformanceDate; 189 } 190 191}