当前位置: 首页>>代码示例>>Java>>正文


Java AuditEventRepository类代码示例

本文整理汇总了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);
        }
    };
}
 
开发者ID:VHAINNOVATIONS,项目名称:BCDS,代码行数:35,代码来源:CustomAuditEventRepository.java

示例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);
        }
    };
}
 
开发者ID:TransparencyInternationalEU,项目名称:lobbycal,代码行数:35,代码来源:CustomAuditEventRepository.java

示例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));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:10,代码来源:AuditAutoConfigurationTests.java

示例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));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:9,代码来源:AuditAutoConfigurationTests.java

示例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);
        }
    };
}
 
开发者ID:sanketbajoria,项目名称:jittrackGTS,代码行数:35,代码来源:CustomAuditEventRepository.java

示例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);
        }
    };
}
 
开发者ID:miagebdx,项目名称:website,代码行数:34,代码来源:CustomAuditEventRepository.java

示例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);
        }
    };
}
 
开发者ID:alv-ch,项目名称:alv-ch-sysinfos.api,代码行数:33,代码来源:CustomAuditEventRepository.java

示例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);
        }
    };
}
 
开发者ID:exteso,项目名称:parkingfriends,代码行数:35,代码来源:CustomAuditEventRepository.java

示例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);
            }
        }
    };
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:43,代码来源:CustomAuditEventRepository.java

示例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


注:本文中的org.springframework.boot.actuate.audit.AuditEventRepository类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。