Search in sources :

Example 1 with SystemEvent

use of eu.bcvsolutions.idm.acc.event.SystemEvent in project CzechIdMng by bcvsolutions.

the class SysSystemController method duplicate.

@ResponseBody
@PreAuthorize("hasAuthority('" + AccGroupPermission.SYSTEM_UPDATE + "')")
@RequestMapping(value = "/{backendId}/duplicate", method = RequestMethod.POST)
@ApiOperation(value = "Create system duplicate (copy)", nickname = "duplicateSystem", tags = { SysSystemController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_UPDATE, description = "") }) }, notes = "Creates system duplicate with all configurations - connector, schemas, mappings etc.. Duplicate is disabled by default.")
public ResponseEntity<?> duplicate(@ApiParam(value = "System's uuid identifier or code.", required = true) @PathVariable @NotNull String backendId) {
    SysSystemDto system = getDto(backendId);
    if (system == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
    }
    EntityEvent<SysSystemDto> event = new SystemEvent(SystemEventType.DUPLICATE, system);
    SysSystemDto duplicate = systemService.publish(event, IdmBasePermission.UPDATE).getContent();
    return new ResponseEntity<>(toResource(duplicate), HttpStatus.OK);
}
Also used : SystemEvent(eu.bcvsolutions.idm.acc.event.SystemEvent) ResponseEntity(org.springframework.http.ResponseEntity) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with SystemEvent

use of eu.bcvsolutions.idm.acc.event.SystemEvent in project CzechIdMng by bcvsolutions.

the class VsSpecificDuplicationProcessorIntegrationTest method testVsConfigurationDuplication.

@Test
public void testVsConfigurationDuplication() {
    SysSystemDto origSystem = helper.createVirtualSystem(helper.createName());
    EntityEvent<SysSystemDto> event = new SystemEvent(SystemEventType.DUPLICATE, origSystem);
    SysSystemDto newSystem = systemService.publish(event).getContent();
    Assert.assertNotNull(newSystem);
    Assert.assertNotEquals(origSystem.getId(), newSystem.getId());
    String type = VsAccount.class.getName();
    String origKey = vsSystemService.createVsFormDefinitionKey(origSystem);
    String newKey = vsSystemService.createVsFormDefinitionKey(newSystem);
    IdmFormDefinitionDto origFormDef = formService.getDefinition(type, origKey);
    IdmFormDefinitionDto newFormDef = formService.getDefinition(type, newKey);
    Assert.assertNotNull(origFormDef);
    Assert.assertNotNull(newFormDef);
    Assert.assertNotEquals(origFormDef.getId(), newFormDef.getId());
    Assert.assertTrue(compareFormDefinition(newFormDef, origFormDef));
    List<IdmFormAttributeDto> origFormAttrs = formService.getAttributes(origFormDef);
    List<IdmFormAttributeDto> newFormAttrs = formService.getAttributes(newFormDef);
    Assert.assertEquals(origFormAttrs.size(), newFormAttrs.size());
    Assert.assertTrue(compareFormAttributeLists(origFormAttrs, newFormAttrs));
}
Also used : SystemEvent(eu.bcvsolutions.idm.acc.event.SystemEvent) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 3 with SystemEvent

use of eu.bcvsolutions.idm.acc.event.SystemEvent in project CzechIdMng by bcvsolutions.

the class SystemExportBulkAction method publishExportEvent.

/**
 * Triggers processor for export event
 *
 * @param system
 * @param batch
 */
private void publishExportEvent(SysSystemDto system, IdmExportImportDto batch) {
    SystemEvent event = new SystemEvent(SystemEventType.EXPORT, system);
    event.getProperties().put(SystemProcessor.EXPORT_BATCH_PROPERTY, batch);
    systemService.publish(event, IdmBasePermission.READ);
}
Also used : SystemEvent(eu.bcvsolutions.idm.acc.event.SystemEvent)

Example 4 with SystemEvent

