From 2962669cc2ba63c315dd6aa5b930ed34ec7fd439 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Mar 2022 19:19:04 +0100 Subject: [PATCH 1/4] chore(deps): bump libphonenumber from 8.12.44 to 8.12.45 Bumps [libphonenumber](https://github.com/google/libphonenumber) from 8.12.44 to 8.12.45. - [Release notes](https://github.com/google/libphonenumber/releases) - [Changelog](https://github.com/google/libphonenumber/blob/master/making-metadata-changes.md) - [Commits](https://github.com/google/libphonenumber/compare/v8.12.44...v8.12.45) --- updated-dependencies: - dependency-name: com.googlecode.libphonenumber:libphonenumber dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> PR #671 --- iris-client-bff/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iris-client-bff/pom.xml b/iris-client-bff/pom.xml index 4ac22687b..93b7a4590 100644 --- a/iris-client-bff/pom.xml +++ b/iris-client-bff/pom.xml @@ -252,7 +252,7 @@ com.googlecode.libphonenumber libphonenumber - 8.12.44 + 8.12.45 From 6d8536c5a4600a485860cb971c74a46f644ae305 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Mar 2022 19:20:12 +0100 Subject: [PATCH 2/4] chore(deps): bump modelmapper from 3.0.0 to 3.1.0 Bumps [modelmapper](https://github.com/modelmapper/modelmapper) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/modelmapper/modelmapper/releases) - [Changelog](https://github.com/modelmapper/modelmapper/blob/master/CHANGES.md) - [Commits](https://github.com/modelmapper/modelmapper/compare/modelmapper-parent-3.0.0...modelmapper-parent-3.1.0) --- updated-dependencies: - dependency-name: org.modelmapper:modelmapper dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> PR #669 --- iris-client-bff/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iris-client-bff/pom.xml b/iris-client-bff/pom.xml index 93b7a4590..91bf92efb 100644 --- a/iris-client-bff/pom.xml +++ b/iris-client-bff/pom.xml @@ -237,7 +237,7 @@ org.modelmapper modelmapper - 3.0.0 + 3.1.0 io.vavr From 7186e28392aebc68800b700c81445ab53e6880a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Mar 2022 19:20:28 +0100 Subject: [PATCH 3/4] chore(deps): bump java-jwt from 3.18.3 to 3.19.0 Bumps [java-jwt](https://github.com/auth0/java-jwt) from 3.18.3 to 3.19.0. - [Release notes](https://github.com/auth0/java-jwt/releases) - [Changelog](https://github.com/auth0/java-jwt/blob/master/CHANGELOG.md) - [Commits](https://github.com/auth0/java-jwt/compare/3.18.3...3.19.0) --- updated-dependencies: - dependency-name: com.auth0:java-jwt dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> PR #670 --- iris-client-bff/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iris-client-bff/pom.xml b/iris-client-bff/pom.xml index 91bf92efb..61b373e01 100644 --- a/iris-client-bff/pom.xml +++ b/iris-client-bff/pom.xml @@ -263,7 +263,7 @@ com.auth0 java-jwt - 3.18.3 + 3.19.0 org.springframework.security From 446da176fa26cc3dd81151048b6133a30e964b54 Mon Sep 17 00:00:00 2001 From: Nuts Date: Tue, 15 Mar 2022 13:34:47 +0100 Subject: [PATCH 4/4] feat(Messages): Uses `_ping` and the EPS version check when building the recipient list to determine if a health department is able to receive messages. This avoids additional configuration and enables faster propagation of the feature. - uses health-departments _ping and EPS version check to determine if a health-department is able to receive messages - uses simple caching by a map with stored timestamps and results Co-authored-by: Jens Kutzsche Co-authored-by: lucky-lusa PR #668 --- .../eps/EPSIrisMessageClient.java | 78 +++++++++++++++---- 1 file changed, 64 insertions(+), 14 deletions(-) diff --git a/iris-client-bff/src/main/java/iris/client_bff/iris_messages/eps/EPSIrisMessageClient.java b/iris-client-bff/src/main/java/iris/client_bff/iris_messages/eps/EPSIrisMessageClient.java index 9eab582f5..b7eed51f8 100644 --- a/iris-client-bff/src/main/java/iris/client_bff/iris_messages/eps/EPSIrisMessageClient.java +++ b/iris-client-bff/src/main/java/iris/client_bff/iris_messages/eps/EPSIrisMessageClient.java @@ -1,21 +1,41 @@ package iris.client_bff.iris_messages.eps; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.googlecode.jsonrpc4j.JsonRpcHttpClient; import iris.client_bff.config.RPCClientProperties; -import iris.client_bff.iris_messages.*; +import iris.client_bff.iris_messages.IrisMessage; +import iris.client_bff.iris_messages.IrisMessageException; +import iris.client_bff.iris_messages.IrisMessageHdContact; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; +import lombok.extern.slf4j.Slf4j; + +import java.time.Duration; +import java.time.Instant; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import java.util.*; + +import org.springframework.data.util.Version; +import org.springframework.stereotype.Service; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.googlecode.jsonrpc4j.JsonRpcHttpClient; @Service @RequiredArgsConstructor +@Slf4j public class EPSIrisMessageClient { private static final int READ_TIMEOUT = 12 * 1000; + private static final Duration CACHING_TIME = Duration.ofMinutes(30); + + private static final Version MESSAGE_CLIENT_MIN_VERSION = new Version(0, 2, 4); + + private static final Map hdCache = new ConcurrentHashMap<>(); private final JsonRpcHttpClient epsRpcClient; private final RPCClientProperties rpcClientProps; @@ -46,15 +66,27 @@ public List getIrisMessageHdContacts() throws IrisMessageE } } - private boolean isHealthDepartmentWithInterGaCommunication(DirectoryEntry directoryEntry) { - - return - directoryEntry.groups() != null && - directoryEntry.groups().contains("health-departments") && - directoryEntry.services() != null && - directoryEntry.services().stream().anyMatch(service -> service.name().equals("inter-ga-communication")); + private boolean isHealthDepartment(DirectoryEntry directoryEntry) { + return + directoryEntry.groups() != null && + directoryEntry.groups().contains("health-departments"); + } + + private boolean isHealthDepartmentWithInterGaCommunication(DirectoryEntry directoryEntry) { + + if (!isHealthDepartment(directoryEntry)) + return false; + + return hdCache.compute(directoryEntry.name, (key, value) -> { + + if (value == null || value.validatedAt().isBefore(Instant.now().minus(CACHING_TIME))) { + return new MapEntry(Instant.now(), checkIfEpsVersionGreatEnough(directoryEntry.name)); } + return value; + }).valid(); + } + public void createIrisMessage(IrisMessage message) throws IrisMessageException { String methodName = message.getHdRecipient().getId() + ".createIrisMessage"; Map payload = Map.of("irisMessage", IrisMessageTransferDto.fromEntity(message)); @@ -69,13 +101,31 @@ public void createIrisMessage(IrisMessage message) throws IrisMessageException { } } + private boolean checkIfEpsVersionGreatEnough(String name) { + + var methodName = name + "._ping"; + + try { + Ping ping = epsRpcClient.invoke(methodName, null, Ping.class); + String semver = ping.version.replaceAll("^v", ""); + Version version = Version.parse(semver); + return version.isGreaterThanOrEqualTo(MESSAGE_CLIENT_MIN_VERSION); + } catch (Throwable t) { + + log.warn("Can't ping hd client " + name); + + return false; + } + } + @JsonIgnoreProperties(ignoreUnknown = true) record Directory(@NotNull List<@Valid DirectoryEntry> entries) {} @JsonIgnoreProperties(ignoreUnknown = true) - record DirectoryEntry(@NotNull String name, Set groups, List<@Valid DirectoryEntryService> services) {} + record DirectoryEntry(@NotNull String name, Set groups) {} @JsonIgnoreProperties(ignoreUnknown = true) - record DirectoryEntryService(@NotNull String name) {} + record Ping(String version) {}; + private record MapEntry(Instant validatedAt, boolean valid) {}; }