use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto in project CzechIdMng by bcvsolutions.
the class IdmMonitoringResultController method getDto.
@Override
public IdmMonitoringResultDto getDto(Serializable backendId) {
IdmMonitoringResultDto dto = super.getDto(backendId);
if (dto == null) {
return null;
}
//
UUID ownerId = dto.getOwnerId();
String ownerType = dto.getOwnerType();
if (ownerId != null && StringUtils.isNotEmpty(ownerType)) {
try {
dto.getEmbedded().put(AttachableEntity.PARAMETER_OWNER_ID, getLookupService().lookupDto(ownerType, ownerId));
} catch (IllegalArgumentException ex) {
LOG.debug("Class [{}] not found on classpath (e.g. module was uninstalled)", ownerType, ex);
}
}
//
return dto;
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto in project CzechIdMng by bcvsolutions.
the class DatabaseTableMonitoringEvaluator method evaluate.
@Override
public IdmMonitoringResultDto evaluate(IdmMonitoringDto monitoring) {
String serviceName = getParameterConverter().toString(monitoring.getEvaluatorProperties(), PARAMETER_READ_SERVICE_BEAN_NAME);
Object bean;
try {
bean = context.getBean(serviceName);
if (bean == null || !(bean instanceof ReadDtoService<?, ?>)) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", serviceName));
}
} catch (BeansException ex) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", serviceName), ex);
}
//
ReadDtoService<?, ?> readService = (ReadDtoService<?, ?>) bean;
long treshold = getParameterConverter().toLong(monitoring.getEvaluatorProperties(), PARAMETER_THRESHOLD, DEFAULT_THRESHOLD);
long count = readService.count(null);
ResultModel resultModel = new DefaultResultModel(CoreResultCode.MONITORING_DATABASE_TABLE, ImmutableMap.of("tableName", String.valueOf(getTableName(readService)), "dtoName", String.valueOf(getDtoName(readService)), "count", Long.toString(count)));
IdmMonitoringResultDto result = new IdmMonitoringResultDto();
result.setValue(Long.toString(count));
result.setResult(new OperationResultDto.Builder(OperationState.EXECUTED).setModel(resultModel).build());
if (treshold < count) {
result.setLevel(NotificationLevel.WARNING);
}
//
return result;
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto in project CzechIdMng by bcvsolutions.
the class DemoAdminMonitoringEvaluator method evaluate.
@Override
public IdmMonitoringResultDto evaluate(IdmMonitoringDto monitoring) {
IdmMonitoringResultDto result = new IdmMonitoringResultDto();
ResultModel resultModel;
//
IdmIdentityDto adminIdentity = getLookupService().lookupDto(IdmIdentityDto.class, InitAdminIdentityProcessor.ADMIN_USERNAME);
if (adminIdentity == null) {
resultModel = new DefaultResultModel(CoreResultCode.MONITORING_DEMO_ADMIN_NOT_FOUND);
} else {
result.setOwnerId(getLookupService().getOwnerId(adminIdentity));
result.setOwnerType(getLookupService().getOwnerType(adminIdentity));
//
LoginDto loginDto = new LoginDto();
loginDto.setUsername(adminIdentity.getUsername());
loginDto.setPassword(new GuardedString(InitAdminIdentityProcessor.ADMIN_PASSWORD));
//
if (authenticationManager.validate(loginDto)) {
resultModel = new DefaultResultModel(CoreResultCode.MONITORING_DEMO_ADMIN_WARNING);
//
if (!applicationConfiguration.isDevelopment()) {
result.setLevel(NotificationLevel.ERROR);
}
} else {
resultModel = new DefaultResultModel(CoreResultCode.OK);
}
}
//
result.setResult(new OperationResultDto.Builder(OperationState.EXECUTED).setModel(resultModel).build());
//
return result;
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto in project CzechIdMng by bcvsolutions.
the class EntityEventMonitoringEvaluator method evaluate.
@Override
public IdmMonitoringResultDto evaluate(IdmMonitoringDto monitoring) {
IdmMonitoringResultDto result = new IdmMonitoringResultDto();
ResultModel resultModel;
//
IdmEntityEventFilter filter = new IdmEntityEventFilter();
filter.setStates(Lists.newArrayList(OperationState.EXCEPTION));
filter.setMonitoringIgnored(Boolean.FALSE);
Long givenNumberOfDays = getParameterConverter().toLong(monitoring.getEvaluatorProperties(), PARAMETER_NUMBER_OF_DAYS);
if (givenNumberOfDays != null) {
filter.setCreatedFrom(ZonedDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(givenNumberOfDays));
}
long count = entityEventService.count(filter);
//
if (count > 0) {
resultModel = new DefaultResultModel(CoreResultCode.MONITORING_ENTITY_EVENT_ERROR, ImmutableMap.of("count", Long.toString(count)));
} else {
resultModel = new DefaultResultModel(CoreResultCode.OK);
}
//
result.setResult(new OperationResultDto.Builder(OperationState.EXECUTED).setModel(resultModel).build());
result.setValue(String.valueOf(count));
//
return result;
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto in project CzechIdMng by bcvsolutions.
the class LoggingEventMonitoringEvaluator method evaluate.
@Override
public IdmMonitoringResultDto evaluate(IdmMonitoringDto monitoring) {
IdmMonitoringResultDto result = new IdmMonitoringResultDto();
ResultModel resultModel;
//
IdmLoggingEventFilter filter = new IdmLoggingEventFilter();
filter.setLevelString(LogType.ERROR);
Long givenNumberOfDays = getParameterConverter().toLong(monitoring.getEvaluatorProperties(), PARAMETER_NUMBER_OF_DAYS);
if (givenNumberOfDays != null) {
filter.setFrom(ZonedDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(givenNumberOfDays));
}
long count = loggingEventService.count(filter);
//
if (count > 0) {
resultModel = new DefaultResultModel(CoreResultCode.MONITORING_LOGGING_EVENT_ERROR, ImmutableMap.of("count", Long.toString(count)));
} else {
resultModel = new DefaultResultModel(CoreResultCode.OK);
}
//
result.setResult(new OperationResultDto.Builder(OperationState.EXECUTED).setModel(resultModel).build());
result.setValue(String.valueOf(count));
//
return result;
}
Aggregations