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()));
}
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();
}
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;
}
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;
}
Aggregations