Search in sources :

Example 1 with ProvisioningOperation

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);
            }
        }
    }
}
Also used : SysProvisioningAttribute(eu.bcvsolutions.idm.acc.entity.SysProvisioningAttribute) List(java.util.List) Propagation(org.springframework.transaction.annotation.Propagation) ProvisioningOperation(eu.bcvsolutions.idm.acc.domain.ProvisioningOperation) SysProvisioningAttributeRepository(eu.bcvsolutions.idm.acc.repository.SysProvisioningAttributeRepository) CollectionUtils(org.springframework.util.CollectionUtils) SysProvisioningAttribute(eu.bcvsolutions.idm.acc.entity.SysProvisioningAttribute) Autowired(org.springframework.beans.factory.annotation.Autowired) SysProvisioningAttributeService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningAttributeService) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) StringUtils(org.apache.commons.lang3.StringUtils) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ProvisioningOperation

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;
}
Also used : ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) ProvisioningOperation(eu.bcvsolutions.idm.acc.domain.ProvisioningOperation) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysAttributeDifferenceDto(eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceDto)

Aggregations

ProvisioningOperation (eu.bcvsolutions.idm.acc.domain.ProvisioningOperation)2 ProvisioningContext (eu.bcvsolutions.idm.acc.domain.ProvisioningContext)1 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)1 SysAttributeDifferenceDto (eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceDto)1 SysProvisioningAttribute (eu.bcvsolutions.idm.acc.entity.SysProvisioningAttribute)1 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)1 SysProvisioningAttributeRepository (eu.bcvsolutions.idm.acc.repository.SysProvisioningAttributeRepository)1 SysProvisioningAttributeService (eu.bcvsolutions.idm.acc.service.api.SysProvisioningAttributeService)1 IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)1 List (java.util.List)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Propagation (org.springframework.transaction.annotation.Propagation)1 Transactional (org.springframework.transaction.annotation.Transactional)1 Assert (org.springframework.util.Assert)1 CollectionUtils (org.springframework.util.CollectionUtils)1