Search in sources :

Example 41 with SysSyncItemLogDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto 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");
    nodeFilter.setTreeTypeId(DtoUtils.getEmbedded(syncConfigCustom, SysSyncConfig_.systemMapping, SysSystemMappingDto.class).getTreeType());
    IdmTreeNodeDto treeNode = treeNodeService.find(nodeFilter, null).getContent().get(0);
    Assert.assertEquals("111", treeNode.getCode());
    helper.startSynchronization(syncConfigCustom);
    // 
    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 42 with SysSyncItemLogDto

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

the class AbstractSynchronizationExecutor method findAccount.

private AccAccountDto findAccount(SynchronizationContext context) {
    String uid = context.getUid();
    SysSystemDto system = context.getSystem();
    SysSyncItemLogDto logItem = context.getLogItem();
    SysSystemEntityDto systemEntity = context.getSystemEntity();
    AccAccountFilter accountFilter = new AccAccountFilter();
    accountFilter.setSystemId(system.getId());
    List<AccAccountDto> accounts = null;
    if (systemEntity != null) {
        // System entity for this uid was found. We will find account
        // for this system entity.
        addToItemLog(logItem, MessageFormat.format("System entity [{1}] for this UID [{0}] was found. We try to find account for this system entity", uid, systemEntity.getId()));
        accountFilter.setSystemEntityId(systemEntity.getId());
        accounts = accountService.find(accountFilter, null).getContent();
    }
    if (CollectionUtils.isEmpty(accounts)) {
        // System entity was not found. We will find account by generated UID directly.
        // Generate UID value from mapped attribute marked as UID (Unique ID).
        // UID mapped attribute must exist and returned value must be not null
        // and must be String
        String attributeUid = this.generateUID(context);
        addToItemLog(logItem, MessageFormat.format("Account was not found. We try to find account for UID [{0}] (generated from the mapped attribute marked as Identifier)", attributeUid));
        accountFilter.setUid(attributeUid);
        accountFilter.setSystemEntityId(null);
        accounts = accountService.find(accountFilter, null).getContent();
    }
    if (accounts != null && accounts.size() > 1) {
        throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TO_MANY_ACC_ACCOUNT, uid);
    }
    if (accounts != null && !accounts.isEmpty()) {
        return accounts.get(0);
    }
    return null;
}
Also used : AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 43 with SysSyncItemLogDto

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

the class DefaultSynchronizationService method resolveMissingAccountSituation.

