use of eu.bcvsolutions.idm.core.api.entity.OperationResult in project CzechIdMng by bcvsolutions.
the class OperationResultConverter method convert.
@Override
public OperationResult convert(MappingContext<OperationResult, OperationResult> context) {
if (context != null && context.getSource() != null && context.getSource() instanceof OperationResult) {
OperationResult source = context.getSource();
OperationResult operationResult = new OperationResult();
// We need use convertors for the String (StringToStringConverter)
operationResult.setCause(source.getCause() != null ? modeler.map(source.getCause(), String.class) : null);
operationResult.setCode(source.getCode() != null ? modeler.map(source.getCode(), String.class) : null);
operationResult.setState(source.getState());
operationResult.setModel(source.getModel());
return operationResult;
}
return null;
}
use of eu.bcvsolutions.idm.core.api.entity.OperationResult in project CzechIdMng by bcvsolutions.
the class IdentityContractExclusionProcessor method process.
/**
* Check identity state after contract is excluded
*
* @param contract
* @param skipRecalculation Skip automatic role recalculation
* @return
*/
public OperationResult process(IdmIdentityContractDto contract, Boolean skipRecalculation) {
IdmIdentityDto identity = identityService.get(contract.getIdentity());
IdentityState newState = identityService.evaluateState(identity.getId());
//
if (identity.getState() != newState) {
LOG.info("Change identity [{}] state [{}]", identity.getUsername(), newState);
//
identity.setState(newState);
// is necessary publish new event with skip recalculation automatic roles
IdentityEvent identityEvent = new IdentityEvent(IdentityEventType.UPDATE, identity);
identityEvent.getProperties().put(IdmAutomaticRoleAttributeService.SKIP_RECALCULATION, skipRecalculation);
identityService.publish(identityEvent);
}
return new OperationResult.Builder(OperationState.EXECUTED).build();
}
use of eu.bcvsolutions.idm.core.api.entity.OperationResult in project CzechIdMng by bcvsolutions.
the class IdentityContractExclusionProcessor method process.
@Override
public EventResult<IdmIdentityContractDto> process(EntityEvent<IdmIdentityContractDto> event) {
if (!StringUtils.isEmpty(getWorkflowDefinitionKey())) {
// wf is configured - execute wf instance
return super.process(event);
}
//
IdmIdentityContractDto contract = event.getContent();
OperationResult result = process(contract, (Boolean) event.getProperties().get(IdmAutomaticRoleAttributeService.SKIP_RECALCULATION));
return new DefaultEventResult.Builder<>(event, this).setResult(result).build();
}
use of eu.bcvsolutions.idm.core.api.entity.OperationResult in project CzechIdMng by bcvsolutions.
the class SysProvisioningOperationFilterIntegrationTest method createProvisioningOperation.
private SysProvisioningOperationDto createProvisioningOperation(SystemEntityType type, SysSystemDto system) {
SysProvisioningOperationDto provisioningOperation = new SysProvisioningOperationDto();
provisioningOperation.setEntityType(type);
provisioningOperation.setOperationType(ProvisioningEventType.CREATE);
provisioningOperation.setProvisioningContext(new ProvisioningContext());
provisioningOperation.setSystem(system.getId());
SysSystemEntityDto systemEntity = helper.createSystemEntity(system);
provisioningOperation.setSystemEntity(systemEntity.getId());
OperationResult result = new OperationResult();
result.setState(OperationState.RUNNING);
provisioningOperation.setResult(result);
return operationService.save(provisioningOperation);
}
use of eu.bcvsolutions.idm.core.api.entity.OperationResult in project CzechIdMng by bcvsolutions.
the class SysProvisioningOperationFilterIntegrationTest method resultStateFilterTest.
@Test
public void resultStateFilterTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
SysSystemDto system = createSystem();
OperationResult resultState = new OperationResult();
resultState.setState(OperationState.CREATED);
SysProvisioningOperationDto provisioningOperation1 = createProvisioningOperation(entityType, system);
SysProvisioningOperationDto provisioningOperation2 = createProvisioningOperation(entityType, system);
provisioningOperation2.setResult(resultState);
operationService.save(provisioningOperation2);
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setResultState(OperationState.CREATED);
filter.setSystemId(system.getId());
Page<SysProvisioningOperationDto> result = operationService.find(filter, null, permission);
assertEquals(1, result.getTotalElements());
assertTrue(result.getContent().contains(provisioningOperation2));
assertFalse(result.getContent().contains(provisioningOperation1));
}
Aggregations