use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleAttributeService method removeAutomaticRoles.
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void removeAutomaticRoles(UUID contractId, Set<AbstractIdmAutomaticRoleDto> automaticRoles) {
for (AbstractIdmAutomaticRoleDto autoRole : automaticRoles) {
IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
identityRoleFilter.setIdentityContractId(contractId);
identityRoleFilter.setAutomaticRoleId(autoRole.getId());
// TODO: possible performance update with pageable
for (IdmIdentityRoleDto identityRole : identityRoleService.find(identityRoleFilter, null).getContent()) {
// skip check granted authorities
IdentityRoleEvent event = new IdentityRoleEvent(IdentityRoleEventType.DELETE, identityRole);
event.getProperties().put(IdmIdentityRoleService.SKIP_CHECK_AUTHORITIES, Boolean.TRUE);
identityRoleService.publish(event);
}
}
}
use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleTreeNodeService method addAutomaticRoles.
@Override
@Transactional
public void addAutomaticRoles(IdmIdentityContractDto contract, Set<IdmRoleTreeNodeDto> automaticRoles) {
// original method assignAutomaticRoles has also only @Transactional without reguired new
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);
}
}
use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleRequestService method removeAssignedRole.
/**
* Remove identity-role by concept
*
* @param concept
* @param request
* @param requestEvent
*/
private void removeAssignedRole(IdmConceptRoleRequestDto concept, IdmRoleRequestDto request, EntityEvent<IdmRoleRequestDto> requestEvent) {
Assert.notNull(concept.getIdentityRole(), "IdentityRole is mandatory for delete!");
IdmIdentityRoleDto identityRole = DtoUtils.getEmbedded(concept, IdmConceptRoleRequest_.identityRole.getName(), IdmIdentityRoleDto.class, (IdmIdentityRoleDto) null);
if (identityRole == null) {
identityRole = identityRoleThinService.get(concept.getIdentityRole());
}
if (identityRole != null) {
concept.setState(RoleRequestState.EXECUTED);
// we have to remove relation on
concept.setIdentityRole(null);
// deleted identityRole
String message = MessageFormat.format("IdentityRole [{0}] (reqested in concept [{1}]) was deleted (from this role request).", identityRole.getId(), concept.getId());
conceptRoleRequestService.addToLog(concept, message);
conceptRoleRequestService.addToLog(request, message);
conceptRoleRequestService.save(concept);
IdentityRoleEvent event = new IdentityRoleEvent(IdentityRoleEventType.DELETE, identityRole, ImmutableMap.of(IdmAccountDto.SKIP_PROPAGATE, Boolean.TRUE));
identityRoleService.publish(event, requestEvent);
// Add list of identity-accounts for delayed ACM to parent event
Set<UUID> subIdentityAccountsForAcm = event.getSetProperty(IdmAccountDto.IDENTITY_ACCOUNT_FOR_DELAYED_ACM, UUID.class);
Set<UUID> identityAccountsForAcm = requestEvent.getSetProperty(IdmAccountDto.IDENTITY_ACCOUNT_FOR_DELAYED_ACM, UUID.class);
identityAccountsForAcm.addAll(subIdentityAccountsForAcm);
// Add list of accounts for additional provisioning to parent event
Set<UUID> subIdentityAccountsForProvisioning = event.getSetProperty(IdmAccountDto.ACCOUNT_FOR_ADDITIONAL_PROVISIONING, UUID.class);
Set<UUID> identityAccountsForProvisioning = requestEvent.getSetProperty(IdmAccountDto.ACCOUNT_FOR_ADDITIONAL_PROVISIONING, UUID.class);
identityAccountsForProvisioning.addAll(subIdentityAccountsForProvisioning);
// Removed assigned roles by business roles
Set<UUID> subRemovedIdentityRoles = event.getSetProperty(IdentityRoleEvent.PROPERTY_ASSIGNED_REMOVED_ROLES, UUID.class);
// Add to parent event
Set<UUID> removedIdentityRoles = requestEvent.getSetProperty(IdentityRoleEvent.PROPERTY_ASSIGNED_REMOVED_ROLES, UUID.class);
removedIdentityRoles.addAll(subRemovedIdentityRoles);
removedIdentityRoles.add(identityRole.getId());
}
}
use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleTreeNodeService method createIdentityRole.
/**
* Method create identity role and start event with create
* the identity role and skip check authorities.
*
* @param contract
* @param automaticRoles
*/
private void createIdentityRole(IdmIdentityContractDto contract, IdmContractPositionDto contractPosition, Set<IdmRoleTreeNodeDto> automaticRoles) {
for (AbstractIdmAutomaticRoleDto autoRole : automaticRoles) {
// create identity role directly
IdmIdentityRoleDto identityRole = new IdmIdentityRoleDto();
identityRole.setAutomaticRole(autoRole.getId());
identityRole.setIdentityContract(contract.getId());
identityRole.setContractPosition(contractPosition == null ? null : contractPosition.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);
}
}
use of eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleTreeNodeService method removeAutomaticRoles.
@Override
public void removeAutomaticRoles(IdmIdentityRoleDto identityRole, Set<IdmRoleTreeNodeDto> automaticRoles) {
IdentityRoleEvent event = new IdentityRoleEvent(IdentityRoleEventType.DELETE, identityRole);
event.getProperties().put(IdmIdentityRoleService.SKIP_CHECK_AUTHORITIES, Boolean.TRUE);
identityRoleService.publish(event);
}
Aggregations