Search in sources :

Example 1 with IcSyncDeltaTypeEnum

use of eu.bcvsolutions.idm.ic.impl.IcSyncDeltaTypeEnum in project CzechIdMng by bcvsolutions.

the class AbstractSynchronizationExecutor method handleIcObject.

/**
 * Handle IC connector object
 *
 * @param itemContext
 * @return
 */
protected boolean handleIcObject(SynchronizationContext itemContext) {
    Assert.notNull(itemContext, "Item context is required.");
    IcConnectorObject icObject = itemContext.getIcObject();
    AbstractSysSyncConfigDto config = itemContext.getConfig();
    SysSyncLogDto log = itemContext.getLog();
    AttributeMapping tokenAttribute = itemContext.getTokenAttribute();
    SysSyncItemLogDto itemLog = new SysSyncItemLogDto();
    // Synchronization by custom filter not supported DELETE
    // event
    IcSyncDeltaTypeEnum type = IcSyncDeltaTypeEnum.CREATE_OR_UPDATE;
    itemContext.addLogItem(itemLog).addType(type);
    // Find token by token attribute
    // For Reconciliation can be token attribute null
    Object tokenObj = null;
    if (tokenAttribute != null) {
        tokenObj = getValueByMappedAttribute(tokenAttribute, icObject.getAttributes(), itemContext);
    }
    // Token is saved in Sync as String, therefore we transform token (from
    // IcObject) to String too.
    String token = tokenObj != null ? tokenObj.toString() : null;
    // grater token to config and log.
    if (token != null && config.getToken() != null && token.compareTo(config.getToken()) <= -1) {
        token = config.getToken();
    }
    // Save token
    log.setToken(token);
    if (!config.isReconciliation()) {
        config.setToken(token);
    }
    boolean result = startItemSynchronization(itemContext);
    // sync or LRT)
    return updateAndCheckState(result, log);
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) IcSyncDeltaTypeEnum(eu.bcvsolutions.idm.ic.impl.IcSyncDeltaTypeEnum) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)

Example 2 with IcSyncDeltaTypeEnum

use of eu.bcvsolutions.idm.ic.impl.IcSyncDeltaTypeEnum in project CzechIdMng by bcvsolutions.

the class AbstractSynchronizationExecutor method doItemSynchronization.

@Override
public boolean doItemSynchronization(SynchronizationContext context) {
    Assert.notNull(context, "Context is required.");
    String uid = context.getUid();
    IcConnectorObject icObject = context.getIcObject();
    IcSyncDeltaTypeEnum type = context.getType();
    AbstractSysSyncConfigDto config = context.getConfig();
    SysSystemDto system = context.getSystem();
    SystemEntityType entityType = context.getEntityType();
    AccAccountDto account = context.getAccount();
    SysSyncLogDto log = context.getLog();
    SysSyncItemLogDto logItem = context.getLogItem();
    List<SysSyncActionLogDto> actionLogs = context.getActionLogs();
    // Set default unknown action type
    context.addActionType(SynchronizationActionType.UNKNOWN);
    // If differential sync is disabled, then is every entity marks as different.
    context.setIsEntityDifferent(!config.isDifferentialSync());
    try {
        // Find system entity for uid
        SysSystemEntityDto systemEntity = findSystemEntity(uid, system, entityType);
        context.addSystemEntity(systemEntity);
        // Find acc account for uid or system entity
        if (account == null) {
            account = findAccount(context);
            if (systemEntity == null) {
                addToItemLog(logItem, "SystemEntity for this uid doesn't exist. We will create it.");
                systemEntity = createSystemEntity(uid, entityType, system);
            }
        }
        context.addSystemEntity(systemEntity).addAccount(account);
        if (IcSyncDeltaTypeEnum.CREATE == type || IcSyncDeltaTypeEnum.UPDATE == type || IcSyncDeltaTypeEnum.CREATE_OR_UPDATE == type) {
            // Update or create
            Assert.notNull(icObject, "Connector object is required.");
            List<IcAttribute> icAttributes = icObject.getAttributes();
            if (account == null) {
                // Account doesn't exist in IDM
                systemEntity = removeSystemEntityWishIfPossible(systemEntity, false, context);
                context.addSystemEntity(systemEntity);
                resolveAccountNotExistSituation(context, systemEntity, icAttributes);
            } else {
                // Account exist in IdM (LINKED)
                SynchronizationLinkedActionType linkedAction = config.getLinkedAction();
                SynchronizationActionType action = linkedAction.getAction();
                context.addActionType(action);
                SynchronizationSituationType situation = SynchronizationSituationType.LINKED;
                // configured
                if (linkedAction == SynchronizationLinkedActionType.UPDATE_ENTITY || linkedAction == SynchronizationLinkedActionType.UPDATE_ACCOUNT) {
                    systemEntity = removeSystemEntityWishIfPossible(systemEntity, true, context);
                    context.addSystemEntity(systemEntity);
                }
                if (StringUtils.hasLength(config.getLinkedActionWfKey())) {
                    // We will start specific workflow
                    startWorkflow(config.getLinkedActionWfKey(), situation, action, null, context);
                } else {
                    resolveLinkedSituation(config.getLinkedAction(), context);
                }
                addToItemLog(logItem, "Account exist in IdM (LINKED) - ended");
            }
        } else if (IcSyncDeltaTypeEnum.DELETE == type) {
            // Missing account situation, can be call from connector
            // (support delete account event) and from reconciliation
            context.addActionType(config.getMissingAccountAction().getAction());
            SynchronizationSituationType situation = SynchronizationSituationType.MISSING_ACCOUNT;
            if (StringUtils.hasLength(config.getMissingAccountActionWfKey())) {
                ReconciliationMissingAccountActionType missingAccountActionType = config.getMissingAccountAction();
                SynchronizationActionType action = missingAccountActionType.getAction();
                // We will start specific workflow
                startWorkflow(config.getMissingAccountActionWfKey(), situation, action, null, context);
            } else {
                // Resolve missing account situation for one item
                this.resolveMissingAccountSituation(config.getMissingAccountAction(), context);
            }
        } else if (context.isExportAction()) {
            // Export situation - create account to system
            this.resolveUnlinkedSituation(SynchronizationUnlinkedActionType.LINK_AND_UPDATE_ACCOUNT, context);
        }
        // Call hard hibernate session flush and clear
        if (getHibernateSession().isOpen()) {
            getHibernateSession().flush();
            getHibernateSession().clear();
        }
        return true;
    } catch (Exception e) {
        loggingException(context.getActionType(), log, logItem, actionLogs, uid, e);
        throw e;
    }
}
Also used : SynchronizationSituationType(eu.bcvsolutions.idm.acc.domain.SynchronizationSituationType) SynchronizationLinkedActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationLinkedActionType) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ReconciliationMissingAccountActionType(eu.bcvsolutions.idm.acc.domain.ReconciliationMissingAccountActionType) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) SynchronizationActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationActionType) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) IcSyncDeltaTypeEnum(eu.bcvsolutions.idm.ic.impl.IcSyncDeltaTypeEnum) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)

