Search in sources :

Example 21 with SysSyncActionLogDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto in project CzechIdMng by bcvsolutions.

the class DefaultTreeSynchronizationServiceTest method doStartSyncB_Linked_doEntityUpdate.

@Test
public void doStartSyncB_Linked_doEntityUpdate() {
    SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
    configFilter.setName(SYNC_CONFIG_NAME);
    List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
    // Change node code to changed
    this.getBean().changeOne();
    Assert.assertEquals(1, syncConfigs.size());
    AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
    Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
    // Set sync config
    syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
    syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
    syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
    syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
    syncConfigService.save(syncConfigCustom);
    // Check state before sync
    IdmTreeNodeFilter nodeFilter = new IdmTreeNodeFilter();
    nodeFilter.setProperty(NODE_NAME);
    nodeFilter.setValue("111");
    IdmTreeNodeDto treeNode = treeNodeService.find(nodeFilter, null).getContent().get(0);
    Assert.assertEquals("111", treeNode.getCode());
    synchornizationService.setSynchronizationConfigId(syncConfigCustom.getId());
    synchornizationService.process();
    // 
    SysSyncLogFilter logFilter = new SysSyncLogFilter();
    logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
    List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
    Assert.assertEquals(1, logs.size());
    SysSyncLogDto log = logs.get(0);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
    actionLogFilter.setSynchronizationLogId(log.getId());
    List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
    Assert.assertEquals(1, actions.size());
    SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
        return SynchronizationActionType.UPDATE_ENTITY == action.getSyncAction();
    }).findFirst().get();
    SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
    itemLogFilter.setSyncActionLogId(actionLog.getId());
    List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
    Assert.assertEquals(6, items.size());
    // Check state after sync
    treeNode = treeNodeService.get(treeNode.getId());
    Assert.assertEquals(CHANGED, treeNode.getCode());
    // Delete log
    syncLogService.delete(log);
}
Also used : IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSyncItemLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter) SysSyncActionLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 22 with SysSyncActionLogDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto in project CzechIdMng by bcvsolutions.

the class DefaultTreeSynchronizationServiceTest method doStartSyncC_MissingEntity.

@Test
public void doStartSyncC_MissingEntity() {
    SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
    configFilter.setName(SYNC_CONFIG_NAME);
    List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
    Assert.assertEquals(1, syncConfigs.size());
    AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
    Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
    syncConfigCustom.setRootsFilterScript("if(account){ def parentValue = account.getAttributeByName(\"PARENT\").getValue();" + " def uidValue = account.getAttributeByName(\"__NAME__\").getValue();" + " if(parentValue != null && parentValue.equals(uidValue)){" + "	 account.getAttributeByName(\"PARENT\").setValues(null); return Boolean.TRUE;}}" + " \nreturn Boolean.FALSE;");
    // Set sync config
    syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
    syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
    syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
    syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
    syncConfigService.save(syncConfigCustom);
    // 
    synchornizationService.setSynchronizationConfigId(syncConfigCustom.getId());
    synchornizationService.process();
    // 
    SysSyncLogFilter logFilter = new SysSyncLogFilter();
    logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
    List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
    Assert.assertEquals(1, logs.size());
    SysSyncLogDto log = logs.get(0);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
    actionLogFilter.setSynchronizationLogId(log.getId());
    List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
    Assert.assertEquals(2, actions.size());
    SysSyncActionLogDto createEntityActionLog = actions.stream().filter(action -> {
        return SynchronizationActionType.CREATE_ENTITY == action.getSyncAction();
    }).findFirst().get();
    SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
    itemLogFilter.setSyncActionLogId(createEntityActionLog.getId());
    List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
    Assert.assertEquals(6, items.size());
    IdmTreeTypeDto treeType = treeTypeService.find(null).getContent().stream().filter(tree -> {
        return tree.getName().equals(TREE_TYPE_TEST);
    }).findFirst().get();
    Assert.assertEquals(2, treeNodeService.findRoots(treeType.getId(), null).getContent().size());
    // Delete log
    syncLogService.delete(log);
}
Also used : SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSyncItemLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter) SysSyncActionLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 23 with SysSyncActionLogDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto in project CzechIdMng by bcvsolutions.

