Add docs, upgrade guide, upgrade.md (#5543)

This commit is contained in:
Tadgh 2023-12-12 15:08:00 -08:00 committed by GitHub
parent 564ae46008
commit 9e20659680
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 89 additions and 1 deletions

View File

@ -73,7 +73,11 @@ public final class HapiErrorCodeCheck extends AbstractCheck {
} else {
String location = getFilePath() + ":" + instantiation.getLineNo() + ":"
+ instantiation.getColumnNo() + "(" + code + ")";
ourCache.put(code, location);
// Ignore errors thrown in test for duplicates, as some fake implementations are throwing the same
// codes for test purpsoes.
if (!location.contains("/test/")) {
ourCache.put(code, location);
}
}
} else {
log(theAst.getLineNo(), "Called Msg.code() with a non-integer argument");

View File

@ -0,0 +1,4 @@
---
type: fix
issue: 5452
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."

View File

@ -0,0 +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.

View File

@ -105,6 +105,7 @@ page.interceptors.built_in_client_interceptors=Built-In Client Interceptors
page.interceptors.server_interceptors=Server Interceptors
page.interceptors.server_pointcuts=Server Pointcuts
page.interceptors.built_in_server_interceptors=Built-In Server Interceptors
page.interceptors.jakarta_upgrade=7.0.0 Migration Guide
section.security.title=Security
page.security.introduction=Introduction

View File

@ -0,0 +1,78 @@
# 7.0.0 Interceptor Upgrade Guide
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.
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.
## Example
### Old Server Interceptor
```java
package com.example;
import ca.uhn.fhir.interceptor.api.Hook;
import ca.uhn.fhir.interceptor.api.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Iterator;
import java.util.function.Supplier;
public class SampleInteceptor{
private static final Logger ourLog = LoggerFactory.getLogger(SampleInteceptor.class);
@Hook(Pointcut.SERVER_INCOMING_REQUEST_PRE_PROCESSED)
public boolean serverIncomingRequestPreProcessed(HttpServletRequest theHttpServletRequest, HttpServletResponse theHttpServletResponse) {
ourLog.info("I'm an interceptor!");
return true;
}
}
```
## New Server Interceptor
```java
package com.example;
import ca.uhn.fhir.interceptor.api.Hook;
import ca.uhn.fhir.interceptor.api.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Iterator;
import java.util.function.Supplier;
public class SampleInteceptor{
private static final Logger ourLog = LoggerFactory.getLogger(SampleInteceptor.class);
@Hook(Pointcut.SERVER_INCOMING_REQUEST_PRE_PROCESSED)
public boolean serverIncomingRequestPreProcessed(HttpServletRequest theHttpServletRequest, HttpServletResponse theHttpServletResponse) {
ourLog.info("I'm an interceptor!");
return true;
}
}
```
You'll note that there is only one very subtle difference between these two versions, and that is the change from:
```java
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
```
to:
```java
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
```