Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #274 from josejulio/bugs/1331538-
Browse files Browse the repository at this point in the history
Bug 1331538 - Error when trying to save RemoteConnectionFactory confi…
  • Loading branch information
burmanm committed Nov 1, 2016
2 parents b9a60ba + 6e7e2b3 commit c47289d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 46 deletions.
Expand Up @@ -95,6 +95,8 @@ public class BaseComponent<T extends ResourceComponent<?>> implements AS7Compone

public static final String MANAGED_SERVER = "Managed Server";

private static final String PROFILE_SUFFIX = " (Profile)";

/**
* @deprecated as of 4.10. Use your own logger or {@link #getLog()} method.
*/
Expand Down Expand Up @@ -952,4 +954,12 @@ public static ComplexRequest create(String requestName) {
public static Log getLog() {
return LOG;
}

public static String resourceTypeNameByRemovingProfileSuffix(String resourceTypeName) {
if (resourceTypeName.endsWith(PROFILE_SUFFIX)) {
resourceTypeName = resourceTypeName.substring(0, resourceTypeName.length() - PROFILE_SUFFIX.length());
}
return resourceTypeName;
}

}
Expand Up @@ -20,17 +20,14 @@
package org.rhq.modules.plugins.wildfly10;

import static org.rhq.core.domain.configuration.ConfigurationUpdateStatus.FAILURE;
import static org.rhq.core.util.StringUtil.EMPTY_STRING;
import static org.rhq.core.util.StringUtil.isNotBlank;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.resource.ResourceType;
Expand All @@ -54,12 +51,13 @@
* @author Stefan Negrea
*/
public class ConnectorDiscoveryGroupValidatorComponent extends BaseComponent<ResourceComponent<?>> {
private static final String DISCOVERY_GROUP_NAME = "discovery-group-name";
private static final String DISCOVERY_GROUP_NAME = "discovery-group";

@Override
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
ResourceType resourceType = context.getResourceType();
String resourceTypeName = resourceType.getName();
resourceTypeName = BaseComponent.resourceTypeNameByRemovingProfileSuffix(resourceTypeName);

ConfigurationUpdateHelper configurationUpdateHelper;
if (resourceTypeName.equals("Connection Factory") || resourceTypeName.equals("Pooled Connection Factory")) {
Expand Down Expand Up @@ -134,8 +132,8 @@ boolean hasDiscoveryGroupName() {
}

private static class ConnectionFactoriesConfigurationUpdateHelper extends ConfigurationUpdateHelper {
static final String CONNECTOR_ATTRIBUTE = "connector";
static final String CONNECTOR_PROPERTY = CONNECTOR_ATTRIBUTE + ":collapsed";
static final String CONNECTOR_ATTRIBUTE = "connectors";
static final String CONNECTOR_PROPERTY = CONNECTOR_ATTRIBUTE;

Address address;

Expand All @@ -151,9 +149,13 @@ String getConnectorPropertyName() {

@Override
boolean isConnectorPropertyDefined() {
PropertyMap connector = configuration.getMap(CONNECTOR_PROPERTY);
if (connector != null) {
return isNotBlank(connector.getSimpleValue("name:0", EMPTY_STRING));
PropertyList connector = configuration.getList(CONNECTOR_PROPERTY);
if (connector != null && connector.getList().size() > 0) {
Property property = connector.getList().get(0);
if (property instanceof PropertySimple) {
PropertySimple propertySimple = (PropertySimple) property;
return isNotBlank(propertySimple.getStringValue());
}
}
return false;
}
Expand All @@ -172,8 +174,17 @@ public Operation getBatchOperation() {
.getSimpleValue(DISCOVERY_GROUP_NAME)));
} else {
compositeOperation.addStep(new UndefineAttribute(address, DISCOVERY_GROUP_NAME));
compositeOperation.addStep(new WriteAttribute(address, CONNECTOR_ATTRIBUTE, Collections.singletonMap(
configuration.getMap(CONNECTOR_PROPERTY).getSimpleValue("name:0", EMPTY_STRING), null)));
List<Property> propertyList = configuration.getList(CONNECTOR_PROPERTY).getList();
List<String> connectors = new ArrayList<String>(propertyList.size());
for (Property property : propertyList) {
if (property instanceof PropertySimple) {
PropertySimple propertySimple = (PropertySimple) property;
connectors.add(propertySimple.getStringValue());
} else {
throw new IllegalArgumentException(property.getName() + " property has unexpected type: " + property.getClass());
}
}
compositeOperation.addStep(new WriteAttribute(address, CONNECTOR_PROPERTY, connectors));
}
return compositeOperation;
}
Expand Down
Expand Up @@ -21,6 +21,8 @@
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;

/**
Expand All @@ -42,6 +44,16 @@ public void updateResourceConfiguration(ConfigurationUpdateReport report) {

//defer the rest of the validation for connector and discovery group name to
//the base class
super.updateResourceConfiguration(report);
// Except for JMS Queue and JMS Topic, those don't have connector or discovery group name.
ResourceType resourceType = context.getResourceType();
String resourceTypeName = resourceType.getName();
resourceTypeName = BaseComponent.resourceTypeNameByRemovingProfileSuffix(resourceTypeName);
if (!resourceTypeName.equals("JMS Queue") && !resourceTypeName.equals("JMS Topic")) {
super.updateResourceConfiguration(report);
} else {
ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
ConfigurationWriteDelegate delegate = new ConfigurationWriteDelegate(configDef, getASConnection(), address);
delegate.updateResourceConfiguration(report);
}
}
}
46 changes: 12 additions & 34 deletions modules/plugins/wfly-10/src/main/resources/META-INF/rhq-plugin.xml
Expand Up @@ -5382,7 +5382,10 @@
<c:simple-property name="pre-acknowledge" required="false" type="boolean" readOnly="false" defaultValue="false" description="True to pre&#45;acknowledge. The default value is false."/>
<c:simple-property name="producer-max-rate:expr" required="false" type="string" readOnly="false" defaultValue="&#45;1" description="The producer max rate. The default value is &#45;1."/>
<c:simple-property name="producer-window-size:expr" required="false" type="string" readOnly="false" defaultValue="65536" description="The producer window size. The default value is 65536."/>
<!--
Currently not working on EAP7, see: https://issues.jboss.org/browse/JBEAP-4506
<c:simple-property name="protocol-manager-factory" required="false" type="string" readOnly="false" description="The protocol manager factory used by this connection factory."/>
-->
<c:simple-property name="reconnect-attempts:expr" required="false" type="string" readOnly="false" defaultValue="0" description="The reconnect attempts. The default value is 0."/>
<c:simple-property name="retry-interval:expr" required="false" type="string" readOnly="false" defaultValue="2000" description="The retry interval. The default value is 2000."/>
<c:simple-property name="retry-interval-multiplier:expr" required="false" type="string" readOnly="false" defaultValue="1.0"
Expand Down Expand Up @@ -5436,16 +5439,6 @@
<c:list-property name="entries" required="true" description="The jndi names the connection factory should be bound to." >
<c:simple-property name="entries" />
</c:list-property>
<c:simple-property name="factory-type" required="false" type="string" readOnly="false" defaultValue="GENERIC" description="The type of connection factory. The default value is GENERIC.">
<c:property-options>
<c:option value="GENERIC" name="GENERIC"/>
<c:option value="QUEUE" name="QUEUE"/>
<c:option value="TOPIC" name="TOPIC"/>
<c:option value="XA_GENERIC" name="XA_GENERIC"/>
<c:option value="XA_QUEUE" name="XA_QUEUE"/>
<c:option value="XA_TOPIC" name="XA_TOPIC"/>
</c:property-options>
</c:simple-property>
<c:simple-property name="failover-on-initial-connection" required="false" type="boolean" readOnly="false" defaultValue="false"
description="True to fail over on initial connection. The default value is false."/>
<c:simple-property name="group-id" required="false" type="string" readOnly="false" description="The group id."/>
Expand Down Expand Up @@ -8390,11 +8383,11 @@
</plugin-configuration>

<resource-configuration>
<c:simple-property name="durable" required="false" type="boolean" readOnly="false" defaultValue="true" description="Whether the queue is durable or not. The default value is true."/>
<c:simple-property name="durable" required="false" type="boolean" readOnly="true" defaultValue="true" description="Whether the queue is durable or not. The default value is true."/>
<c:list-property name="entries" required="true" description="The jndi names the queue will be bound to." >
<c:simple-property name="entry" type="string" description="A single JNDI entry"/>
</c:list-property>
<c:simple-property name="selector" required="false" type="string" readOnly="false" description="The queue selector."/>
<c:simple-property name="selector" required="false" type="string" readOnly="true" description="The queue selector."/>
</resource-configuration>
</service>

Expand Down Expand Up @@ -8475,7 +8468,9 @@
<c:simple-property name="pre-acknowledge" required="false" type="boolean" readOnly="false" defaultValue="false" description="True to pre&#45;acknowledge. The default value is false."/>
<c:simple-property name="producer-max-rate:expr" required="false" type="string" readOnly="false" defaultValue="&#45;1" description="The producer max rate. The default value is &#45;1."/>
<c:simple-property name="producer-window-size:expr" required="false" type="string" readOnly="false" defaultValue="65536" description="The producer window size. The default value is 65536."/>
<!-- Currently not working on EAP7, see: https://issues.jboss.org/browse/JBEAP-4506
<c:simple-property name="protocol-manager-factory" required="false" type="string" readOnly="false" description="The protocol manager factory used by this connection factory."/>
-->
<c:simple-property name="reconnect-attempts:expr" required="false" type="string" readOnly="false" defaultValue="0" description="The reconnect attempts. The default value is 0."/>
<c:simple-property name="retry-interval:expr" required="false" type="string" readOnly="false" defaultValue="2000" description="The retry interval. The default value is 2000."/>
<c:simple-property name="retry-interval-multiplier:expr" required="false" type="string" readOnly="false" defaultValue="1.0"
Expand Down Expand Up @@ -8529,16 +8524,6 @@
<c:list-property name="entries" required="true" description="The jndi names the connection factory should be bound to." >
<c:simple-property name="entries" />
</c:list-property>
<c:simple-property name="factory-type" required="false" type="string" readOnly="false" defaultValue="GENERIC" description="The type of connection factory. The default value is GENERIC.">
<c:property-options>
<c:option value="GENERIC" name="GENERIC"/>
<c:option value="QUEUE" name="QUEUE"/>
<c:option value="TOPIC" name="TOPIC"/>
<c:option value="XA_GENERIC" name="XA_GENERIC"/>
<c:option value="XA_QUEUE" name="XA_QUEUE"/>
<c:option value="XA_TOPIC" name="XA_TOPIC"/>
</c:property-options>
</c:simple-property>
<c:simple-property name="failover-on-initial-connection" required="false" type="boolean" readOnly="false" defaultValue="false"
description="True to fail over on initial connection. The default value is false."/>
<c:simple-property name="group-id" required="false" type="string" readOnly="false" description="The group id."/>
Expand Down Expand Up @@ -14883,11 +14868,11 @@
<metric property="queue-address" dataType="trait" description="The queue address defines what address is used for routing messages."/>

<resource-configuration>
<c:simple-property name="durable" required="false" type="boolean" readOnly="false" defaultValue="true" description="Whether the queue is durable or not. The default value is true."/>
<c:simple-property name="durable" required="false" type="boolean" readOnly="true" defaultValue="true" description="Whether the queue is durable or not. The default value is true."/>
<c:list-property name="entries" required="true" description="The jndi names the queue will be bound to.">
<c:simple-property name="entry" type="string" description="A single JNDI entry"/>
</c:list-property>
<c:simple-property name="selector" required="false" type="string" readOnly="false" description="The queue selector."/>
<c:simple-property name="selector" required="false" type="string" readOnly="true" description="The queue selector."/>
</resource-configuration>
</service>

Expand Down Expand Up @@ -15070,7 +15055,10 @@
<c:simple-property name="pre-acknowledge" required="false" type="boolean" readOnly="false" defaultValue="false" description="True to pre&#45;acknowledge. The default value is false."/>
<c:simple-property name="producer-max-rate:expr" required="false" type="string" readOnly="false" defaultValue="&#45;1" description="The producer max rate. The default value is &#45;1."/>
<c:simple-property name="producer-window-size:expr" required="false" type="string" readOnly="false" defaultValue="65536" description="The producer window size. The default value is 65536."/>
<!--
Currently not supported on EAP7, see: https://issues.jboss.org/browse/JBEAP-4506
<c:simple-property name="protocol-manager-factory" required="false" type="string" readOnly="false" description="The protocol manager factory used by this connection factory."/>
-->
<c:simple-property name="reconnect-attempts:expr" required="false" type="string" readOnly="false" defaultValue="0" description="The reconnect attempts. The default value is 0."/>
<c:simple-property name="retry-interval:expr" required="false" type="string" readOnly="false" defaultValue="2000" description="The retry interval. The default value is 2000."/>
<c:simple-property name="retry-interval-multiplier:expr" required="false" type="string" readOnly="false" defaultValue="1.0"
Expand Down Expand Up @@ -15124,16 +15112,6 @@
<c:list-property name="entries" required="true" description="The jndi names the connection factory should be bound to." >
<c:simple-property name="entries" />
</c:list-property>
<c:simple-property name="factory-type" required="false" type="string" readOnly="false" defaultValue="GENERIC" description="The type of connection factory. The default value is GENERIC.">
<c:property-options>
<c:option value="GENERIC" name="GENERIC"/>
<c:option value="QUEUE" name="QUEUE"/>
<c:option value="TOPIC" name="TOPIC"/>
<c:option value="XA_GENERIC" name="XA_GENERIC"/>
<c:option value="XA_QUEUE" name="XA_QUEUE"/>
<c:option value="XA_TOPIC" name="XA_TOPIC"/>
</c:property-options>
</c:simple-property>
<c:simple-property name="failover-on-initial-connection" required="false" type="boolean" readOnly="false" defaultValue="false"
description="True to fail over on initial connection. The default value is false."/>
<c:simple-property name="group-id" required="false" type="string" readOnly="false" description="The group id."/>
Expand Down

0 comments on commit c47289d

Please sign in to comment.