package jnpf.limsService.provider;
|
|
import jnpf.audit.sdk.AuditClient;
|
import jnpf.audit.sdk.AuditContextCollector;
|
import jnpf.audit.sdk.AuditEventPublisher;
|
import jnpf.audit.sdk.AuditRequestScopeFilter;
|
import jnpf.audit.sdk.aspect.AuditLogAspect;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Aspect;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.context.ApplicationContext;
|
import org.springframework.core.annotation.Order;
|
import org.springframework.stereotype.Component;
|
|
/** Adds ELN-origin auditing only for the new source module; the existing LIMS scope is unchanged. */
|
@Aspect
|
@Component
|
@Order(49)
|
@org.springframework.boot.autoconfigure.condition.ConditionalOnProperty(
|
name = {"audit.enabled", "audit.layer2-enabled"}, matchIfMissing = true)
|
public class LimsElnSourceAuditAspect {
|
private final AuditRequestScopeFilter scope = new AuditRequestScopeFilter(true, "ELN");
|
private final AuditRequestScopeFilter existingScope;
|
private final AuditLogAspect delegate;
|
|
public LimsElnSourceAuditAspect(AuditContextCollector collector, AuditEventPublisher publisher,
|
ApplicationContext context, AuditRequestScopeFilter existingScope,
|
@Value("${audit.enabled:true}") boolean enabled) {
|
this.existingScope = existingScope;
|
delegate = new AuditLogAspect(new AuditClient(collector, publisher, enabled, scope), publisher, context);
|
}
|
|
@Around("@annotation(jnpf.audit.sdk.annotation.AuditLog) && within(jnpf.limsService.provider..*)")
|
public Object record(ProceedingJoinPoint invocation) throws Throwable {
|
return scope.acceptsCurrentRequest() && !existingScope.acceptsCurrentRequest()
|
? delegate.around(invocation) : invocation.proceed();
|
}
|
}
|