use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class RoleCatalogueDeleteProcessor method process.
@Override
public EventResult<IdmRoleCatalogueDto> process(EntityEvent<IdmRoleCatalogueDto> event) {
AccRoleCatalogueAccountFilter filter = new AccRoleCatalogueAccountFilter();
filter.setEntityId(event.getContent().getId());
catalogueAccountService.find(filter, null).forEach(treeAccount -> {
catalogueAccountService.delete(treeAccount);
});
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class RoleDeleteProcessor method process.
@Override
public EventResult<IdmRoleDto> process(EntityEvent<IdmRoleDto> event) {
IdmRoleDto role = event.getContent();
if (role.getId() != null) {
// delete mapped roles
SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
roleSystemFilter.setRoleId(role.getId());
roleSystemService.find(roleSystemFilter, null).forEach(roleSystem -> {
roleSystemService.delete(roleSystem);
});
//
// delete relations on account (includes delete of account )
AccRoleAccountFilter filter = new AccRoleAccountFilter();
filter.setRoleId(role.getId());
roleAccountService.find(filter, null).forEach(roleAccount -> {
roleAccountService.delete(roleAccount);
});
//
// remove all recipients from provisioning break
deleteProvisioningRecipient(event.getContent().getId());
//
// Delete link to sync identity configuration
syncConfigRepository.clearDefaultRole(role.getId());
}
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class SchemaAttributeDeleteProcessor method process.
@Override
public EventResult<SysSchemaAttributeDto> process(EntityEvent<SysSchemaAttributeDto> event) {
SysSchemaAttributeDto schemaAttribute = event.getContent();
// remove all handled attributes
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSchemaAttributeId(schemaAttribute.getId());
systeAttributeMappingService.find(filter, null).forEach(systemAttributeMapping -> {
systeAttributeMappingService.delete(systemAttributeMapping);
});
//
schemaAttributeService.deleteInternal(schemaAttribute);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class SystemDeleteProcessor method process.
@Override
public EventResult<SysSystemDto> process(EntityEvent<SysSystemDto> event) {
SysSystemDto system = event.getContent();
Assert.notNull(system);
//
// if exists provisioning operations, then is not possible to delete
// system
SysProvisioningOperationFilter operationFilter = new SysProvisioningOperationFilter();
operationFilter.setSystemId(system.getId());
if (provisioningOperationRepository.find(operationFilter, null).getTotalElements() > 0) {
throw new ResultCodeException(AccResultCode.SYSTEM_DELETE_FAILED_HAS_OPERATIONS, ImmutableMap.of("system", system.getName()));
}
if (accountRepository.countBySystem_Id(system.getId()) > 0) {
throw new ResultCodeException(AccResultCode.SYSTEM_DELETE_FAILED_HAS_ACCOUNTS, ImmutableMap.of("system", system.getName()));
}
// delete system entities
SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
systemEntityFilter.setSystemId(system.getId());
systemEntityService.find(systemEntityFilter, null).forEach(systemEntity -> {
systemEntityService.delete(systemEntity);
});
// delete synchronization configs
SysSyncConfigFilter synchronizationConfigFilter = new SysSyncConfigFilter();
synchronizationConfigFilter.setSystemId(system.getId());
synchronizationConfigService.find(synchronizationConfigFilter, null).forEach(config -> {
synchronizationConfigService.delete(config);
});
// delete schema
SysSchemaObjectClassFilter filter = new SysSchemaObjectClassFilter();
filter.setSystemId(system.getId());
objectClassService.find(filter, null).forEach(schemaObjectClass -> {
objectClassService.delete(schemaObjectClass);
});
// delete archived provisioning operations
provisioningArchiveRepository.deleteBySystem_Id(system.getId());
//
// clear provisioning break cache
clearProvisioningBreakAndCache(system.getId());
//
// deletes all confidential values
confidentialStorage.deleteAll(system.getId(), SysSystem.class);
//
// deletes identity
service.deleteInternal(system);
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class SystemMappingSaveProcessor method process.
@Override
public EventResult<SysSystemMappingDto> process(EntityEvent<SysSystemMappingDto> event) {
SysSystemMappingDto dto = event.getContent();
// it is not possible get schema from embedded - new entity
SysSchemaObjectClassDto schema = schemaObjectClassService.get(dto.getObjectClass());
SysSystemDto system = DtoUtils.getEmbedded(schema, SysSchemaObjectClass_.system, SysSystemDto.class);
// for tree type is possible has more than one provisioning, both only for one tree type
if (dto.getOperationType() == SystemOperationType.PROVISIONING) {
// check if exists mapping
List<SysSystemMappingDto> anotherMapping = getMapping(dto.getEntityType(), schema.getSystem(), dto.getTreeType());
// if list not empty throw error with duplicate mapping
if (anotherMapping.stream().filter(mapping -> {
return !mapping.getId().equals(dto.getId());
}).findFirst().isPresent()) {
throw new ResultCodeException(AccResultCode.SYSTEM_MAPPING_FOR_ENTITY_EXISTS, ImmutableMap.of("system", system.getName(), "entityType", dto.getEntityType()));
}
}
//
SysSystemMappingDto result = systemMappingService.saveInternal(dto);
// update content
event.setContent(result);
//
return new DefaultEventResult<>(event, this);
}
Aggregations