+ ThrowableUtil.getRootMessage(e));
return;
}
// 2. We will wrap all property-simple and connection properties changes in a composite operation
CompositeOperation updateOperation = new CompositeOperation();
// 3. Capture property-simple changes
Map<String, PropertySimple> newConfigSimpleProperties = newConfig.getSimpleProperties();
Map<String, PropertySimple> currentConfigSimpleProperties = currentConfig.getSimpleProperties();
Set<String> allSimplePropertyNames = new HashSet<String>(newConfigSimpleProperties.size()
+ currentConfigSimpleProperties.size());
allSimplePropertyNames.addAll(newConfigSimpleProperties.keySet());
allSimplePropertyNames.addAll(currentConfigSimpleProperties.keySet());
// Read-only
allSimplePropertyNames.remove(ENABLED_ATTRIBUTE);
if (getServerComponent().getServerPluginConfiguration().getProductType() == JBossProductType.AS) {
// Only supported on EAP
allSimplePropertyNames.remove(ALLOW_MULTIPLE_USERS_ATTRIBUTE);
allSimplePropertyNames.remove(TRACK_STATEMENTS_ATTRIBUTE);
}
for (String simplePropertyName : allSimplePropertyNames) {
PropertySimple newConfigPropertySimple = newConfigSimpleProperties.get(simplePropertyName);
String newConfigPropertySimpleValue = newConfigPropertySimple == null ? null : newConfigPropertySimple
.getStringValue();
PropertySimple currentConfigPropertySimple = currentConfigSimpleProperties.get(simplePropertyName);
String currentConfigPropertySimpleValue = currentConfigPropertySimple == null ? null
: currentConfigPropertySimple.getStringValue();
boolean canUnset = !UNSET_FORBIDDEN_ATTRIBUTES.contains(simplePropertyName);
if (newConfigPropertySimpleValue == null) {
if (currentConfigPropertySimpleValue != null) {
String val;
if (canUnset) {
val = null;
} else {
val = configDef.getPropertyDefinitionSimple(simplePropertyName).getDefaultValue();
}
updateOperation.addStep(new WriteAttribute(getAddress(), simplePropertyName, val));
}
} else if (!newConfigPropertySimpleValue.equals(currentConfigPropertySimpleValue)) {
updateOperation.addStep(new WriteAttribute(getAddress(), simplePropertyName,
newConfigPropertySimpleValue));
}
}
// 4. Capture connection property changes
String connPropAttributeNameOnServer, connPropPluginConfigPropertyName, keyName;
if (isXADatasourceResource(resourceType)) {
connPropAttributeNameOnServer = "xa-datasource-properties";
connPropPluginConfigPropertyName = XA_DATASOURCE_PROPERTIES_ATTRIBUTE;
keyName = "key";
} else {
connPropAttributeNameOnServer = "connection-properties";
connPropPluginConfigPropertyName = CONNECTION_PROPERTIES_ATTRIBUTE;
keyName = "pname";
}
Map<String, String> newConfigConnectionProperties = getConnectionPropertiesAsMap(
newConfig.getList(connPropPluginConfigPropertyName), keyName);
Map<String, String> currentConfigConnectionProperties = getConnectionPropertiesAsMap(
currentConfig.getList(connPropPluginConfigPropertyName), keyName);
Set<String> allConnectionPropertyNames = new HashSet<String>(newConfigConnectionProperties.size()
+ currentConfigConnectionProperties.size());
allConnectionPropertyNames.addAll(newConfigConnectionProperties.keySet());
allConnectionPropertyNames.addAll(currentConfigConnectionProperties.keySet());
for (String connectionPropertyName : allConnectionPropertyNames) {
Address propertyAddress = new Address(getAddress());
propertyAddress.add(connPropAttributeNameOnServer, connectionPropertyName);
String newConfigConnectionPropertyValue = newConfigConnectionProperties.get(connectionPropertyName);
String currentConfigConnectionPropertyValue = currentConfigConnectionProperties.get(connectionPropertyName);
if (newConfigConnectionPropertyValue == null) {
updateOperation.addStep(new Operation("remove", propertyAddress));
} else if (currentConfigConnectionPropertyValue == null) {
Operation addOperation = new Operation("add", propertyAddress);
addOperation.addAdditionalProperty("value", newConfigConnectionPropertyValue);
updateOperation.addStep(addOperation);
} else if (!newConfigConnectionPropertyValue.equals(currentConfigConnectionPropertyValue)) {
updateOperation.addStep(new Operation("remove", propertyAddress));
Operation addOperation = new Operation("add", propertyAddress);
addOperation.addAdditionalProperty("value", newConfigConnectionPropertyValue);
updateOperation.addStep(addOperation);
}
}
// 5. Update config if needed
if (updateOperation.numberOfSteps() > 0) {
Result res = getASConnection().execute(updateOperation);
if (res.isSuccess()) {
configurationUpdateReport.setStatus(SUCCESS);
} else {
configurationUpdateReport.setStatus(FAILURE);