Search in sources :

Example 1 with IdmRoleComposition_

use of eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_ in project CzechIdMng by bcvsolutions.

the class AddNewRoleCompositionTaskExecutor method getItemsToProcess.

/**
 * Returns superior roles, which should be processed
 */
@Override
public Page<IdmRoleDto> getItemsToProcess(Pageable pageable) {
    IdmRoleCompositionDto roleComposition = roleCompositionService.get(roleCompositionId);
    Assert.notNull(roleComposition, "Role composition is required.");
    // 
    List<IdmRoleDto> superiorRoles = roleCompositionService.findAllSuperiorRoles(roleComposition.getSub()).stream().map(composition -> {
        return DtoUtils.getEmbedded(composition, IdmRoleComposition_.superior, IdmRoleDto.class);
    }).collect(Collectors.toList());
    return new PageImpl<>(superiorRoles);
}
Also used : DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) IdmIdentityRole_(eu.bcvsolutions.idm.core.model.entity.IdmIdentityRole_) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto) IdmRoleCompositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCompositionFilter) Autowired(org.springframework.beans.factory.annotation.Autowired) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) IdmRoleRequestService(eu.bcvsolutions.idm.core.api.service.IdmRoleRequestService) Lists(com.google.common.collect.Lists) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) Map(java.util.Map) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) IdmLongRunningTaskFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter) Pageable(org.springframework.data.domain.Pageable) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmCheckConcurrentExecution(eu.bcvsolutions.idm.core.scheduler.api.domain.IdmCheckConcurrentExecution) IdmIdentityRoleService(eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) ImmutableMap(com.google.common.collect.ImmutableMap) IdmRoleComposition_(eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_) AbstractSchedulableStatefulExecutor(eu.bcvsolutions.idm.core.scheduler.api.service.AbstractSchedulableStatefulExecutor) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) PageRequest(org.springframework.data.domain.PageRequest) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) AcceptedException(eu.bcvsolutions.idm.core.api.exception.AcceptedException) IdmRoleCompositionService(eu.bcvsolutions.idm.core.api.service.IdmRoleCompositionService) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) List(java.util.List) Component(org.springframework.stereotype.Component) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) RoleRequestEvent(eu.bcvsolutions.idm.core.model.event.RoleRequestEvent) Optional(java.util.Optional) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) RoleRequestEventType(eu.bcvsolutions.idm.core.model.event.RoleRequestEvent.RoleRequestEventType) PageImpl(org.springframework.data.domain.PageImpl) ConceptRoleRequestOperation(eu.bcvsolutions.idm.core.api.domain.ConceptRoleRequestOperation) Assert(org.springframework.util.Assert) PageImpl(org.springframework.data.domain.PageImpl) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto)

Example 2 with IdmRoleComposition_

use of eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_ in project CzechIdMng by bcvsolutions.

the class DefaultIdmAuthorizationPolicyService method getDefaultPolicies.