use of eu.bcvsolutions.idm.acc.event.SystemEvent in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemServiceIntegrationTest method duplicateSystem.

@Test
public void duplicateSystem() {
    // create test system
    SysSystemDto system = helper.createTestResourceSystem(true);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    // Number of schema attributes on original system
    int numberOfSchemaAttributesOrig = schemaAttributeService.find(schemaAttributeFilter, null).getContent().size();
    SysSystemMappingDto mappingOrig = helper.getDefaultMapping(system);
    // Number of mapping attributes on original system
    int numberOfMappingAttributesOrig = systemAttributeMappingService.findBySystemMapping(mappingOrig).size();
    EntityEvent<SysSystemDto> event = new SystemEvent(SystemEventType.DUPLICATE, system);
    SysSystemDto duplicatedSystem = systemService.publish(event).getContent();
    // check duplicate
    systemService.checkSystem(duplicatedSystem);
    Assert.assertNotEquals(system.getId(), duplicatedSystem.getId());
    schemaAttributeFilter.setSystemId(duplicatedSystem.getId());
    // Number of schema attributes on duplicated system
    int numberOfSchemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent().size();
    Assert.assertEquals(numberOfSchemaAttributesOrig, numberOfSchemaAttributes);
    SysSystemMappingDto mapping = helper.getDefaultMapping(duplicatedSystem);
    // Number of mapping attributes on duplicated system
    int numberOfMappingAttributes = systemAttributeMappingService.findBySystemMapping(mapping).size();
    Assert.assertEquals(numberOfMappingAttributesOrig, numberOfMappingAttributes);
}
Also used : SystemEvent(eu.bcvsolutions.idm.acc.event.SystemEvent) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 5 with SystemEvent

use of eu.bcvsolutions.idm.acc.event.SystemEvent in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemServiceIntegrationTest method duplicateSystemWithSynchronization.

