Search in sources :

Example 6 with VsException

use of eu.bcvsolutions.idm.vs.exception.VsException in project CzechIdMng by bcvsolutions.

the class BasicVirtualConnector method loadImplementers.

/**
 * Load implementers by UUIDs in connector configuration. Throw exception when
 * identity not found.
 *
 * @param implementersString
 * @return
 */
private List<IdmIdentityDto> loadImplementers(UUID[] implementersUUID) {
    List<IdmIdentityDto> implementers = new ArrayList<>();
    if (implementersUUID == null) {
        return implementers;
    }
    for (UUID implementer : implementersUUID) {
        IdmIdentityDto identity = identityService.get(implementer);
        if (identity == null) {
            throw new VsException(VsResultCode.VS_IMPLEMENTER_WAS_NOT_FOUND, ImmutableMap.of("implementer", implementer));
        }
        implementers.add(identity);
    }
    return implementers;
}
Also used : VsException(eu.bcvsolutions.idm.vs.exception.VsException) ArrayList(java.util.ArrayList) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID)

Example 7 with VsException

use of eu.bcvsolutions.idm.vs.exception.VsException in project CzechIdMng by bcvsolutions.

the class DefaultVsSystemService method loadImplementerRoles.

/**
 * Load implementer roles by UUIDs in connector configuration. If none role are
 * set and none direct implementers are set, then will be used default role.
 * Throw exception when identity not found.
 *
 * @param implementerRolesUUID
 * @param implementersFromConfig
 * @return
 */
private List<IdmRoleDto> loadImplementerRoles(UUID[] implementerRolesUUID, List<IdmIdentityDto> implementersFromConfig) {
    if ((implementerRolesUUID == null || implementerRolesUUID.length == 0)) {
        List<IdmRoleDto> implementerRoles = new ArrayList<>(1);
        if (CollectionUtils.isEmpty(implementersFromConfig)) {
            // Load default role from configuration
            IdmRoleDto defaultRole = vsConfiguration.getDefaultRole();
            if (defaultRole != null) {
                implementerRoles.add(defaultRole);
            }
        }
        return implementerRoles;
    }
    List<IdmRoleDto> implementerRoles = new ArrayList<>(implementerRolesUUID.length);
    for (UUID implementer : implementerRolesUUID) {
        IdmRoleDto role = roleService.get(implementer);
        if (role == null) {
            throw new VsException(VsResultCode.VS_IMPLEMENTER_ROLE_WAS_NOT_FOUND, ImmutableMap.of("role", implementer));
        }
        implementerRoles.add(role);
    }
    return implementerRoles;
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) VsException(eu.bcvsolutions.idm.vs.exception.VsException) ArrayList(java.util.ArrayList) UUID(java.util.UUID)

Aggregations

VsException (eu.bcvsolutions.idm.vs.exception.VsException)7 UUID (java.util.UUID)5 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)3 IcUidAttribute (eu.bcvsolutions.idm.ic.api.IcUidAttribute)3 ArrayList (java.util.ArrayList)3 Transactional (org.springframework.transaction.annotation.Transactional)3 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)1 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)1 SysAttributeDifferenceDto (eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceDto)1 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)1 SysSystem_ (eu.bcvsolutions.idm.acc.entity.SysSystem_)1 AccAccountService (eu.bcvsolutions.idm.acc.service.api.AccAccountService)1 SynchronizationEntityExecutor (eu.bcvsolutions.idm.acc.service.api.SynchronizationEntityExecutor)1 SysProvisioningArchiveService (eu.bcvsolutions.idm.acc.service.api.SysProvisioningArchiveService)1 SysSystemService (eu.bcvsolutions.idm.acc.service.api.SysSystemService)1 RoleRequestState (eu.bcvsolutions.idm.core.api.domain.RoleRequestState)1 AbstractDto (eu.bcvsolutions.idm.core.api.dto.AbstractDto)1 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)1