the class DefaultTreeSynchronizationServiceTest method doStartSyncA_MissingEntity.

@Test
public void doStartSyncA_MissingEntity() {
    SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
    configFilter.setName(SYNC_CONFIG_NAME);
    List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
    Assert.assertEquals(1, syncConfigs.size());
    AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
    Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
    // 
    synchornizationService.setSynchronizationConfigId(syncConfigCustom.getId());
    synchornizationService.process();
    // 
    SysSyncLogFilter logFilter = new SysSyncLogFilter();
    logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
    List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
    Assert.assertEquals(1, logs.size());
    SysSyncLogDto log = logs.get(0);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
    actionLogFilter.setSynchronizationLogId(log.getId());
    List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
    Assert.assertEquals(1, actions.size());
    SysSyncActionLogDto createEntityActionLog = actions.stream().filter(action -> {
        return SynchronizationActionType.CREATE_ENTITY == action.getSyncAction();
    }).findFirst().get();
    SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
    itemLogFilter.setSyncActionLogId(createEntityActionLog.getId());
    List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
    Assert.assertEquals(6, items.size());
    IdmTreeTypeDto treeType = treeTypeService.find(null).getContent().stream().filter(tree -> {
        return tree.getName().equals(TREE_TYPE_TEST);
    }).findFirst().get();
    Assert.assertEquals(1, treeNodeService.findRoots(treeType.getId(), null).getContent().size());
    // Delete log
    syncLogService.delete(log);
}
Also used : SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSyncItemLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter) SysSyncActionLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 24 with SysSyncActionLogDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto in project CzechIdMng by bcvsolutions.

the class AbstractSynchronizationExecutor method resolveMissingAccountSituation.

/**
 * Method for resolve missing account situation for one item.
 */
@Override
public void resolveMissingAccountSituation(ReconciliationMissingAccountActionType action, SynchronizationContext context) {
    SystemEntityType entityType = context.getEntityType();
    SysSyncLogDto log = context.getLog();
    SysSyncItemLogDto logItem = context.getLogItem();
    List<SysSyncActionLogDto> actionLogs = context.getActionLogs();
    AccAccountDto account = context.getAccount();
    addToItemLog(logItem, "Account doesn't exist on target system, but account in IdM was found (missing account).");
    addToItemLog(logItem, MessageFormat.format("Missing account action is {0}", action));
    switch(action) {
        case IGNORE:
            // Ignore we will do nothing
            initSyncActionLog(SynchronizationActionType.MISSING_ACCOUNT, OperationResultType.IGNORE, logItem, log, actionLogs);
            return;
        case CREATE_ACCOUNT:
            doUpdateAccount(account, entityType, log, logItem, actionLogs);
            initSyncActionLog(SynchronizationActionType.CREATE_ACCOUNT, OperationResultType.SUCCESS, logItem, log, actionLogs);
            return;
        case DELETE_ENTITY:
            doDeleteEntity(account, entityType, log, logItem, actionLogs);
            initSyncActionLog(SynchronizationActionType.DELETE_ENTITY, OperationResultType.SUCCESS, logItem, log, actionLogs);
            return;
        case UNLINK:
            doUnlink(account, false, log, logItem, actionLogs);
            initSyncActionLog(SynchronizationActionType.UNLINK, OperationResultType.SUCCESS, logItem, log, actionLogs);
            return;
        case UNLINK_AND_REMOVE_ROLE:
            doUnlink(account, true, log, logItem, actionLogs);
            initSyncActionLog(SynchronizationActionType.UNLINK_AND_REMOVE_ROLE, OperationResultType.SUCCESS, logItem, log, actionLogs);
            return;
    }
}
Also used : SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)

