Search in sources :

Example 1 with IdmLoggingEventExceptionDto

use of eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventExceptionDto in project CzechIdMng by bcvsolutions.

the class IdmDbAppender method saveStacktraceLine.

/**
 * Saves one line of stack trace related to the given event.
 *
 * @param traceLine One line of stacktrace
 * @param baseIndex line number of stacktrace
 * @param eventId {@link Long} autogenerated id of related event
 */
private void saveStacktraceLine(String traceLine, long baseIndex, long eventId) {
    IdmLoggingEventExceptionDto dto = new IdmLoggingEventExceptionDto();
    dto.setEvent(eventId);
    dto.setTraceLine(traceLine);
    dto.setId(baseIndex);
    final IdmLoggingEventExceptionDto save = loggingEventExceptionService.save(dto);
}
Also used : IdmLoggingEventExceptionDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventExceptionDto)

Example 2 with IdmLoggingEventExceptionDto

use of eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventExceptionDto in project CzechIdMng by bcvsolutions.

the class IdmDbAppenderTest method append.

@Test
public void append() {
    final IdmDbAppender appender = new IdmDbAppender(loggingEventService, eventExceptionService, propertyService);
    LoggerContext context = new LoggerContext();
    final Logger logger = context.getLogger(IdmDbAppenderTest.class);
    final RuntimeException runtimeException = new RuntimeException();
    runtimeException.setStackTrace(new StackTraceElement[] { new StackTraceElement(IdmDbAppenderTest.class.getCanonicalName(), "test", "file", 0) });
    ILoggingEvent loggingEvent = new LoggingEvent(IdmDbAppenderTest.class.getCanonicalName(), logger, Level.ERROR, "TEST", runtimeException, new String[] {});
    appender.append(loggingEvent);
    IdmLoggingEventFilter eventFilter = new IdmLoggingEventFilter();
    eventFilter.setLoggerName(IdmDbAppenderTest.class.getCanonicalName());
    final List<IdmLoggingEventDto> foundEvents = loggingEventService.find(eventFilter, null).getContent();
    Assert.assertEquals(1, foundEvents.size());
    final IdmLoggingEventDto loggingEventDto = foundEvents.get(0);
    Assert.assertEquals("TEST", loggingEventDto.getFormattedMessage());
    Assert.assertEquals(IdmDbAppenderTest.class.getCanonicalName(), loggingEventDto.getLoggerName());
    Assert.assertEquals("ERROR", loggingEventDto.getLevelString().name());
    IdmLoggingEventExceptionFilter loggingEventExceptionFilter = new IdmLoggingEventExceptionFilter();
    loggingEventExceptionFilter.setEvent((Long) loggingEventDto.getId());
    // 
    final List<IdmLoggingEventExceptionDto> exceptions = eventExceptionService.find(loggingEventExceptionFilter, null).getContent();
    Assert.assertEquals(2, exceptions.size());
    IdmLoggingEventExceptionDto exceptionDto = exceptions.stream().filter(e -> ((long) e.getId()) == 1l).findFirst().get();
    Assert.assertTrue(exceptionDto.getTraceLine().contains("test"));
    Assert.assertTrue(exceptionDto.getTraceLine().contains("file"));
    Assert.assertTrue(exceptionDto.getTraceLine().contains("0"));
}
Also used : IdmLoggingEventExceptionDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventExceptionDto) IdmLoggingEventFilter(eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmLoggingEventFilter) IdmLoggingEventExceptionFilter(eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmLoggingEventExceptionFilter) Logger(ch.qos.logback.classic.Logger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) LoggerContext(ch.qos.logback.classic.LoggerContext) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) LoggingEvent(ch.qos.logback.classic.spi.LoggingEvent) IdmLoggingEventDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 3 with IdmLoggingEventExceptionDto

use of eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventExceptionDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmLoggingEventExceptionService method getEntity.

@Override
protected IdmLoggingEventException getEntity(Serializable id, BasePermission... permission) {
    Assert.notNull(id, "Identifier is required to load a log event.");
    IdmLoggingEventExceptionFilter filter = new IdmLoggingEventExceptionFilter();
    filter.setId(Long.valueOf(id.toString()));
    List<IdmLoggingEventExceptionDto> entities = this.find(filter, null, permission).getContent();
    if (entities.isEmpty()) {
        return null;
    }
    // for given id must found only one entity
    IdmLoggingEventException entity = this.toEntity(entities.get(0));
    return checkAccess(entity, permission);
}
Also used : IdmLoggingEventExceptionDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventExceptionDto) IdmLoggingEventException(eu.bcvsolutions.idm.core.audit.entity.IdmLoggingEventException) IdmLoggingEventExceptionFilter(eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmLoggingEventExceptionFilter)

Example 4 with IdmLoggingEventExceptionDto

use of eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventExceptionDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmLoggingEventExceptionService method toDto.

@Override
protected IdmLoggingEventExceptionDto toDto(IdmLoggingEventException entity, IdmLoggingEventExceptionDto dto) {
    if (entity == null) {
        return null;
    }
    if (dto == null) {
        dto = new IdmLoggingEventExceptionDto();
    }
    dto.setTraceLine(entity.getTraceLine());
    dto.setId(entity.getId());
    dto.setEvent((Long) entity.getEvent().getId());
    return dto;
}
Also used : IdmLoggingEventExceptionDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventExceptionDto)

Aggregations

IdmLoggingEventExceptionDto (eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventExceptionDto)4 IdmLoggingEventExceptionFilter (eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmLoggingEventExceptionFilter)2 Logger (ch.qos.logback.classic.Logger)1 LoggerContext (ch.qos.logback.classic.LoggerContext)1 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 LoggingEvent (ch.qos.logback.classic.spi.LoggingEvent)1 IdmLoggingEventDto (eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventDto)1 IdmLoggingEventFilter (eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmLoggingEventFilter)1 IdmLoggingEventException (eu.bcvsolutions.idm.core.audit.entity.IdmLoggingEventException)1 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)1 Test (org.junit.Test)1