Skip to content

Commit 9e20659

Browse files
authored
Add docs, upgrade guide, upgrade.md (#5543)
1 parent 564ae46 commit 9e20659

File tree

5 files changed

+89
-1
lines changed

5 files changed

+89
-1
lines changed

hapi-fhir-checkstyle/src/main/java/ca/uhn/fhir/checks/HapiErrorCodeCheck.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ private void validateMessageCode(DetailAST theAst) {
7373
} else {
7474
String location = getFilePath() + ":" + instantiation.getLineNo() + ":"
7575
+ instantiation.getColumnNo() + "(" + code + ")";
76-
ourCache.put(code, location);
76+
// Ignore errors thrown in test for duplicates, as some fake implementations are throwing the same
77+
// codes for test purpsoes.
78+
if (!location.contains("/test/")) {
79+
ourCache.put(code, location);
80+
}
7781
}
7882
} else {
7983
log(theAst.getLineNo(), "Called Msg.code() with a non-integer argument");
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
type: fix
3+
issue: 5452
4+
title: "Swapped from using `javax.*` to `jakarta.*` packages. This is a breaking change for a large majority of people who write custom code against HAPI-FHIR. Please see [the migration guide](/docs/interceptors/jakarta_upgrade.md) for more information."
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This release contains a large breaking change for authors of interceptors. Internally, HAPI-FHIR has swapped from using `javax.*` to `jakarta.*` packages. Please see [the migration guide](/docs/interceptors/jakarta_upgrade.md) for more information. Without manual intervention, the majority of interceptors will fail at runtime unless they are upgraded.

hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/files.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ page.interceptors.built_in_client_interceptors=Built-In Client Interceptors
105105
page.interceptors.server_interceptors=Server Interceptors
106106
page.interceptors.server_pointcuts=Server Pointcuts
107107
page.interceptors.built_in_server_interceptors=Built-In Server Interceptors
108+
page.interceptors.jakarta_upgrade=7.0.0 Migration Guide
108109

109110
section.security.title=Security
110111
page.security.introduction=Introduction
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# 7.0.0 Interceptor Upgrade Guide
2+
3+
As of HAPI-FHIR 7.0.0, dependency on the `javax.*` packages has now changed to instead use the `jakarta.*` packages. This is a breaking change for any users who have written their own interceptors, as the package names of the interfaces have changed.
4+
5+
In order to upgrade your interceptors, you will need to change, at a minimum, the imports in your affected interceptor implementations. For example, if you have an interceptor that uses imports such as `javax.servlet.http.HttpServletRequest`, you will need to change these to `jakarta.servlet.http.HttpServletRequest`. The following is an example of a migration of an interceptor.
6+
7+
## Example
8+
9+
### Old Server Interceptor
10+
11+
```java
12+
package com.example;
13+
14+
import ca.uhn.fhir.interceptor.api.Hook;
15+
import ca.uhn.fhir.interceptor.api.Pointcut;
16+
import org.slf4j.Logger;
17+
import org.slf4j.LoggerFactory;
18+
import org.springframework.beans.factory.annotation.Autowired;
19+
20+
import javax.servlet.http.HttpServletRequest;
21+
import javax.servlet.http.HttpServletResponse;
22+
import java.util.Iterator;
23+
import java.util.function.Supplier;
24+
25+
public class SampleInteceptor{
26+
27+
private static final Logger ourLog = LoggerFactory.getLogger(SampleInteceptor.class);
28+
29+
@Hook(Pointcut.SERVER_INCOMING_REQUEST_PRE_PROCESSED)
30+
public boolean serverIncomingRequestPreProcessed(HttpServletRequest theHttpServletRequest, HttpServletResponse theHttpServletResponse) {
31+
ourLog.info("I'm an interceptor!");
32+
return true;
33+
}
34+
}
35+
```
36+
37+
## New Server Interceptor
38+
39+
```java
40+
package com.example;
41+
42+
import ca.uhn.fhir.interceptor.api.Hook;
43+
import ca.uhn.fhir.interceptor.api.Pointcut;
44+
import org.slf4j.Logger;
45+
import org.slf4j.LoggerFactory;
46+
import org.springframework.beans.factory.annotation.Autowired;
47+
48+
import jakarta.servlet.http.HttpServletRequest;
49+
import jakarta.servlet.http.HttpServletResponse;
50+
import java.util.Iterator;
51+
import java.util.function.Supplier;
52+
53+
public class SampleInteceptor{
54+
55+
private static final Logger ourLog = LoggerFactory.getLogger(SampleInteceptor.class);
56+
57+
@Hook(Pointcut.SERVER_INCOMING_REQUEST_PRE_PROCESSED)
58+
public boolean serverIncomingRequestPreProcessed(HttpServletRequest theHttpServletRequest, HttpServletResponse theHttpServletResponse) {
59+
ourLog.info("I'm an interceptor!");
60+
return true;
61+
}
62+
}
63+
```
64+
65+
You'll note that there is only one very subtle difference between these two versions, and that is the change from:
66+
67+
```java
68+
import javax.servlet.http.HttpServletRequest;
69+
import javax.servlet.http.HttpServletResponse;
70+
```
71+
72+
to:
73+
74+
```java
75+
import jakarta.servlet.http.HttpServletRequest;
76+
import jakarta.servlet.http.HttpServletResponse;
77+
```
78+

0 commit comments

Comments
 (0)