use of eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmLoggingEventService method getEntity.
@Override
protected IdmLoggingEvent getEntity(Serializable id, BasePermission... permission) {
Assert.notNull(id);
IdmLoggingEventFilter filter = new IdmLoggingEventFilter();
filter.setId(Long.valueOf(id.toString()));
List<IdmLoggingEventDto> entities = this.find(filter, null, permission).getContent();
if (entities.isEmpty()) {
return null;
}
// for given id must found only one entity
IdmLoggingEvent entity = this.toEntity(entities.get(0));
return checkAccess(entity, permission);
}
use of eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventDto in project CzechIdMng by bcvsolutions.
the class RemoveOldLogsTaskExecutor method process.
@Override
public Boolean process() {
if (days == null) {
LOG.warn("Parameter {} is not filled. This task will be skipped.", PARAMETER_DAYS);
return Boolean.TRUE;
}
//
IdmLoggingEventFilter filter = new IdmLoggingEventFilter();
filter.setTill(DateTime.now().minusDays(days.intValue()));
Page<IdmLoggingEventDto> loggingEvents = loggingEventService.find(filter, new PageRequest(0, 100, new Sort(IdmLoggingEvent_.timestmp.getName())));
//
Long exceptionCounter = 0l;
boolean canContinue = true;
this.count = loggingEvents.getTotalElements();
this.setCounter(0l);
//
while (canContinue) {
for (IdmLoggingEventDto event : loggingEvents) {
Long eventId = Long.valueOf(event.getId().toString());
//
LOG.debug("Event id: [{}] will be removed", event.getId());
loggingEventExceptionService.deleteByEventId(eventId);
loggingEventPropertyService.deleteAllByEventId(eventId);
loggingEventService.deleteAllById(eventId);
this.increaseCounter();
//
canContinue = updateState();
if (!canContinue) {
break;
}
}
//
loggingEvents = loggingEventService.find(filter, new PageRequest(0, 100, new Sort(IdmLoggingEvent_.timestmp.getName())));
//
if (loggingEvents.getContent().isEmpty()) {
break;
}
}
//
LOG.info("Removed logs older than [{}] days was successfully completed. Removed logs: [{}] and their exceptions [{}].", days, this.counter, exceptionCounter);
//
return Boolean.TRUE;
}
Aggregations