Example 3 with IcSyncDeltaTypeEnum

use of eu.bcvsolutions.idm.ic.impl.IcSyncDeltaTypeEnum in project CzechIdMng by bcvsolutions.

the class ConnIdIcConvertUtil method convertConnIdSyncDelta.

public static IcSyncDelta convertConnIdSyncDelta(SyncDelta delta) {
    if (delta == null) {
        return null;
    }
    IcSyncToken token = ConnIdIcConvertUtil.convertConnIdSyncToken(delta.getToken());
    IcSyncDeltaTypeEnum deltaType = IcSyncDeltaTypeEnum.valueOf(delta.getDeltaType().name());
    IcUidAttribute previousUid = ConnIdIcConvertUtil.convertConnIdUid(delta.getPreviousUid());
    IcObjectClass objectClass = ConnIdIcConvertUtil.convertConnIdObjectClass(delta.getObjectClass());
    IcUidAttribute uid = ConnIdIcConvertUtil.convertConnIdUid(delta.getUid());
    IcConnectorObject object = ConnIdIcConvertUtil.convertConnIdConnectorObject(delta.getObject());
    return new IcSyncDeltaImpl(token, deltaType, previousUid, objectClass, uid, object);
}
Also used : IcSyncDeltaTypeEnum(eu.bcvsolutions.idm.ic.impl.IcSyncDeltaTypeEnum) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) IcSyncDeltaImpl(eu.bcvsolutions.idm.ic.impl.IcSyncDeltaImpl) IcSyncToken(eu.bcvsolutions.idm.ic.api.IcSyncToken) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute)

Aggregations

IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)3 IcSyncDeltaTypeEnum (eu.bcvsolutions.idm.ic.impl.IcSyncDeltaTypeEnum)3 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)2 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)2 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)2 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)2 AttributeMapping (eu.bcvsolutions.idm.acc.domain.AttributeMapping)1 ReconciliationMissingAccountActionType (eu.bcvsolutions.idm.acc.domain.ReconciliationMissingAccountActionType)1 SynchronizationActionType (eu.bcvsolutions.idm.acc.domain.SynchronizationActionType)1 SynchronizationLinkedActionType (eu.bcvsolutions.idm.acc.domain.SynchronizationLinkedActionType)1 SynchronizationSituationType (eu.bcvsolutions.idm.acc.domain.SynchronizationSituationType)1 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)1 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)1 SysSyncActionLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto)1 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)1 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)1 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)1 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)1 IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)1 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)1