Search in sources :

Example 21 with SysProvisioningBreakConfigDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningBreakConfigService method save.

@Override
public SysProvisioningBreakConfigDto save(SysProvisioningBreakConfigDto dto, BasePermission... permission) {
    // check global configuration
    if (dto.getGlobalConfiguration() != null && dto.getGlobalConfiguration()) {
        throw new ProvisioningException(AccResultCode.PROVISIONING_BREAK_GLOBAL_CONFIG_SAVE, ImmutableMap.of("operationType", dto.getOperationType()));
    }
    // check if for same system doesn't exist same operation type
    SysProvisioningBreakConfigFilter filter = new SysProvisioningBreakConfigFilter();
    filter.setSystemId(dto.getSystem());
    filter.setOperationType(dto.getOperationType());
    List<SysProvisioningBreakConfigDto> similarConfigs = this.find(filter, null).getContent();
    boolean existSimilar = similarConfigs.stream().filter(config -> !config.getId().equals(dto.getId())).findFirst().isPresent();
    if (!existSimilar) {
        return super.save(dto, permission);
    }
    throw new ProvisioningException(AccResultCode.PROVISIONING_BREAK_OPERATION_EXISTS, ImmutableMap.of("operationType", dto.getOperationType(), "systemId", dto.getSystem()));
}
Also used : SysProvisioningBreakConfigDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysProvisioningBreakConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningBreakConfigFilter)

Example 22 with SysProvisioningBreakConfigDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningBreakConfigService method getConfig.

@Override
public SysProvisioningBreakConfigDto getConfig(ProvisioningEventType operationType, UUID systemId) {
    SysProvisioningBreakConfigFilter filter = new SysProvisioningBreakConfigFilter();
    filter.setOperationType(operationType);
    filter.setSystemId(systemId);
    List<SysProvisioningBreakConfigDto> configs = this.find(filter, null).getContent();
    // 
    if (configs.isEmpty()) {
        return null;
    }
    // must exists only one configs for operation type and system id
    return configs.stream().findFirst().get();
}
Also used : SysProvisioningBreakConfigDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto) SysProvisioningBreakConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningBreakConfigFilter)

Example 23 with SysProvisioningBreakConfigDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningBreakConfigService method find.

@Override
public Page<SysProvisioningBreakConfigDto> find(SysProvisioningBreakConfigFilter filter, Pageable pageable, BasePermission... permission) {
    Page<SysProvisioningBreakConfigDto> configs = super.find(filter, pageable, permission);
    // if include global config and set systemId add global configurations
    if (filter != null && filter.isIncludeGlobalConfig() && filter.getSystemId() != null && configs.getTotalElements() != MAX_CONFIGS_FOR_SYSTEM) {
        List<SysProvisioningBreakConfigDto> configsList = addGlobalConfigs(configs.getContent(), filter.getSystemId());
        // 
        if (!configsList.isEmpty()) {
            PageRequest pageRequest = new PageRequest(pageable.getPageNumber(), configsList.size(), pageable.getSort());
            Page<SysProvisioningBreakConfigDto> dtoPage = new PageImpl<>(configsList, pageRequest, configsList.size());
            return dtoPage;
        }
    }
    // 
    return configs;
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) PageRequest(org.springframework.data.domain.PageRequest) SysProvisioningBreakConfigDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto)

Example 24 with SysProvisioningBreakConfigDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningBreakConfigService method addGlobalConfigs.

/**
 * Methods for system and his provisioning break config add global configuration
 *
 * @param configs
 * @param systemId
 * @return
 */
private List<SysProvisioningBreakConfigDto> addGlobalConfigs(List<SysProvisioningBreakConfigDto> configsOld, UUID systemId) {
    boolean containsCreate = configsOld.stream().filter(item -> item.getOperationType() == ProvisioningEventType.CREATE).findFirst().isPresent();
    boolean containsDelete = configsOld.stream().filter(item -> item.getOperationType() == ProvisioningEventType.DELETE).findFirst().isPresent();
    boolean containsUpdate = configsOld.stream().filter(item -> item.getOperationType() == ProvisioningEventType.UPDATE).findFirst().isPresent();
    // unmodifiable list, create copy
    List<SysProvisioningBreakConfigDto> configs = new ArrayList<>(configsOld);
    if (!containsCreate) {
        SysProvisioningBreakConfigDto global = this.getGlobalBreakConfiguration(ProvisioningEventType.CREATE);
        if (global != null) {
            global.setActualOperationCount(getCounter(systemId, ProvisioningEventType.CREATE));
            configs.add(global);
        }
    }
    if (!containsDelete) {
        SysProvisioningBreakConfigDto global = this.getGlobalBreakConfiguration(ProvisioningEventType.DELETE);
        if (global != null) {
            global.setActualOperationCount(getCounter(systemId, ProvisioningEventType.DELETE));
            configs.add(global);
        }
    }
    if (!containsUpdate) {
        SysProvisioningBreakConfigDto global = this.getGlobalBreakConfiguration(ProvisioningEventType.UPDATE);
        if (global != null) {
            global.setActualOperationCount(getCounter(systemId, ProvisioningEventType.UPDATE));
            configs.add(global);
        }
    }
    return configs;
}
Also used : SysProvisioningBreakConfigDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto) ArrayList(java.util.ArrayList)

Aggregations

SysProvisioningBreakConfigDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto)24 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)16 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)15 Test (org.junit.Test)15 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)13 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)10 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)10 SysProvisioningBreakItems (eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakItems)3 SysProvisioningBatchDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto)2 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)2 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)2 SysProvisioningBreakConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningBreakConfigFilter)2 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)2 IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)2 ProvisioningEventType (eu.bcvsolutions.idm.acc.domain.ProvisioningEventType)1 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1 ArrayList (java.util.ArrayList)1 PageImpl (org.springframework.data.domain.PageImpl)1 PageRequest (org.springframework.data.domain.PageRequest)1