Example 25 with SysSyncActionLogDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto in project CzechIdMng by bcvsolutions.

the class AbstractSynchronizationExecutor method startWorkflow.

/**
 * Start workflow process by wfDefinitionKey. Create input variables and put
 * them to the process. If log variable is present after the process started,
 * then add the log to the synchronization log.
 *
 * @param wfDefinitionKey
 * @param uid
 * @param situation
 * @param action
 * @param icAttributes
 * @param dto
 * @param account
 * @param entityType
 * @param config
 * @param log
 * @param logItem
 * @param actionLogs
 */
private void startWorkflow(String wfDefinitionKey, SynchronizationSituationType situation, SynchronizationActionType action, DTO dto, SynchronizationContext context) {
    SystemEntityType entityType = context.getEntityType();
    SysSyncLogDto log = context.getLog();
    SysSyncItemLogDto logItem = context.getLogItem();
    List<SysSyncActionLogDto> actionLogs = context.getActionLogs();
    AccAccountDto account = context.getAccount();
    String uid = context.getUid();
    AbstractSysSyncConfigDto config = context.getConfig();
    addToItemLog(logItem, MessageFormat.format("Workflow for {0} situation was found. We will start it.", situation));
    Map<String, Object> variables = new HashMap<>();
    variables.put(SynchronizationService.WF_VARIABLE_KEY_UID, uid);
    variables.put(SynchronizationService.WF_VARIABLE_KEY_ENTITY_TYPE, entityType);
    variables.put(SynchronizationService.WF_VARIABLE_KEY_SYNC_SITUATION, situation.name());
    variables.put(SynchronizationService.WF_VARIABLE_KEY_IC_ATTRIBUTES, context.getIcObject().getAttributes());
    variables.put(SynchronizationService.WF_VARIABLE_KEY_ACTION_TYPE, action.name());
    variables.put(SynchronizationService.WF_VARIABLE_KEY_ENTITY_ID, dto != null ? dto.getId() : null);
    variables.put(SynchronizationService.WF_VARIABLE_KEY_ACC_ACCOUNT_ID, account != null ? account.getId() : null);
    variables.put(SynchronizationService.WF_VARIABLE_KEY_SYNC_CONFIG_ID, config.getId());
    ProcessInstance processInstance = workflowProcessInstanceService.startProcess(wfDefinitionKey, SysSyncConfig.class.getSimpleName(), uid, config.getId().toString(), variables);
    if (processInstance instanceof VariableScope) {
        Object logItemObj = ((VariableScope) processInstance).getVariable(SynchronizationService.WF_VARIABLE_KEY_LOG_ITEM);
        if (logItemObj instanceof String) {
            addToItemLog(logItem, (String) logItemObj);
        }
    }
    if (processInstance.isEnded()) {
        addToItemLog(logItem, MessageFormat.format("Workflow (with id {0}) for missing entity situation ended.", processInstance.getId()));
        initSyncActionLog(situation.getAction(), OperationResultType.WF, logItem, log, actionLogs);
    } else {
        addToItemLog(logItem, MessageFormat.format("Workflow (with id {0}) for missing entity situation not ended (will be ended asynchronously).", processInstance.getId()));
        initSyncActionLog(situation.getAction(), OperationResultType.WF, logItem, log, actionLogs);
    }
}
Also used : HashMap(java.util.HashMap) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSyncConfig(eu.bcvsolutions.idm.acc.entity.SysSyncConfig) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) VariableScope(org.activiti.engine.delegate.VariableScope)

Aggregations

SysSyncActionLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto)42 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)41 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)39 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)32 SysSyncActionLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter)27 SysSyncLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter)26 SysSyncItemLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter)25 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)23 Test (org.junit.Test)23 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)21 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)14 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)13 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)11 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)11 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)9 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)9 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)7 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)7 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)6 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)6