Search in sources :

Example 11 with EntityAccountFilter

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

the class AbstractSynchronizationExecutor method getEntityByAccount.

/**
 * Find entity by account
 *
 * @param account
 * @param log
 * @param logItem
 * @param actionLogs
 * @return
 */
protected UUID getEntityByAccount(UUID accountId) {
    EntityAccountFilter entityAccountFilter = createEntityAccountFilter();
    entityAccountFilter.setAccountId(accountId);
    entityAccountFilter.setOwnership(Boolean.TRUE);
    @SuppressWarnings("unchecked") List<EntityAccountDto> entityAccounts = this.getEntityAccountService().find((BaseFilter) entityAccountFilter, null).getContent();
    if (entityAccounts.isEmpty()) {
        return null;
    } else {
        // ownership) have same identity!
        return entityAccounts.get(0).getEntity();
    }
}
Also used : EntityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.EntityAccountFilter) EntityAccountDto(eu.bcvsolutions.idm.acc.dto.EntityAccountDto) BaseFilter(eu.bcvsolutions.idm.core.api.dto.filter.BaseFilter)

Example 12 with EntityAccountFilter

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

the class IdentitySynchronizationExecutor method doUnlink.

/**
 * Operation remove IdentityAccount relations and linked roles
 *
 * @param account
 * @param removeIdentityRole
 * @param log
 * @param logItem
 * @param actionLogs
 */
@Override
protected void doUnlink(AccAccountDto account, boolean removeIdentityRole, SysSyncLogDto log, SysSyncItemLogDto logItem, List<SysSyncActionLogDto> actionLogs) {
    EntityAccountFilter identityAccountFilter = new AccIdentityAccountFilter();
    identityAccountFilter.setAccountId(account.getId());
    List<AccIdentityAccountDto> identityAccounts = identityAccoutnService.find((AccIdentityAccountFilter) identityAccountFilter, null).getContent();
    if (identityAccounts.isEmpty()) {
        addToItemLog(logItem, "Identity account relation was not found!");
        initSyncActionLog(SynchronizationActionType.UPDATE_ENTITY, OperationResultType.WARNING, logItem, log, actionLogs);
        return;
    }
    addToItemLog(logItem, MessageFormat.format("Identity-account relations to delete {0}", identityAccounts));
    identityAccounts.stream().forEach(identityAccount -> {
        // We will remove identity account, but without delete connected
        // account
        identityAccoutnService.delete(identityAccount, false);
        addToItemLog(logItem, MessageFormat.format("Identity-account relation deleted (without call delete provisioning) (username: {0}, id: {1})", identityAccount.getIdentity(), identityAccount.getId()));
        UUID identityRole = identityAccount.getIdentityRole();
        if (removeIdentityRole && identityRole != null) {
            // We will remove connected identity role
            identityRoleService.deleteById(identityRole);
            addToItemLog(logItem, MessageFormat.format("Identity-role relation deleted (id: {0})", identityRole));
        }
    });
    return;
}
Also used : EntityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.EntityAccountFilter) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) UUID(java.util.UUID) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)

Aggregations

EntityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.EntityAccountFilter)12 EntityAccountDto (eu.bcvsolutions.idm.acc.dto.EntityAccountDto)4 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)4 AttributeMapping (eu.bcvsolutions.idm.acc.domain.AttributeMapping)3 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)3 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)3 SysSystemAttributeMapping (eu.bcvsolutions.idm.acc.entity.SysSystemAttributeMapping)3 UUID (java.util.UUID)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 AccResultCode (eu.bcvsolutions.idm.acc.domain.AccResultCode)2 AccountType (eu.bcvsolutions.idm.acc.domain.AccountType)2 AttributeMappingStrategyType (eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType)2 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)2 ProvisioningEventType (eu.bcvsolutions.idm.acc.domain.ProvisioningEventType)2 ProvisioningOperationType (eu.bcvsolutions.idm.acc.domain.ProvisioningOperationType)2 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)2 SystemOperationType (eu.bcvsolutions.idm.acc.domain.SystemOperationType)2 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)2 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)2