use of eu.bcvsolutions.idm.acc.domain.ProvisioningOperation in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningAttributeService method saveAttributes.
/**
* Provisioning operation is saved in new transaction, attributes has to be saved too.
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void saveAttributes(ProvisioningOperation operation) {
Assert.notNull(operation, "Operation is required.");
Assert.notNull(operation.getId(), "Operation identifier is required.");
//
if (operation.getProvisioningContext().getConnectorObject() != null) {
List<IcAttribute> connectorAttributes = operation.getProvisioningContext().getConnectorObject().getAttributes();
if (!CollectionUtils.isEmpty(connectorAttributes)) {
for (IcAttribute connectorAttribute : connectorAttributes) {
SysProvisioningAttribute provisioningAttribute = new SysProvisioningAttribute(operation.getId(), connectorAttribute.getName());
if (CollectionUtils.isEmpty(connectorAttribute.getValues())) {
provisioningAttribute.setRemoved(true);
} else {
provisioningAttribute.setRemoved(connectorAttribute.getValues().stream().allMatch(v -> {
return v == null || StringUtils.isEmpty(v.toString());
}));
}
repository.save(provisioningAttribute);
}
}
}
}
use of eu.bcvsolutions.idm.acc.domain.ProvisioningOperation in project CzechIdMng by bcvsolutions.
the class ChangesOnSystemReportExecutor method createAccountDifferences.
/**
* Starts the provisioning in the dry run for single account. Results of the
* calculated provisioning is used for differences evaluation and highlight.
*
* @param account
* @param identity
* @param selectedAttributeNames
* @return
*/
private List<SysAttributeDifferenceDto> createAccountDifferences(AccAccountDto account, IdmIdentityDto identity, List<String> selectedAttributeNames) {
EventContext<AccAccountDto> eventCtx = provisioningService.doProvisioning(account, identity, ImmutableMap.of(ProvisioningService.DRY_RUN_PROPERTY_NAME, Boolean.TRUE));
EventResult<AccAccountDto> result = eventCtx.getLastResult();
if (result == null) {
throw new ProvisioningException(AccResultCode.PROVISIONING_FAILED, ImmutableMap.of("name", account.getId(), "system", account.getSystem(), "operationType", "DRY_RUN", "objectClass", ""));
}
ProvisioningOperation provisioningOperation = (ProvisioningOperation) result.getEvent().getProperties().get(EventResult.EVENT_PROPERTY_RESULT);
if (provisioningOperation == null) {
throw new ProvisioningException(AccResultCode.PROVISIONING_FAILED, ImmutableMap.of("name", account.getId(), "system", account.getSystem(), "operationType", "DRY_RUN", "objectClass", ""));
}
ProvisioningContext context = provisioningOperation.getProvisioningContext();
context = filterAttributes(context, selectedAttributeNames);
if (context == null) {
throw new ProvisioningException(AccResultCode.PROVISIONING_FAILED, ImmutableMap.of("name", account.getId(), "system", account.getSystem(), "operationType", "DRY_RUN", "objectClass", ""));
}
List<SysAttributeDifferenceDto> differences = provisioningArchiveService.evaluateProvisioningDifferences(context.getSystemConnectorObject(), context.getConnectorObject());
return differences;
}
Aggregations