use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.
the class AbstractSynchronizationExecutor method findSystemEntity.
private SysSystemEntityDto findSystemEntity(String uid, SysSystemDto system, SystemEntityType entityType) {
SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
systemEntityFilter.setEntityType(entityType);
systemEntityFilter.setSystemId(system.getId());
systemEntityFilter.setUid(uid);
List<SysSystemEntityDto> systemEntities = systemEntityService.find(systemEntityFilter, null).getContent();
SysSystemEntityDto systemEntity = null;
if (systemEntities.size() == 1) {
systemEntity = systemEntities.get(0);
} else if (systemEntities.size() > 1) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TO_MANY_SYSTEM_ENTITY, uid);
}
return systemEntity;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.
the class IdentityAccountManagementTest method defaultAccountRemovedEntitySystemExist.
@Test
public void defaultAccountRemovedEntitySystemExist() {
SysSystemEntityFilter filter = new SysSystemEntityFilter();
filter.setEntityType(SystemEntityType.IDENTITY);
filter.setUid("x" + IDENTITY_USERNAME);
Assert.assertEquals("SystemEntity must not be after account was deleted!", 0, systemEntityService.find(filter, null).getContent().size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.
the class IdentityAccountManagementTest method defaultAccountEntitySystemExist.
@Test
public void defaultAccountEntitySystemExist() {
SysSystemEntityFilter filter = new SysSystemEntityFilter();
filter.setEntityType(SystemEntityType.IDENTITY);
filter.setUid("x" + IDENTITY_USERNAME);
Assert.assertEquals("SystemEntity must be after account was created!", 1, systemEntityService.find(filter, null).getContent().size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter 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, "System is required.");
//
// if exists provisioning operations, then is not possible to delete
// system
SysProvisioningOperationFilter operationFilter = new SysProvisioningOperationFilter();
operationFilter.setSystemId(system.getId());
if (provisioningOperationService.count(operationFilter) > 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()));
}
// Check if system is used in some systems group.
SysSystemGroupSystemFilter groupSystemFilter = new SysSystemGroupSystemFilter();
groupSystemFilter.setSystemId(system.getId());
long count = systemGroupSystemService.count(groupSystemFilter);
if (count > 0) {
throw new ResultCodeException(AccResultCode.SYSTEM_DELETE_FAILED_HAS_SYSTEM_GROUPS, ImmutableMap.of("system", system.getName(), "count", count));
}
// 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);
//
// Delete connected uniform password. Or throw error at the beginning?
AccUniformPasswordSystemFilter uniformPasswordSystemFilter = new AccUniformPasswordSystemFilter();
uniformPasswordSystemFilter.setSystemId(system.getId());
passwordFilterSystemService.find(uniformPasswordSystemFilter, null).forEach(uniformPasswordSystem -> {
passwordFilterSystemService.delete(uniformPasswordSystem);
});
//
// deletes identity
service.deleteInternal(system);
return new DefaultEventResult<>(event, this);
}
Aggregations