001package ca.uhn.fhir.jpa.mdm.interceptor; 002 003/*- 004 * #%L 005 * HAPI FHIR JPA Server - Master Data Management 006 * %% 007 * Copyright (C) 2014 - 2022 Smile CDR, Inc. 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 ca.uhn.fhir.interceptor.api.IInterceptorService; 024import ca.uhn.fhir.jpa.api.config.DaoConfig; 025import ca.uhn.fhir.mdm.interceptor.IMdmStorageInterceptor; 026import ca.uhn.fhir.mdm.interceptor.MdmSearchExpandingInterceptor; 027import ca.uhn.fhir.jpa.subscription.submit.interceptor.SubscriptionSubmitInterceptorLoader; 028import ca.uhn.fhir.mdm.api.IMdmSettings; 029import ca.uhn.fhir.mdm.log.Logs; 030import org.hl7.fhir.dstu2.model.Subscription; 031import org.slf4j.Logger; 032import org.springframework.beans.factory.annotation.Autowired; 033 034import javax.annotation.PostConstruct; 035 036public class MdmSubmitterInterceptorLoader { 037 private static final Logger ourLog = Logs.getMdmTroubleshootingLog(); 038 039 @Autowired 040 private IMdmSettings myMdmSettings; 041 @Autowired 042 DaoConfig myDaoConfig; 043 @Autowired 044 private IMdmStorageInterceptor myIMdmStorageInterceptor; 045 @Autowired 046 private MdmSearchExpandingInterceptor myMdmSearchExpandingInterceptorInterceptor; 047 @Autowired 048 private IInterceptorService myInterceptorService; 049 @Autowired 050 private SubscriptionSubmitInterceptorLoader mySubscriptionSubmitInterceptorLoader; 051 052 @PostConstruct 053 public void start() { 054 if (!myMdmSettings.isEnabled()) { 055 return; 056 } 057 058 myDaoConfig.addSupportedSubscriptionType(Subscription.SubscriptionChannelType.MESSAGE); 059 myInterceptorService.registerInterceptor(myIMdmStorageInterceptor); 060 myInterceptorService.registerInterceptor(myMdmSearchExpandingInterceptorInterceptor); 061 ourLog.info("MDM interceptor registered"); 062 // We need to call SubscriptionSubmitInterceptorLoader.start() again in case there were no subscription types the first time it was called. 063 mySubscriptionSubmitInterceptorLoader.start(); 064 } 065}