@Override
@Transactional(readOnly = true)
public List<IdmAuthorizationPolicyDto> getDefaultPolicies(Class<? extends Identifiable> entityType) {
    IdmRoleDto defaultRole = roleService.getDefaultRole();
    if (defaultRole == null) {
        LOG.debug("Default role not found, no default authorization policies will be added.  Change configuration [{}].", IdmRoleService.PROPERTY_DEFAULT_ROLE);
        return Collections.<IdmAuthorizationPolicyDto>emptyList();
    }
    if (defaultRole.isDisabled()) {
        LOG.debug("Default role [{}] is disabled, no default authorization policies will be added.", defaultRole.getCode());
        return Collections.<IdmAuthorizationPolicyDto>emptyList();
    }
    // 
    UUID defaultRoleId = defaultRole.getId();
    IdmAuthorizationPolicyFilter filter = new IdmAuthorizationPolicyFilter();
    filter.setDisabled(Boolean.FALSE);
    if (entityType != null) {
        // optional
        filter.setAuthorizableType(entityType.getCanonicalName());
    }
    // default role policies
    filter.setRoleId(defaultRoleId);
    List<IdmAuthorizationPolicyDto> defaultPolicies = new ArrayList<>();
    defaultPolicies.addAll(find(filter, null).getContent());
    // all sub roles policies
    roleCompositionService.findAllSubRoles(defaultRoleId).stream().filter(roleComposition -> {
        IdmRoleDto subRole = DtoUtils.getEmbedded(roleComposition, IdmRoleComposition_.sub);
        return !subRole.isDisabled();
    }).forEach(roleComposition -> {
        filter.setRoleId(roleComposition.getSub());
        defaultPolicies.addAll(find(filter, null).getContent());
    });
    // 
    LOG.debug("Found [{}] default policies", defaultPolicies.size());
    // 
    return defaultPolicies;
}
Also used : DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) Autowired(org.springframework.beans.factory.annotation.Autowired) SiemLoggerManager(eu.bcvsolutions.idm.core.api.audit.service.SiemLoggerManager) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) IdmAuthorizationPolicyFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmAuthorizationPolicyFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) Predicate(javax.persistence.criteria.Predicate) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) IdmAuthorizationPolicyRepository(eu.bcvsolutions.idm.core.model.repository.IdmAuthorizationPolicyRepository) ModuleService(eu.bcvsolutions.idm.core.api.service.ModuleService) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Root(javax.persistence.criteria.Root) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) IdmRole_(eu.bcvsolutions.idm.core.model.entity.IdmRole_) ImmutableMap(com.google.common.collect.ImmutableMap) IdmRoleComposition_(eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_) AbstractEventableDtoService(eu.bcvsolutions.idm.core.api.service.AbstractEventableDtoService) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) Set(java.util.Set) DefaultGrantedAuthority(eu.bcvsolutions.idm.core.security.api.domain.DefaultGrantedAuthority) IdmRoleCompositionService(eu.bcvsolutions.idm.core.api.service.IdmRoleCompositionService) UUID(java.util.UUID) IdmAuthorizationPolicy(eu.bcvsolutions.idm.core.model.entity.IdmAuthorizationPolicy) Sets(com.google.common.collect.Sets) GrantedAuthority(org.springframework.security.core.GrantedAuthority) Objects(java.util.Objects) IdmAuthorizationPolicy_(eu.bcvsolutions.idm.core.model.entity.IdmAuthorizationPolicy_) List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) IdmAuthorizationPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto) LocalDate(java.time.LocalDate) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) IdmAuthorizationPolicyService(eu.bcvsolutions.idm.core.api.service.IdmAuthorizationPolicyService) IdmGroupPermission(eu.bcvsolutions.idm.core.security.api.domain.IdmGroupPermission) Collections(java.util.Collections) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) AuthorizableType(eu.bcvsolutions.idm.core.security.api.dto.AuthorizableType) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) ArrayList(java.util.ArrayList) IdmAuthorizationPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto) IdmAuthorizationPolicyFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmAuthorizationPolicyFilter) UUID(java.util.UUID) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with IdmRoleComposition_

use of eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_ in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleCompositionService method findAllSubRoles.

