use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class VsRequestRealizationProcessor method process.
@Override
public EventResult<VsRequestDto> process(EntityEvent<VsRequestDto> event) {
VsRequestDto dto = event.getContent();
//
dto = service.createRequest(dto);
IcUidAttribute uid = service.internalStart(dto);
event.getProperties().put(VsRequestRealizationProcessor.RESULT_UID, uid);
event.setContent(dto);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class AccountDeleteProcessor method process.
@Override
public EventResult<AccAccountDto> process(EntityEvent<AccAccountDto> event) {
AccAccountDto account = event.getContent();
UUID entityId = null;
Object entityIdObj = event.getProperties().get(AccAccountService.ENTITY_ID_PROPERTY);
if (entityIdObj instanceof UUID) {
entityId = (UUID) entityIdObj;
}
boolean deleteTargetAccount = false;
Object deleteTargetAccountObj = event.getProperties().get(AccAccountService.DELETE_TARGET_ACCOUNT_PROPERTY);
if (deleteTargetAccountObj instanceof Boolean) {
deleteTargetAccount = (boolean) deleteTargetAccountObj;
}
Assert.notNull(account, "Account cannot be null!");
// We do not allow delete account in protection
if (account.isAccountProtectedAndValid()) {
throw new ResultCodeException(AccResultCode.ACCOUNT_CANNOT_BE_DELETED_IS_PROTECTED, ImmutableMap.of("uid", account.getUid()));
}
// delete all identity accounts
AccIdentityAccountFilter identityAccountFilter = new AccIdentityAccountFilter();
identityAccountFilter.setAccountId(account.getId());
List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(identityAccountFilter, null).getContent();
identityAccounts.forEach(identityAccount -> {
identityAccountService.delete(identityAccount);
});
// delete all role accounts
AccRoleAccountFilter roleAccountFilter = new AccRoleAccountFilter();
roleAccountFilter.setAccountId(account.getId());
List<AccRoleAccountDto> roleAccounts = roleAccountService.find(roleAccountFilter, null).getContent();
roleAccounts.forEach(roleAccount -> {
roleAccountService.delete(roleAccount);
});
// delete all roleCatalogue accounts
AccRoleCatalogueAccountFilter roleCatalogueAccountFilter = new AccRoleCatalogueAccountFilter();
roleCatalogueAccountFilter.setAccountId(account.getId());
List<AccRoleCatalogueAccountDto> roleCatalogueAccounts = roleCatalogueAccountService.find(roleCatalogueAccountFilter, null).getContent();
roleCatalogueAccounts.forEach(roleCatalogueAccount -> {
roleCatalogueAccountService.delete(roleCatalogueAccount);
});
// delete all tree accounts
AccTreeAccountFilter treeAccountFilter = new AccTreeAccountFilter();
treeAccountFilter.setAccountId(account.getId());
List<AccTreeAccountDto> treeAccounts = treeAccountService.find(treeAccountFilter, null).getContent();
treeAccounts.forEach(treeAccount -> {
treeAccountService.delete(treeAccount);
});
// delete all contract accounts
AccContractAccountFilter contractAccountFilter = new AccContractAccountFilter();
contractAccountFilter.setAccountId(account.getId());
List<AccContractAccountDto> contractAccounts = contractAccountService.find(contractAccountFilter, null).getContent();
contractAccounts.forEach(contractAccount -> {
contractAccountService.delete(contractAccount);
});
//
AccAccountDto refreshAccount = accountService.get(account.getId());
// If account still exists (was not deleted by entity-account), we delete him directly now
if (refreshAccount != null) {
accountService.deleteInternal(refreshAccount);
}
if (deleteTargetAccount) {
if (SystemEntityType.CONTRACT == account.getEntityType()) {
LOG.warn(MessageFormat.format("Provisioning is not supported for contract now [{0}]!", account.getUid()));
return new DefaultEventResult<>(event, this);
}
this.provisioningService.doDeleteProvisioning(account, account.getEntityType(), entityId);
}
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class IdentityAccountSaveProcessor method process.
@Override
public EventResult<AccIdentityAccountDto> process(EntityEvent<AccIdentityAccountDto> event) {
AccIdentityAccountDto entity = event.getContent();
UUID account = entity.getAccount();
AccAccountDto accountEntity = accountService.get(account);
Assert.notNull(account, "Account cannot be null!");
// identity-account
if (service.isNew(entity) && entity.isOwnership() && accountEntity.isInProtection()) {
AccIdentityAccountDto protectedIdentityAccount = findProtectedIdentityAccount(account);
// First we save new identity-account
event.setContent(service.saveInternal(entity));
// Second we delete protected identity-account
service.delete(protectedIdentityAccount);
// Next we set account to unprotected state
this.deactivateProtection(accountEntity);
accountEntity = accountService.save(accountEntity);
return new DefaultEventResult<>(event, this);
}
event.setContent(service.saveInternal(entity));
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class IdentityContractDeleteProcessor method process.
@Override
public EventResult<IdmIdentityContractDto> process(EntityEvent<IdmIdentityContractDto> event) {
// delete relations on account (includes delete of account )
AccContractAccountFilter filter = new AccContractAccountFilter();
filter.setEntityId(event.getContent().getId());
entityAccountService.find(filter, null).forEach(entityAccount -> {
LOG.debug("Remove contract-account for account [{}]", entityAccount.getId());
entityAccountService.delete(entityAccount);
});
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class IdentityDeleteProcessor method process.
@Override
public EventResult<IdmIdentityDto> process(EntityEvent<IdmIdentityDto> event) {
IdmIdentityDto identity = event.getContent();
Assert.notNull(identity);
Assert.notNull(identity.getId());
syncConfigRepository.clearDefaultLeader(identity.getId());
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
identityAccountService.find(filter, null).forEach(identityAccount -> {
identityAccountService.forceDelete(identityAccount);
});
//
// remove all recipients from provisioning break
deleteProvisioningRecipients(identity.getId());
//
return new DefaultEventResult<>(event, this);
}
Aggregations