use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class IdentityRoleDeleteProcessor method process.
@Override
public EventResult<IdmIdentityRoleDto> process(EntityEvent<IdmIdentityRoleDto> event) {
IdmIdentityRoleDto identityRole = event.getContent();
// Find all concepts and remove relation on identity role
IdmConceptRoleRequestFilter conceptRequestFilter = new IdmConceptRoleRequestFilter();
conceptRequestFilter.setIdentityRoleId(identityRole.getId());
conceptRequestService.find(conceptRequestFilter, null).getContent().forEach(concept -> {
IdmRoleRequestDto request = roleRequestService.get(concept.getRoleRequest());
String message = null;
if (concept.getState().isTerminatedState()) {
message = MessageFormat.format("IdentityRole [{0}] (reqested in concept [{1}]) was deleted (not from this role request)!", identityRole.getId(), 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(), identityRole.getId());
concept.setState(RoleRequestState.CANCELED);
}
roleRequestService.addToLog(request, message);
conceptRequestService.addToLog(concept, message);
concept.setIdentityRole(null);
roleRequestService.save(request);
conceptRequestService.save(concept);
});
//
// remove all IdentityRoleValidRequest for this role
List<IdmIdentityRoleValidRequestDto> validRequests = identityRoleValidRequestService.findAllValidRequestForIdentityRoleId(identityRole.getId());
identityRoleValidRequestService.deleteAll(validRequests);
//
// Delete identity role
service.deleteInternal(identityRole);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class IdentitySaveProcessor method process.
@Override
public EventResult<IdmIdentityDto> process(EntityEvent<IdmIdentityDto> event) {
IdmIdentityDto identity = event.getContent();
GuardedString password = identity.getPassword();
identity = service.saveInternal(identity);
//
event.setContent(identity);
// save password
if (password != null) {
PasswordChangeDto passwordDto = new PasswordChangeDto();
passwordDto.setNewPassword(password);
passwordProcessor.savePassword(identity, passwordDto);
}
//
// create default identity contract
boolean skipCreationDefaultContract = getBooleanProperty(IdmIdentityContractService.SKIP_CREATION_OF_DEFAULT_POSITION, event.getProperties());
if (!skipCreationDefaultContract && IdentityEventType.CREATE.name() == event.getType().name() && identityConfiguration.isCreateDefaultContractEnabled()) {
// TODO: skip publish event? But contract is created properly ...
identityContractService.save(identityContractService.prepareMainContract(identity.getId()));
}
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class PasswordPolicyDeleteProcessor method process.
@Override
public EventResult<IdmPasswordPolicyDto> process(EntityEvent<IdmPasswordPolicyDto> event) {
IdmPasswordPolicyDto dto = event.getContent();
//
passwordPolicyService.deleteInternal(dto);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class AutomaticRoleAttributeCreateProcessor method process.
@Override
public EventResult<IdmAutomaticRoleAttributeDto> process(EntityEvent<IdmAutomaticRoleAttributeDto> event) {
IdmAutomaticRoleAttributeDto automaticRoleAttributeDto = event.getContent();
//
automaticRoleAttributeDto = service.saveInternal(automaticRoleAttributeDto);
event.setContent(automaticRoleAttributeDto);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class AutomaticRoleAttributeDeleteProcessor method process.
@Override
public EventResult<IdmAutomaticRoleAttributeDto> process(EntityEvent<IdmAutomaticRoleAttributeDto> event) {
IdmAutomaticRoleAttributeDto content = event.getContent();
//
// delete all assigned roles gained by this automatic role by long running task
RemoveAutomaticRoleTaskExecutor automaticRoleTask = AutowireHelper.createBean(RemoveAutomaticRoleTaskExecutor.class);
automaticRoleTask.setAutomaticRoleId(content.getId());
longRunningTaskManager.executeSync(automaticRoleTask);
//
return new DefaultEventResult<>(event, this);
}
Aggregations