private void findAllSubRoles(List<IdmRoleCompositionDto> results, List<IdmRoleCompositionDto> parents, UUID superiorId, BasePermission... permission) {
    IdmRoleCompositionFilter filter = new IdmRoleCompositionFilter();
    filter.setSuperiorId(superiorId);
    // 
    find(filter, null, permission).stream().filter(// cyclic composition in the first level is ignored
    subRole -> !subRole.getSuperior().equals(subRole.getSub())).forEach(subRole -> {
        if (!// duplicate composition is enabled, but from different superior role => is not cycle, is duplicate but ok
        parents.stream().map(IdmRoleCompositionDto::getSuperior).anyMatch(superior -> superior.equals(subRole.getSub()))) {
            results.add(subRole);
            List<IdmRoleCompositionDto> lineParents = Lists.newArrayList(parents);
            lineParents.add(subRole);
            // 
            IdmRoleDto subRoleDto = DtoUtils.getEmbedded(subRole, IdmRoleComposition_.sub);
            if (subRoleDto.getChildrenCount() > 0) {
                findAllSubRoles(results, lineParents, subRole.getSub(), permission);
            }
        }
    });
}
Also used : DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) IdmRoleCompositionRepository(eu.bcvsolutions.idm.core.model.repository.IdmRoleCompositionRepository) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmAccountDto(eu.bcvsolutions.idm.core.api.dto.IdmAccountDto) IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto) IdmRoleCompositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCompositionFilter) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) ValueWrapper(eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) IdmRoleComposition(eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) Lists(com.google.common.collect.Lists) Predicate(javax.persistence.criteria.Predicate) CollectionUtils(org.apache.commons.collections.CollectionUtils) Map(java.util.Map) BasePermission(eu.bcvsolutions.idm.core.security.api.domain.BasePermission) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) IdentityRoleEventType(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent.IdentityRoleEventType) IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Root(javax.persistence.criteria.Root) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) IdmIdentityRoleService(eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService) IdmRole_(eu.bcvsolutions.idm.core.model.entity.IdmRole_) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmRoleComposition_(eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_) AbstractEventableDtoService(eu.bcvsolutions.idm.core.api.service.AbstractEventableDtoService) IdmCacheManager(eu.bcvsolutions.idm.core.api.service.IdmCacheManager) Set(java.util.Set) IdmRoleCompositionService(eu.bcvsolutions.idm.core.api.service.IdmRoleCompositionService) IdentityRoleEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent) UUID(java.util.UUID) Serializable(java.io.Serializable) List(java.util.List) ExportDescriptorDto(eu.bcvsolutions.idm.core.api.dto.ExportDescriptorDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) AuthorizableType(eu.bcvsolutions.idm.core.security.api.dto.AuthorizableType) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto) IdmRoleCompositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCompositionFilter)

Example 4 with IdmRoleComposition_

use of eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_ in project CzechIdMng by bcvsolutions.

the class DefaultIdmAuthorizationPolicyService method getDefaultAuthorities.

@Override
@Transactional(readOnly = true)
public Set<GrantedAuthority> getDefaultAuthorities(UUID identityId) {
    IdmRoleDto defaultRole = roleService.getDefaultRole();
    if (defaultRole == null) {
        LOG.debug("Default role not found, no default authorities will be added. Change configuration [{}].", IdmRoleService.PROPERTY_DEFAULT_ROLE);
        return Collections.<GrantedAuthority>emptySet();
    }
    if (defaultRole.isDisabled()) {
        LOG.debug("Default role [{}] is disabled, no default authorities will be added.", defaultRole.getCode());
        return Collections.<GrantedAuthority>emptySet();
    }
    // 
    UUID defaultRoleId = defaultRole.getId();
    Set<GrantedAuthority> defaultAuthorities = new HashSet<>();
    // default role authorities
    defaultAuthorities.addAll(getEnabledRoleAuthorities(identityId, defaultRoleId));
    // all sub roles authorities
    roleCompositionService.findAllSubRoles(defaultRoleId).stream().filter(roleComposition -> {
        IdmRoleDto subRole = DtoUtils.getEmbedded(roleComposition, IdmRoleComposition_.sub);
        return !subRole.isDisabled();
    }).forEach(roleComposition -> {
        defaultAuthorities.addAll(getEnabledRoleAuthorities(identityId, roleComposition.getSub()));
    });
    // 
    LOG.debug("Found [{}] default authorities", defaultAuthorities.size());
    return defaultAuthorities;
}
Also used : DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) Autowired(org.springframework.beans.factory.annotation.Autowired) SiemLoggerManager(eu.bcvsolutions.idm.core.api.audit.service.SiemLoggerManager) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) IdmAuthorizationPolicyFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmAuthorizationPolicyFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) Predicate(javax.persistence.criteria.Predicate) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) IdmAuthorizationPolicyRepository(eu.bcvsolutions.idm.core.model.repository.IdmAuthorizationPolicyRepository) ModuleService(eu.bcvsolutions.idm.core.api.service.ModuleService) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Root(javax.persistence.criteria.Root) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) IdmRole_(eu.bcvsolutions.idm.core.model.entity.IdmRole_) ImmutableMap(com.google.common.collect.ImmutableMap) IdmRoleComposition_(eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_) AbstractEventableDtoService(eu.bcvsolutions.idm.core.api.service.AbstractEventableDtoService) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) Set(java.util.Set) DefaultGrantedAuthority(eu.bcvsolutions.idm.core.security.api.domain.DefaultGrantedAuthority) IdmRoleCompositionService(eu.bcvsolutions.idm.core.api.service.IdmRoleCompositionService) UUID(java.util.UUID) IdmAuthorizationPolicy(eu.bcvsolutions.idm.core.model.entity.IdmAuthorizationPolicy) Sets(com.google.common.collect.Sets) GrantedAuthority(org.springframework.security.core.GrantedAuthority) Objects(java.util.Objects) IdmAuthorizationPolicy_(eu.bcvsolutions.idm.core.model.entity.IdmAuthorizationPolicy_) List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) IdmAuthorizationPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto) LocalDate(java.time.LocalDate) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) IdmAuthorizationPolicyService(eu.bcvsolutions.idm.core.api.service.IdmAuthorizationPolicyService) IdmGroupPermission(eu.bcvsolutions.idm.core.security.api.domain.IdmGroupPermission) Collections(java.util.Collections) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) AuthorizableType(eu.bcvsolutions.idm.core.security.api.dto.AuthorizableType) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) DefaultGrantedAuthority(eu.bcvsolutions.idm.core.security.api.domain.DefaultGrantedAuthority) GrantedAuthority(org.springframework.security.core.GrantedAuthority) UUID(java.util.UUID) HashSet(java.util.HashSet) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with IdmRoleComposition_

