Search in sources :

Example 1 with DelegationType

use of eu.bcvsolutions.idm.core.eav.api.service.DelegationType in project CzechIdMng by bcvsolutions.

the class DefaultDelegationManager method findDelegation.

@Override
public List<IdmDelegationDefinitionDto> findDelegation(String type, UUID delegatorId, UUID delegatorContractId, BaseDto owner) {
    Assert.notNull(type, "Delegation type cannot be null!");
    Assert.notNull(delegatorId, "Delegator cannot be null!");
    DelegationType delegateType = this.getDelegateType(type);
    if (delegateType == null) {
        // of delegatio type for this code missing ) -> throw exception.
        throw new ResultCodeException(CoreResultCode.DELEGATION_UNSUPPORTED_TYPE, ImmutableMap.of("type", type));
    }
    List<IdmDelegationDefinitionDto> definitions = delegateType.findDelegation(delegatorId, delegatorContractId, owner);
    if (CollectionUtils.isEmpty(definitions)) {
        if (DefaultDelegationType.NAME.equals(type)) {
            return null;
        }
        // Try to default delegation.
        DelegationType defaultDelegateType = this.getDelegateType(DefaultDelegationType.NAME);
        definitions = defaultDelegateType.findDelegation(delegatorId, delegatorContractId, owner);
        if (CollectionUtils.isEmpty(definitions)) {
            return null;
        }
    }
    definitions.forEach(definition -> {
        LOG.debug("Delegation definition found [{}] for type [{}] and delegator [{}]", definition.getId(), type, delegatorId);
    });
    return definitions;
}
Also used : IdmDelegationDefinitionDto(eu.bcvsolutions.idm.core.api.dto.IdmDelegationDefinitionDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) DefaultDelegationType(eu.bcvsolutions.idm.core.model.delegation.type.DefaultDelegationType) DelegationType(eu.bcvsolutions.idm.core.eav.api.service.DelegationType)

Example 2 with DelegationType

use of eu.bcvsolutions.idm.core.eav.api.service.DelegationType in project CzechIdMng by bcvsolutions.

the class DefaultIdmDelegationDefinitionService method toDto.

@Override
protected IdmDelegationDefinitionDto toDto(IdmDelegationDefinition entity, IdmDelegationDefinitionDto dto, IdmDelegationDefinitionFilter filter) {
    dto = super.toDto(entity, dto, filter);
    if (dto != null && dto.getType() != null) {
        // Add delegation type DTO to the delegation definition.
        DelegationType delegateType = delegationManager.getDelegateType(dto.getType());
        if (delegateType != null) {
            DelegationTypeDto delegationTypeDto = delegationManager.convertDelegationTypeToDto(delegateType);
            // I cannot use a key "type", because EnumSelect on FE try to use complex value from embedded.
            dto.getEmbedded().put(DelegationManager.WORKFLOW_DELEGATION_TYPE_KEY, delegationTypeDto);
        }
    }
    return dto;
}
Also used : DelegationType(eu.bcvsolutions.idm.core.eav.api.service.DelegationType) DelegationTypeDto(eu.bcvsolutions.idm.core.api.dto.DelegationTypeDto)

Example 3 with DelegationType

use of eu.bcvsolutions.idm.core.eav.api.service.DelegationType in project CzechIdMng by bcvsolutions.

the class DefaultDelegationManager method delegate.

@Override
public IdmDelegationDto delegate(BaseDto owner, IdmDelegationDefinitionDto definition) {
    Assert.notNull(owner, "Delegation goal/owner cannot be null!");
    Assert.notNull(definition, "Delegation definition cannot be null!");
    DelegationType delegateType = this.getDelegateType(definition.getType());
    if (delegateType == null) {
        // of delegation type for this code missing ) -> throw exception.
        throw new ResultCodeException(CoreResultCode.DELEGATION_UNSUPPORTED_TYPE, ImmutableMap.of("type", definition.getType()));
    }
    return delegateType.delegate(owner, definition);
}
Also used : ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) DefaultDelegationType(eu.bcvsolutions.idm.core.model.delegation.type.DefaultDelegationType) DelegationType(eu.bcvsolutions.idm.core.eav.api.service.DelegationType)

Aggregations

DelegationType (eu.bcvsolutions.idm.core.eav.api.service.DelegationType)3 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)2 DefaultDelegationType (eu.bcvsolutions.idm.core.model.delegation.type.DefaultDelegationType)2 DelegationTypeDto (eu.bcvsolutions.idm.core.api.dto.DelegationTypeDto)1 IdmDelegationDefinitionDto (eu.bcvsolutions.idm.core.api.dto.IdmDelegationDefinitionDto)1