Search in sources :

Example 11 with NotificationLevel

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();
}
Also used : IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) NotificationLevel(eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with NotificationLevel

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();
}
Also used : IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) NotificationLevel(eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with NotificationLevel

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);
    }
}
Also used : NotificationLevel(eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel)

Example 14 with NotificationLevel

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;
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) NotificationLevel(eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel) ConfigurationMap(eu.bcvsolutions.idm.core.api.domain.ConfigurationMap)

Example 15 with NotificationLevel

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;
}
Also used : NotificationLevel(eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel) UUID(java.util.UUID) Predicate(javax.persistence.criteria.Predicate)

Aggregations

NotificationLevel (eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel)16 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)10 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)10 Test (org.junit.Test)10 IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)9 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)9 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)9 Transactional (org.springframework.transaction.annotation.Transactional)9 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 JsonParser (com.fasterxml.jackson.core.JsonParser)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 Lists (com.google.common.collect.Lists)1 IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)1 ConfigurationMap (eu.bcvsolutions.idm.core.api.domain.ConfigurationMap)1 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1 BaseDtoController (eu.bcvsolutions.idm.core.api.rest.BaseDtoController)1 IdmIdentityService (eu.bcvsolutions.idm.core.api.service.IdmIdentityService)1 InitTestDataProcessor (eu.bcvsolutions.idm.core.model.event.processor.module.InitTestDataProcessor)1