use of eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel in project CzechIdMng by bcvsolutions.
the class IdmNotificationConfigurationDisabledTest method testDisabledError.
@Test
@Transactional
public void testDisabledError() {
assertEquals(0, idmNotificationRepository.count());
NotificationLevel level = NotificationLevel.ERROR;
IdmNotificationTemplateDto template = createTestTemplate("Idm test notification", "disabled test");
IdmIdentityDto identity = getHelper().createIdentity("Test_disable_notifications" + System.currentTimeMillis());
configs.add(createNotificationConfiguration(TOPIC, level, IdmConsoleLog.NOTIFICATION_TYPE, template.getId(), true));
configs.add(createNotificationConfiguration(TOPIC, level, IdmEmailLog.NOTIFICATION_TYPE, template.getId(), true));
IdmMessageDto message = new IdmMessageDto();
message.setTemplate(template);
message.setLevel(level);
notificationManager.send(TOPIC, message, identity);
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setNotificationType(IdmNotificationLog.class);
assertEquals(0, notificationLogService.find(filter, null).getTotalElements());
deleteNotificationConfig();
}
use of eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel in project CzechIdMng by bcvsolutions.
the class IdmNotificationConfigurationDisabledTest method testOneDisabled.
@Test
@Transactional
public void testOneDisabled() {
assertEquals(0, idmNotificationRepository.count());
NotificationLevel level = NotificationLevel.ERROR;
IdmNotificationTemplateDto template = createTestTemplate("Idm test notification", "disabled test");
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
configs.add(createNotificationConfiguration(TOPIC, null, IdmConsoleLog.NOTIFICATION_TYPE, template.getId(), true));
configs.add(createNotificationConfiguration(TOPIC, null, IdmEmailLog.NOTIFICATION_TYPE, template.getId(), false));
IdmMessageDto message = new IdmMessageDto();
message.setTemplate(template);
message.setLevel(level);
notificationManager.send(TOPIC, message, identity);
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setNotificationType(IdmNotificationLog.class);
assertEquals(1, notificationLogService.find(filter, null).getTotalElements());
deleteNotificationConfig();
}
use of eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel in project CzechIdMng by bcvsolutions.
the class ExceptionUtils method log.
/**
* Logs exception with level defined by given result model.
*
* @param logger
* @param resultModel
* @param ex
* @since 9.6.0
*/
public static void log(Logger logger, ResultModel resultModel, Throwable ex) {
Assert.notNull(logger, "Logger is required.");
// model not given - log exception only, if given
if (resultModel == null) {
if (ex != null) {
logger.error("", ex);
}
return;
}
NotificationLevel level = resultModel.getLevel();
if (level != null) {
// override http status code
switch(level) {
case SUCCESS:
{
logger.debug(resultModel.toString(), ex);
break;
}
case INFO:
{
logger.info(resultModel.toString(), ex);
break;
}
case WARNING:
{
logger.warn(resultModel.toString(), ex);
break;
}
default:
{
// error by default
logger.error(resultModel.toString(), ex);
}
}
} else if (resultModel.getStatus().is5xxServerError()) {
logger.error(resultModel.toString(), ex);
} else if (resultModel.getStatus().is2xxSuccessful()) {
logger.debug(resultModel.toString(), ex);
} else {
logger.warn(resultModel.toString(), ex);
}
}
use of eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel in project CzechIdMng by bcvsolutions.
the class DefaultBulkActionManager method toDto.
/**
* Map action to dto.
*
* @param action
* @return
*/
@Override
public IdmBulkActionDto toDto(AbstractBulkAction<? extends BaseDto, ? extends BaseFilter> action) {
IdmBulkActionDto actionDto = new IdmBulkActionDto();
actionDto.setId(action.getId());
if (action.getService() != null && action.getService().getEntityClass() != null) {
actionDto.setEntityClass(action.getService().getEntityClass().getCanonicalName());
} else {
Class<? extends BaseEntity> entityClass = action.getEntityClass();
if (entityClass != null) {
actionDto.setEntityClass(entityClass.getCanonicalName());
}
}
if (action.getDtoClass() != null) {
actionDto.setDtoClass(action.getDtoClass().getName());
}
if (action.getService() != null && action.getService().getFilterClass() != null) {
actionDto.setFilterClass(action.getService().getFilterClass().getName());
}
actionDto.setModule(action.getModule());
actionDto.setName(action.getName());
actionDto.setDescription(action.getDescription());
actionDto.setFormAttributes(action.getFormAttributes());
actionDto.setAuthorities(action.getAuthorities());
actionDto.setShowWithoutSelection(action.showWithoutSelection());
actionDto.setShowWithSelection(action.showWithSelection());
actionDto.setDisabled(action.isDisabled());
ConfigurationMap configurationMap = action.getConfigurationMap();
//
// set configurable properties
actionDto.setIcon(parameterConverter.toString(configurationMap, ConfigurationService.PROPERTY_ICON));
// FIXME: add ParameterConverter#toInteger method instead.
actionDto.setOrder((int) parameterConverter.toLong(configurationMap, ConfigurationService.PROPERTY_ORDER, action.getOrder()));
actionDto.setDeleteAction(parameterConverter.toBoolean(configurationMap, IdmBulkAction.PROPERTY_DELETE_ACTION, action.isDeleteAction()));
actionDto.setQuickButton(parameterConverter.toBoolean(configurationMap, IdmBulkAction.PROPERTY_QUICK_BUTTON, action.isQuickButton()));
actionDto.setQuickButtonable(parameterConverter.toBoolean(configurationMap, IdmBulkAction.PROPERTY_QUICK_BUTTONABLE, action.isQuickButtonable()));
actionDto.setSupportsPreprocessing(parameterConverter.toBoolean(configurationMap, IdmBulkAction.PROPERTY_SUPPORTS_PREPROCESSING, action.isSupportsPreprocessing()));
actionDto.setLevel(action.getLevel());
try {
NotificationLevel level = parameterConverter.toEnum(configurationMap, ConfigurationService.PROPERTY_LEVEL, NotificationLevel.class);
if (level != null) {
actionDto.setLevel(level);
}
} catch (ResultCodeException ex) {
LOG.warn("Configuration property [{}] is wrongly configured, given [{}]. Default action level [{}] will be used.", action.getConfigurationPropertyName(ConfigurationService.PROPERTY_LEVEL), configurationMap.get(ConfigurationService.PROPERTY_LEVEL), action.getLevel());
}
//
return actionDto;
}
use of eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel in project CzechIdMng by bcvsolutions.
the class DefaultIdmMonitoringResultService method toPredicates.
@Override
protected List<Predicate> toPredicates(Root<IdmMonitoringResult> root, CriteriaQuery<?> query, CriteriaBuilder builder, IdmMonitoringResultFilter filter) {
List<Predicate> predicates = super.toPredicates(root, query, builder, filter);
//
// "fulltext"
String text = filter.getText();
if (StringUtils.isNotEmpty(text)) {
text = text.toLowerCase();
predicates.add(builder.or(builder.like(builder.lower(root.get(IdmMonitoringResult_.monitoring).get(IdmMonitoring_.code)), "%" + text + "%"), builder.like(builder.lower(root.get(IdmMonitoringResult_.monitoring).get(IdmMonitoring_.evaluatorType)), "%" + text + "%"), builder.like(builder.lower(root.get(IdmMonitoringResult_.monitoring).get(IdmMonitoring_.description)), "%" + text + "%")));
}
//
UUID monitoring = filter.getMonitoring();
if (monitoring != null) {
predicates.add(builder.equal(root.get(IdmMonitoringResult_.monitoring).get(IdmMonitoring_.id), monitoring));
}
List<NotificationLevel> levels = filter.getLevels();
if (CollectionUtils.isNotEmpty(levels)) {
predicates.add(root.get(IdmMonitoringResult_.level).in(levels));
}
//
if (filter.isLastResult()) {
predicates.add(builder.isTrue(root.get(IdmMonitoringResult_.lastResult)));
}
//
return predicates;
}
Aggregations