use of eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_ in project CzechIdMng by bcvsolutions.

the class DuplicateRoleCompositionProcessor method process.

@Override
@SuppressWarnings("unchecked")
public EventResult<IdmRoleDto> process(EntityEvent<IdmRoleDto> event) {
    IdmRoleDto cloned = event.getContent();
    IdmRoleDto originalSource = event.getOriginalSource();
    // 
    Map<String, Serializable> props = resolveProperties(event);
    Set<UUID> processedRoles = (Set<UUID>) props.get(RoleEvent.PROPERTY_PROCESSED_ROLES);
    processedRoles.add(cloned.getId());
    // 
    // find and clone business role composition
    // clone roles recursively
    Set<String> processedSubRoles = new HashSet<>();
    Map<String, IdmRoleCompositionDto> currentSubRoles = new HashMap<>();
    roleCompositionService.findDirectSubRoles(cloned.getId()).forEach(composition -> {
        IdmRoleDto subRole = DtoUtils.getEmbedded(composition, IdmRoleComposition_.sub);
        currentSubRoles.put(subRole.getCode(), composition);
    });
    // 
    roleCompositionService.findDirectSubRoles(originalSource.getId()).stream().filter(composition -> {
        return includeComposition(event, composition);
    }).forEach(composition -> {
        // find sub role on the target environment
        IdmRoleDto subRole = DtoUtils.getEmbedded(composition, IdmRoleComposition_.sub);
        IdmRoleDto targetRole = roleService.getByBaseCodeAndEnvironment(subRole.getBaseCode(), cloned.getEnvironment());
        // 
        if (targetRole != null || duplicateRecursively(event, subRole, targetRole)) {
            if (targetRole == null) {
                // new clone
                targetRole = prepareRole(subRole.getBaseCode(), cloned.getEnvironment());
            }
            if (targetRole != null && subRole.getId().equals(targetRole.getId())) {
                LOG.debug("Role [{}] is duplicated on the same environment - skipping recursion for the same roles", targetRole.getCode());
            } else if (targetRole != null && processedRoles.contains(targetRole.getId())) {
                LOG.debug("Role [{}] was already processed by other business role composition - cycle, skipping", targetRole.getCode());
            } else {
                // 
                // clone / update
                EntityEvent<IdmRoleDto> subEvent = new RoleEvent(RoleEventType.DUPLICATE, targetRole, props);
                // original source is the cloned role
                subEvent.setOriginalSource(subRole);
                // we want to be sync
                subEvent.setPriority(PriorityType.IMMEDIATE);
                EventContext<IdmRoleDto> resultSubRole = roleService.publish(subEvent, event);
                targetRole = resultSubRole.getContent();
            }
            // 
            // create the composition (or check composition exists)
            // find exists
            processedSubRoles.add(targetRole.getCode());
            if (!currentSubRoles.containsKey(targetRole.getCode())) {
                IdmRoleCompositionDto cloneComposition = new IdmRoleCompositionDto(cloned.getId(), targetRole.getId());
                EntityEvent<IdmRoleCompositionDto> createCompositionEvent = new RoleCompositionEvent(RoleCompositionEventType.CREATE, cloneComposition);
                // we want to be sync
                createCompositionEvent.setPriority(PriorityType.IMMEDIATE);
                roleCompositionService.publish(createCompositionEvent, event);
            }
        }
    });
    // 
    // remove unprocessed sub roles, which was removed in surce role
    currentSubRoles.entrySet().stream().filter(entry -> {
        return !processedSubRoles.contains(entry.getKey());
    }).filter(entry -> {
        return includeComposition(event, entry.getValue());
    }).forEach(entry -> {
        // dirty flag role composition only - will be processed after parent action ends
        IdmEntityStateDto stateDeleted = new IdmEntityStateDto();
        stateDeleted.setEvent(event.getId());
        stateDeleted.setSuperOwnerId(cloned.getId());
        stateDeleted.setResult(new OperationResultDto.Builder(OperationState.RUNNING).setModel(new DefaultResultModel(CoreResultCode.DELETED)).build());
        entityStateManager.saveState(entry.getValue(), stateDeleted);
    });
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) CoreEventProcessor(eu.bcvsolutions.idm.core.api.event.CoreEventProcessor) RoleEvent(eu.bcvsolutions.idm.core.model.event.RoleEvent) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) HashSet(java.util.HashSet) EntityStateManager(eu.bcvsolutions.idm.core.api.service.EntityStateManager) Lists(com.google.common.collect.Lists) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) Map(java.util.Map) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) EventResult(eu.bcvsolutions.idm.core.api.event.EventResult) RoleEventType(eu.bcvsolutions.idm.core.model.event.RoleEvent.RoleEventType) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Description(org.springframework.context.annotation.Description) RoleCompositionEventType(eu.bcvsolutions.idm.core.model.event.RoleCompositionEvent.RoleCompositionEventType) RoleProcessor(eu.bcvsolutions.idm.core.api.event.processor.RoleProcessor) IdmRoleComposition_(eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) Set(java.util.Set) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) IdmRoleCompositionService(eu.bcvsolutions.idm.core.api.service.IdmRoleCompositionService) UUID(java.util.UUID) RoleCompositionEvent(eu.bcvsolutions.idm.core.model.event.RoleCompositionEvent) EventContext(eu.bcvsolutions.idm.core.api.event.EventContext) PriorityType(eu.bcvsolutions.idm.core.api.domain.PriorityType) Serializable(java.io.Serializable) IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) List(java.util.List) Component(org.springframework.stereotype.Component) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) Serializable(java.io.Serializable) HashSet(java.util.HashSet) Set(java.util.Set) RoleCompositionEvent(eu.bcvsolutions.idm.core.model.event.RoleCompositionEvent) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) HashMap(java.util.HashMap) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) RoleEvent(eu.bcvsolutions.idm.core.model.event.RoleEvent) EventContext(eu.bcvsolutions.idm.core.api.event.EventContext) IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) UUID(java.util.UUID) HashSet(java.util.HashSet)

Aggregations

IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)5 IdmRoleCompositionService (eu.bcvsolutions.idm.core.api.service.IdmRoleCompositionService)5 DtoUtils (eu.bcvsolutions.idm.core.api.utils.DtoUtils)5 IdmRoleComposition_ (eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_)5 List (java.util.List)5 UUID (java.util.UUID)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)4 EntityEvent (eu.bcvsolutions.idm.core.api.event.EntityEvent)4 Assert (org.springframework.util.Assert)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 Lists (com.google.common.collect.Lists)3 IdmRoleCompositionDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto)3 AbstractEventableDtoService (eu.bcvsolutions.idm.core.api.service.AbstractEventableDtoService)3 EntityEventManager (eu.bcvsolutions.idm.core.api.service.EntityEventManager)3 IdmRoleService (eu.bcvsolutions.idm.core.api.service.IdmRoleService)3 CoreGroupPermission (eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 Sets (com.google.common.collect.Sets)2