Search in sources :

Example 1 with IcObjectPoolConfiguration

use of eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemService method createPoolingFormDefinition.

/**
 * Create form definition for connector pooling configuration
 *
 * @param connectorInstance
 * @return
 */
private synchronized IdmFormDefinitionDto createPoolingFormDefinition(IcConnectorInstance connectorInstance) {
    IcConnectorConfiguration config = icConfigurationFacade.getConnectorConfiguration(connectorInstance);
    String poolingDefinitionCode = getPoolingFormDefinitionCode(connectorInstance);
    if (config == null) {
        throw new IllegalStateException(MessageFormat.format("Connector with key [{0}] was not found!", poolingDefinitionCode));
    }
    // 
    List<IdmFormAttributeDto> formAttributes = new ArrayList<>();
    IcObjectPoolConfiguration poolConfiguration = config.getConnectorPoolConfiguration();
    IdmFormAttributeDto attributePoolingSupported = new IdmFormAttributeDto(POOLING_SUPPORTED_PROPERTY, POOLING_SUPPORTED_NAME, PersistentType.BOOLEAN);
    attributePoolingSupported.setDefaultValue(String.valueOf(false));
    attributePoolingSupported.setSeq((short) 1);
    formAttributes.add(attributePoolingSupported);
    // Max idle objects
    IdmFormAttributeDto attributeMaxIdle = new IdmFormAttributeDto(MAX_IDLE_PROPERTY, MAX_IDLE_NAME, PersistentType.INT);
    if (poolConfiguration != null) {
        attributeMaxIdle.setDefaultValue(String.valueOf(poolConfiguration.getMaxIdle()));
    }
    attributeMaxIdle.setSeq((short) 2);
    formAttributes.add(attributeMaxIdle);
    // Max idle objects
    IdmFormAttributeDto attributeMinIdle = new IdmFormAttributeDto(MIN_IDLE_PROPERTY, MIN_IDLE_NAME, PersistentType.INT);
    if (poolConfiguration != null) {
        attributeMinIdle.setDefaultValue(String.valueOf(poolConfiguration.getMinIdle()));
    }
    attributeMinIdle.setSeq((short) 3);
    formAttributes.add(attributeMinIdle);
    // Max objects (idle + active).
    IdmFormAttributeDto attributeMaxObjects = new IdmFormAttributeDto(MAX_OBJECTS_PROPERTY, MAX_OBJECTS_NAME, PersistentType.INT);
    if (poolConfiguration != null) {
        attributeMaxObjects.setDefaultValue(String.valueOf(poolConfiguration.getMaxObjects()));
    }
    attributeMaxObjects.setSeq((short) 4);
    formAttributes.add(attributeMaxObjects);
    // Max time to wait if the pool is waiting for a free object. Zero means do not wait.
    IdmFormAttributeDto attributeMaxWait = new IdmFormAttributeDto(MAX_WAIT_PROPERTY, MAX_WAIT_NAME, PersistentType.LONG);
    if (poolConfiguration != null) {
        attributeMaxWait.setDefaultValue(String.valueOf(poolConfiguration.getMaxWait()));
    }
    attributeMaxWait.setSeq((short) 5);
    formAttributes.add(attributeMaxWait);
    // Minimum time to wait before evicting idle objects. Zero means do not wait.
    IdmFormAttributeDto attributeMinEvicTime = new IdmFormAttributeDto(MIN_TIME_TO_EVIC_PROPERTY, MIN_TIME_TO_EVIC_NAME, PersistentType.LONG);
    if (poolConfiguration != null) {
        attributeMinEvicTime.setDefaultValue(String.valueOf(poolConfiguration.getMinEvictableIdleTimeMillis()));
    }
    attributeMinEvicTime.setSeq((short) 6);
    formAttributes.add(attributeMinEvicTime);
    return getFormService().createDefinition(SysSystem.class, poolingDefinitionCode, formAttributes);
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) ArrayList(java.util.ArrayList) IcObjectPoolConfiguration(eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString)

Example 2 with IcObjectPoolConfiguration

use of eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemService method fillPoolingConnectorConfiguration.

/**
 * Creates configuration for pool by EAV values
 *
 * @param configuration
 * @param connectorInstance
 * @param system
 */
