Search in sources :

Example 11 with IdentityRoleEvent

use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleCompositionService method updateSubRoles.

@Override
@Transactional
public void updateSubRoles(EntityEvent<IdmIdentityRoleDto> event, BasePermission... permission) {
    Assert.notNull(event, "Event is required.");
    IdmIdentityRoleDto identityRole = event.getContent();
    Assert.notNull(identityRole, "Identity role identifier is required.");
    // 
    IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
    filter.setDirectRoleId(identityRole.getId());
    // 
    identityRoleService.find(filter, null).forEach(subIdentityRole -> {
        subIdentityRole.setIdentityContract(identityRole.getIdentityContract());
        subIdentityRole.setContractPosition(identityRole.getContractPosition());
        subIdentityRole.getEmbedded().put(IdmIdentityRoleDto.PROPERTY_IDENTITY_CONTRACT, identityRole.getEmbedded().get(IdmIdentityRoleDto.PROPERTY_IDENTITY_CONTRACT));
        subIdentityRole.setValidFrom(identityRole.getValidFrom());
        subIdentityRole.setValidTill(identityRole.getValidTill());
        // 
        IdentityRoleEvent subEvent = new IdentityRoleEvent(IdentityRoleEventType.UPDATE, subIdentityRole);
        // 
        identityRoleService.publish(subEvent, event, permission);
        // Notes updated assigned role to parent event
        IdmIdentityRoleDto subContent = subEvent.getContent();
        notingAssignedRole(event, subEvent, subContent, IdentityRoleEvent.PROPERTY_ASSIGNED_UPDATED_ROLES);
    });
}
Also used : IdentityRoleEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with IdentityRoleEvent

use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.

the class IdentityContractUpdateByAutomaticRoleProcessor method updateIdentityRole.

/**
 * Saves identity role by event - skip authorities check is needed (optimalizations)
 *
 * @param identityRole
 */
private void updateIdentityRole(IdmIdentityRoleDto identityRole) {
    // skip check granted authorities
    IdentityRoleEvent event = new IdentityRoleEvent(IdentityRoleEventType.UPDATE, identityRole);
    event.getProperties().put(IdmIdentityRoleService.SKIP_CHECK_AUTHORITIES, Boolean.TRUE);
    identityRoleService.publish(event);
}
Also used : IdentityRoleEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent)

Example 13 with IdentityRoleEvent

use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.

the class DefaultIdmAutomaticRoleAttributeService method addAutomaticRoles.

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void addAutomaticRoles(IdmIdentityContractDto contract, Set<AbstractIdmAutomaticRoleDto> automaticRoles) {
    for (AbstractIdmAutomaticRoleDto autoRole : automaticRoles) {
        // create identity role directly
        IdmIdentityRoleDto identityRole = new IdmIdentityRoleDto();
        identityRole.setRoleTreeNode(autoRole.getId());
        identityRole.setIdentityContract(contract.getId());
        identityRole.setRole(autoRole.getRole());
        identityRole.setValidFrom(contract.getValidFrom());
        identityRole.setValidTill(contract.getValidTill());
        // 
        // start event with skip check authorities
        IdentityRoleEvent event = new IdentityRoleEvent(IdentityRoleEventType.CREATE, identityRole);
        event.getProperties().put(IdmIdentityRoleService.SKIP_CHECK_AUTHORITIES, Boolean.TRUE);
        identityRoleService.publish(event);
    }
}
Also used : IdentityRoleEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent) AbstractIdmAutomaticRoleDto(eu.bcvsolutions.idm.core.api.dto.AbstractIdmAutomaticRoleDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with IdentityRoleEvent

use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.

the class IdentityRoleDeleteProcessor method process.

@Override
public EventResult<IdmIdentityRoleDto> process(EntityEvent<IdmIdentityRoleDto> event) {
    IdmIdentityRoleDto identityRole = event.getContent();
    UUID identityRoleId = identityRole.getId();
    Assert.notNull(identityRoleId, "Content identifier is required.");
    // Find all concepts and remove relation on identity role
    IdmConceptRoleRequestFilter conceptRequestFilter = new IdmConceptRoleRequestFilter();
    conceptRequestFilter.setIdentityRoleId(identityRoleId);
    conceptRequestService.find(conceptRequestFilter, null).getContent().forEach(concept -> {
        String message = null;
        if (concept.getState().isTerminatedState()) {
            message = MessageFormat.format("IdentityRole [{0}] (reqested in concept [{1}]) was deleted (not from this role request)!", identityRoleId, concept.getId());
        } else {
            message = MessageFormat.format("Request change in concept [{0}], was not executed, because requested IdentityRole [{1}] was deleted (not from this role request)!", concept.getId(), identityRoleId);
            concept = conceptRequestService.cancel(concept);
        }
        conceptRequestService.addToLog(concept, message);
        concept.setIdentityRole(null);
        conceptRequestService.save(concept);
    });
    // 
    // remove all IdentityRoleValidRequest for this role
    List<IdmIdentityRoleValidRequestDto> validRequests = identityRoleValidRequestService.findAllValidRequestForIdentityRoleId(identityRoleId);
    identityRoleValidRequestService.deleteAll(validRequests);
    // 
    // remove sub roles - just for sure, if role is not removed by role request
    IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
    filter.setDirectRoleId(identityRoleId);
    service.find(filter, null).forEach(subIdentityRole -> {
        IdentityRoleEvent subEvent = new IdentityRoleEvent(IdentityRoleEventType.DELETE, subIdentityRole);
        // 
        service.publish(subEvent, event);
        // Notes identity-accounts to ACM
        notingIdentityAccountForDelayedAcm(event, subEvent);
    });
    // 
    // Delete identity role
    service.deleteInternal(identityRole);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : IdmConceptRoleRequestFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmConceptRoleRequestFilter) IdentityRoleEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) UUID(java.util.UUID) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmIdentityRoleValidRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto)

Aggregations

IdentityRoleEvent (eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent)14 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)11 Transactional (org.springframework.transaction.annotation.Transactional)6 IdmIdentityRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter)5 AbstractIdmAutomaticRoleDto (eu.bcvsolutions.idm.core.api.dto.AbstractIdmAutomaticRoleDto)4 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)3 UUID (java.util.UUID)3 IdmIdentityRoleValidRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto)1 IdmRoleCompositionDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto)1 IdmConceptRoleRequestFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmConceptRoleRequestFilter)1 IdmRoleCompositionFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCompositionFilter)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1 Serializable (java.io.Serializable)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1