-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OZ-689 - Changed mechanism in which the filter is registered
- Loading branch information
Showing
3 changed files
with
60 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
omod/src/main/java/org/openmrs/module/fhirproxy/web/FhirProxyFilterRegistrar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.module.fhirproxy.web; | ||
|
||
import java.util.EnumSet; | ||
|
||
import javax.servlet.DispatcherType; | ||
import javax.servlet.FilterRegistration.Dynamic; | ||
import javax.servlet.ServletContext; | ||
|
||
import org.openmrs.module.fhirproxy.web.filter.FhirProxyFilter; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.context.ServletContextAware; | ||
|
||
@Component | ||
public class FhirProxyFilterRegistrar implements ServletContextAware { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(FhirProxyFilterRegistrar.class); | ||
|
||
private static final String[] MAPPINGS = { "/ws/fhir2/R4/ChargeItemDefinition/*", "/ws/fhir2/R4/InventoryItem/*" }; | ||
|
||
@Override | ||
public void setServletContext(ServletContext servletContext) { | ||
LOG.info("Adding FHIR Proxy Filter"); | ||
|
||
try { | ||
Dynamic filter = servletContext.addFilter("FHIR Proxy", new FhirProxyFilter()); | ||
filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, MAPPINGS); | ||
} | ||
catch (Exception ex) { | ||
//Ignore known issue, this happens when running openmrs the first time. | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters