Skip to content

Commit

Permalink
Fixing multi-value configuration variables for built-in connectors (M…
Browse files Browse the repository at this point in the history
…ID-5399)
  • Loading branch information
semancik committed Sep 24, 2019
1 parent ac5cee2 commit e1b9c5f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
Expand Up @@ -24,6 +24,7 @@
public class DummyItsmIntegrationConnectorConfiguration {

private String uselessString;
private String[] uselessArray;

@ConfigurationProperty
public String getUselessString() {
Expand All @@ -33,6 +34,13 @@ public String getUselessString() {
public void setUselessString(String uselessString) {
this.uselessString = uselessString;
}


@ConfigurationProperty
public String[] getUselessArray() {
return uselessArray;
}

public void setUselessArray(String[] uselessArray) {
this.uselessArray = uselessArray;
}
}
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2017-2018 Evolveum
~ Copyright (c) 2017-2019 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,6 +37,9 @@

<connectorConfiguration>
<conf:uselessString>whatever</conf:uselessString>
<!-- MID-5399 -->
<conf:uselessArray>something1</conf:uselessArray>
<conf:uselessArray>something2</conf:uselessArray>
</connectorConfiguration>

<!-- Static schema definition -->
Expand Down
Expand Up @@ -21,14 +21,11 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.provisioning.ucf.api.*;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;

import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.schema.PrismSchema;
import com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance;
import com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException;
Expand Down Expand Up @@ -201,8 +198,14 @@ private void applyConfigurationToConfigurationClass(PrismContainerValue<?> confi
throw new ConfigurationException("Only properties are supported for now");
}
PrismProperty<?> configurationProperty = (PrismProperty<?>)configurationItem;
Object realValue = configurationProperty.getRealValue();
configurationClassBean.setPropertyValue(configurationProperty.getElementName().getLocalPart(), realValue);
PrismPropertyDefinition<?> configurationPropertyDefinition = configurationProperty.getDefinition();
if (configurationPropertyDefinition != null && configurationPropertyDefinition.isMultiValue()) {
Object[] realValuesArray = configurationProperty.getRealValuesArray(Object.class);
configurationClassBean.setPropertyValue(configurationProperty.getElementName().getLocalPart(), realValuesArray);
} else {
Object realValue = configurationProperty.getRealValue();
configurationClassBean.setPropertyValue(configurationProperty.getElementName().getLocalPart(), realValue);
}
}
connectorBean.setPropertyValue(connectorConfigurationProp.getName(), configurationObject);
}
Expand Down

0 comments on commit e1b9c5f

Please sign in to comment.