diff --git a/pom.xml b/pom.xml index 82db6ce..5511040 100644 --- a/pom.xml +++ b/pom.xml @@ -104,6 +104,10 @@ org.openehealth.ipf.boot ipf-hl7-spring-boot-starter + + org.openehealth.ipf.commons + ipf-commons-ihe-xua + org.mock-server mockserver-junit-jupiter-no-dependencies diff --git a/src/main/java/org/openehealth/app/xdstofhir/registry/audit/ATNAEventActuator.java b/src/main/java/org/openehealth/app/xdstofhir/registry/audit/ATNAEventActuator.java new file mode 100644 index 0000000..2e69f7a --- /dev/null +++ b/src/main/java/org/openehealth/app/xdstofhir/registry/audit/ATNAEventActuator.java @@ -0,0 +1,23 @@ +package org.openehealth.app.xdstofhir.registry.audit; + +import java.util.stream.Collectors; + +import lombok.RequiredArgsConstructor; +import org.springframework.boot.actuate.endpoint.annotation.Endpoint; +import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.stereotype.Component; + +@Component +@Endpoint(id="atna") +@RequiredArgsConstructor +@ConditionalOnBean(RecentATNAEvents.class) +public class ATNAEventActuator { + private final RecentATNAEvents atnaEvents; + + @ReadOperation(produces = "text/plain") + public String getReleaseNotes() { + return atnaEvents.getMessages().reversed().stream() + .collect(Collectors.joining(System.lineSeparator())); + } +} diff --git a/src/main/java/org/openehealth/app/xdstofhir/registry/audit/RecentATNAEvents.java b/src/main/java/org/openehealth/app/xdstofhir/registry/audit/RecentATNAEvents.java new file mode 100644 index 0000000..6feea85 --- /dev/null +++ b/src/main/java/org/openehealth/app/xdstofhir/registry/audit/RecentATNAEvents.java @@ -0,0 +1,43 @@ +package org.openehealth.app.xdstofhir.registry.audit; + +import java.util.ArrayList; +import java.util.List; + +import lombok.Getter; +import org.openehealth.ipf.commons.audit.AuditContext; +import org.openehealth.ipf.commons.audit.AuditMetadataProvider; +import org.openehealth.ipf.commons.audit.protocol.AuditTransmissionProtocol; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.stereotype.Component; + +@Component +@ConditionalOnProperty(value = "ipf.atna.mock.enabled", havingValue = "true") +public class RecentATNAEvents implements AuditTransmissionProtocol { + @Getter + private final List messages = new ArrayList<>(); + + @Value("${ipf.atna.mock.recent:20}") + private int recentAuditValues; + + @Override + public void send(AuditContext auditContext, AuditMetadataProvider auditMetadataProvider, String auditMessage) { + if (auditMessage != null) { + messages.add(auditMessage); + } + if (messages.size()>recentAuditValues) + messages.removeFirst(); + } + + @Override + public void shutdown() { + // no-op + } + + @Override + public String getTransportName() { + return "recentEventsMock"; + } + + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 4226ae6..ee9cfe1 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -26,6 +26,13 @@ xds.endpoint.iti8=xds-iti8:0.0.0.0:2575 fhir.server.profile.bootstrap=false +ipf.atna.auditEnabled=true + +# Capture recent N atna messages and expose on /actuator/atna +# Disable mock to configure IPF's UDP or TLS ATNA sender +ipf.atna.mock.enabled=true +ipf.atna.mock.recent=20 + server.port=8081 -management.endpoints.web.exposure.include=health,info,configprops \ No newline at end of file +management.endpoints.web.exposure.include=health,info,configprops,atna \ No newline at end of file diff --git a/src/main/resources/public/index.html b/src/main/resources/public/index.html index 9594631..1954af9 100644 --- a/src/main/resources/public/index.html +++ b/src/main/resources/public/index.html @@ -41,5 +41,6 @@

IHE XDS.b to FHIR adapter

SOAP Service List
Github Project Page + Service Actuator's \ No newline at end of file