use of eu.bcvsolutions.idm.ic.api.IcConfigurationProperties in project CzechIdMng by bcvsolutions.
the class ConnIdIcConvertUtil method convertIcConnectorConfiguration.
public static APIConfiguration convertIcConnectorConfiguration(IcConnectorConfiguration icConf, APIConfiguration defaultConnIdConf) {
if (icConf == null) {
return null;
}
((APIConfigurationImpl) defaultConnIdConf).setConnectorPoolingSupported(icConf.isConnectorPoolingSupported());
defaultConnIdConf.setProducerBufferSize(icConf.getProducerBufferSize());
IcConfigurationProperties properties = icConf.getConfigurationProperties();
ConfigurationProperties connIdProperties = defaultConnIdConf.getConfigurationProperties();
if (properties != null && properties.getProperties() != null) {
for (IcConfigurationProperty icProperty : properties.getProperties()) {
if (connIdProperties != null) {
connIdProperties.setPropertyValue(icProperty.getName(), icProperty.getValue());
}
}
}
ObjectPoolConfiguration connectorPoolConfiguration = convertIcPoolConfiguration(icConf.getConnectorPoolConfiguration());
((APIConfigurationImpl) defaultConnIdConf).setConnectorPoolConfiguration(connectorPoolConfiguration);
Map<String, Object> systemOperationOptions = icConf.getSystemOperationOptions();
boolean disableFilterValidation = false;
if (systemOperationOptions != null && systemOperationOptions.containsKey(IcConnectorConfiguration.DISABLE_FILTER_VALIDATION_KEY)) {
Object valueObj = systemOperationOptions.get(IcConnectorConfiguration.DISABLE_FILTER_VALIDATION_KEY);
if (Boolean.TRUE.equals(valueObj)) {
disableFilterValidation = true;
}
}
// Filter authentication can be turned off because it does not work properly in some cases.
// This option must be enabled for pagination purpose.
defaultConnIdConf.getResultsHandlerConfiguration().setEnableFilteredResultsHandler(!disableFilterValidation);
defaultConnIdConf.getResultsHandlerConfiguration().setFilteredResultsHandlerInValidationMode(!disableFilterValidation);
return defaultConnIdConf;
}
use of eu.bcvsolutions.idm.ic.api.IcConfigurationProperties in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemService method getConnectorConfiguration.
@Override
@Transactional
public IcConnectorConfiguration getConnectorConfiguration(SysSystemDto system) {
Assert.notNull(system, "System is required.");
if (system.getConnectorKey() == null) {
return null;
}
IcConnectorConfiguration connectorConfig = null;
// load connector properties, different between local and remote
IcConnectorInstance connectorInstance = getConnectorInstance(system);
connectorConfig = icConfigurationFacade.getConnectorConfiguration(connectorInstance);
// load filled form values
IdmFormDefinitionDto formDefinition = getConnectorFormDefinition(connectorInstance);
IdmFormInstanceDto formInstance = getFormService().getFormInstance(system, formDefinition);
Map<String, List<IdmFormValueDto>> attributeValues = formInstance.toValueMap();
// fill connector configuration from form values
IcConnectorConfigurationImpl configuration = null;
if (SysSystemService.CONNECTOR_FRAMEWORK_CZECHIDM.equals(connectorInstance.getConnectorKey().getFramework())) {
// For CzechIdM connector framework is needs system ID (exactly for virtual systems).
configuration = new IcConnectorConfigurationCzechIdMImpl();
((IcConnectorConfigurationCzechIdMImpl) configuration).setSystemId(system.getId());
} else {
configuration = new IcConnectorConfigurationImpl();
}
// Create configuration for pool
fillPoolingConnectorConfiguration(configuration, connectorInstance, system);
// Load operation options
configuration.setOperationOptions(getOperationOptionsForSystem(connectorInstance, system));
IcConfigurationProperties properties = new IcConfigurationPropertiesImpl();
configuration.setConfigurationProperties(properties);
//
for (short seq = 0; seq < connectorConfig.getConfigurationProperties().getProperties().size(); seq++) {
IcConfigurationProperty propertyConfig = connectorConfig.getConfigurationProperties().getProperties().get(seq);
IdmFormAttributeDto formAttribute = formInstance.getMappedAttributeByCode(propertyConfig.getName());
List<IdmFormValueDto> eavAttributeValues = attributeValues.get(formAttribute.getCode());
// create property instance from configuration
IcConfigurationProperty property = formPropertyManager.toConnectorProperty(propertyConfig, eavAttributeValues);
if (property.getValue() != null) {
// only filled values to configuration
properties.getProperties().add(property);
}
}
return configuration;
}
use of eu.bcvsolutions.idm.ic.api.IcConfigurationProperties in project CzechIdMng by bcvsolutions.
the class CsvConnectorTypeTest method testCsvSecondStep.
@Test
public void testCsvSecondStep() {
ConnectorTypeDto mockCsvConnectorTypeDto = new ConnectorTypeDto();
mockCsvConnectorTypeDto.setReopened(false);
mockCsvConnectorTypeDto.setId(CsvConnectorType.NAME);
mockCsvConnectorTypeDto.setConnectorName(csvConnectorType.getConnectorName());
ConnectorTypeDto csvConnectorTypeDto = connectorManager.load(mockCsvConnectorTypeDto);
assertNotNull(csvConnectorTypeDto);
csvConnectorTypeDto.getMetadata().put(CsvConnectorType.FILE_PATH, CSV_TEST_FILE);
csvConnectorTypeDto.setWizardStepName(CsvConnectorType.STEP_ONE_CREATE_SYSTEM);
// Execute the first step.
ConnectorTypeDto stepExecutedResult = connectorManager.execute(csvConnectorTypeDto);
// The system had to be created.
BaseDto system = stepExecutedResult.getEmbedded().get(CsvConnectorType.SYSTEM_DTO_KEY);
assertTrue(system instanceof SysSystemDto);
SysSystemDto systemDto = systemService.get(system.getId());
assertNotNull(systemDto);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(systemDto.getId());
schemaAttributeFilter.setName("username");
SysSchemaAttributeDto usernameAttributeDto = schemaAttributeService.find(schemaAttributeFilter, null).getContent().stream().findFirst().orElse(null);
assertNotNull(usernameAttributeDto);
// Set username attribute as primary attribute for second wizard step.
stepExecutedResult.getMetadata().put(CsvConnectorType.PRIMARY_SCHEMA_ATTRIBUTE, usernameAttributeDto.getId().toString());
// Execute the second step.
csvConnectorTypeDto.setWizardStepName(CsvConnectorType.STEP_TWO_SELECT_PK);
csvConnectorTypeDto.getMetadata().put(CsvConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
connectorManager.execute(csvConnectorTypeDto);
// Load connector properties from created system.
IcConnectorConfiguration connectorConfiguration = systemService.getConnectorConfiguration(systemDto);
IcConfigurationProperties configurationProperties = connectorConfiguration.getConfigurationProperties();
// Check uid attribute.
IcConfigurationProperty uidProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_UID.equals(property.getName())).findFirst().orElse(null);
assertNotNull(uidProperty);
// UID attribute have to be "username" now.
assertEquals(usernameAttributeDto.getName(), uidProperty.getValue());
// Delete created system.
systemService.delete(systemDto);
}
use of eu.bcvsolutions.idm.ic.api.IcConfigurationProperties in project CzechIdMng by bcvsolutions.
the class CsvConnectorTypeTest method testCsvFirstStep.
@Test
public void testCsvFirstStep() {
ConnectorTypeDto mockCsvConnectorTypeDto = new ConnectorTypeDto();
mockCsvConnectorTypeDto.setReopened(false);
mockCsvConnectorTypeDto.setId(CsvConnectorType.NAME);
mockCsvConnectorTypeDto.setConnectorName(csvConnectorType.getConnectorName());
ConnectorTypeDto csvConnectorTypeDto = connectorManager.load(mockCsvConnectorTypeDto);
assertNotNull(csvConnectorTypeDto);
csvConnectorTypeDto.getMetadata().put(CsvConnectorType.FILE_PATH, CSV_TEST_FILE);
csvConnectorTypeDto.setWizardStepName(CsvConnectorType.STEP_ONE_CREATE_SYSTEM);
// Execute the first step.
ConnectorTypeDto stepExecutedResult = connectorManager.execute(csvConnectorTypeDto);
// The system had to be created.
BaseDto system = stepExecutedResult.getEmbedded().get(CsvConnectorType.SYSTEM_DTO_KEY);
assertTrue(system instanceof SysSystemDto);
SysSystemDto systemDto = systemService.get(system.getId());
assertNotNull(systemDto);
// Load connector properties from created system.
IcConnectorInstance connectorInstance = systemService.getConnectorInstance(systemDto);
assertEquals("eu.bcvsolutions.idm.connectors.csv.CSVConnConnector", connectorInstance.getConnectorKey().getConnectorName());
IcConnectorConfiguration connectorConfiguration = systemService.getConnectorConfiguration(systemDto);
IcConfigurationProperties configurationProperties = connectorConfiguration.getConfigurationProperties();
// Check source path of CSV.
IcConfigurationProperty sourcePathProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_SOURCE_PATH.equals(property.getName())).findFirst().orElse(null);
assertNotNull(sourcePathProperty);
assertEquals(CSV_TEST_FILE.replace('/', '\\'), ((String) sourcePathProperty.getValue()).replace('/', '\\'));
// Check separator.
IcConfigurationProperty separatorProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_SOURCE_PATH.equals(property.getName())).findFirst().orElse(null);
assertNotNull(separatorProperty);
// Check include headers.
IcConfigurationProperty includeHeadersProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_INCLUDES_HEADERS.equals(property.getName())).findFirst().orElse(null);
assertNotNull(includeHeadersProperty);
// Headers have to be always included in CSV file.
assertEquals(true, includeHeadersProperty.getValue());
// Check uid attribute (in first step has value "...random...").
IcConfigurationProperty uidProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_UID.equals(property.getName())).findFirst().orElse(null);
assertNotNull(uidProperty);
// UID attribute have to be filled, but will be selected in the next wizard step -> is use temporary value "...random...".
assertEquals("...random...", uidProperty.getValue());
// Delete created system.
systemService.delete(systemDto);
}
Aggregations