private void fillPoolingConnectorConfiguration(IcConnectorConfigurationImpl configuration, IcConnectorInstance connectorInstance, SysSystemDto system) {
    IdmFormDefinitionDto formDefinition = getPoolingConnectorFormDefinition(connectorInstance);
    if (formDefinition == null) {
        return;
    }
    IdmFormInstanceDto formInstance = getFormService().getFormInstance(system, formDefinition);
    if (formInstance == null) {
        return;
    }
    IcObjectPoolConfiguration connectorPoolConfiguration = configuration.getConnectorPoolConfiguration();
    if (connectorPoolConfiguration == null) {
        connectorPoolConfiguration = new IcObjectPoolConfigurationImpl();
    }
    Serializable poolingSupported = formInstance.toSinglePersistentValue(POOLING_SUPPORTED_PROPERTY);
    if (poolingSupported instanceof Boolean) {
        configuration.setConnectorPoolingSupported(((Boolean) poolingSupported).booleanValue());
    } else {
        configuration.setConnectorPoolingSupported(false);
    }
    configuration.setConnectorPoolConfiguration(connectorPoolConfiguration);
    Serializable minIdle = formInstance.toSinglePersistentValue(MIN_IDLE_PROPERTY);
    if (minIdle instanceof Integer) {
        connectorPoolConfiguration.setMinIdle((int) minIdle);
    }
    Serializable minEvicTime = formInstance.toSinglePersistentValue(MIN_TIME_TO_EVIC_PROPERTY);
    if (minEvicTime instanceof Long) {
        connectorPoolConfiguration.setMinEvictableIdleTimeMillis((long) minEvicTime);
    }
    Serializable maxIdle = formInstance.toSinglePersistentValue(MAX_IDLE_PROPERTY);
    if (maxIdle instanceof Integer) {
        connectorPoolConfiguration.setMaxIdle((int) maxIdle);
    }
    Serializable maxObjects = formInstance.toSinglePersistentValue(MAX_OBJECTS_PROPERTY);
    if (maxObjects instanceof Integer) {
        connectorPoolConfiguration.setMaxObjects((int) maxObjects);
    }
    Serializable maxWait = formInstance.toSinglePersistentValue(MAX_WAIT_PROPERTY);
    if (maxWait instanceof Long) {
        connectorPoolConfiguration.setMaxWait((long) maxWait);
    }
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) Serializable(java.io.Serializable) IcObjectPoolConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcObjectPoolConfigurationImpl) IcObjectPoolConfiguration(eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)

Example 3 with IcObjectPoolConfiguration

use of eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemServiceIntegrationTest method testPoolingConnectorConfiguration.

@Test
public void testPoolingConnectorConfiguration() {
    // create test system
    SysSystemDto system = helper.createTestResourceSystem(true);
    IdmFormDefinitionDto formDefinition = systemService.getPoolingConnectorFormDefinition(system);
    Assert.assertNotNull(formDefinition);
    systemService.save(system);
    List<IdmFormValueDto> values = formService.getValues(system, formDefinition);
    Assert.assertNotNull(values);
    Assert.assertEquals(0, values.size());
    values = Lists.newArrayList();
    IdmFormValueDto formValueDto = new IdmFormValueDto(formService.getAttribute(formDefinition, SysSystemService.POOLING_SUPPORTED_PROPERTY));
    // Change value
    formValueDto.setValue(true);
    values.add(formValueDto);
    formValueDto = new IdmFormValueDto(formService.getAttribute(formDefinition, SysSystemService.MAX_IDLE_PROPERTY));
    // Change value
    formValueDto.setValue(111);
    values.add(formValueDto);
    formValueDto = new IdmFormValueDto(formService.getAttribute(formDefinition, SysSystemService.MAX_OBJECTS_PROPERTY));
    // Change value
    formValueDto.setValue(222);
    values.add(formValueDto);
    formValueDto = new IdmFormValueDto(formService.getAttribute(formDefinition, SysSystemService.MIN_IDLE_PROPERTY));
    // Change value
    formValueDto.setValue(333);
    values.add(formValueDto);
    formValueDto = new IdmFormValueDto(formService.getAttribute(formDefinition, SysSystemService.MAX_WAIT_PROPERTY));
    // Change value
    formValueDto.setValue((long) 444);
    values.add(formValueDto);
    formValueDto = new IdmFormValueDto(formService.getAttribute(formDefinition, SysSystemService.MIN_TIME_TO_EVIC_PROPERTY));
    // Change value
    formValueDto.setValue((long) 555);
    values.add(formValueDto);
    // Save all values
    formService.saveValues(system, formDefinition, values);
    IcConnectorConfiguration connectorConfiguration = systemService.getConnectorConfiguration(system);
    Assert.assertNotNull(connectorConfiguration);
    Assert.assertTrue(connectorConfiguration.isConnectorPoolingSupported());
    IcObjectPoolConfiguration poolConfiguration = connectorConfiguration.getConnectorPoolConfiguration();
    Assert.assertNotNull(poolConfiguration);
    Assert.assertEquals(111, poolConfiguration.getMaxIdle());
    Assert.assertEquals(222, poolConfiguration.getMaxObjects());
    Assert.assertEquals(333, poolConfiguration.getMinIdle());
    Assert.assertEquals(444, poolConfiguration.getMaxWait());
    Assert.assertEquals(555, poolConfiguration.getMinEvictableIdleTimeMillis());
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcObjectPoolConfiguration(eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 4 with IcObjectPoolConfiguration

use of eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration in project CzechIdMng by bcvsolutions.

the class SystemExportBulkActionIntegrationTest method testExportAndImportConnectorPoolingConfigs.

@Test
public void testExportAndImportConnectorPoolingConfigs() {
    SysSystemDto system = createSystem();
    IdmFormDefinitionDto formDefinition = systemService.getPoolingConnectorFormDefinition(system);
    Assert.assertNotNull(formDefinition);
    systemService.save(system);
    List<IdmFormValueDto> values = formService.getValues(system, formDefinition);
    Assert.assertNotNull(values);
    Assert.assertEquals(0, values.size());
    values = Lists.newArrayList();
    IdmFormValueDto formValueDto = new IdmFormValueDto(formService.getAttribute(formDefinition, SysSystemService.POOLING_SUPPORTED_PROPERTY));
    // Change value
    formValueDto.setValue(true);
    values.add(formValueDto);
    formValueDto = new IdmFormValueDto(formService.getAttribute(formDefinition, SysSystemService.MAX_IDLE_PROPERTY));
    // Change value
    formValueDto.setValue(111);
    values.add(formValueDto);
    formValueDto = new IdmFormValueDto(formService.getAttribute(formDefinition, SysSystemService.MAX_OBJECTS_PROPERTY));
    // Change value
    formValueDto.setValue(222);
    values.add(formValueDto);
    formValueDto = new IdmFormValueDto(formService.getAttribute(formDefinition, SysSystemService.MIN_IDLE_PROPERTY));
    // Change value
    formValueDto.setValue(333);
    values.add(formValueDto);
    formValueDto = new IdmFormValueDto(formService.getAttribute(formDefinition, SysSystemService.MAX_WAIT_PROPERTY));
    // Change value
    formValueDto.setValue((long) 444);
    values.add(formValueDto);
    formValueDto = new IdmFormValueDto(formService.getAttribute(formDefinition, SysSystemService.MIN_TIME_TO_EVIC_PROPERTY));
    // Change value
    formValueDto.setValue((long) 555);
    values.add(formValueDto);
    // Save all values
    formService.saveValues(system, formDefinition, values);
    IcConnectorConfiguration connectorConfiguration = systemService.getConnectorConfiguration(system);
    Assert.assertNotNull(connectorConfiguration);
    Assert.assertTrue(connectorConfiguration.isConnectorPoolingSupported());
    IcObjectPoolConfiguration poolConfiguration = connectorConfiguration.getConnectorPoolConfiguration();
    Assert.assertNotNull(poolConfiguration);
    Assert.assertEquals(111, poolConfiguration.getMaxIdle());
    Assert.assertEquals(222, poolConfiguration.getMaxObjects());
    Assert.assertEquals(333, poolConfiguration.getMinIdle());
    Assert.assertEquals(444, poolConfiguration.getMaxWait());
    Assert.assertEquals(555, poolConfiguration.getMinEvictableIdleTimeMillis());
    // Make export, upload, delete system and import
    executeExportAndImport(system, SystemExportBulkAction.NAME);
    system = systemService.get(system.getId());
    Assert.assertNotNull(system);
    connectorConfiguration = systemService.getConnectorConfiguration(system);
    Assert.assertNotNull(connectorConfiguration);
    Assert.assertTrue(connectorConfiguration.isConnectorPoolingSupported());
    poolConfiguration = connectorConfiguration.getConnectorPoolConfiguration();
    Assert.assertNotNull(poolConfiguration);
    Assert.assertEquals(111, poolConfiguration.getMaxIdle());
    Assert.assertEquals(222, poolConfiguration.getMaxObjects());
    Assert.assertEquals(333, poolConfiguration.getMinIdle());
    Assert.assertEquals(444, poolConfiguration.getMaxWait());
    Assert.assertEquals(555, poolConfiguration.getMinEvictableIdleTimeMillis());
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcObjectPoolConfiguration(eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractExportBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractExportBulkActionTest) Test(org.junit.Test)

Example 5 with IcObjectPoolConfiguration

use of eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration in project CzechIdMng by bcvsolutions.

the class ConnIdIcConvertUtil method convertIcPoolConfiguration.

public static ObjectPoolConfiguration convertIcPoolConfiguration(IcObjectPoolConfiguration pool) {
    if (pool == null) {
        return null;
    }
    ObjectPoolConfiguration dto = new ObjectPoolConfiguration();
    dto.setMaxIdle(pool.getMaxIdle());
    dto.setMaxObjects(pool.getMaxObjects());
    dto.setMaxWait(pool.getMaxWait());
    dto.setMinEvictableIdleTimeMillis(pool.getMinEvictableIdleTimeMillis());
    dto.setMinIdle(pool.getMinIdle());
    return dto;
}
Also used : IcObjectPoolConfiguration(eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration) ObjectPoolConfiguration(org.identityconnectors.common.pooling.ObjectPoolConfiguration)

Aggregations

IcObjectPoolConfiguration (eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration)5 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)3 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)3 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)2 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)2 Test (org.junit.Test)2 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)1 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)1 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)1 IcObjectPoolConfigurationImpl (eu.bcvsolutions.idm.ic.impl.IcObjectPoolConfigurationImpl)1 AbstractExportBulkActionTest (eu.bcvsolutions.idm.test.api.AbstractExportBulkActionTest)1 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)1 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 ObjectPoolConfiguration (org.identityconnectors.common.pooling.ObjectPoolConfiguration)1