本文整理匯總了Java中org.springframework.boot.actuate.audit.AuditEventRepository類的典型用法代碼示例。如果您正苦於以下問題:Java AuditEventRepository類的具體用法?Java AuditEventRepository怎麽用?Java AuditEventRepository使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AuditEventRepository類屬於org.springframework.boot.actuate.audit包,在下文中一共展示了AuditEventRepository類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: auditEventRepository
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
@Bean
public AuditEventRepository auditEventRepository() {
return new AuditEventRepository() {
@Inject
private AuditEventConverter auditEventConverter;
@Override
public List<AuditEvent> find(String principal, Date after) {
Iterable<PersistentAuditEvent> persistentAuditEvents;
if (principal == null && after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findAll();
} else if (after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findByPrincipal(principal);
} else {
persistentAuditEvents =
persistenceAuditEventRepository.findByPrincipalAndAuditEventDateAfter(principal, new LocalDateTime(after));
}
return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
}
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void add(AuditEvent event) {
PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
persistentAuditEvent.setPrincipal(event.getPrincipal());
persistentAuditEvent.setAuditEventType(event.getType());
persistentAuditEvent.setAuditEventDate(new LocalDateTime(event.getTimestamp()));
persistentAuditEvent.setData(auditEventConverter.convertDataToStrings(event.getData()));
persistenceAuditEventRepository.save(persistentAuditEvent);
}
};
}
示例2: testStoredEvents
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
@Test
public void testStoredEvents() {
AuditEventRepository repository = mock(AuditEventRepository.class);
AuditEvent event = new AuditEvent("principal", "type",
Collections.<String, Object>emptyMap());
AuditListener listener = new AuditListener(repository);
listener.onApplicationEvent(new AuditApplicationEvent(event));
verify(repository).add(event);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:10,代碼來源:AuditListenerTests.java
示例3: defaultConfiguration
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
@Test
public void defaultConfiguration() throws Exception {
registerAndRefresh(AuditAutoConfiguration.class);
assertThat(this.context.getBean(AuditEventRepository.class)).isNotNull();
assertThat(this.context.getBean(AuthenticationAuditListener.class)).isNotNull();
assertThat(this.context.getBean(AuthorizationAuditListener.class)).isNotNull();
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:8,代碼來源:AuditAutoConfigurationTests.java
示例4: ownAuditEventRepository
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
@Test
public void ownAuditEventRepository() throws Exception {
registerAndRefresh(CustomAuditEventRepositoryConfiguration.class,
AuditAutoConfiguration.class);
assertThat(this.context.getBean(AuditEventRepository.class))
.isInstanceOf(TestAuditEventRepository.class);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:8,代碼來源:AuditAutoConfigurationTests.java
示例5: auditEventRepository
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
@Bean
public AuditEventRepository auditEventRepository() {
return new AuditEventRepository() {
@Inject
private AuditEventConverter auditEventConverter;
@Override
public List<AuditEvent> find(String principal, Date after) {
Iterable<PersistentAuditEvent> persistentAuditEvents;
if (principal == null && after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findAll();
} else if (after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findByPrincipal(principal);
} else {
persistentAuditEvents =
persistenceAuditEventRepository.findByPrincipalAndAuditEventDateAfter(principal,DateToLocalDateTimeConverter.INSTANCE.convert(after));
}
return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
}
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void add(AuditEvent event) {
PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
persistentAuditEvent.setPrincipal(event.getPrincipal());
persistentAuditEvent.setAuditEventType(event.getType());
persistentAuditEvent.setAuditEventDate(JSR310DateConverters.DateToLocalDateTimeConverter.INSTANCE.convert(event.getTimestamp()) );
persistentAuditEvent.setData(auditEventConverter.convertDataToStrings(event.getData()));
persistenceAuditEventRepository.save(persistentAuditEvent);
}
};
}
示例6: testTraceConfiguration
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
@Test
public void testTraceConfiguration() throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(AuditAutoConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(AuditEventRepository.class));
assertNotNull(this.context.getBean(AuthenticationAuditListener.class));
assertNotNull(this.context.getBean(AuthorizationAuditListener.class));
}
示例7: ownAutoRepository
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
@Test
public void ownAutoRepository() throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(Config.class, AuditAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(AuditEventRepository.class),
instanceOf(TestAuditEventRepository.class));
}
示例8: auditEventRepository
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
@Bean
public AuditEventRepository auditEventRepository() {
return new AuditEventRepository() {
@Inject
private AuditEventConverter auditEventConverter;
@Override
public List<AuditEvent> find(String principal, Date after) {
final Iterable<PersistentAuditEvent> persistentAuditEvents;
if (principal == null && after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findAll();
} else if (after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findByPrincipal(principal);
} else {
persistentAuditEvents =
persistenceAuditEventRepository.findByPrincipalAndAuditEventDateGreaterThan(principal, new LocalDateTime(after));
}
return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
}
@Override
public void add(AuditEvent event) {
PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
persistentAuditEvent.setPrincipal(event.getPrincipal());
persistentAuditEvent.setAuditEventType(event.getType());
persistentAuditEvent.setAuditEventDate(new LocalDateTime(event.getTimestamp()));
persistentAuditEvent.setData(auditEventConverter.convertDataToStrings(event.getData()));
persistenceAuditEventRepository.save(persistentAuditEvent);
}
};
}
示例9: auditEventRepository
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
@Bean
public AuditEventRepository auditEventRepository() {
return new AuditEventRepository() {
@Inject
private AuditEventConverter auditEventConverter;
@Override
public List<AuditEvent> find(String principal, Date after) {
Iterable<PersistentAuditEvent> persistentAuditEvents;
if (principal == null && after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findAll();
} else if (after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findByPrincipal(principal);
} else {
persistentAuditEvents =
persistenceAuditEventRepository.findByPrincipalAndAuditEventDateAfter(principal, new LocalDateTime(after));
}
return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
}
@Override
public void add(AuditEvent event) {
PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
persistentAuditEvent.setPrincipal(event.getPrincipal());
persistentAuditEvent.setAuditEventType(event.getType());
persistentAuditEvent.setAuditEventDate(new LocalDateTime(event.getTimestamp()));
persistentAuditEvent.setData(auditEventConverter.convertDataToStrings(event.getData()));
persistenceAuditEventRepository.save(persistentAuditEvent);
}
};
}
示例10: auditEventRepository
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
@Bean
public AuditEventRepository auditEventRepository() {
return new AuditEventRepository() {
@Inject
private AuditEventConverter auditEventConverter;
@Override
public List<AuditEvent> find(String principal, Date after) {
final Iterable<PersistentAuditEvent> persistentAuditEvents;
if (principal == null && after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findAll();
} else if (after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findByPrincipal(principal);
} else {
persistentAuditEvents =
persistenceAuditEventRepository.findByPrincipalAndAuditEventDateGreaterThan(principal, new LocalDateTime(after));
}
return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
}
@Override
public void add(AuditEvent event) {
PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
persistentAuditEvent.setPrincipal(event.getPrincipal());
persistentAuditEvent.setAuditEventType(event.getType());
persistentAuditEvent.setAuditEventDate(new LocalDateTime(event.getTimestamp()));
persistentAuditEvent.setData(auditEventConverter.convertDataToStrings(event.getData()));
persistenceAuditEventRepository.save(persistentAuditEvent);
}
};
}
示例11: auditEventRepository
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
@Bean
public AuditEventRepository auditEventRepository() {
return new AuditEventRepository() {
@Inject
private AuditEventConverter auditEventConverter;
@Override
public List<AuditEvent> find(String principal, Date after) {
final List<PersistentAuditEvent> persistentAuditEvents;
if (principal == null && after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findAll();
} else if (after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findByPrincipal(principal);
} else {
persistentAuditEvents =
persistenceAuditEventRepository.findByPrincipalAndAuditEventDateGreaterThan(principal, new LocalDateTime(after));
}
return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
}
@Override
public void add(AuditEvent event) {
PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
persistentAuditEvent.setPrincipal(event.getPrincipal());
persistentAuditEvent.setAuditEventType(event.getType());
persistentAuditEvent.setAuditEventDate(new LocalDateTime(event.getTimestamp()));
persistentAuditEvent.setData(auditEventConverter.convertDataToStrings(event.getData()));
persistenceAuditEventRepository.save(persistentAuditEvent);
}
};
}
示例12: auditEventRepository
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
@Bean
public AuditEventRepository auditEventRepository() {
return new AuditEventRepository() {
private static final String AUTHORIZATION_FAILURE = "AUTHORIZATION_FAILURE";
private static final String ANONYMOUS_USER = "anonymousUser";
@Inject
private AuditEventConverter auditEventConverter;
@Override
public List<AuditEvent> find(String principal, Date after) {
Iterable<PersistentAuditEvent> persistentAuditEvents;
if (principal == null && after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findAll();
} else if (after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findByPrincipal(principal);
} else {
persistentAuditEvents =
persistenceAuditEventRepository.findByPrincipalAndAuditEventDateAfter(principal, LocalDateTime.from(after.toInstant()));
}
return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
}
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void add(AuditEvent event) {
if (!AUTHORIZATION_FAILURE.equals(event.getType()) &&
!ANONYMOUS_USER.equals(event.getPrincipal().toString())) {
PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
persistentAuditEvent.setPrincipal(event.getPrincipal());
persistentAuditEvent.setAuditEventType(event.getType());
Instant instant = Instant.ofEpochMilli(event.getTimestamp().getTime());
persistentAuditEvent.setAuditEventDate(LocalDateTime.ofInstant(instant, ZoneId.systemDefault()));
persistentAuditEvent.setData(auditEventConverter.convertDataToStrings(event.getData()));
persistenceAuditEventRepository.save(persistentAuditEvent);
}
}
};
}
示例13: AuditListener
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
public AuditListener(AuditEventRepository auditEventRepository) {
this.auditEventRepository = auditEventRepository;
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:4,代碼來源:AuditListener.java
示例14: AuditAutoConfiguration
import org.springframework.boot.actuate.audit.AuditEventRepository; //導入依賴的package包/類
public AuditAutoConfiguration(
ObjectProvider<AuditEventRepository> auditEventRepositoryProvider) {
this.auditEventRepository = auditEventRepositoryProvider.getIfAvailable();
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:5,代碼來源:AuditAutoConfiguration.java