-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/org/openehealth/app/xdstofhir/registry/audit/ATNAEventActuator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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())); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/org/openehealth/app/xdstofhir/registry/audit/RecentATNAEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> 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"; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters