diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca2ebbe..b16bcdd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,10 +17,10 @@ jobs: - uses: actions/checkout@v3 - name: Set up JDK 11 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: 11 + java-version: '17' - name: Run Unit tests and generate report run: mvn -B clean test jacoco:report --file pom.xml --file README.md --file LICENSE diff --git a/exec/pom.xml b/exec/pom.xml index f6cebec..7f48363 100755 --- a/exec/pom.xml +++ b/exec/pom.xml @@ -12,7 +12,7 @@ ${project.parent.basedir} - 2.7.5 + 3.3.4 true @@ -46,13 +46,13 @@ com.google.fhir.gateway server - 0.3.1 + ${fhir.gateway.version} com.google.fhir.gateway plugins - 0.3.1 + ${fhir.gateway.version} @@ -98,7 +98,7 @@ org.smartregister.fhir.gateway.MainApp - - javax.servlet - javax.servlet-api - 4.0.1 - provided + jakarta.servlet + jakarta.servlet-api + ${jakarta-servlet.version} ca.uhn.hapi.fhir @@ -51,12 +51,12 @@ io.sentry sentry-logback - 7.6.0 + ${sentry.version} io.sentry - sentry-spring-boot-starter - 7.6.0 + sentry-spring-boot-starter-jakarta + ${sentry.version} diff --git a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelper.java b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelper.java index d7fa9ad..a16ed3f 100644 --- a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelper.java +++ b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelper.java @@ -10,9 +10,6 @@ import java.util.Map; import java.util.stream.Collectors; -import javax.annotation.Nullable; -import javax.servlet.http.HttpServletRequest; - import org.hl7.fhir.instance.model.api.IBaseBundle; import org.hl7.fhir.r4.model.Binary; import org.hl7.fhir.r4.model.Bundle; @@ -37,6 +34,8 @@ import ca.uhn.fhir.rest.gclient.TokenClientParam; import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; +import jakarta.annotation.Nullable; +import jakarta.servlet.http.HttpServletRequest; public class LocationHierarchyEndpointHelper { diff --git a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/PermissionAccessChecker.java b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/PermissionAccessChecker.java index 3fc6241..84720e0 100755 --- a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/PermissionAccessChecker.java +++ b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/PermissionAccessChecker.java @@ -17,7 +17,6 @@ import org.hl7.fhir.r4.model.CareTeam; import org.hl7.fhir.r4.model.Composition; import org.hl7.fhir.r4.model.Organization; -import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.smartregister.fhir.gateway.plugins.interfaces.ResourceFinder; @@ -40,6 +39,7 @@ import ca.uhn.fhir.rest.api.SearchStyleEnum; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.server.exceptions.AuthenticationException; +import jakarta.annotation.Nonnull; public class PermissionAccessChecker implements AccessChecker { private static final Logger logger = LoggerFactory.getLogger(PermissionAccessChecker.class); @@ -282,7 +282,7 @@ private List getLocationUuids(String[] syncLocations) { return locationUuids; } - @NotNull + @Nonnull private Map> collateSyncStrategyIds( String syncStrategy, PractitionerDetails practitionerDetails, diff --git a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/PractitionerDetailsEndpointHelper.java b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/PractitionerDetailsEndpointHelper.java index 9db8d57..e1c825d 100755 --- a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/PractitionerDetailsEndpointHelper.java +++ b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/PractitionerDetailsEndpointHelper.java @@ -23,7 +23,6 @@ import org.hl7.fhir.r4.model.OrganizationAffiliation; import org.hl7.fhir.r4.model.Practitioner; import org.hl7.fhir.r4.model.PractitionerRole; -import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.smartregister.model.location.LocationHierarchy; @@ -37,6 +36,7 @@ import ca.uhn.fhir.rest.api.SearchStyleEnum; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.gclient.ReferenceClientParam; +import jakarta.annotation.Nonnull; public class PractitionerDetailsEndpointHelper { private static final Logger logger = @@ -160,7 +160,7 @@ protected Bundle getAttributedPractitionerDetailsByPractitioner(Practitioner pra return responseBundle; } - @NotNull + @Nonnull public static Set getAttributedLocations(List locationHierarchies) { List parentChildrenList = locationHierarchies.stream() diff --git a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/RestUtils.java b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/RestUtils.java index 5afb3a4..5d07a38 100644 --- a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/RestUtils.java +++ b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/RestUtils.java @@ -2,9 +2,6 @@ import static org.smartregister.fhir.gateway.plugins.Constants.AUTHORIZATION; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -12,6 +9,8 @@ import com.google.fhir.gateway.TokenVerifier; import ca.uhn.fhir.rest.server.exceptions.AuthenticationException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; public class RestUtils { diff --git a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/SyncAccessDecision.java b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/SyncAccessDecision.java index cb78dab..d67eb89 100755 --- a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/SyncAccessDecision.java +++ b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/SyncAccessDecision.java @@ -13,8 +13,6 @@ import java.util.Map; import java.util.stream.Collectors; -import javax.annotation.Nullable; - import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpResponse; @@ -25,7 +23,6 @@ import org.hl7.fhir.r4.model.ListResource; import org.hl7.fhir.r4.model.OperationOutcome; import org.hl7.fhir.r4.model.Resource; -import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,6 +39,8 @@ import ca.uhn.fhir.rest.api.RequestTypeEnum; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; import lombok.Getter; public class SyncAccessDecision implements AccessDecision { @@ -152,7 +151,7 @@ public RequestMutation getRequestMutation(RequestDetailsReader requestDetailsRea requestMutation = RequestMutation.builder() - .queryParams( + .additionalQueryParams( Map.of( Constants.TAG_SEARCH_PARAM, List.of( @@ -359,7 +358,7 @@ private boolean includeAttributedPractitioners(String requestPath) { && SyncAccessDecisionConstants.ENDPOINT_PRACTITIONER_DETAILS.equals(requestPath); } - @NotNull + @Nonnull private static OperationOutcome createOperationOutcome(String exception) { OperationOutcome operationOutcome = new OperationOutcome(); OperationOutcome.OperationOutcomeIssueComponent operationOutcomeIssueComponent = @@ -371,7 +370,7 @@ private static OperationOutcome createOperationOutcome(String exception) { return operationOutcome; } - @NotNull + @Nonnull private static Bundle processListEntriesGatewayModeByListResource( ListResource responseListResource, int start, int count) { Bundle requestBundle = new Bundle(); @@ -418,7 +417,7 @@ private Bundle processListEntriesGatewayModeByBundle( return requestBundle.setEntry(bundleEntryComponentList); } - @NotNull + @Nonnull static Bundle.BundleEntryComponent createBundleEntryComponent( Bundle.HTTPVerb method, String requestPath, @Nullable String condition) { diff --git a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/endpoint/BaseEndpoint.java b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/endpoint/BaseEndpoint.java index 80c0114..3df21a8 100644 --- a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/endpoint/BaseEndpoint.java +++ b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/endpoint/BaseEndpoint.java @@ -6,10 +6,6 @@ import java.io.PrintWriter; import java.nio.charset.StandardCharsets; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.smartregister.fhir.gateway.plugins.RestUtils; @@ -18,6 +14,9 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.parser.IParser; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; public abstract class BaseEndpoint extends HttpServlet { private static final Logger logger = LoggerFactory.getLogger(BaseEndpoint.class); diff --git a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/endpoint/LocationHierarchyEndpoint.java b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/endpoint/LocationHierarchyEndpoint.java index b0c79f9..bac1b75 100644 --- a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/endpoint/LocationHierarchyEndpoint.java +++ b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/endpoint/LocationHierarchyEndpoint.java @@ -4,10 +4,6 @@ import java.io.IOException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.apache.http.HttpStatus; import org.hl7.fhir.r4.model.Bundle; import org.smartregister.fhir.gateway.plugins.Constants; @@ -18,6 +14,9 @@ import com.auth0.jwt.interfaces.DecodedJWT; import ca.uhn.fhir.rest.server.exceptions.AuthenticationException; +import jakarta.servlet.annotation.WebServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; @WebServlet("/LocationHierarchy") public class LocationHierarchyEndpoint extends BaseEndpoint { diff --git a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/endpoint/PractitionerDetailEndpoint.java b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/endpoint/PractitionerDetailEndpoint.java index 3f17417..35412a5 100755 --- a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/endpoint/PractitionerDetailEndpoint.java +++ b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/endpoint/PractitionerDetailEndpoint.java @@ -5,10 +5,6 @@ import java.io.IOException; import java.util.Collections; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.apache.http.HttpStatus; import org.smartregister.fhir.gateway.plugins.Constants; import org.smartregister.fhir.gateway.plugins.PractitionerDetailsEndpointHelper; @@ -17,6 +13,9 @@ import org.smartregister.model.practitioner.PractitionerDetails; import ca.uhn.fhir.rest.server.exceptions.AuthenticationException; +import jakarta.servlet.annotation.WebServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; @WebServlet("/PractitionerDetail") public class PractitionerDetailEndpoint extends BaseEndpoint { diff --git a/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelperTest.java b/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelperTest.java index befa60a..b356e45 100644 --- a/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelperTest.java +++ b/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelperTest.java @@ -12,8 +12,6 @@ import java.util.List; import java.util.Map; -import javax.servlet.http.HttpServletRequest; - import org.hl7.fhir.instance.model.api.IBaseBundle; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.CodeableConcept; @@ -37,6 +35,7 @@ import ca.uhn.fhir.rest.gclient.IQuery; import ca.uhn.fhir.rest.gclient.IUntypedQuery; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; +import jakarta.servlet.http.HttpServletRequest; public class LocationHierarchyEndpointHelperTest { diff --git a/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/RestUtilTest.java b/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/RestUtilTest.java index 0372651..fef62f9 100644 --- a/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/RestUtilTest.java +++ b/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/RestUtilTest.java @@ -5,14 +5,14 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.junit.Test; import org.mockito.Mockito; import com.google.fhir.gateway.TokenVerifier; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + public class RestUtilTest { @Test(expected = RuntimeException.class) diff --git a/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/SyncAccessDecisionTest.java b/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/SyncAccessDecisionTest.java index 244c337..c3c7ef6 100755 --- a/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/SyncAccessDecisionTest.java +++ b/plugins/src/test/java/org/smartregister/fhir/gateway/plugins/SyncAccessDecisionTest.java @@ -83,9 +83,10 @@ public void preProcessShouldAddLocationIdFiltersWhenUserIsAssignedToLocationsOnl Assert.assertFalse(requestDetails.getCompleteUrl().contains(locationId)); Assert.assertFalse(requestDetails.getRequestPath().contains(locationId)); } + assert mutatedRequest != null; Assert.assertTrue( mutatedRequest - .getQueryParams() + .getAdditionalQueryParams() .get(Constants.TAG_SEARCH_PARAM) .get(0) .contains( @@ -95,7 +96,8 @@ public void preProcessShouldAddLocationIdFiltersWhenUserIsAssignedToLocationsOnl + Constants.DEFAULT_LOCATION_TAG_URL + Constants.CODE_URL_VALUE_SEPARATOR))); - for (String param : mutatedRequest.getQueryParams().get(Constants.TAG_SEARCH_PARAM)) { + for (String param : + mutatedRequest.getAdditionalQueryParams().get(Constants.TAG_SEARCH_PARAM)) { Assert.assertFalse(param.contains(Constants.DEFAULT_CARE_TEAM_TAG_URL)); Assert.assertFalse(param.contains(Constants.DEFAULT_ORGANISATION_TAG_URL)); } @@ -180,7 +182,7 @@ public void preProcessWhenNotOneClientRoleIsAddedShouldThrowError() throws IOExc } Assert.assertTrue( mutatedRequest - .getQueryParams() + .getAdditionalQueryParams() .get(Constants.TAG_SEARCH_PARAM) .get(0) .contains( @@ -190,7 +192,8 @@ public void preProcessWhenNotOneClientRoleIsAddedShouldThrowError() throws IOExc + Constants.DEFAULT_RELATED_ENTITY_TAG_URL + Constants.CODE_URL_VALUE_SEPARATOR))); - for (String param : mutatedRequest.getQueryParams().get(Constants.TAG_SEARCH_PARAM)) { + for (String param : + mutatedRequest.getAdditionalQueryParams().get(Constants.TAG_SEARCH_PARAM)) { Assert.assertFalse(param.contains(Constants.DEFAULT_CARE_TEAM_TAG_URL)); Assert.assertFalse(param.contains(Constants.DEFAULT_ORGANISATION_TAG_URL)); } @@ -258,12 +261,15 @@ public void preProcessWhenNotOneClientRoleIsAddedShouldThrowError() throws IOExc Assert.assertEquals( expected.substring(0, expected.length() - 1), - mutatedRequest.getQueryParams().get(Constants.TAG_SEARCH_PARAM).get(0)); + mutatedRequest + .getAdditionalQueryParams() + .get(Constants.TAG_SEARCH_PARAM) + .get(0)); Collections.reverse(relatedEntityLocationIds); Assert.assertFalse( mutatedRequest - .getQueryParams() + .getAdditionalQueryParams() .get(Constants.TAG_SEARCH_PARAM) .get(0) .contains( @@ -371,7 +377,7 @@ public void preProcessShouldAddCareTeamIdFiltersWhenUserIsAssignedToCareTeamsOnl Assert.assertTrue( mutatedRequest - .getQueryParams() + .getAdditionalQueryParams() .get(Constants.TAG_SEARCH_PARAM) .get(0) .contains( @@ -381,7 +387,8 @@ public void preProcessShouldAddCareTeamIdFiltersWhenUserIsAssignedToCareTeamsOnl + Constants.DEFAULT_CARE_TEAM_TAG_URL + Constants.CODE_URL_VALUE_SEPARATOR))); - for (String param : mutatedRequest.getQueryParams().get(Constants.TAG_SEARCH_PARAM)) { + for (String param : + mutatedRequest.getAdditionalQueryParams().get(Constants.TAG_SEARCH_PARAM)) { Assert.assertFalse(param.contains(Constants.DEFAULT_LOCATION_TAG_URL)); Assert.assertFalse(param.contains(Constants.DEFAULT_ORGANISATION_TAG_URL)); } @@ -410,7 +417,7 @@ public void preProcessShouldAddOrganisationIdFiltersWhenUserIsAssignedToOrganisa Assert.assertFalse(requestDetails.getRequestPath().contains(locationId)); Assert.assertTrue( mutatedRequest - .getQueryParams() + .getAdditionalQueryParams() .get(Constants.TAG_SEARCH_PARAM) .contains( Constants.DEFAULT_ORGANISATION_TAG_URL @@ -418,7 +425,8 @@ public void preProcessShouldAddOrganisationIdFiltersWhenUserIsAssignedToOrganisa + locationId)); } - for (String param : mutatedRequest.getQueryParams().get(Constants.TAG_SEARCH_PARAM)) { + for (String param : + mutatedRequest.getAdditionalQueryParams().get(Constants.TAG_SEARCH_PARAM)) { Assert.assertFalse(param.contains(Constants.DEFAULT_LOCATION_TAG_URL)); Assert.assertFalse(param.contains(Constants.DEFAULT_CARE_TEAM_TAG_URL)); } @@ -445,11 +453,11 @@ public void preProcessShouldAddFiltersWhenResourceNotInSyncFilterIgnoredResource for (String locationId : organisationIds) { Assert.assertFalse(requestDetails.getCompleteUrl().contains(locationId)); Assert.assertFalse(requestDetails.getRequestPath().contains(locationId)); - Assert.assertEquals(1, mutatedRequest.getQueryParams().size()); + Assert.assertEquals(1, mutatedRequest.getAdditionalQueryParams().size()); } Assert.assertTrue( mutatedRequest - .getQueryParams() + .getAdditionalQueryParams() .get(Constants.TAG_SEARCH_PARAM) .get(0) .contains( @@ -557,7 +565,7 @@ public void preProcessShouldSkipAddingFiltersWhenResourceInSyncFilterIgnoredReso testInstance.getRequestMutation(new TestRequestDetailsToReader(requestDetails)); List searchParamArrays = - mutatedRequest.getQueryParams().get(Constants.TAG_SEARCH_PARAM); + mutatedRequest.getAdditionalQueryParams().get(Constants.TAG_SEARCH_PARAM); Assert.assertNotNull(searchParamArrays); Assert.assertTrue( @@ -1013,7 +1021,7 @@ public void preProcessWhenRequestIsAnOperationRequestShouldAddFilters() { } Assert.assertTrue( mutatedRequest - .getQueryParams() + .getAdditionalQueryParams() .get(Constants.TAG_SEARCH_PARAM) .get(0) .contains( @@ -1023,7 +1031,8 @@ public void preProcessWhenRequestIsAnOperationRequestShouldAddFilters() { + Constants.DEFAULT_LOCATION_TAG_URL + Constants.CODE_URL_VALUE_SEPARATOR))); - for (String param : mutatedRequest.getQueryParams().get(Constants.TAG_SEARCH_PARAM)) { + for (String param : + mutatedRequest.getAdditionalQueryParams().get(Constants.TAG_SEARCH_PARAM)) { Assert.assertFalse(param.contains(Constants.DEFAULT_CARE_TEAM_TAG_URL)); Assert.assertFalse(param.contains(Constants.DEFAULT_ORGANISATION_TAG_URL)); } diff --git a/pom.xml b/pom.xml index 074b0d7..b83e2db 100755 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ implementations do not have to do this; they can redeclare those deps. --> com.google.fhir.gateway fhir-gateway - 0.3.2 + 0.4.0 org.smartregister @@ -20,7 +20,8 @@ - 2.30.0 + 2.43.0 + 0.4.0 @@ -33,6 +34,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + + com.mycila license-maven-plugin