@Override
public SysSyncItemLogDto resolveMissingAccountSituation(String uid, SystemEntityType entityType, UUID accountId, UUID configId, String actionType) {
    Assert.notNull(uid, "Uid is required.");
    Assert.notNull(entityType, "Entity type is required.");
    Assert.notNull(configId, "Configuration identifier is required.");
    Assert.notNull(actionType, "Action type is required.");
    Assert.notNull(accountId, "Account identifier is required.");
    AbstractSysSyncConfigDto config = synchronizationConfigService.get(configId);
    SysSystemMappingDto mapping = systemMappingService.get(config.getSystemMapping());
    AccAccountDto account = accountService.get(accountId);
    SysSchemaObjectClassDto sysSchemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
    SysSystemDto system = DtoUtils.getEmbedded(sysSchemaObjectClassDto, SysSchemaObjectClass_.system);
    SysSyncItemLogDto itemLog = new SysSyncItemLogDto();
    SynchronizationContext context = new SynchronizationContext();
    // 
    context.addUid(uid).addSystem(// 
    system).addConfig(// 
    config).addEntityType(// 
    entityType).addAccount(// 
    account).addLogItem(// 
    itemLog);
    getSyncExecutor(entityType, configId).resolveMissingAccountSituation(ReconciliationMissingAccountActionType.valueOf(actionType), context);
    return itemLog;
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SynchronizationContext(eu.bcvsolutions.idm.acc.domain.SynchronizationContext) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 44 with SysSyncItemLogDto

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

the class DefaultSynchronizationService method resolveLinkedSituation.

@Override
public SysSyncItemLogDto resolveLinkedSituation(String uid, SystemEntityType entityType, List<IcAttribute> icAttributes, UUID accountId, UUID configId, String actionType) {
    Assert.notNull(uid, "Uid is required.");
    Assert.notNull(entityType, "Entity type is required.");
    Assert.notNull(icAttributes, "Connector attribues are required.");
    Assert.notNull(configId, "Configuration identifier is required.");
    Assert.notNull(actionType, "Action type is required.");
    Assert.notNull(accountId, "Account identifier is required.");
    SysSyncItemLogDto itemLog = new SysSyncItemLogDto();
    AbstractSysSyncConfigDto config = synchronizationConfigService.get(configId);
    SysSystemMappingDto mapping = systemMappingService.get(config.getSystemMapping());
    AccAccountDto account = accountService.get(accountId);
    SysSystemAttributeMappingFilter attributeHandlingFilter = new SysSystemAttributeMappingFilter();
    attributeHandlingFilter.setSystemMappingId(mapping.getId());
    List<SysSystemAttributeMappingDto> mappedAttributes = attributeHandlingService.find(attributeHandlingFilter, null).getContent();
    // Little workaround, we have only IcAttributes ... we create IcObject manually
    IcConnectorObjectImpl icObject = new IcConnectorObjectImpl();
    icObject.setAttributes(icAttributes);
    icObject.setUidValue(uid);
    SynchronizationContext context = new SynchronizationContext();
    // 
    context.addUid(uid).addAccount(// 
    account).addConfig(// 
    config).addEntityType(// 
    entityType).addLogItem(// 
    itemLog).addMappedAttributes(// 
    mappedAttributes).addIcObject(// 
    icObject);
    getSyncExecutor(entityType, configId).resolveLinkedSituation(SynchronizationLinkedActionType.valueOf(actionType), context);
    return itemLog;
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SynchronizationContext(eu.bcvsolutions.idm.acc.domain.SynchronizationContext) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl)

Example 45 with SysSyncItemLogDto

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

the class DefaultSynchronizationService method resolveUnlinkedSituation.

@Override
public SysSyncItemLogDto resolveUnlinkedSituation(String uid, SystemEntityType entityType, UUID entityId, UUID configId, String actionType, List<IcAttribute> icAttributes) {
    Assert.notNull(uid, "Uid is required.");
    Assert.notNull(entityType, "Entity type is required.");
    Assert.notNull(configId, "Configuration identifier is required.");
    Assert.notNull(actionType, "Action type is required.");
    Assert.notNull(entityId, "Entity identifier is required.");
    AbstractSysSyncConfigDto config = synchronizationConfigService.get(configId);
    SysSystemMappingDto mapping = systemMappingService.get(config.getSystemMapping());
    SysSchemaObjectClassDto sysSchemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
    SysSystemDto system = DtoUtils.getEmbedded(sysSchemaObjectClassDto, SysSchemaObjectClass_.system);
    SysSystemEntityDto systemEntity = findSystemEntity(uid, system, entityType);
    SysSyncItemLogDto itemLog = new SysSyncItemLogDto();
    SysSystemAttributeMappingFilter attributeHandlingFilter = new SysSystemAttributeMappingFilter();
    attributeHandlingFilter.setSystemMappingId(mapping.getId());
    List<SysSystemAttributeMappingDto> mappedAttributes = attributeHandlingService.find(attributeHandlingFilter, null).getContent();
    // Little workaround, we have only IcAttributes ... we create IcObject manually
    IcConnectorObjectImpl icObject = new IcConnectorObjectImpl();
    icObject.setAttributes(icAttributes);
    icObject.setUidValue(uid);
    SynchronizationContext context = new SynchronizationContext();
    // 
    context.addUid(uid).addSystem(// 
    system).addConfig(// 
    config).addEntityType(// 
    entityType).addEntityId(// 
    entityId).addLogItem(// 
    itemLog).addSystemEntity(// 
    systemEntity).addIcObject(// 
    icObject).addMappedAttributes(// 
    mappedAttributes);
    getSyncExecutor(entityType, configId).resolveUnlinkedSituation(SynchronizationUnlinkedActionType.valueOf(actionType), context);
    return itemLog;
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SynchronizationContext(eu.bcvsolutions.idm.acc.domain.SynchronizationContext) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Aggregations

SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)60 SysSyncActionLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto)43 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)43 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)38 SysSyncActionLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter)29 SysSyncItemLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter)27 SysSyncLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter)26 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)24 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)24 Test (org.junit.Test)24 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)20 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)19 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)17 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)16 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)13 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)12 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)11 UUID (java.util.UUID)11 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)10 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)10