use of eu.bcvsolutions.idm.core.api.dto.filter.IdmDelegationFilter in project CzechIdMng by bcvsolutions.
the class AbstractDelegationType method delegate.
@Override
public IdmDelegationDto delegate(BaseDto owner, IdmDelegationDefinitionDto definition) {
IdmDelegationFilter delegationFilter = new IdmDelegationFilter();
delegationFilter.setOwnerId(DtoUtils.toUuid(owner.getId()));
delegationFilter.setOwnerType(owner.getClass().getCanonicalName());
delegationFilter.setDelegationDefinitionId(definition.getId());
// Check if same delegation already exists.
IdmDelegationDto delegation = delegationService.find(delegationFilter, null).getContent().stream().findFirst().orElse(null);
if (delegation != null) {
LOG.debug("Delegation [{}] for definition [{}] and owner [{}],[{}] already exists.", delegation.getId(), definition.getId(), owner.getId(), owner.getClass().getSimpleName());
return delegation;
}
delegation = new IdmDelegationDto();
delegation.setOwnerState(new OperationResultDto(OperationState.RUNNING));
delegation.setDefinition(definition.getId());
delegation.setOwnerId(DtoUtils.toUuid(owner.getId()));
delegation.setOwnerType(owner.getClass().getCanonicalName());
return delegationService.save(delegation);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmDelegationFilter in project CzechIdMng by bcvsolutions.
the class ManualTaskDelegationType method delegate.
@Override
public IdmDelegationDto delegate(BaseDto owner, IdmDelegationDefinitionDto definition) {
IdmDelegationFilter delegationFilter = new IdmDelegationFilter();
delegationFilter.setOwnerId(DtoUtils.toUuid(owner.getId()));
delegationFilter.setOwnerType(owner.getClass().getCanonicalName());
delegationFilter.setDelegationDefinitionId(definition.getId());
// Check if same delegation already exists is for manual delegatio disabled.
IdmDelegationDto delegation = new IdmDelegationDto();
delegation.setOwnerState(new OperationResultDto(OperationState.RUNNING));
delegation.setDefinition(definition.getId());
delegation.setOwnerId(DtoUtils.toUuid(owner.getId()));
delegation.setOwnerType(owner.getClass().getCanonicalName());
return delegationService.save(delegation);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmDelegationFilter in project CzechIdMng by bcvsolutions.
the class IdmDelegationController method toFilter.
@Override
protected IdmDelegationFilter toFilter(MultiValueMap<String, Object> parameters) {
IdmDelegationFilter filter = new IdmDelegationFilter(parameters, getParameterConverter());
filter.setIncludeOwner(true);
return filter;
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmDelegationFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmDelegationDefinitionService method deleteInternal.
@Override
@Transactional
public void deleteInternal(IdmDelegationDefinitionDto dto) {
Assert.notNull(dto.getId(), "ID cannot be null!");
// Referential integrity - delete all delegations for that definition.
IdmDelegationFilter delegationFilter = new IdmDelegationFilter();
delegationFilter.setDelegationDefinitionId(dto.getId());
delegationService.find(delegationFilter, null).getContent().forEach(delegation -> delegationService.delete(delegation));
super.deleteInternal(dto);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmDelegationFilter in project CzechIdMng by bcvsolutions.
the class DefaultDelegationManager method findDelegationForOwner.
@Override
public List<IdmDelegationDto> findDelegationForOwner(BaseDto owner, BasePermission... permission) {
Assert.notNull(owner, "Owner cannot be null!");
IdmDelegationFilter delegationFilter = new IdmDelegationFilter();
delegationFilter.setOwnerId(DtoUtils.toUuid(owner.getId()));
delegationFilter.setOwnerType(owner.getClass().getCanonicalName());
return delegationService.find(delegationFilter, null, permission).getContent();
}
Aggregations