modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/InputPropertyType.java
| 48 -
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigDefRecipeCommand.java
| 14
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
| 34 +
modules/common/filetemplate-bundle/src/test/java/org/rhq/bundle/filetemplate/recipe/RecipeParserTest.java
| 14
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
| 161 ++++-
modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtilityTest.java
| 322 ++++++++++
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
| 28
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
| 27
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
| 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java
| 79 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
| 16
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
| 3
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16.png
|binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16_Disabled.png
|binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16.png
|binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16_Disabled.png
|binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16.png
|binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16_Disabled.png
|binary
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
| 16
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
| 67 +-
modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
| 1
23 files changed, 747 insertions(+), 103 deletions(-)
New commits:
commit 2c87326ad0fa9449ef0e351e0f241d36ec4566da
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sun Dec 19 18:40:53 2010 -0500
BZ 625198 the bundle deploy wizard needs to show the default values for the config
properties if defaults have been set in the recipe
this code is agnostic to the kind of bundle type it is.
checked in fixes to both filetemplate and ant bundle types (file template now supports
setting default values in configdef command)
diff --git
a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/InputPropertyType.java
b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/InputPropertyType.java
index 2b44a3a..070f02c 100644
---
a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/InputPropertyType.java
+++
b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/InputPropertyType.java
@@ -19,6 +19,7 @@ package org.rhq.bundle.ant.type;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@@ -48,7 +49,8 @@ public class InputPropertyType extends AbstractBundleType {
ConfigurationDefinition configDef = getProject().getConfigurationDefinition();
PropertySimpleType propType = PropertySimpleType.fromXmlName(this.type);
PropertyDefinitionSimple propDef = new PropertyDefinitionSimple(this.name,
this.description, this.required,
- propType);
+ propType);
+ propDef.setDefaultValue(this.defaultValue);
configDef.put(propDef);
String value = getProject().getProperty(this.name);
@@ -61,7 +63,7 @@ public class InputPropertyType extends AbstractBundleType {
if (!parseOnly) {
if (value == null && this.required) {
throw new BuildException("No value was specified for required input
property '" + this.name
- + "', and no default is defined for the
property.");
+ + "', and no default is defined for the property.");
}
validateValue(value, propType);
String valueString = (value != null) ? "'" + value +
"'" : "<null>";
@@ -74,7 +76,7 @@ public class InputPropertyType extends AbstractBundleType {
return;
}
-
+
public String getDescription() {
return description;
}
@@ -145,7 +147,7 @@ public class InputPropertyType extends AbstractBundleType {
validateValue(this.defaultValue, propType);
} catch (RuntimeException e) {
throw new BuildException("Default value '" +
this.defaultValue
- + "' is not valid according to 'type' attribute:
" + this.type, e);
+ + "' is not valid according to 'type' attribute:
" + this.type, e);
}
}
}
@@ -154,28 +156,28 @@ public class InputPropertyType extends AbstractBundleType {
if (value != null) {
try {
switch (propType) {
- case BOOLEAN:
- if (!value.equals(Boolean.TRUE.toString()) &&
!value.equals(Boolean.FALSE.toString())) {
- throw new RuntimeException("Illegal value for boolean
property - value must be 'true' or 'false'."
- + value);
- }
- break;
- case DOUBLE:
- Double.valueOf(value);
- break;
- case FLOAT:
- Float.valueOf(value);
- break;
- case INTEGER:
- Integer.valueOf(value);
- break;
- case LONG:
- Long.valueOf(value);
- break;
+ case BOOLEAN:
+ if (!value.equals(Boolean.TRUE.toString()) &&
!value.equals(Boolean.FALSE.toString())) {
+ throw new RuntimeException(
+ "Illegal value for boolean property - value must be
'true' or 'false'." + value);
+ }
+ break;
+ case DOUBLE:
+ Double.valueOf(value);
+ break;
+ case FLOAT:
+ Float.valueOf(value);
+ break;
+ case INTEGER:
+ Integer.valueOf(value);
+ break;
+ case LONG:
+ Long.valueOf(value);
+ break;
}
} catch (RuntimeException e) {
throw new BuildException("'" + value + "' is not a
legal value for input property '" + this.name
- + "', which has type '" + this.type +
"'.", e);
+ + "', which has type '" + this.type +
"'.", e);
}
}
}
diff --git
a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigDefRecipeCommand.java
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigDefRecipeCommand.java
index 54f297c..59a0984 100644
---
a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigDefRecipeCommand.java
+++
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigDefRecipeCommand.java
@@ -36,10 +36,12 @@ public class ConfigDefRecipeCommand implements RecipeCommand {
}
public void parse(RecipeParser parser, RecipeContext context, String[] args) {
- String sopts = ":n:";
- LongOpt[] lopts = { new LongOpt("name", LongOpt.REQUIRED_ARGUMENT,
null, 'n') };
+ String sopts = ":n:d:";
+ LongOpt[] lopts = { new LongOpt("default", LongOpt.REQUIRED_ARGUMENT,
null, 'd'),
+ new LongOpt("name", LongOpt.REQUIRED_ARGUMENT, null, 'n')
};
String replacementVariableName = null;
+ String defaultValue = null;
Getopt getopt = new Getopt(getName(), args, sopts, lopts);
int code;
@@ -60,6 +62,11 @@ public class ConfigDefRecipeCommand implements RecipeCommand {
break;
}
+ case 'd': {
+ defaultValue = getopt.getOptarg();
+ break;
+ }
+
default: {
throw new IllegalArgumentException("Unexpected error in recipe
command");
}
@@ -75,6 +82,9 @@ public class ConfigDefRecipeCommand implements RecipeCommand {
Set<String> replacementVariableNames = new HashSet<String>(1);
replacementVariableNames.add(replacementVariableName);
context.addReplacementVariables(replacementVariableNames);
+ if (defaultValue != null) {
+ context.assignDefaultValueToReplacementVariable(replacementVariableName,
defaultValue);
+ }
return;
}
diff --git
a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
index e147e45..f6824a1 100644
---
a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
+++
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
@@ -49,6 +49,7 @@ public class RecipeContext {
private final Map<String, String> files;
private final Set<String> realizedFiles;
private final Set<String> replacementVariables;
+ private final Map<String, String> replacementVariableDefaultValues;
private Configuration replacementVariableValues;
private final List<Script> scripts;
private final List<Command> commands;
@@ -62,6 +63,7 @@ public class RecipeContext {
this.files = new HashMap<String, String>();
this.realizedFiles = new HashSet<String>();
this.replacementVariables = new HashSet<String>();
+ this.replacementVariableDefaultValues = new HashMap<String, String>();
this.scripts = new ArrayList<Script>();
this.commands = new ArrayList<Command>();
this.deploymentProperties = new DeploymentProperties();
@@ -172,6 +174,29 @@ public class RecipeContext {
}
/**
+ * If a replacement varaible is known to have a default value, call this
+ * to set that default value.
+ *
+ * @param replacementVariable the variable whose default is being set
+ * @param defaultValue the value of the default for the given replacement variable
+ */
+ public void assignDefaultValueToReplacementVariable(String replacementVariable,
String defaultValue) {
+ this.replacementVariableDefaultValues.put(replacementVariable, defaultValue);
+ }
+
+ /**
+ * Returns a map keyed on replacement variables whose values are the default
+ * values for the replacement variables. Note that not all replacement variables
+ * found in {@link #getReplacementVariables()} will have an associated entry
+ * in the returned map (that is, not all variables have a default value).
+ *
+ * @return the map of all known default values for replacement variables
+ */
+ public Map<String, String> getReplacementVariableDefaultValues() {
+ return this.replacementVariableDefaultValues;
+ }
+
+ /**
* If known, the returned value will contain values that are to be used to replace
* replacement variables found in the recipe.
*
@@ -287,6 +312,15 @@ public class RecipeContext {
}
str.append("\n");
+ str.append("Replacement Default Values: ");
+ Map<String, String> defaults = getReplacementVariableDefaultValues();
+ if (defaults == null) {
+ str.append("<none>");
+ } else {
+ str.append(defaults);
+ }
+ str.append("\n");
+
str.append("Script Files:
").append(getScriptFiles()).append("\n");
for (Script script : this.scripts) {
str.append("* ").append(script.getExecutable()).append("
").append(script.getArguments()).append("\n");
diff --git
a/modules/common/filetemplate-bundle/src/test/java/org/rhq/bundle/filetemplate/recipe/RecipeParserTest.java
b/modules/common/filetemplate-bundle/src/test/java/org/rhq/bundle/filetemplate/recipe/RecipeParserTest.java
index 16054e0..cc277f1 100644
---
a/modules/common/filetemplate-bundle/src/test/java/org/rhq/bundle/filetemplate/recipe/RecipeParserTest.java
+++
b/modules/common/filetemplate-bundle/src/test/java/org/rhq/bundle/filetemplate/recipe/RecipeParserTest.java
@@ -156,6 +156,20 @@ public class RecipeParserTest {
assert vars.size() == 2 : vars;
assert vars.contains("my.first.property");
assert vars.contains("custom.prop");
+ assert context.getReplacementVariableDefaultValues().isEmpty();
+
+ cleanRecipe();
+ addRecipeCommand("configdef -n custom.prop -d 8080");
+ addRecipeCommand("configdef --name another.prop --default
some.default.value");
+ parser = new RecipeParser();
+ context = new RecipeContext(getRecipe());
+ parser.parseRecipe(context);
+ vars = context.getReplacementVariables();
+ assert vars.size() == 2 : vars;
+ assert vars.contains("custom.prop");
+ assert vars.contains("another.prop");
+ assert
context.getReplacementVariableDefaultValues().containsKey("another.prop");
+ assert
context.getReplacementVariableDefaultValues().get("another.prop").equals("some.default.value");
}
public void testRealizeRecipe() throws Exception {
diff --git
a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
index 74a864e..62b5377 100644
---
a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
+++
b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
@@ -1,30 +1,31 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
package org.rhq.core.clientapi.agent.configuration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -36,6 +37,7 @@ 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.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
@@ -47,6 +49,57 @@ import
org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
* @author Ian Springer
*/
public abstract class ConfigurationUtility {
+
+ /**
+ * This will populate the given configuration definition with a default template.
+ * A default template will only be created if one or more properties are required
+ * or have default values. If no property definition is required or has a default
value,
+ * the default template will remain <code>null</code> in the given config
definition.
+ *
+ * Note that if the given configuration definition already has a default template
defined
+ * for it, this method is a no-op and will return immediately.
+ *
+ * @param configDef the configuration definition whose default template is to be
created and set
+ */
+ public static void initializeDefaultTemplate(ConfigurationDefinition configDef) {
+ ConfigurationTemplate defaultTemplate = configDef.getDefaultTemplate();
+ if (defaultTemplate == null) {
+ Configuration defaultConfig = createDefaultConfiguration(configDef);
+ // not everything should have a default template - only stuff that has
default values
+ if (!defaultConfig.getProperties().isEmpty()) {
+ defaultTemplate = new
ConfigurationTemplate(ConfigurationTemplate.DEFAULT_TEMPLATE_NAME,
+ ConfigurationTemplate.DEFAULT_TEMPLATE_NAME);
+ defaultTemplate.setDefault(true);
+ defaultTemplate.setConfiguration(defaultConfig);
+ configDef.putTemplate(defaultTemplate);
+ }
+ }
+ return;
+ }
+
+ /**
+ * Given a configuration definition, this will build and return a "default
configuration" that
+ * can be validated with the definition. All required properties are set and all
properties
+ * that define a default value are also set. If a required property does not have a
default
+ * value defined in the definition, the property value will be set to
<code>null</code>.
+ *
+ * Use this to help create the definition's default template.
+ *
+ * @param configurationDefinition the configuration definition whose default
configuration is to be created
+ * @return configuration the default configuration
+ */
+ public static Configuration createDefaultConfiguration(ConfigurationDefinition
configurationDefinition) {
+ if (configurationDefinition == null) {
+ throw new IllegalArgumentException("configurationDefinition ==
null");
+ }
+ Configuration defaultConfig = new Configuration();
+ Map<String, PropertyDefinition> childPropertyDefinitions =
configurationDefinition.getPropertyDefinitions();
+ for (PropertyDefinition childPropertyDefinition :
childPropertyDefinitions.values()) {
+ createDefaultProperty(childPropertyDefinition, defaultConfig);
+ }
+ return defaultConfig;
+ }
+
/**
* "Normalize" the given configuration according to the given configuration
definition. That is, for any optional
* properties that are not defined in the top-level configuration Map or any
sub-Maps, set them. Simple properties
@@ -55,9 +108,8 @@ public abstract class ConfigurationUtility {
* @param configuration the configuration to be normalized
* @param configurationDefinition the configuration definition to normalize the
configuration against
*/
- public static void normalizeConfiguration(@NotNull
- Configuration configuration, @Nullable
- ConfigurationDefinition configurationDefinition) {
+ public static void normalizeConfiguration(@NotNull Configuration configuration,
+ @Nullable ConfigurationDefinition configurationDefinition) {
//noinspection ConstantConditions
if (configuration == null) {
throw new IllegalArgumentException("Configuration parameter is
null.");
@@ -82,9 +134,8 @@ public abstract class ConfigurationUtility {
* @return a list of messages describing any errors that were found
*/
@NotNull
- public static List<String> validateConfiguration(@NotNull
- Configuration configuration, @Nullable
- ConfigurationDefinition configurationDefinition) {
+ public static List<String> validateConfiguration(@NotNull Configuration
configuration,
+ @Nullable ConfigurationDefinition configurationDefinition) {
List<String> errorMessages = new ArrayList<String>();
if (configurationDefinition != null) {
Map<String, PropertyDefinition> childPropertyDefinitions =
configurationDefinition.getPropertyDefinitions();
@@ -95,6 +146,60 @@ public abstract class ConfigurationUtility {
return errorMessages;
}
+ private static void createDefaultProperty(PropertyDefinition propertyDefinition,
+ AbstractPropertyMap parentPropertyMap) {
+
+ Property property = null;
+
+ if (propertyDefinition instanceof PropertyDefinitionSimple) {
+ String defaultValue = ((PropertyDefinitionSimple)
propertyDefinition).getDefaultValue();
+ if (defaultValue != null || propertyDefinition.isRequired()) {
+ property = new PropertySimple(propertyDefinition.getName(),
defaultValue);
+ }
+ } else if (propertyDefinition.isRequired()) {
+ if (propertyDefinition instanceof PropertyDefinitionMap) {
+ property = new PropertyMap(propertyDefinition.getName());
+ Map<String, PropertyDefinition> childPropertyDefinitions =
((PropertyDefinitionMap) propertyDefinition)
+ .getPropertyDefinitions();
+ for (PropertyDefinition childPropertyDefinition :
childPropertyDefinitions.values()) {
+ createDefaultProperty(childPropertyDefinition, (PropertyMap)
property);
+ }
+ } else if (propertyDefinition instanceof PropertyDefinitionList) {
+ property = new PropertyList(propertyDefinition.getName());
+ PropertyDefinition listMemberPropertyDefinition =
((PropertyDefinitionList) propertyDefinition)
+ .getMemberDefinition();
+ if (listMemberPropertyDefinition.isRequired()) {
+ if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
+ // member property is a list-o-maps, create a default child map
if appropriate
+ PropertyDefinitionMap listMemberDefinitionMap =
(PropertyDefinitionMap) listMemberPropertyDefinition;
+ PropertyMap listMap = new
PropertyMap(listMemberDefinitionMap.getName());
+ createDefaultProperty(listMemberDefinitionMap, listMap);
+ ((PropertyList) property).add(listMap);
+ } else if (listMemberPropertyDefinition instanceof
PropertyDefinitionSimple) {
+ // member property is a simple, create a single list entry as its
default if appropriate
+ PropertyDefinitionSimple listMemberDefinitionSimple =
(PropertyDefinitionSimple) listMemberPropertyDefinition;
+ String defaultValue =
listMemberDefinitionSimple.getDefaultValue();
+ if (defaultValue != null ||
listMemberDefinitionSimple.isRequired()) {
+ PropertySimple listSimple = new
PropertySimple(listMemberDefinitionSimple.getName(),
+ defaultValue);
+ ((PropertyList) property).add(listSimple);
+ }
+ }
+ }
+ } else if (propertyDefinition instanceof PropertyDefinitionDynamic) {
+ // Dynamic property values should simply be stored as simple
+ property = new PropertySimple(propertyDefinition.getName(), null);
+ } else {
+ throw new IllegalStateException("Unsupported PropertyDefinition
subclass: "
+ + propertyDefinition.getClass().getName());
+ }
+ }
+
+ if (property != null) {
+ parentPropertyMap.put(property);
+ }
+ }
+
private static void normalizeProperty(PropertyDefinition propertyDefinition,
AbstractPropertyMap parentPropertyMap) {
if (parentPropertyMap.getMap().keySet().contains(propertyDefinition.getName()))
// property is already set
{
diff --git
a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtilityTest.java
b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtilityTest.java
new file mode 100644
index 0000000..3f3dccd
--- /dev/null
+++
b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtilityTest.java
@@ -0,0 +1,322 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.clientapi.agent.configuration;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.configuration.Configuration;
+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.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+
+@Test
+public class ConfigurationUtilityTest {
+ public void testCreateDefaultNone() {
+ // no defaults, no required props - returned config should be empty
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo",
null);
+
+ PropertyDefinitionSimple simple = new
PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionMap map = new PropertyDefinitionMap("map", null,
false, simple);
+ PropertyDefinitionList list = new PropertyDefinitionList("list", null,
false, simple);
+
+ configDef.put(simple);
+ configDef.put(map);
+ configDef.put(list);
+
+ Configuration config =
ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 0;
+ }
+
+ public void testCreateDefaultSimple() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo",
null);
+
+ PropertyDefinitionSimple simple = new
PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequired = new
PropertyDefinitionSimple("simpleRequired", null, true,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleDefault = new
PropertyDefinitionSimple("simpleDefault", null, false,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequiredDefault = new
PropertyDefinitionSimple("simpleRequiredDefault", null,
+ true, PropertySimpleType.STRING);
+
+ simpleDefault.setDefaultValue("!!simpleDefaultValue!!");
+
simpleRequiredDefault.setDefaultValue("!!simpleRequiredDefaultValue!!");
+
+ configDef.put(simple);
+ configDef.put(simpleRequired);
+ configDef.put(simpleDefault);
+ configDef.put(simpleRequiredDefault);
+
+ Configuration config =
ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 3; // simple is not required with no
default - its not in the config
+ assert config.getSimple(simple.getName()) == null;
+ assert config.getSimpleValue(simpleRequired.getName(), null) == null;
+ assert config.getSimpleValue(simpleDefault.getName(),
null).equals("!!simpleDefaultValue!!");
+ assert config.getSimpleValue(simpleRequiredDefault.getName(),
null).equals("!!simpleRequiredDefaultValue!!");
+ }
+
+ public void testCreateDefaultMap() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo",
null);
+
+ // a=not required, no default; c=not required, has default; d=required, has
default
+ PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null,
false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null,
false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null,
true, PropertySimpleType.STRING);
+ b.setDefaultValue("!!bDefaultValue!!");
+ c.setDefaultValue("!!cDefaultValue!!");
+
+ PropertyDefinitionMap map1 = new PropertyDefinitionMap("map1", null,
false, a, b, c);
+ PropertyDefinitionMap mapRequired1 = new
PropertyDefinitionMap("mapRequired1", null, true, a, b, c);
+ PropertyDefinitionMap mapRequiredDefault1 = new
PropertyDefinitionMap("mapRequiredDefault1", null, true, a, b,
+ c);
+
+ configDef.put(map1);
+ configDef.put(mapRequired1);
+ configDef.put(mapRequiredDefault1);
+
+ Configuration config =
ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 2; // map is not required with no default
- its not in the config
+ assert config.getMap(map1.getName()) == null;
+
+ // the two required maps have the same definitions - a,b,c as above. since a
isn't required with no default, its not there
+ PropertyMap mapProp1 = config.getMap(mapRequired1.getName());
+ assert mapProp1 != null;
+ assert mapProp1.getSimple(a.getName()) == null;
+ assert mapProp1.getSimpleValue(b.getName(),
null).equals("!!bDefaultValue!!");
+ assert mapProp1.getSimpleValue(c.getName(),
null).equals("!!cDefaultValue!!");
+
+ mapProp1 = config.getMap(mapRequiredDefault1.getName());
+ assert mapProp1 != null;
+ assert mapProp1.getSimple(a.getName()) == null;
+ assert mapProp1.getSimpleValue(b.getName(),
null).equals("!!bDefaultValue!!");
+ assert mapProp1.getSimpleValue(c.getName(),
null).equals("!!cDefaultValue!!");
+ }
+
+ public void testCreateDefaultList() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo",
null);
+
+ // a=not required, no default, b=required, has default
+ PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null,
false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null,
true, PropertySimpleType.STRING);
+ c.setDefaultValue("!!cDefaultValue!!");
+
+ PropertyDefinitionList list1 = new PropertyDefinitionList("list1",
null, false, a);
+ PropertyDefinitionList listRequired1 = new
PropertyDefinitionList("listRequired1", null, true, a);
+ PropertyDefinitionList listRequiredDefault1 = new
PropertyDefinitionList("listRequiredDefault1", null, true, c);
+
+ configDef.put(list1);
+ configDef.put(listRequired1);
+ configDef.put(listRequiredDefault1);
+
+ Configuration config =
ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 2; // list is not required with no
default - its not in the config
+ assert config.getList(list1.getName()) == null;
+
+ PropertyList listProp1 = config.getList(listRequired1.getName());
+ assert listProp1 != null;
+ assert listProp1.getList().isEmpty(); // has "a" definition, which is
not required and has no default
+
+ listProp1 = config.getList(listRequiredDefault1.getName());
+ assert listProp1 != null;
+ assert listProp1.getList().get(0).getName().equals(c.getName());
+ assert ((PropertySimple)
listProp1.getList().get(0)).getStringValue().equals("!!cDefaultValue!!");
+ }
+
+ public void testCreateDefaultListOMaps() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo",
null);
+
+ // a=not required, no default; c=not required, has default; d=required, has
default
+ PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null,
false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null,
false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null,
true, PropertySimpleType.STRING);
+ b.setDefaultValue("!!bDefaultValue!!");
+ c.setDefaultValue("!!cDefaultValue!!");
+
+ PropertyDefinitionMap map2 = new PropertyDefinitionMap("map2", null,
false, a, b, c);
+ PropertyDefinitionMap mapRequired2 = new
PropertyDefinitionMap("mapRequired2", null, true, a, b, c);
+ PropertyDefinitionMap mapRequiredDefault2 = new
PropertyDefinitionMap("mapRequiredDefault2", null, true, a, b,
+ c);
+
+ PropertyDefinitionList listX = new PropertyDefinitionList("listX",
null, true, map2);
+ PropertyDefinitionList listY = new PropertyDefinitionList("listY",
null, true, mapRequired2);
+ PropertyDefinitionList listZ = new PropertyDefinitionList("listZ",
null, true, mapRequiredDefault2);
+
+ configDef.put(listX);
+ configDef.put(listY);
+ configDef.put(listZ);
+
+ Configuration config =
ConfigurationUtility.createDefaultConfiguration(configDef);
+
+ assert config != null;
+ assert config.getProperties().size() == 3;
+
+ PropertyList listPropTest = config.getList(listX.getName());
+ assert listPropTest != null;
+ assert listPropTest.getList().isEmpty();
+
+ listPropTest = config.getList(listY.getName());
+ assert listPropTest != null;
+ PropertyMap childMap2 = (PropertyMap) listPropTest.getList().get(0);
+
+ listPropTest = config.getList(listZ.getName());
+ assert listPropTest != null;
+ PropertyMap childMap3 = (PropertyMap) listPropTest.getList().get(0);
+
+ assert childMap2.getName().equals(mapRequired2.getName());
+ assert childMap3.getName().equals(mapRequiredDefault2.getName());
+ }
+
+ public void testCreateDefaultAllSimpleMapList() {
+ // tests a big config def that has simples, lists, maps - combination of the
other individual tests
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo",
null);
+
+ // SETUP SIMPLE
+
+ PropertyDefinitionSimple simple = new
PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequired = new
PropertyDefinitionSimple("simpleRequired", null, true,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleDefault = new
PropertyDefinitionSimple("simpleDefault", null, false,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequiredDefault = new
PropertyDefinitionSimple("simpleRequiredDefault", null,
+ true, PropertySimpleType.STRING);
+
+ simpleDefault.setDefaultValue("!!simpleDefaultValue!!");
+
simpleRequiredDefault.setDefaultValue("!!simpleRequiredDefaultValue!!");
+
+ configDef.put(simple);
+ configDef.put(simpleRequired);
+ configDef.put(simpleDefault);
+ configDef.put(simpleRequiredDefault);
+
+ // SETUP MAP
+
+ // a=not required, no default; c=not required, has default; d=required, has
default
+ PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null,
false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null,
false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null,
true, PropertySimpleType.STRING);
+ b.setDefaultValue("!!bDefaultValue!!");
+ c.setDefaultValue("!!cDefaultValue!!");
+
+ PropertyDefinitionMap map1 = new PropertyDefinitionMap("map1", null,
false, a, b, c);
+ PropertyDefinitionMap mapRequired1 = new
PropertyDefinitionMap("mapRequired1", null, true, a, b, c);
+ PropertyDefinitionMap mapRequiredDefault1 = new
PropertyDefinitionMap("mapRequiredDefault1", null, true, a, b,
+ c);
+
+ configDef.put(map1);
+ configDef.put(mapRequired1);
+ configDef.put(mapRequiredDefault1);
+
+ // SETUP LIST
+
+ PropertyDefinitionList list1 = new PropertyDefinitionList("list1",
null, false, a);
+ PropertyDefinitionList listRequired1 = new
PropertyDefinitionList("listRequired1", null, true, a);
+ PropertyDefinitionList listRequiredDefault1 = new
PropertyDefinitionList("listRequiredDefault1", null, true, c);
+
+ configDef.put(list1);
+ configDef.put(listRequired1);
+ configDef.put(listRequiredDefault1);
+
+ // SETUP LIST-O-MAPS
+
+ PropertyDefinitionMap map2 = new PropertyDefinitionMap("map2", null,
false, a, b, c);
+ PropertyDefinitionMap mapRequired2 = new
PropertyDefinitionMap("mapRequired2", null, true, a, b, c);
+ PropertyDefinitionMap mapRequiredDefault2 = new
PropertyDefinitionMap("mapRequiredDefault2", null, true, a, b,
+ c);
+
+ PropertyDefinitionList listX = new PropertyDefinitionList("listX",
null, true, map2);
+ PropertyDefinitionList listY = new PropertyDefinitionList("listY",
null, true, mapRequired2);
+ PropertyDefinitionList listZ = new PropertyDefinitionList("listZ",
null, true, mapRequiredDefault2);
+
+ configDef.put(listX);
+ configDef.put(listY);
+ configDef.put(listZ);
+
+ // get the default config
+ Configuration config =
ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 10;
+
+ // ASSERT SIMPLE
+
+ assert config.getSimple(simple.getName()) == null;
+ assert config.getSimpleValue(simpleRequired.getName(), null) == null;
+ assert config.getSimpleValue(simpleDefault.getName(),
null).equals("!!simpleDefaultValue!!");
+ assert config.getSimpleValue(simpleRequiredDefault.getName(),
null).equals("!!simpleRequiredDefaultValue!!");
+
+ // ASSERT MAP
+
+ assert config.getMap(map1.getName()) == null;
+
+ // the two required maps have the same definitions - a,b,c as above. since a
isn't required with no default, its not there
+ PropertyMap mapProp1 = config.getMap(mapRequired1.getName());
+ assert mapProp1 != null;
+ assert mapProp1.getSimple(a.getName()) == null;
+ assert mapProp1.getSimpleValue(b.getName(),
null).equals("!!bDefaultValue!!");
+ assert mapProp1.getSimpleValue(c.getName(),
null).equals("!!cDefaultValue!!");
+
+ mapProp1 = config.getMap(mapRequiredDefault1.getName());
+ assert mapProp1 != null;
+ assert mapProp1.getSimple(a.getName()) == null;
+ assert mapProp1.getSimpleValue(b.getName(),
null).equals("!!bDefaultValue!!");
+ assert mapProp1.getSimpleValue(c.getName(),
null).equals("!!cDefaultValue!!");
+
+ // ASSERT LIST
+
+ assert config.getList(list1.getName()) == null;
+
+ PropertyList listProp1 = config.getList(listRequired1.getName());
+ assert listProp1 != null;
+ assert listProp1.getList().isEmpty(); // has "a" definition, which is
not required and has no default
+
+ listProp1 = config.getList(listRequiredDefault1.getName());
+ assert listProp1 != null;
+ assert listProp1.getList().get(0).getName().equals(c.getName());
+ assert ((PropertySimple)
listProp1.getList().get(0)).getStringValue().equals("!!cDefaultValue!!");
+
+ // ASSERT LIST-O-MAPS
+
+ PropertyList listPropTest = config.getList(listX.getName());
+ assert listPropTest != null;
+ assert listPropTest.getList().isEmpty();
+
+ listPropTest = config.getList(listY.getName());
+ assert listPropTest != null;
+ PropertyMap childMap2 = (PropertyMap) listPropTest.getList().get(0);
+
+ listPropTest = config.getList(listZ.getName());
+ assert listPropTest != null;
+ PropertyMap childMap3 = (PropertyMap) listPropTest.getList().get(0);
+
+ assert childMap2.getName().equals(mapRequired2.getName());
+ assert childMap3.getName().equals(mapRequiredDefault2.getName());
+ }
+}
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
index 174aa8e..b77b4e6 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
@@ -83,10 +83,11 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
* This property's default value. This field should have a non-null value for
properties whose
* {@link PropertyDefinition#required} field is <code>false</code> (i.e.
for optional properties). Conversely, this
* field should be null for properties whose {@link PropertyDefinition#required}
field is <code>true</code> (i.e. for
- * required properties).
- * @deprecated Use the (default) template instead
+ * required properties).
+ *
+ * This field is mainly used to help build default templates. You usually do not want
to use this
+ * default value member variable directly - consider using the configuration
definition's default template.
*/
- @Deprecated
@Column(name = "DEFAULT_VALUE", length = 2000)
private String defaultValue;
@@ -201,12 +202,29 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
this.allowCustomEnumeratedValue = allowCustomEnumValue;
}
- @Deprecated
+ /**
+ * Returns the default value that this property definition defines for its
+ * value. Note, however, you rarely want to use this directly. Under most
+ * circumstances, you should be using the configuration definition's
+ * {@link ConfigurationDefinition#getDefaultTemplate() default template}.
+ *
+ * For an example of where this method is useful, see
+ *
org.rhq.core.clientapi.agent.configuration.ConfigurationUtility.initializeDefaultTemplate(ConfigurationDefinition)
+ *
+ * @return property default value
+ */
public String getDefaultValue() {
return defaultValue;
}
- @Deprecated
+ /**
+ * Sets the default value for this property. Note that you normally call this
+ * only at times when you plan on building default templates with this
+ * property definition later. See {@link #getDefaultValue()} for more details
+ * on this default value.
+ *
+ * @param defaultValue
+ */
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
index 108c097..5c42f9b 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * Copyright (C) 2005-2010 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@ package org.rhq.enterprise.server.bundle;
import java.util.Set;
+import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.util.updater.DeploymentProperties;
@@ -28,7 +29,8 @@ import org.rhq.core.util.updater.DeploymentProperties;
* This class is general to all Bundle handling server side plugins. It is returned by
the SSP when parsing
* a bundle's recipe and contains all of the information neded to create a bundle
version.
*
- * @author jay shaughnessy
+ * @author Jay Shaughnessy
+ * @author John Mazzitelli
*/
public class RecipeParseResults {
@@ -43,9 +45,9 @@ public class RecipeParseResults {
public RecipeParseResults(DeploymentProperties bundleMetadata,
ConfigurationDefinition configDef,
Set<String> bundleFileNames) {
- this.bundleMetadata = bundleMetadata;
- this.configDef = configDef;
- this.bundleFileNames = bundleFileNames;
+ setBundleMetadata(bundleMetadata);
+ setConfigurationDefinition(configDef);
+ setBundleFiles(bundleFileNames);
}
public DeploymentProperties getBundleMetadata() {
@@ -60,8 +62,9 @@ public class RecipeParseResults {
return configDef;
}
- public void setConfigDef(ConfigurationDefinition configDef) {
+ public void setConfigurationDefinition(ConfigurationDefinition configDef) {
this.configDef = configDef;
+ ConfigurationUtility.initializeDefaultTemplate(this.configDef);
}
public Set<String> getBundleFileNames() {
@@ -71,5 +74,4 @@ public class RecipeParseResults {
public void setBundleFiles(Set<String> bundleFileNames) {
this.bundleFileNames = bundleFileNames;
}
-
}
diff --git
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
index ab55bac..968d5cd 100644
---
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
+++
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -57,6 +57,7 @@ import
org.rhq.core.domain.bundle.composite.BundleWithLatestVersionComposite;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.content.Architecture;
@@ -300,9 +301,30 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
bundleDescription);
ConfigurationDefinition configDef = new
ConfigurationDefinition("foo", null);
- String propName = "prop1";
- String propDescription = "prop1desc";
- configDef.put(new PropertyDefinitionSimple(propName, propDescription, true,
PropertySimpleType.INTEGER));
+ int propDefaultValue1 = 998877;
+ String propDefaultValue4 = "this.is.the.default";
+ String propName1 = "prop1requiredWithDefault";
+ String propName2 = "prop2";
+ String propName3 = "prop3requiredWithNoDefault";
+ String propName4 = "prop4notRequiredWithDefault";
+ String propDesc1 = "prop1desc";
+ String propDesc2 = "prop2desc";
+ String propDesc3 = "prop3desc";
+ String propDesc4 = "prop4desc";
+ PropertyDefinitionSimple propdef1requiredWithDefault = new
PropertyDefinitionSimple(propName1, propDesc1,
+ true, PropertySimpleType.INTEGER);
+ PropertyDefinitionSimple propdef2 = new PropertyDefinitionSimple(propName2,
propDesc2, false,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple propdef3requiredWithNoDefault = new
PropertyDefinitionSimple(propName3, propDesc3,
+ true, PropertySimpleType.STRING);
+ PropertyDefinitionSimple propdef4notRequiredWithDefault = new
PropertyDefinitionSimple(propName4,
+ propDesc4, false, PropertySimpleType.STRING);
+
propdef1requiredWithDefault.setDefaultValue(String.valueOf(propDefaultValue1));
+ propdef4notRequiredWithDefault.setDefaultValue(propDefaultValue4);
+ configDef.put(propdef1requiredWithDefault);
+ configDef.put(propdef2);
+ configDef.put(propdef3requiredWithNoDefault);
+ configDef.put(propdef4notRequiredWithDefault);
Map<String, File> bundleFiles = new HashMap<String, File>(3);
bundleFiles.put(bundleFile1, new File(tmpDir, bundleFile1));
@@ -358,12 +380,41 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
assert bundleFileNames.contains(bundleFile2) : bv;
assert bundleFileNames.contains(bundleFile3) : bv;
assert bv.getBundleDeployments().isEmpty() : bv;
- assert bv.getConfigurationDefinition().getPropertyDefinitions().size() ==
1;
- assert bv.getConfigurationDefinition().get(propName) != null;
- assert
bv.getConfigurationDefinition().get(propName).getDescription().equals(propDescription);
- assert bv.getConfigurationDefinition().get(propName).isRequired();
- assert
bv.getConfigurationDefinition().getPropertyDefinitionSimple(propName).getType() ==
PropertySimpleType.INTEGER;
+ assert bv.getConfigurationDefinition().getPropertyDefinitions().size() ==
4;
+ assert bv.getConfigurationDefinition().get(propName1) != null;
+ assert
bv.getConfigurationDefinition().get(propName1).getDescription().equals(propDesc1);
+ assert bv.getConfigurationDefinition().get(propName1).isRequired() ==
true;
+ assert
bv.getConfigurationDefinition().getPropertyDefinitionSimple(propName1).getType() ==
PropertySimpleType.INTEGER;
+ assert bv.getConfigurationDefinition().get(propName2) != null;
+ assert
bv.getConfigurationDefinition().get(propName2).getDescription().equals(propDesc2);
+ assert bv.getConfigurationDefinition().get(propName2).isRequired() ==
false;
+ assert
bv.getConfigurationDefinition().getPropertyDefinitionSimple(propName2).getType() ==
PropertySimpleType.STRING;
+ assert bv.getConfigurationDefinition().get(propName3) != null;
+ assert
bv.getConfigurationDefinition().get(propName3).getDescription().equals(propDesc3);
+ assert bv.getConfigurationDefinition().get(propName3).isRequired() ==
true;
+ assert
bv.getConfigurationDefinition().getPropertyDefinitionSimple(propName3).getType() ==
PropertySimpleType.STRING;
+ assert bv.getConfigurationDefinition().get(propName4) != null;
+ assert
bv.getConfigurationDefinition().get(propName4).getDescription().equals(propDesc4);
+ assert bv.getConfigurationDefinition().get(propName4).isRequired() ==
false;
+ assert
bv.getConfigurationDefinition().getPropertyDefinitionSimple(propName4).getType() ==
PropertySimpleType.STRING;
assert bv.getRecipe().equals(recipe);
+
+ // make sure the default template is correct
+ ConfigurationTemplate defaultTemplate =
bv.getConfigurationDefinition().getDefaultTemplate();
+ Configuration defaultConfig = defaultTemplate.getConfiguration();
+ assert defaultConfig.getProperties().size() == 3; // prop2 is not
required and has no default, thus is missing
+ PropertySimple prop1 = defaultConfig.getSimple(propName1);
+ PropertySimple prop2 = defaultConfig.getSimple(propName2);
+ PropertySimple prop3 = defaultConfig.getSimple(propName3);
+ PropertySimple prop4 = defaultConfig.getSimple(propName4);
+ assert prop1 != null;
+ assert prop2 == null : "prop2 was not required and has no default,
it should not be in the default template config";
+ assert prop3 != null;
+ assert prop4 != null;
+ assert prop1.getIntegerValue() != null;
+ assert prop1.getIntegerValue().intValue() == propDefaultValue1;
+ assert prop3.getStringValue() == null : "prop3 was required but had
no default, its template value should have been null";
+ assert prop4.getStringValue().equals(propDefaultValue4);
}
} finally {
FileUtil.purge(tmpDir, true);
diff --git
a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
index 4db9de9..cdb855a 100644
---
a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
+++
b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
@@ -111,6 +111,7 @@ public class BundleServerPluginComponent implements
ServerPluginComponent, Bundl
PropertyDefinitionSimple prop = new
PropertyDefinitionSimple(replacementVar,
"Needed by bundle recipe.", false,
PropertySimpleType.STRING);
prop.setDisplayName(replacementVar);
+
prop.setDefaultValue(recipeContext.getReplacementVariableDefaultValues().get(replacementVar));
configDef.put(prop);
}
}
commit ebbeac6c225768c858efeb2a6c95037e67ef3d72
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Dec 18 16:03:34 2010 -0500
support deleting bundle versions
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
index 2d40a23..ec1ca5e 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
@@ -111,6 +111,7 @@ public class BundleDestinationView extends LocatableVLayout implements
Bookmarka
form.setWidth100();
form.setColWidths("20%", "40%", "40%");
form.setNumCols(3);
+ form.setAutoHeight();
form.setWrapItemTitles(false);
form.setExtraSpace(10);
form.setIsGroup(true);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
index e0bd7e9..e4ff4d3 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
@@ -168,6 +168,7 @@ public class BundleView extends LocatableVLayout implements
BookmarkableView {
form.setWidth100();
form.setColWidths("20%", "40%", "40%");
form.setNumCols(3);
+ form.setAutoHeight();
form.setWrapItemTitles(false);
form.setExtraSpace(10);
form.setIsGroup(true);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java
index 284ef3c..cf4ab17 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java
@@ -26,7 +26,13 @@ import java.util.HashSet;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.util.BooleanCallback;
+import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
@@ -49,9 +55,11 @@ import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagEditorView;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagsChangedCallback;
+import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -61,6 +69,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class BundleVersionView extends LocatableVLayout implements BookmarkableView {
+ private BundleGWTServiceAsync bundleManager = GWTServiceLookup.getBundleService();
private BundleVersion version;
private boolean canManageBundles = false;
@@ -111,16 +120,24 @@ public class BundleVersionView extends LocatableVLayout implements
BookmarkableV
}
private LocatableDynamicForm createSummaryForm() {
+
LocatableDynamicForm form = new
LocatableDynamicForm(extendLocatorId("Summary"));
form.setWidth100();
+ form.setColWidths("20%", "40%", "40%");
+ form.setNumCols(3);
form.setAutoHeight();
- form.setNumCols(2);
form.setWrapItemTitles(false);
form.setExtraSpace(10);
form.setIsGroup(true);
form.setGroupTitle(MSG.common_title_summary());
form.setPadding(5);
+ CanvasItem actionItem = new CanvasItem("actions");
+ actionItem.setColSpan(1);
+ actionItem.setRowSpan(4);
+ actionItem.setShowTitle(false);
+
actionItem.setCanvas(getActionLayout(form.extendLocatorId("actions")));
+
StaticTextItem versionItem = new StaticTextItem("version",
MSG.common_title_version());
versionItem.setValue(version.getVersion());
@@ -133,10 +150,47 @@ public class BundleVersionView extends LocatableVLayout implements
BookmarkableV
StaticTextItem descriptionItem = new StaticTextItem("description",
MSG.common_title_description());
descriptionItem.setValue(version.getDescription());
- form.setFields(versionItem, liveDeploymentsItem, filesItems, descriptionItem);
+ form.setFields(versionItem, actionItem, liveDeploymentsItem, filesItems,
descriptionItem);
return form;
}
+ private Canvas getActionLayout(String locatorId) {
+ LocatableVLayout actionLayout = new LocatableVLayout(locatorId, 10);
+ IButton deleteButton = new LocatableIButton(extendLocatorId("Delete"),
MSG.common_button_delete());
+
deleteButton.setIcon("subsystems/bundle/BundleVersionAction_Delete_16.png");
+ deleteButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ SC.ask(MSG.view_bundle_version_deleteConfirm(), new BooleanCallback() {
+ public void execute(Boolean aBoolean) {
+ if (aBoolean) {
+ bundleManager.deleteBundleVersion(version.getId(), false, new
AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+
MSG.view_bundle_version_deleteFailure(version.getVersion()), caught);
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new
Message(MSG.view_bundle_version_deleteSuccessful(version.getVersion()),
+ Message.Severity.Info));
+ // Bundle version is deleted, go back to main bundle
view
+
CoreGUI.goToView(LinkManager.getBundleLink(version.getBundle().getId()));
+ }
+ });
+ }
+ }
+ });
+ }
+ });
+ actionLayout.addMember(deleteButton);
+
+ if (!canManageBundles) {
+ deleteButton.setDisabled(true);
+ }
+
+ return actionLayout;
+ }
+
private TagEditorView createTagEditor() {
boolean readOnly = !this.canManageBundles;
TagEditorView tagEditor = new TagEditorView(extendLocatorId("Tags"),
version.getTags(), readOnly,
@@ -213,17 +267,16 @@ public class BundleVersionView extends LocatableVLayout implements
BookmarkableV
criteria.fetchConfigurationDefinition(true);
criteria.fetchTags(true);
- GWTServiceLookup.getBundleService().findBundleVersionsByCriteria(criteria,
- new AsyncCallback<PageList<BundleVersion>>() {
- public void onFailure(Throwable caught) {
-
CoreGUI.getErrorHandler().handleError(MSG.view_bundle_version_loadFailure(), caught);
- }
+ bundleManager.findBundleVersionsByCriteria(criteria, new
AsyncCallback<PageList<BundleVersion>>() {
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_bundle_version_loadFailure(), caught);
+ }
- public void onSuccess(PageList<BundleVersion> result) {
- BundleVersion version = result.get(0);
- ViewId nextPath = viewPath.next().getCurrent();
- viewBundleVersion(version, nextPath);
- }
- });
+ public void onSuccess(PageList<BundleVersion> result) {
+ BundleVersion version = result.get(0);
+ ViewId nextPath = viewPath.next().getCurrent();
+ viewBundleVersion(version, nextPath);
+ }
+ });
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 0009db8..d98386e 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -908,6 +908,9 @@ view_bundle_fileListView_loadFailure = Failed to load bundle file
data
view_bundle_version_backToBundle = Back to Bundle
view_bundle_version_bundleVersionTagUpdateFailure = Failed to update bundle version tags
view_bundle_version_bundleVersionTagUpdateSuccessful = You have successfully updated the
bundle version tags
+view_bundle_version_deleteConfirm = Are you sure you want to delete this bundle version?
+view_bundle_version_deleteFailure = Failed to delete the bundle version [{0}]
+view_bundle_version_deleteSuccessful = You successfully deleted the bundle version [{0}]
view_bundle_version_loadFailure = Failed to load bundle version
view_bundle_tree_loadFailure = Failed to load bundle data
view_bundle_revertWizard_title = Bundle Revert
diff --git
a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16.png
b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16.png
new file mode 100644
index 0000000..f4d69d8
Binary files /dev/null and
b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16.png
differ
diff --git
a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16_Disabled.png
b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16_Disabled.png
new file mode 100644
index 0000000..c8b5750
Binary files /dev/null and
b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16_Disabled.png
differ
diff --git
a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16.png
b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16.png
new file mode 100644
index 0000000..7c528ef
Binary files /dev/null and
b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16.png
differ
diff --git
a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16_Disabled.png
b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16_Disabled.png
new file mode 100644
index 0000000..b76504b
Binary files /dev/null and
b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16_Disabled.png
differ
diff --git
a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16.png
b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16.png
new file mode 100644
index 0000000..3f5cce4
Binary files /dev/null and
b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16.png
differ
diff --git
a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16_Disabled.png
b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16_Disabled.png
new file mode 100644
index 0000000..049b3c1
Binary files /dev/null and
b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16_Disabled.png
differ
commit 504bd1c6af214f3bacd3a7c894a0f1926bcc9fdb
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Dec 18 12:41:27 2010 -0500
add todo - need to remember this is where the selection fails if tree is not loaded
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
index 74c78ad..272841f 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
@@ -64,9 +64,9 @@ public class BundleTreeView extends LocatableTreeGrid {
}
public void selectPath(ViewPath viewPath) {
-
Tree theTree = getTree();
+ // TODO: how do we get the tree to load its nodes if they aren't loaded yet?
if (viewPath.viewsLeft() > 0) {
String key = "";
for (ViewId view : viewPath.getViewPath().subList(2,
viewPath.getViewPath().size())) {
@@ -89,7 +89,6 @@ public class BundleTreeView extends LocatableTreeGrid {
final String finalKey = key;
GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable reason) {
-
}
public void onSuccess() {
commit 95b92ea3d6b6b8640761ca3081d63c3e50b8606e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Dec 18 12:34:07 2010 -0500
I'm always confused what these do. adding javadoc so I can remember in the future
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
index 81f9882..122f032 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
@@ -61,7 +61,21 @@ public class Message {
};
public enum Option {
- Transient, Sticky, BackgroundJobResult
+ /**
+ * The message will not be persisted in the message center list.
+ */
+ Transient,
+
+ /**
+ * The message will not auto-clear after a delay - it remains on the screen until
you navigate away.
+ */
+ Sticky,
+
+ /**
+ * The message will be persisted in the message center list,
+ * but will not show up in the main screen message area.
+ */
+ BackgroundJobResult
};
public Message(String conciseMessage) {
commit 529f4c4431f6a315b8721e11d36a8185d00e6312
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Dec 18 11:22:53 2010 -0500
make sure the tree folders are open when selected. this only partially works. if the
tree is not loaded yet, it won't load on its own
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
index 4bad6b9..dadace4 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
@@ -226,40 +226,45 @@ public class BundleTreeDataSource extends RPCDataSource {
}
public ListGridRecord copyValuesForKnownBundle(Object from, Integer bundleId) {
+ String parentID;
TreeNode node = new TreeNode();
if (from instanceof Bundle) {
Bundle bundle = (Bundle) from;
+ node.setIsFolder(true);
+ node.setIcon("subsystems/bundle/Bundle_16.png");
node.setID(String.valueOf(bundle.getId()));
node.setName(bundle.getName());
- node.setIcon("subsystems/bundle/Bundle_16.png");
} else if (from instanceof BundleVersion) {
BundleVersion version = (BundleVersion) from;
- node.setName(version.getVersion());
- node.setID(version.getBundle().getId() + "_versions_" +
version.getId());
- node.setParentID(version.getBundle().getId() + "_versions");
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleVersion_16.png");
+ parentID = version.getBundle().getId() + "_versions";
+ node.setParentID(parentID);
+ node.setID(parentID + '_' + version.getId());
+ node.setName(version.getVersion());
} else if (from instanceof BundleDeployment) {
BundleDeployment deployment = (BundleDeployment) from;
+ node.setIsFolder(false);
+ node.setIcon("subsystems/bundle/BundleDeployment_16.png");
+ parentID = bundleId + "_destinations_" +
deployment.getDestination().getId();
+ node.setParentID(parentID);
+ node.setID(bundleId + "_deployments_" + deployment.getId());
if (deployment.isLive()) {
node.setName("<span style=\"color: green; font-weight:
bold\">(live)</span> " + deployment.getName());
} else {
node.setName(deployment.getName());
}
- node.setID(bundleId + "_deployments_" + deployment.getId());
- node.setParentID(bundleId + "_destinations_" +
deployment.getDestination().getId());
- node.setIsFolder(false);
- node.setIcon("subsystems/bundle/BundleDeployment_16.png");
} else if (from instanceof BundleDestination) {
BundleDestination destination = (BundleDestination) from;
- node.setName(destination.getName());
- node.setID(destination.getBundle().getId() + "_destinations_" +
destination.getId());
- node.setParentID(destination.getBundle().getId() +
"_destinations");
node.setIsFolder(true);
node.setIcon("subsystems/bundle/BundleDestination_16.png");
+ parentID = destination.getBundle().getId() + "_destinations";
+ node.setParentID(parentID);
+ node.setID(parentID + '_' + destination.getId());
+ node.setName(destination.getName());
}
return node;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
index 9f3a5be..74c78ad 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
@@ -26,6 +26,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.user.client.History;
import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeNode;
import com.smartgwt.client.widgets.tree.events.NodeClickEvent;
import com.smartgwt.client.widgets.tree.events.NodeClickHandler;
@@ -55,7 +56,8 @@ public class BundleTreeView extends LocatableTreeGrid {
addNodeClickHandler(new NodeClickHandler() {
public void onNodeClick(NodeClickEvent event) {
- String path =
event.getNode().getAttribute("id").replaceAll("_", "/");
+ TreeNode node = event.getNode();
+ String path = node.getAttribute("id").replaceAll("_",
"/");
History.newItem("Bundles/Bundle/" + path);
}
});
@@ -63,6 +65,8 @@ public class BundleTreeView extends LocatableTreeGrid {
public void selectPath(ViewPath viewPath) {
+ Tree theTree = getTree();
+
if (viewPath.viewsLeft() > 0) {
String key = "";
for (ViewId view : viewPath.getViewPath().subList(2,
viewPath.getViewPath().size())) {
@@ -71,9 +75,14 @@ public class BundleTreeView extends LocatableTreeGrid {
key += view.getPath();
- TreeNode node = getTree().findById(key);
+ TreeNode node = theTree.findById(key);
if (node != null) {
- getTree().openFolder(node);
+ // make sure all its parents are open as well as itself
+ TreeNode parentNode = node; // prime the pump
+ while (parentNode != null) {
+ theTree.openFolder(parentNode);
+ parentNode = theTree.getParent(parentNode);
+ }
}
}
commit 3a351ac8dd9d8657b04ac024d379db4dec90af49
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Dec 18 10:13:00 2010 -0500
the separator for our custom keys is underscore, not colon
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
index 12b8e23..9f3a5be 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
@@ -67,7 +67,7 @@ public class BundleTreeView extends LocatableTreeGrid {
String key = "";
for (ViewId view : viewPath.getViewPath().subList(2,
viewPath.getViewPath().size())) {
if (key.length() > 0)
- key += ":";
+ key += "_";
key += view.getPath();