[rhq] Branch 'drift' - modules/core modules/enterprise
by mazz
modules/core/client-api/pom.xml | 19
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/DriftMetadataParser.java | 72
modules/core/client-api/src/main/resources/rhq-drift.xsd | 79
modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy | 565 ------
modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/PluginMetadataParserTest.java | 837 ++++++++++
modules/core/dbutils/src/main/scripts/dbsetup/config-data.xml | 164 +
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 58
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java | 115 +
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java | 370 +++-
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java | 155 +
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftConfigurationDefinitionTest.java | 212 ++
modules/enterprise/server/jar/src/test/resources/log4j.xml | 7
12 files changed, 1897 insertions(+), 756 deletions(-)
New commits:
commit 3c32b55beba3c2f8550c12d7106ad7c5cea1d9a9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jun 29 14:31:32 2011 -0400
change drift metadata to specify value-context and value-name
diff --git a/modules/core/client-api/pom.xml b/modules/core/client-api/pom.xml
index 9fed074..9f5f66a 100644
--- a/modules/core/client-api/pom.xml
+++ b/modules/core/client-api/pom.xml
@@ -69,12 +69,6 @@
</dependency>
<dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-all</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
<groupId>commons-jxpath</groupId>
<artifactId>commons-jxpath</artifactId>
<version>1.3</version>
@@ -110,19 +104,6 @@
</plugin>
<plugin>
- <groupId>org.codehaus.groovy.maven</groupId>
- <artifactId>gmaven-plugin</artifactId>
- <version>1.0</version>
- <executions>
- <execution>
- <goals>
- <!--<goal>generateTestStubs</goal>-->
- <goal>testCompile</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/DriftMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/DriftMetadataParser.java
index 1a4d261..54892ab 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/DriftMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/DriftMetadataParser.java
@@ -1,20 +1,37 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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.metadata;
import org.rhq.core.clientapi.descriptor.drift.DriftDescriptor;
import org.rhq.core.clientapi.descriptor.drift.DriftFilterDescriptor;
+import org.rhq.core.clientapi.descriptor.drift.DriftDescriptor.Basedir;
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.ConfigurationTemplate;
-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;
-
-import static org.rhq.core.domain.configuration.definition.PropertySimpleType.LONG;
-import static org.rhq.core.domain.configuration.definition.PropertySimpleType.STRING;
+import org.rhq.core.domain.drift.DriftConfigurationDefinition;
public class DriftMetadataParser {
@@ -32,43 +49,52 @@ public class DriftMetadataParser {
}
private ConfigurationTemplate createTemplate(String name) {
- ConfigurationTemplate template = new ConfigurationTemplate(name,
- name + " drift configuration default template");
+ ConfigurationTemplate template = new ConfigurationTemplate(name, name + " drift configuration default template");
template.setConfiguration(new Configuration());
return template;
}
private void initEnabled(ConfigurationTemplate template) {
- template.getConfiguration().put(new PropertySimple("enabled", false));
+ template.getConfiguration().put(new PropertySimple(DriftConfigurationDefinition.PROP_ENABLED, false));
}
private void initName(DriftDescriptor descriptor, ConfigurationTemplate template) {
- template.getConfiguration().put(new PropertySimple("name", descriptor.getName()));
+ template.getConfiguration().put(
+ new PropertySimple(DriftConfigurationDefinition.PROP_NAME, descriptor.getName()));
}
private void initBasedir(DriftDescriptor descriptor, ConfigurationTemplate template) {
- template.getConfiguration().put(new PropertySimple("basedir", descriptor.getBasedir()));
+ Basedir basedir = descriptor.getBasedir();
+ String valueContext = basedir.getValueContext();
+ String valueName = basedir.getValueName();
+
+ PropertyMap basedirMap = new PropertyMap(DriftConfigurationDefinition.PROP_BASEDIR);
+ basedirMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUECONTEXT, valueContext));
+ basedirMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUENAME, valueName));
+
+ template.getConfiguration().put(basedirMap);
}
private void initInterval(DriftDescriptor descriptor, ConfigurationTemplate template) {
Configuration config = template.getConfiguration();
if (descriptor.getInterval() == null) {
- config.put(new PropertySimple("interval", "1800"));
+ config.put(new PropertySimple(DriftConfigurationDefinition.PROP_INTERVAL, String
+ .valueOf(DriftConfigurationDefinition.DEFAULT_INTERVAL)));
} else {
- config.put(new PropertySimple("interval", descriptor.getInterval()));
+ config.put(new PropertySimple(DriftConfigurationDefinition.PROP_INTERVAL, descriptor.getInterval()));
}
}
private void initIncludes(DriftDescriptor descriptor, ConfigurationTemplate template) {
if (descriptor.getIncludes() != null && descriptor.getIncludes().getInclude().size() > 0) {
Configuration config = template.getConfiguration();
- PropertyList includes = new PropertyList("includes");
+ PropertyList includes = new PropertyList(DriftConfigurationDefinition.PROP_INCLUDES);
for (DriftFilterDescriptor include : descriptor.getIncludes().getInclude()) {
- PropertyMap includeMap = new PropertyMap("include");
- includeMap.put(new PropertySimple("path", include.getPath()));
- includeMap.put(new PropertySimple("pattern", include.getPattern()));
+ PropertyMap includeMap = new PropertyMap(DriftConfigurationDefinition.PROP_INCLUDES_INCLUDE);
+ includeMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATH, include.getPath()));
+ includeMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATTERN, include.getPattern()));
includes.add(includeMap);
}
@@ -79,12 +105,12 @@ public class DriftMetadataParser {
private void initExcludes(DriftDescriptor descriptor, ConfigurationTemplate template) {
if (descriptor.getExcludes() != null && descriptor.getExcludes().getExclude().size() > 0) {
Configuration config = template.getConfiguration();
- PropertyList excludes = new PropertyList("excludes");
+ PropertyList excludes = new PropertyList(DriftConfigurationDefinition.PROP_EXCLUDES);
for (DriftFilterDescriptor exclude : descriptor.getExcludes().getExclude()) {
- PropertyMap excludeMap = new PropertyMap("exclude");
- excludeMap.put(new PropertySimple("path", exclude.getPath()));
- excludeMap.put(new PropertySimple("pattern", exclude.getPattern()));
+ PropertyMap excludeMap = new PropertyMap(DriftConfigurationDefinition.PROP_EXCLUDES_EXCLUDE);
+ excludeMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATH, exclude.getPath()));
+ excludeMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATTERN, exclude.getPattern()));
excludes.add(excludeMap);
}
diff --git a/modules/core/client-api/src/main/resources/rhq-drift.xsd b/modules/core/client-api/src/main/resources/rhq-drift.xsd
index 81aa704..2330c64 100644
--- a/modules/core/client-api/src/main/resources/rhq-drift.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-drift.xsd
@@ -29,79 +29,108 @@
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" blockDefault="">
<xs:annotation>
- <xs:documentation>Schema for the definition of drift configuration data.</xs:documentation>
- <xs:appinfo>
- <jaxb:schemaBindings>
- <jaxb:package name="org.rhq.core.clientapi.descriptor.drift"/>
- </jaxb:schemaBindings>
- </xs:appinfo>
- </xs:annotation>
+ <xs:documentation>Schema for the definition of drift configuration data.</xs:documentation>
+ <xs:appinfo>
+ <jaxb:schemaBindings>
+ <jaxb:package name="org.rhq.core.clientapi.descriptor.drift" />
+ </jaxb:schemaBindings>
+ </xs:appinfo>
+ </xs:annotation>
<xs:complexType name="Drift">
<xs:annotation>
<xs:appinfo>
- <jaxb:class name="DriftDescriptor"/>
+ <jaxb:class name="DriftDescriptor" />
</xs:appinfo>
</xs:annotation>
<xs:sequence>
- <xs:element name="basedir" type="xs:string" minOccurs="1" maxOccurs="1">
- <xs:annotation>
- <xs:documentation>The root directory from which snapshots will be generated during drift
- monitoring.</xs:documentation>
- </xs:annotation>
+ <xs:element name="basedir" minOccurs="1" maxOccurs="1">
+ <xs:complexType>
+ <xs:annotation>
+ <xs:documentation>
+ The root directory from which snapshots will be generated during drift monitoring.
+ Each base directory's value is obtained from a particular context
+ (e.g. in the resource's plugin configuration or its resource configuration).
+ Within that context, the base directory value is obtained by looking up the named value in the given context.
+ For example, if the value-name is "install.dir" and the value-context is "pluginConfiguration",
+ then the destination base directory value is obtained by getting the "install.dir" property value
+ found in the resource's plugin configuration.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="value-context">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="pluginConfiguration"></xs:enumeration>
+ <xs:enumeration value="resourceConfiguration"></xs:enumeration>
+ <xs:enumeration value="measurementTrait"></xs:enumeration>
+ <xs:enumeration value="fileSystem"></xs:enumeration>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+ <xs:element name="value-name" type="xs:string"></xs:element>
+ </xs:sequence>
+ </xs:complexType>
</xs:element>
<xs:element name="interval" type="xs:long" minOccurs="0" maxOccurs="1" default="1800">
<xs:annotation>
- <xs:documentation>The frequency in seconds in which drift monitoring should run. Defaults to thirty
- minutes.</xs:documentation>
+ <xs:documentation>
+ The frequency in seconds in which drift monitoring should run. Defaults to thirty minutes.
+ </xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="includes" type="drift:Includes" minOccurs="0" maxOccurs="1">
<xs:annotation>
- <xs:documentation>A set of patterns that specify files and/or directories to include.</xs:documentation>
+ <xs:documentation>
+ A set of patterns that specify files and/or directories to include.
+ </xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="excludes" type="drift:Excludes" minOccurs="0" maxOccurs="1">
<xs:annotation>
- <xs:documentation>A set of patterns that specify files and/or directories to exclude.</xs:documentation>
+ <xs:documentation>
+ A set of patterns that specify files and/or directories to exclude.
+ </xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
- <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="name" type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="Includes">
<xs:annotation>
<xs:appinfo>
- <jaxb:class name="IncludesDescriptor"/>
+ <jaxb:class name="IncludesDescriptor" />
</xs:appinfo>
</xs:annotation>
<xs:sequence>
- <xs:element name="include" type="drift:DriftFilter" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="include" type="drift:DriftFilter" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Excludes">
<xs:annotation>
<xs:appinfo>
- <jaxb:class name="ExcludesDescriptor"/>
+ <jaxb:class name="ExcludesDescriptor" />
</xs:appinfo>
</xs:annotation>
<xs:sequence>
- <xs:element name="exclude" type="drift:DriftFilter" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="exclude" type="drift:DriftFilter" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="DriftFilter">
<xs:annotation>
<xs:appinfo>
- <jaxb:class name="DriftFilterDescriptor"/>
+ <jaxb:class name="DriftFilterDescriptor" />
</xs:appinfo>
</xs:annotation>
<xs:attribute name="path" type="xs:string" use="required">
<xs:annotation>
- <xs:documentation>A file system path that can be a directory or a file. The path is assumed to be
- relative to the base directory of the drift configuration.</xs:documentation>
+ <xs:documentation>
+ A file system path that can be a directory or a file. The path is assumed to be
+ relative to the base directory of the drift configuration.
+ </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="pattern" type="xs:string" use="optional">
diff --git a/modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy b/modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy
deleted file mode 100644
index ef41e90..0000000
--- a/modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy
+++ /dev/null
@@ -1,565 +0,0 @@
-/*
- * 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 as published by
- * the Free Software Foundation version 2 of the License.
- *
- * 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 for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.core.clientapi.agent.metadata
-
-import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor
-import org.rhq.core.domain.configuration.definition.ConfigurationFormat
-import org.testng.annotations.Test
-import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.toPluginDescriptor
-import static org.testng.Assert.assertEquals
-import static org.testng.Assert.assertNotNull
-import static org.testng.Assert.assertFalse
-
-class PluginMetadataParserTest {
-
- @Test
- void allTypesShouldHaveOneElementForDescriptorWithOnlyOneResourceType() {
- def pluginDescriptor = toPluginDescriptor(
- """
- <plugin name="TestServer" displayName="Test Server" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin">
- <server name="testServer"
- class="org.rhq.plugins.test.TestServer"
- discovery="org.rhq.plugins.test.TestServerDiscoveryComponent"/>
- </plugin>
- """
- )
-
- def parsersByPlugin = [:]
-
- def parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin)
-
- assertEquals(parser.allTypes.size(), 1, "The allTypes property should have 1 element for descriptor with a single resource type.")
- assertEquals(parser.allTypes[0].name, "testServer", "Expected to find resource type named 'testServer' in allTypes.")
- }
-
- @Test
- void allTypesShouldHaveTwoElementsForDescriptorWithOneServerAndOneService() {
- def pluginDescriptor = toPluginDescriptor(
- """
- <plugin name="TestServer" displayName="Test Server" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin">
- <server name="testServer"
- class="TestServer"
- discovery="TestServerDiscoveryComponent">
- <service name="testService"
- class="TestService"
- discovery="TestServiceDiscoveryComponent"/>
- </server>
- </plugin>
- """
- )
-
- def parsersByPlugin = [:]
-
- def parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin)
-
- assertEquals(parser.allTypes.size(), 2, "The allTypes property should have 2 elements for a descriptor with a server and a child service.")
-
- assertNotNull(parser.allTypes.find { it.name == "testServer" }, "Expected to find 'testServer' resource type.")
- assertNotNull(parser.allTypes.find { it.name == "testService" }, "Expected to find 'testService' resource type.")
- }
-
- @Test
- void rootResourceTypesShouldHaveOneElementForDescriptorWithOnlyOneResourceType() {
- def pluginDescriptor = toPluginDescriptor(
- """
- <plugin name="TestServer" displayName="Test Server" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin">
- <server name="testServer"
- class="org.rhq.plugins.test.TestServer"
- discovery="org.rhq.plugins.test.TestServerDiscoveryComponent"/>
- </plugin>
- """
- )
-
- def parsersByPlugin = [:]
-
- def parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin)
-
- assertEquals(parser.rootResourceTypes.size(), 1, "rootResourceTypes property should have 1 element for descriptor with a single resource type.")
- assertNotNull(parser.rootResourceTypes.find { it.name == 'testServer' }, "Expected to find resource type named 'testServer' in rootResouceTypes.")
- }
-
- @Test
- void getComponentClassShouldReturnValueOfClassAttributeWhenPackageNameIncludedInAttribute() {
- def pluginDescriptor = toPluginDescriptor(
- """
- <plugin name="TestServer" displayName="Test Server" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin">
- <server name="testServer"
- class="org.rhq.plugins.test.TestServer"
- discovery="org.rhq.plugins.test.TestServerDiscoveryComponent"/>
- </plugin>
- """
- )
-
- def parsersByPlugin = [:]
-
- def parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin)
-
- def resourceType = parser.allTypes.find { it.name == "testServer" }
-
- def componentClass = parser.getComponentClass(resourceType)
-
- assertEquals(
- componentClass,
- "org.rhq.plugins.test.TestServer",
- "Expected the package and class name from the 'class' attribute when it includes the package name.")
- }
-
- @Test
- void getComponentClassShouldIncludePluginPackageWhenClassAttributeDoesNotSpecifyPackageName() {
- def pluginDescriptor = toPluginDescriptor(
- """
- <plugin name="TestServer" displayName="Test Server" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin">
- <server name="testServer"
- class="TestServer"
- discovery="TestServerDiscoveryComponent"/>
- </plugin>
- """
- )
-
- def parsersByPlugin = [:]
-
- def parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin)
-
- def resourceType = parser.allTypes.find { it.name == "testServer" }
-
- def componentClass = parser.getComponentClass(resourceType)
-
- assertEquals(
- componentClass,
- "org.rhq.plugins.test.TestServer",
- "Expected the package name from the 'package' attribute of the <plugin> element to be included when the " +
- "package is not included in the 'class' attribute."
- )
- }
-
- @Test
- void getDiscoveryComponentClassShouldReturnValueOfDiscoveryComponentAttributeWhenPackageNameIncludedInAttribute() {
- def pluginDescriptor = toPluginDescriptor(
- """
- <plugin name="TestServer" displayName="Test Server" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin">
- <server name="testServer"
- class="org.rhq.plugins.test.TestServer"
- discovery="org.rhq.plugins.test.TestServerDiscoveryComponent"/>
- </plugin>
- """
- )
-
- def parsersByPlugin = [:]
-
- def parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin)
-
- def resourceType = parser.allTypes.find { it.name == "testServer" }
-
- def discoveryComponent = parser.getDiscoveryComponentClass(resourceType)
-
- assertEquals(
- discoveryComponent,
- "org.rhq.plugins.test.TestServerDiscoveryComponent",
- "Expected the package and class name from 'discovery' attribute when it includes the package name."
- )
- }
-
- @Test
- void getDiscoveryComponentClassShouldIncludePluginPackageWhenDiscoveryAttributeDoesNotSpecifyPackageName() {
- def pluginDescriptor = toPluginDescriptor(
- """
- <plugin name="TestServer" displayName="Test Server" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin">
- <server name="testServer"
- class="TestServer"
- discovery="TestServerDiscoveryComponent"/>
- </plugin>
- """
- )
-
- def parsersByPlugin = [:]
-
- def parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin)
-
- def resourceType = parser.allTypes.find { it.name == "testServer" }
-
- def discoveryComponent = parser.getDiscoveryComponentClass(resourceType)
-
- assertEquals(
- discoveryComponent,
- "org.rhq.plugins.test.TestServerDiscoveryComponent",
- "Expected the package name from the 'package' attribute of the <plugin> element to be included when the " +
- "pacage is not included in the 'discovery' attribute."
- )
- }
-
- @Test
- void childServiceResourceTypeShouldBeAddedToParentServerResourceType() {
- def pluginDescriptor = toPluginDescriptor(
- """
- <plugin name="TestServer" displayName="Test Server" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin">
- <server name="testServer"
- class="TestServer"
- discovery="TestServerDiscoveryComponent">
- <service name="testService"
- class="TestService"
- discovery="TestServiceDiscoveryComponent"/>
- </server>
- </plugin>
- """
- )
-
- def parsersByPlugin = [:]
-
- def parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin)
-
- def serverResourceType = parser.allTypes.find { it.name == "testServer" }
-
- assertNotNull(
- serverResourceType.childResourceTypes.find { it.name == "testService" },
- "Expected resource type 'testService' to be added to its parent resource type 'testServer'"
- )
- }
-
- @Test
- void resourceTypeHavingResourceConfigurationDefinitionShouldBeBuiltForServerWithResourceConfiguration() {
- def pluginDescriptor = toPluginDescriptor(
- """
- <plugin name="TestServer" displayName="Test Server" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin"
- xmlns:c="urn:xmlns:rhq-configuration">
- <server name="testServer"
- class="TestServer"
- discovery="TestServerDiscoveryComponent">
- <resource-configuration>
- <c:simple-property name="foo" defaultValue="bar"/>
- </resource-configuration>
- </server>
- </plugin>
- """
- )
-
- def parsersByPlugin = [:]
-
- def parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin)
-
- def serverResourceType = parser.allTypes.find { it.name == "testServer" }
-
- assertNotNull(serverResourceType.resourceConfigurationDefinition, "Expected resource type to have a resource configuration definition.")
- assertNotNull(
- serverResourceType.resourceConfigurationDefinition.getPropertyDefinitionSimple("foo"),
- "Expected resource configuration to contain a simple property named 'foo'."
- )
- }
-
- @Test
- void configurationDefinitionShouldHaveConfigurationFormatSetWhenSpecifiedInDescriptor() {
- def pluginDescriptor = toPluginDescriptor(
- """
- <plugin name="TestServer" displayName="Test Server" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin"
- xmlns:c="urn:xmlns:rhq-configuration">
- <server name="testServer"
- class="TestServer"
- discovery="TestServerDiscoveryComponent">
- <resource-configuration configurationFormat="structured">
- <c:simple-property name="foo" defaultValue="bar"/>
- </resource-configuration>
- </server>
- </plugin>
- """
- )
-
- def parsersByPlugin = [:]
-
- def parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin)
-
- def serverResourceType = parser.allTypes.find { it.name == "testServer" }
- def resourceConfigurationDefinition = serverResourceType.resourceConfigurationDefinition
-
- assertEquals(
- resourceConfigurationDefinition.configurationFormat,
- ConfigurationFormat.STRUCTURED,
- "Expected configurationFormat property to be set on resource configuration definition."
- )
- }
-
- @Test
- void configurationFormatShouldDefaultToStructuredWhenNotDeclaredInDescriptor() {
- def pluginDescriptor = toPluginDescriptor(
- """
- <plugin name="TestServer" displayName="Test Server" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin"
- xmlns:c="urn:xmlns:rhq-configuration">
- <server name="testServer"
- class="TestServer"
- discovery="TestServerDiscoveryComponent">
- <resource-configuration>
- <c:simple-property name="foo" defaultValue="bar"/>
- </resource-configuration>
- </server>
- </plugin>
- """
- )
-
- def parsersByPlugin = [:]
-
- def parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin)
-
- def serverResourceType = parser.allTypes.find { it.name == "testServer" }
- def resourceConfigurationDefinition = serverResourceType.resourceConfigurationDefinition
-
- assertEquals(
- resourceConfigurationDefinition.configurationFormat,
- ConfigurationFormat.STRUCTURED,
- "The configurationFormat property of the configuration definition should default to stuctured when it is not declared in the plugin descriptor."
- )
- }
-
- @Test
- void rawResourceConfigurationShouldNotHaveToSpecifyAnyStructuredConfig() {
- def pluginDescriptor = toPluginDescriptor(
- """
- <plugin name="TestServer" displayName="Test Server" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin"
- xmlns:c="urn:xmlns:rhq-configuration">
- <server name="testServer"
- class="TestServer"
- discovery="TestServerDiscoveryComponent">
- <resource-configuration configurationFormat="raw"/>
- </server>
- </plugin>
- """
- )
-
- def parsersByPlugin = [:]
-
- def parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin)
-
- }
-
- @Test
- void createDriftConfigurationBasedirDefaultWithSpecifiedValue() {
- def descriptor = toPluginDescriptor(
- """
- <plugin name="drift-test-plugin" displayName="Drift Test" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin"
- xmlns:d="urn:xmlns:rhq-drift">
- <server name="TestServer">
- <drift-configuration name="test1">
- <d:basedir>/var/lib/test1</d:basedir>
- </drift-configuration>
- </server>
- </plugin>
- """
- )
-
- verifyDriftConfiguration(descriptor, 'TestServer', 'test1') { driftTemplate ->
- assertEquals(driftTemplate.configuration.getSimpleValue("basedir", null),
- "/var/lib/test1", "Expected to find default property set for basedir")
- }
- }
-
- @Test
- void createDriftConfigurationIntervalDefault() {
- def descriptor = toPluginDescriptor(
- """
- <plugin name="drift-test-plugin" displayName="Drift Test" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin"
- xmlns:d="urn:xmlns:rhq-drift">
- <server name="TestServer">
- <drift-configuration name="test1">
- <d:basedir>/var/lib/test1</d:basedir>
- </drift-configuration>
- </server>
- </plugin>
- """
- )
-
- verifyDriftConfiguration(descriptor, 'TestServer', 'test1') { driftTemplate ->
- assertEquals(driftTemplate.configuration.getSimpleValue("interval", null), "1800",
- "Expected to find default property set for interval")
- }
- }
-
- @Test
- void createDriftConfigurationIntervalDefaultWithSpecifiedValue() {
- def descriptor = toPluginDescriptor(
- """
- <plugin name="drift-test-plugin" displayName="Drift Test" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin"
- xmlns:d="urn:xmlns:rhq-drift">
- <server name="TestServer">
- <drift-configuration name="test1">
- <d:basedir>/var/lib/test1</d:basedir>
- <d:interval>3600</d:interval>
- </drift-configuration>
- </server>
- </plugin>
- """
- )
-
- verifyDriftConfiguration(descriptor, 'TestServer', 'test1') { driftTemplate ->
- assertEquals(driftTemplate.configuration.getSimpleValue("interval", null), "3600",
- "Expected to find default property set for <interval>")
- }
- }
-
- @Test
- void createDriftConfigurationIncludesDefaultWithSpecifiedValue() {
- def descriptor = toPluginDescriptor(
- """
- <plugin name="drift-test-plugin" displayName="Drift Test" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin"
- xmlns:d="urn:xmlns:rhq-drift">
- <server name="TestServer">
- <drift-configuration name="test1">
- <d:basedir>/var/lib/test1</d:basedir>
- <d:includes>
- <d:include path="lib" pattern="*.jar"/>
- <d:include path="conf" pattern="*.xml"/>
- </d:includes>
- </drift-configuration>
- </server>
- </plugin>
- """
- )
-
- verifyDriftConfiguration(descriptor, 'TestServer', 'test1') { driftTemplate ->
- def config = driftTemplate.configuration
- def includes = config.getList('includes')
-
- assertNotNull(includes, "Expected to find default property set for <includes>")
- assertEquals(includes.list.size(), 2, "Expected <includes> property list to have two property elements.")
-
- def include1 = includes.list[0]
- def path1 = include1.getSimple('path')
- def pattern1 = include1.getSimple('pattern')
-
- assertNotNull(path1, "Expected to find a simple property for the path of the first <include>")
- assertEquals(path1.stringValue, "lib", "The value is wrong for the path of the first <include>")
-
- assertNotNull(pattern1, "Expected to find a simple property for the pattern of the first <include>")
- assertEquals(pattern1.stringValue, '*.jar', 'The value is wrong for the pattern of the first <include>')
-
- def include2 = includes.list[1]
- def path2 = include2.getSimple('path')
- def pattern2 = include2.getSimple('pattern')
-
- assertNotNull(path1, "Expected to find a simple property for the path of the second <include>")
- assertEquals(path1.stringValue, "lib", "The value is wrong for the path of the second <include>")
-
- assertNotNull(pattern1, "Expected to find a simple property for the pattern of the second <include>")
- assertEquals(pattern1.stringValue, '*.jar', 'The value is wrong for the pattern of the second <include>')
- }
- }
-
- @Test
- void createDriftConfigurationExcludesDefaultWithSpecifiedValue() {
- def descriptor = toPluginDescriptor(
- """
- <plugin name="drift-test-plugin" displayName="Drift Test" package="org.rhq.plugins.test"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin"
- xmlns:d="urn:xmlns:rhq-drift">
- <server name="TestServer">
- <drift-configuration name="test1">
- <d:basedir>/var/lib/test1</d:basedir>
- <d:interval>3600</d:interval>
- <d:excludes>
- <d:exclude path="lib" pattern="*.jar"/>
- <d:exclude path="conf" pattern="*.xml"/>
- </d:excludes>
- </drift-configuration>
- </server>
- </plugin>
- """
- )
-
- verifyDriftConfiguration(descriptor, 'TestServer', 'test1') { driftTemplate ->
- def config = driftTemplate.configuration
- def excludes = config.getList('excludes')
-
- assertNotNull(excludes, "Expected to find default property set for <excludes>")
- assertEquals(excludes.list.size(), 2, "Expected <excludes> property list to have two property elements.")
-
- def exclude1 = excludes.list[0]
- def path1 = exclude1.getSimple('path')
- def pattern1 = exclude1.getSimple('pattern')
-
- assertNotNull(path1, "Expected to find a simple property for the path of the first <exclude>")
- assertEquals(path1.stringValue, "lib", "The value is wrong for the path of the first <exclude>")
-
- assertNotNull(pattern1, "Expected to find a simple property for the pattern of the first <exclude>")
- assertEquals(pattern1.stringValue, '*.jar', 'The value is wrong for the pattern of the first <exclude>')
-
- def exclude2 = excludes.list[1]
- def path2 = exclude2.getSimple('path')
- def pattern2 = exclude2.getSimple('pattern')
-
- assertNotNull(path1, "Expected to find a simple property for the path of the second <exclude>")
- assertEquals(path1.stringValue, "lib", "The value is wrong for the path of the second <exclude>")
-
- assertNotNull(pattern1, "Expected to find a simple property for the pattern of the second <exclude>")
- assertEquals(pattern1.stringValue, '*.jar', 'The value is wrong for the pattern of the second <exclude>')
- }
- }
-
- def verifyDriftConfiguration(PluginDescriptor descriptor, String resourceTypeName, String driftConfigName,
- Closure test) {
- def parser = new PluginMetadataParser(descriptor, [:])
- def resourceType = parser.allTypes.find { it.name == resourceTypeName }
- def driftTemplate = resourceType.driftConfigurationTemplates.find { it.name == driftConfigName }
-
- assertNotNull(
- resourceType.driftConfigurationTemplates.find { it.name == driftConfigName},
- "Failed to find drift configuration template <$driftConfigName>. The name attribute may not have been parsed correctly."
- )
-
- def name = driftTemplate.configuration.getSimple('name')
- def enabled = driftTemplate.configuration.getSimple('enabled')
-
- assertNotNull(name, "Expected to find a simple property <name> for the drift configuration name")
- assertEquals(name.stringValue, driftConfigName,
- "The value is wrong for the <name> property that represents the drift configuration name")
-
- assertNotNull(enabled, "Expected to find simple property <enabled> for the drift configuration")
- assertFalse(enabled.booleanValue, "The <enabled> property should be set to a default value of false")
-
- test(driftTemplate)
- }
-}
diff --git a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/PluginMetadataParserTest.java b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/PluginMetadataParserTest.java
new file mode 100644
index 0000000..f44d2cb
--- /dev/null
+++ b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/PluginMetadataParserTest.java
@@ -0,0 +1,837 @@
+/*
+ * 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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.core.clientapi.agent.metadata.test;
+
+import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.toPluginDescriptor;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser;
+import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+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.ConfigurationFormat;
+import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
+import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.drift.DriftConfigurationDefinition;
+import org.rhq.core.domain.drift.DriftConfiguration.BaseDirectory;
+import org.rhq.core.domain.drift.DriftConfiguration.Filter;
+import org.rhq.core.domain.drift.DriftConfigurationDefinition.BaseDirValueContext;
+import org.rhq.core.domain.resource.ResourceType;
+
+@Test
+public class PluginMetadataParserTest {
+
+ @Test
+ void allTypesShouldHaveOneElementForDescriptorWithOnlyOneResourceType() throws Exception {
+ PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
+ "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'>" + //
+ " <server name='testServer'" + //
+ " class='org.rhq.plugins.test.TestServer'" + //
+ " discovery='org.rhq.plugins.test.TestServerDiscoveryComponent'/>" + //
+ "</plugin>");
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);
+
+ assertEquals(parser.getAllTypes().size(), 1,
+ "The allTypes property should have 1 element for descriptor with a single resource type.");
+ assertEquals(parser.getAllTypes().get(0).getName(), "testServer",
+ "Expected to find resource type named 'testServer' in allTypes.");
+ }
+
+ @Test
+ void allTypesShouldHaveTwoElementsForDescriptorWithOneServerAndOneService() throws Exception {
+ PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
+ "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'>" + //
+ " <server name='testServer'" + //
+ " class='TestServer'" + //
+ " discovery='TestServerDiscoveryComponent'>" + //
+ " <service name='testService'" + //
+ " class='TestService'" + //
+ " discovery='TestServiceDiscoveryComponent'/>" + //
+ " </server>" + //
+ "</plugin>");
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);
+
+ assertEquals(parser.getAllTypes().size(), 2,
+ "The allTypes property should have 2 elements for a descriptor with a server and a child service.");
+
+ assertNotNull(findResourceType(parser, "testServer"));
+ assertNotNull(findResourceType(parser, "testService"));
+ }
+
+ private ResourceType findResourceType(PluginMetadataParser parser, String resourceTypeName) {
+ List<ResourceType> allTypes = parser.getAllTypes();
+ for (ResourceType resourceType : allTypes) {
+ if (resourceType.getName().equals(resourceTypeName)) {
+ return resourceType;
+ }
+ }
+ assert false : "expected to find resource type [" + resourceTypeName + "] in: " + allTypes;
+ return null; // no-op since the above assert should always throw exception
+ }
+
+ @Test
+ void rootResourceTypesShouldHaveOneElementForDescriptorWithOnlyOneResourceType() throws Exception {
+ PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
+ "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'>" + //
+ " <server name='testServer'" + //
+ " class='org.rhq.plugins.test.TestServer'" + //
+ " discovery='org.rhq.plugins.test.TestServerDiscoveryComponent'/>" + //
+ "</plugin>");
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);
+
+ assertEquals(parser.getRootResourceTypes().size(), 1,
+ "rootResourceTypes property should have 1 element for descriptor with a single resource type.");
+ Set<ResourceType> rootResourceTypes = parser.getRootResourceTypes();
+ ResourceType root = null;
+ for (ResourceType resourceType : rootResourceTypes) {
+ if (resourceType.getName().equals("testServer")) {
+ root = resourceType;
+ break;
+ }
+ }
+ assertNotNull(root, "Expected to find resource type named 'testServer' in rootResouceTypes.");
+ }
+
+ @Test
+ void getComponentClassShouldReturnValueOfClassAttributeWhenPackageNameIncludedInAttribute() throws Exception {
+ PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
+ "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'>" + //
+ " <server name='testServer'" + //
+ " class='org.rhq.plugins.test.TestServer'" + //
+ " discovery='org.rhq.plugins.test.TestServerDiscoveryComponent'/>" + //
+ "</plugin>");
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);
+
+ ResourceType resourceType = findResourceType(parser, "testServer");
+
+ String componentClass = parser.getComponentClass(resourceType);
+
+ assertEquals(componentClass, "org.rhq.plugins.test.TestServer",
+ "Expected the package and class name from the 'class' attribute when it includes the package name.");
+ }
+
+ @Test
+ void getComponentClassShouldIncludePluginPackageWhenClassAttributeDoesNotSpecifyPackageName() throws Exception {
+ PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
+ "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'>" + //
+ " <server name='testServer'" + //
+ " class='TestServer'" + //
+ " discovery='TestServerDiscoveryComponent'/>" + //
+ "</plugin>");
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);
+
+ ResourceType resourceType = findResourceType(parser, "testServer");
+
+ String componentClass = parser.getComponentClass(resourceType);
+
+ assertEquals(componentClass, "org.rhq.plugins.test.TestServer",
+ "Expected the package name from the 'package' attribute of the <plugin> element to be included when the "
+ + "package is not included in the 'class' attribute.");
+ }
+
+ @Test
+ void getDiscoveryComponentClassShouldReturnValueOfDiscoveryComponentAttributeWhenPackageNameIncludedInAttribute()
+ throws Exception {
+ PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
+ "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'>" + //
+ " <server name='testServer'" + //
+ " class='org.rhq.plugins.test.TestServer'" + //
+ " discovery='org.rhq.plugins.test.TestServerDiscoveryComponent'/>" + //
+ "</plugin>");
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);
+
+ ResourceType resourceType = findResourceType(parser, "testServer");
+
+ String discoveryComponent = parser.getDiscoveryComponentClass(resourceType);
+
+ assertEquals(discoveryComponent, "org.rhq.plugins.test.TestServerDiscoveryComponent",
+ "Expected the package and class name from 'discovery' attribute when it includes the package name.");
+ }
+
+ @Test
+ void getDiscoveryComponentClassShouldIncludePluginPackageWhenDiscoveryAttributeDoesNotSpecifyPackageName()
+ throws Exception {
+ PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
+ "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'>" + //
+ " <server name='testServer'" + //
+ " class='TestServer'" + //
+ " discovery='TestServerDiscoveryComponent'/>" + //
+ "</plugin>");
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);
+
+ ResourceType resourceType = findResourceType(parser, "testServer");
+
+ String discoveryComponent = parser.getDiscoveryComponentClass(resourceType);
+
+ assertEquals(discoveryComponent, "org.rhq.plugins.test.TestServerDiscoveryComponent",
+ "Expected the package name from the 'package' attribute of the <plugin> element to be included when the "
+ + "pacage is not included in the 'discovery' attribute.");
+ }
+
+ @Test
+ void childServiceResourceTypeShouldBeAddedToParentServerResourceType() throws Exception {
+ PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
+ "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'>" + //
+ " <server name='testServer'" + //
+ " class='TestServer'" + //
+ " discovery='TestServerDiscoveryComponent'>" + //
+ " <service name='testService'" + //
+ " class='TestService'" + //
+ " discovery='TestServiceDiscoveryComponent'/>" + //
+ " </server>" + //
+ "</plugin>");
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);
+
+ ResourceType serverResourceType = findResourceType(parser, "testServer");
+ Set<ResourceType> childResourceTypes = serverResourceType.getChildResourceTypes();
+ ResourceType child = null;
+ for (ResourceType resourceType : childResourceTypes) {
+ if (resourceType.getName().equals("testService")) {
+ child = resourceType;
+ break;
+ }
+ }
+
+ assertNotNull(child,
+ "Expected resource type 'testService' to be added to its parent resource type 'testServer'");
+ }
+
+ @Test
+ void resourceTypeHavingResourceConfigurationDefinitionShouldBeBuiltForServerWithResourceConfiguration()
+ throws Exception {
+ PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
+ "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'" + //
+ " xmlns:c='urn:xmlns:rhq-configuration'>" + //
+ " <server name='testServer'" + //
+ " class='TestServer'" + //
+ " discovery='TestServerDiscoveryComponent'>" + //
+ " <resource-configuration>" + //
+ " <c:simple-property name='foo' defaultValue='bar'/>" + //
+ " </resource-configuration>" + //
+ " </server>" + //
+ "</plugin>");
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);
+
+ ResourceType serverResourceType = findResourceType(parser, "testServer");
+
+ assertNotNull(serverResourceType.getResourceConfigurationDefinition(),
+ "Expected resource type to have a resource configuration definition.");
+ assertNotNull(serverResourceType.getResourceConfigurationDefinition().getPropertyDefinitionSimple("foo"),
+ "Expected resource configuration to contain a simple property named 'foo'.");
+ }
+
+ @Test
+ void configurationDefinitionShouldHaveConfigurationFormatSetWhenSpecifiedInDescriptor() throws Exception {
+ PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
+ "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'" + //
+ " xmlns:c='urn:xmlns:rhq-configuration'>" + //
+ " <server name='testServer'" + //
+ " class='TestServer'" + //
+ " discovery='TestServerDiscoveryComponent'>" + //
+ " <resource-configuration configurationFormat='structured'>" + //
+ " <c:simple-property name='foo' defaultValue='bar'/>" + //
+ " </resource-configuration>" + //
+ " </server>" + //
+ "</plugin>");
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);
+
+ ResourceType serverResourceType = findResourceType(parser, "testServer");
+ ConfigurationDefinition resourceConfigurationDefinition = serverResourceType
+ .getResourceConfigurationDefinition();
+
+ assertEquals(resourceConfigurationDefinition.getConfigurationFormat(), ConfigurationFormat.STRUCTURED,
+ "Expected configurationFormat property to be set on resource configuration definition.");
+ }
+
+ @Test
+ void configurationFormatShouldDefaultToStructuredWhenNotDeclaredInDescriptor() throws Exception {
+ PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
+ "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'" + //
+ " xmlns:c='urn:xmlns:rhq-configuration'>" + //
+ " <server name='testServer'" + //
+ " class='TestServer'" + //
+ " discovery='TestServerDiscoveryComponent'>" + //
+ " <resource-configuration>" + //
+ " <c:simple-property name='foo' defaultValue='bar'/>" + //
+ " </resource-configuration>" + //
+ " </server>" + //
+ "</plugin>");
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);
+
+ ResourceType serverResourceType = findResourceType(parser, "testServer");
+ ConfigurationDefinition resourceConfigurationDefinition = serverResourceType
+ .getResourceConfigurationDefinition();
+
+ assertEquals(
+ resourceConfigurationDefinition.getConfigurationFormat(),
+ ConfigurationFormat.STRUCTURED,
+ "The configurationFormat property of the configuration definition should default to stuctured when it is not declared in the plugin descriptor.");
+ }
+
+ @Test
+ void rawResourceConfigurationShouldNotHaveToSpecifyAnyStructuredConfig() throws Exception {
+ PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
+ "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'" + //
+ " xmlns:c='urn:xmlns:rhq-configuration'>" + //
+ " <server name='testServer'" + //
+ " class='TestServer'" + //
+ " discovery='TestServerDiscoveryComponent'>" + //
+ " <resource-configuration configurationFormat='raw'/>" + //
+ " </server>" + //
+ "</plugin>");
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);
+ assert parser.getAllTypes().size() > 0;
+ }
+
+ @Test
+ void createDriftConfigurationBasedir() throws Exception {
+ PluginDescriptor descriptor = toPluginDescriptor("" + //
+ "<plugin name='drift-test-plugin' displayName='Drift Test' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'" + //
+ " xmlns:d='urn:xmlns:rhq-drift'>" + //
+ " <server name='TestServer'>" + //
+ " <drift-configuration name='test1'>" + //
+ " <d:basedir>" + //
+ " <d:value-context>pluginConfiguration</d:value-context>" + //
+ " <d:value-name>var.lib.test1</d:value-name>" + //
+ " </d:basedir>" + //
+ " </drift-configuration>" + //
+ " </server>" + //
+ "</plugin>");
+
+ verifyDriftConfiguration(descriptor, "TestServer", "test1", new AssertDriftTemplateRunnable() {
+ @Override
+ public void assertDriftTemplate(ConfigurationTemplate driftTemplate) throws Exception {
+ DriftConfiguration dc = new DriftConfiguration(driftTemplate.getConfiguration());
+ BaseDirectory basedir = dc.getBasedir();
+ assertEquals(basedir.getValueContext(), BaseDirValueContext.pluginConfiguration, "Bad value context");
+ assertEquals(basedir.getValueName(), "var.lib.test1", "Bad value name");
+ }
+ });
+ }
+
+ @Test
+ void createDriftConfigurationInvalidBasedir() throws Exception {
+ try {
+ toPluginDescriptor("" + //
+ "<plugin name='drift-test-plugin' displayName='Drift Test' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'" + //
+ " xmlns:d='urn:xmlns:rhq-drift'>" + //
+ " <server name='TestServer'>" + //
+ " <drift-configuration name='test1'>" + //
+ " <d:basedir>" + //
+ " <d:value-context>saywhat</d:value-context>" + // this is an invalid context
+ " <d:value-name>var.lib.test1</d:value-name>" + //
+ " </d:basedir>" + //
+ " </drift-configuration>" + //
+ " </server>" + //
+ "</plugin>");
+ assert false : "should not have reached here, the XML itself was invalid and should not have parsed";
+ } catch (Exception ignore) {
+ // this is OK and expected - the XML should not have parsed due to the invalid context
+ }
+ }
+
+ @Test
+ void createDriftConfigurationIntervalDefault() throws Exception {
+ PluginDescriptor descriptor = toPluginDescriptor("" + //
+ "<plugin name='drift-test-plugin' displayName='Drift Test' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'" + //
+ " xmlns:d='urn:xmlns:rhq-drift'>" + //
+ " <server name='TestServer'>" + //
+ " <drift-configuration name='test1'>" + //
+ " <d:basedir>" + //
+ " <d:value-context>pluginConfiguration</d:value-context>" + //
+ " <d:value-name>var.lib.test1</d:value-name>" + //
+ " </d:basedir>" + //
+ " </drift-configuration>" + //
+ " </server>" + //
+ "</plugin>");
+
+ verifyDriftConfiguration(descriptor, "TestServer", "test1", new AssertDriftTemplateRunnable() {
+ @Override
+ public void assertDriftTemplate(ConfigurationTemplate driftTemplate) throws Exception {
+ assertEquals(driftTemplate.getConfiguration().getSimpleValue(
+ DriftConfigurationDefinition.PROP_INTERVAL, null), String
+ .valueOf(DriftConfigurationDefinition.DEFAULT_INTERVAL),
+ "Expected to find default property set for interval");
+ }
+ });
+ }
+
+ @Test
+ void createDriftConfigurationIntervalDefaultWithSpecifiedValue() throws Exception {
+ PluginDescriptor descriptor = toPluginDescriptor("" + //
+ "<plugin name='drift-test-plugin' displayName='Drift Test' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'" + //
+ " xmlns:d='urn:xmlns:rhq-drift'>" + //
+ " <server name='TestServer'>" + //
+ " <drift-configuration name='test1'>" + //
+ " <d:basedir>" + //
+ " <d:value-context>pluginConfiguration</d:value-context>" + //
+ " <d:value-name>var.lib.test1</d:value-name>" + //
+ " </d:basedir>" + //
+ " <d:interval>3600</d:interval>" + //
+ " </drift-configuration>" + //
+ " </server>" + //
+ "</plugin>");
+
+ verifyDriftConfiguration(descriptor, "TestServer", "test1", new AssertDriftTemplateRunnable() {
+ @Override
+ public void assertDriftTemplate(ConfigurationTemplate driftTemplate) throws Exception {
+ assertEquals(driftTemplate.getConfiguration().getSimpleValue(
+ DriftConfigurationDefinition.PROP_INTERVAL, null), "3600",
+ "Expected to find default property set for <interval>");
+ }
+ });
+
+ }
+
+ @Test
+ void createDriftConfigurationIncludesDefaultWithSpecifiedValue() throws Exception {
+ PluginDescriptor descriptor = toPluginDescriptor("" + //
+ "<plugin name='drift-test-plugin' displayName='Drift Test' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'" + //
+ " xmlns:d='urn:xmlns:rhq-drift'>" + //
+ " <server name='TestServer'>" + //
+ " <drift-configuration name='test1'>" + //
+ " <d:basedir>" + //
+ " <d:value-context>pluginConfiguration</d:value-context>" + //
+ " <d:value-name>var.lib.test1</d:value-name>" + //
+ " </d:basedir>" + //
+ " <d:includes>" + //
+ " <d:include path='lib' pattern='*.jar'/>" + //
+ " <d:include path='conf' pattern='*.xml'/>" + //
+ " </d:includes>" + //
+ " </drift-configuration>" + //
+ " </server>" + //
+ "</plugin>");
+
+ verifyDriftConfiguration(descriptor, "TestServer", "test1", new AssertDriftTemplateRunnable() {
+ @Override
+ public void assertDriftTemplate(ConfigurationTemplate driftTemplate) throws Exception {
+ Configuration config = driftTemplate.getConfiguration();
+ PropertyList includes = config.getList(DriftConfigurationDefinition.PROP_INCLUDES);
+
+ assertNotNull(includes, "Expected to find default property set for <includes>");
+ assertEquals(includes.getList().size(), 2,
+ "Expected <includes> property list to have two property elements.");
+
+ PropertyMap include1 = (PropertyMap) includes.getList().get(0);
+ PropertySimple path1 = include1.getSimple(DriftConfigurationDefinition.PROP_PATH);
+ PropertySimple pattern1 = include1.getSimple(DriftConfigurationDefinition.PROP_PATTERN);
+
+ assertNotNull(path1, "Expected to find a simple property for the path of the first <include>");
+ assertEquals(path1.getStringValue(), "lib", "The value is wrong for the path of the first <include>");
+
+ assertNotNull(pattern1, "Expected to find a simple property for the pattern of the first <include>");
+ assertEquals(pattern1.getStringValue(), "*.jar",
+ "The value is wrong for the pattern of the first <include>");
+
+ PropertyMap include2 = (PropertyMap) includes.getList().get(1);
+ PropertySimple path2 = include2.getSimple(DriftConfigurationDefinition.PROP_PATH);
+ PropertySimple pattern2 = include2.getSimple(DriftConfigurationDefinition.PROP_PATTERN);
+
+ assertNotNull(path2, "Expected to find a simple property for the path of the second <include>");
+ assertEquals(path2.getStringValue(), "conf", "The value is wrong for the path of the second <include>");
+
+ assertNotNull(pattern2, "Expected to find a simple property for the pattern of the second <include>");
+ assertEquals(pattern2.getStringValue(), "*.xml",
+ "The value is wrong for the pattern of the second <include>");
+ }
+ });
+ }
+
+ @Test
+ void createDriftConfigurationExcludesDefaultWithSpecifiedValue() throws Exception {
+ PluginDescriptor descriptor = toPluginDescriptor("" + //
+ "<plugin name='drift-test-plugin' displayName='Drift Test' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'" + //
+ " xmlns:d='urn:xmlns:rhq-drift'>" + //
+ " <server name='TestServer'>" + //
+ " <drift-configuration name='test1'>" + //
+ " <d:basedir>" + //
+ " <d:value-context>pluginConfiguration</d:value-context>" + //
+ " <d:value-name>var.lib.test1</d:value-name>" + //
+ " </d:basedir>" + //
+ " <d:interval>3600</d:interval>" + //
+ " <d:excludes>" + //
+ " <d:exclude path='lib' pattern='*.jar'/>" + //
+ " <d:exclude path='conf' pattern='*.xml'/>" + //
+ " </d:excludes>" + //
+ " </drift-configuration>" + //
+ " </server>" + //
+ "</plugin>");
+
+ verifyDriftConfiguration(descriptor, "TestServer", "test1", new AssertDriftTemplateRunnable() {
+ @Override
+ public void assertDriftTemplate(ConfigurationTemplate driftTemplate) throws Exception {
+ Configuration config = driftTemplate.getConfiguration();
+ PropertyList excludes = config.getList(DriftConfigurationDefinition.PROP_EXCLUDES);
+
+ assertNotNull(excludes, "Expected to find default property set for <excludes>");
+ assertEquals(excludes.getList().size(), 2,
+ "Expected <excludes> property list to have two property elements.");
+
+ PropertyMap exclude1 = (PropertyMap) excludes.getList().get(0);
+ PropertySimple path1 = exclude1.getSimple(DriftConfigurationDefinition.PROP_PATH);
+ PropertySimple pattern1 = exclude1.getSimple(DriftConfigurationDefinition.PROP_PATTERN);
+
+ assertNotNull(path1, "Expected to find a simple property for the path of the first <exclude>");
+ assertEquals(path1.getStringValue(), "lib", "The value is wrong for the path of the first <exclude>");
+
+ assertNotNull(pattern1, "Expected to find a simple property for the pattern of the first <exclude>");
+ assertEquals(pattern1.getStringValue(), "*.jar",
+ "The value is wrong for the pattern of the first <exclude>");
+
+ PropertyMap exclude2 = (PropertyMap) excludes.getList().get(1);
+ PropertySimple path2 = exclude2.getSimple(DriftConfigurationDefinition.PROP_PATH);
+ PropertySimple pattern2 = exclude2.getSimple(DriftConfigurationDefinition.PROP_PATTERN);
+
+ assertNotNull(path2, "Expected to find a simple property for the path of the second <exclude>");
+ assertEquals(path2.getStringValue(), "conf", "The value is wrong for the path of the second <exclude>");
+
+ assertNotNull(pattern2, "Expected to find a simple property for the pattern of the second <exclude>");
+ assertEquals(pattern2.getStringValue(), "*.xml",
+ "The value is wrong for the pattern of the second <exclude>");
+ }
+ });
+ }
+
+ /**
+ * This also tests DriftConfiguration POJO.
+ *
+ * @throws Exception
+ */
+ @Test
+ void createDriftConfigurationMultipleAndTestDriftConfiguration() throws Exception {
+ PluginDescriptor descriptor = toPluginDescriptor("" + //
+ "<plugin name='drift-test-plugin' displayName='Drift Test' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'" + //
+ " xmlns:d='urn:xmlns:rhq-drift'>" + //
+ " <server name='TestServer'>" + //
+ " <drift-configuration name='test1'>" + //
+ " <d:basedir>" + //
+ " <d:value-context>pluginConfiguration</d:value-context>" + //
+ " <d:value-name>var.lib.test1</d:value-name>" + //
+ " </d:basedir>" + //
+ " <d:interval>11111</d:interval>" + //
+ " <d:includes>" + //
+ " <d:include path='ilib' pattern='*.ijar'/>" + //
+ " <d:include path='iconf' pattern='*.ixml'/>" + //
+ " </d:includes>" + //
+ " </drift-configuration>" + //
+ " <drift-configuration name='test2'>" + //
+ " <d:basedir>" + //
+ " <d:value-context>resourceConfiguration</d:value-context>" + //
+ " <d:value-name>var.lib.test2</d:value-name>" + //
+ " </d:basedir>" + //
+ " <d:interval>22222</d:interval>" + //
+ " <d:excludes>" + //
+ " <d:exclude path='elib' pattern='*.ejar'/>" + //
+ " <d:exclude path='econf' pattern='*.exml'/>" + //
+ " </d:excludes>" + //
+ " </drift-configuration>" + //
+ " <drift-configuration name='test3'>" + //
+ " <d:basedir>" + //
+ " <d:value-context>measurementTrait</d:value-context>" + //
+ " <d:value-name>var.lib.test3</d:value-name>" + //
+ " </d:basedir>" + //
+ " <d:interval>33333</d:interval>" + //
+ " <d:includes>" + //
+ " <d:include path='ilib' pattern='*.ijar'/>" + //
+ " <d:include path='iconf' pattern='*.ixml'/>" + //
+ " </d:includes>" + //
+ " <d:excludes>" + //
+ " <d:exclude path='elib' pattern='*.ejar'/>" + //
+ " <d:exclude path='econf' pattern='*.exml'/>" + //
+ " </d:excludes>" + //
+ " </drift-configuration>" + //
+ " <drift-configuration name='test4'>" + //
+ " <d:basedir>" + //
+ " <d:value-context>fileSystem</d:value-context>" + //
+ " <d:value-name>/wot/gorilla</d:value-name>" + //
+ " </d:basedir>" + //
+ " <d:interval>44444</d:interval>" + //
+ " </drift-configuration>" + //
+ " </server>" + //
+ "</plugin>");
+
+ verifyDriftConfiguration(descriptor, "TestServer", "test1", new AssertDriftTemplateRunnable() {
+ @Override
+ public void assertDriftTemplate(ConfigurationTemplate driftTemplate) throws Exception {
+ Configuration config = driftTemplate.getConfiguration();
+ DriftConfiguration dconfig = new DriftConfiguration(config);
+
+ assertEquals(dconfig.getInterval().longValue(), 11111L);
+ assertEquals(dconfig.getBasedir().getValueContext(), BaseDirValueContext.pluginConfiguration);
+ assertEquals(dconfig.getBasedir().getValueName(), "var.lib.test1");
+
+ assertNotNull(dconfig.getExcludes(), "though we have no excludes, still expect non-null empty list");
+ assertEquals(dconfig.getExcludes().size(), 0);
+
+ List<Filter> includes = dconfig.getIncludes();
+
+ assertNotNull(includes, "Expected to find default property set for <includes>");
+ assertEquals(includes.size(), 2, "Expected <includes> property list to have two property elements.");
+
+ DriftConfiguration.Filter include1 = includes.get(0);
+ String path1 = include1.getPath();
+ String pattern1 = include1.getPattern();
+
+ assertNotNull(path1, "Expected to find a simple property for the path of the first <include>");
+ assertEquals(path1, "ilib", "The value is wrong for the path of the first <include>");
+
+ assertNotNull(pattern1, "Expected to find a simple property for the pattern of the first <include>");
+ assertEquals(pattern1, "*.ijar", "The value is wrong for the pattern of the first <include>");
+
+ DriftConfiguration.Filter include2 = includes.get(1);
+ String path2 = include2.getPath();
+ String pattern2 = include2.getPattern();
+
+ assertNotNull(path2, "Expected to find a simple property for the path of the second <include>");
+ assertEquals(path2, "iconf", "The value is wrong for the path of the second <include>");
+
+ assertNotNull(pattern2, "Expected to find a simple property for the pattern of the second <include>");
+ assertEquals(pattern2, "*.ixml", "The value is wrong for the pattern of the second <include>");
+ }
+ });
+
+ verifyDriftConfiguration(descriptor, "TestServer", "test2", new AssertDriftTemplateRunnable() {
+ @Override
+ public void assertDriftTemplate(ConfigurationTemplate driftTemplate) throws Exception {
+ Configuration config = driftTemplate.getConfiguration();
+ DriftConfiguration dconfig = new DriftConfiguration(config);
+
+ assertEquals(dconfig.getInterval().longValue(), 22222L);
+ assertEquals(dconfig.getBasedir().getValueContext(), BaseDirValueContext.resourceConfiguration);
+ assertEquals(dconfig.getBasedir().getValueName(), "var.lib.test2");
+
+ assertNotNull(dconfig.getIncludes(), "though we have no includes, still expect non-null empty list");
+ assertEquals(dconfig.getIncludes().size(), 0);
+
+ List<Filter> excludes = dconfig.getExcludes();
+
+ assertNotNull(excludes, "Expected to find default property set for <excludes>");
+ assertEquals(excludes.size(), 2, "Expected <excludes> property list to have two property elements.");
+
+ DriftConfiguration.Filter exclude1 = excludes.get(0);
+ String path1 = exclude1.getPath();
+ String pattern1 = exclude1.getPattern();
+
+ assertNotNull(path1, "Expected to find a simple property for the path of the first <exclude>");
+ assertEquals(path1, "elib", "The value is wrong for the path of the first <exclude>");
+
+ assertNotNull(pattern1, "Expected to find a simple property for the pattern of the first <exclude>");
+ assertEquals(pattern1, "*.ejar", "The value is wrong for the pattern of the first <exclude>");
+
+ DriftConfiguration.Filter exclude2 = excludes.get(1);
+ String path2 = exclude2.getPath();
+ String pattern2 = exclude2.getPattern();
+
+ assertNotNull(path2, "Expected to find a simple property for the path of the second <exclude>");
+ assertEquals(path2, "econf", "The value is wrong for the path of the second <exclude>");
+
+ assertNotNull(pattern2, "Expected to find a simple property for the pattern of the second <exclude>");
+ assertEquals(pattern2, "*.exml", "The value is wrong for the pattern of the second <exclude>");
+ }
+ });
+
+ verifyDriftConfiguration(descriptor, "TestServer", "test3", new AssertDriftTemplateRunnable() {
+ @Override
+ public void assertDriftTemplate(ConfigurationTemplate driftTemplate) throws Exception {
+ Configuration config = driftTemplate.getConfiguration();
+ DriftConfiguration dconfig = new DriftConfiguration(config);
+
+ assertEquals(dconfig.getInterval().longValue(), 33333L);
+ assertEquals(dconfig.getBasedir().getValueContext(), BaseDirValueContext.measurementTrait);
+ assertEquals(dconfig.getBasedir().getValueName(), "var.lib.test3");
+
+ List<Filter> includes = dconfig.getIncludes();
+
+ assertNotNull(includes, "Expected to find default property set for <includes>");
+ assertEquals(includes.size(), 2, "Expected <includes> property list to have two property elements.");
+
+ DriftConfiguration.Filter include1 = includes.get(0);
+ String path1 = include1.getPath();
+ String pattern1 = include1.getPattern();
+
+ assertNotNull(path1, "Expected to find a simple property for the path of the first <include>");
+ assertEquals(path1, "ilib", "The value is wrong for the path of the first <include>");
+
+ assertNotNull(pattern1, "Expected to find a simple property for the pattern of the first <include>");
+ assertEquals(pattern1, "*.ijar", "The value is wrong for the pattern of the first <include>");
+
+ DriftConfiguration.Filter include2 = includes.get(1);
+ String path2 = include2.getPath();
+ String pattern2 = include2.getPattern();
+
+ assertNotNull(path2, "Expected to find a simple property for the path of the second <include>");
+ assertEquals(path2, "iconf", "The value is wrong for the path of the second <include>");
+
+ assertNotNull(pattern2, "Expected to find a simple property for the pattern of the second <include>");
+ assertEquals(pattern2, "*.ixml", "The value is wrong for the pattern of the second <include>");
+
+ List<Filter> excludes = dconfig.getExcludes();
+
+ assertNotNull(excludes, "Expected to find default property set for <excludes>");
+ assertEquals(excludes.size(), 2, "Expected <excludes> property list to have two property elements.");
+
+ DriftConfiguration.Filter exclude1 = excludes.get(0);
+ path1 = exclude1.getPath();
+ pattern1 = exclude1.getPattern();
+
+ assertNotNull(path1, "Expected to find a simple property for the path of the first <exclude>");
+ assertEquals(path1, "elib", "The value is wrong for the path of the first <exclude>");
+
+ assertNotNull(pattern1, "Expected to find a simple property for the pattern of the first <exclude>");
+ assertEquals(pattern1, "*.ejar", "The value is wrong for the pattern of the first <exclude>");
+
+ DriftConfiguration.Filter exclude2 = excludes.get(1);
+ path2 = exclude2.getPath();
+ pattern2 = exclude2.getPattern();
+
+ assertNotNull(path2, "Expected to find a simple property for the path of the second <exclude>");
+ assertEquals(path2, "econf", "The value is wrong for the path of the second <exclude>");
+
+ assertNotNull(pattern2, "Expected to find a simple property for the pattern of the second <exclude>");
+ assertEquals(pattern2, "*.exml", "The value is wrong for the pattern of the second <exclude>");
+ }
+ });
+
+ verifyDriftConfiguration(descriptor, "TestServer", "test4", new AssertDriftTemplateRunnable() {
+ @Override
+ public void assertDriftTemplate(ConfigurationTemplate driftTemplate) throws Exception {
+ Configuration config = driftTemplate.getConfiguration();
+ DriftConfiguration dconfig = new DriftConfiguration(config);
+
+ assertEquals(dconfig.getInterval().longValue(), 44444L);
+ assertEquals(dconfig.getBasedir().getValueContext(), BaseDirValueContext.fileSystem);
+ assertEquals(dconfig.getBasedir().getValueName(), "/wot/gorilla");
+
+ assertNotNull(dconfig.getIncludes(), "though we have no includes, still expect non-null empty list");
+ assertEquals(dconfig.getIncludes().size(), 0);
+
+ assertNotNull(dconfig.getExcludes(), "though we have no excludes, still expect non-null empty list");
+ assertEquals(dconfig.getExcludes().size(), 0);
+ }
+ });
+ }
+
+ private interface AssertDriftTemplateRunnable {
+ void assertDriftTemplate(ConfigurationTemplate driftTemplate) throws Exception;
+ }
+
+ private void verifyDriftConfiguration(PluginDescriptor descriptor, String resourceTypeName, String driftConfigName,
+ AssertDriftTemplateRunnable test) throws Exception {
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(descriptor, parsersByPlugin);
+ ResourceType resourceType = findResourceType(parser, resourceTypeName);
+ Set<ConfigurationTemplate> driftTemplates = resourceType.getDriftConfigurationTemplates();
+ ConfigurationTemplate driftTemplate = null;
+ for (ConfigurationTemplate template : driftTemplates) {
+ if (template.getName().equals(driftConfigName)) {
+ driftTemplate = template;
+ break;
+ }
+ }
+ assertNotNull(driftTemplate, "Failed to find drift configuration template [" + driftConfigName
+ + "]. The name attribute may not have been parsed correctly.");
+
+ PropertySimple name = driftTemplate.getConfiguration().getSimple(DriftConfigurationDefinition.PROP_NAME);
+ PropertySimple enabled = driftTemplate.getConfiguration().getSimple(DriftConfigurationDefinition.PROP_ENABLED);
+
+ assertNotNull(name, "Expected to find a simple property <name> for the drift configuration name");
+ assertEquals(name.getStringValue(), driftConfigName,
+ "The value is wrong for the <name> property that represents the drift configuration name");
+
+ assertNotNull(enabled, "Expected to find simple property <enabled> for the drift configuration");
+ assertFalse(enabled.getBooleanValue(), "The <enabled> property should be set to a default value of false");
+
+ test.assertDriftTemplate(driftTemplate);
+ }
+}
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/config-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/config-data.xml
index 03768a2..089cd64 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/config-data.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/config-data.xml
@@ -2,37 +2,149 @@
<dbsetup name="config-data.xml">
<table name="RHQ_CONFIG_DEF">
- <data id="1" name="GLOBAL_DRIFT_CONFIG_DEF" description="The drift configuration definition"/>
+ <data id="1" name="GLOBAL_DRIFT_CONFIG_DEF" description="The drift configuration definition"
+ config_format="STRUCTURED" />
</table>
<table name="RHQ_CONFIG_PROP_DEF">
- <data id="1" name="name" display_name="Drift Configuration Name" description="The drift configuration name"
- required="true" simple_type="string" order_index="0" dtype="property" config_def_id="1"/>
- <data id="2" name="enabled" display_name="Enabled" description="Enables or disables the drift configuration"
- required="true" default_value="false" simple_type="boolean" order_index="1" dtype="property" config_def_id="1"/>
- <data id="3" name="basedir" display_name="Base Directory" dtype="property"
+ <data id="1" name="name" display_name="Drift Configuration Name" config_def_id="1"
+ description="The drift configuration name"
+ required="true"
+ readonly="false"
+ summary="true"
+ order_index="0"
+ dtype="property"
+ simple_type="STRING"
+ allow_custom_enum_value="false" />
+
+ <data id="2" name="enabled" display_name="Enabled" config_def_id="1"
+ description="Enables or disables the drift configuration"
+ required="true"
+ readonly="false"
+ summary="true"
+ order_index="1"
+ dtype="property"
+ simple_type="BOOLEAN"
+ allow_custom_enum_value="false"
+ default_value="false" />
+
+ <data id="3" name="basedir" display_name="Base Directory" config_def_id="1"
description="The root directory from which snapshots will be generated during drift monitoring."
- required="true" simple_type="string" order_index="2" config_def_id="1"/>
- <data id="4" name="interval" display_name="Interval" dtype="property"
- description="The frequency in seconds in which drift monitoring should run. Defaults to thirty minutes."
- default_value="1800" simple_type="long" order_index="3" config_def_id="1"/>
- <data id="5" name="includes" display_name="Includes" dtype="list"
- description="A set of patterns that specify files and/or directories to include." order_index="4"
- config_def_id="1"/>
- <data id="6" name="include" display_name="Include" dtype="map" parent_list_definition_id="4"/>
- <data id="7" name="path" display_name="Path" dtype="property"
+ required="true"
+ readonly="false"
+ summary="true"
+ order_index="2"
+ dtype="map" />
+
+ <data id="4" name="valueContext" display_name="Value Context" parent_map_definition_id="3"
+ description="Identifies where the named value can be found."
+ required="true"
+ readonly="false"
+ summary="true"
+ order_index="0"
+ dtype="property"
+ simple_type="STRING"
+ allow_custom_enum_value="false" />
+
+ <data id="5" name="valueName" display_name="Value Name" parent_map_definition_id="3"
+ description="The name of the value as found in the context"
+ required="true"
+ readonly="false"
+ summary="true"
+ order_index="1"
+ dtype="property"
+ simple_type="STRING"
+ allow_custom_enum_value="false" />
+
+ <data id="6" name="interval" display_name="Interval" config_def_id="1"
+ description="The frequency in seconds in which drift monitoring should run. Defaults to 1800 seconds (i.e. 30 minutes)"
+ required="false"
+ readonly="false"
+ summary="true"
+ order_index="3"
+ dtype="property"
+ simple_type="LONG"
+ allow_custom_enum_value="false"
+ default_value="1800" />
+
+ <data id="7" name="includes" display_name="Includes" config_def_id="1"
+ description="A set of patterns that specify files and/or directories to include."
+ required="false"
+ readonly="false"
+ summary="true"
+ order_index="4"
+ dtype="list" />
+
+ <data id="8" name="include" display_name="Include" parent_list_definition_id="7"
+ description="A pattern that specifies a file or directory to include."
+ required="true"
+ readonly="false"
+ summary="true"
+ order_index="0"
+ dtype="map" />
+
+ <data id="9" name="path" display_name="Path" parent_map_definition_id="8"
description="A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration."
- simple_type="string" order_index="0" parent_map_definition_id="5"/>
- <data id="8" name="pattern" display_name="Pattern" dtype="property" description="TBD" simple_type="string"
- order_index="1" parent_map_definition_id="5"/>
- <data id="9" name="excludes" display_name="Excludes" dtype="list"
- description="A set of patterns that specify files and/or directories to exclude." order_index="5"
- config_def_id="1"/>
- <data id="10" name="exclude" display_name="Exclude" dtype="map" parent_list_definition_id="8"/>
- <data id="11" name="path" display_name="Path" dtype="property"
+ required="true"
+ readonly="false"
+ summary="true"
+ order_index="0"
+ dtype="property"
+ simple_type="STRING"
+ allow_custom_enum_value="false" />
+
+ <data id="10" name="pattern" display_name="Pattern" parent_map_definition_id="8"
+ description="Pathname pattern that must match for the items in the directory path to be included."
+ required="false"
+ readonly="false"
+ summary="true"
+ order_index="1"
+ dtype="property"
+ simple_type="STRING"
+ allow_custom_enum_value="false" />
+
+ <data id="11" name="excludes" display_name="Excludes" config_def_id="1"
+ description="A set of patterns that specify files and/or directories to exclude."
+ required="false"
+ readonly="false"
+ summary="true"
+ order_index="5"
+ dtype="list" />
+
+ <data id="12" name="exclude" display_name="Exclude" parent_list_definition_id="11"
+ description="A pattern that specifies a files or directory to exclude."
+ required="true"
+ readonly="false"
+ summary="true"
+ order_index="0"
+ dtype="map" />
+
+ <data id="13" name="path" display_name="Path" parent_map_definition_id="12"
description="A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration."
- simple_type="string" order_index="0" parent_map_definition_id="9"/>
- <data id="12" name="pattern" display_name="Pattern" dtype="property" description="TBD" simple_type="string"
- order_index="1" parent_map_definition_id="9"/>
+ required="true"
+ readonly="false"
+ summary="true"
+ order_index="0"
+ dtype="property"
+ simple_type="STRING"
+ allow_custom_enum_value="false" />
+
+ <data id="14" name="pattern" display_name="Pattern" parent_map_definition_id="12"
+ description="Pathname pattern that must match for the items in the directory path to be excluded."
+ required="false"
+ readonly="false"
+ summary="true"
+ order_index="1"
+ dtype="property"
+ simple_type="STRING"
+ allow_custom_enum_value="false" />
+ </table>
+
+ <table name="RHQ_CONF_PROP_DEF_ENUM">
+ <data id="1" name="pluginConfiguration" string_value="pluginConfiguration" order_index="0" property_def_id="4" />
+ <data id="2" name="resourceConfiguration" string_value="resourceConfiguration" order_index="1" property_def_id="4" />
+ <data id="3" name="measurementTrait" string_value="measurementTrait" order_index="2" property_def_id="4" />
+ <data id="4" name="fileSystem" string_value="fileSystem" order_index="3" property_def_id="4" />
</table>
+
</dbsetup>
\ No newline at end of file
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 8f0a9c7..d34a247 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3451,70 +3451,52 @@
VALUES (1, 'GLOBAL_DRIFT_CONFIG_DEF', 'The drift configuration definition')
</statement>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type,
- order_index, dtype, config_def_id)
- VALUES (1, 'name', 'Drift Configuration Name', 'The drift configuration name', true, 'string',
- 0, 'property', 1)
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type, order_index, dtype, config_def_id)
+ VALUES (1, 'name', 'Drift Configuration Name', 'The drift configuration name', true, 'STRING', 0, 'property', 1)
</statement>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type,
- default_value, order_index, dtype, config_def_id)
- VALUES (2, 'enabled', 'Enabled', 'Enables or disables drift detection for this configuration', true, 'boolean',
- 'false', 1, 'property', 1)
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type, default_value, order_index, dtype, config_def_id)
+ VALUES (2, 'enabled', 'Enabled', 'Enables or disables drift detection for this configuration', true, 'BOOLEAN', 'false', 1, 'property', 1)
</statement>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type,
- order_index, dtype, config_def_id)
- VALUES (3, 'basedir', 'Base Directory', 'The base directory from which files will be monitored for drift.',
- true, 'string', 2, 'property', 1)
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type, order_index, dtype, config_def_id)
+ VALUES (3, 'basedir', 'Base Directory', 'The base directory from which files will be monitored for drift.', true, 'STRING', 2, 'property', 1)
</statement>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type,
- order_index, dtype, default_value, config_def_id)
- VALUES (4, 'interval', 'Interval', 'The interval, in seconds, between drift detection scans for this configuration. Default is thirty minutes.',
- false, 'long', 3, 'property', '1800', 1)
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type, order_index, dtype, default_value, config_def_id)
+ VALUES (4, 'interval', 'Interval', 'The interval, in seconds, between drift detection scans for this configuration. Default is thirty minutes.', false, 'LONG', 3, 'property', '1800', 1)
</statement>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, description, order_index,
- config_def_id)
- VALUES (5, 'includes', 'Includes', 'list', 'A set of patterns that specify files and/or directories to include.',
- 4, 1)
+ INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, description, order_index, config_def_id)
+ VALUES (5, 'includes', 'Includes', 'list', 'A set of patterns that specify files and/or directories to include.', 4, 1)
</statement>
<statement>
INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, parent_list_definition_id)
VALUES (6, 'include', 'Include', 'map', 4)
</statement>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type,
- order_index, dtype, parent_map_definition_id)
- VALUES (7, 'path', 'Path', 'A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.',
- 'string', 0, 'property', 5)
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type, order_index, dtype, parent_map_definition_id)
+ VALUES (7, 'path', 'Path', 'A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.', 'STRING', 0, 'property', 5)
</statement>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type,
- order_index, dtype, parent_map_definition_id)
- VALUES (8, 'pattern', 'Pattern', 'TBD', 'string', 1, 'property', 5)
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type, order_index, dtype, parent_map_definition_id)
+ VALUES (8, 'pattern', 'Pattern', 'Pathname pattern that must match for the items in the directory path to be included.', 'STRING', 1, 'property', 5)
</statement>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, description, order_index,
- config_def_id)
- VALUES (9, 'excludes', 'Excludes', 'list', 'A set of patterns that specify files and/or directories to exclude.',
- 5, 1)
+ INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, description, order_index, config_def_id)
+ VALUES (9, 'excludes', 'Excludes', 'list', 'A set of patterns that specify files and/or directories to exclude.', 5, 1)
</statement>
<statement>
INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, parent_list_definition_id)
VALUES (10, 'exclude', 'Exclude', 'map', 8)
</statement>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type,
- order_index, dtype, parent_map_definition_id)
- VALUES (11, 'path', 'Path', 'A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.',
- 'string', 0, 'property', 9)
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type, order_index, dtype, parent_map_definition_id)
+ VALUES (11, 'path', 'Path', 'A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.', 'STRING', 0, 'property', 9)
</statement>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type,
- order_index, dtype, parent_map_definition_id)
- VALUES (12, 'pattern', 'Pattern', 'TBD', 'string', 1, 'property', 9)
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type, order_index, dtype, parent_map_definition_id)
+ VALUES (12, 'pattern', 'Pattern', 'Pathname pattern that must match for the items in the directory path to be excluded.', 'STRING', 1, 'property', 9)
</statement>
</schema-directSQL>
</schemaSpec>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java
index c09b473..00f9ab9 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java
@@ -32,15 +32,47 @@ 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.drift.DriftConfigurationDefinition.BaseDirValueContext;
import org.rhq.core.domain.resource.Resource;
/**
+ * This is a convienence wrapper around a Configuration object whose schema is that
+ * of {@link DriftConfigurationDefinition}.
+ *
+ * Note that this is not an actual Configuration object - it's got a HAS-A relationship
+ * with Configuration.
+ *
+ * This object also has an optional relationship with a Resource.
+ *
+ * TODO: this is missing setters for includes/excludes filters. We should add those.
+ *
* @author John Sanda
+ * @author John Mazzitelli
*/
public class DriftConfiguration implements Serializable {
private static final long serialVersionUID = 1L;
+ public class BaseDirectory implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private final BaseDirValueContext context;
+ private final String name;
+
+ public BaseDirectory(BaseDirValueContext context, String name) {
+ this.context = context;
+ this.name = name;
+ }
+
+ public BaseDirValueContext getValueContext() {
+ return context;
+ }
+
+ public String getValueName() {
+ return name;
+ }
+ }
+
public static class Filter implements Serializable {
private static final long serialVersionUID = 1L;
@@ -126,28 +158,94 @@ public class DriftConfiguration implements Serializable {
return configuration.getId();
}
+ public void setId(int id) {
+ configuration.setId(id);
+ }
+
public String getName() {
- return configuration.getSimpleValue("name", "");
+ return configuration.getSimpleValue(DriftConfigurationDefinition.PROP_NAME, "");
+ }
+
+ public void setName(String name) {
+ if (name == null) {
+ throw new NullPointerException("name is null");
+ }
+ configuration.put(new PropertySimple(DriftConfigurationDefinition.PROP_NAME, name));
+ }
+
+ public BaseDirectory getBasedir() {
+ PropertyMap map = configuration.getMap(DriftConfigurationDefinition.PROP_BASEDIR);
+ String valueContext = map.getSimpleValue(DriftConfigurationDefinition.PROP_BASEDIR_VALUECONTEXT, null);
+ String valueName = map.getSimpleValue(DriftConfigurationDefinition.PROP_BASEDIR_VALUENAME, null);
+
+ BaseDirValueContext valueContextEnum;
+
+ if (valueContext == null) {
+ throw new NullPointerException("valueContext is null");
+ } else {
+ try {
+ valueContextEnum = BaseDirValueContext.valueOf(valueContext);
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Invalid valueContext: " + valueContext);
+ }
+ }
+
+ if (valueName == null) {
+ throw new NullPointerException("valueName is null");
+ }
+
+ return new BaseDirectory(valueContextEnum, valueName);
}
- public String getBasedir() {
- return configuration.getSimpleValue("basedir", "");
+ public void setBasedir(BaseDirectory basedir) {
+ if (basedir == null) {
+ throw new NullPointerException("basedir is null");
+ }
+ if (basedir.getValueContext() == null) {
+ throw new NullPointerException("valueContext is null");
+ }
+ if (basedir.getValueName() == null) {
+ throw new NullPointerException("valueName is null");
+ }
+
+ String valueContext = basedir.getValueContext().name();
+ String valueName = basedir.getValueName();
+
+ PropertyMap basedirMap = new PropertyMap(DriftConfigurationDefinition.PROP_BASEDIR);
+ basedirMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUECONTEXT, valueContext));
+ basedirMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUENAME, valueName));
+
+ configuration.put(basedirMap);
}
public Long getInterval() {
- return Long.parseLong(configuration.getSimpleValue("interval", "0"));
+ return Long.parseLong(configuration.getSimpleValue(DriftConfigurationDefinition.PROP_INTERVAL, String
+ .valueOf(DriftConfigurationDefinition.DEFAULT_INTERVAL)));
+ }
+
+ public void setInterval(Long interval) {
+ if (interval == null) {
+ configuration.remove(DriftConfigurationDefinition.PROP_INTERVAL);
+ } else {
+ configuration.put(new PropertySimple(DriftConfigurationDefinition.PROP_INTERVAL, interval.toString()));
+ }
}
public boolean getEnabled() {
- return configuration.getSimpleValue("enabled", "false").equals("true");
+ return configuration.getSimpleValue(DriftConfigurationDefinition.PROP_ENABLED,
+ String.valueOf(DriftConfigurationDefinition.DEFAULT_ENABLED)).equals("true");
+ }
+
+ public void setEnabled(boolean enabled) {
+ configuration.put(new PropertySimple(DriftConfigurationDefinition.PROP_ENABLED, String.valueOf(enabled)));
}
public List<Filter> getIncludes() {
- return getFilters("includes");
+ return getFilters(DriftConfigurationDefinition.PROP_INCLUDES);
}
public List<Filter> getExcludes() {
- return getFilters("excludes");
+ return getFilters(DriftConfigurationDefinition.PROP_EXCLUDES);
}
private List<Filter> getFilters(String type) {
@@ -159,7 +257,8 @@ public class DriftConfiguration implements Serializable {
List<Filter> filters = new ArrayList<Filter>();
for (Property property : filtersListProperty.getList()) {
PropertyMap filter = (PropertyMap) property;
- filters.add(new Filter(filter.getSimpleValue("path", ""), filter.getSimpleValue("pattern", "")));
+ filters.add(new Filter(filter.getSimpleValue(DriftConfigurationDefinition.PROP_PATH, ""), filter
+ .getSimpleValue(DriftConfigurationDefinition.PROP_PATTERN, "")));
}
return filters;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java
index 4279049..3090601 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java
@@ -18,68 +18,340 @@
*/
package org.rhq.core.domain.drift;
-import java.util.HashMap;
-import java.util.Map;
+import java.io.Serializable;
+import java.util.ArrayList;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.ConfigurationFormat;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration;
+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;
/**
+ * The drift subsystem has a fixed configuration definition. That is, its property definitions
+ * are the same always. There is no metadata that needs to be read in from a descriptor - this definition
+ * is fixed and the code requires all the property definitions to follow what is encoded in this POJO.
+ *
+ * Note that this class must mimic the definition data as found in the database. The installer
+ * will prepopulate the configuration definition tables that match the definitions encoded in this POJO.
+ *
* @author Jay Shaughnessy
+ * @author John Mazzitelli
*/
-public class DriftConfigurationDefinition {
+public class DriftConfigurationDefinition implements Serializable {
+ private static final long serialVersionUID = 1L;
- static private final ConfigurationDefinition INSTANCE = new ConfigurationDefinition("GLOBAL_DRIFT_CONFIG_DEF",
+ public static final String PROP_NAME = "name";
+ public static final String PROP_ENABLED = "enabled";
+ public static final String PROP_BASEDIR = "basedir";
+ public static final String PROP_BASEDIR_VALUECONTEXT = "valueContext";
+ public static final String PROP_BASEDIR_VALUENAME = "valueName";
+ public static final String PROP_INTERVAL = "interval";
+ public static final String PROP_INCLUDES = "includes";
+ public static final String PROP_INCLUDES_INCLUDE = "include";
+ public static final String PROP_EXCLUDES = "excludes";
+ public static final String PROP_EXCLUDES_EXCLUDE = "exclude";
+ public static final String PROP_PATH = "path"; // for both include and exclude
+ public static final String PROP_PATTERN = "pattern"; // for both include and exclude
+
+ public static final boolean DEFAULT_ENABLED = false;
+ public static final long DEFAULT_INTERVAL = 1800L;
+
+ /**
+ * The basedir property is specified in two parts - a "context" and a "name". Taken together
+ * the value of the basedir can be determined. The value name is just a simple name that
+ * is used to look up the basedir value within the appropriate context. A context can be
+ * one of four places - either the value is a named property in a resource's plugin configuration,
+ * a named property in a resource's resource configuration, a named trait that is emitted by a
+ * resource or an absolute path found on a file system.
+ */
+ public enum BaseDirValueContext {
+ pluginConfiguration, resourceConfiguration, measurementTrait, fileSystem
+ }
+
+ private static final ConfigurationDefinition INSTANCE = new ConfigurationDefinition("GLOBAL_DRIFT_CONFIG_DEF",
"The drift configuration definition");
+ public static ConfigurationDefinition getInstance() {
+ return INSTANCE;
+ }
+
static {
INSTANCE.setId(1);
- Map<String, PropertyDefinition> propDefs = new HashMap<String, PropertyDefinition>();
- PropertyDefinitionSimple propDef;
-
- propDef = new PropertyDefinitionSimple("name", "The drift configuration name", true, PropertySimpleType.STRING);
- propDefs.put("name", propDef);
-
- propDef = new PropertyDefinitionSimple("name", "The drift configuration name", true, PropertySimpleType.STRING);
- propDef.setId(1);
- propDef.setDisplayName("Drift Configuration Name");
- propDef.setOrder(0);
- propDef.setConfigurationDefinition(INSTANCE);
- propDefs.put("name", propDef);
-
- propDef = new PropertyDefinitionSimple("enabled", "Enabled", true, PropertySimpleType.BOOLEAN);
- propDef.setId(2);
- propDef.setDisplayName("Enables or disables drift detection for this configuration");
- propDef.setOrder(1);
- propDef.setDefaultValue("false");
- propDef.setConfigurationDefinition(INSTANCE);
- propDefs.put("enabled", propDef);
-
- propDef = new PropertyDefinitionSimple("basedir", "Base Directory", true, PropertySimpleType.STRING);
- propDef.setId(3);
- propDef.setDisplayName("The base directory from which files will be monitored for drift.");
- propDef.setOrder(2);
- propDef.setConfigurationDefinition(INSTANCE);
- propDefs.put("basedir", propDef);
-
- propDef = new PropertyDefinitionSimple("interval", "Interval", false, PropertySimpleType.LONG);
- propDef.setId(4);
- propDef
- .setDisplayName("The interval, in seconds, between drift detection scans for this configuration. Default is 30 minutes.");
- propDef.setOrder(3);
- propDef.setDefaultValue("1800");
- propDef.setConfigurationDefinition(INSTANCE);
- propDefs.put("interval", propDef);
-
- //TODO, add the include/exclude list of maps
-
- INSTANCE.setPropertyDefinitions(propDefs);
- }
-
- static public ConfigurationDefinition getInstance() {
- return INSTANCE;
+ INSTANCE.setConfigurationFormat(ConfigurationFormat.STRUCTURED);
+
+ INSTANCE.put(createName());
+ INSTANCE.put(createEnabled());
+ INSTANCE.put(createBasedir());
+ INSTANCE.put(createInterval());
+ INSTANCE.put(createIncludes());
+ INSTANCE.put(createExcludes());
+
+ }
+
+ private static PropertyDefinitionSimple createName() {
+ String name = PROP_NAME;
+ String description = "The drift configuration name";
+ boolean required = true;
+ PropertySimpleType type = PropertySimpleType.STRING;
+
+ PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type);
+ pd.setId(1);
+ pd.setDisplayName("Drift Configuration Name");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(0);
+ pd.setAllowCustomEnumeratedValue(false);
+ pd.setConfigurationDefinition(INSTANCE);
+ return pd;
+ }
+
+ private static PropertyDefinitionSimple createEnabled() {
+ String name = PROP_ENABLED;
+ String description = "Enables or disables the drift configuration";
+ boolean required = true;
+ PropertySimpleType type = PropertySimpleType.BOOLEAN;
+
+ PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type);
+ pd.setId(2);
+ pd.setDisplayName("Enabled");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(1);
+ pd.setAllowCustomEnumeratedValue(false);
+ pd.setConfigurationDefinition(INSTANCE);
+ pd.setDefaultValue(String.valueOf(DEFAULT_ENABLED));
+ return pd;
+ }
+
+ private static PropertyDefinitionMap createBasedir() {
+ String name = PROP_BASEDIR;
+ String description = "The root directory from which snapshots will be generated during drift monitoring.";
+ boolean required = true;
+
+ PropertyDefinitionSimple valueContext = createBasedirValueContext();
+ PropertyDefinitionSimple valueName = createBasedirValueName();
+
+ PropertyDefinitionMap pd = new PropertyDefinitionMap(name, description, required, valueContext, valueName);
+ pd.setId(3);
+ pd.setDisplayName("Base Directory");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(2);
+ pd.setConfigurationDefinition(INSTANCE);
+
+ return pd;
+ }
+
+ private static PropertyDefinitionSimple createBasedirValueContext() {
+ String name = PROP_BASEDIR_VALUECONTEXT;
+ String description = "Identifies where the named value can be found.";
+ boolean required = true;
+ PropertySimpleType type = PropertySimpleType.STRING;
+
+ PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type);
+ pd.setId(4);
+ pd.setDisplayName("Value Context");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(0);
+
+ PropertyDefinitionEnumeration pcEnum = new PropertyDefinitionEnumeration(
+ BaseDirValueContext.pluginConfiguration.name(), BaseDirValueContext.pluginConfiguration.name());
+ pcEnum.setId(1);
+ pcEnum.setOrderIndex(0);
+
+ PropertyDefinitionEnumeration rcEnum = new PropertyDefinitionEnumeration(
+ BaseDirValueContext.resourceConfiguration.name(), BaseDirValueContext.resourceConfiguration.name());
+ rcEnum.setId(2);
+ rcEnum.setOrderIndex(1);
+
+ PropertyDefinitionEnumeration mtEnum = new PropertyDefinitionEnumeration(BaseDirValueContext.measurementTrait
+ .name(), BaseDirValueContext.measurementTrait.name());
+ mtEnum.setId(3);
+ mtEnum.setOrderIndex(2);
+
+ PropertyDefinitionEnumeration fsEnum = new PropertyDefinitionEnumeration(BaseDirValueContext.fileSystem.name(),
+ BaseDirValueContext.fileSystem.name());
+ fsEnum.setId(4);
+ fsEnum.setOrderIndex(3);
+
+ ArrayList<PropertyDefinitionEnumeration> pdEnums = new ArrayList<PropertyDefinitionEnumeration>(4);
+ pdEnums.add(pcEnum);
+ pdEnums.add(rcEnum);
+ pdEnums.add(mtEnum);
+ pdEnums.add(fsEnum);
+ pd.setEnumeratedValues(pdEnums, false);
+
+ return pd;
+ }
+
+ private static PropertyDefinitionSimple createBasedirValueName() {
+ String name = PROP_BASEDIR_VALUENAME;
+ String description = "The name of the value as found in the context";
+ boolean required = true;
+ PropertySimpleType type = PropertySimpleType.STRING;
+ PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type);
+ pd.setId(5);
+ pd.setDisplayName("Value Name");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(1);
+ pd.setAllowCustomEnumeratedValue(false);
+ return pd;
}
+
+ private static PropertyDefinitionSimple createInterval() {
+ String name = PROP_INTERVAL;
+ String description = "The frequency in seconds in which drift monitoring should run. Defaults to 1800 seconds (i.e. 30 minutes)";
+ boolean required = false;
+ PropertySimpleType type = PropertySimpleType.LONG;
+
+ PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type);
+ pd.setId(6);
+ pd.setDisplayName("Interval");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(3);
+ pd.setAllowCustomEnumeratedValue(false);
+ pd.setConfigurationDefinition(INSTANCE);
+ pd.setDefaultValue(String.valueOf(DEFAULT_INTERVAL));
+ return pd;
+ }
+
+ private static PropertyDefinitionList createIncludes() {
+ String name = PROP_INCLUDES;
+ String description = "A set of patterns that specify files and/or directories to include.";
+ boolean required = false;
+
+ PropertyDefinitionMap map = createInclude();
+
+ PropertyDefinitionList pd = new PropertyDefinitionList(name, description, required, map);
+ pd.setId(7);
+ pd.setDisplayName("Includes");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(4);
+ pd.setConfigurationDefinition(INSTANCE);
+ return pd;
+ }
+
+ private static PropertyDefinitionMap createInclude() {
+ String name = PROP_INCLUDES_INCLUDE;
+ String description = "A set of patterns that specify files and/or directories to include.";
+ boolean required = true;
+
+ PropertyDefinitionSimple path = createIncludePath();
+ PropertyDefinitionSimple pattern = createIncludePattern();
+
+ PropertyDefinitionMap pd = new PropertyDefinitionMap(name, description, required, path, pattern);
+ pd.setId(8);
+ pd.setDisplayName("Include");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(0);
+ return pd;
+ }
+
+ private static PropertyDefinitionSimple createIncludePath() {
+ String name = PROP_PATH;
+ String description = "A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.";
+ boolean required = true;
+ PropertySimpleType type = PropertySimpleType.STRING;
+
+ PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type);
+ pd.setId(9);
+ pd.setDisplayName("Path");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(0);
+ pd.setAllowCustomEnumeratedValue(false);
+ return pd;
+ }
+
+ private static PropertyDefinitionSimple createIncludePattern() {
+ String name = PROP_PATTERN;
+ String description = "Pathname pattern that must match for the items in the directory path to be included.";
+ boolean required = false;
+ PropertySimpleType type = PropertySimpleType.STRING;
+
+ PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type);
+ pd.setId(10);
+ pd.setDisplayName("Pattern");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(1);
+ pd.setAllowCustomEnumeratedValue(false);
+ return pd;
+ }
+
+ private static PropertyDefinitionList createExcludes() {
+ String name = PROP_EXCLUDES;
+ String description = "A set of patterns that specify files and/or directories to exclude.";
+ boolean required = false;
+
+ PropertyDefinitionMap map = createExclude();
+
+ PropertyDefinitionList pd = new PropertyDefinitionList(name, description, required, map);
+ pd.setId(11);
+ pd.setDisplayName("Excludes");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(5);
+ pd.setConfigurationDefinition(INSTANCE);
+ return pd;
+ }
+
+ private static PropertyDefinitionMap createExclude() {
+ String name = PROP_EXCLUDES_EXCLUDE;
+ String description = "A set of patterns that specify files and/or directories to exclude.";
+ boolean required = true;
+
+ PropertyDefinitionSimple path = createExcludePath();
+ PropertyDefinitionSimple pattern = createExcludePattern();
+
+ PropertyDefinitionMap pd = new PropertyDefinitionMap(name, description, required, path, pattern);
+ pd.setId(12);
+ pd.setDisplayName("Exclude");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(0);
+ return pd;
+ }
+
+ private static PropertyDefinitionSimple createExcludePath() {
+ String name = PROP_PATH;
+ String description = "A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.";
+ boolean required = true;
+ PropertySimpleType type = PropertySimpleType.STRING;
+
+ PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type);
+ pd.setId(13);
+ pd.setDisplayName("Path");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(0);
+ pd.setAllowCustomEnumeratedValue(false);
+ return pd;
+ }
+
+ private static PropertyDefinitionSimple createExcludePattern() {
+ String name = PROP_PATTERN;
+ String description = "Pathname pattern that must match for the items in the directory path to be excluded.";
+ boolean required = false;
+ PropertySimpleType type = PropertySimpleType.STRING;
+
+ PropertyDefinitionSimple pd = new PropertyDefinitionSimple(name, description, required, type);
+ pd.setId(14);
+ pd.setDisplayName("Pattern");
+ pd.setReadOnly(false);
+ pd.setSummary(true);
+ pd.setOrder(1);
+ pd.setAllowCustomEnumeratedValue(false);
+ return pd;
+ }
+
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index ef97e00..cffea1c 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -6,7 +6,9 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -18,9 +20,18 @@ import org.rhq.core.clientapi.agent.drift.DriftAgentService;
import org.rhq.core.clientapi.server.drift.DriftServerService;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDataRequest;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.pc.ContainerService;
+import org.rhq.core.pc.PluginContainer;
import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.agent.AgentService;
+import org.rhq.core.pc.inventory.InventoryManager;
+import org.rhq.core.pc.inventory.ResourceContainer;
+import org.rhq.core.pc.measurement.MeasurementManager;
public class DriftManager extends AgentService implements DriftAgentService, DriftClient, ContainerService {
@@ -108,8 +119,8 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
driftServer.sendFilesZip(resourceId, zipFile.length(), remoteInputStream(new BufferedInputStream(
new FileInputStream(zipFile))));
} catch (IOException e) {
- log.error("An error occurred while trying to send content for changeset[resourceId: " + resourceId +
- ", driftConfiguration: " + driftConfigurationName + "]", e);
+ log.error("An error occurred while trying to send content for changeset[resourceId: " + resourceId
+ + ", driftConfiguration: " + driftConfigurationName + "]", e);
}
}
@@ -165,7 +176,6 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
return true;
}
-
@Override
public void unscheduleDriftDetection(int resourceId, DriftConfiguration driftConfiguration) {
}
@@ -174,4 +184,143 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
public void updateDriftDetection(int resourceId, DriftConfiguration driftConfiguration) {
}
+ /**
+ * Given a drift configuration, this examines the config and its associated resource to determine where exactly
+ * the base directory is that should be monitoried.
+ *
+ * @param driftConfiguration describes what is to be monitored for drift
+ *
+ * @return absolute directory location where the drift configuration base directory is referring
+ */
+ public File getAbsoluteBaseDirectory(DriftConfiguration driftConfiguration) {
+
+ // get the resource entity stored in our local inventory
+ InventoryManager im = getInventoryManager();
+ Resource resource = driftConfiguration.getResource();
+ ResourceContainer container = im.getResourceContainer(resource);
+ resource = container.getResource();
+
+ // find out the type of base location that is specified by the drift config
+ DriftConfiguration.BaseDirectory baseDir = driftConfiguration.getBasedir();
+ if (baseDir == null) {
+ throw new IllegalArgumentException("Missing basedir in drift config");
+ }
+
+ // based on the type of base location, determine the root base directory
+ String baseDirValueName = baseDir.getValueName(); // the name we look up in the given context
+ String baseLocation;
+ switch (baseDir.getValueContext()) {
+ case fileSystem: {
+ baseLocation = baseDirValueName; // the value name IS the absolute directory name
+ if (baseLocation == null || baseLocation.trim().length() == 0) {
+ baseLocation = File.separator; // paranoia, if not specified, assume the top root directory
+ }
+ break;
+ }
+ case pluginConfiguration: {
+ baseLocation = resource.getPluginConfiguration().getSimpleValue(baseDirValueName, null);
+ if (baseLocation == null) {
+ throw new IllegalArgumentException("Cannot determine the bundle base deployment location - "
+ + "there is no plugin configuration setting for [" + baseDirValueName + "]");
+ }
+ break;
+ }
+ case resourceConfiguration: {
+ baseLocation = resource.getResourceConfiguration().getSimpleValue(baseDirValueName, null);
+ if (baseLocation == null) {
+ throw new IllegalArgumentException("Cannot determine the bundle base deployment location - "
+ + "there is no resource configuration setting for [" + baseDirValueName + "]");
+ }
+ break;
+ }
+ case measurementTrait: {
+ baseLocation = getTraitValue(container, baseDirValueName);
+ if (baseLocation == null) {
+ throw new IllegalArgumentException("Cannot obtain trait [" + baseDirValueName + "] for resource ["
+ + resource.getName() + "]");
+ }
+ break;
+ }
+ default: {
+ throw new IllegalArgumentException("Unknown location context: " + baseDir.getValueContext());
+ }
+ }
+
+ File destDir = new File(baseLocation);
+
+ if (!destDir.isAbsolute()) {
+ throw new IllegalArgumentException("The base location path specified by [" + baseDirValueName
+ + "] in the context [" + baseDir.getValueContext() + "] did not resolve to an absolute path ["
+ + destDir.getPath() + "] so there is no way to know what directory to monitor for drift");
+ }
+
+ return destDir;
+ }
+
+ /**
+ * Given the name of a trait, this will find the value of that trait for the given resource.
+ *
+ * @param resource the resource whose trait value is to be obtained
+ * @param traitName the name of the trait whose value is to be obtained
+ *
+ * @return the value of the trait, or <code>null</code> if unknown
+ *
+ * TODO: this is taken directly from BundleManager. We should refactor this and the one
+ * in BundleManager to a single place, perhaps MeasurementManager.
+ */
+ private String getTraitValue(ResourceContainer container, String traitName) {
+ Integer traitScheduleId = null;
+ Set<MeasurementScheduleRequest> schedules = container.getMeasurementSchedule();
+ for (MeasurementScheduleRequest schedule : schedules) {
+ if (schedule.getName().equals(traitName)) {
+ if (schedule.getDataType() != DataType.TRAIT) {
+ throw new IllegalArgumentException("Measurement named [" + traitName + "] for resource ["
+ + container.getResource().getName() + "] is not a trait, it is of type ["
+ + schedule.getDataType() + "]");
+ }
+ traitScheduleId = Integer.valueOf(schedule.getScheduleId());
+ }
+ }
+ if (traitScheduleId == null) {
+ throw new IllegalArgumentException("There is no trait [" + traitName + "] for resource ["
+ + container.getResource().getName() + "]");
+ }
+
+ MeasurementManager mm = getMeasurementManager();
+ String traitValue = mm.getCachedTraitValue(traitScheduleId.intValue());
+ if (traitValue == null) {
+ // the trait hasn't been collected yet, so it isn't cached. We need to get its live value
+ List<MeasurementDataRequest> requests = new ArrayList<MeasurementDataRequest>();
+ requests.add(new MeasurementDataRequest(traitName, DataType.TRAIT));
+ Set<MeasurementData> dataset = mm.getRealTimeMeasurementValue(container.getResource().getId(), requests);
+ if (dataset != null && dataset.size() == 1) {
+ Object value = dataset.iterator().next().getValue();
+ if (value != null) {
+ traitValue = value.toString();
+ }
+ }
+ }
+
+ return traitValue;
+ }
+
+ /**
+ * Returns the manager that can provide data on the inventory. This is a separate protected method
+ * so we can extend our manger class to have a mock manager for testing.
+ *
+ * @return the inventory manager
+ */
+ protected InventoryManager getInventoryManager() {
+ return PluginContainer.getInstance().getInventoryManager();
+ }
+
+ /**
+ * Returns the manager that can provide data on the measurements/metrics. This is a separate protected method
+ * so we can extend our manger class to have a mock manager for testing.
+ *
+ * @return the inventory manager
+ */
+ protected MeasurementManager getMeasurementManager() {
+ return PluginContainer.getInstance().getMeasurementManager();
+ }
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftConfigurationDefinitionTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftConfigurationDefinitionTest.java
new file mode 100644
index 0000000..525a46c
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftConfigurationDefinitionTest.java
@@ -0,0 +1,212 @@
+/*
+ * 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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.drift;
+
+import java.util.List;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration;
+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.drift.DriftConfigurationDefinition;
+import org.rhq.enterprise.server.test.AbstractEJB3Test;
+
+/**
+ * Tests that our hard-coded singleton DriftConfigurationDefinition is persisted properly in the DB.
+ */
+@Test
+public class DriftConfigurationDefinitionTest extends AbstractEJB3Test {
+
+ public void testDriftConfigurationDefinition() throws Throwable {
+ getTransactionManager().begin();
+ try {
+ ConfigurationDefinition def = DriftConfigurationDefinition.getInstance();
+ ConfigurationDefinition defDATABASE = getEntityManager().find(ConfigurationDefinition.class, def.getId());
+
+ assert defDATABASE.getId() == def.getId();
+ assert defDATABASE.getPropertyDefinitions().size() == def.getPropertyDefinitions().size();
+
+ PropertyDefinitionSimple simpleDATABASE;
+ PropertyDefinitionSimple simple;
+ PropertyDefinitionMap mapDATABASE;
+ PropertyDefinitionMap map;
+ PropertyDefinitionList listDATABASE;
+ PropertyDefinitionList list;
+
+ // NAME
+ simpleDATABASE = defDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_NAME);
+ simple = def.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_NAME);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // ENABLED
+ simpleDATABASE = defDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_ENABLED);
+ simple = def.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_ENABLED);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // INTERVAL
+ simpleDATABASE = defDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_INTERVAL);
+ simple = def.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_INTERVAL);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // BASEDIR
+ mapDATABASE = defDATABASE.getPropertyDefinitionMap(DriftConfigurationDefinition.PROP_BASEDIR);
+ map = def.getPropertyDefinitionMap(DriftConfigurationDefinition.PROP_BASEDIR);
+ assertMapProperty(mapDATABASE, map);
+
+ // BASEDIR VALUECONTEXT (implicitly also tests the enums)
+ simpleDATABASE = mapDATABASE
+ .getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUECONTEXT);
+ simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUECONTEXT);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // BASEDIR VALUENAME
+ simpleDATABASE = mapDATABASE
+ .getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUENAME);
+ simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUENAME);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // INCLUDES
+ listDATABASE = defDATABASE.getPropertyDefinitionList(DriftConfigurationDefinition.PROP_INCLUDES);
+ list = def.getPropertyDefinitionList(DriftConfigurationDefinition.PROP_INCLUDES);
+ assertListProperty(listDATABASE, list);
+
+ // INCLUDES INCLUDE
+ /*
+ PropertyDefinitionMap deleteme = getEntityManager().find(PropertyDefinitionMap.class, 8);
+
+ mapDATABASE = (PropertyDefinitionMap) listDATABASE.getMemberDefinition();
+ map = (PropertyDefinitionMap) list.getMemberDefinition();
+ assertMapProperty(mapDATABASE, map);
+
+ // INCLUDES INCLUDE PATH
+ simpleDATABASE = mapDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATH);
+ simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATH);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // INCLUDES INCLUDE PATTERN
+ simpleDATABASE = mapDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATTERN);
+ simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATTERN);
+ assertSimpleProperty(simpleDATABASE, simple);
+ */
+
+ // EXCLUDES
+ listDATABASE = defDATABASE.getPropertyDefinitionList(DriftConfigurationDefinition.PROP_EXCLUDES);
+ list = def.getPropertyDefinitionList(DriftConfigurationDefinition.PROP_EXCLUDES);
+ assertListProperty(listDATABASE, list);
+
+ /*
+ // EXCLUDES EXCLUDE
+ mapDATABASE = (PropertyDefinitionMap) listDATABASE.getMemberDefinition();
+ map = (PropertyDefinitionMap) list.getMemberDefinition();
+ assertMapProperty(mapDATABASE, map);
+
+ // EXCLUDES EXCLUDE PATH
+ simpleDATABASE = mapDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATH);
+ simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATH);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // EXCLUDES EXCLUDE PATTERN
+ simpleDATABASE = mapDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATTERN);
+ simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATTERN);
+ assertSimpleProperty(simpleDATABASE, simple);
+ */
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
+
+ private void assertListProperty(PropertyDefinitionList listDb, PropertyDefinitionList list) throws Throwable {
+
+ try {
+ assert listDb.getId() == list.getId();
+ assert listDb.getActivationPolicy() == list.getActivationPolicy();
+ assert listDb.getDescription().equals(list.getDescription());
+ assert listDb.getDisplayName().equals(list.getDisplayName());
+ assert listDb.getName().equals(list.getName());
+ assert listDb.getOrder() == list.getOrder();
+ } catch (Throwable t) {
+ System.out.println("Lists failed test:\nlistDb=[" + listDb + "]\nlist=[" + list + "]");
+ throw t;
+ }
+ }
+
+ private void assertMapProperty(PropertyDefinitionMap mapDb, PropertyDefinitionMap map) throws Throwable {
+
+ try {
+ assert mapDb.getId() == map.getId();
+ assert mapDb.getActivationPolicy() == map.getActivationPolicy();
+ assert mapDb.getDescription().equals(map.getDescription());
+ assert mapDb.getDisplayName().equals(map.getDisplayName());
+ assert mapDb.getName().equals(map.getName());
+ assert mapDb.getOrder() == map.getOrder();
+ } catch (Throwable t) {
+ System.out.println("Maps failed test:\nmapDb=[" + mapDb + "]\nmap=[" + map + "]");
+ throw t;
+ }
+ }
+
+ private void assertSimpleProperty(PropertyDefinitionSimple simpleDb, PropertyDefinitionSimple simple)
+ throws Throwable {
+
+ try {
+ assert simpleDb.getId() == simple.getId();
+ assert simpleDb.getAllowCustomEnumeratedValue() == simple.getAllowCustomEnumeratedValue();
+ assert simpleDb.getActivationPolicy() == simple.getActivationPolicy();
+ assert simpleDb.getDescription().equals(simple.getDescription());
+ assert simpleDb.getDisplayName().equals(simple.getDisplayName());
+ assert simpleDb.getName().equals(simple.getName());
+ assert simpleDb.getOrder() == simple.getOrder();
+ assert simpleDb.getType() == simple.getType();
+ if (simpleDb.getDefaultValue() == null) {
+ assert simpleDb.getDefaultValue() == null && simple.getDefaultValue() == null;
+ } else {
+ assert simpleDb.getDefaultValue().equals(simple.getDefaultValue());
+ }
+ assertEnumeratedValues(simpleDb.getEnumeratedValues(), simple.getEnumeratedValues());
+
+ } catch (Throwable t) {
+ System.out.println("Simples failed test:\nsimpleDb=[" + simpleDb + "]\nsimple=[" + simple + "]");
+ throw t;
+ }
+ }
+
+ private void assertEnumeratedValues(List<PropertyDefinitionEnumeration> enumsDb,
+ List<PropertyDefinitionEnumeration> enums) throws Throwable {
+
+ assert enumsDb.size() == enums.size() : "enum sizes do not match: " + enumsDb.size() + ":" + enums.size();
+
+ for (int i = 0; i < enumsDb.size(); i++) {
+ PropertyDefinitionEnumeration eenumDb = enumsDb.get(i);
+ PropertyDefinitionEnumeration eenum = enums.get(i);
+
+ try {
+ assert eenumDb.getId() == eenum.getId();
+ assert eenumDb.getName().equals(eenum.getName());
+ assert eenumDb.getOrderIndex() == eenum.getOrderIndex();
+ assert eenumDb.getValue().equals(eenum.getValue());
+ } catch (Throwable t) {
+ System.out.println("Enum failed test:\neenumDb=[" + eenumDb + "]\neenums=[" + eenum + "]");
+ throw t;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/test/resources/log4j.xml b/modules/enterprise/server/jar/src/test/resources/log4j.xml
index d721bff..681f2af 100644
--- a/modules/enterprise/server/jar/src/test/resources/log4j.xml
+++ b/modules/enterprise/server/jar/src/test/resources/log4j.xml
@@ -49,6 +49,13 @@
<priority value="ERROR"/>
</category>
+ <!-- Hibernate SQL logs -->
+ <!--
+ <category name="org.hibernate.SQL">
+ <priority value="DEBUG"/>
+ </category>
+ -->
+
<root>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
12 years, 10 months
[rhq] Branch 'drift' - 3 commits - .classpath modules/core modules/enterprise
by Jay Shaughnessy
.classpath | 1
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java | 21 ++---
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java | 40 +++-------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java | 7 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java | 30 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java | 9 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java | 9 ++
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java | 33 +++++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerRemote.java | 10 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 5 -
15 files changed, 125 insertions(+), 55 deletions(-)
New commits:
commit db93f4f7d5149507dce3d066f58d40fe40a88ab0
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jun 29 11:47:37 2011 -0400
Drift GUI - Add "Detect Now" button to Drift->Configuration subtab
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java
index c38b68d..c1265db 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java
@@ -58,6 +58,8 @@ public class DriftConfigurationDataSource extends RPCDataSource<DriftConfigurati
public static final String FILTER_CATEGORIES = "categories";
+ public static final String ATTR_ENTITY = "Entity";
+
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
private EntityContext entityContext;
@@ -266,7 +268,7 @@ public class DriftConfigurationDataSource extends RPCDataSource<DriftConfigurati
@Override
public DriftConfiguration copyValues(Record from) {
- return null;
+ return (DriftConfiguration) from.getAttributeAsObject(ATTR_ENTITY);
}
@Override
@@ -276,6 +278,9 @@ public class DriftConfigurationDataSource extends RPCDataSource<DriftConfigurati
public static ListGridRecord convert(DriftConfiguration from) {
ListGridRecord record = new ListGridRecord();
+
+ record.setAttribute(ATTR_ENTITY, from);
+
record.setAttribute("id", from.getId());
record.setAttribute("name", from.getName());
record.setAttribute("interval", String.valueOf(from.getInterval()));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
index 002f468..94d06b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
@@ -34,6 +34,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.drift.DriftCategory;
+import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
@@ -122,7 +123,9 @@ public class DriftConfigurationView extends TableSection<DriftConfigurationDataS
}
protected void setupTableInteractions(final boolean hasWriteAccess) {
- TableActionEnablement singleTargetEnablement = hasWriteAccess ? TableActionEnablement.ANY
+ TableActionEnablement deleteEnablement = hasWriteAccess ? TableActionEnablement.ANY
+ : TableActionEnablement.NEVER;
+ TableActionEnablement detectNowEnablement = hasWriteAccess ? TableActionEnablement.SINGLE
: TableActionEnablement.NEVER;
addTableAction("Add", MSG.common_button_add(), null, new TableAction() {
@@ -136,7 +139,7 @@ public class DriftConfigurationView extends TableSection<DriftConfigurationDataS
});
addTableAction("Delete", MSG.common_button_delete(), MSG.view_drift_delete_confirm(), new AbstractTableAction(
- singleTargetEnablement) {
+ deleteEnablement) {
public void executeAction(ListGridRecord[] selection, Object actionValue) {
delete(selection);
}
@@ -154,6 +157,13 @@ public class DriftConfigurationView extends TableSection<DriftConfigurationDataS
deleteAll();
}
});
+
+ addTableAction("DetectNow", MSG.view_drift_button_detectNow(), null, new AbstractTableAction(
+ detectNowEnablement) {
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ detectDrift(selection);
+ }
+ });
}
void add() {
@@ -197,6 +207,22 @@ public class DriftConfigurationView extends TableSection<DriftConfigurationDataS
});
}
+ void detectDrift(ListGridRecord[] records) {
+ DriftConfiguration driftConfig = (DriftConfiguration) records[0]
+ .getAttributeAsObject(DriftConfigurationDataSource.ATTR_ENTITY);
+ GWTServiceLookup.getDriftService().detectDrift(context, driftConfig, new AsyncCallback<Void>() {
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_drift_success_detectNow(), Message.Severity.Info));
+ refresh();
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_failure_detectNow(), caught);
+ }
+ });
+ }
+
@Override
public Canvas getDetailsView(int driftConfigId) {
return new DriftConfigurationEditView(extendLocatorId("ConfigEdit"), context, driftConfigId, hasWriteAccess);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
index b72f9cc..05429df 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
@@ -86,6 +86,15 @@ public interface DriftGWTService extends RemoteService {
int deleteDriftConfigurationsByContext(EntityContext entityContext) throws RuntimeException;
/**
+ * One time on-demand request to detect drift on the specified entities, using the supplied config.
+ *
+ * @param entityContext
+ * @param driftConfig
+ * @throws RuntimeException
+ */
+ void detectDrift(EntityContext entityContext, DriftConfiguration driftConfig) throws RuntimeException;
+
+ /**
* Find all drift changesets that match the specified criteria.
*
* @param criteria the criteria
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
index 92f12cd..9d0cd0f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
@@ -83,6 +83,15 @@ public class DriftGWTServiceImpl extends AbstractGWTServiceImpl implements Drift
}
@Override
+ public void detectDrift(EntityContext entityContext, DriftConfiguration driftConfig) {
+ try {
+ this.driftManager.detectDrift(getSessionSubject(), entityContext, driftConfig);
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
+ @Override
public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(DriftChangeSetCriteria criteria)
throws RuntimeException {
try {
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 fb4e2a6..2ade41c 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
@@ -1110,6 +1110,7 @@ view_dashboards_portlets_refresh_one_min = 1 minute
view_dashboards_portlets_refresh_success1 = Updated interval for portlets that auto-refresh
view_dashboards_portlets_refresh_success2 = Stopping reload for portlets that auto-refresh
view_dashboards_title = Dashboard
+view_drift_button_detectNow = Detect Now
view_drift_category_fileAdded = File Added
view_drift_category_fileChanged = File Changed
view_drift_category_fileRemoved = File Removed
@@ -1117,10 +1118,12 @@ view_drift_delete_confirm = Delete the selected drift(s)?
view_drift_delete_confirmAll = Delete all drifts from this source?
view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
view_drift_failure_deleteAll = Failed to delete all drift targets from this source
+view_drift_failure_detectNow = Failed to submit drift detection request
view_drift_failure_load = Failed to fetch drift data
view_drift_success_configurationUpdated = Drift configuration updated. File coverage will be updated on next detection scan.
view_drift_success_delete = Successfully deleted {0} drifts
view_drift_success_deleteConfigs = Successfully deleted {0} drift configurations
+view_drift_success_detectNow = Successfully submitted drift detection request
view_drift_table_baseDir = Base Directory
view_drift_table_newFile = New File
view_drift_table_oldFile = Old File
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index d3b63d2..883a336 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -934,6 +934,7 @@ view_dashboardsManager_error1 = Failed to add new dashboard~
view_dashboardsManager_message_title_details = <h1>Willkommen bei RHQ</h1>\n<p>Das RHQ-Projekt is an abstraction and plug-in based systems management suite that provides extensible and integrated systems management for multiple products and platforms across a set of core features. The project is designed with layered modules that provide a flexible architecture for deployment. It delivers a core user interface that delivers audited and historical management across an entire enterprise. A Server/Agent architecture provides remote management and plugins implement all specific support for managed products.</p>\n <p>This default dashboard can be edited by clicking the (edit mode) button above.</p>~
view_dashboards_confirm1 = Sind Sie sicher, dass Sie löschen möchten
view_dashboards_title = Dashboard
+##view_drift_button_detectNow = Detect Now
##view_drift_category_fileAdded = File Added
##view_drift_category_fileChanged = File Changed
##view_drift_category_fileRemoved = File Removed
@@ -941,10 +942,12 @@ view_dashboards_title = Dashboard
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
##view_drift_failure_deleteAll = Failed to delete all drift targets from this source
+##view_drift_failure_detectNow = Failed to submit drift detection request
##view_drift_failure_load = Failed to fetch drift data
##view_drift_success_configurationUpdated = Drift configuration updated. File coverage will be updated on next detection scan.
##view_drift_success_delete = Successfully deleted {0} drifts
##view_drift_success_deleteConfigs = Successfully deleted {0} drift configurations
+##view_drift_success_detectNow = Successfully submitted drift detection request
##view_drift_table_baseDir = Base Directory
##view_drift_table_newFile = New File
##view_drift_table_oldFile = Old File
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index c648541..2be7d4c 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -1111,6 +1111,7 @@ view_dashboards_portlets_refresh_one_min = 1 minute
view_dashboards_portlets_refresh_success1 = Updated interval for portlets that auto-refresh
view_dashboards_portlets_refresh_success2 = Stopping reload for portlets that auto-refresh
view_dashboards_title = ダッシュボード
+##view_drift_button_detectNow = Detect Now
##view_drift_category_fileAdded = File Added
##view_drift_category_fileChanged = File Changed
##view_drift_category_fileRemoved = File Removed
@@ -1118,10 +1119,12 @@ view_dashboards_title = ダッシュボード
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
##view_drift_failure_deleteAll = Failed to delete all drift targets from this source
+##view_drift_failure_detectNow = Failed to submit drift detection request
##view_drift_failure_load = Failed to fetch drift data
##view_drift_success_configurationUpdated = Drift configuration updated. File coverage will be updated on next detection scan.
##view_drift_success_delete = Successfully deleted {0} drifts
##view_drift_success_deleteConfigs = Successfully deleted {0} drift configurations
+##view_drift_success_detectNow = Successfully submitted drift detection request
##view_drift_table_baseDir = Base Directory
##view_drift_table_newFile = New File
##view_drift_table_oldFile = Old File
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index a81c28f..d4c0af4 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -1134,6 +1134,7 @@ view_dashboards_portlets_refresh_one_min = 1 minute
view_dashboards_portlets_refresh_success1 = Updated interval for portlets that auto-refresh
view_dashboards_portlets_refresh_success2 = Stopping reload for portlets that auto-refresh
view_dashboards_title = Dashboard~
+##view_drift_button_detectNow = Detect Now
##view_drift_category_fileAdded = File Added
##view_drift_category_fileChanged = File Changed
##view_drift_category_fileRemoved = File Removed
@@ -1141,10 +1142,12 @@ view_dashboards_title = Dashboard~
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
##view_drift_failure_deleteAll = Failed to delete all drift targets from this source
+##view_drift_failure_detectNow = Failed to submit drift detection request
##view_drift_failure_load = Failed to fetch drift data
##view_drift_success_configurationUpdated = Drift configuration updated. File coverage will be updated on next detection scan.
##view_drift_success_delete = Successfully deleted {0} drifts
##view_drift_success_deleteConfigs = Successfully deleted {0} drift configurations
+##view_drift_success_detectNow = Successfully submitted drift detection request
##view_drift_table_baseDir = Base Directory
##view_drift_table_newFile = New File
##view_drift_table_oldFile = Old File
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 560241b..d4b479c 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -1110,6 +1110,7 @@ view_dashboards_portlets_refresh_one_min = 1 \u5206\u652F
view_dashboards_portlets_refresh_success1 = \u6210\u529F\u4FEE\u6539portlets\u81EA\u52A8\u5237\u65B0\u7684\u95F4\u9694\u65F6\u95F4
view_dashboards_portlets_refresh_success2 = \u6210\u529F\u505C\u7528portlets\u81EA\u52A8\u5237\u65B0\u7684\u91CD\u8F7D
view_dashboards_title = \u7EDF\u8BA1\u8868\u76D8
+##view_drift_button_detectNow = Detect Now
##view_drift_category_fileAdded = File Added
##view_drift_category_fileChanged = File Changed
##view_drift_category_fileRemoved = File Removed
@@ -1117,10 +1118,12 @@ view_dashboards_title = \u7EDF\u8BA1\u8868\u76D8
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
##view_drift_failure_deleteAll = Failed to delete all drift targets from this source
+##view_drift_failure_detectNow = Failed to submit drift detection request
##view_drift_failure_load = Failed to fetch drift data
##view_drift_success_configurationUpdated = Drift configuration updated. File coverage will be updated on next detection scan.
##view_drift_success_delete = Successfully deleted {0} drifts
##view_drift_success_deleteConfigs = Successfully deleted {0} drift configurations
+##view_drift_success_detectNow = Successfully submitted drift detection request
##view_drift_table_baseDir = Base Directory
##view_drift_table_newFile = New File
##view_drift_table_oldFile = Old File
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index ba94b08..089d5df 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -413,21 +413,28 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
@Override
- public void detectDrift(Subject subject, int resourceId, DriftConfiguration driftConfig) {
+ public void detectDrift(Subject subject, EntityContext context, DriftConfiguration driftConfig) {
- Resource resource = entityManager.find(Resource.class, resourceId);
- if (null == resource) {
- throw new IllegalArgumentException("Resource not found [" + resourceId + "]");
- }
+ switch (context.getType()) {
+ case Resource:
+ int resourceId = context.getResourceId();
+ Resource resource = entityManager.find(Resource.class, resourceId);
+ if (null == resource) {
+ throw new IllegalArgumentException("Resource not found [" + resourceId + "]");
+ }
- AgentClient agentClient = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
- DriftAgentService service = agentClient.getDriftAgentService();
- try {
- service.detectDrift(resourceId, driftConfig);
- } catch (Exception e) {
- log.warn(" Unable to inform agent of drift detection request [" + driftConfig + "]", e);
- }
+ AgentClient agentClient = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
+ DriftAgentService service = agentClient.getDriftAgentService();
+ try {
+ service.detectDrift(resourceId, driftConfig);
+ } catch (Exception e) {
+ log.warn(" Unable to inform agent of drift detection request [" + driftConfig + "]", e);
+ }
- }
+ break;
+ default:
+ throw new IllegalArgumentException("Entity Context Type not supported [" + context + "]");
+ }
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerRemote.java
index 1fde7c0..25a1562 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerRemote.java
@@ -25,6 +25,7 @@ import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.enterprise.server.system.ServerVersion;
@@ -33,9 +34,16 @@ import org.rhq.enterprise.server.system.ServerVersion;
@Remote
public interface DriftManagerRemote {
+ /**
+ * One time on-demand request to detect drift on the specified entities, using the supplied config.
+ *
+ * @param entityContext
+ * @param driftConfig
+ * @throws RuntimeException
+ */
@WebMethod
void detectDrift(//
@WebParam(name = "subject") Subject subject, //
- @WebParam(name = "resourceId") int resourceId, //
+ @WebParam(name = "entityContext") EntityContext entityContext, //
@WebParam(name = "driftConfiguration") DriftConfiguration driftConfiguration) throws Exception;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 7533881..75ea9a4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -590,8 +590,9 @@ public class WebservicesManagerBean implements WebservicesRemote {
// DRIFTMANAGER: BEGIN ----------------------------------
@Override
- public void detectDrift(Subject subject, int resourceId, DriftConfiguration driftConfiguration) throws Exception {
- driftManager.detectDrift(subject, resourceId, driftConfiguration);
+ public void detectDrift(Subject subject, EntityContext entityContext, DriftConfiguration driftConfiguration)
+ throws Exception {
+ driftManager.detectDrift(subject, entityContext, driftConfiguration);
}
// DRIFTMANAGER: END ------------------------------------
commit 12c406e5a0ece98de21544d04876979e996e9687
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jun 29 11:45:57 2011 -0400
trivial - Remove some compiler warnings. Folks should add IDE setting for
removing unused imports.
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
index 0a10de3..605b275 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
@@ -1,5 +1,11 @@
package org.rhq.core.pc.drift;
+import static org.apache.commons.io.FileUtils.deleteDirectory;
+import static org.apache.commons.io.IOUtils.readLines;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+import static org.testng.Assert.assertEquals;
+import static org.unitils.thirdparty.org.apache.commons.io.FileUtils.touch;
+
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
@@ -20,12 +26,6 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.test.JMockTest;
-import static org.apache.commons.io.FileUtils.deleteDirectory;
-import static org.apache.commons.io.IOUtils.readLines;
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
-import static org.testng.Assert.assertEquals;
-import static org.unitils.thirdparty.org.apache.commons.io.FileUtils.touch;
-
public class DriftDetectorTest extends JMockTest {
File changeSetsDir;
@@ -55,6 +55,7 @@ public class DriftDetectorTest extends JMockTest {
scheduleQueue = new ScheduleQueueImpl();
}
+ @SuppressWarnings("unchecked")
@Test
public void generateCoverageChangeSet() throws Exception {
File server1Dir = new File(resourcesDir, "server-1");
@@ -99,8 +100,8 @@ public class DriftDetectorTest extends JMockTest {
void assertHeaderEquals(List<String> lines, String... expected) {
assertEquals(lines.get(0), expected[0], "The first header entry should be the drift configuration name.");
assertEquals(lines.get(1), expected[1], "The second header entry should be the base directory.");
- assertEquals(lines.get(2), expected[2], "The third header entry should be a flag indicating the change set " +
- "type.");
+ assertEquals(lines.get(2), expected[2], "The third header entry should be a flag indicating the change set "
+ + "type.");
}
void assertThatChangeSetDoesNotContainEmptyDirs(File changeSet) throws Exception {
@@ -108,8 +109,8 @@ public class DriftDetectorTest extends JMockTest {
DirectoryEntry dirEntry = reader.readDirectoryEntry();
while (dirEntry != null) {
- Assert.assertTrue(dirEntry.getNumberOfFiles() > 0, "The change set file should not include empty " +
- "directories");
+ Assert.assertTrue(dirEntry.getNumberOfFiles() > 0, "The change set file should not include empty "
+ + "directories");
dirEntry = reader.readDirectoryEntry();
}
}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java
index eb333f5..6a5eb71 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java
@@ -1,30 +1,25 @@
package org.rhq.core.pc.drift;
+import static java.util.Arrays.asList;
+import static org.apache.commons.io.FileUtils.deleteDirectory;
+import static org.apache.commons.io.FileUtils.touch;
+import static org.apache.commons.io.IOUtils.writeLines;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
-import java.util.Arrays;
import java.util.List;
-import org.apache.commons.io.IOUtils;
-import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import org.unitils.thirdparty.org.apache.commons.io.FileUtils;
import org.rhq.common.drift.Headers;
-import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftFile;
-import static java.util.Arrays.asList;
-import static org.apache.commons.io.FileUtils.deleteDirectory;
-import static org.apache.commons.io.FileUtils.touch;
-import static org.apache.commons.io.IOUtils.writeLines;
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
public class DriftFilesSenderTest {
File changeSetsDir;
@@ -59,7 +54,7 @@ public class DriftFilesSenderTest {
public void sendFiles() throws Exception {
String driftConfigName = "test";
- File server1Dir = new File(resourcesDir, "server-1");
+ File server1Dir = new File(resourcesDir, "server-1");
server1Dir.mkdir();
File confDir = new File(server1Dir, "conf");
@@ -72,14 +67,8 @@ public class DriftFilesSenderTest {
File changeSetDir = new File(new File(changeSetsDir, Integer.toString(resourceId)), driftConfigName);
changeSetDir.mkdirs();
- List<String> changeSet = asList(
- driftConfigName,
- server1Dir.getAbsolutePath(),
- COVERAGE.code(),
- "conf 1",
- "2e345df 0 server.conf A",
- ""
- );
+ List<String> changeSet = asList(driftConfigName, server1Dir.getAbsolutePath(), COVERAGE.code(), "conf 1",
+ "2e345df 0 server.conf A", "");
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(new File(changeSetDir,
"changeset.txt")));
writeLines(changeSet, "\n", stream);
@@ -101,10 +90,9 @@ public class DriftFilesSenderTest {
File content = new File(contentDir, "2e345df");
- assertEquals(contentDir.list().length, 1, "Expected to find one file in " +
- contentDir.getAbsolutePath());
- assertTrue(content.exists(), "Expected to find file named " + content.getName() + " in content directory. " +
- "SHA-256 hashes should be used as file names");
+ assertEquals(contentDir.list().length, 1, "Expected to find one file in " + contentDir.getAbsolutePath());
+ assertTrue(content.exists(), "Expected to find file named " + content.getName() + " in content directory. "
+ + "SHA-256 hashes should be used as file names");
}
}
commit 776846ae36106c28af5efe7028d11141265bf3e8
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jun 29 11:43:02 2011 -0400
add unitils-core to eclipse classpath for new test deps
diff --git a/.classpath b/.classpath
index 089189f..c263ab4 100644
--- a/.classpath
+++ b/.classpath
@@ -112,6 +112,7 @@
<classpathentry exported="true" kind="var" path="M2_REPO/org/dbunit/dbunit/2.4.8/dbunit-2.4.8.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/poi/poi/3.7/poi-3.7.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/bsh/bsh/1.3.0/bsh-1.3.0.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/unitils/unitils-core/3.1/unitils-core-3.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/unitils/unitils-dbunit/3.1/unitils-dbunit-3.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/unitils/unitils-orm/3.1/unitils-orm-3.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/unitils/unitils-testng/3.1/unitils-testng-3.1.jar"/>
12 years, 10 months
[rhq] Branch 'drift' - modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit a64a7390e5c62450bd4228fddd4343e01588aa90
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jun 29 09:37:49 2011 -0400
Fixing bug that was scheduling an unitialized DriftDetector to run.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index 1d6ec1a..ef97e00 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -57,7 +57,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
driftDetector.setDriftClient(this);
driftThreadPool = new ScheduledThreadPoolExecutor(5);
- driftThreadPool.scheduleAtFixedRate(new DriftDetector(), 30, 1800, TimeUnit.SECONDS);
+ driftThreadPool.scheduleAtFixedRate(driftDetector, 30, 1800, TimeUnit.SECONDS);
}
@Override
12 years, 10 months
[rhq] Branch 'as7plugin' - 14 commits - modules/core modules/enterprise modules/plugins
by Heiko W. Rupp
modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml | 2
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 31 +
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyOptionsSource.java | 4
modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java | 160 +++++-----
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml | 1
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml | 1
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml | 1
modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 11
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 2
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java | 2
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java | 3
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java | 9
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 7
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java | 17 +
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java | 69 +++-
16 files changed, 235 insertions(+), 97 deletions(-)
New commits:
commit ee7349dd14ba42c4364b2264d7a8da1e6dfed9d9
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 29 15:18:52 2011 +0200
Add a test for a composite operation with only one member operation (i.e. deploy to domain only)
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index dfa9fd9..b0d68ee 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -41,7 +41,7 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* the UPLOAD_FILE must point to a valid archive in the resources directory.
* @author Heiko W. Rupp
*/
-@Test(enabled = false) // TODO add an "integration test profile" that is able to fire the server before running the test
+@Test(enabled = true) // TODO add an "integration test profile" that is able to fire the server before running the test
public class UploadAndDeployTest {
static final String TEST_WAR = "test.war";
@@ -49,7 +49,8 @@ public class UploadAndDeployTest {
private static final String DC_HOST = "localhost";
private static final int DC_HTTP_PORT = 9990;
- @Test(timeOut = 60*1000L, enabled=false)
+
+ @Test(timeOut = 60*1000L, enabled=true)
public void testUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -61,7 +62,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L, enabled=false)
+ @Test(timeOut = 60*1000L, enabled=true)
public void testDoubleUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -74,7 +75,7 @@ public class UploadAndDeployTest {
assert bytes_value.equals("7jgpMVmynfxpqp8UDleKLmtgbrA=");
}
- @Test(timeOut = 60*1000L,enabled=false)
+ @Test(timeOut = 60*1000L,enabled=true)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -154,7 +155,7 @@ public class UploadAndDeployTest {
}
// Test for AS7-853
- @Test(timeOut = 60*1000L,enabled = false)
+ @Test(timeOut = 60*1000L,enabled = true)
public void testUploadIndividualSteps2() throws Exception {
String bytes_value = prepare();
@@ -228,7 +229,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L,enabled = false)
+ @Test(timeOut = 60*1000L,enabled = true)
public void testUploadComposite() throws Exception {
String bytes_value = prepare();
@@ -290,6 +291,62 @@ public class UploadAndDeployTest {
}
+ /**
+ * Test uploading to domain only, but not to a server group
+ * @throws Exception
+ */
+ @Test(timeOut = 60*1000L,enabled = true)
+ public void testUploadComposite2() throws Exception {
+
+ String bytes_value = prepare();
+
+ System.out.println("Prepare done");
+ System.out.flush();
+
+ List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
+ deploymentsAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Operation step1 = new Operation("add",deploymentsAddress);
+ List<Object> content = new ArrayList<Object>(1);
+ Map<String,Object> contentValues = new HashMap<String,Object>();
+ contentValues.put("hash",new PROPERTY_VALUE("BYTES_VALUE",bytes_value));
+ content.add(contentValues);
+ step1.addAdditionalProperty("content", content);
+ step1.addAdditionalProperty("name", TEST_WAR); // this needs to be unique per upload
+
+
+ CompositeOperation cop = new CompositeOperation();
+ cop.addStep(step1);
+
+
+ ASConnection connection = new ASConnection(DC_HOST, DC_HTTP_PORT);
+ JsonNode ret = connection.executeRaw(cop);
+ System.out.println(ret);
+ System.out.flush();
+
+ assert ret.has("outcome") : "Ret not valid " + ret.toString();
+ assert ret.get("outcome").getTextValue().equals("success") : "Composite deploy was no success " + ret.getTextValue();
+
+ // Wait for AS to settle
+ Thread.sleep(1000);
+
+
+ // Now undeploy again to clean up
+
+ cop = new CompositeOperation();
+ Operation step4 = new Operation("remove",deploymentsAddress);
+
+ cop.addStep(step4);
+ ret = connection.executeRaw(cop);
+
+ System.out.println(ret);
+ System.out.flush();
+
+ assert ret.has("outcome") : "Ret not valid " + ret.toString();
+ assert ret.get("outcome").getTextValue().equals("success") : "Composite remove was no success " + ret.getTextValue();
+
+
+ }
+
private String prepare() throws IOException {
ASUploadConnection conn = new ASUploadConnection(DC_HOST, DC_HTTP_PORT);
OutputStream os = conn.getOutputStream("test.war");
commit b8b1edbac9e407404be7a7bf88d0738df175bd5b
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 22 13:30:29 2011 +0200
Add a dependent value for the web connector
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 0ccacf6..76d1bcf 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -548,6 +548,7 @@
<service name="Connector"
discovery="SubsystemDiscovery"
class="BaseComponent"
+ createDeletePolicy="both"
>
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="connector"/>
@@ -563,8 +564,10 @@
<resource-configuration>
<c:simple-property name="protocol" required="true" type="string" readOnly="true" description="The web connector protocol."/>
- <c:simple-property name="socket-binding" required="true" type="string" readOnly="true"
- description="The web connector socket-binding reference, this connector should be bound to."/>
+ <c:simple-property name="socket-binding" required="true" type="string" readOnly="false"
+ description="The web connector socket-binding reference, this connector should be bound to.">
+ <c:option-source target="configuration" expression="socket-binding=name:type=SocketBindingGroup"/>
+ </c:simple-property>
<c:simple-property name="scheme" type="string" readOnly="true" default="http" description="The web connector scheme."/>
<c:simple-property name="executor" type="string" readOnly="true" required="false"
description="The name of the executor that should be used for the processing threads of this connector. Defaults to using an internal pool."/>
commit aed0881f6c23e7015c7c8665074d2c444acad189
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 28 21:59:52 2011 +0200
Support the new "rolled-back" element in the JSON response from the AS.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
index a5583b7..63c5262 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
@@ -40,6 +40,8 @@ public class Result {
private /*List<Map<String, String>>*/Object failureDescription;
@JsonIgnore
private boolean success = false;
+ @JsonProperty("rolled-back")
+ private boolean rolledBack = false;
public Result() {
@@ -83,4 +85,11 @@ public class Result {
this.failureDescription = failureDescription;
}
+ public boolean isRolledBack() {
+ return rolledBack;
+ }
+
+ public void setRolledBack(boolean rolledBack) {
+ this.rolledBack = rolledBack;
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 53ac89e..b36a03b 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -185,7 +185,7 @@ public class OperationJsonTest {
public void arrayResult1() throws Exception {
- String resultString = "{\"outcome\":\"success\",\"result\":[\"standard-sockets\",\"messaging-sockets\"],\"compensating-operation\":null}";
+ String resultString = "{\"outcome\":\"success\",\"result\":[\"standard-sockets\",\"messaging-sockets\"],\"compensating-operation\":null, \"rolled-back\" : false}";
ObjectMapper mapper = new ObjectMapper();
Result result = mapper.readValue(resultString,Result.class);
@@ -197,6 +197,21 @@ public class OperationJsonTest {
assert stringList.size()==2;
assert stringList.get(0).equals("standard-sockets");
assert stringList.get(1).equals("messaging-sockets");
+ assert !result.isRolledBack();
+
+ }
+
+ public void rolledBack() throws Exception {
+
+ String resultString = "{\"outcome\":\"failed\", \"rolled-back\" : true}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ Result result = mapper.readValue(resultString,Result.class);
+
+ assert result != null;
+ assert result.getOutcome().equals("failed");
+ assert !result.isSuccess();
+ assert result.isRolledBack();
}
commit f3a39fd7c84e203b90c3a0b6e35bc0e0fc8c4c9b
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jun 28 13:43:36 2011 -0500
Fix dbunit setup failures after a new table was added to the schema.
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
index 290ad18..51e689e 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
@@ -10,8 +10,8 @@
mtime="123456"/>
<rhq_config_def/>
- <rhq_config_pd_osrc/>
<rhq_config_prop_def/>
+ <rhq_config_pd_osrc/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
index 306297c..0cfe2f1 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
@@ -1,7 +1,7 @@
<dataset>
<rhq_config_def/>
- <rhq_config_pd_osrc/>
<rhq_config_prop_def/>
+ <rhq_config_pd_osrc/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml
index d584809..29351c4 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml
@@ -2,6 +2,7 @@
<rhq_config_def/>
<rhq_config_prop_grp_def/>
<rhq_config_prop_def/>
+ <rhq_config_pd_osrc/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
<rhq_config/>
commit 50fb5956ca8b06cc826766bd2a9d84806d79cda2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 28 17:30:10 2011 +0200
/domain-api got renamed to /management.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index c51f275..f2bb47f 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -52,7 +52,7 @@ public class ASConnection {
public ASConnection(String host, int port) {
try {
- url = new URL("http",host,port,"/domain-api");
+ url = new URL("http",host,port,"/management");
urlString = url.toString();
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e.getMessage());
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
index 80e8ea4..d876c80 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
@@ -51,7 +51,7 @@ public class ASUploadConnection {
private static final String POST_REQUEST_METHOD = "POST";
- private static final String UPLOAD_URL_PATH = "/domain-api/add-content";
+ private static final String UPLOAD_URL_PATH = "/management/add-content";
private final Log log = LogFactory.getLog(ASUploadConnection.class);
commit c4bc8030a89861799fc79ff1611fa7cfc0009168
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jun 28 09:58:25 2011 -0500
Attempt to correct the dbunit setup failures after a new table was added to the schema.
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
index 79ba415..290ad18 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
@@ -10,6 +10,7 @@
mtime="123456"/>
<rhq_config_def/>
+ <rhq_config_pd_osrc/>
<rhq_config_prop_def/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
index 7e6ae2a..306297c 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
@@ -1,5 +1,6 @@
<dataset>
<rhq_config_def/>
+ <rhq_config_pd_osrc/>
<rhq_config_prop_def/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
commit 19558e110cd6f9233225e7122d8af4baafb1ea56
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jun 27 17:27:39 2011 -0400
we can't rename tables (which is essentially removing an old table and creating a new table)
because dbsetup won't work - the dbsetup uninstall won't know about the old table to remove if it is still around
collapse the two dbupgrade steps into one
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 39f0798..a368986 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.111</db.schema.version>
+ <db.schema.version>2.110</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 9950e58..df0daf7 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3417,44 +3417,34 @@
<schemaSpec version="2.110">
<schema-directSQL>
- <statement desc="Creating table RHQ_PROP_DEF_OPT_SRC">
- CREATE TABLE RHQ_PROP_DEF_OPT_SRC ( ID INTEGER PRIMARY KEY )
+ <statement desc="Creating table RHQ_CONFIG_PD_OSRC">
+ CREATE TABLE RHQ_CONFIG_PD_OSRC ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
- <schema-addColumn table="RHQ_PROP_DEF_OPT_SRC" column="LINK_TO_TARGET" columnType="BOOLEAN"/>
- <schema-alterColumn table="RHQ_PROP_DEF_OPT_SRC" column="LINK_TO_TARGET" nullable="TRUE"/>
+ <schema-addColumn table="RHQ_CONFIG_PD_OSRC" column="LINK_TO_TARGET" columnType="BOOLEAN"/>
+ <schema-alterColumn table="RHQ_CONFIG_PD_OSRC" column="LINK_TO_TARGET" nullable="TRUE"/>
- <schema-addColumn table="RHQ_PROP_DEF_OPT_SRC" column="FILTER" columnType="VARCHAR2" precision="40"/>
- <schema-alterColumn table="RHQ_PROP_DEF_OPT_SRC" column="FILTER" nullable="TRUE"/>
+ <schema-addColumn table="RHQ_CONFIG_PD_OSRC" column="FILTER" columnType="VARCHAR2" precision="40"/>
+ <schema-alterColumn table="RHQ_CONFIG_PD_OSRC" column="FILTER" nullable="TRUE"/>
- <schema-addColumn table="RHQ_PROP_DEF_OPT_SRC" column="EXPRESSION" columnType="VARCHAR2" precision="400"/>
- <schema-alterColumn table="RHQ_PROP_DEF_OPT_SRC" column="EXPRESSION" nullable="FALSE"/>
+ <schema-addColumn table="RHQ_CONFIG_PD_OSRC" column="EXPRESSION" columnType="VARCHAR2" precision="400"/>
+ <schema-alterColumn table="RHQ_CONFIG_PD_OSRC" column="EXPRESSION" nullable="FALSE"/>
- <schema-addColumn table="RHQ_PROP_DEF_OPT_SRC" column="TARGET_TYPE" columnType="VARCHAR2" precision="20"/>
- <schema-alterColumn table="RHQ_PROP_DEF_OPT_SRC" column="TARGET_TYPE" nullable="FALSE"/>
+ <schema-addColumn table="RHQ_CONFIG_PD_OSRC" column="TARGET_TYPE" columnType="VARCHAR2" precision="20"/>
+ <schema-alterColumn table="RHQ_CONFIG_PD_OSRC" column="TARGET_TYPE" nullable="FALSE"/>
- <schema-addColumn table="RHQ_PROP_DEF_OPT_SRC" column="PROPERTY_DEF_ID" columnType="INTEGER"/>
+ <schema-addColumn table="RHQ_CONFIG_PD_OSRC" column="PROPERTY_DEF_ID" columnType="INTEGER"/>
<schema-directSQL>
- <statement desc="Adding a fk">
- ALTER TABLE RHQ_PROP_DEF_OPT_SRC
- ADD CONSTRAINT RHQ_PROP_DEF_OPT_SRC_ID_FK
+ <statement desc="Adding a foreign key constraint to RHQ_CONFIG_PD_OSRC">
+ ALTER TABLE RHQ_CONFIG_PD_OSRC
+ ADD CONSTRAINT RHQ_CONFIG_PD_OSRC_ID_FK
FOREIGN KEY (PROPERTY_DEF_ID)
REFERENCES RHQ_CONFIG_PROP_DEF (ID)
</statement>
</schema-directSQL>
- <schema-createSequence name="rhq_config_prop_def_opt_src_id_seq" initial="10001" />
- </schemaSpec>
- <schemaSpec version="2.111">
- <schema-directSQL>
- <statement desc="rename to correct name">
- ALTER TABLE RHQ_PROP_DEF_OPT_SRC
- RENAME TO RHQ_CONFIG_PD_OSRC
- </statement>
- <statement desc="rename sequence">
- ALTER TABLE rhq_config_prop_def_opt_src_id_seq RENAME TO rhq_config_pd_osrc_id_seq
- </statement>
- </schema-directSQL>
+ <schema-createSequence name="rhq_config_pd_osrc_id_seq" initial="10001" />
</schemaSpec>
+
</dbupgrade>
</target>
</project>
commit 1553673802ec3f30d6582d6f0a8df3707cc5d6a1
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jun 27 17:55:59 2011 +0200
Fix a possible NPE that prevents config rendering.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
index f66cefd..ae8e5d9 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
@@ -219,6 +219,9 @@ public class ConfigurationDelegate implements ConfigurationFacet {
* @return the populated map
*/
PropertyMap handlePropertyMap(PropertyDefinitionMap propDef, Object valueObject) {
+ if (valueObject==null)
+ return null;
+
PropertyMap propertyMap = new PropertyMap(propDef.getName());
Map<String, PropertyDefinition> memberDefMap = propDef.getPropertyDefinitions();
commit c57ee650b5c77aeb10df19ed3da12c6ad0c20ef5
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jun 27 10:59:47 2011 +0200
Fix table and sequence names for dependent values
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index a368986..39f0798 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.110</db.schema.version>
+ <db.schema.version>2.111</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
index c5155ab..07f101d 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
@@ -58,7 +58,7 @@
<column name="PROPERTY_DEF_ID" type="INTEGER" required="false" references="RHQ_CONFIG_PROP_DEF"/>
</table>
- <table name="RHQ_PROP_DEF_OPT_SRC">
+ <table name="RHQ_CONFIG_PD_OSRC">
<column name="ID" type="INTEGER" required="true" default="sequence-only" initial="10001" primarykey="true"/>
<column name="LINK_TO_TARGET" type="BOOLEAN" required="false"/>
<column name="FILTER" type="VARCHAR2" required="false" size="40"/>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 4d66b02..9950e58 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3444,6 +3444,17 @@
</schema-directSQL>
<schema-createSequence name="rhq_config_prop_def_opt_src_id_seq" initial="10001" />
</schemaSpec>
+ <schemaSpec version="2.111">
+ <schema-directSQL>
+ <statement desc="rename to correct name">
+ ALTER TABLE RHQ_PROP_DEF_OPT_SRC
+ RENAME TO RHQ_CONFIG_PD_OSRC
+ </statement>
+ <statement desc="rename sequence">
+ ALTER TABLE rhq_config_prop_def_opt_src_id_seq RENAME TO rhq_config_pd_osrc_id_seq
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
</dbupgrade>
</target>
</project>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyOptionsSource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyOptionsSource.java
index 1af0bf4..9755bdd 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyOptionsSource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyOptionsSource.java
@@ -45,8 +45,8 @@ import javax.xml.bind.annotation.XmlAccessorType;
* @author Heiko W. Rupp
*/
@Entity
-@Table(name="RHQ_PROP_DEF_OPT_SRC")
-@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CONFIG_PROP_DEF_OPT_SRC_ID_SEQ")
+@Table(name="RHQ_CONFIG_PD_OSRC")
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CONFIG_PD_OSRC_ID_SEQ")
@XmlAccessorType(XmlAccessType.FIELD)
public class PropertyOptionsSource implements Serializable{
commit c1539ab2b81270985ba026be2725f8195d9d4917
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jun 23 11:57:01 2011 -0400
BZ 644328 - abort the bundle deployment if we cannot determine where to put the bundle,
that is, if we don't have an absolute path. We need to do this for those cases
where, for example, a resource doesn't store an absolute path in its plugin config,
resource source or trait - rather it stores a relative path. In this case, we can't
pin that relative path to anything absolute, so we don't know where to put
the bundle.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
index b0cd714..29afab5 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
@@ -507,7 +507,17 @@ public class BundleManager extends AgentService implements BundleAgentService, B
}
}
- return new File(baseLocation, relativeDeployDir);
+ File destDir = new File(baseLocation, relativeDeployDir);
+
+ if (!destDir.isAbsolute()) {
+ throw new IllegalArgumentException("The base location path specified by [" + destBaseDirValueName
+ + "] in the context [" + bundleDestBaseDir.getValueContext()
+ + "] along with the destination directory of [" + relativeDeployDir
+ + "] did not resolve to an absolute path [" + destDir.getPath()
+ + "] so there is no way to know where to put the bundle.");
+ }
+
+ return destDir;
}
/**
commit 44d0542ab1bf78b8953dc69f805f55fa15420509
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jun 23 11:43:28 2011 -0400
BZ 644328 - enable bundle deployments to jboss-as-5 plugin
diff --git a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
index 40e2441..21161fe 100644
--- a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
@@ -1191,6 +1191,17 @@
</configuration>
</content>
+ <bundle-target>
+ <destination-base-dir name="Install Directory" description="The top directory where the JBossAS Server is installed. (i.e. the value found in the 'JBoss Home Directory' connection property)">
+ <value-context>pluginConfiguration</value-context>
+ <value-name>homeDir</value-name>
+ </destination-base-dir>
+ <destination-base-dir name="Profile Directory" description="The profile configuration directory such as 'default', 'minimal', 'production' or similar location. (i.e. the value found in the 'Server Home Dir' connection property)">
+ <value-context>pluginConfiguration</value-context>
+ <value-name>serverHomeDir</value-name>
+ </destination-base-dir>
+ </bundle-target>
+
<server name="JBoss AS JVM"
description="JVM of the JBossAS"
sourcePlugin="JMX"
commit d6718f1139ed78493364cbd25e19ebec436822e7
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 22 20:53:15 2011 +0200
Disable the individual test methods, as the class one did not work.
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index 2c9f546..dfa9fd9 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -49,7 +49,7 @@ public class UploadAndDeployTest {
private static final String DC_HOST = "localhost";
private static final int DC_HTTP_PORT = 9990;
- @Test(timeOut = 60*1000L)
+ @Test(timeOut = 60*1000L, enabled=false)
public void testUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -61,7 +61,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L)
+ @Test(timeOut = 60*1000L, enabled=false)
public void testDoubleUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -74,7 +74,7 @@ public class UploadAndDeployTest {
assert bytes_value.equals("7jgpMVmynfxpqp8UDleKLmtgbrA=");
}
- @Test(timeOut = 60*1000L)
+ @Test(timeOut = 60*1000L,enabled=false)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -154,7 +154,7 @@ public class UploadAndDeployTest {
}
// Test for AS7-853
- @Test(timeOut = 60*1000L)
+ @Test(timeOut = 60*1000L,enabled = false)
public void testUploadIndividualSteps2() throws Exception {
String bytes_value = prepare();
@@ -228,7 +228,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L)
+ @Test(timeOut = 60*1000L,enabled = false)
public void testUploadComposite() throws Exception {
String bytes_value = prepare();
commit 2906b2db5c170ef6d80dad8e74a1a1a956bb4ba0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 22 20:26:16 2011 +0200
Disable the test, as it needs a running as7
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index 57ec4f3..2c9f546 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -41,7 +41,7 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* the UPLOAD_FILE must point to a valid archive in the resources directory.
* @author Heiko W. Rupp
*/
-@Test
+@Test(enabled = false) // TODO add an "integration test profile" that is able to fire the server before running the test
public class UploadAndDeployTest {
static final String TEST_WAR = "test.war";
@@ -49,7 +49,7 @@ public class UploadAndDeployTest {
private static final String DC_HOST = "localhost";
private static final int DC_HTTP_PORT = 9990;
- @Test(timeOut = 60*1000L, enabled = true)
+ @Test(timeOut = 60*1000L)
public void testUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -61,7 +61,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L, enabled = true)
+ @Test(timeOut = 60*1000L)
public void testDoubleUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -74,7 +74,7 @@ public class UploadAndDeployTest {
assert bytes_value.equals("7jgpMVmynfxpqp8UDleKLmtgbrA=");
}
- @Test(timeOut = 60*1000L, enabled = true)
+ @Test(timeOut = 60*1000L)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -154,7 +154,7 @@ public class UploadAndDeployTest {
}
// Test for AS7-853
- @Test(timeOut = 60*1000L, enabled = true)
+ @Test(timeOut = 60*1000L)
public void testUploadIndividualSteps2() throws Exception {
String bytes_value = prepare();
@@ -228,7 +228,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L, enabled = true)
+ @Test(timeOut = 60*1000L)
public void testUploadComposite() throws Exception {
String bytes_value = prepare();
commit 28432d866fba7a7cae80e7efc9bd7e84314e113e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jun 22 10:43:30 2011 -0400
BZ 644328 - when someone creates a new group from within the bundle deploy wizard, prepopulate the
bundle deploy wizard's group selector, but only if the new group supports bundles.
This also clears the radio button options whenever the user starts typing in the
drop down group selector because once you change the group (or start changing the group)
the radio options probably are not valid (we will refresh the options once a valid
group has been selected)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java
index 54f6f15..7459562 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.bundle.deploy;
import java.util.LinkedHashMap;
import java.util.Set;
+import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -31,6 +32,8 @@ import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.form.fields.events.DataArrivedEvent;
+import com.smartgwt.client.widgets.form.fields.events.DataArrivedHandler;
import com.smartgwt.client.widgets.form.fields.events.IconClickEvent;
import com.smartgwt.client.widgets.form.fields.events.IconClickHandler;
import com.smartgwt.client.widgets.form.validator.IsIntegerValidator;
@@ -61,8 +64,9 @@ public class GetDestinationStep extends AbstractWizardStep {
private VLayout form;
DynamicForm valForm = new LocatableDynamicForm("GetDestinationStepValForm");
private SingleCompatibleResourceGroupSelector selector;
- private BundleDestination dest = new BundleDestination();
+ private BundleDestination destination = new BundleDestination();
private boolean createInProgress = false;
+ private RadioGroupItem destBaseDirItem;
public GetDestinationStep(BundleDeployWizard wizard) {
this.wizard = wizard;
@@ -94,7 +98,7 @@ public class GetDestinationStep extends AbstractWizardStep {
value = "";
}
wizard.setSubtitle(value.toString());
- dest.setName(value.toString());
+ destination.setName(value.toString());
}
});
FormUtility.addContextualHelp(nameTextItem, MSG.view_bundle_deployWizard_getDest_name_help());
@@ -108,7 +112,7 @@ public class GetDestinationStep extends AbstractWizardStep {
if (value == null) {
value = "";
}
- dest.setDescription(value.toString());
+ destination.setDescription(value.toString());
}
});
@@ -122,23 +126,23 @@ public class GetDestinationStep extends AbstractWizardStep {
if (value == null) {
value = "";
}
- dest.setDeployDir(value.toString());
+ destination.setDeployDir(value.toString());
}
});
FormUtility.addContextualHelp(deployDirTextItem, MSG.view_bundle_deployWizard_getDest_deployDir_help());
- final RadioGroupItem destBaseDirItem = new RadioGroupItem("destBaseDir", MSG
+ this.destBaseDirItem = new RadioGroupItem("destBaseDir", MSG
.view_bundle_deployWizard_getDest_destBaseDirName());
- destBaseDirItem.setWidth(300);
- destBaseDirItem.setRequired(true);
- destBaseDirItem.setDisabled(true);
- destBaseDirItem.addChangedHandler(new ChangedHandler() {
+ this.destBaseDirItem.setWidth(300);
+ this.destBaseDirItem.setRequired(true);
+ this.destBaseDirItem.setDisabled(true);
+ this.destBaseDirItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
Object value = event.getValue();
if (value != null && value.toString().length() > 0) {
- dest.setDestinationBaseDirectoryName(value.toString());
+ destination.setDestinationBaseDirectoryName(value.toString());
} else {
- dest.setDestinationBaseDirectoryName(null);
+ destination.setDestinationBaseDirectoryName(null);
}
}
});
@@ -152,62 +156,16 @@ public class GetDestinationStep extends AbstractWizardStep {
this.selector.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
- Integer selectedGroupId = null;
-
// if the user is typing in the name of the group, and is only partially
// done, the event value will be the String of the partial group name.
// If the selection is an actual group name, the event value will be
// an integer (the group ID) and that is our indication that the selection
// of an actual group has been made
+ Integer selectedGroupId = null;
if (event.getValue() instanceof Integer) {
selectedGroupId = (Integer) event.getValue();
}
-
- // new group is, or is in the process of being, selected so forget what the base location was before
- dest.setDestinationBaseDirectoryName(null);
- destBaseDirItem.clearValue();
-
- if (selectedGroupId != null) {
- bundleServer.getResourceTypeBundleConfiguration(selectedGroupId.intValue(),
- new AsyncCallback<ResourceTypeBundleConfiguration>() {
- public void onSuccess(ResourceTypeBundleConfiguration result) {
- // populate the base location drop down with all the possible dest base directories
- LinkedHashMap<String, String> menuItems = null;
- if (result != null) {
- Set<BundleDestinationBaseDirectory> baseDirs;
- baseDirs = result.getBundleDestinationBaseDirectories();
- if (baseDirs != null && baseDirs.size() > 0) {
- String defaultSelectedItem = null;
- menuItems = new LinkedHashMap<String, String>(baseDirs.size());
- for (BundleDestinationBaseDirectory baseDir : baseDirs) {
- if (baseDir.getDescription() != null) {
- menuItems.put(baseDir.getName(), "<b>" + baseDir.getName()
- + "</b>: " + baseDir.getDescription());
- } else {
- menuItems.put(baseDir.getName(), baseDir.getName());
- }
- if (defaultSelectedItem == null) {
- defaultSelectedItem = baseDir.getName();
- }
- }
- destBaseDirItem.setValueMap(menuItems);
- destBaseDirItem.setValue(defaultSelectedItem);
- dest.setDestinationBaseDirectoryName(defaultSelectedItem);
- }
- }
-
- destBaseDirItem.setDisabled(menuItems == null);
- }
-
- public void onFailure(Throwable caught) {
- destBaseDirItem.setDisabled(true);
- CoreGUI.getErrorHandler().handleError(
- MSG.view_bundle_deployWizard_error_noBundleConfig(), caught);
- }
- });
- } else {
- destBaseDirItem.setDisabled(true);
- }
+ groupSelectionChanged(selectedGroupId);
}
});
final FormItemIcon newGroupIcon = new FormItemIcon();
@@ -223,7 +181,7 @@ public class GetDestinationStep extends AbstractWizardStep {
FormUtility.addContextualHelp(this.selector, MSG.view_bundle_deployWizard_getDest_group_help(),
newGroupIcon);
- this.valForm.setItems(nameTextItem, descriptionTextAreaItem, this.selector, destBaseDirItem,
+ this.valForm.setItems(nameTextItem, descriptionTextAreaItem, this.selector, this.destBaseDirItem,
deployDirTextItem);
CanvasItem ci1 = new CanvasItem();
ci1.setShowTitle(false);
@@ -271,8 +229,8 @@ public class GetDestinationStep extends AbstractWizardStep {
private void createDestination() {
int selectedGroup = (Integer) this.valForm.getValue("group");
- bundleServer.createBundleDestination(wizard.getBundleId(), dest.getName(), dest.getDescription(), dest
- .getDestinationBaseDirectoryName(), dest.getDeployDir(), selectedGroup, //
+ bundleServer.createBundleDestination(wizard.getBundleId(), destination.getName(), destination.getDescription(),
+ destination.getDestinationBaseDirectoryName(), destination.getDeployDir(), selectedGroup, //
new AsyncCallback<BundleDestination>() {
public void onSuccess(BundleDestination result) {
wizard.setDestination(result);
@@ -295,16 +253,84 @@ public class GetDestinationStep extends AbstractWizardStep {
});
}
+ private void groupSelectionChanged(Integer selectedGroupId) {
+ // new group is, or is in the process of being, selected so forget what the base location was before
+ destination.setDestinationBaseDirectoryName(null);
+ destBaseDirItem.clearValue();
+ destBaseDirItem.setValueMap((String[]) null);
+
+ // this will be null if there is no true group actually selected (e.g. user is typing a partial name to search)
+ if (selectedGroupId != null) {
+ bundleServer.getResourceTypeBundleConfiguration(selectedGroupId.intValue(),
+ new AsyncCallback<ResourceTypeBundleConfiguration>() {
+ public void onSuccess(ResourceTypeBundleConfiguration result) {
+ // populate the base location drop down with all the possible dest base directories
+ LinkedHashMap<String, String> menuItems = null;
+ if (result != null) {
+ Set<BundleDestinationBaseDirectory> baseDirs;
+ baseDirs = result.getBundleDestinationBaseDirectories();
+ if (baseDirs != null && baseDirs.size() > 0) {
+ String defaultSelectedItem = null;
+ menuItems = new LinkedHashMap<String, String>(baseDirs.size());
+ for (BundleDestinationBaseDirectory baseDir : baseDirs) {
+ if (baseDir.getDescription() != null) {
+ menuItems.put(baseDir.getName(), "<b>" + baseDir.getName() + "</b>: "
+ + baseDir.getDescription());
+ } else {
+ menuItems.put(baseDir.getName(), baseDir.getName());
+ }
+ if (defaultSelectedItem == null) {
+ defaultSelectedItem = baseDir.getName();
+ }
+ }
+ destBaseDirItem.setValueMap(menuItems);
+ destBaseDirItem.setValue(defaultSelectedItem);
+ destination.setDestinationBaseDirectoryName(defaultSelectedItem);
+ }
+ }
+
+ destBaseDirItem.setDisabled(menuItems == null);
+ }
+
+ public void onFailure(Throwable caught) {
+ destBaseDirItem.setDisabled(true);
+ CoreGUI.getErrorHandler().handleError(MSG.view_bundle_deployWizard_error_noBundleConfig(),
+ caught);
+ }
+ });
+ } else {
+ destBaseDirItem.setDisabled(true);
+ }
+ }
+
private class QuickGroupCreateWizard extends AbstractGroupCreateWizard {
- private SingleCompatibleResourceGroupSelector selector;
+ private SingleCompatibleResourceGroupSelector groupSelector;
+ private HandlerRegistration handlerRegistrar;
- public QuickGroupCreateWizard(SingleCompatibleResourceGroupSelector selector) {
+ public QuickGroupCreateWizard(SingleCompatibleResourceGroupSelector theSelector) {
super();
- this.selector = selector;
+ this.groupSelector = theSelector;
}
- public void groupCreateCallback(ResourceGroup group) {
- selector.fetchData();
+ public void groupCreateCallback(final ResourceGroup group) {
+ // note: "group" is essentially a flyweight - it doesn't have much other than ID
+ this.groupSelector.setValue(group.getId());
+
+ this.handlerRegistrar = this.groupSelector.addDataArrivedHandler(new DataArrivedHandler() {
+ public void onDataArrived(DataArrivedEvent event) {
+ handlerRegistrar.removeHandler(); // this handler is only needed once, when group wizard is finished with and we created our group
+ if (groupSelector.getSelectedRecord() == null) {
+ // it appears that the user created a group that cannot be a bundle target.
+ groupSelector.clearValue();
+ groupSelectionChanged(null);
+ } else {
+ groupSelectionChanged(group.getId());
+ }
+ }
+ });
+
+ // order is important - we set the value first above, add dataArrivedHandler, then fetch, which triggers our handler
+ this.groupSelector.fetchData();
}
}
12 years, 10 months
[rhq] pom.xml
by ips
pom.xml | 242 +++++++++++++++++++++++++++++-----------------------------------
1 file changed, 112 insertions(+), 130 deletions(-)
New commits:
commit f67bd011101a1b463108fb8a79348eafc118b474
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Jun 28 17:40:42 2011 -0400
make sure the Build-Number and Build-Time Manifest attributes always get set
to valid values, even for SNAPSHOT builds; however, if the project dir is not a
git working dir or the git executable is not available on the PATH, the
Build-Number attribute will not get set to a valid value, but the build should
not fail
diff --git a/pom.xml b/pom.xml
index 719a827..3c8cc4c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -607,7 +607,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
- <version>1.0-beta-4</version>
+ <version>1.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -842,6 +842,113 @@
</configuration>
</plugin>
+ <!-- As of v1.0 of the buildnumber plugin, the create goal doesn't work,
+ and the create-timestamp goal doesn't provide a way to specify
+ a locale or a timezone, so comment this out for now and instead use
+ our own homemade mix of antrun and properties-file plugin executions
+ (just below this commented out block). (ips, 06/28/11)
+ -->
+ <!--
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>buildnumber-maven-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <id>setBuildNumber</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ <configuration>
+ <useLastCommittedRevision>true</useLastCommittedRevision>
+ <getRevisionOnlyOnce>true</getRevisionOnlyOnce>
+ <revisionOnScmFailure></revisionOnScmFailure>
+ <doCheck>false</doCheck>
+ <doUpdate>false</doUpdate>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>setBuildTime</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>create-timestamp</goal>
+ </goals>
+ <configuration>
+ <timestampFormat>MM/dd/yy hh:mm aa z</timestampFormat>
+ <timestampPropertyName>buildTime</timestampPropertyName>
+ </configuration>
+ </execution>
+
+ </executions>
+ </plugin>
+ -->
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>write-build-properties-file</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>generate-sources</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="target" />
+
+ <tstamp>
+ <format property="buildTime" pattern="MM/dd/yy hh:mm aa z" locale="en,US" timezone="GMT" />
+ </tstamp>
+ <echo file="target/build.properties">buildTime = ${buildTime}${line.separator}</echo>
+
+ <exec executable="git" outputproperty="buildNumber" failonerror="false" failifexecutionfails="false">
+ <arg value="log"/>
+ <arg value="--pretty=format:%h"/>
+ <arg value="-n1"/>
+ </exec>
+ <echo file="target/build.properties" append="true">buildNumber = ${buildNumber}${line.separator}</echo>
+ </tasks>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>echo-build-properties</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <echo level="debug">buildTime = ${buildTime}</echo>
+ <echo level="debug">buildNumber = ${buildNumber}</echo>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>properties-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>read-build-properties-file</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>read-project-properties</goal>
+ </goals>
+ <configuration>
+ <files>
+ <file>${project.build.directory}/build.properties</file>
+ </files>
+ <quiet>true</quiet>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
@@ -990,7 +1097,9 @@
</properties>
</profile>
- <!-- Set the java6.home prop to a Java6 JRE dir to enforce that only Java6 APIs are used. -->
+ <!-- Set the java6.home prop to a Java6 JRE dir to enforce that only Java6 APIs are used.
+ If using Java7 to run the build, this will ensure no APIs introduced in Java7 are
+ used. -->
<profile>
<id>check-java-api</id>
<activation>
@@ -1031,133 +1140,6 @@
</build>
</profile>
- <!-- Use buildnumber plugin only if SVN metadata is present. -->
- <profile>
- <id>build-number-generation</id>
- <activation>
- <file>
- <exists>.svn</exists>
- </file>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>buildnumber-maven-plugin</artifactId>
- <executions>
- <execution>
- <phase>validate</phase>
- <goals>
- <goal>create</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <getRevisionOnlyOnce>true</getRevisionOnlyOnce>
- <revisionOnScmFailure>0</revisionOnScmFailure>
- <doCheck>false</doCheck>
- <doUpdate>false</doUpdate>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>build-properties</id>
- <activation>
- <file>
- <exists>.git</exists>
- </file>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>write-build-time-properties-file</id>
- <goals>
- <goal>run</goal>
- </goals>
- <phase>generate-sources</phase>
- <configuration>
- <tasks>
- <tstamp>
- <format property="buildTime" pattern="MM/dd/yy hh:mm aa z" locale="en,US" timezone="GMT" />
- </tstamp>
- <mkdir dir="target" />
- <echo file="target/build-time.properties" level="error">buildTime = ${buildTime}
- </echo>
- </tasks>
- </configuration>
- </execution>
-
- <execution>
- <id>echo-build-properties</id>
- <phase>compile</phase>
- <inherited>false</inherited>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <echo level="debug">buildTime = ${buildTime}</echo>
- <echo level="debug">buildNumber = ${buildNumber}</echo>
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-build-number-properties</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <executable>git</executable>
- <arguments>
- <argument>log</argument>
- <argument>--pretty=format:buildNumber = %h</argument>
- <argument>-n1</argument>
- </arguments>
- <outputFile>${project.build.directory}/build-number.properties</outputFile>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>properties-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>read-build-properties</id>
- <phase>process-sources</phase>
- <goals>
- <goal>read-project-properties</goal>
- </goals>
- <configuration>
- <files>
- <file>${project.build.directory}/build-time.properties</file>
- <file>${project.build.directory}/build-number.properties</file>
- </files>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
<!-- This profile should be enabled when a release is being published.
It will ensure that sources and javadoc jars are built and published
for each source module. -->
@@ -1262,7 +1244,7 @@
<licenses>
<license>
<name>GPL</name>
- <url>http://gnu.org</url>
+ <url>http://www.gnu.org/licenses/gpl.html</url>
</license>
</licenses>
12 years, 10 months
[rhq] Branch 'drift' - modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java | 17 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 11 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java | 74 ++++++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java | 44 ++--
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java | 15 +
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java | 1
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java | 110 ++++++++++
7 files changed, 249 insertions(+), 23 deletions(-)
New commits:
commit 9d6b41dc094a53ee93d6ecf9aa9a568da313029d
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jun 28 17:17:49 2011 -0400
Adding support for sending change set content to server
Initial commit for DriftFilesSenderTest and DriftClient. DriftClient is
an interface that is passed into DriftDetector and DriftFilesSender to
better facilitate testing.
This is a rough, first cut at this functionality that has not yet gone
through end-to-end testing. DriftFilesSender iterates through the change
set meta data file for each DriftFile until it finds a matching hash.
When a match is found, it stages the file so that it can be sent to the
server.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java
new file mode 100644
index 0000000..114c365
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java
@@ -0,0 +1,17 @@
+package org.rhq.core.pc.drift;
+
+import java.io.File;
+
+import org.rhq.core.domain.drift.DriftConfiguration;
+
+/**
+ * This is a client interface to the server that drift-related tasks call to interact with
+ * the server.
+ */
+public interface DriftClient {
+
+ void sendChangeSetToServer(int resourceId, DriftConfiguration driftConfiguration);
+
+ void sendChangeSetContentToServer(int resourceId, String driftConfigurationName, File contentDir);
+
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
index f1f0fdb..6c31e7f 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
@@ -6,7 +6,6 @@ import java.util.Collection;
import java.util.Stack;
import org.apache.commons.io.DirectoryWalker;
-import org.apache.commons.io.FilenameUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -14,11 +13,9 @@ import org.rhq.common.drift.ChangeSetWriter;
import org.rhq.common.drift.DirectoryEntry;
import org.rhq.common.drift.FileEntry;
import org.rhq.common.drift.Headers;
-import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.util.MessageDigestGenerator;
-import static java.io.File.separator;
import static java.util.Collections.EMPTY_LIST;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
@@ -31,7 +28,7 @@ public class DriftDetector implements Runnable {
private MessageDigestGenerator digestGenerator = new MessageDigestGenerator(MessageDigestGenerator.SHA_256);
- private DriftManager driftMgr;
+ private DriftClient driftClient;
public void setScheduleQueue(ScheduleQueue queue) {
scheduleQueue = queue;
@@ -41,8 +38,8 @@ public class DriftDetector implements Runnable {
changeSetMgr = changeSetManager;
}
- public void setDriftManager(DriftManager driftManager) {
- driftMgr = driftManager;
+ public void setDriftClient(DriftClient driftClient) {
+ this.driftClient = driftClient;
}
@Override
@@ -70,7 +67,7 @@ public class DriftDetector implements Runnable {
schedule.updateShedule();
scheduleQueue.enqueue(schedule);
- driftMgr.sendChangeSetToServer(schedule.getResourceId(), driftConfig);
+ driftClient.sendChangeSetToServer(schedule.getResourceId(), driftConfig);
}
private String relativePath(File basedir, File file) {
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java
index a6ec604..e7cf34c 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java
@@ -1,16 +1,88 @@
package org.rhq.core.pc.drift;
+import java.io.File;
+import java.io.IOException;
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.common.drift.ChangeSetReader;
+import org.rhq.common.drift.DirectoryEntry;
+import org.rhq.common.drift.FileEntry;
+import org.rhq.common.drift.Headers;
import org.rhq.core.domain.drift.DriftFile;
+import org.rhq.core.util.file.FileUtil;
+
+import static org.rhq.core.util.file.FileUtil.copyFile;
public class DriftFilesSender implements Runnable {
- public DriftFilesSender(int resourceId, String driftConfigurationName, List<DriftFile> driftFiles) {
+ private Log log = LogFactory.getLog(DriftFilesSender.class);
+
+ private int resourceId;
+
+ private Headers headers;
+
+ private List<DriftFile> driftFiles;
+ private ChangeSetManager changeSetMgr;
+
+ private DriftClient driftClient;
+
+ public void setResourceId(int resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ public void setHeaders(Headers headers) {
+ this.headers = headers;
+ }
+
+ public void setDriftFiles(List<DriftFile> driftFiles) {
+ this.driftFiles = driftFiles;
+ }
+
+ public void setDriftClient(DriftClient driftClient) {
+ this.driftClient = driftClient;
+ }
+
+ public void setChangeSetManager(ChangeSetManager changeSetManager) {
+ changeSetMgr = changeSetManager;
}
@Override
public void run() {
+ try {
+ File changeSet = changeSetMgr.findChangeSet(resourceId, headers.getDriftConfigurationName());
+ File contentDir = new File(changeSet.getParentFile(), "content");
+ contentDir.mkdir();
+
+ for (DriftFile driftFile : driftFiles) {
+ File file = find(driftFile);
+ if (file == null) {
+ log.warn("Unable to find file for " + driftFile);
+ } else {
+ copyFile(file, new File(contentDir, driftFile.getHashId()));
+ }
+ }
+ driftClient.sendChangeSetContentToServer(resourceId, headers.getDriftConfigurationName(), contentDir);
+ } catch (IOException e) {
+ log.error("Failed to send drift files.", e);
+ }
+ }
+
+ private File find(DriftFile driftFile) throws IOException {
+ ChangeSetReader reader = changeSetMgr.getChangeSetReader(resourceId, headers.getDriftConfigurationName());
+ DirectoryEntry dirEntry = reader.readDirectoryEntry();
+
+ while (dirEntry != null) {
+ for (FileEntry fileEntry : dirEntry) {
+ if (fileEntry.getNewSHA().equals(driftFile.getHashId())) {
+ File dir = new File(headers.getBasedir(), dirEntry.getDirectory());
+ return new File(dir, fileEntry.getFile());
+ }
+ }
+ }
+ return null;
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index 2560147..1d6ec1a 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -22,7 +22,7 @@ import org.rhq.core.pc.ContainerService;
import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.agent.AgentService;
-public class DriftManager extends AgentService implements DriftAgentService, ContainerService {
+public class DriftManager extends AgentService implements DriftAgentService, DriftClient, ContainerService {
private final Log log = LogFactory.getLog(DriftManager.class);
@@ -54,7 +54,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Con
DriftDetector driftDetector = new DriftDetector();
driftDetector.setScheduleQueue(schedulesQueue);
driftDetector.setChangeSetManager(changeSetMgr);
- driftDetector.setDriftManager(this);
+ driftDetector.setDriftClient(this);
driftThreadPool = new ScheduledThreadPoolExecutor(5);
driftThreadPool.scheduleAtFixedRate(new DriftDetector(), 30, 1800, TimeUnit.SECONDS);
@@ -71,6 +71,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Con
changeSetMgr = null;
}
+ @Override
public void sendChangeSetToServer(int resourceId, DriftConfiguration driftConfiguration) {
try {
File changeSetFile = changeSetMgr.findChangeSet(resourceId, driftConfiguration.getName());
@@ -98,6 +99,21 @@ public class DriftManager extends AgentService implements DriftAgentService, Con
}
@Override
+ public void sendChangeSetContentToServer(int resourceId, String driftConfigurationName, File contentDir) {
+ try {
+ File zipFile = new File(pluginContainerConfiguration.getTemporaryDirectory(), "content.zip");
+ zipFileOrDirectory(contentDir, zipFile);
+
+ DriftServerService driftServer = pluginContainerConfiguration.getServerServices().getDriftServerService();
+ driftServer.sendFilesZip(resourceId, zipFile.length(), remoteInputStream(new BufferedInputStream(
+ new FileInputStream(zipFile))));
+ } catch (IOException e) {
+ log.error("An error occurred while trying to send content for changeset[resourceId: " + resourceId +
+ ", driftConfiguration: " + driftConfigurationName + "]", e);
+ }
+ }
+
+ @Override
public void detectDrift(int resourceId, DriftConfiguration driftConfiguration) {
ScheduleQueue queue = new ScheduleQueue() {
DriftDetectionSchedule schedule;
@@ -125,7 +141,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Con
DriftDetector driftDetector = new DriftDetector();
driftDetector.setChangeSetManager(changeSetMgr);
driftDetector.setScheduleQueue(queue);
- driftDetector.setDriftManager(this);
+ driftDetector.setDriftClient(this);
driftThreadPool.execute(driftDetector);
}
@@ -135,29 +151,27 @@ public class DriftManager extends AgentService implements DriftAgentService, Con
schedulesQueue.enqueue(new DriftDetectionSchedule(resourceId, driftConfiguration));
}
- public void sendSnapshotReport(int resourceId, SnapshotHandle handle) throws Exception {
- DriftServerService driftServer = pluginContainerConfiguration.getServerServices().getDriftServerService();
-
- driftServer.sendChangesetZip(resourceId, handle.getMetadataFile().length(),
- remoteInputStream(new BufferedInputStream(new FileInputStream(handle.getMetadataFile()))));
- }
-
@Override
public boolean requestDriftFiles(int resourceId, Headers headers, List<DriftFile> driftFiles) {
- return false;
+ DriftFilesSender sender = new DriftFilesSender();
+ sender.setResourceId(resourceId);
+ sender.setDriftClient(this);
+ sender.setDriftFiles(driftFiles);
+ sender.setHeaders(headers);
+ sender.setChangeSetManager(changeSetMgr);
+
+ driftThreadPool.execute(sender);
+
+ return true;
}
@Override
public void unscheduleDriftDetection(int resourceId, DriftConfiguration driftConfiguration) {
- // TODO Auto-generated method stub
-
}
@Override
public void updateDriftDetection(int resourceId, DriftConfiguration driftConfiguration) {
- // TODO Auto-generated method stub
-
}
}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java
new file mode 100644
index 0000000..d6e5d45
--- /dev/null
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java
@@ -0,0 +1,15 @@
+package org.rhq.core.pc.drift;
+
+import java.io.File;
+
+import org.rhq.core.domain.drift.DriftConfiguration;
+
+class DriftClientTestStub implements DriftClient {
+ @Override
+ public void sendChangeSetToServer(int resourceId, DriftConfiguration driftConfiguration) {
+ }
+
+ @Override
+ public void sendChangeSetContentToServer(int resourceId, String driftConfigurationName, File contentDir) {
+ }
+}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
index 8ec7938..0a10de3 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
@@ -73,6 +73,7 @@ public class DriftDetectorTest extends JMockTest {
scheduleQueue.enqueue(schedule);
DriftDetector detector = new DriftDetector();
+ detector.setDriftClient(new DriftClientTestStub());
detector.setChangeSetManager(changeSetMgr);
detector.setScheduleQueue(scheduleQueue);
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java
new file mode 100644
index 0000000..eb333f5
--- /dev/null
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java
@@ -0,0 +1,110 @@
+package org.rhq.core.pc.drift;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.io.IOUtils;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import org.unitils.thirdparty.org.apache.commons.io.FileUtils;
+
+import org.rhq.common.drift.Headers;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+import org.rhq.core.domain.drift.DriftFile;
+
+import static java.util.Arrays.asList;
+import static org.apache.commons.io.FileUtils.deleteDirectory;
+import static org.apache.commons.io.FileUtils.touch;
+import static org.apache.commons.io.IOUtils.writeLines;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+public class DriftFilesSenderTest {
+
+ File changeSetsDir;
+
+ File resourcesDir;
+
+ ChangeSetManager changeSetMgr;
+
+ String driftConfigName = "test";
+
+ File server1Dir;
+
+ @BeforeClass
+ public void init() throws Exception {
+ File basedir = new File("target", getClass().getSimpleName());
+ deleteDirectory(basedir);
+ basedir.mkdir();
+
+ changeSetsDir = new File(basedir, "changesets");
+ changeSetsDir.mkdir();
+
+ resourcesDir = new File(basedir, "resources");
+ resourcesDir.mkdir();
+ }
+
+ @BeforeMethod
+ public void setUp() {
+ changeSetMgr = new ChangeSetManagerImpl(changeSetsDir);
+ }
+
+ @Test
+ public void sendFiles() throws Exception {
+ String driftConfigName = "test";
+
+ File server1Dir = new File(resourcesDir, "server-1");
+ server1Dir.mkdir();
+
+ File confDir = new File(server1Dir, "conf");
+ confDir.mkdir();
+
+ touch(new File(confDir, "server.conf"));
+
+ int resourceId = 1;
+
+ File changeSetDir = new File(new File(changeSetsDir, Integer.toString(resourceId)), driftConfigName);
+ changeSetDir.mkdirs();
+
+ List<String> changeSet = asList(
+ driftConfigName,
+ server1Dir.getAbsolutePath(),
+ COVERAGE.code(),
+ "conf 1",
+ "2e345df 0 server.conf A",
+ ""
+ );
+ BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(new File(changeSetDir,
+ "changeset.txt")));
+ writeLines(changeSet, "\n", stream);
+ stream.close();
+
+ Headers headers = new Headers(driftConfigName, server1Dir.getAbsolutePath(), COVERAGE);
+ List<DriftFile> driftFiles = asList(new DriftFile("2e345df"));
+
+ DriftFilesSender sender = new DriftFilesSender();
+ sender.setDriftClient(new DriftClientTestStub());
+ sender.setChangeSetManager(changeSetMgr);
+ sender.setResourceId(resourceId);
+ sender.setDriftFiles(driftFiles);
+ sender.setHeaders(headers);
+ sender.run();
+
+ File contentDir = new File(changeSetDir, "content");
+ contentDir.mkdir();
+
+ File content = new File(contentDir, "2e345df");
+
+ assertEquals(contentDir.list().length, 1, "Expected to find one file in " +
+ contentDir.getAbsolutePath());
+ assertTrue(content.exists(), "Expected to find file named " + content.getName() + " in content directory. " +
+ "SHA-256 hashes should be used as file names");
+ }
+
+}
12 years, 10 months
[rhq] Branch 'drift' - modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java | 15 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java | 23 -------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java | 13 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/AbstractDriftAddConfigWizard.java | 7 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizard.java | 31 +++++++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizardInfoStep.java | 6 -
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 2
11 files changed, 74 insertions(+), 31 deletions(-)
New commits:
commit c9bc8846f642fbe9ff9a155548b477dbeb3894f5
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jun 28 16:40:49 2011 -0400
- Drift AddConfig wizard now adding configs to the db. It's a canned config for testing
until we have real support for drift config templates.
- Add missing filtering in DriftDataSource and DriftConfigDataSource to
narrow down the result set to applicable resource.
- Fix issue in DriftConfigDataSource needing string attribute value
- Remove unnecessary/wrong link column stuff in config view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java
index ba942b0..c38b68d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java
@@ -236,6 +236,19 @@ public class DriftConfigurationDataSource extends RPCDataSource<DriftConfigurati
protected ResourceCriteria getFetchCriteria(DSRequest request) {
ResourceCriteria criteria = new ResourceCriteria();
+ switch (entityContext.getType()) {
+ case Resource:
+ criteria.addFilterId(entityContext.getResourceId());
+ break;
+
+ case ResourceGroup:
+ criteria.addFilterExplicitGroupIds(entityContext.getGroupId());
+ break;
+
+ default:
+ // no filter
+ }
+
criteria.fetchDriftConfigurations(true);
criteria.setPageControl(getPageControl(request));
@@ -265,7 +278,7 @@ public class DriftConfigurationDataSource extends RPCDataSource<DriftConfigurati
ListGridRecord record = new ListGridRecord();
record.setAttribute("id", from.getId());
record.setAttribute("name", from.getName());
- record.setAttribute("interval", from.getInterval());
+ record.setAttribute("interval", String.valueOf(from.getInterval()));
record.setAttribute("baseDir", from.getBasedir());
record.setAttribute("enabled", from.getEnabled());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
index b217d5b..002f468 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
@@ -28,7 +28,6 @@ import com.smartgwt.client.data.ResultSet;
import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -36,18 +35,14 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
-import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.drift.wizard.DriftAddConfigWizard;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* A view that displays a paginated table of {@link org.rhq.core.domain.drift.DriftConfiguration}s, along with the
@@ -126,24 +121,6 @@ public class DriftConfigurationView extends TableSection<DriftConfigurationDataS
super.configureTable();
}
- @Override
- protected String getDetailsLinkColumnName() {
- return "name";
- }
-
- @Override
- protected CellFormatter getDetailsLinkColumnCellFormatter() {
- return new CellFormatter() {
- public String format(Object value, ListGridRecord record, int i, int i1) {
- Integer resourceId = record.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
- Integer driftConfigId = getId(record);
- String url = LinkManager.getSubsystemDriftConfigLink(resourceId, driftConfigId);
- String formattedValue = TimestampCellFormatter.format(value);
- return SeleniumUtility.getLocatableHref(url, formattedValue, null);
- }
- };
- }
-
protected void setupTableInteractions(final boolean hasWriteAccess) {
TableActionEnablement singleTargetEnablement = hasWriteAccess ? TableActionEnablement.ANY
: TableActionEnablement.NEVER;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
index fe592a9..ae5db2a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
@@ -242,6 +242,19 @@ public class DriftDataSource extends RPCDataSource<Drift, DriftCriteria> {
DriftCriteria criteria = new DriftCriteria();
criteria.addFilterCategories(categoriesFilter);
+
+ switch (entityContext.getType()) {
+ case Resource:
+ criteria.addFilterResourceIds(entityContext.getResourceId());
+ break;
+
+ case ResourceGroup:
+ // TODO ?
+
+ default:
+ // no filter
+ }
+
criteria.fetchChangeSet(true);
criteria.setPageControl(getPageControl(request));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/AbstractDriftAddConfigWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/AbstractDriftAddConfigWizard.java
index 0b6bca4..4d3b073 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/AbstractDriftAddConfigWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/AbstractDriftAddConfigWizard.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.gui.coregui.client.drift.wizard;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard;
import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardView;
@@ -35,7 +36,7 @@ public abstract class AbstractDriftAddConfigWizard extends AbstractWizard {
private String newConfigName;
private String newConfigInterval;
private Configuration newStartingConfiguration;
- private Configuration newDriftConfiguration;
+ private DriftConfiguration newDriftConfiguration;
private WizardView view;
@@ -90,12 +91,12 @@ public abstract class AbstractDriftAddConfigWizard extends AbstractWizard {
this.newStartingConfiguration = newStartingConfiguration;
}
- public Configuration getNewDriftConfiguration() {
+ public DriftConfiguration getNewDriftConfiguration() {
return newDriftConfiguration;
}
public void setNewConfiguration(Configuration newDriftConfiguration) {
- this.newDriftConfiguration = newDriftConfiguration;
+ this.newDriftConfiguration = new DriftConfiguration(newDriftConfiguration);
}
public void cancel() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizard.java
index 4fcb61f..f8bca45 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizard.java
@@ -31,6 +31,7 @@ import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardStep;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
/**
* @author Jay Shaughnessy
@@ -62,7 +63,35 @@ public class DriftAddConfigWizard extends AbstractDriftAddConfigWizard {
}
public void execute() {
- // TODO
+ EntityContext context = getEntityContext();
+ switch (context.getType()) {
+ case Resource:
+
+ ResourceCriteria rc = new ResourceCriteria();
+ rc.addFilterId(context.getResourceId());
+ rc.fetchResourceType(true);
+ GWTServiceLookup.getDriftService().updateDriftConfiguration(context, getNewDriftConfiguration(),
+ new AsyncCallback<Void>() {
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_drift_wizard_addConfig_success(getNewDriftConfiguration().getName()),
+ Message.Severity.Info));
+ getView().closeDialog();
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_drift_wizard_addConfig_failure(getNewDriftConfiguration().getName()), caught);
+ getView().closeDialog();
+ }
+ });
+
+ break;
+
+ default:
+ throw new IllegalArgumentException("Entity Context Type not supported [" + context + "]");
+ }
+
}
public static void showWizard(final EntityContext context) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizardInfoStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizardInfoStep.java
index 2d0932b..8f5b750 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizardInfoStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizardInfoStep.java
@@ -100,12 +100,12 @@ public class DriftAddConfigWizardInfoStep extends AbstractWizardStep {
}
} else {
// TODO this should throw an error as there should be at least one template (can remove the +1 sizing above when changing)
- // throw new IllegalStateException( "At least one srift configuration template should exist for the resource type" );
+ // throw new IllegalStateException( "At least one drift configuration template should exist for the resource type" );
ConfigurationTemplate test = new ConfigurationTemplate("Test", "Test");
Configuration config = new Configuration();
config.put(new PropertySimple("name", "Test"));
- config.put(new PropertySimple("basedir", "/TestDir"));
- config.put(new PropertySimple("interval", "1200"));
+ config.put(new PropertySimple("basedir", "C:/workspace/rhq/dev-container/jbossas/server/default/conf"));
+ config.put(new PropertySimple("interval", "6000"));
test.setConfiguration(config);
test.setConfigurationDefinition(DriftConfigurationDefinition.getInstance());
templatesMap.put("TestOnly", test);
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 d171188..fb4e2a6 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
@@ -1126,9 +1126,11 @@ view_drift_table_newFile = New File
view_drift_table_oldFile = Old File
view_drift_table_resourceConfig = Resource Drift Configuration
view_drift_table_resourceHistory = Resource Drift History
+view_drift_wizard_addConfig_failure = Failed to add new drift configuration [{0}]
view_drift_wizard_addConfig_infoStepName = Provide Drift Detection Information
view_drift_wizard_addConfig_nameHelp = A textual name briefly describing the purpose of this drift detection configuration. Drift configuration names must be unique for a resource.
view_drift_wizard_addConfig_namePrompt = New Drift Configuration Name
+view_drift_wizard_addConfig_success = Successfully added new drift configuration [{0}]. Agent(s) will be updated.
view_drift_wizard_addConfig_templateHelp = Each drift configuration describes a set of files for which drift detection can be performed. The configuration can be enabled and disabled, defines the detection interval, and specifies a base directory and optional file filters. For each resource type offering drift detection there will be one or more predefined templates to use a starting configuration, which can then be edited.
view_drift_wizard_addConfig_templatePrompt = Drift Configuration Templates
view_drift_wizard_addConfig_title = Add Drift Configuration for Resource of Type [{0}]
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 52389a9..d3b63d2 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -950,9 +950,11 @@ view_dashboards_title = Dashboard
##view_drift_table_oldFile = Old File
view_drift_table_resourceConfig = Resource Drift Configuration
##view_drift_table_resourceHistory = Resource Drift History
+##view_drift_wizard_addConfig_failure = Failed to add new drift configuration [{0}]
##view_drift_wizard_addConfig_infoStepName = Provide Drift Detection Information
##view_drift_wizard_addConfig_nameHelp = A textual name briefly describing the purpose of this drift detection configuration. Drift configuration names must be unique for a resource.
##view_drift_wizard_addConfig_namePrompt = New Drift Configuration Name
+##view_drift_wizard_addConfig_success = Successfully added new drift configuration [{0}]. Agent(s) will be updated.
##view_drift_wizard_addConfig_templateHelp = Each drift configuration describes a set of files for which drift detection can be performed. The configuration can be enabled and disabled, defines the detection interval, and specifies a base directory and optional file filters. For each resource type offering drift detection there will be one or more predefined templates to use a starting configuration, which can then be edited.
##view_drift_wizard_addConfig_templatePrompt = Drift Configuration Templates
##view_drift_wizard_addConfig_title = Add Drift Configuration for Resource of Type [{0}]
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 134a22f..c648541 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -1127,9 +1127,11 @@ view_dashboards_title = ダッシュボード
##view_drift_table_oldFile = Old File
view_drift_table_resourceConfig = Resource Drift Configuration
##view_drift_table_resourceHistory = Resource Drift History
+##view_drift_wizard_addConfig_failure = Failed to add new drift configuration [{0}]
##view_drift_wizard_addConfig_infoStepName = Provide Drift Detection Information
##view_drift_wizard_addConfig_nameHelp = A textual name briefly describing the purpose of this drift detection configuration. Drift configuration names must be unique for a resource.
##view_drift_wizard_addConfig_namePrompt = New Drift Configuration Name
+##view_drift_wizard_addConfig_success = Successfully added new drift configuration [{0}]. Agent(s) will be updated.
##view_drift_wizard_addConfig_templateHelp = Each drift configuration describes a set of files for which drift detection can be performed. The configuration can be enabled and disabled, defines the detection interval, and specifies a base directory and optional file filters. For each resource type offering drift detection there will be one or more predefined templates to use a starting configuration, which can then be edited.
##view_drift_wizard_addConfig_templatePrompt = Drift Configuration Templates
##view_drift_wizard_addConfig_title = Add Drift Configuration for Resource of Type [{0}]
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index 88273e4..a81c28f 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -1150,9 +1150,11 @@ view_dashboards_title = Dashboard~
##view_drift_table_oldFile = Old File
view_drift_table_resourceConfig = Resource Drift Configuration
##view_drift_table_resourceHistory = Resource Drift History
+##view_drift_wizard_addConfig_failure = Failed to add new drift configuration [{0}]
##view_drift_wizard_addConfig_infoStepName = Provide Drift Detection Information
##view_drift_wizard_addConfig_nameHelp = A textual name briefly describing the purpose of this drift detection configuration. Drift configuration names must be unique for a resource.
##view_drift_wizard_addConfig_namePrompt = New Drift Configuration Name
+##view_drift_wizard_addConfig_success = Successfully added new drift configuration [{0}]. Agent(s) will be updated.
##view_drift_wizard_addConfig_templateHelp = Each drift configuration describes a set of files for which drift detection can be performed. The configuration can be enabled and disabled, defines the detection interval, and specifies a base directory and optional file filters. For each resource type offering drift detection there will be one or more predefined templates to use a starting configuration, which can then be edited.
##view_drift_wizard_addConfig_templatePrompt = Drift Configuration Templates
##view_drift_wizard_addConfig_title = Add Drift Configuration for Resource of Type [{0}]
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 9ff3634..560241b 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -1126,9 +1126,11 @@ view_dashboards_title = \u7EDF\u8BA1\u8868\u76D8
##view_drift_table_oldFile = Old File
view_drift_table_resourceConfig = Resource Drift Configuration
##view_drift_table_resourceHistory = Resource Drift History
+##view_drift_wizard_addConfig_failure = Failed to add new drift configuration [{0}]
##view_drift_wizard_addConfig_infoStepName = Provide Drift Detection Information
##view_drift_wizard_addConfig_nameHelp = A textual name briefly describing the purpose of this drift detection configuration. Drift configuration names must be unique for a resource.
##view_drift_wizard_addConfig_namePrompt = New Drift Configuration Name
+##view_drift_wizard_addConfig_success = Successfully added new drift configuration [{0}]. Agent(s) will be updated.
##view_drift_wizard_addConfig_templateHelp = Each drift configuration describes a set of files for which drift detection can be performed. The configuration can be enabled and disabled, defines the detection interval, and specifies a base directory and optional file filters. For each resource type offering drift detection there will be one or more predefined templates to use a starting configuration, which can then be edited.
##view_drift_wizard_addConfig_templatePrompt = Drift Configuration Templates
##view_drift_wizard_addConfig_title = Add Drift Configuration for Resource of Type [{0}]
12 years, 10 months
[rhq] modules/plugins
by Heiko W. Rupp
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java | 9 +++++
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java | 17 +++++++++-
2 files changed, 25 insertions(+), 1 deletion(-)
New commits:
commit aed0881f6c23e7015c7c8665074d2c444acad189
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 28 21:59:52 2011 +0200
Support the new "rolled-back" element in the JSON response from the AS.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
index a5583b7..63c5262 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
@@ -40,6 +40,8 @@ public class Result {
private /*List<Map<String, String>>*/Object failureDescription;
@JsonIgnore
private boolean success = false;
+ @JsonProperty("rolled-back")
+ private boolean rolledBack = false;
public Result() {
@@ -83,4 +85,11 @@ public class Result {
this.failureDescription = failureDescription;
}
+ public boolean isRolledBack() {
+ return rolledBack;
+ }
+
+ public void setRolledBack(boolean rolledBack) {
+ this.rolledBack = rolledBack;
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 53ac89e..b36a03b 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -185,7 +185,7 @@ public class OperationJsonTest {
public void arrayResult1() throws Exception {
- String resultString = "{\"outcome\":\"success\",\"result\":[\"standard-sockets\",\"messaging-sockets\"],\"compensating-operation\":null}";
+ String resultString = "{\"outcome\":\"success\",\"result\":[\"standard-sockets\",\"messaging-sockets\"],\"compensating-operation\":null, \"rolled-back\" : false}";
ObjectMapper mapper = new ObjectMapper();
Result result = mapper.readValue(resultString,Result.class);
@@ -197,6 +197,21 @@ public class OperationJsonTest {
assert stringList.size()==2;
assert stringList.get(0).equals("standard-sockets");
assert stringList.get(1).equals("messaging-sockets");
+ assert !result.isRolledBack();
+
+ }
+
+ public void rolledBack() throws Exception {
+
+ String resultString = "{\"outcome\":\"failed\", \"rolled-back\" : true}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ Result result = mapper.readValue(resultString,Result.class);
+
+ assert result != null;
+ assert result.getOutcome().equals("failed");
+ assert !result.isSuccess();
+ assert result.isRolledBack();
}
12 years, 10 months
[rhq] Branch 'drift' - modules/common modules/core
by John Sanda
modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java | 46 ++-
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 18 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java | 14 -
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java | 116 ++++++++++
4 files changed, 162 insertions(+), 32 deletions(-)
New commits:
commit 223dad5af4d8a53b4912630633a4e40b2d8a9b38
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jun 28 15:41:44 2011 -0400
Add absolute path of basedir header entry
This commit includes two changes. First, ChangeSetWriter has been
updated to write out the full path of the basedir header.
Secondly, empty directories are excluded from the change set file.
diff --git a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
index 3f4efda..0109619 100644
--- a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
+++ b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
@@ -24,23 +24,35 @@ import static org.testng.Assert.assertTrue;
public class ChangeSetWriterImplTest {
- File changeSetsDir = new File("target", "changesets");
+ File changeSetsDir;
+
+ File resourcesDir;
@BeforeClass
public void setupChangesetsDir() throws Exception {
- deleteDirectory(changeSetsDir);
- assertTrue(changeSetsDir.mkdirs(), "Failed to create " + changeSetsDir.getPath());
+ File basedir = new File("target", getClass().getSimpleName());
+ deleteDirectory(basedir);
+
+ basedir.mkdir();
+
+ changeSetsDir = new File(basedir, "changesets");
+ changeSetsDir.mkdir();
+
+ resourcesDir = new File(basedir, "resources");
+ resourcesDir.mkdir();
}
@Test
@SuppressWarnings("unchecked")
public void writeDirectoryEntryWithAddedFile() throws Exception {
+ File resourceDir = new File(resourcesDir, "myresource");
+
File changeSetFile = new File(changeSetsDir, "added-file-test");
- Headers headers = new Headers("added-file-test", "myresource", COVERAGE);
+ Headers headers = new Headers("added-file-test", resourceDir.getAbsolutePath(), COVERAGE);
ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, headers);
- writer.writeDirectoryEntry(new DirectoryEntry("myresource/conf").add(
+ writer.writeDirectoryEntry(new DirectoryEntry("conf").add(
addedFileEntry("myconf.conf", "a34ef6")));
writer.close();
@@ -50,9 +62,9 @@ public class ChangeSetWriterImplTest {
assertEquals(lines.size(), 6, "Expected to find six lines in " + metaDataFile.getPath() +
" - three for the header followed by three for a directory entry.");
- assertHeaderEquals(lines, "added-file-test", "myresource", "C");
+ assertHeaderEquals(lines, "added-file-test", resourceDir.getAbsolutePath(), "C");
- assertEquals(lines.get(3), "myresource/conf 1", "The first line for a directory entry should specify the " +
+ assertEquals(lines.get(3), "conf 1", "The first line for a directory entry should specify the " +
"directory path followed by the number of lines in the entry.");
assertFileEntryEquals(lines.get(4), "a34ef6 0 myconf.conf A");
@@ -61,12 +73,14 @@ public class ChangeSetWriterImplTest {
@Test
@SuppressWarnings("unchecked")
public void writeDirectoryEntryWithRemovedFile() throws Exception {
+ File resourceDir = new File(resourcesDir, "myresource");
+
File changeSetFile = new File(changeSetsDir, "removed-file-test");
- Headers headers = new Headers("removed-file-test", "myresource", COVERAGE);
+ Headers headers = new Headers("removed-file-test", resourceDir.getAbsolutePath(), COVERAGE);
ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, headers);
- writer.writeDirectoryEntry(new DirectoryEntry("myresource/conf").add(
+ writer.writeDirectoryEntry(new DirectoryEntry("conf").add(
removedFileEntry("myconf.conf", "a34ef6")));
writer.close();
@@ -76,9 +90,9 @@ public class ChangeSetWriterImplTest {
assertEquals(lines.size(), 6, "Expected to find six lines in " + metaDataFile.getPath() +
" - three for the header followed by three for a directory entry.");
- assertHeaderEquals(lines, "removed-file-test", "myresource", "C");
+ assertHeaderEquals(lines, "removed-file-test", resourceDir.getAbsolutePath(), "C");
- assertEquals(lines.get(3), "myresource/conf 1", "The first line for a directory entry should specify the " +
+ assertEquals(lines.get(3), "conf 1", "The first line for a directory entry should specify the " +
"directory path followed by the number of lines in the entry.");
assertFileEntryEquals(lines.get(4), "0 a34ef6 myconf.conf R");
@@ -87,12 +101,14 @@ public class ChangeSetWriterImplTest {
@Test
@SuppressWarnings("unchecked")
public void writeDirectoryEntryWithChangedFile() throws Exception {
+ File resourceDir = new File(resourcesDir, "myresource");
+
File changeSetFile = new File(changeSetsDir, "changed-file-test");
- Headers headers = new Headers("changed-file-test", "myresource", COVERAGE);
+ Headers headers = new Headers("changed-file-test", resourceDir.getAbsolutePath(), COVERAGE);
ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, headers);
- writer.writeDirectoryEntry(new DirectoryEntry("myresource/conf").add(
+ writer.writeDirectoryEntry(new DirectoryEntry("conf").add(
changedFileEntry("myconf.conf", "a34ef6", "c2d55f")));
writer.close();
@@ -102,9 +118,9 @@ public class ChangeSetWriterImplTest {
assertEquals(lines.size(), 6, "Expected to find six lines in " + metaDataFile.getPath() +
" - three for the header followed by three for a directory entry.");
- assertHeaderEquals(lines, "changed-file-test", "myresource", "C");
+ assertHeaderEquals(lines, "changed-file-test", resourceDir.getAbsolutePath(), "C");
- assertEquals(lines.get(3), "myresource/conf 1", "The first line for a directory entry should specify the " +
+ assertEquals(lines.get(3), "conf 1", "The first line for a directory entry should specify the " +
"directory path followed by the number of lines in the entry.");
assertFileEntryEquals(lines.get(4), "c2d55f a34ef6 myconf.conf C");
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
index 40524ed..f1f0fdb 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
@@ -52,13 +52,14 @@ public class DriftDetector implements Runnable {
return;
}
+ DriftConfiguration driftConfig = schedule.getDriftConfiguration();
+
try {
// TODO add logic to determine if there is an existing changeset
// if there is no previous changeset then we need to generate the initial
// coverage changeset
ChangeSetWriter writer = changeSetMgr.getChangeSetWriter(schedule.getResourceId(),
- new Headers(schedule.getDriftConfiguration().getName(), schedule.getDriftConfiguration().getBasedir(),
- COVERAGE));
+ new Headers(driftConfig.getName(), driftConfig.getBasedir(), COVERAGE));
DirectoryScanner scanner = new DirectoryScanner(schedule.getDriftConfiguration(), writer);
scanner.scan();
@@ -69,15 +70,14 @@ public class DriftDetector implements Runnable {
schedule.updateShedule();
scheduleQueue.enqueue(schedule);
- driftMgr.sendChangeSetToServer(schedule.getResourceId(), schedule.getDriftConfiguration());
+ driftMgr.sendChangeSetToServer(schedule.getResourceId(), driftConfig);
}
private String relativePath(File basedir, File file) {
if (basedir.equals(file)) {
- return basedir.getPath();
+ return basedir.getName();
}
- return FilenameUtils.getName(basedir.getAbsolutePath()) + separator +
- file.getAbsolutePath().substring(basedir.getAbsolutePath().length() + 1);
+ return file.getAbsolutePath().substring(basedir.getAbsolutePath().length() + 1);
}
private String sha256(File file) throws IOException {
@@ -109,9 +109,9 @@ public class DriftDetector implements Runnable {
@Override
protected void handleDirectoryEnd(File directory, int depth, Collection results) throws IOException {
DirectoryEntry dirEntry = stack.pop();
- writer.writeDirectoryEntry(dirEntry);
-
-
+ if (dirEntry.getNumberOfFiles() > 0) {
+ writer.writeDirectoryEntry(dirEntry);
+ }
}
@Override
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java
index 7bd2623..fe15677 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java
@@ -12,35 +12,33 @@ public class ScheduleQueueImpl implements ScheduleQueue {
@Override
public DriftDetectionSchedule dequeue() {
- Lock writeLock = lock.writeLock();
try {
+ lock.writeLock().lock();
return queue.poll();
} finally {
- writeLock.unlock();
+ lock.writeLock().unlock();
}
}
@Override
public boolean enqueue(DriftDetectionSchedule schedule) {
- Lock writeLock = lock.writeLock();
boolean inserted = false;
try {
- writeLock.lock();
+ lock.writeLock().lock();
inserted = queue.offer(schedule);
} finally {
- writeLock.unlock();
+ lock.writeLock().unlock();
}
return inserted;
}
@Override
public void clear() {
- Lock writeLock = lock.writeLock();
try {
- writeLock.lock();
+ lock.writeLock().lock();
queue.clear();
} finally {
- writeLock.unlock();
+ lock.writeLock().unlock();
}
}
}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
new file mode 100644
index 0000000..8ec7938
--- /dev/null
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
@@ -0,0 +1,116 @@
+package org.rhq.core.pc.drift;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.util.List;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.common.drift.ChangeSetReader;
+import org.rhq.common.drift.ChangeSetReaderImpl;
+import org.rhq.common.drift.DirectoryEntry;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.test.JMockTest;
+
+import static org.apache.commons.io.FileUtils.deleteDirectory;
+import static org.apache.commons.io.IOUtils.readLines;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+import static org.testng.Assert.assertEquals;
+import static org.unitils.thirdparty.org.apache.commons.io.FileUtils.touch;
+
+public class DriftDetectorTest extends JMockTest {
+
+ File changeSetsDir;
+
+ File resourcesDir;
+
+ ChangeSetManager changeSetMgr;
+
+ ScheduleQueue scheduleQueue;
+
+ @BeforeClass
+ public void init() throws Exception {
+ File basedir = new File("target", getClass().getSimpleName());
+ deleteDirectory(basedir);
+ basedir.mkdir();
+
+ changeSetsDir = new File(basedir, "changesets");
+ changeSetsDir.mkdir();
+
+ resourcesDir = new File(basedir, "resources");
+ resourcesDir.mkdir();
+ }
+
+ @BeforeMethod
+ public void setUp() {
+ changeSetMgr = new ChangeSetManagerImpl(changeSetsDir);
+ scheduleQueue = new ScheduleQueueImpl();
+ }
+
+ @Test
+ public void generateCoverageChangeSet() throws Exception {
+ File server1Dir = new File(resourcesDir, "server-1");
+ server1Dir.mkdir();
+
+ File confDir = new File(server1Dir, "conf");
+ confDir.mkdir();
+
+ touch(new File(confDir, "server.conf"));
+
+ DriftConfiguration driftConfig = driftConfiguration("coverage-test", server1Dir.getAbsolutePath());
+
+ int resourceId = 1;
+ DriftDetectionSchedule schedule = new DriftDetectionSchedule(resourceId, driftConfig);
+
+ scheduleQueue.enqueue(schedule);
+
+ DriftDetector detector = new DriftDetector();
+ detector.setChangeSetManager(changeSetMgr);
+ detector.setScheduleQueue(scheduleQueue);
+
+ detector.run();
+
+ File changeSetDir = new File(new File(changeSetsDir, Integer.toString(resourceId)), "coverage-test");
+ File changeSet = new File(changeSetDir, "changeset.txt");
+
+ List<String> lines = readLines(new BufferedInputStream(new FileInputStream(changeSet)));
+
+ assertHeaderEquals(lines, driftConfig.getName(), driftConfig.getBasedir(), COVERAGE.code());
+ assertThatChangeSetDoesNotContainEmptyDirs(changeSet);
+ }
+
+ DriftConfiguration driftConfiguration(String name, String basedir) {
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("name", name));
+ config.put(new PropertySimple("basedir", basedir));
+
+ return new DriftConfiguration(config);
+ }
+
+ void assertHeaderEquals(List<String> lines, String... expected) {
+ assertEquals(lines.get(0), expected[0], "The first header entry should be the drift configuration name.");
+ assertEquals(lines.get(1), expected[1], "The second header entry should be the base directory.");
+ assertEquals(lines.get(2), expected[2], "The third header entry should be a flag indicating the change set " +
+ "type.");
+ }
+
+ void assertThatChangeSetDoesNotContainEmptyDirs(File changeSet) throws Exception {
+ ChangeSetReader reader = new ChangeSetReaderImpl(new BufferedReader(new FileReader(changeSet)));
+ DirectoryEntry dirEntry = reader.readDirectoryEntry();
+
+ while (dirEntry != null) {
+ Assert.assertTrue(dirEntry.getNumberOfFiles() > 0, "The change set file should not include empty " +
+ "directories");
+ dirEntry = reader.readDirectoryEntry();
+ }
+ }
+
+}
12 years, 10 months
[rhq] Branch 'drift' - 3 commits - modules/common modules/enterprise
by Jay Shaughnessy
modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java | 7 +++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java | 3 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 16 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java | 2 -
4 files changed, 16 insertions(+), 12 deletions(-)
New commits:
commit cf14573dee789270e5855f08f5de244ec8bc10ba
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jun 28 15:36:55 2011 -0400
- Start using Drift_16 icon
- also, update resource detail tabs to use subsystem icon paths under CoreGUI
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index d0ec4ee..858e0c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -163,7 +163,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
tabs.add(summaryTab);
inventoryTab = new TwoLevelTab(getTabSet().extendLocatorId("Inventory"), new ViewName("Inventory", MSG
- .view_tabs_common_inventory()), "/images/icons/Inventory_grey_16.png");
+ .view_tabs_common_inventory()), "subsystems/inventory/Inventory_grey_16.png");
inventoryChildren = new SubTab(inventoryTab.extendLocatorId("Children"), new ViewName("Children", MSG
.view_tabs_common_child_resources()), null);
inventoryChildHistory = new SubTab(inventoryTab.extendLocatorId("ChildHist"), new ViewName("ChildHistory", MSG
@@ -181,7 +181,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
tabs.add(inventoryTab);
alertsTab = new TwoLevelTab(getTabSet().extendLocatorId("Alerts"), new ViewName("Alerts", MSG
- .view_tabs_common_alerts()), "/images/icons/Alert_grey_16.png");
+ .view_tabs_common_alerts()), "subsystems/alert/Alerts_16.png");
this.alertHistory = new SubTab(alertsTab.extendLocatorId("History"), new ViewName("History", MSG
.view_tabs_common_history()), null);
this.alertDef = new SubTab(alertsTab.extendLocatorId("Definitions"), new ViewName("Definitions", MSG
@@ -190,7 +190,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
tabs.add(alertsTab);
monitoringTab = new TwoLevelTab(getTabSet().extendLocatorId("Monitoring"), new ViewName("Monitoring", MSG
- .view_tabs_common_monitoring()), "/images/icons/Monitor_grey_16.png");
+ .view_tabs_common_monitoring()), "subsystems/monitor/Monitor_grey_16.png");
monitorGraphs = new SubTab(monitoringTab.extendLocatorId("Graphs"), new ViewName("Graphs", MSG
.view_tabs_common_graphs()), null);
monitorTables = new SubTab(monitoringTab.extendLocatorId("Tables"), new ViewName("Tables", MSG
@@ -208,14 +208,14 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
tabs.add(monitoringTab);
eventsTab = new TwoLevelTab(getTabSet().extendLocatorId("Events"), new ViewName("Events", MSG
- .view_tabs_common_events()), "/images/icons/Events_grey_16.png");
+ .view_tabs_common_events()), "subsystems/event/Events_grey_16.png");
this.eventHistory = new SubTab(eventsTab.extendLocatorId("History"), new ViewName("History", MSG
.view_tabs_common_history()), null);
eventsTab.registerSubTabs(eventHistory);
tabs.add(eventsTab);
operationsTab = new TwoLevelTab(getTabSet().extendLocatorId(Tab.OPERATIONS), new ViewName(Tab.OPERATIONS, MSG
- .view_tabs_common_operations()), "/images/icons/Operation_grey_16.png");
+ .view_tabs_common_operations()), "subsystems/control/Operation_grey_16.png");
this.operationsSchedules = new SubTab(operationsTab.extendLocatorId(OperationsSubTab.SCHEDULES), new ViewName(
OperationsSubTab.SCHEDULES, MSG.view_tabs_common_schedules()), null);
this.operationsHistory = new SubTab(operationsTab.extendLocatorId(OperationsSubTab.HISTORY), new ViewName(
@@ -224,7 +224,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
tabs.add(operationsTab);
configurationTab = new TwoLevelTab(getTabSet().extendLocatorId(Tab.CONFIGURATION), new ViewName(
- Tab.CONFIGURATION, MSG.view_tabs_common_configuration()), "/images/icons/Configure_grey_16.png");
+ Tab.CONFIGURATION, MSG.view_tabs_common_configuration()), "subsystems/configure/Configure_grey_16.png");
this.configCurrent = new SubTab(configurationTab.extendLocatorId(ConfigurationSubTab.CURRENT), new ViewName(
ConfigurationSubTab.CURRENT, MSG.view_tabs_common_current()), null);
this.configHistory = new SubTab(configurationTab.extendLocatorId(ConfigurationSubTab.HISTORY), new ViewName(
@@ -233,7 +233,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
tabs.add(configurationTab);
driftTab = new TwoLevelTab(getTabSet().extendLocatorId("Drift"), new ViewName("Drift", MSG
- .view_tabs_common_drift()), "/images/icons/Configure_grey_16.png");
+ .view_tabs_common_drift()), "subsystems/drift/Drift_16.png");
this.driftHistory = new SubTab(driftTab.extendLocatorId("History"), new ViewName("History", MSG
.view_tabs_common_history()), null);
this.driftConfig = new SubTab(driftTab.extendLocatorId("Config"), new ViewName("Config", MSG
@@ -242,7 +242,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
tabs.add(driftTab);
contentTab = new TwoLevelTab(getTabSet().extendLocatorId("Content"), new ViewName("Content", MSG
- .view_tabs_common_content()), "/images/icons/Content_grey_16.png");
+ .view_tabs_common_content()), "subsystems/content/Content_grey_16.png");
this.contentDeployed = new SubTab(contentTab.extendLocatorId("Deployed"), new ViewName("Deployed", MSG
.view_tabs_common_deployed()), null);
this.contentNew = new SubTab(contentTab.extendLocatorId("New"),
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
index 8bd4960..3823ebe 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
@@ -144,7 +144,7 @@ public class ReportTopView extends AbstractSectionedLeftNavigationView {
});
NavigationItem recentDriftsItem = new NavigationItem(DriftHistoryView.SUBSYSTEM_VIEW_ID,
- "subsystems/configure/Configure_16.png", new ViewFactory() {
+ "subsystems/drift/Drift_16.png", new ViewFactory() {
public Canvas createView() {
return new SubsystemResourceDriftView(
extendLocatorId(DriftHistoryView.SUBSYSTEM_VIEW_ID.getName()), getGlobalPermissions().contains(
commit 8fccc25601a7cf529e2245b189792d612b17fefe
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jun 28 15:23:38 2011 -0400
Fix dev mode issue by ensuring a String value for a record property.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
index d5e0f1c..fe592a9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
@@ -124,6 +124,7 @@ public class DriftDataSource extends RPCDataSource<Drift, DriftCriteria> {
pathField.setWidth("35%");
resourceNameField.setWidth("25%");
ancestryField.setWidth("40%");
+
} else {
ctimeField.setWidth(200);
pathField.setWidth("*");
@@ -270,7 +271,7 @@ public class DriftDataSource extends RPCDataSource<Drift, DriftCriteria> {
ListGridRecord record = new ListGridRecord();
record.setAttribute("id", from.getId());
record.setAttribute("ctime", new Date(from.getCtime()));
- record.setAttribute("category", from.getCategory());
+ record.setAttribute("category", from.getCategory().name());
record.setAttribute("path", from.getPath());
DriftChangeSet changeSet = from.getChangeSet();
commit fd2978a0d3055264f6c417a65c7498cd9411cafe
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jun 28 15:22:31 2011 -0400
Add serialization to [Drift]Headers so it can be passed around as needed.
diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java b/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java
index acfdaf1..39fe8d9 100644
--- a/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java
+++ b/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java
@@ -1,9 +1,12 @@
package org.rhq.common.drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
+import java.io.Serializable;
+
import org.rhq.core.domain.drift.DriftChangeSetCategory;
-public class Headers {
+public class Headers implements Serializable {
+
+ private static final long serialVersionUID = 1L;
private String driftConfigurationName;
12 years, 10 months