AuditorAwareImpl.java

  1. package no.nav.data.common.auditing;

  2. import no.nav.data.common.utils.MdcUtils;
  3. import org.springframework.data.domain.AuditorAware;

  4. import java.util.Optional;

  5. public class AuditorAwareImpl implements AuditorAware<String> {

  6.     @Override
  7.     public Optional<String> getCurrentAuditor() {
  8.         return Optional.ofNullable(MdcUtils.getUser()).or(() -> Optional.of("no-user-set"));
  9.     }

  10. }