Skip to content

Commit

Permalink
FM2-651: Allow access to all API load-able by the OpenMRS Class loader.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruhanga committed Dec 12, 2024
1 parent 3597294 commit 538d4e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import org.openmrs.module.fhir2.api.dao.FhirDao;
import org.openmrs.module.fhir2.api.search.param.PropParam;
import org.openmrs.module.fhir2.api.search.param.SearchParameterMap;
import org.openmrs.util.OpenmrsClassLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -101,7 +100,6 @@ protected BaseFhirDao() {
@Override
@Transactional(readOnly = true)
public T get(@Nonnull String uuid) {
Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance());
@SuppressWarnings("unchecked")
T result = (T) sessionFactory.getCurrentSession().createCriteria(typeToken.getRawType()).add(eq("uuid", uuid))
.uniqueResult();
Expand All @@ -117,7 +115,6 @@ public T get(@Nonnull String uuid) {
@Transactional(readOnly = true)
@SuppressWarnings("unchecked")
public List<T> get(@Nonnull Collection<String> uuids) {
Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance());
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(typeToken.getRawType());
criteria.add(in("uuid", uuids));

Expand Down Expand Up @@ -213,7 +210,6 @@ protected void applyExactTotal(SearchParameterMap theParams, Criteria criteria)
@SuppressWarnings("unchecked")
@Override
public List<T> getSearchResults(@Nonnull SearchParameterMap theParams) {
Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance());
Criteria criteria = getSearchResultCriteria(theParams);

handleSort(criteria, theParams.getSortSpec());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

import static org.openmrs.module.fhir2.FhirConstants.FHIR2_MODULE_ID;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -46,6 +51,7 @@
import org.openmrs.module.fhir2.web.util.NarrativeUtils;
import org.openmrs.module.fhir2.web.util.SummaryInterceptor;
import org.openmrs.module.fhir2.web.util.SupportMergePatchInterceptor;
import org.openmrs.util.OpenmrsClassLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
import org.springframework.beans.factory.annotation.Qualifier;
Expand Down Expand Up @@ -181,6 +187,12 @@ protected String getRequestPath(String requestFullPath, String servletContextPat
.substring(escapedLength(servletContextPath) + escapedLength(servletPath) + escapedLength("/fhir2Servlet"));
}

@Override
protected void service(HttpServletRequest theReq, HttpServletResponse theResp) throws ServletException, IOException {
Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance());
super.service(theReq, theResp);
}

@Override
@Autowired
@Qualifier("fhirR4")
Expand Down

0 comments on commit 538d4e3

Please sign in to comment.