@Test
public void duplicateSystemWithSynchronization() {
    String syncName = "test-sync-config";
    // create test system
    SysSystemDto system = helper.createTestResourceSystem(true);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(system.getId());
    // Number of schema attributes on original system
    int numberOfSchemaAttributesOrig = schemaAttributeService.find(schemaAttributeFilter, null).getContent().size();
    SysSystemMappingDto mappingOrig = helper.getDefaultMapping(system);
    // Number of mapping attributes on original system
    int numberOfMappingAttributesOrig = systemAttributeMappingService.findBySystemMapping(mappingOrig).size();
    SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
    attributeMappingFilter.setSystemMappingId(mappingOrig.getId());
    List<SysSystemAttributeMappingDto> attributes = schemaAttributeMappingService.find(attributeMappingFilter, null).getContent();
    SysSystemAttributeMappingDto nameAttribute = attributes.stream().filter(attribute -> {
        return attribute.getName().equalsIgnoreCase(TestHelper.ATTRIBUTE_MAPPING_NAME);
    }).findFirst().get();
    SysSystemAttributeMappingDto firstNameAttribute = attributes.stream().filter(attribute -> {
        return attribute.getName().equalsIgnoreCase(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME);
    }).findFirst().get();
    SysSystemAttributeMappingDto emailAttribute = attributes.stream().filter(attribute -> {
        return attribute.getName().equalsIgnoreCase(TestHelper.ATTRIBUTE_MAPPING_EMAIL);
    }).findFirst().get();
    // create synchronization config
    AbstractSysSyncConfigDto syncConfigDuplicate = new SysSyncIdentityConfigDto();
    syncConfigDuplicate.setCustomFilter(true);
    syncConfigDuplicate.setSystemMapping(mappingOrig.getId());
    syncConfigDuplicate.setCorrelationAttribute(nameAttribute.getId());
    syncConfigDuplicate.setTokenAttribute(firstNameAttribute.getId());
    syncConfigDuplicate.setFilterAttribute(emailAttribute.getId());
    syncConfigDuplicate.setReconciliation(true);
    syncConfigDuplicate.setName(syncName);
    syncConfigDuplicate.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
    syncConfigDuplicate.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
    syncConfigDuplicate.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
    syncConfigDuplicate.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
    syncConfigDuplicate = syncConfigService.save(syncConfigDuplicate);
    EntityEvent<SysSystemDto> event = new SystemEvent(SystemEventType.DUPLICATE, system);
    SysSystemDto duplicatedSystem = systemService.publish(event).getContent();
    // check duplicate
    systemService.checkSystem(duplicatedSystem);
    Assert.assertNotEquals(system.getId(), duplicatedSystem.getId());
    schemaAttributeFilter.setSystemId(duplicatedSystem.getId());
    // Number of schema attributes on duplicated system
    int numberOfSchemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent().size();
    Assert.assertEquals(numberOfSchemaAttributesOrig, numberOfSchemaAttributes);
    SysSystemMappingDto mapping = helper.getDefaultMapping(duplicatedSystem);
    // Number of mapping attributes on duplicated system
    int numberOfMappingAttributes = systemAttributeMappingService.findBySystemMapping(mapping).size();
    Assert.assertEquals(numberOfMappingAttributesOrig, numberOfMappingAttributes);
    // check synchronization config
    SysSyncConfigFilter syncFilter = new SysSyncConfigFilter();
    syncFilter.setSystemId(duplicatedSystem.getId());
    List<AbstractSysSyncConfigDto> configs = syncConfigService.find(syncFilter, null).getContent();
    Assert.assertEquals(1, configs.size());
    Assert.assertEquals(1, configs.size());
    AbstractSysSyncConfigDto configNew = configs.get(0);
    Assert.assertFalse(configNew.isEnabled());
    Assert.assertTrue(configNew.isReconciliation());
    Assert.assertEquals(syncName, configNew.getName());
    Assert.assertTrue(configNew.isCustomFilter());
    Assert.assertEquals(syncConfigDuplicate.getLinkedAction(), configNew.getLinkedAction());
    Assert.assertEquals(syncConfigDuplicate.getUnlinkedAction(), configNew.getUnlinkedAction());
    Assert.assertEquals(syncConfigDuplicate.getMissingEntityAction(), configNew.getMissingEntityAction());
    Assert.assertEquals(syncConfigDuplicate.getMissingAccountAction(), configNew.getMissingAccountAction());
    SysSystemAttributeMappingDto correlationAtt = schemaAttributeMappingService.get(configNew.getCorrelationAttribute());
    SysSystemAttributeMappingDto tokenAtt = schemaAttributeMappingService.get(configNew.getTokenAttribute());
    SysSystemAttributeMappingDto filterAtt = schemaAttributeMappingService.get(configNew.getFilterAttribute());
    Assert.assertEquals(nameAttribute.getName(), correlationAtt.getName());
    Assert.assertEquals(nameAttribute.getIdmPropertyName(), correlationAtt.getIdmPropertyName());
    Assert.assertEquals(firstNameAttribute.getName(), tokenAtt.getName());
    Assert.assertEquals(firstNameAttribute.getIdmPropertyName(), tokenAtt.getIdmPropertyName());
    Assert.assertEquals(emailAttribute.getName(), filterAtt.getName());
    Assert.assertEquals(emailAttribute.getIdmPropertyName(), filterAtt.getIdmPropertyName());
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SystemEvent(eu.bcvsolutions.idm.acc.event.SystemEvent) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

SystemEvent (eu.bcvsolutions.idm.acc.event.SystemEvent)6 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)5 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)4 Test (org.junit.Test)4 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)2 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)2 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)2 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)2 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)2 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)1 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)1 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)1 SysSyncIdentityConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto)1 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)1 AccAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)1 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)1 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)1 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)1 IdmAccountDto (eu.bcvsolutions.idm.core.api.dto.IdmAccountDto)1 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1