Search in sources :

Example 6 with OperationResult

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;
}
Also used : OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult)

Example 7 with OperationResult

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();
}
Also used : IdentityEvent(eu.bcvsolutions.idm.core.model.event.IdentityEvent) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdentityState(eu.bcvsolutions.idm.core.api.domain.IdentityState)

Example 8 with OperationResult

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();
}
Also used : OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)

Example 9 with OperationResult

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);
}
Also used : ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

Example 10 with OperationResult

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));
}
Also used : SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)32 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)14 Test (org.junit.Test)10 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)7 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)6 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)5 UUID (java.util.UUID)5 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)4 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)4 AbstractDto (eu.bcvsolutions.idm.core.api.dto.AbstractDto)4 IdmAccountDto (eu.bcvsolutions.idm.core.api.dto.IdmAccountDto)4 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)4 IdentityEvent (eu.bcvsolutions.idm.core.model.event.IdentityEvent)4 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)4 AbstractRestTest (eu.bcvsolutions.idm.test.api.AbstractRestTest)4 ArrayList (java.util.ArrayList)4 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)3 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)3 IdentityState (eu.bcvsolutions.idm.core.api.domain.IdentityState)3 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)3