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);
});
}
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);
}
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);
}
}
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);
}
Aggregations