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.commons.ihe.fhir; 18 19 import ca.uhn.fhir.context.FhirContext; 20 21 import java.util.Map; 22 23 /** 24 * Instances of {@link FhirTransactionValidator} are used in order to have FHIR request and response validated. 25 * 26 * @author Christian Ohr 27 */ 28 public interface FhirTransactionValidator { 29 30 FhirTransactionValidator NO_VALIDATION = new Support(); 31 32 /** 33 * Validates a FHIR request, throwing an {@link ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException} 34 * on validation failure 35 * 36 * @param context FHIR context 37 * @param payload request payload 38 * @param parameters request parameters 39 */ 40 void validateRequest(FhirContext context, Object payload, Map<String, Object> parameters); 41 42 /** 43 * Validates a FHIR response, throwing an appropriate subclass of 44 * {@link ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException} on 45 * validation failure 46 * 47 * @param context FHIR context 48 * @param payload response payload 49 * @param parameters response parameters 50 */ 51 void validateResponse(FhirContext context, Object payload, Map<String, Object> parameters); 52 53 class Support implements FhirTransactionValidator { 54 55 @Override 56 public void validateRequest(FhirContext context, Object payload, Map<String, Object> headers) { 57 } 58 59 @Override 60 public void validateResponse(FhirContext context, Object payload, Map<String, Object> parameters) { 61 } 62 } 63 } 64 65