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

Commit

Permalink
[1155991] [EAP5] Unable to create datasource/Queue/Topic via JON
Browse files Browse the repository at this point in the history
We only want to trim the managedProperties when updating ResConfig, not
when creating a resource. In that case all props need to be set
appropriately.

(cherry picked from commit 673af68)
Signed-off-by: Libor Zoubek <lzoubek@redhat.com>
  • Loading branch information
jshaughn authored and Libor Zoubek committed Oct 24, 2014
1 parent dc988e8 commit 04dc2bc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
Expand Up @@ -213,7 +213,7 @@ public Configuration loadResourceConfiguration() {
/**
* updates resource configuration, but only changes. This is done by loading configuration first and then comparing
* all the simple properties (if existing and new value equals, property is skipped)
*
*
* @param configurationUpdateReport report
*/
public void updateResourceConfigurationChangesOnly(ConfigurationUpdateReport configurationUpdateReport) {
Expand Down Expand Up @@ -247,7 +247,7 @@ public void updateResourceConfigurationChangesOnly(ConfigurationUpdateReport con
}

/**
* update resource configuration. Given resourceConfigurationDefinition defines which properties will be updated. Use this
* update resource configuration. Given resourceConfigurationDefinition defines which properties will be updated. Use this
* method in case you don't want to update all properties defined by resource type and supply resourceConfigurationDefinition
* consisting of stuff you want.
* @param configurationUpdateReport
Expand All @@ -265,7 +265,7 @@ protected void updateResourceConfiguration(ConfigurationUpdateReport configurati
LOG.debug("*** BEFORE UPDATE:\n" + DebugUtils.convertPropertiesToString(managedProperties));
}
ConversionUtils.convertConfigurationToManagedProperties(managedProperties, resourceConfig,
resourceConfigurationDefinition, customProps);
resourceConfigurationDefinition, customProps, true);
if (LOG.isDebugEnabled()) {
LOG.debug("*** AFTER UPDATE:\n" + DebugUtils.convertPropertiesToString(managedProperties));
}
Expand Down Expand Up @@ -534,7 +534,7 @@ protected String getComponentName() {
* This method should most likely not be overridden. Instead, override {@link #getManagedComponent(ManagementView)}.
* <br/><br/>
* IMPORTANT!!! The returned ManagedComponent SHOULD NOT be cached in the instance. It is potentially a memory hog.
*
*
* @return The ManagedComponent
* @throws RuntimeException if fetching the ManagementView or getting the component fails
* @throws IllegalStateException if the managedComponent is null/not found
Expand All @@ -551,7 +551,7 @@ protected ManagedComponent getManagedComponent() {
+ this.componentName + "].", e);
}

// Even if not found, update the refresh time. It will avoid too many costly, and potentially fruitless, fetches
// Even if not found, update the refresh time. It will avoid too many costly, and potentially fruitless, fetches
lastComponentRefresh = System.currentTimeMillis();

if (managedComponent == null) {
Expand All @@ -568,7 +568,7 @@ protected ManagedComponent getManagedComponent() {

/**
* This is an override point. When actually fetching the managed component, this entry point should not be
* used. Instead, access should be via {@link #getManagedComponent()}.
* used. Instead, access should be via {@link #getManagedComponent()}.
*
* @param managementView for querying profile service
* @return the ManagedComponent. Null if not found.
Expand Down
Expand Up @@ -86,7 +86,8 @@ public class ConversionUtils {
private static final Map<String, KnownDeploymentTypes> DEPLOYMENT_TYPE_CACHE = new HashMap<String, KnownDeploymentTypes>();
private static final Map<String, Configuration> DEFAULT_PLUGIN_CONFIG_CACHE = new HashMap<String, Configuration>();

public static ComponentType getComponentType(@NotNull ResourceType resourceType) {
public static ComponentType getComponentType(@NotNull
ResourceType resourceType) {
String resourceTypeName = resourceType.getName();
if (COMPONENT_TYPE_CACHE.containsKey(resourceTypeName))
return COMPONENT_TYPE_CACHE.get(resourceTypeName);
Expand All @@ -104,7 +105,8 @@ public static ComponentType getComponentType(@NotNull ResourceType resourceType)
return componentType;
}

public static KnownDeploymentTypes getDeploymentType(@NotNull ResourceType resourceType) {
public static KnownDeploymentTypes getDeploymentType(@NotNull
ResourceType resourceType) {
String resourceTypeName = resourceType.getName();
if (DEPLOYMENT_TYPE_CACHE.containsKey(resourceTypeName))
return DEPLOYMENT_TYPE_CACHE.get(resourceTypeName);
Expand Down Expand Up @@ -168,7 +170,8 @@ public static Configuration convertManagedObjectToConfiguration(Map<String, Mana
}

public static void convertConfigurationToManagedProperties(Map<String, ManagedProperty> managedProperties,
Configuration configuration, ConfigurationDefinition configDefinition, Map<String, PropertySimple> customProps) {
Configuration configuration, ConfigurationDefinition configDefinition, Map<String, PropertySimple> customProps,
boolean trimManagedProperties) {
Set<String> missingManagedPropertyNames = new HashSet<String>();
for (Property property : configuration.getProperties()) {
String propertyName = property.getName();
Expand All @@ -189,21 +192,25 @@ public static void convertConfigurationToManagedProperties(Map<String, ManagedPr
throw new IllegalStateException("***** The following properties are defined in this plugin's "
+ "descriptor but have no corresponding ManagedProperties: " + missingManagedPropertyNames);
}
// remove all managed properties missing in configuration definition
List<String> toRemove = new ArrayList<String>();
for (Entry<String, ManagedProperty> prop : managedProperties.entrySet()) {
if (configDefinition.get(prop.getKey()) == null) {
toRemove.add(prop.getKey());

if (trimManagedProperties) {
// remove all managed properties missing in configuration definition
List<String> toRemove = new ArrayList<String>();
for (Entry<String, ManagedProperty> prop : managedProperties.entrySet()) {
if (configDefinition.get(prop.getKey()) == null) {
toRemove.add(prop.getKey());
}
}
managedProperties.keySet().removeAll(toRemove);
}
managedProperties.keySet().removeAll(toRemove);

return;
}

public static void convertConfigurationToManagedProperties(Map<String, ManagedProperty> managedProperties,
Configuration configuration, ResourceType resourceType, Map<String, PropertySimple> customProps) {
convertConfigurationToManagedProperties(managedProperties, configuration,
resourceType.getResourceConfigurationDefinition(), customProps);
resourceType.getResourceConfigurationDefinition(), customProps, false);
}

private static Configuration getDefaultPluginConfiguration(ResourceType resourceType) {
Expand All @@ -218,7 +225,9 @@ private static Configuration getDefaultPluginConfiguration(ResourceType resource
}

private static void populateManagedPropertyFromProperty(Property property, PropertyDefinition propertyDefinition,
@NotNull ManagedProperty managedProperty, @Nullable PropertySimple customProperty) {
@NotNull
ManagedProperty managedProperty, @Nullable
PropertySimple customProperty) {
// See if there is a custom adapter defined for this property.
PropertyAdapter propertyAdapter = PropertyAdapterFactory.getCustomPropertyAdapter(customProperty);

Expand Down Expand Up @@ -304,8 +313,10 @@ private static MetaType convertPropertySimpleTypeToSimpleMetaType(PropertySimple
* will be returned
*/
@NotNull
public static MetaValue[] convertOperationsParametersToMetaValues(@NotNull ManagedOperation managedOperation,
@NotNull Configuration parameters, @NotNull OperationDefinition operationDefinition) {
public static MetaValue[] convertOperationsParametersToMetaValues(@NotNull
ManagedOperation managedOperation, @NotNull
Configuration parameters, @NotNull
OperationDefinition operationDefinition) {
ConfigurationDefinition paramsConfigDef = operationDefinition.getParametersConfigurationDefinition();
if (paramsConfigDef == null)
return new MetaValue[0];
Expand Down

0 comments on commit 04dc2bc

Please sign in to comment.