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);
}
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));
}
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);
}
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);
}
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());
}
Aggregations