當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。