use of eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto in project CzechIdMng by bcvsolutions.
the class ReadonlySystemProcessor method process.
@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
SysProvisioningOperationDto provisioningOperation = event.getContent();
SysSystemDto system = systemService.get(provisioningOperation.getSystem());
boolean closed = false;
if (system.isReadonly()) {
String uid = provisioningOperationService.getByProvisioningOperation(provisioningOperation).getUid();
ResultModel resultModel = new DefaultResultModel(AccResultCode.PROVISIONING_SYSTEM_READONLY, ImmutableMap.of("name", uid, "system", system.getName()));
provisioningOperation.setResult(new OperationResult.Builder(OperationState.NOT_EXECUTED).setModel(resultModel).build());
//
provisioningOperation = provisioningOperationService.save(provisioningOperation);
//
LOG.info(resultModel.toString());
notificationManager.send(AccModuleDescriptor.TOPIC_PROVISIONING, new IdmMessageDto.Builder().setModel(resultModel).build());
//
closed = true;
}
// set back to event content
event.setContent(provisioningOperation);
return new DefaultEventResult<>(event, this, closed);
}
use of eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto in project CzechIdMng by bcvsolutions.
the class RemoveProcessedOperationProcessor method process.
@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
SysProvisioningOperationDto provisioningOperation = event.getContent();
if (OperationState.EXECUTED == provisioningOperation.getResultState() || ProvisioningEventType.CANCEL == event.getType()) {
provisioningOperationService.delete(provisioningOperation);
LOG.debug("Executed provisioning operation [{}] was removed from queue.", provisioningOperation.getId());
//
if (ProvisioningEventType.DELETE == event.getType()) {
// We successfully deleted account on target system. We need to delete system entity
systemEntityService.delete(systemEntityService.getByProvisioningOperation(provisioningOperation));
}
}
return new DefaultEventResult<>(event, this, isClosable());
}
use of eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto in project CzechIdMng by bcvsolutions.
the class SysProvisioningOperationFilterIntegrationTest method entityIdentifierFilterTest.
@Test
public void entityIdentifierFilterTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
SysSystemDto system = createSystem();
createProvisioningOperation(entityType, system);
SysProvisioningOperationDto provisioningOperation1 = createProvisioningOperation(entityType, system);
provisioningOperation1.setEntityIdentifier(UUID.randomUUID());
operationService.save(provisioningOperation1);
SysProvisioningOperationDto provisioningOperation2 = createProvisioningOperation(entityType, system);
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setEntityIdentifier(provisioningOperation1.getEntityIdentifier());
filter.setSystemId(system.getId());
Page<SysProvisioningOperationDto> result = operationService.find(filter, null, permission);
assertEquals(1, result.getTotalElements());
assertTrue(result.getContent().contains(provisioningOperation1));
assertFalse(result.getContent().contains(provisioningOperation2));
}
use of eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto 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.acc.dto.SysProvisioningOperationDto 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