diff --git a/.github/actions/build-cache/action.yml b/.github/actions/build-cache/action.yml
index afa7cad97c95..b2cbf9bfdc1c 100644
--- a/.github/actions/build-cache/action.yml
+++ b/.github/actions/build-cache/action.yml
@@ -51,7 +51,7 @@ runs:
MAVEN_CACHE_FOLDER: ${{ inputs.cache-path }}
MAVEN_OPTS: '-Xmx1024m -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Duser.timezone=America/Toronto'
run: |
- mvn clean install -P CI,CHECKSTYLE \
+ mvn clean install -P CI \
-Dmaven.test.skip=true -e -B \
-Dmaven.javadoc.skip=true \
-Dmaven.wagon.http.pool=false \
diff --git a/.github/actions/checkstyle-validation/action.yml b/.github/actions/checkstyle-validation/action.yml
new file mode 100644
index 000000000000..0f717dd4d21d
--- /dev/null
+++ b/.github/actions/checkstyle-validation/action.yml
@@ -0,0 +1,64 @@
+name: 'Cross-Module Checkstyle Validation'
+description: 'Runs cross-module checkstyle validation to detect duplicate error codes and other violations'
+
+inputs:
+ java-version:
+ description: 'The Java version to use'
+ required: false
+ default: '17'
+ maven-cache-key:
+ description: 'The cache key for Maven dependencies'
+ required: true
+ hapi-cache-key:
+ description: 'The cache key for HAPI dependencies'
+ required: true
+
+runs:
+ using: "composite"
+ steps:
+ - name: Create and List Maven Cache Directory
+ shell: bash
+ run: |
+ mkdir -p $HOME/.m2/repository
+ pwd
+ ls -al $HOME/.m2/repository
+ env:
+ MAVEN_CACHE_FOLDER: $HOME/.m2/repository
+
+ - name: Restore HAPI Cache
+ uses: ./.github/actions/caching-handler
+ with:
+ path: "$HOME/.m2/repository/ca/uhn/"
+ key: ${{ inputs.hapi-cache-key }}
+
+ - name: Set up JDK
+ uses: actions/setup-java@v4
+ with:
+ distribution: 'temurin'
+ java-version: ${{ inputs.java-version }}
+ cache: 'maven'
+
+ - name: Restore Maven Cache
+ uses: ./.github/actions/caching-handler
+ with:
+ key: ${{ inputs.maven-cache-key }}
+
+ - name: Debug cache contents
+ shell: bash
+ run: |
+ echo "Checking Maven repository contents..."
+ ls -la $HOME/.m2/repository/ca/uhn/hapi/fhir/ || echo "HAPI FHIR directory not found"
+ ls -la $HOME/.m2/repository/ca/uhn/hapi/fhir/hapi-fhir-checkstyle/ || echo "hapi-fhir-checkstyle directory not found"
+ find $HOME/.m2/repository -name "*checkstyle*" -type f || echo "No checkstyle artifacts found"
+
+ - name: Run cross-module checkstyle validation
+ shell: bash
+ env:
+ MAVEN_CACHE_FOLDER: $HOME/.m2/repository
+ run: |
+ echo "Running cross-module checkstyle validation to detect duplicate error codes and other violations..."
+ echo "This step ensures that HAPI FHIR error codes (Msg.code) are unique across all modules."
+ echo "If this step fails, it means there are checkstyle violations that must be fixed before the build can proceed."
+ echo ""
+ mvn validate -P CHECKSTYLE --batch-mode --no-transfer-progress \
+ -Dmaven.repo.local=$MAVEN_CACHE_FOLDER
diff --git a/.github/workflows/parallel-pipeline-build.yml b/.github/workflows/parallel-pipeline-build.yml
index 40d4bf1c6869..2cf71ea0d3b4 100644
--- a/.github/workflows/parallel-pipeline-build.yml
+++ b/.github/workflows/parallel-pipeline-build.yml
@@ -26,9 +26,26 @@ jobs:
java-version: '17'
cache-path: $HOME/.m2/repository
+ checkstyle:
+ runs-on: ubuntu-latest
+ needs: build-cache
+ continue-on-error: true
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Run Checkstyle Validation
+ uses: ./.github/actions/checkstyle-validation
+ with:
+ java-version: '17'
+ maven-cache-key: ${{ github.ref_name }}-maven-${{ hashFiles('**/pom.xml') }}
+ hapi-cache-key: ${{ github.ref_name }}-hapi-${{ github.run_id }}
+
generate-module-list:
name: Generate List of Modules to Build
runs-on: ubuntu-latest
+ needs: checkstyle
+ if: always()
outputs:
modules_list: ${{ steps.format-modules.outputs.modules_list }}
steps:
@@ -94,7 +111,7 @@ jobs:
final-result:
if: ${{ always() }}
runs-on: ubuntu-latest
- needs: [ assemble-test-reports ]
+ needs: [ assemble-test-reports, checkstyle ]
steps:
- run: exit 1
if: >-
diff --git a/.gitignore b/.gitignore
index 1e9ce672b0c1..6089052ebedd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -170,6 +170,6 @@ Snap.*
/database*/
/activemq-data/
/.run/
-/CLAUDE.md
+**/CLAUDE.md
**/.claude/settings.local.json
diff --git a/hapi-fhir-base/src/main/java/org/hl7/fhir/instance/model/api/IBaseReference.java b/hapi-fhir-base/src/main/java/org/hl7/fhir/instance/model/api/IBaseReference.java
index 1da438235288..7e8581307f06 100644
--- a/hapi-fhir-base/src/main/java/org/hl7/fhir/instance/model/api/IBaseReference.java
+++ b/hapi-fhir-base/src/main/java/org/hl7/fhir/instance/model/api/IBaseReference.java
@@ -19,6 +19,8 @@
*/
package org.hl7.fhir.instance.model.api;
+import ca.uhn.fhir.i18n.Msg;
+
public interface IBaseReference extends ICompositeType {
IBaseResource getResource();
@@ -38,7 +40,7 @@ default boolean hasIdentifier() {
}
default IBaseReference setIdentifier(ICompositeType theIdentifier) {
- throw new UnsupportedOperationException("This reference does not support identifiers");
+ throw new UnsupportedOperationException(Msg.code(2759) + "This reference does not support identifiers");
}
default ICompositeType getIdentifier() {
diff --git a/hapi-fhir-checkstyle/pom.xml b/hapi-fhir-checkstyle/pom.xml
index 0d1b62b5bcd8..eab994bc5d42 100644
--- a/hapi-fhir-checkstyle/pom.xml
+++ b/hapi-fhir-checkstyle/pom.xml
@@ -99,39 +99,5 @@
-
- CHECKSTYLE
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- **/osgi/**/*, **/.mvn/**/*, **/.mvn_/**/*
- true
-
- checkstyle/hapi-base-checkstyle.xml
-
- checkstyle/hapi-base-checkstyle-suppression.xml
- UTF-8
- true
-
-
-
- checkstyle-across-all-modules
- install
-
- check
-
-
-
- hapi-single-module-checkstyle
- none
-
-
-
-
-
-
diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java
index 5d185ec78a77..58446c4144d7 100644
--- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java
+++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java
@@ -103,7 +103,8 @@ private byte[] loadFileAsByteArray(String theFileName) throws ParseException {
input = IOUtils.toByteArray(new FileInputStream(new File(theFileName)));
} catch (IOException e) {
throw new ParseException(
- Msg.code(1615) + "Failed to load file '" + theFileName + "' - Error: " + e.toString());
+ // Msg.code(1615) + "Failed to load file '" + theFileName + "' - Error: " + e.toString());
+ Msg.code(2478) + "Failed to load file '" + theFileName + "' - Error: " + e.toString());
}
return input;
}
diff --git a/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/canonical/VersionCanonicalizer.java b/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/canonical/VersionCanonicalizer.java
index 847f743e8436..1a2062c9c0ad 100644
--- a/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/canonical/VersionCanonicalizer.java
+++ b/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/canonical/VersionCanonicalizer.java
@@ -566,7 +566,8 @@ private String encodeAsString(IBaseResource theResource) {
} else if (myDstu2Hl7OrgContext.getVersion().getVersion().equals(version)) {
return myDstu2Hl7OrgContext.newJsonParser().encodeResourceToString(theResource);
} else {
- throw new IllegalArgumentException("Cannot encode resource with version: %s".formatted(version));
+ throw new IllegalArgumentException(
+ Msg.code(2777) + "Cannot encode resource with version: %s".formatted(version));
}
}
}
diff --git a/hapi-fhir-jpa/src/main/java/ca/uhn/fhir/jpa/logging/SqlLoggerFilteringUtil.java b/hapi-fhir-jpa/src/main/java/ca/uhn/fhir/jpa/logging/SqlLoggerFilteringUtil.java
index 7dd1fcd0d181..14646cb59572 100644
--- a/hapi-fhir-jpa/src/main/java/ca/uhn/fhir/jpa/logging/SqlLoggerFilteringUtil.java
+++ b/hapi-fhir-jpa/src/main/java/ca/uhn/fhir/jpa/logging/SqlLoggerFilteringUtil.java
@@ -126,7 +126,7 @@ public void run() {
} catch (Exception theE) {
ourLog.error("Hibernate SQL log filters not refreshed. Exception: {} \n{}", theE, theE.getStackTrace());
- throw new RuntimeException(Msg.code(2478) + theE);
+ throw new RuntimeException(Msg.code(2778) + theE);
} finally {
myRefreshDoneLatch.countDown();
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/cache/ResourceTypeCacheSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/cache/ResourceTypeCacheSvcImpl.java
index b885fb902b8b..59118f06d08a 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/cache/ResourceTypeCacheSvcImpl.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/cache/ResourceTypeCacheSvcImpl.java
@@ -19,6 +19,7 @@
*/
package ca.uhn.fhir.jpa.cache;
+import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.jpa.config.util.ResourceTypeUtil;
import ca.uhn.fhir.jpa.dao.data.IResourceTypeDao;
import ca.uhn.fhir.jpa.dao.tx.IHapiTransactionService;
@@ -119,7 +120,8 @@ protected ResourceTypeEntity createResourceType(String theResourceType) {
myResourceTypeDao.flush();
} catch (DataIntegrityViolationException e) {
if (e.getMessage().contains("Value too long for column")) {
- throw new InternalErrorException("Resource type name is too long: " + theResourceType, e);
+ throw new InternalErrorException(
+ Msg.code(2764) + "Resource type name is too long: " + theResourceType, e);
}
// This can happen if the resource type already exists in the database
ourLog.info("Resource type already exists: {}", theResourceType);
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/AdditionalResourcesParser.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/AdditionalResourcesParser.java
index bb26cec28b59..a843c7d419e7 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/AdditionalResourcesParser.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/AdditionalResourcesParser.java
@@ -20,6 +20,7 @@
package ca.uhn.fhir.jpa.packages;
import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.util.BundleBuilder;
@@ -45,7 +46,7 @@ public static IBaseBundle bundleAdditionalResources(
try {
npmPackage = NpmPackage.fromPackage(new ByteArrayInputStream(packageInstallationSpec.getPackageContents()));
} catch (IOException e) {
- throw new InternalErrorException(e);
+ throw new InternalErrorException(Msg.code(2765) + e);
}
List resources = getAdditionalResources(additionalResources, npmPackage, fhirContext);
@@ -73,7 +74,7 @@ public static List getAdditionalResources(
.flatMap(Collection::stream)
.collect(Collectors.toList());
} catch (IOException e) {
- throw new InternalErrorException(e.getMessage(), e);
+ throw new InternalErrorException(Msg.code(2766) + e.getMessage(), e);
}
resources.addAll(fileNames.stream()
@@ -81,7 +82,7 @@ public static List getAdditionalResources(
try {
return new String(folder.fetchFile(fileName));
} catch (IOException e) {
- throw new InternalErrorException(e.getMessage(), e);
+ throw new InternalErrorException(Msg.code(2767) + e.getMessage(), e);
}
})
.map(parser::parseResource)
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/BaseResourceHistoryPredicateBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/BaseResourceHistoryPredicateBuilder.java
index d61c791c4193..ddb3fd490da5 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/BaseResourceHistoryPredicateBuilder.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/BaseResourceHistoryPredicateBuilder.java
@@ -112,8 +112,7 @@ private Condition createPredicateSourceContains(JpaStorageSettings theStorageSet
String containsLikeExpression = createLeftAndRightMatchLikeExpression(normalizedString);
return BinaryCondition.like(upperFunction, generatePlaceholder(containsLikeExpression));
} else {
- throw new MethodNotAllowedException(
- Msg.code(getContainsModifierDisabledCode()) + ":contains modifier is disabled on this server");
+ throw new MethodNotAllowedException(Msg.code(2768) + ":contains modifier is disabled on this server");
}
}
diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/fulltext/FullTextExtractionRequest.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/fulltext/FullTextExtractionRequest.java
index 50101d8c7739..19965b49ba5d 100644
--- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/fulltext/FullTextExtractionRequest.java
+++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/fulltext/FullTextExtractionRequest.java
@@ -24,7 +24,6 @@
import org.hl7.fhir.instance.model.api.IIdType;
import java.util.function.Supplier;
-import javax.annotation.Nullable;
/**
* This is a request object containing a request to extract the FullText index data from
@@ -35,10 +34,10 @@
*/
public class FullTextExtractionRequest {
- @Nullable
+ @Nonnull
private final IIdType myResourceId;
- @Nullable
+ @Nonnull
private final IBaseResource myResource;
@Nonnull
@@ -51,8 +50,8 @@ public class FullTextExtractionRequest {
* Constructor
*/
public FullTextExtractionRequest(
- @Nullable IIdType theResourceId,
- @Nullable IBaseResource theResource,
+ @Nonnull IIdType theResourceId,
+ @Nonnull IBaseResource theResource,
@Nonnull String theResourceType,
@Nonnull Supplier theDefaultSupplier) {
myResourceId = theResourceId;
@@ -71,7 +70,7 @@ public boolean isDelete() {
/**
* @return Returns the ID of the resource being indexed. This may be null
if a new resource is being created, and a type isn't assigned yet
*/
- @Nullable
+ @Nonnull
public IIdType getResourceId() {
return myResourceId;
}
@@ -79,7 +78,7 @@ public IIdType getResourceId() {
/**
* @return Returns the resource being indexed. May be null
if the operation is a resource deletion.
*/
- @Nullable
+ @Nonnull
public IBaseResource getResource() {
return myResource;
}
diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/fulltext/FullTextExtractionResponse.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/fulltext/FullTextExtractionResponse.java
index aaf30d94d4d2..f553020fc36a 100644
--- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/fulltext/FullTextExtractionResponse.java
+++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/fulltext/FullTextExtractionResponse.java
@@ -19,7 +19,7 @@
*/
package ca.uhn.fhir.jpa.searchparam.fulltext;
-import javax.annotation.Nullable;
+import jakarta.annotation.Nonnull;
/**
* This is a response object containing the FullText index data which should be stored during
@@ -72,7 +72,7 @@ public static FullTextExtractionResponse doNotIndex() {
*
* @param thePayload The fulltext payload string. May be null
if no payload should be specified for the given resource.
*/
- public static FullTextExtractionResponse indexPayload(@Nullable String thePayload) {
+ public static FullTextExtractionResponse indexPayload(@Nonnull String thePayload) {
return new FullTextExtractionResponse(false, false, thePayload);
}
diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/channel/subscription/SubscriptionDeliveryValidator.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/channel/subscription/SubscriptionDeliveryValidator.java
index 4437316bcfd7..b38f5b530b7c 100644
--- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/channel/subscription/SubscriptionDeliveryValidator.java
+++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/channel/subscription/SubscriptionDeliveryValidator.java
@@ -71,7 +71,7 @@ public void validate(IIdType theSubscriptionId, ResourceDeliveryMessage theResou
case OFF:
case NULL:
default:
- throw new SubscriptionInactiveException(Msg.code(2668) + "Attempting to deliver "
+ throw new SubscriptionInactiveException(Msg.code(2762) + "Attempting to deliver "
+ theResourceDeliveryMessage.getPayloadId() + " to disabled subscription "
+ subscription.getIdElementString() + ". Aborting delivery.");
}
diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SourceTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SourceTest.java
index d9853a068f78..25ebaaf5bd51 100644
--- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SourceTest.java
+++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SourceTest.java
@@ -184,7 +184,7 @@ public void testSearchSource_withContainsModifierAndContainsSearchesDisabled_thr
myPatientDao.search(searchParameter);
fail();
} catch (MethodNotAllowedException e) {
- assertEquals(Msg.code(2570) + ":contains modifier is disabled on this server", e.getMessage());
+ assertEquals(Msg.code(2768) + ":contains modifier is disabled on this server", e.getMessage());
}
}
diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchApplyR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchApplyR4Test.java
index f546fa06145d..feba6787a34a 100644
--- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchApplyR4Test.java
+++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchApplyR4Test.java
@@ -506,7 +506,7 @@ public void testReplaceAnElementInHighCardinalityField_NoMatchingElement_Invalid
//When: We apply the patch, expect an InvalidRequestException
InvalidRequestException ex = assertThrows(InvalidRequestException.class, () -> svc.apply(patient, patch));
- String expectedMessage = String.format("HAPI-2617: No element matches the specified path: %s", thePath);
+ String expectedMessage = String.format("HAPI-2716: No element matches the specified path: %s", thePath);
assertThat(ex.getMessage()).isEqualTo(expectedMessage);
assertThat(patient.getIdentifier()).hasSize(2);
diff --git a/hapi-fhir-repositories/src/main/java/ca/uhn/fhir/repository/impl/NaiveRepositoryTransactionProcessor.java b/hapi-fhir-repositories/src/main/java/ca/uhn/fhir/repository/impl/NaiveRepositoryTransactionProcessor.java
index d377ebc0a146..c7803308a65e 100644
--- a/hapi-fhir-repositories/src/main/java/ca/uhn/fhir/repository/impl/NaiveRepositoryTransactionProcessor.java
+++ b/hapi-fhir-repositories/src/main/java/ca/uhn/fhir/repository/impl/NaiveRepositoryTransactionProcessor.java
@@ -1,6 +1,7 @@
package ca.uhn.fhir.repository.impl;
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
+import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.repository.IRepository;
import ca.uhn.fhir.rest.api.Constants;
@@ -83,7 +84,7 @@ public B processTransaction(B theTransactionBundle) {
case PUT -> processPut(e, now);
case DELETE -> processDelete(e, now);
default -> throw new NotImplementedOperationException(
- "Transaction stub only supports POST, PUT, or DELETE");
+ Msg.code(2769) + "Transaction stub only supports POST, PUT, or DELETE");
};
bundleBuilder.addEntry(myResponseEntryBuilder.apply(responseEntry));
}
@@ -120,7 +121,7 @@ private static void validateNoLogicalUrl(BundleEntryParts theBundleEntryParts) {
String url = theBundleEntryParts.getUrl();
Validate.notNull(url, "request url must not be null: entry %s", theBundleEntryParts.getFullUrl());
if (url.contains("?")) {
- throw new UnprocessableEntityException("Conditional urls are not supported");
+ throw new UnprocessableEntityException(Msg.code(2770) + "Conditional urls are not supported");
}
}
@@ -129,7 +130,7 @@ protected BundleResponseEntryParts processPost(
BundleEntryParts theBundleEntryParts, IPrimitiveType theInstant) {
// we assume POST is always "create", not an operation invocation
if (theBundleEntryParts.getConditionalUrl() != null) {
- throw new UnprocessableEntityException("Conditional create urls are not supported");
+ throw new UnprocessableEntityException(Msg.code(2771) + "Conditional create urls are not supported");
}
var responseOutcome = myRepository.create(theBundleEntryParts.getResource());
@@ -197,7 +198,8 @@ protected static String statusCodeToStatusLine(int theResponseStatusCode) {
case Constants.STATUS_HTTP_409_CONFLICT -> "409 Conflict";
case Constants.STATUS_HTTP_204_NO_CONTENT -> "204 No Content";
case Constants.STATUS_HTTP_404_NOT_FOUND -> "404 Not Found";
- default -> throw new IllegalArgumentException("Unsupported response status code: " + theResponseStatusCode);
+ default -> throw new IllegalArgumentException(
+ Msg.code(2776) + "Unsupported response status code: " + theResponseStatusCode);
};
}
}
diff --git a/hapi-fhir-repositories/src/main/java/ca/uhn/fhir/repository/impl/memory/InMemoryFhirRepository.java b/hapi-fhir-repositories/src/main/java/ca/uhn/fhir/repository/impl/memory/InMemoryFhirRepository.java
index 172d1d7c3899..5a8145a6d0f0 100644
--- a/hapi-fhir-repositories/src/main/java/ca/uhn/fhir/repository/impl/memory/InMemoryFhirRepository.java
+++ b/hapi-fhir-repositories/src/main/java/ca/uhn/fhir/repository/impl/memory/InMemoryFhirRepository.java
@@ -1,6 +1,7 @@
package ca.uhn.fhir.repository.impl.memory;
import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.repository.IRepository;
import ca.uhn.fhir.repository.impl.NaiveRepositoryTransactionProcessor;
@@ -121,7 +122,7 @@ private String formatResource(IBaseResource theResource) {
@Override
public synchronized MethodOutcome patch(
I theId, P thePatchParameters, Map theHeaders) {
- throw new NotImplementedOperationException("The PATCH operation is not currently supported");
+ throw new NotImplementedOperationException(Msg.code(2772) + "The PATCH operation is not currently supported");
}
@Override
diff --git a/hapi-fhir-repositories/src/main/java/ca/uhn/fhir/repository/impl/memory/NaiveSearching.java b/hapi-fhir-repositories/src/main/java/ca/uhn/fhir/repository/impl/memory/NaiveSearching.java
index a56a6f7ae8bc..cde90c1f2b59 100644
--- a/hapi-fhir-repositories/src/main/java/ca/uhn/fhir/repository/impl/memory/NaiveSearching.java
+++ b/hapi-fhir-repositories/src/main/java/ca/uhn/fhir/repository/impl/memory/NaiveSearching.java
@@ -1,6 +1,7 @@
package ca.uhn.fhir.repository.impl.memory;
import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.param.ReferenceParam;
@@ -127,8 +128,8 @@ IdDt normalizeIdParamToIdPart(IQueryParameterType theIdParam) {
} else if (theIdParam instanceof StringParam stringParam) {
return new IdDt(stringParam.getValue());
} else {
- throw new IllegalArgumentException(
- "Unsupported _id parameter type: " + theIdParam.getClass().getName());
+ throw new IllegalArgumentException(Msg.code(2773) + "Unsupported _id parameter type: "
+ + theIdParam.getClass().getName());
}
}
@@ -139,7 +140,7 @@ Predicate matchPredicate(Multimap getStringPrimitiveFromParametersParameter(
} else if (value instanceof IBaseReference patientReference) {
return patientReference.getReferenceElement();
} else {
- throw new InvalidRequestException("Unsupported type.");
+ throw new InvalidRequestException(Msg.code(2763) + "Unsupported type.");
}
} catch (Exception e) {
- throw new InvalidRequestException("Invalid patient parameter.", e);
+ throw new InvalidRequestException(Msg.code(2779) + "Invalid patient parameter.", e);
}
}
diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/merge/MergeUpdateTaskReducerStep.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/merge/MergeUpdateTaskReducerStep.java
index 787f2fffb97f..2294077814cf 100644
--- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/merge/MergeUpdateTaskReducerStep.java
+++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/merge/MergeUpdateTaskReducerStep.java
@@ -31,10 +31,10 @@
import ca.uhn.fhir.merge.MergeOperationInputParameterNames;
import ca.uhn.fhir.merge.MergeProvenanceSvc;
import ca.uhn.fhir.rest.api.server.RequestDetails;
+import jakarta.annotation.Nonnull;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.r4.model.Patient;
-import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
@@ -137,7 +137,7 @@ private boolean isDeleteSource(Parameters originalInputParameters) {
return deleteSource;
}
- private @Nullable Patient getResultResource(Parameters theOriginalInputParameters) {
+ private @Nonnull Patient getResultResource(Parameters theOriginalInputParameters) {
Patient resultResource = null;
String resultResourceParamName = myMergeOperationInputParameterNames.getResultResourceParameterName();
if (theOriginalInputParameters.hasParameter(resultResourceParamName)) {
diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/replacereferences/ProvenanceAgentJson.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/replacereferences/ProvenanceAgentJson.java
index a70b07d184b6..469b1db3f712 100644
--- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/replacereferences/ProvenanceAgentJson.java
+++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/replacereferences/ProvenanceAgentJson.java
@@ -25,11 +25,11 @@
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.util.TerserUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
+import jakarta.annotation.Nonnull;
import org.hl7.fhir.instance.model.api.IBaseReference;
import java.util.List;
import java.util.stream.Collectors;
-import javax.annotation.Nullable;
/**
* ProvenanceAgentJson is a JSON representation of an IProvenanceAgent.
@@ -75,7 +75,7 @@ public static ProvenanceAgentJson from(IProvenanceAgent theProvenanceAgent, Fhir
}
public static List from(
- @Nullable List theProvenanceAgents, FhirContext theFhirContext) {
+ @Nonnull List theProvenanceAgents, FhirContext theFhirContext) {
if (theProvenanceAgents == null) {
return null;
}
diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/broker/api/ChannelProducerSettings.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/broker/api/ChannelProducerSettings.java
index 88e984a413e5..312e3410714e 100644
--- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/broker/api/ChannelProducerSettings.java
+++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/broker/api/ChannelProducerSettings.java
@@ -19,14 +19,14 @@
*/
package ca.uhn.fhir.broker.api;
-import javax.annotation.Nullable;
+import jakarta.annotation.Nonnull;
public class ChannelProducerSettings extends BaseChannelSettings {
public static final Integer DEFAULT_CHANNEL_CONSUMERS = 2;
private Integer myConcurrentConsumers = DEFAULT_CHANNEL_CONSUMERS;
- @Nullable
+ @Nonnull
private String myProducerSuffix;
/**
@@ -34,6 +34,7 @@ public class ChannelProducerSettings extends BaseChannelSettings {
*/
public ChannelProducerSettings() {
super();
+ myProducerSuffix = "";
}
public Integer getConcurrentConsumers() {
@@ -51,7 +52,7 @@ public ChannelProducerSettings setConcurrentConsumers(int theConcurrentConsumers
* In the case where the Message Broker adds a suffix to the channel name to define the producer name, this allows
* control of the suffix used.
*/
- @Nullable
+ @Nonnull
public String getProducerNameSuffix() {
return myProducerSuffix;
}
@@ -60,7 +61,7 @@ public String getProducerNameSuffix() {
* In the case where the Message Broker adds a suffix to the channel name to define the producer name, this allows
* control of the suffix used.
*/
- public ChannelProducerSettings setProducerNameSuffix(@Nullable String theProducerNameSuffix) {
+ public ChannelProducerSettings setProducerNameSuffix(@Nonnull String theProducerNameSuffix) {
myProducerSuffix = theProducerNameSuffix;
return this;
}
diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/patch/FhirPatch.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/patch/FhirPatch.java
index ad47b675e0bc..b23dcca2d549 100644
--- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/patch/FhirPatch.java
+++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/patch/FhirPatch.java
@@ -571,7 +571,7 @@ private List applySubsettingFilter(
private void throwNoElementsError(String theFullReplacePath) {
String msg =
myContext.getLocalizer().getMessage(FhirPatch.class, "noMatchingElementForPath", theFullReplacePath);
- throw new InvalidRequestException(Msg.code(2617) + msg);
+ throw new InvalidRequestException(Msg.code(2761) + msg);
}
private void handleMoveOperation(IBaseResource theResource, IBase theParameters) {
diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/replacereferences/ReplaceReferencesRequest.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/replacereferences/ReplaceReferencesRequest.java
index 7945f218a4c6..66081f562368 100644
--- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/replacereferences/ReplaceReferencesRequest.java
+++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/replacereferences/ReplaceReferencesRequest.java
@@ -23,10 +23,10 @@
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
import ca.uhn.fhir.model.api.IProvenanceAgent;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
+import jakarta.annotation.Nonnull;
import org.hl7.fhir.instance.model.api.IIdType;
import java.util.List;
-import javax.annotation.Nonnull;
import static ca.uhn.fhir.rest.server.provider.ProviderConstants.OPERATION_REPLACE_REFERENCES_PARAM_SOURCE_REFERENCE_ID;
import static ca.uhn.fhir.rest.server.provider.ProviderConstants.OPERATION_REPLACE_REFERENCES_PARAM_TARGET_REFERENCE_ID;
diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/replacereferences/UndoReplaceReferencesRequest.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/replacereferences/UndoReplaceReferencesRequest.java
index b7ebcbe0412f..5d6bb90f22e5 100644
--- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/replacereferences/UndoReplaceReferencesRequest.java
+++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/replacereferences/UndoReplaceReferencesRequest.java
@@ -20,10 +20,9 @@
package ca.uhn.fhir.replacereferences;
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
+import jakarta.annotation.Nonnull;
import org.hl7.fhir.instance.model.api.IIdType;
-import javax.annotation.Nonnull;
-
/**
* This class models the parameters for processing a $hapi.fhir.undo-replace-references operation.
*/
diff --git a/pom.xml b/pom.xml
index 93e7dc5e68bb..5ccb9685cf2e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3010,6 +3010,52 @@
+
+ CHECKSTYLE
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ false
+
+
+ com.puppycrawl.tools
+ checkstyle
+ ${checkstyle_version}
+
+
+ ca.uhn.hapi.fhir
+ hapi-fhir-checkstyle
+ ${project.version}
+
+
+
+
+ ./
+
+ **/src/main/java/**/*.java
+ **/osgi/**/*, **/.mvn/**/*, **/.mvn_/**/*, **/target/**/*, **/test/**/*
+ false
+ checkstyle/hapi-base-checkstyle.xml
+ checkstyle/hapi-base-checkstyle-suppression.xml
+ UTF-8
+ true
+ true
+
+
+
+ checkstyle-all-modules
+ validate
+
+ check
+
+
+
+
+
+
+
ERRORPRONE