Search in sources :

Example 1 with IcConfigurationPropertyImpl

use of eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl in project CzechIdMng by bcvsolutions.

the class ConnIdIcConvertUtil method convertConnIdConnectorConfiguration.

public static IcConnectorConfiguration convertConnIdConnectorConfiguration(APIConfiguration conf) {
    if (conf == null) {
        return null;
    }
    IcConnectorConfigurationImpl dto = new IcConnectorConfigurationImpl();
    dto.setConnectorPoolingSupported(conf.isConnectorPoolingSupported());
    dto.setProducerBufferSize(conf.getProducerBufferSize());
    ConfigurationProperties properties = conf.getConfigurationProperties();
    IcConfigurationPropertiesImpl propertiesDto = new IcConfigurationPropertiesImpl();
    if (properties != null && properties.getPropertyNames() != null) {
        List<String> propertyNames = properties.getPropertyNames();
        for (String name : propertyNames) {
            ConfigurationProperty property = properties.getProperty(name);
            IcConfigurationPropertyImpl propertyDto = (IcConfigurationPropertyImpl) convertConnIdConfigurationProperty(property);
            if (propertiesDto != null) {
                propertiesDto.getProperties().add(propertyDto);
            }
        }
    }
    dto.setConfigurationProperties(propertiesDto);
    IcObjectPoolConfigurationImpl connectorPoolConfiguration = (IcObjectPoolConfigurationImpl) convertConnIdPoolConfiguration(conf.getConnectorPoolConfiguration());
    dto.setConnectorPoolConfiguration(connectorPoolConfiguration);
    dto.setOperationOptions(Collections.emptyMap());
    return dto;
}
Also used : ConfigurationProperty(org.identityconnectors.framework.api.ConfigurationProperty) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) IcConnectorConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl) IcObjectPoolConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcObjectPoolConfigurationImpl) ConfigurationProperties(org.identityconnectors.framework.api.ConfigurationProperties) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) GuardedString(org.identityconnectors.common.security.GuardedString) IcConfigurationPropertiesImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl) IcConfigurationPropertyImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl)

Example 2 with IcConfigurationPropertyImpl

use of eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl in project CzechIdMng by bcvsolutions.

the class ConnIdIcConvertUtil method convertConnIdConfigurationProperty.

public static IcConfigurationProperty convertConnIdConfigurationProperty(ConfigurationProperty property) {
    if (property == null) {
        return null;
    }
    IcConfigurationPropertyImpl dto = new IcConfigurationPropertyImpl();
    dto.setConfidential(property.isConfidential());
    dto.setDisplayName(property.getDisplayName(property.getName()));
    dto.setGroup(property.getGroup(null));
    dto.setHelpMessage(property.getHelpMessage(null));
    dto.setName(property.getName());
    dto.setRequired(property.isRequired());
    dto.setType(property.getType() != null ? property.getType().getName() : null);
    dto.setValue(property.getValue());
    return dto;
}
Also used : IcConfigurationPropertyImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl)

Example 3 with IcConfigurationPropertyImpl

use of eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl in project CzechIdMng by bcvsolutions.

the class CzechIdMIcConfigurationService method initDefaultConfiguration.

/**
 * Create instance of default connector configuration
 *
 * @param configurationClass
 * @return
 */
private IcConnectorConfiguration initDefaultConfiguration(Class<? extends ConfigurationClass> configurationClass) {
    try {
        ConfigurationClass configurationClassInstance = configurationClass.getDeclaredConstructor().newInstance();
        List<IcConfigurationProperty> properties = new ArrayList<>();
        PropertyDescriptor[] descriptors = Introspector.getBeanInfo(configurationClass).getPropertyDescriptors();
        Lists.newArrayList(descriptors).stream().forEach(descriptor -> {
            Method readMethod = descriptor.getReadMethod();
            String propertyName = descriptor.getName();
            ConfigurationClassProperty property = readMethod.getAnnotation(ConfigurationClassProperty.class);
            if (property != null) {
                IcConfigurationPropertyImpl icProperty = (IcConfigurationPropertyImpl) CzechIdMIcConvertUtil.convertConfigurationProperty(property);
                icProperty.setName(propertyName);
                icProperty.setType(readMethod.getGenericReturnType().getTypeName());
                try {
                    icProperty.setValue(readMethod.invoke(configurationClassInstance));
                } catch (IllegalArgumentException | ReflectiveOperationException e) {
                    throw new CoreException("Cannot read value of connector configuration property!", e);
                }
                properties.add(icProperty);
            }
        });
        // Sort by order
        properties.sort(Comparator.comparing(IcConfigurationProperty::getOrder));
        IcConfigurationPropertiesImpl icProperties = new IcConfigurationPropertiesImpl();
        icProperties.setProperties(properties);
        IcConnectorConfigurationImpl configuration = new IcConnectorConfigurationImpl();
        configuration.setConnectorPoolingSupported(false);
        configuration.setConfigurationProperties(icProperties);
        return configuration;
    } catch (IntrospectionException | ReflectiveOperationException e) {
        throw new CoreException("Cannot read connector configuration property!", e);
    }
}
Also used : ConfigurationClass(eu.bcvsolutions.idm.core.api.domain.ConfigurationClass) IcConnectorConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl) PropertyDescriptor(java.beans.PropertyDescriptor) ArrayList(java.util.ArrayList) IntrospectionException(java.beans.IntrospectionException) Method(java.lang.reflect.Method) IcConfigurationPropertiesImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl) ConfigurationClassProperty(eu.bcvsolutions.idm.core.api.domain.ConfigurationClassProperty) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) IcConfigurationPropertyImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl)

Example 4 with IcConfigurationPropertyImpl

use of eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl in project CzechIdMng by bcvsolutions.

the class CzechIdMIcConvertUtil method convertConfigurationProperty.

public static IcConfigurationProperty convertConfigurationProperty(ConfigurationClassProperty property) {
    if (property == null) {
        return null;
    }
    IcConfigurationPropertyImpl icProperty = new IcConfigurationPropertyImpl();
    icProperty.setConfidential(property.confidential());
    icProperty.setDisplayName(property.displayName());
    icProperty.setHelpMessage(property.helpMessage());
    icProperty.setRequired(property.required());
    icProperty.setOrder(property.order());
    icProperty.setFace(property.face());
    return icProperty;
}
Also used : IcConfigurationPropertyImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl)

Example 5 with IcConfigurationPropertyImpl

use of eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl in project CzechIdMng by bcvsolutions.

the class AbstractFormPropertyConverter method toConnectorProperty.

@Override
public IcConfigurationProperty toConnectorProperty(IcConfigurationProperty propertyConfiguration, List<IdmFormValueDto> formValues) {
    Assert.notNull(propertyConfiguration, "Property configuration is required");
    // 
    IcConfigurationPropertyImpl property = new IcConfigurationPropertyImpl();
    property.setName(propertyConfiguration.getName());
    property.setValue(toConnectorPropertyValue(propertyConfiguration, formValues));
    return property;
}
Also used : IcConfigurationPropertyImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl)

Aggregations

IcConfigurationPropertyImpl (eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertyImpl)5 IcConfigurationProperty (eu.bcvsolutions.idm.ic.api.IcConfigurationProperty)2 IcConfigurationPropertiesImpl (eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl)2 IcConnectorConfigurationImpl (eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl)2 ConfigurationClass (eu.bcvsolutions.idm.core.api.domain.ConfigurationClass)1 ConfigurationClassProperty (eu.bcvsolutions.idm.core.api.domain.ConfigurationClassProperty)1 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)1 IcConfigurationProperties (eu.bcvsolutions.idm.ic.api.IcConfigurationProperties)1 IcObjectPoolConfigurationImpl (eu.bcvsolutions.idm.ic.impl.IcObjectPoolConfigurationImpl)1 IntrospectionException (java.beans.IntrospectionException)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 GuardedString (org.identityconnectors.common.security.GuardedString)1 ConfigurationProperties (org.identityconnectors.framework.api.ConfigurationProperties)1 ConfigurationProperty (org.identityconnectors.framework.api.ConfigurationProperty)1