[rhq] Branch 'mazz/test-rhq-on-as7' - .classpath modules/enterprise
by mazz
.classpath | 6
modules/enterprise/gui/gwt-installer-war/pom.xml | 50 +++++
modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java | 2
modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/client/gwt/InstallerGWTService.java | 2
modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/server/InstallerGWTServiceImpl.java | 40 ----
modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/server/service/ManagementService.java | 90 ++++++++++
modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java | 58 ++++++
modules/enterprise/gui/gwt-installer-war/src/main/webapp/WEB-INF/classes/META-INF/services/org.jboss.msc.service.ServiceActivator | 1
8 files changed, 206 insertions(+), 43 deletions(-)
New commits:
commit d9c8d2fc0a0da50be046c95540c8996622b4e534
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 13 18:13:05 2012 -0400
this illustrates how we can have a war obtain a co-located ModelController management client without going through a remote connector.
the getAppServerVersion method doesn't work correctly yet, but that is only because the ModelNode operation is incorrectly formed. But this is showing
the ability to successfully send management API requests to the app server.
diff --git a/.classpath b/.classpath
index 96bb406..e541e4f 100644
--- a/.classpath
+++ b/.classpath
@@ -287,6 +287,12 @@
<classpathentry exported="true" kind="var" path="M2_REPO/com/googlecode/java-diff-utils/diffutils/1.2.1/diffutils-1.2.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/com/google/code/morphia/morphia/0.99/morphia-0.99.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/spec/javax/servlet/jboss-servlet-api_3.0_spec/1.0.1.Final/jboss-servlet-api_3.0_spec-1.0.1.Final.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/msc/jboss-msc/1.0.2.GA/jboss-msc-1.0.2.GA.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/jboss-dmr/1.1.1.Final/jboss-dmr-1.1.1.Final.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/as/jboss-as-naming/7.1.1.Final/jboss-as-naming-7.1.1.Final.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/as/jboss-as-server/7.1.1.Final/jboss-as-server-7.1.1.Final.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/as/jboss-as-controller/7.1.1.Final/jboss-as-controller-7.1.1.Final.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/as/jboss-as-controller-client/7.1.1.Final/jboss-as-controller-client-7.1.1.Final.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/resteasy/resteasy-links/2.3.3.Final/resteasy-links-2.3.3.Final.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/resteasy/resteasy-jaxrs/2.3.3.Final/resteasy-jaxrs-2.3.3.Final.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/resteasy/resteasy-jackson-provider/2.3.3.Final/resteasy-jackson-provider-2.3.3.Final.jar"/>
diff --git a/modules/enterprise/gui/gwt-installer-war/pom.xml b/modules/enterprise/gui/gwt-installer-war/pom.xml
index de60430..5185578 100644
--- a/modules/enterprise/gui/gwt-installer-war/pom.xml
+++ b/modules/enterprise/gui/gwt-installer-war/pom.xml
@@ -21,6 +21,9 @@
<!-- dependency versions -->
<gwt.version>2.4.0</gwt.version>
<smartgwt.version>3.0</smartgwt.version>
+ <jboss.as.version>7.1.1.Final</jboss.as.version> <!-- our AS7 container -->
+ <jboss.msc.version>1.0.2.GA</jboss.msc.version> <!-- this ships with our AS7 container -->
+ <jboss.dmr.version>1.1.1.Final</jboss.dmr.version> <!-- this ships with our AS7 container -->
<installerGuiParams />
<installerGuiRunTarget>'http://localhost:7080/rhq-gwt-installer/index.html${installerGuiParams}'</installerGuiRunTarget>
@@ -34,7 +37,8 @@
<gwt.draftCompile>false</gwt.draftCompile>
<gwt.soyc>false</gwt.soyc>
<gwt.style>PRETTY</gwt.style>
- <gwt.locale>en,de,ja,pt,zh,ru,cs</gwt.locale>
+ <!-- <gwt.locale>en,de,ja,pt,zh,ru,cs</gwt.locale> -->
+ <gwt.locale>en</gwt.locale>
<gwt.fallback.locale>en</gwt.fallback.locale>
<enable-tags>true</enable-tags>
@@ -93,6 +97,49 @@
<scope>provided</scope> <!-- provided by AS7 -->
</dependency>
+ <!-- we need these so we can have our own service to provide a co-located management client -->
+ <dependency>
+ <groupId>org.jboss.msc</groupId>
+ <artifactId>jboss-msc</artifactId>
+ <version>${jboss.msc.version}</version>
+ <scope>provided</scope> <!-- provided by AS7 -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-dmr</artifactId>
+ <version>${jboss.dmr.version}</version>
+ <scope>provided</scope> <!-- provided by AS7 -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-naming</artifactId>
+ <version>${jboss.as.version}</version>
+ <scope>provided</scope> <!-- provided by AS7 -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-server</artifactId>
+ <version>${jboss.as.version}</version>
+ <scope>provided</scope> <!-- provided by AS7 -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-controller</artifactId>
+ <version>${jboss.as.version}</version>
+ <scope>provided</scope> <!-- provided by AS7 -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-controller-client</artifactId>
+ <version>${jboss.as.version}</version>
+ <scope>provided</scope> <!-- provided by AS7 -->
+ </dependency>
+
</dependencies>
<build>
@@ -176,6 +223,7 @@
</manifest>
<manifestEntries>
<Build-Number>${buildNumber}</Build-Number>
+ <Dependencies>org.jboss.msc,org.jboss.dmr,org.jboss.as.controller-client,org.jboss.as.controller,org.jboss.as.server,org.jboss.as.naming</Dependencies>
</manifestEntries>
</archive>
<webResources>
diff --git a/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java b/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java
index 32de38d..914d9ad 100644
--- a/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java
+++ b/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java
@@ -45,7 +45,7 @@ public class Installer implements EntryPoint {
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
InstallerGWTServiceAsync rpc = InstallerGWTServiceAsync.Util.getInstance();
- rpc.testMe(new AsyncCallback<String>() {
+ rpc.getAppServerVersion(new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
diff --git a/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/client/gwt/InstallerGWTService.java b/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/client/gwt/InstallerGWTService.java
index 10fd864..c46a15e 100644
--- a/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/client/gwt/InstallerGWTService.java
+++ b/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/client/gwt/InstallerGWTService.java
@@ -25,6 +25,6 @@ import com.google.gwt.user.client.rpc.RemoteService;
*/
public interface InstallerGWTService extends RemoteService {
- String testMe();
+ String getAppServerVersion();
}
diff --git a/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/server/InstallerGWTServiceImpl.java b/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/server/InstallerGWTServiceImpl.java
deleted file mode 100644
index 58acd2f..0000000
--- a/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/server/InstallerGWTServiceImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2012 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.gui.installer.server;
-
-import javax.servlet.annotation.WebServlet;
-
-import com.google.gwt.user.server.rpc.RemoteServiceServlet;
-
-import org.rhq.enterprise.gui.installer.client.gwt.InstallerGWTService;
-
-/**
- * @author John Mazzitelli
- */
-@WebServlet(value = "/org.rhq.enterprise.gui.installer.Installer/InstallerGWTService")
-public class InstallerGWTServiceImpl extends RemoteServiceServlet implements InstallerGWTService {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public String testMe() {
- return "foo";
- }
-
-}
diff --git a/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/server/service/ManagementService.java b/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/server/service/ManagementService.java
new file mode 100644
index 0000000..dcd1ad9
--- /dev/null
+++ b/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/server/service/ManagementService.java
@@ -0,0 +1,90 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 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.gui.installer.server.service;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.jboss.as.controller.ModelController;
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.server.Services;
+import org.jboss.msc.service.Service;
+import org.jboss.msc.service.ServiceActivator;
+import org.jboss.msc.service.ServiceActivatorContext;
+import org.jboss.msc.service.ServiceName;
+import org.jboss.msc.service.ServiceRegistryException;
+import org.jboss.msc.service.StartContext;
+import org.jboss.msc.service.StartException;
+import org.jboss.msc.service.StopContext;
+import org.jboss.msc.value.InjectedValue;
+
+/**
+ * This will provide our co-located management service.
+ * This is useful because it helps us avoid performing any management
+ * over a remote connector. Since we know we are running co-located
+ * in the same app server container that we want to manage, this
+ * service will provide us with a management client that does not go
+ * over a remote connector to talk to our app server container.
+ *
+ * @author John Mazzitelli
+ */
+public class ManagementService implements ServiceActivator {
+
+ private static volatile ModelController controller;
+ private static volatile ExecutorService executor = Executors.newFixedThreadPool(1);
+
+ public static ModelControllerClient getClient() {
+ return controller.createClient(executor);
+ }
+
+ @Override
+ public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
+ final GetModelControllerService service = new GetModelControllerService();
+ context
+ .getServiceTarget()
+ .addService(ServiceName.of("rhq", "installer", "management", "client", "getter"), service)
+ .addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.modelControllerValue)
+ .install();
+ }
+
+ private class GetModelControllerService implements Service<Void> {
+ private InjectedValue<ModelController> modelControllerValue = new InjectedValue<ModelController>();
+
+ @Override
+ public Void getValue() throws IllegalStateException, IllegalArgumentException {
+ return null;
+ }
+
+ @Override
+ public void start(StartContext context) throws StartException {
+ ManagementService.controller = modelControllerValue.getValue();
+ }
+
+ @Override
+ public void stop(StopContext context) {
+ try {
+ ManagementService.executor.shutdownNow();
+ } finally {
+ ManagementService.executor = null;
+ ManagementService.controller = null;
+ }
+ }
+
+ }
+}
diff --git a/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java b/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
new file mode 100644
index 0000000..d232c29
--- /dev/null
+++ b/modules/enterprise/gui/gwt-installer-war/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
@@ -0,0 +1,58 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 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.gui.installer.server.servlet;
+
+import javax.servlet.annotation.WebServlet;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.dmr.ModelNode;
+
+import org.rhq.enterprise.gui.installer.client.gwt.InstallerGWTService;
+import org.rhq.enterprise.gui.installer.server.service.ManagementService;
+
+/**
+ * @author John Mazzitelli
+ */
+@WebServlet(value = "/org.rhq.enterprise.gui.installer.Installer/InstallerGWTService")
+public class InstallerGWTServiceImpl extends RemoteServiceServlet implements InstallerGWTService {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getAppServerVersion() {
+ ModelControllerClient client = ManagementService.getClient();
+ ModelNode op = new ModelNode();
+ op.get("operation").set("read-attribute");
+
+ String versionString;
+
+ try {
+ ModelNode results = client.execute(op);
+ ModelNode version = results.get("result");
+ versionString = version.asString();
+ } catch (Exception e) {
+ versionString = e.toString();
+ }
+
+ return versionString;
+ }
+
+}
diff --git a/modules/enterprise/gui/gwt-installer-war/src/main/webapp/WEB-INF/classes/META-INF/services/org.jboss.msc.service.ServiceActivator b/modules/enterprise/gui/gwt-installer-war/src/main/webapp/WEB-INF/classes/META-INF/services/org.jboss.msc.service.ServiceActivator
new file mode 100644
index 0000000..c64cc21
--- /dev/null
+++ b/modules/enterprise/gui/gwt-installer-war/src/main/webapp/WEB-INF/classes/META-INF/services/org.jboss.msc.service.ServiceActivator
@@ -0,0 +1 @@
+org.rhq.enterprise.gui.installer.server.service.ManagementService
\ No newline at end of file
11 years, 10 months
[rhq] modules/core
by Jay Shaughnessy
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ServerStartScriptDiscoveryUtility.java | 13 ++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
New commits:
commit edb9cf72684d5f5cccc9cf5c0c0f068f17042ea3
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jul 13 14:49:53 2012 -0400
Add some null/empty string protection, even though the string really should
never be empty.
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ServerStartScriptDiscoveryUtility.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ServerStartScriptDiscoveryUtility.java
index df8ac21..4476173 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ServerStartScriptDiscoveryUtility.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ServerStartScriptDiscoveryUtility.java
@@ -290,12 +290,21 @@ public class ServerStartScriptDiscoveryUtility {
}
int startScriptIndex;
- // Advance past any shell (e.g. /bin/sh or cmd.exe) options.
+ // Advance past any shell (e.g. /bin/sh or cmd.exe) options or empty args
for (startScriptIndex = 1; (startScriptIndex < serverParentProcessCommandLine.length); ++startScriptIndex) {
- if (serverParentProcessCommandLine[startScriptIndex].charAt(0) != OPTION_PREFIX) {
+ // the arg should not be null or empty, but we've seen empty args from Sigar...
+ String arg = serverParentProcessCommandLine[startScriptIndex];
+
+ if (arg != null && !arg.isEmpty() && arg.charAt(0) != OPTION_PREFIX) {
break;
}
}
+
+ // for whatever unanticipated reason, we advanced past all of the args
+ if (startScriptIndex == serverParentProcessCommandLine.length) {
+ return null;
+ }
+
String possibleStartScript = serverParentProcessCommandLine[startScriptIndex];
return (isScript(possibleStartScript)) ? startScriptIndex : null;
}
11 years, 10 months
[rhq] 2 commits - modules/enterprise
by lkrejci
modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java | 19 ++
modules/enterprise/scripting/api/src/main/java/org/rhq/scripting/ScriptEngineProvider.java | 6
modules/enterprise/scripting/javascript/src/main/java/org/rhq/scripting/javascript/JsEngineProvider.java | 5
modules/enterprise/scripting/python/src/main/java/org/rhq/scripting/python/PythonScriptEngineInitializer.java | 4
modules/enterprise/scripting/python/src/main/java/org/rhq/scripting/python/PythonScriptEngineProvider.java | 5
modules/enterprise/server/container/src/main/bin-resources/bin/rhq-server.sh | 8
modules/enterprise/server/container/src/main/bin-resources/bin/wrapper/rhq-server-wrapper.conf | 3
modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliSender.java | 86 ++++++++--
8 files changed, 116 insertions(+), 20 deletions(-)
New commits:
commit 6e4d8cd596e81674ec3eacc625be9f3eb3d04f2a
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Jul 13 16:56:55 2012 +0200
Making the package scanning of the python language support configurable
through additional RHQ-specific system variables.
Update the RHQ server startup scripts to configure the python's package
scanning so that it properly discovers domain jar and its packages and
classes. This is then used to pre-import domain classes into the script
context for the alert scripts.
diff --git a/modules/enterprise/scripting/python/src/main/java/org/rhq/scripting/python/PythonScriptEngineInitializer.java b/modules/enterprise/scripting/python/src/main/java/org/rhq/scripting/python/PythonScriptEngineInitializer.java
index e868204..3a030f4 100644
--- a/modules/enterprise/scripting/python/src/main/java/org/rhq/scripting/python/PythonScriptEngineInitializer.java
+++ b/modules/enterprise/scripting/python/src/main/java/org/rhq/scripting/python/PythonScriptEngineInitializer.java
@@ -51,8 +51,8 @@ public class PythonScriptEngineInitializer implements ScriptEngineInitializer {
static {
Properties props = new Properties();
- props.put("python.packages.paths", "java.class.path,sun.boot.class.path");
- props.put("python.packages.directories", "java.ext.dirs");
+ props.put("python.packages.paths", "rhq.python.additional.classpath,java.class.path,sun.boot.class.path");
+ props.put("python.packages.directories", "rhq.python.additional.package.dirs,java.ext.dirs");
props.put("python.cachedir.skip", false);
PythonInterpreter.initialize(System.getProperties(), props, null);
}
diff --git a/modules/enterprise/server/container/src/main/bin-resources/bin/rhq-server.sh b/modules/enterprise/server/container/src/main/bin-resources/bin/rhq-server.sh
index 1a38161..f481201 100644
--- a/modules/enterprise/server/container/src/main/bin-resources/bin/rhq-server.sh
+++ b/modules/enterprise/server/container/src/main/bin-resources/bin/rhq-server.sh
@@ -284,6 +284,12 @@ if $JAVA -version 2>&1 | grep "IBM J9" >/dev/null 2>&1; then
fi
fi
+#-----------------------------------------------------------------------
+# Setup the Python package scanning in case we have Python scripting available
+#-----------------------------------------------------------------------
+JYTHON_CACHE_DIR="$RHQ_SERVER_HOME/jbossas/server/default/data/jython.cachedir"
+PYTHON_ADDITIONAL_CLASSPATH="$RHQ_SERVER_HOME/jbossas/server/default/deploy/rhq.ear/rhq-core-domain-ejb3.jar/./"
+
# ----------------------------------------------------------------------
# Prepare the VM command line options to be passed in
# ----------------------------------------------------------------------
@@ -293,7 +299,7 @@ if [ -z "$RHQ_SERVER_JAVA_OPTS" ]; then
fi
# Add the JVM opts that we always want to specify, whether or not the user set RHQ_SERVER_JAVA_OPTS.
# Note that the double equals for the policy file specification IS INTENTIONAL
-RHQ_SERVER_JAVA_OPTS="-Dapp.name=rhq-server $RHQ_SERVER_JAVA_OPTS -Djava.awt.headless=true -Djboss.platform.mbeanserver -Dsun.lang.ClassLoader.allowArraySyntax=true -Djava.util.logging.config.file=$RHQ_SERVER_HOME/jbossas/server/default/conf/logging.properties -Djava.security.manager -Djava.security.policy==$RHQ_SERVER_HOME/bin/rhq-server.security-policy"
+RHQ_SERVER_JAVA_OPTS="-Dapp.name=rhq-server $RHQ_SERVER_JAVA_OPTS -Djava.awt.headless=true -Djboss.platform.mbeanserver -Dsun.lang.ClassLoader.allowArraySyntax=true -Djava.util.logging.config.file=$RHQ_SERVER_HOME/jbossas/server/default/conf/logging.properties -Djava.security.manager -Djava.security.policy==$RHQ_SERVER_HOME/bin/rhq-server.security-policy -Dpython.cachedir=$JYTHON_CACHE_DIR -Drhq.python.additional.classpath=$PYTHON_ADDITIONAL_CLASSPATH"
debug_msg "RHQ_SERVER_JAVA_OPTS: $RHQ_SERVER_JAVA_OPTS"
debug_msg "RHQ_SERVER_ADDITIONAL_JAVA_OPTS: $RHQ_SERVER_ADDITIONAL_JAVA_OPTS"
diff --git a/modules/enterprise/server/container/src/main/bin-resources/bin/wrapper/rhq-server-wrapper.conf b/modules/enterprise/server/container/src/main/bin-resources/bin/wrapper/rhq-server-wrapper.conf
index b4f178b..cf30c5a 100644
--- a/modules/enterprise/server/container/src/main/bin-resources/bin/wrapper/rhq-server-wrapper.conf
+++ b/modules/enterprise/server/container/src/main/bin-resources/bin/wrapper/rhq-server-wrapper.conf
@@ -71,6 +71,9 @@ wrapper.java.additional.11=-Dsun.lang.ClassLoader.allowArraySyntax=true
wrapper.java.additional.12=-Djava.security.manager
# the double equals for the policy file specification IS INTENTIONAL
wrapper.java.additional.13="-Djava.security.policy==%RHQ_SERVER_HOME%/bin/rhq-server.security-policy"
+#Setup up a cache dir for jython in case python script support was available in the server
+wrapper.java.additional.14="-Dpython.cachedir=%RHQ_SERVER_HOME%/jbossas/server/default/data/jython.cachedir"
+wrapper.java.additional.15="-Drhq.python.additional.classpath=%RHQ_SERVER_HOME%/jbossas/server/default/deploy/rhq.ear/rhq-core-domain-ejb3.jar/./"
# We want to make sure the Server starts in the JBossAS bin directory
wrapper.working.dir=%RHQ_SERVER_HOME%/jbossas/bin
commit 33db4718581ca09afc259a8e73310ce65a573025
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Jul 13 16:54:14 2012 +0200
[BZ 839780] - The scriptengine providers now can tell the file extension of
the scripts they support. The alert-cli plugin then picks the correct
script engine implementation for a script based on its file name extension.
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java
index 9887958..6bba114 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java
@@ -114,6 +114,25 @@ public class ScriptEngineFactory {
return new HashSet<String>(KNOWN_PROVIDERS.keySet());
}
+ public static String getLanguageByScriptFileExtension(String fileExtension) {
+ for (ScriptEngineProvider p : KNOWN_PROVIDERS.values()) {
+ if (fileExtension.equals(p.getScriptFileExtension())) {
+ return p.getSupportedLanguage();
+ }
+ }
+
+ return null;
+ }
+
+ public static String getFileExtensionForLanguage(String language) {
+ ScriptEngineProvider provider = KNOWN_PROVIDERS.get(language);
+ if (provider == null) {
+ return null;
+ }
+
+ return provider.getScriptFileExtension();
+ }
+
/**
* Initializes the script engine for given language.
*
diff --git a/modules/enterprise/scripting/api/src/main/java/org/rhq/scripting/ScriptEngineProvider.java b/modules/enterprise/scripting/api/src/main/java/org/rhq/scripting/ScriptEngineProvider.java
index 067ed90..f5b619e 100644
--- a/modules/enterprise/scripting/api/src/main/java/org/rhq/scripting/ScriptEngineProvider.java
+++ b/modules/enterprise/scripting/api/src/main/java/org/rhq/scripting/ScriptEngineProvider.java
@@ -47,6 +47,12 @@ public interface ScriptEngineProvider {
String getSupportedLanguage();
/**
+ * @return the file extension of files written in the language supported by this provider.
+ * The returned string is the extension without the leading dot.
+ */
+ String getScriptFileExtension();
+
+ /**
* @return an implementation of {@link ScriptEngineInitializer} that can instantiate
* and initialize a script engine for the supported language for use with RHQ.
*/
diff --git a/modules/enterprise/scripting/javascript/src/main/java/org/rhq/scripting/javascript/JsEngineProvider.java b/modules/enterprise/scripting/javascript/src/main/java/org/rhq/scripting/javascript/JsEngineProvider.java
index 02d54eb..63c5023 100644
--- a/modules/enterprise/scripting/javascript/src/main/java/org/rhq/scripting/javascript/JsEngineProvider.java
+++ b/modules/enterprise/scripting/javascript/src/main/java/org/rhq/scripting/javascript/JsEngineProvider.java
@@ -36,6 +36,11 @@ public class JsEngineProvider implements ScriptEngineProvider {
}
@Override
+ public String getScriptFileExtension() {
+ return "js";
+ }
+
+ @Override
public ScriptEngineInitializer getInitializer() {
return new JsEngineInitializer();
}
diff --git a/modules/enterprise/scripting/python/src/main/java/org/rhq/scripting/python/PythonScriptEngineProvider.java b/modules/enterprise/scripting/python/src/main/java/org/rhq/scripting/python/PythonScriptEngineProvider.java
index c0bfcac..2d71f85 100644
--- a/modules/enterprise/scripting/python/src/main/java/org/rhq/scripting/python/PythonScriptEngineProvider.java
+++ b/modules/enterprise/scripting/python/src/main/java/org/rhq/scripting/python/PythonScriptEngineProvider.java
@@ -36,6 +36,11 @@ public class PythonScriptEngineProvider implements ScriptEngineProvider {
}
@Override
+ public String getScriptFileExtension() {
+ return "py";
+ }
+
+ @Override
public ScriptEngineInitializer getInitializer() {
return new PythonScriptEngineInitializer();
}
diff --git a/modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliSender.java b/modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliSender.java
index 0bca2fa..5eb9360 100644
--- a/modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliSender.java
+++ b/modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliSender.java
@@ -30,8 +30,11 @@ import java.io.PipedOutputStream;
import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.util.ArrayDeque;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Queue;
import javax.script.ScriptEngine;
@@ -71,8 +74,6 @@ import org.rhq.scripting.ScriptSourceProviderFactory;
*/
public class CliSender extends AlertSender<CliComponent> {
- private static final String ENGINE_NAME = "javascript";
-
private static final int MAX_RESULT_SIZE = 4000;
public static final String PROP_PACKAGE_ID = "packageId";
@@ -91,7 +92,7 @@ public class CliSender extends AlertSender<CliComponent> {
//no more than 10 concurrently running CLI notifications..
//is that enough?
private static final int MAX_SCRIPT_ENGINES = 10;
- private static Queue<ScriptEngine> SCRIPT_ENGINES = new ArrayDeque<ScriptEngine>(MAX_SCRIPT_ENGINES);
+ private static Map<String, Queue<ScriptEngine>> SCRIPT_ENGINES = new HashMap<String, Queue<ScriptEngine>>();
private static int ENGINES_IN_USE = 0;
/**
@@ -108,12 +109,18 @@ public class CliSender extends AlertSender<CliComponent> {
public Throwable throwable;
}
+ private static class BitsAndFileExtension {
+ InputStream packageBits;
+ String scriptFileExtension;
+ }
+
public SenderResult send(Alert alert) {
SenderResult result = new SenderResult();
BufferedReader reader = null;
ScriptEngine engine = null;
Subject subjectWithSession = null;
final SessionManager sessionManager = SessionManager.getInstance();
+ String language = null;
try {
final Config config = getConfig();
@@ -127,9 +134,25 @@ public class CliSender extends AlertSender<CliComponent> {
ByteArrayOutputStream scriptOutputStream = new ByteArrayOutputStream();
PrintWriter scriptOut = new PrintWriter(scriptOutputStream);
- engine = getScriptEngine(alert, scriptOut, config);
+ BitsAndFileExtension packageData = getPackageBits(config.packageId, config.repoId);
+
+ InputStream packageBits = packageData.packageBits;
+ String scriptFileExtension = packageData.scriptFileExtension;
+ language = ScriptEngineFactory.getLanguageByScriptFileExtension(scriptFileExtension);
+
+ if (language == null) {
+ ArrayList<String> supportedExtensions = new ArrayList<String>();
+ for (String lang : ScriptEngineFactory.getSupportedLanguages()) {
+ supportedExtensions.add(ScriptEngineFactory.getFileExtensionForLanguage(lang));
+ }
+
+ throw new IllegalArgumentException(
+ "Could not determine the script engine to use based on the script file extension '"
+ + scriptFileExtension + "'. Only the following extensions are currently supported: "
+ + supportedExtensions);
+ }
- InputStream packageBits = getPackageBits(config.packageId, config.repoId);
+ engine = getScriptEngine(alert, scriptOut, config, language);
reader = new BufferedReader(new InputStreamReader(packageBits));
@@ -166,7 +189,7 @@ public class CliSender extends AlertSender<CliComponent> {
exceptionHolder.scriptException);
//make things pretty for the UI
- ScriptEngineInitializer initializer = ScriptEngineFactory.getInitializer(ENGINE_NAME);
+ ScriptEngineInitializer initializer = ScriptEngineFactory.getInitializer(language);
String message = initializer.extractUserFriendlyErrorMessage(exceptionHolder.scriptException);
int col = exceptionHolder.scriptException.getColumnNumber();
int line = exceptionHolder.scriptException.getLineNumber();
@@ -203,7 +226,7 @@ public class CliSender extends AlertSender<CliComponent> {
sessionManager.invalidate(subjectWithSession.getSessionId());
}
if (engine != null) {
- returnEngine(engine);
+ returnEngine(engine, language);
}
if (reader != null) {
@@ -264,7 +287,8 @@ public class CliSender extends AlertSender<CliComponent> {
return results;
}
- private static ScriptEngine getScriptEngine(Alert alert, PrintWriter output, Config config) throws ScriptException,
+ private static ScriptEngine getScriptEngine(Alert alert, PrintWriter output, Config config, String language)
+ throws ScriptException,
IOException, InterruptedException {
Subject user = config.subject;
@@ -273,14 +297,14 @@ public class CliSender extends AlertSender<CliComponent> {
StandardBindings bindings = new StandardBindings(output, client);
bindings.put("alert", alert);
- ScriptEngine engine = takeEngine(bindings);
+ ScriptEngine engine = takeEngine(bindings, language);
engine.getContext().setWriter(output);
engine.getContext().setErrorWriter(output);
return engine;
}
- private static InputStream getPackageBits(int packageId, int repoId) throws IOException {
+ private static BitsAndFileExtension getPackageBits(int packageId, int repoId) throws IOException {
final ContentSourceManagerLocal csm = LookupUtil.getContentSourceManager();
RepoManagerLocal rm = LookupUtil.getRepoManagerLocal();
final PackageVersion versionToUse = rm.getLatestPackageVersion(LookupUtil.getSubjectManager().getOverlord(),
@@ -293,8 +317,8 @@ public class CliSender extends AlertSender<CliComponent> {
+ " either doesn't exist at all or doesn't have any version. Can't execute a CLI script without a script to run.");
}
- PipedInputStream ret = new PipedInputStream();
- final PipedOutputStream out = new PipedOutputStream(ret);
+ PipedInputStream bits = new PipedInputStream();
+ final PipedOutputStream out = new PipedOutputStream(bits);
Thread reader = new Thread(new Runnable() {
public void run() {
@@ -320,6 +344,20 @@ public class CliSender extends AlertSender<CliComponent> {
reader.setDaemon(true);
reader.start();
+ BitsAndFileExtension ret = new BitsAndFileExtension();
+ ret.packageBits = bits;
+ String fileName = versionToUse.getFileName();
+ String extension = "";
+
+ if (fileName != null) {
+ int dotIdx = fileName.lastIndexOf('.');
+ if (dotIdx >= 0) {
+ extension = fileName.substring(dotIdx + 1);
+ }
+ }
+
+ ret.scriptFileExtension = extension;
+
return ret;
}
@@ -417,17 +455,24 @@ public class CliSender extends AlertSender<CliComponent> {
}
}
- private static ScriptEngine takeEngine(StandardBindings bindings) throws InterruptedException, ScriptException,
+ private static ScriptEngine takeEngine(StandardBindings bindings, String language) throws InterruptedException,
+ ScriptException,
IOException {
synchronized (SCRIPT_ENGINES) {
if (ENGINES_IN_USE >= MAX_SCRIPT_ENGINES) {
SCRIPT_ENGINES.wait();
}
- ScriptEngine engine = SCRIPT_ENGINES.poll();
+ Queue<ScriptEngine> q = SCRIPT_ENGINES.get(language);
+ if (q == null) {
+ q = new ArrayDeque<ScriptEngine>();
+ SCRIPT_ENGINES.put(language, q);
+ }
+
+ ScriptEngine engine = q.poll();
if (engine == null) {
- engine = ScriptEngineFactory.getSecuredScriptEngine(ENGINE_NAME,
+ engine = ScriptEngineFactory.getSecuredScriptEngine(language,
new PackageFinder(Collections.<File> emptyList()), bindings, new StandardScriptPermissions());
}
//TODO is this OK, or should we use a different classloader than the context classloader?
@@ -440,9 +485,16 @@ public class CliSender extends AlertSender<CliComponent> {
}
}
- private static void returnEngine(ScriptEngine engine) {
+ private static void returnEngine(ScriptEngine engine, String language) {
synchronized (SCRIPT_ENGINES) {
- SCRIPT_ENGINES.offer(engine);
+ Queue<ScriptEngine> q = SCRIPT_ENGINES.get(language);
+ if (q == null) {
+ //hmm... this is very strange and should not happen, because we should have initied the queue in the
+ //takeEngine() method...
+ q = new ArrayDeque<ScriptEngine>();
+ SCRIPT_ENGINES.put(language, q);
+ }
+ q.offer(engine);
--ENGINES_IN_USE;
SCRIPT_ENGINES.notify();
}
11 years, 10 months
[rhq] modules/enterprise
by Jiri Kremser
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java | 1 +
1 file changed, 1 insertion(+)
New commits:
commit 5f0388a7ba23c1f395892950c322e3d649840d2f
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri Jul 13 13:10:34 2012 +0200
[BZ 839720 - The alert notifications dialog initially shows wrong UI] This was caused by commit 1c7723b
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
index 9cf0850..c66b207 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
@@ -118,6 +118,7 @@ public class NewNotificationEditor extends LocatableDynamicForm {
notificationSenderSelectItem.setDisabled(false);
notificationSenderSelectItem.redraw();
+ notificationSenderSelectItem.setValue(result[0]);
switchToAlertSender(result[0]);
senderCanvasItem.show();
} else {
11 years, 10 months
[rhq] modules/enterprise
by lkrejci
modules/enterprise/scripting/javascript/pom.xml | 5 ++---
modules/enterprise/scripting/python/pom.xml | 4 ++--
2 files changed, 4 insertions(+), 5 deletions(-)
New commits:
commit f5bbb1ef7b8b7ae50086dac59ab36b61aeceb762
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Jul 13 11:29:40 2012 +0200
Fixing the dev profile of the lang support modules to copy the final
repackaged jars to the dev-container.
diff --git a/modules/enterprise/scripting/javascript/pom.xml b/modules/enterprise/scripting/javascript/pom.xml
index 06bed89..38ead44 100644
--- a/modules/enterprise/scripting/javascript/pom.xml
+++ b/modules/enterprise/scripting/javascript/pom.xml
@@ -86,7 +86,7 @@
<execution>
<id>deploy</id>
- <phase>compile</phase>
+ <phase>install</phase>
<configuration>
<tasks>
<mkdir dir="${rhq.deploymentDir}" />
@@ -94,8 +94,7 @@
location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
<echo>*** Updating
${deployment.file}...</echo>
- <jar destfile="${deployment.file}"
- basedir="${project.build.outputDirectory}" />
+ <copy tofile="${deployment.file}" file="${project.build.directory}/${project.build.finalName}.jar" />
</tasks>
</configuration>
<goals>
diff --git a/modules/enterprise/scripting/python/pom.xml b/modules/enterprise/scripting/python/pom.xml
index b657dd2..39d3895 100644
--- a/modules/enterprise/scripting/python/pom.xml
+++ b/modules/enterprise/scripting/python/pom.xml
@@ -85,14 +85,14 @@
<execution>
<id>deploy</id>
- <phase>compile</phase>
+ <phase>install</phase>
<configuration>
<tasks>
<mkdir dir="${rhq.deploymentDir}" />
<property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
<echo>*** Updating
${deployment.file}...</echo>
- <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ <copy tofile="${deployment.file}" file="${project.build.directory}/${project.build.finalName}.jar" />
</tasks>
</configuration>
<goals>
11 years, 10 months
[rhq] modules/core
by mike thompson
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionList.java | 2 ++
1 file changed, 2 insertions(+)
New commits:
commit 97c9424489cbb8cf65f44d83c06015ed4b0b7c32
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Thu Jul 12 15:49:38 2012 -0700
HotFix: The min/max fields on PropertyDefinitionList broke some other plugins. I didn't see this until I created new schema. This is a temp fix until real fix.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionList.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionList.java
index 92c8df6..1b1f248 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionList.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionList.java
@@ -48,8 +48,10 @@ import java.lang.Integer;
public class PropertyDefinitionList extends PropertyDefinition {
private static final long serialVersionUID = 1L;
+ @Transient
private int min = 0;
+ @Transient
private int max = Integer.MAX_VALUE;
@JoinColumn(name = "parent_list_definition_id")
11 years, 10 months
[rhq] Changes to 'mazz/test-rhq-on-as7'
by mazz
New branch 'mazz/test-rhq-on-as7' available with the following commits:
commit 6b88faf5aad4b79abc04589fefa53936f93b7176
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 12 18:14:16 2012 -0400
the start of a GWT installer. this builds and runs for AS7 only (it uses EE6)
11 years, 10 months
[rhq] Branch 'searchbar' - 63 commits - .classpath etc/eclipse-tools modules/core modules/enterprise modules/helpers modules/jopr modules/plugins pom.xml
by mike thompson
.classpath | 4
etc/eclipse-tools/maven/RHQ | 11
modules/core/arquillian-integration/archive/pom.xml | 6
modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginArchiveImpl.java | 28
modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginDescriptorContainer.java | 16
modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java | 76
modules/core/client-api/pom.xml | 426 +-
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java | 244 -
modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtilityTest.java | 322 -
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java | 8
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionLog.java | 22
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java | 40
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUtility.java | 334 +
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/drift/Filter.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/DuplicateExpressionTypeException.java | 38
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/InvalidExpressionException.java | 38
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationUtilityTest.java | 363 +
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java | 175
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java | 111
modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/SingleResourceDiscoveryComponent.java | 30
modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058ResourceComponent.java | 84
modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ834019ResourceComponent.java | 104
modules/core/plugin-container-itest/src/test/resources/arquillian.xml | 10
modules/core/plugin-container-itest/src/test/resources/single-metric-rhq-plugin.xml | 21
modules/core/plugin-container-itest/src/test/resources/two-metric-rhq-plugin.xml | 27
modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java | 18
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 5
modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java | 5
modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java | 26
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/FilterFileVisitorTest.java | 3
modules/enterprise/gui/coregui/pom.xml | 754 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/IconEnum.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/ServerPluginControlView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 28
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java | 96
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 47
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleTypeDropDownSelectItem.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDeploymentConfigStep.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleVersionStep.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 106
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SortedSelectItem.java | 96
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddDefinitionWizardInfoStep.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftPinTemplateWizardInfoStep.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertTemplateGWTService.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListDetailView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionExpressionBuilder.java | 34
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java | 25
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryInfoStep.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java | 36
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java | 13
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java | 2
modules/enterprise/server/jar/pom.xml | 2096 +++++-----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionLogManagerBean.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerLocal.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java | 13
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerLocal.java | 12
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 19
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerLocal.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java | 83
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/InvalidExpressionException.java | 38
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java | 14
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerLocal.java | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java | 27
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJob.java | 18
modules/enterprise/server/jar/src/main/resources/rest_templates/group.ftl | 11
modules/enterprise/server/jar/src/main/xsl/apiout2docbook.xsl | 3
modules/enterprise/server/jar/src/main/xsl/apiout2html.xsl | 3
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertConditionTest.java | 78
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java | 704 +++
modules/enterprise/server/xml-schemas/pom.xml | 448 +-
modules/helpers/rest-docs-generator/pom.xml | 5
modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java | 6
modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml | 46
modules/jopr/tools/jbas5-plugin-descriptor-gen/src/main/java/org/jboss/jopr/tool/jbas5/PluginDescriptorGenerator.java | 6
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java | 15
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java | 15
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java | 71
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java | 14
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/serviceBinding/ManagerComponent.java | 10
modules/plugins/jboss-as-7/pom.xml | 6
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebservicesComponent.java | 55
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 10
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/SecurityModuleOptionsTest.java | 319 -
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractJBossAS7PluginTest.java | 17
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java | 675 +++
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/ResourcesStandaloneServerTest.java | 2
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java | 5
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java | 2
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableDiscoveryComponent.java | 11
modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml | 1
modules/plugins/mysql/src/test/java/org/rhq/plugins/mysql/ComponentTest.java | 545 ++
modules/plugins/mysql/src/test/java/org/rhq/plugins/mysql/PluginTest.java | 41
modules/plugins/mysql/src/test/resources/log4j.xml | 35
modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleServerComponent.java | 12
modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml | 11
modules/plugins/perftest/pom.xml | 453 +-
modules/plugins/platform/src/main/java/org/rhq/plugins/platform/NetworkAdapterComponent.java | 203
pom.xml | 7
136 files changed, 6861 insertions(+), 3474 deletions(-)
New commits:
commit 392b34f4a04b640b19a093519d2762595c674f7f
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Thu Jul 5 13:48:44 2012 -0700
Trivial: clean up unused code.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
index 9d2d1a2..72c5290 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
@@ -47,7 +47,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceD
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.MetadataType;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypeLoadedCallback;
-import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
@@ -80,8 +79,6 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
protected void onDraw() {
super.onDraw();
- //createButtonBar();
-
refresh();
if (!this.resourcePermission.isConfigureWrite()) {
commit 0c36dc61d6246c34272ca9b4c9d5fc34602f21bc
Merge: 2fb2a50 cb5bd25
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Thu Jul 5 13:35:07 2012 -0700
Merge branch 'master' into searchbar
commit cb5bd253f36a04710b2906f89429d36b9f9a1b8a
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Thu Jul 5 12:26:50 2012 -0700
[BZ 815305] Min/max constraints on PropertyList not honored. Change IntegerItems to SpinnerItems on configuration screens making sure validations still work as SpinnerItem validations is little different than IntegerItems.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 9932499..4e188dd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -52,24 +52,8 @@ import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.ValuesManager;
import com.smartgwt.client.widgets.form.events.ItemChangedEvent;
import com.smartgwt.client.widgets.form.events.ItemChangedHandler;
-import com.smartgwt.client.widgets.form.fields.ButtonItem;
-import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.form.fields.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
-import com.smartgwt.client.widgets.form.fields.FloatItem;
-import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.IntegerItem;
-import com.smartgwt.client.widgets.form.fields.PasswordItem;
-import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
-import com.smartgwt.client.widgets.form.fields.SpacerItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-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.FocusEvent;
-import com.smartgwt.client.widgets.form.fields.events.FocusHandler;
+import com.smartgwt.client.widgets.form.fields.*;
+import com.smartgwt.client.widgets.form.fields.events.*;
import com.smartgwt.client.widgets.form.validator.CustomValidator;
import com.smartgwt.client.widgets.form.validator.FloatRangeValidator;
import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator;
@@ -134,6 +118,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableSectionStack
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+import sun.net.www.content.image.png;
/**
* A SmartGWT widget for editing an RHQ {@link Configuration} that conforms to a {@link ConfigurationDefinition}.
@@ -1031,13 +1016,13 @@ public class ConfigurationEditor extends LocatableVLayout {
toolStrip.setWidth100();
if (!propertyReadOnly) {
IButton addRowButton = new IButton();
- addRowButton.setIcon(Window.getImgURL("[SKIN]/actions/add.png"));
- addRowButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- displayMapEditor(summaryTable, null, propertyDefinitionList, propertyList,
- memberPropertyDefinitionMap, null, mapReadOnly);
- }
- });
+ addRowButton.setIcon(Window.getImgURL(ImageManager.getAddIcon()));
+ addRowButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ displayMapEditor(summaryTable, null, propertyDefinitionList, propertyList,
+ memberPropertyDefinitionMap, null, mapReadOnly);
+ }
+ });
toolStrip.addMember(addRowButton);
}
@@ -1341,15 +1326,10 @@ public class ConfigurationEditor extends LocatableVLayout {
valueItem = radioGroupItem;
break;
case INTEGER:
- // Ideally, we'd use SpinnerItems for INTEGER props, but unfortunately, as of version 2.4, SmartGWT
- // has a nasty bug where it does not fire ValueChangedEvents or ItemChangedEvents when the value of
- // a SpinnerItem changes...
- /*SpinnerItem spinnerItem = new SpinnerItem();
+ SpinnerItem spinnerItem = new SpinnerItem();
spinnerItem.setMin(Integer.MIN_VALUE);
spinnerItem.setMax(Integer.MAX_VALUE);
- // TODO: If an integer constraint is defined on the propdef, use that to set the min and max.
- valueItem = spinnerItem;*/
- valueItem = new IntegerItem();
+ valueItem = spinnerItem;
break;
case FLOAT:
case DOUBLE:
@@ -1378,6 +1358,25 @@ public class ConfigurationEditor extends LocatableVLayout {
}
}
});
+ // Since spinnerItems only fire ChangedEvent once the spinner buttons are pushed
+ // we add blur handler to pick up any changes to that field when leaving
+ if(valueItem instanceof SpinnerItem){
+ valueItem.addBlurHandler(new BlurHandler() {
+ @Override
+ public void onBlur(BlurEvent event) {
+ updatePropertySimpleValue(event.getItem(), event.getItem().getValue(), propertySimple,
+ propertyDefinitionSimple);
+ // Only fire a prop value change event if the prop's a top-level simple or a simple within a
+ // top-level map.
+ if (shouldFireEventOnPropertyValueChange(event.getItem(), propertyDefinitionSimple,
+ propertySimple)) {
+ boolean isValid = event.getItem().validate();
+ firePropertyChangedEvent(propertySimple, propertyDefinitionSimple, isValid);
+ }
+
+ }
+ });
+ }
}
}
commit 21ca86fc1c1be1d5c4108918d965b03119ec9895
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Jul 5 09:09:13 2012 -0400
[BZ 828938] fix typo and add thread identification.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
index e1883e4..0470d9b 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
@@ -700,13 +700,14 @@ public class PluginContainer {
rebootListener.reboot();
}
});
+ rebootThread.setName("Plugin Container Reboot Thread");
rebootThread.setDaemon(false);
rebootThread.start();
try {
rebootThread.join();
} catch (InterruptedException e) {
log.error("Interrupted while rebooting agent after one or more resource types "
- + " have been marked for deletion. You man need to manually reboot the agent/plugin container to purge "
+ + " have been marked for deletion. You may need to manually reboot the agent/plugin container to purge "
+ "stale types.");
}
}
commit b70072126da6810a1fc96d6e33cbd100c438e369
Author: Elias Ross <genman(a)noderunner.net>
Date: Wed Jul 4 14:19:46 2012 +0200
BZ 797356 - Allow to disable automatic table discovery per database
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java
index c8f8673..100e536 100644
--- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java
@@ -61,7 +61,7 @@ public class MySqlDatabaseDiscoveryComponent implements ResourceDiscoveryCompone
while (resultSet.next()) {
String databaseName = resultSet.getString(1);
- Configuration config = new Configuration();
+ Configuration config = context.getDefaultPluginConfiguration();
config.put(new PropertySimple("databaseName",databaseName));
DiscoveredResourceDetails details =
new DiscoveredResourceDetails(
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableDiscoveryComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableDiscoveryComponent.java
index 5b62118..4d7b354 100644
--- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableDiscoveryComponent.java
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableDiscoveryComponent.java
@@ -35,11 +35,12 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.database.DatabaseQueryUtility;
/**
- *
+ * Discovers MySQL tables.
* @author Steve Millidge (C2B2 Consulting Limited)
*/
public class MySqlTableDiscoveryComponent implements ResourceDiscoveryComponent {
+ private static final String TABLE_DISCOVERY = "tableDiscovery";
private Log log = LogFactory.getLog(this.getClass());
@Override
@@ -47,6 +48,14 @@ public class MySqlTableDiscoveryComponent implements ResourceDiscoveryComponent
HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
MySqlDatabaseComponent parent = (MySqlDatabaseComponent)rdc.getParentResourceComponent();
+ Configuration pconfig = rdc.getParentResourceContext().getPluginConfiguration();
+ // If the user has disabled table discovery on the parent, we don't autodiscover
+ // them, as we may hit temporary ones that go away any time soon again
+ // See BZ-797356
+ if (!Boolean.parseBoolean(pconfig.getSimpleValue(TABLE_DISCOVERY, "true"))) {
+ log.debug("table discovery disabled");
+ return set;
+ }
Connection conn = parent.getConnection();
if (conn != null) {
diff --git a/modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml
index 439370e..a2986e9 100644
--- a/modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml
@@ -335,6 +335,7 @@
<service name="Database" class="MySqlDatabaseComponent" discovery="MySqlDatabaseDiscoveryComponent">
<plugin-configuration>
<c:simple-property name="databaseName" displayName="Database Name" readOnly="true" />
+ <c:simple-property name="tableDiscovery" displayName="Table Discovery" readOnly="false" type="boolean" default="true"/>
</plugin-configuration>
<operation name="invokeSql" description="Execute arbitrary SQL">
diff --git a/modules/plugins/mysql/src/test/java/org/rhq/plugins/mysql/ComponentTest.java b/modules/plugins/mysql/src/test/java/org/rhq/plugins/mysql/ComponentTest.java
new file mode 100644
index 0000000..1e5b9e8
--- /dev/null
+++ b/modules/plugins/mysql/src/test/java/org/rhq/plugins/mysql/ComponentTest.java
@@ -0,0 +1,545 @@
+package org.rhq.plugins.mysql;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.AssertJUnit.fail;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.clientapi.agent.metadata.PluginMetadataManager;
+import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
+import org.rhq.core.clientapi.descriptor.configuration.ConfigurationProperty;
+import org.rhq.core.clientapi.descriptor.plugin.MetricDescriptor;
+import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+import org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor;
+import org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor;
+import org.rhq.core.clientapi.descriptor.plugin.ServiceDescriptor;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementSchedule;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.domain.resource.ProcessScan;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.PluginContainerConfiguration;
+import org.rhq.core.pc.availability.AvailabilityContextImpl;
+import org.rhq.core.pc.content.ContentContextImpl;
+import org.rhq.core.pc.event.EventContextImpl;
+import org.rhq.core.pc.event.EventManager;
+import org.rhq.core.pc.inventory.ResourceContainer;
+import org.rhq.core.pc.operation.OperationContextImpl;
+import org.rhq.core.pluginapi.availability.AvailabilityContext;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.content.ContentContext;
+import org.rhq.core.pluginapi.event.EventContext;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.PluginContainerDeployment;
+import org.rhq.core.pluginapi.inventory.ProcessScanResult;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationContext;
+import org.rhq.core.system.ProcessInfo;
+import org.rhq.core.system.SystemInfo;
+import org.rhq.core.system.SystemInfoFactory;
+import org.rhq.core.system.pquery.ProcessInfoQuery;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeSuite;
+
+/**
+ * Base class for RHQ Component Testing.
+ * Initializes a plugin configuration.
+ *
+ * Methods to override:
+ *
+ * {@link #setConfiguration(Configuration, ResourceType)}
+ */
+public abstract class ComponentTest {
+
+ /**
+ * Logging component.
+ */
+ protected final Log log = LogFactory.getLog(getClass());
+
+ private static File temp = new File(System.getProperty("java.io.tmpdir"));
+
+ /**
+ * Associates a resource component with a resource.
+ */
+ protected Map<ResourceComponent, Resource> components = new LinkedHashMap<ResourceComponent, Resource>();
+
+ /**
+ * Associates a name of a resource with a resource descriptor.
+ */
+ protected Map<String, ResourceDescriptor> descriptors = new LinkedHashMap<String, ResourceDescriptor>();
+
+ /**
+ * Associates a name of a resource with a type.
+ * This is useful for manually adding resources.
+ *
+ * @see #manuallyAdd(ResourceType, Configuration)
+ */
+ protected Map<String, ResourceType> resourceTypes = new LinkedHashMap<String, ResourceType>();
+
+ /**
+ * Event manager; used to obtain events.
+ */
+ private EventManager eventManager;
+
+ private PluginContainer pluginContainer = PluginContainer.getInstance();
+
+ private SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();
+
+ /**
+ * Scan all processes before starting; false will disable this feature.
+ * Disabling is suggested for running tests against a remote instance.
+ */
+ private boolean processScan = true;
+
+ // TODO
+
+ private final PluginMetadataManager pmm = new PluginMetadataManager();
+ private final File temporaryDirectory = temp;
+ private final File dataDirectory = temp;
+ private final String pluginContainerName = "rhq";
+ private final OperationContext operationContext = new OperationContextImpl(0);
+ private final ContentContext contentContext = new ContentContextImpl(0);
+ private final Executor availCollectorThreadPool = Executors.newCachedThreadPool();
+ private PluginContainerDeployment pluginContainerDeployment = null;
+ private Resource platform;
+ private ResourceContainer platformContainer;
+ private List<ProcessInfo> processInfo = Collections.emptyList();
+ private PluginDescriptor pluginDescriptor;
+
+ /**
+ * Constructs a new component test.
+ */
+ protected ComponentTest() {
+ }
+
+ /**
+ * Initializes the plugin container.
+ * This is run before {@link #before()}.
+ */
+ @BeforeSuite
+ protected void beforeSuite() {
+ // Speed up propagation of events by adjusting delay/period to 1 second
+ PluginContainerConfiguration pcc = new PluginContainerConfiguration();
+ pcc.setEventSenderInitialDelay(1);
+ pcc.setEventSenderPeriod(1);
+ pluginContainer.setConfiguration(pcc);
+ pluginContainer.initialize();
+ eventManager = pluginContainer.getEventManager();
+ platform = pluginContainer.getInventoryManager().getPlatform();
+ platformContainer = pluginContainer.getInventoryManager().getResourceContainer(platform);
+ if (platformContainer == null) {
+ platformContainer = new ResourceContainer(platform, getClass().getClassLoader());
+ }
+ }
+
+ /**
+ * Initializes all plugins defined in the system; using auto-discovery where possible.
+ * This is run once per test class.
+ */
+ @BeforeClass
+ protected void before() throws Exception {
+ if (processScan) {
+ processInfo = getProcessInfos();
+ if (processInfo == null)
+ processInfo = Collections.emptyList();
+ log.debug("Process Info " + processInfo);
+ for (ProcessInfo i : processInfo) {
+ log.debug(i.getBaseName() + " " + Arrays.toString(i.getCommandLine()));
+ }
+ }
+ Enumeration<URL> e = getClass().getClassLoader().getResources("META-INF/rhq-plugin.xml");
+ List<URL> l = Collections.list(e);
+ Collections.sort(l, new Comparator<URL>() {
+ @Override
+ public int compare(URL u1, URL u2) {
+ return u2.toString().compareTo(u1.toString());
+ }
+ });
+ for (URL url : l) {
+ log.debug("parse " + url);
+ InputStream is = url.openStream();
+ PluginDescriptor pd = AgentPluginDescriptorUtil.parsePluginDescriptor(is);
+ processPluginDescriptor(pd);
+ log.debug("pmm names " + pmm.getPluginNames());
+ buildDesc(pd.getServers());
+ buildDesc(pd.getServices());
+ is.close();
+ }
+ }
+
+ @AfterSuite
+ protected void afterSuite() {
+ pluginContainer.shutdown();
+ }
+
+ /**
+ * Process a plugin descriptor.
+ */
+ private void processPluginDescriptor(PluginDescriptor pd) throws Exception {
+ this.pluginDescriptor = pd;
+ Set<ResourceType> types = pmm.loadPlugin(pd);
+ mapResourceTypeNames(types);
+ log.info("Resource types: " + resourceTypes);
+ resources(types, platform, platformContainer.getResourceComponent(), platformContainer.getResourceContext());
+ log.info("ResourceComponent map: " + components);
+ }
+
+ private void mapResourceTypeNames(Set<ResourceType> types) {
+ for (ResourceType type : types) {
+ this.resourceTypes.put(type.getName(), type);
+ mapResourceTypeNames(type.getChildResourceTypes());
+ }
+ }
+
+ /**
+ * Manually create a component by name.
+ */
+ public ResourceComponent manuallyAdd(String name) throws Exception {
+ ResourceType resourceType = resourceTypes.get(name);
+ if (resourceType == null)
+ throw new IllegalStateException("no type " + name);
+ Configuration configuration = resourceType.getPluginConfigurationDefinition().getDefaultTemplate().createConfiguration();
+ setConfiguration(configuration, resourceType);
+ return manuallyAdd(resourceType, configuration);
+ }
+
+ /**
+ * Manually create a component by resource type.
+ */
+ public ResourceComponent manuallyAdd(ResourceType type, Configuration configuration) throws Exception {
+ return manuallyAdd(type, configuration, platformContainer.getResourceComponent());
+ }
+
+ /**
+ * Manually create a component by resource type, configuration, parent.
+ */
+ public ResourceComponent manuallyAdd(ResourceType type, Configuration configuration, ResourceComponent parent) throws Exception {
+ DiscoveredResourceDetails drd = new DiscoveredResourceDetails(type,
+ "key", "name", "ver", "desc", configuration, (ProcessInfo) null);
+ ResourceDiscoveryComponent c = null;
+ return createChild(drd, platform, configuration, parent, c);
+ }
+
+ private ResourceComponent createChild(DiscoveredResourceDetails drd,
+ Resource resource,
+ Configuration configuration,
+ ResourceComponent parentComponent,
+ ResourceDiscoveryComponent rdc) throws Exception
+ {
+ ResourceType type = pmm.getType(drd.getResourceType());
+
+ Resource cresource = new Resource();
+ cresource.setResourceType(type);
+ cresource.setPluginConfiguration(configuration);
+ cresource.setResourceKey(drd.getResourceKey());
+ cresource.setParentResource(resource);
+ cresource.setName(drd.getResourceName());
+ cresource.setVersion(drd.getResourceVersion());
+
+ String rclassname = pmm.getComponentClass(type);
+ ResourceComponent component = (ResourceComponent) Class.forName(rclassname).newInstance();
+
+ AvailabilityContext availContext = new AvailabilityContextImpl(cresource,availCollectorThreadPool);
+
+ EventContext eventContext = new EventContextImpl(resource);
+ ResourceContext context = new ResourceContext(cresource, parentComponent,
+ null, rdc, systemInfo, temporaryDirectory, dataDirectory,
+ pluginContainerName, eventContext, operationContext, contentContext,
+ availContext, pluginContainerDeployment);
+
+ component.start(context);
+ components.put(component, cresource);
+ resources(type.getChildResourceTypes(), cresource, component, context);
+ return component;
+ }
+
+ private void resources(Set<ResourceType> types, Resource parent, ResourceComponent component, ResourceContext context) throws Exception {
+ for (ResourceType type : types) {
+ String s = pmm.getDiscoveryClass(type);
+ if (s == null) {
+ throw new NullPointerException("no discovery " + type);
+ }
+ ResourceDiscoveryComponent rdc = (ResourceDiscoveryComponent) Class.forName(s).newInstance();
+ log.debug("rdc=" + rdc);
+ List<Configuration> configList = new ArrayList<Configuration>();
+ ResourceDiscoveryContext resourceDiscoveryContext = new ResourceDiscoveryContext(type, component,
+ context, systemInfo,
+ performProcessScans(type), configList,
+ pluginContainerName, pluginContainerDeployment);
+ Set<DiscoveredResourceDetails> drds = rdc.discoverResources(resourceDiscoveryContext);
+ for (DiscoveredResourceDetails drd : drds) {
+ log.debug("discovered " + drd);
+ ResourceType resourceType = drd.getResourceType();
+ setConfiguration(drd.getPluginConfiguration(), resourceType);
+ createChild(drd, parent, drd.getPluginConfiguration(), component, rdc);
+ }
+ if (drds.isEmpty()) {
+ log.warn("not discovered " + type);
+ context.getPluginConfiguration();
+ }
+ }
+
+ }
+
+ /**
+ * Called before the configuration is processed; override to set specific plugin parameters.
+ */
+ protected void setConfiguration(Configuration configuration, ResourceType resourceType) {
+ }
+
+ /**
+ * Stops all components, stops the plugin container.
+ */
+ @AfterTest
+ protected void after() throws Exception {
+ for (ResourceComponent c : components.keySet())
+ c.stop();
+ PluginContainer.getInstance().shutdown();
+ }
+
+ /**
+ * Returns a measurement report.
+ */
+ public MeasurementReport getMeasurementReport(ResourceComponent component) throws Exception {
+ Resource resource = this.components.get(component);
+ ResourceType type = resource.getResourceType();
+ MeasurementReport report = new MeasurementReport();
+ Set<MeasurementScheduleRequest> s = new HashSet<MeasurementScheduleRequest>();
+ for (MeasurementDefinition md : type.getMetricDefinitions())
+ s.add(new MeasurementScheduleRequest(new MeasurementSchedule(md, resource)));
+ ((MeasurementFacet)component).getValues(report, s);
+ return report;
+ }
+
+ /**
+ * Returns the first resource component by resource name, then looks by matching resource type name,
+ * then asserts failure if not found.
+ */
+ public ResourceComponent getComponent(String name) {
+ for (Map.Entry<ResourceComponent, Resource> c : components.entrySet())
+ if (c.getValue().getName().equals(name))
+ return c.getKey();
+ for (Map.Entry<ResourceComponent, Resource> c : components.entrySet())
+ if (c.getValue().getResourceType().getName().equals(name))
+ return c.getKey();
+ fail("component not found " + name + " in " + components.entrySet());
+ return null;
+ }
+
+ /**
+ * Returns a resource matching this component.
+ */
+ public Resource getResource(ResourceComponent rc) {
+ Resource r = components.get(rc);
+ if (r == null)
+ throw new IllegalStateException();
+ return r;
+ }
+
+ /**
+ * Returns a resource matching this name.
+ */
+ public Resource getResource(String name) {
+ return getResource(getComponent(name));
+ }
+
+ /**
+ * Builds a new configuration for a resource type.
+ */
+ public Configuration getConfiguration(ResourceType resourceType) {
+ Configuration configuration = resourceType.getPluginConfigurationDefinition().getDefaultTemplate().createConfiguration();
+ setConfiguration(configuration, resourceType);
+ return configuration;
+ }
+
+ // ASSERT METHOD
+
+ /**
+ * From a measurement report, returns a measurement value, or asserts failure if no such value exists.
+ */
+ public static Double getValue(MeasurementReport report, String name) {
+ for (MeasurementDataNumeric m: report.getNumericData()) {
+ if (m.getName().equals(name)) {
+ return m.getValue();
+ }
+ }
+ fail("report does not incude " + name + " report " + report.getNumericData());
+ return null;
+ }
+
+ /**
+ * Asserts the resource component is available.
+ */
+ public static void assertUp(ResourceComponent component) {
+ assertEquals("up " + component, AvailabilityType.UP, component.getAvailability());
+ }
+
+ /**
+ * Asserts the resource component is unavailable.
+ */
+ public static void assertDown(ResourceComponent component) {
+ assertEquals("down " + component, AvailabilityType.DOWN, component.getAvailability());
+ }
+
+ /**
+ * Sets a configuration option.
+ */
+ public static void set(Configuration config, String name, String value) {
+ PropertySimple s = config.getSimple(name);
+ if (s == null) {
+ s = new PropertySimple(name, value);
+ config.put(s);
+ } else {
+ s.setStringValue(value);
+ }
+ }
+
+ private List<ProcessScanResult> performProcessScans(ResourceType serverType) {
+ List<ProcessScanResult> scanResults = new ArrayList<ProcessScanResult>();
+ Set<ProcessScan> processScans = serverType.getProcessScans();
+ log.debug("Executing process scans for server type " + serverType + "...");
+ ProcessInfoQuery piq = new ProcessInfoQuery(processInfo);
+ for (ProcessScan processScan : processScans) {
+ List<ProcessInfo> queryResults = piq.query(processScan.getQuery());
+ for (ProcessInfo autoDiscoveredProcess : queryResults) {
+ scanResults.add(new ProcessScanResult(processScan, autoDiscoveredProcess));
+ log.info("Process scan auto-detected new server resource: scan=[" + processScan
+ + "], discovered-process=[" + autoDiscoveredProcess + "]");
+ }
+ }
+ return scanResults;
+ }
+
+ /**
+ * AutoDiscoveryExecutor method.
+ */
+ private List<ProcessInfo> getProcessInfos() {
+ SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();
+ log.debug("Retrieving process table...");
+ long startTime = System.currentTimeMillis();
+ List<ProcessInfo> processInfos = null;
+ try {
+ processInfos = systemInfo.getAllProcesses();
+ } catch (UnsupportedOperationException uoe) {
+ log.debug("Cannot perform process scan - not supported on this platform. (" + systemInfo.getClass() + ")");
+ }
+ long elapsedTime = System.currentTimeMillis() - startTime;
+ log.debug("Retrieval of process table took " + elapsedTime + " ms.");
+ return processInfos;
+ }
+
+ /**
+ * Returns the plugin descriptor.
+ */
+ public PluginDescriptor getPluginDescriptor() {
+ return pluginDescriptor;
+ }
+
+ /**
+ * Returns the plugin descriptor.
+ */
+ public ResourceDescriptor getResourceDescriptor(String name) {
+ ResourceDescriptor rd = descriptors.get(name);
+ if (rd == null)
+ throw new IllegalStateException("no descriptor " + name + " in " + descriptors.keySet());
+ return rd;
+ }
+
+ private void buildDesc(List<? extends ResourceDescriptor> l) {
+ for (ResourceDescriptor rd : l) {
+ descriptors.put(rd.getName(), rd);
+ if (rd instanceof ServerDescriptor) {
+ buildDesc(((ServerDescriptor)rd).getServers());
+ buildDesc(((ServerDescriptor)rd).getServices());
+ }
+ if (rd instanceof ServiceDescriptor) {
+ buildDesc(((ServiceDescriptor)rd).getServices());
+ buildDesc(((ServiceDescriptor)rd).getServices());
+ }
+ }
+ }
+
+ /**
+ * Asserts that all measurements in the report are present
+ * according to the resource descriptor.
+ *
+ * @see #getResourceDescriptor(String) for obtaining this.
+ * @param report
+ */
+ public static void assertAll(MeasurementReport report, ResourceDescriptor l) {
+ HashMap<String, MetricDescriptor> map = new HashMap<String, MetricDescriptor>();
+ for (MetricDescriptor md : l.getMetric()) {
+ map.put(md.getProperty(), md);
+ }
+ for (MeasurementDataNumeric n : report.getNumericData()) {
+ map.remove(n.getName());
+ }
+ for (MeasurementDataTrait n : report.getTraitData()) {
+ map.remove(n.getName());
+ }
+ assertTrue("Measurements not found " + map.keySet(), map.isEmpty());
+ }
+
+ /**
+ * Returns the event manager.
+ */
+ public EventManager getEventManager() {
+ return eventManager;
+ }
+
+ /**
+ * Set to false to avoid scanning local machine processes to speed up testing.
+ */
+ public void setProcessScan(boolean processScan) {
+ this.processScan = processScan;
+ }
+
+ public void assertAll(ConfigurationFacet cf, ResourceDescriptor rd) throws Exception {
+ Configuration config = cf.loadResourceConfiguration();
+ List<JAXBElement<? extends ConfigurationProperty>> templates = rd.getResourceConfiguration().getConfigurationProperty();
+ for (JAXBElement<? extends ConfigurationProperty> template : templates) {
+ String name = template.getValue().getName();
+ // Property property = config.get(name);
+ assertNotNull("config contains " + name, config.get(name));
+ Object value = config.getSimpleValue(name, null);
+ assertNotNull("value for " + name, value);
+ log.debug("config found " + name + " value " + value );
+ }
+ }
+
+}
diff --git a/modules/plugins/mysql/src/test/java/org/rhq/plugins/mysql/PluginTest.java b/modules/plugins/mysql/src/test/java/org/rhq/plugins/mysql/PluginTest.java
new file mode 100644
index 0000000..3f35c65
--- /dev/null
+++ b/modules/plugins/mysql/src/test/java/org/rhq/plugins/mysql/PluginTest.java
@@ -0,0 +1,41 @@
+package org.rhq.plugins.mysql;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.testng.annotations.Test;
+
+/**
+ * Tests MySql Server.
+ */
+@Test
+public class PluginTest extends ComponentTest {
+
+ String host = System.getProperty("host", "localhost");
+ String principal = System.getProperty("principal", "mysql");
+ String credentials = System.getProperty("credentials", "");
+ String rtn = "MySql Server";
+
+ {
+ setProcessScan(false);
+ }
+
+ @Override
+ protected void setConfiguration(Configuration c, ResourceType resourceType) {
+ if (resourceType.getName().equals(rtn)) {
+ c.getSimple("host").setStringValue(host);
+ c.getSimple("principal").setStringValue(principal);
+ c.getSimple("credentials").setStringValue(credentials);
+ }
+ if (resourceType.getName().equals("Database")) {
+ c.getSimple("tableDiscovery").setBooleanValue(false);
+ }
+ }
+
+ public void test() throws Exception {
+ manuallyAdd("MySql Server");
+ ResourceComponent resource = getComponent("MySql Server");
+ assertUp(resource);
+ }
+
+}
diff --git a/modules/plugins/mysql/src/test/resources/log4j.xml b/modules/plugins/mysql/src/test/resources/log4j.xml
new file mode 100644
index 0000000..69a897c
--- /dev/null
+++ b/modules/plugins/mysql/src/test/resources/log4j.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- tests configuration that only dumps WARN or higher messages due to appender threadhold -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Threshold" value="ERROR"/>
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t] (%c{5}) - %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="FILE" class="org.apache.log4j.FileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="DEBUG"/>
+ <param name="Append" value="false"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n"/>
+ </layout>
+ </appender>
+
+ <category name="org.jboss.on">
+ <priority value="DEBUG"/>
+ </category>
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
commit 005484491e18d138e1c58c5f65a330abf435bbe4
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jul 4 09:46:11 2012 +0200
BZ 797331 - If a network adapter is down on plugin component start, mark it as disabled.
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/NetworkAdapterComponent.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/NetworkAdapterComponent.java
index 774dd08..72cea4e 100644
--- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/NetworkAdapterComponent.java
+++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/NetworkAdapterComponent.java
@@ -1,99 +1,106 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.plugins.platform;
-
-import java.net.InetAddress;
-import java.util.List;
-import java.util.Set;
-
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementDataNumeric;
-import org.rhq.core.domain.measurement.MeasurementDataTrait;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.rhq.core.pluginapi.util.ObjectUtil;
-import org.rhq.core.system.NetworkAdapterInfo;
-import org.rhq.core.system.NetworkAdapterStats;
-
-public class NetworkAdapterComponent implements ResourceComponent<PlatformComponent>, MeasurementFacet {
- //private final Log log = LogFactory.getLog(NetworkAdapterComponent.class);
-
- private ResourceContext<PlatformComponent> context;
-
- public void start(ResourceContext<PlatformComponent> resourceContext) {
- this.context = resourceContext;
- }
-
- public void stop() {
- }
-
- public AvailabilityType getAvailability() {
- if (getInfo().getOperationalStatus() == NetworkAdapterInfo.OperationState.UP) {
- return AvailabilityType.UP;
- }
-
- return AvailabilityType.DOWN;
- }
-
- private NetworkAdapterInfo getInfo() {
- for (NetworkAdapterInfo info : this.context.getSystemInformation().getAllNetworkAdapters()) {
- if (context.getResourceKey().equals(info.getName())) {
- return info;
- }
- }
-
- throw new RuntimeException("Could not find network adapter info [" + context.getResourceKey() + "]");
- }
-
- public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) {
- NetworkAdapterInfo info = getInfo();
- NetworkAdapterStats stats = this.context.getSystemInformation().getNetworkAdapterStats(info.getName());
-
- for (MeasurementScheduleRequest request : metrics) {
- String property = request.getName();
-
- if (property.startsWith("Trait.net4.address")) // TODO
- { // this trait is supported regardless of having native support or not
- List<InetAddress> addrs = info.getUnicastAddresses();
- String ifAddrs = (addrs.size() > 0) ? addrs.get(0).getHostAddress() : "";
- for (int i = 1; i < addrs.size(); i++) {
- ifAddrs += "," + addrs.get(i).getHostAddress();
- }
-
- report.addData(new MeasurementDataTrait(request, ifAddrs));
- } else if (property.equals("Trait.interfaceFlags")) {
- report.addData(new MeasurementDataTrait(request, info.getAllFlags()));
- } else {
- Number number = ((Number) ObjectUtil.lookupAttributeProperty(stats, request.getName()));
- if (number != null) {
- report.addData(new MeasurementDataNumeric(request, number.doubleValue()));
- }
- }
- }
-
- return;
- }
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.plugins.platform;
+
+import java.net.InetAddress;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.util.ObjectUtil;
+import org.rhq.core.system.NetworkAdapterInfo;
+import org.rhq.core.system.NetworkAdapterStats;
+
+public class NetworkAdapterComponent implements ResourceComponent<PlatformComponent>, MeasurementFacet {
+ private final Log log = LogFactory.getLog(NetworkAdapterComponent.class);
+
+ private ResourceContext<PlatformComponent> context;
+
+ public void start(ResourceContext<PlatformComponent> resourceContext) {
+ this.context = resourceContext;
+ if (getInfo().getOperationalStatus()==NetworkAdapterInfo.OperationState.DOWN) {
+ context.getAvailabilityContext().disable();
+ log.info("Disabled " + context.getResourceKey() + " as it was down on start");
+ }
+ }
+
+ public void stop() {
+ }
+
+ public AvailabilityType getAvailability() {
+ if (getInfo().getOperationalStatus() == NetworkAdapterInfo.OperationState.UP) {
+ return AvailabilityType.UP;
+ }
+
+ return AvailabilityType.DOWN;
+ }
+
+ private NetworkAdapterInfo getInfo() {
+ for (NetworkAdapterInfo info : this.context.getSystemInformation().getAllNetworkAdapters()) {
+ if (context.getResourceKey().equals(info.getName())) {
+ return info;
+ }
+ }
+
+ throw new RuntimeException("Could not find network adapter info [" + context.getResourceKey() + "]");
+ }
+
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) {
+ NetworkAdapterInfo info = getInfo();
+ NetworkAdapterStats stats = this.context.getSystemInformation().getNetworkAdapterStats(info.getName());
+
+ for (MeasurementScheduleRequest request : metrics) {
+ String property = request.getName();
+
+ if (property.startsWith("Trait.net4.address")) // TODO
+ { // this trait is supported regardless of having native support or not
+ List<InetAddress> addrs = info.getUnicastAddresses();
+ String ifAddrs = (addrs.size() > 0) ? addrs.get(0).getHostAddress() : "";
+ for (int i = 1; i < addrs.size(); i++) {
+ ifAddrs += "," + addrs.get(i).getHostAddress();
+ }
+
+ report.addData(new MeasurementDataTrait(request, ifAddrs));
+ } else if (property.equals("Trait.interfaceFlags")) {
+ report.addData(new MeasurementDataTrait(request, info.getAllFlags()));
+ } else {
+ Number number = ((Number) ObjectUtil.lookupAttributeProperty(stats, request.getName()));
+ if (number != null) {
+ report.addData(new MeasurementDataNumeric(request, number.doubleValue()));
+ }
+ }
+ }
+
+ return;
+ }
}
\ No newline at end of file
commit 0a0c9a990684675cecf7b0dbef03a6a37bc20432
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Jul 3 16:59:03 2012 -0400
[BZ 828938] make sure reboot listener persists when agent is running in background.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
index 3515c55..e1883e4 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
@@ -693,7 +693,22 @@ public class PluginContainer {
}
public void notifyRebootRequestListener() {
- rebootListener.reboot();
+ //BZ 828938: the thread needs to run as non-daemon so that it's allowed to complete cleanup in daemon mode
+ Thread rebootThread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ rebootListener.reboot();
+ }
+ });
+ rebootThread.setDaemon(false);
+ rebootThread.start();
+ try {
+ rebootThread.join();
+ } catch (InterruptedException e) {
+ log.error("Interrupted while rebooting agent after one or more resource types "
+ + " have been marked for deletion. You man need to manually reboot the agent/plugin container to purge "
+ + "stale types.");
+ }
}
/**
commit fc82a357767f64e22356588cb5645f17fa626fc0
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 3 16:05:35 2012 -0400
[BZ 836664] allow oracle plugin to connect using the "service name URL". Thanks go to Richard Hensman for the patch.
diff --git a/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleServerComponent.java b/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleServerComponent.java
index 3d70eef..3849657 100644
--- a/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleServerComponent.java
+++ b/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleServerComponent.java
@@ -24,8 +24,10 @@ import java.sql.SQLException;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
@@ -128,7 +130,13 @@ public class OracleServerComponent implements DatabaseComponent, MeasurementFace
}
private static String buildUrl(Configuration configuration) {
- return "jdbc:oracle:thin:@" + configuration.getSimpleValue("host", "localhost") + ":"
- + configuration.getSimpleValue("port", "1521") + ":" + configuration.getSimpleValue("sid", "XE");
+ String connMethod = configuration.getSimpleValue("connectionMethod", "SID");
+ if (connMethod.equalsIgnoreCase("SID")) {
+ return "jdbc:oracle:thin:@" + configuration.getSimpleValue("host", "localhost") + ":"
+ + configuration.getSimpleValue("port", "1521") + ":" + configuration.getSimpleValue("sid", "XE");
+ } else {
+ return "jdbc:oracle:thin:@//" + configuration.getSimpleValue("host", "localhost") + ":"
+ + configuration.getSimpleValue("port", "1521") + "/" + configuration.getSimpleValue("sid", "XE");
+ }
}
}
\ No newline at end of file
diff --git a/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml
index 27c9033..00f0284 100644
--- a/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml
@@ -21,7 +21,16 @@
<plugin-configuration>
<c:simple-property name="host" default="localhost" displayName="Listen host" description="the hostname or IP address that the database is listening on"/>
<c:simple-property name="port" default="1521" displayName="Listen port" description="the TCP port that the database is listening on"/>
- <c:simple-property name="sid" default="XE" displayName="Database SID" description="the name of the database to connect to"/>
+
+ <c:simple-property name="connectionMethod" displayName="Connection Method" type="string" required="true" default="SID"
+ description="The method used to connect to Oracle; defaults to 'SID'.">
+ <c:property-options>
+ <c:option value="SID" name="SID"/>
+ <c:option value="SERVICENAME" name="Service name"/>
+ </c:property-options>
+ </c:simple-property>
+
+ <c:simple-property name="sid" default="XE" displayName="Database SID/Service name" description="SID or service name of the database to connect to"/>
<c:simple-property name="driverClass" default="oracle.jdbc.driver.OracleDriver" displayName="JDBC driver class"
description="the fully-qualified classname of the JDBC driver class" required="false"/>
commit a0b4f34693d070063c74c22dc463b34fd8b82cdf
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jul 3 21:39:22 2012 +0200
Update RESTEasy to 2.3.4.Final and enable GZIP compression on some methods.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
index d602751..7c664b7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
@@ -60,8 +60,6 @@ import javax.ws.rs.core.StreamingOutput;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
-import com.arjuna.ats.internal.jdbc.drivers.modifiers.list;
-
import org.jboss.cache.Fqn;
import org.rhq.core.domain.common.EntityContext;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java
index 472fd1c..8ec3d82 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java
@@ -45,6 +45,8 @@ import com.wordnik.swagger.annotations.ApiErrors;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
+import org.jboss.resteasy.annotations.GZIP;
+
import org.rhq.enterprise.server.rest.domain.Baseline;
import org.rhq.enterprise.server.rest.domain.MetricAggregate;
import org.rhq.enterprise.server.rest.domain.MetricSchedule;
@@ -65,6 +67,7 @@ public interface MetricHandlerLocal {
static String NO_RESOURCE_FOR_ID = "If no resource with the passed id exists";
static String NO_SCHEDULE_FOR_ID = "No schedule with the passed id exists";
+ @GZIP
@GET
@Path("data/{scheduleId}")
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML,MediaType.TEXT_HTML})
@@ -143,6 +146,7 @@ public interface MetricHandlerLocal {
* @param headers Injected HttpHeaders
* @return an encoded stream of numerical values
*/
+ @GZIP
@ApiOperation(value = "Expose the raw metrics of a single schedule. This can only expose raw data, which means the start date may "
+ "not be older than 7 days.")
@GET
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerLocal.java
index 867a0e4..b30f8ce 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerLocal.java
@@ -41,6 +41,7 @@ import com.wordnik.swagger.annotations.ApiError;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
+import org.jboss.resteasy.annotations.GZIP;
import org.jboss.resteasy.annotations.cache.Cache;
import org.jboss.resteasy.links.AddLinks;
import org.jboss.resteasy.links.LinkResource;
@@ -74,6 +75,7 @@ public interface ResourceHandlerLocal {
@Context Request request, @Context HttpHeaders headers,
@Context UriInfo uriInfo);
+ @GZIP
@GET
@Path("/platforms")
@Cache(isPrivate = true,maxAge = 300)
@@ -97,6 +99,7 @@ public interface ResourceHandlerLocal {
Response getAvailability(
@ApiParam("Id of the resource to query") @PathParam("id") int resourceId, @Context HttpHeaders headers);
+ @GZIP
@GET
@Path("/{id}/availability/history")
@ApiError(code = 404, reason = NO_RESOURCE_FOR_ID)
@@ -115,6 +118,7 @@ public interface ResourceHandlerLocal {
@ApiParam("Id of the resource to update") @PathParam("id") int resourceId,
@ApiParam(value= "New Availability setting", required = true) AvailabilityRest avail);
+ @GZIP
@GET
@Path("/{id}/schedules")
@LinkResource(rel="schedules",value = MetricSchedule.class)
@@ -130,6 +134,7 @@ public interface ResourceHandlerLocal {
@Context UriInfo uriInfo);
+ @GZIP
@GET
@Path("/{id}/children")
@LinkResource(rel="children", value = ResourceWithType.class)
@@ -141,6 +146,7 @@ public interface ResourceHandlerLocal {
@Context UriInfo uriInfo);
+ @GZIP
@AddLinks
@GET
@Path(("/{id}/alerts"))
diff --git a/modules/enterprise/server/jar/src/main/xsl/apiout2docbook.xsl b/modules/enterprise/server/jar/src/main/xsl/apiout2docbook.xsl
index f9a5f83..d97645a 100644
--- a/modules/enterprise/server/jar/src/main/xsl/apiout2docbook.xsl
+++ b/modules/enterprise/server/jar/src/main/xsl/apiout2docbook.xsl
@@ -97,6 +97,9 @@
</emphasis>
</simpara>
<simpara><xsl:value-of select="@description"/></simpara>
+ <xsl:if test="not(@gzip = '')">
+ <simpara>Supports returning a gzip'ed Content-Encoding</simpara>
+ </xsl:if>
<xsl:choose>
<xsl:when test="param">
<table>
diff --git a/modules/enterprise/server/jar/src/main/xsl/apiout2html.xsl b/modules/enterprise/server/jar/src/main/xsl/apiout2html.xsl
index dff70ba..4cf7d4f 100644
--- a/modules/enterprise/server/jar/src/main/xsl/apiout2html.xsl
+++ b/modules/enterprise/server/jar/src/main/xsl/apiout2html.xsl
@@ -87,6 +87,9 @@
</h3>
<em><xsl:value-of select="@description"/></em>
<br/>
+ <xsl:if test="not(@gzip = '')">
+ <p><em>Supports returning a gzip'ed Content-Encoding</em></p>
+ </xsl:if>
<xsl:choose>
<xsl:when test="param">
Parameters:
diff --git a/modules/helpers/rest-docs-generator/pom.xml b/modules/helpers/rest-docs-generator/pom.xml
index 4010747..b6be916 100644
--- a/modules/helpers/rest-docs-generator/pom.xml
+++ b/modules/helpers/rest-docs-generator/pom.xml
@@ -149,6 +149,11 @@
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>${resteasy.version}</version>
+ </dependency>
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons-logging.version}</version>
diff --git a/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java b/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
index 8144273..a3a6ddf 100644
--- a/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
+++ b/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
@@ -47,6 +47,8 @@ import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.jboss.resteasy.annotations.GZIP;
+
/**
* Processor for JAX-RS classes
* @author Heiko W. Rupp
@@ -213,6 +215,10 @@ public class ClassLevelProcessor extends AbstractProcessor {
Element methodElement = doc.createElement("method");
methodElement.setAttribute("path",path);
+ GZIP gzip = td.getAnnotation(GZIP.class);
+ if (gzip!=null) {
+ methodElement.setAttribute("gzip","true");
+ }
classElement.appendChild(methodElement);
Name elementName = td.getSimpleName();
methodElement.setAttribute("name", elementName.toString());
diff --git a/pom.xml b/pom.xml
index 603b89d..8e99665 100644
--- a/pom.xml
+++ b/pom.xml
@@ -107,7 +107,7 @@
<augeas.zip.location>${settings.localRepository}/net/augeas/augeas-native/${augeas.version}</augeas.zip.location>
<augeas.zip.mask>*-${augeas.classifier}.zip</augeas.zip.mask>
<ant.contrib.version>1.0b3</ant.contrib.version>
- <resteasy.version>2.3.3.Final</resteasy.version>
+ <resteasy.version>2.3.4.Final</resteasy.version>
<freemarker.version>2.3.18</freemarker.version>
<powermock.version>1.4.11</powermock.version>
<arquillian.version>1.0.1.Final</arquillian.version>
commit e7b13bd50bbac52f88cdde48b28a90286740e896
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Tue Jul 3 11:43:44 2012 -0700
On Resource Detail Configuration Tab - Move Save Button bar down to bottom of screen (from top) to match other button bars.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
index 6725e98..9d2d1a2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
@@ -80,6 +80,18 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
protected void onDraw() {
super.onDraw();
+ //createButtonBar();
+
+ refresh();
+
+ if (!this.resourcePermission.isConfigureWrite()) {
+ Message message = new Message(MSG.view_configurationDetails_noPermission(), Message.Severity.Info, EnumSet
+ .of(Message.Option.Transient, Message.Option.Sticky));
+ CoreGUI.getMessageCenter().notify(message);
+ }
+ }
+
+ private ToolStrip createButtonBar() {
this.buttonbar = new ToolStrip();
buttonbar.setWidth100();
buttonbar.setExtraSpace(10);
@@ -95,15 +107,7 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
buttonbar.addMember(saveButton);
// The button bar will remain hidden until the configuration has been successfully loaded.
buttonbar.setVisible(false);
- addMember(buttonbar);
-
- refresh();
-
- if (!this.resourcePermission.isConfigureWrite()) {
- Message message = new Message(MSG.view_configurationDetails_noPermission(), Message.Severity.Info, EnumSet
- .of(Message.Option.Transient, Message.Option.Sticky));
- CoreGUI.getMessageCenter().notify(message);
- }
+ return buttonbar;
}
@Override
@@ -113,11 +117,12 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
}
this.refreshing = true;
- this.buttonbar.setVisible(false);
if (editor != null) {
editor.destroy();
removeMember(editor);
+ buttonbar.destroy();
+ removeMember(buttonbar);
}
GWTServiceLookup.getConfigurationService().getLatestResourceConfigurationUpdate(resource.getId(),
@@ -155,6 +160,7 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
editor.addPropertyValueChangeListener(ResourceConfigurationEditView.this);
editor.setReadOnly(!resourcePermission.isConfigureWrite());
addMember(editor);
+ addMember(createButtonBar());
saveButton.disable();
buttonbar.setVisible(true);
commit 00db03b19d5a70e9798405b33f91ed150e38382e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 3 13:06:41 2012 -0400
[BZ 834019] unit test to make sure we push out the schedule properly for late-collected metrics
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java
index 518d5da..e7661ac 100644
--- a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java
@@ -21,6 +21,7 @@ import org.rhq.core.pc.PluginContainer;
import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.plugins.test.SingleResourceDiscoveryComponent;
import org.rhq.plugins.test.measurement.BZ834019ResourceComponent;
+import org.rhq.plugins.test.measurement.BZ834019ResourceComponent.CollectedMetric;
import org.rhq.test.arquillian.AfterDiscovery;
import org.rhq.test.arquillian.BeforeDiscovery;
import org.rhq.test.arquillian.FakeServerInventory;
@@ -31,20 +32,22 @@ import org.rhq.test.arquillian.RunDiscovery;
import org.rhq.test.shrinkwrap.RhqAgentPluginArchive;
/**
- * Test for BZ 834019.
+ * Test for BZ 834019. This test requires a long time to complete (about 2.5 minutes) because
+ * we have to wait for the minimum collection intervals (30s) to pass several times.
*/
@RunDiscovery
public class LateMeasurementRescheduleTest extends Arquillian {
- @Deployment(name = "SingleMetricPlugin")
+ @Deployment(name = "TwoMetricPlugin")
@TargetsContainer("connected-pc-with-metric-collection")
public static RhqAgentPluginArchive getTestPlugin() {
- RhqAgentPluginArchive pluginJar = ShrinkWrap
- .create(RhqAgentPluginArchive.class, "single-metric-plugin-1.0.jar");
+ RhqAgentPluginArchive pluginJar = ShrinkWrap.create(RhqAgentPluginArchive.class, "bz834019-plugin-1.0.jar");
HashMap<String, String> replacements = new HashMap<String, String>();
replacements.put("@@@discovery@@@", SingleResourceDiscoveryComponent.class.getName());
replacements.put("@@@class@@@", BZ834019ResourceComponent.class.getName());
- return pluginJar.setPluginDescriptorFromTemplate("single-metric-rhq-plugin.xml", replacements).addClasses(
+ replacements.put("@@@metric1.interval@(a)@", "30000");
+ replacements.put("@@@metric2.interval@(a)@", "35000"); // this MUST be 35s - if you make it 30s, the collections won't be late!
+ return pluginJar.setPluginDescriptorFromTemplate("two-metric-rhq-plugin.xml", replacements).addClasses(
SingleResourceDiscoveryComponent.class, BZ834019ResourceComponent.class);
}
@@ -57,10 +60,10 @@ public class LateMeasurementRescheduleTest extends Arquillian {
private FakeServerInventory fakeServerInventory;
private FakeServerInventory.CompleteDiscoveryChecker discoveryCompleteChecker;
- @ResourceContainers(plugin = "SingleMetricPlugin", resourceType = "SingleMetricServer")
+ @ResourceContainers(plugin = "TwoMetricPlugin", resourceType = "TwoMetricServer")
private Set<ResourceContainer> containers;
- @ResourceComponentInstances(plugin = "SingleMetricPlugin", resourceType = "SingleMetricServer")
+ @ResourceComponentInstances(plugin = "TwoMetricPlugin", resourceType = "TwoMetricServer")
private Set<BZ834019ResourceComponent> components;
@BeforeDiscovery(testMethods = "testBZ834019")
@@ -100,6 +103,73 @@ public class LateMeasurementRescheduleTest extends Arquillian {
BZ834019ResourceComponent server = this.components.iterator().next();
- // TODO do things to test BZ 834019
+ // do things to test BZ 834019. Here's what is happening:
+ // - server has metric1 and metric2 with intervals of 30s and 35s respectively
+ // (MUST make sure metric2 is no less than 35s, else the collections won't be late!)
+ // - the resource component will sleep in its getValues for 91s - no metrics will be reported the first 91s
+ // - the PC will call getValues() in this sequence:
+ // ** metric1 - starting at time 0 (due to the sleep in our getValues, this won't compete until time 91)
+ // ** metric2 - starting at time 0 (completes at time 91)
+ // ** metric1 - starting at time 30 (completes at time 91)
+ // ** metric2 - starting at time 60 (completes at time 91)
+ // ** metric2 - starting at time 90 (completes at time 91)
+ // ** metric2 - starting at time 105 (completes at time 105)
+ // ** metric1 - starting at time 121 (completes at time 121)
+ // Now, I can't explain this behavior entirely, however, it appears that metric1 is considered late so it
+ // is pushed back by our fix. It is last collected at time 30, but doesn't finish timely. The next time it should
+ // be collected is time 60 but because it has been late, that collection is skipped and our fix will re-schedule it
+ // next at time (interval+31), which means: 60 + (interval+31) == 60 + (30+31) == 60+61 == 121.
+ // And you can see above, that is when the next request to collect metric1 is done.
+ // Without the fix, the next collection of metric1 would have been at around time 60 + (interval) == 60 + (30) == 90
+
+ // rather than just blindly sleeping, make this test complete as fast as possible by
+ // stop waiting as soon as we see metric1 having been collected at least 3 times.
+ CollectedMetric[] collectedMetrics = null;
+ boolean keepWaiting = true;
+ int waitCycles = 0;
+ while (keepWaiting) {
+ Thread.sleep(1000);
+ int numberOfTimesMetric1WasCollectedSoFar = 0;
+ collectedMetrics = server.collectedMetrics.toArray(new CollectedMetric[0]); // copy it fast, this is synchronized so our component's thread won't break us
+ for (CollectedMetric collectedMetric : collectedMetrics) {
+ if (collectedMetric.metricName.equals("metric1")) {
+ numberOfTimesMetric1WasCollectedSoFar++;
+ }
+ }
+ if (numberOfTimesMetric1WasCollectedSoFar >= 3) {
+ keepWaiting = false;
+ }
+ if (waitCycles++ > 140) {
+ keepWaiting = false; // stop waiting but the test will probably fail because we should have had three metric1 collections by now
+ }
+ }
+
+ // round all the time values to the nearest second
+ for (CollectedMetric metric : collectedMetrics) {
+ metric.collectedTime = getRoundedSeconds(metric.collectedTime);
+ metric.finishedTime = getRoundedSeconds(metric.finishedTime);
+ System.out.println("BZ 834019 test metric=" + metric.metricName + "; start=" + metric.collectedTime
+ + "; stop=" + metric.finishedTime);
+ }
+
+ // now look at the timings and make sure we see metric1 pushed out into the future like our bug fix wants it to be
+ int collectionNumber = 0;
+ for (CollectedMetric metric : collectedMetrics) {
+ if ("metric1".equals(metric.metricName)) {
+ collectionNumber++; // this tracks that we are on the Nth time the metric was collected, we expect 3 total
+ if (collectionNumber == 1) {
+ assert metric.collectedTime <= 3; // should be 0, but give it some leeway in case our test box is slow
+ } else if (collectionNumber == 2) {
+ assert metric.collectedTime >= 29 && metric.collectedTime <= 32; // should be 30, but give it some leeway
+ } else if (collectionNumber == 3) {
+ assert metric.collectedTime >= 119 && metric.collectedTime <= 123; // should be 121, but give it some leeway
+ }
+ }
+ }
+ assert collectionNumber >= 3 : "test should have collected metric1 at least 3 times: " + collectionNumber;
+ }
+
+ private long getRoundedSeconds(long millis) {
+ return (long) ((millis / 1000.0) + 0.5);
}
}
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
index ed55d63..dedf968 100644
--- a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
@@ -44,6 +44,8 @@ public class ReadOnlyScheduleSetTest extends Arquillian {
HashMap<String, String> replacements = new HashMap<String, String>();
replacements.put("@@@discovery@@@", SingleResourceDiscoveryComponent.class.getName());
replacements.put("@@@class@@@", BZ821058ResourceComponent.class.getName());
+ replacements.put("@@@metric1.interval@(a)@", "30000");
+ replacements.put("@@@metric2.interval@(a)@", "30000");
return pluginJar.setPluginDescriptorFromTemplate("two-metric-rhq-plugin.xml", replacements).addClasses(
SingleResourceDiscoveryComponent.class, BZ821058ResourceComponent.class);
}
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ834019ResourceComponent.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ834019ResourceComponent.java
index 6a3a93d..a6f7221 100644
--- a/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ834019ResourceComponent.java
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ834019ResourceComponent.java
@@ -1,7 +1,10 @@
package org.rhq.plugins.test.measurement;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.Set;
+import java.util.Vector;
+import java.util.concurrent.CountDownLatch;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
@@ -13,6 +16,16 @@ import org.rhq.core.pluginapi.measurement.MeasurementFacet;
public class BZ834019ResourceComponent implements ResourceComponent<ResourceComponent<?>>, MeasurementFacet {
+ public class CollectedMetric {
+ public String metricName;
+ public long collectedTime; // the collected time as relative to initialCollectionTime
+ public long finishedTime; // the time when the getValues returned relative to initialCollectionTime
+ }
+
+ public CountDownLatch latch;
+ public long initialCollectionTime = 0L;
+ public Vector<CollectedMetric> collectedMetrics = new Vector<CollectedMetric>(); // we want synchronized Vector
+
@Override
public AvailabilityType getAvailability() {
return AvailabilityType.UP;
@@ -28,11 +41,64 @@ public class BZ834019ResourceComponent implements ResourceComponent<ResourceComp
@Override
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
- // TODO: do things to test BZ 834019
+ boolean doSleep = false;
+ if (initialCollectionTime == 0L) {
+ initialCollectionTime = System.currentTimeMillis();
+ doSleep = true;
+ latch = new CountDownLatch(1); // so the rest of our collections will wait for our sleep to finish
+ }
+
+ ArrayList<CollectedMetric> thisCollection = new ArrayList<CollectedMetric>();
+
+ long now = System.currentTimeMillis() - initialCollectionTime;
for (Iterator<MeasurementScheduleRequest> i = metrics.iterator(); i.hasNext();) {
MeasurementScheduleRequest metric = i.next();
+ log("collecting metric " + (metric.getName() + " (interval=" + metric.getInterval() + ")"));
report.addData(new MeasurementDataNumeric(metric, new Double(1.0)));
+
+ // remember what time we were called and which metric was asked to be collected
+ CollectedMetric collectedMetric = new CollectedMetric();
+ collectedMetric.collectedTime = now;
+ collectedMetric.metricName = metric.getName();
+ collectedMetrics.add(collectedMetric);
+ thisCollection.add(collectedMetric);
+ }
+
+ // delay the initial collection a long time to push back collection of future metrics - we must ignore all interrupts!
+ if (doSleep) {
+ log("before sleep");
+ for (int i = 0; i < 91; i++) {
+ try {
+ Thread.sleep(1000);
+ } catch (Exception e) {
+ log("ignoring interrupt at second #" + i);
+ }
+ }
+ log("after sleep");
+ latch.countDown();
+ } else {
+ // don't let interrupts abort our wait - always wait for the countdown latch to open up
+ boolean shouldWait = true;
+ while (shouldWait) {
+ try {
+ log("before latch wait");
+ latch.await();
+ log("latch opened up");
+ shouldWait = false;
+ } catch (Exception e) {
+ log("latch wait interruptted, go back and wait...");
+ }
+ }
+ }
+
+ now = System.currentTimeMillis() - initialCollectionTime;
+ for (CollectedMetric collection : thisCollection) {
+ collection.finishedTime = now;
}
return;
}
+
+ private void log(String msg) {
+ //System.out.println("!!!!!!!!!!! " + this.getClass().getSimpleName() + ": " + new Date() + ": " + msg);
+ }
}
\ No newline at end of file
diff --git a/modules/core/plugin-container-itest/src/test/resources/two-metric-rhq-plugin.xml b/modules/core/plugin-container-itest/src/test/resources/two-metric-rhq-plugin.xml
index 4d9b7e1..8302160 100644
--- a/modules/core/plugin-container-itest/src/test/resources/two-metric-rhq-plugin.xml
+++ b/modules/core/plugin-container-itest/src/test/resources/two-metric-rhq-plugin.xml
@@ -16,12 +16,12 @@
dataType="measurement"
defaultOn="true"
displayType="summary"
- defaultInterval="30000" />
+ defaultInterval="@@@metric1.interval@(a)@" />
<metric property="metric2"
dataType="measurement"
defaultOn="true"
displayType="summary"
- defaultInterval="30000" />
+ defaultInterval="@@@metric2.interval@(a)@" />
</server>
</plugin>
commit bbf48d7bddbd0361e7406d23762990fd840cd8da
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jul 3 12:48:30 2012 +0200
BZ 834820 Eliminate call to isLast() which is problematic on Oracle
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
index 5987758..d602751 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
@@ -646,8 +646,13 @@ public class MetricHandlerBean extends AbstractRestBean implements MetricHandle
PrintWriter pw = new PrintWriter(outputStream);
if (mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) {
+ boolean needsComma = false;
pw.println("[");
while (rs.next()) {
+ if (needsComma) {
+ pw.print(",\n");
+ }
+ needsComma = true;
pw.print("{");
pw.print("\"scheduleId\":");
pw.print(scheduleId);
@@ -658,8 +663,6 @@ public class MetricHandlerBean extends AbstractRestBean implements MetricHandle
pw.print("\"value\":");
pw.print(rs.getDouble(2));
pw.print("}");
- if (!rs.isLast())
- pw.print(",\n");
}
pw.println("]");
}
commit 87f63d5522059ca035c0c1d1377aba569e552b22
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Mon Jul 2 13:19:44 2012 -0700
[BZ 734490] AS7 plugin: resource config: 'Module Name' member props of 'Installed Extensions' map should be read-only
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
index c7de21b..e50fe14 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
@@ -72,6 +72,13 @@ public class ImageManager {
}
/**
+ * Returns a generic add icon.
+ */
+ public static String getAddIcon() {
+ return "[SKIN]/actions/add.png";
+ }
+
+ /**
* Returns a generic approve (aka "ok") icon.
*/
public static String getApproveIcon() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 4e3e9df..9932499 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -545,7 +545,6 @@ public class ConfigurationEditor extends LocatableVLayout {
if (propertyMap instanceof Configuration) {
this.topLevelPropertiesValuesManager.addMember(form);
}
- //form.setValidateOnExit(true); // TODO: Remove this?
form.setHiliteRequiredFields(true);
form.setNumCols(4);
form.setCellPadding(5);
@@ -1000,7 +999,7 @@ public class ConfigurationEditor extends LocatableVLayout {
removeField.addRecordClickHandler(new RecordClickHandler() {
public void onRecordClick(final RecordClickEvent recordClickEvent) {
- Log.info("You want to delete: " + recordClickEvent.getRecordNum());
+ Log.debug("You want to delete: " + recordClickEvent.getRecordNum());
SC.confirm(MSG.view_configEdit_confirm_2(), new BooleanCallback() {
public void execute(Boolean confirmed) {
if (confirmed) {
@@ -1074,20 +1073,15 @@ public class ConfigurationEditor extends LocatableVLayout {
}
private static boolean isAllReadOnly(List<PropertyDefinition> propertyDefinitions) {
- // TODO (ips, 02/13/12): If we are going to do this correctly, we need to call isPropertyReadOnly() on each
- // member property to determine whether that particular property is read-only or not,
- // rather than relying solely on whether the member property definition is read-only; this
- // is because, for a couple special cases, isPropertyReadOnly() returns false even when
- // the prop def is read-only.
- /*boolean allPropsDefsReadOnly = true;
+ boolean allPropsDefsReadOnly = true;
for (PropertyDefinition subDef : propertyDefinitions) {
if (!subDef.isReadOnly()) {
+ Log.debug("Found at least one non-readOnly property for: "+subDef.getName());
allPropsDefsReadOnly = false;
break;
}
}
- return allPropsDefsReadOnly;*/
- return false;
+ return allPropsDefsReadOnly;
}
private PropertyMapListGridRecord[] buildSummaryRecords(PropertyList propertyList,
@@ -1133,8 +1127,8 @@ public class ConfigurationEditor extends LocatableVLayout {
vLayout.addMember(footer);
final IButton deleteButton = new LocatableIButton(extendLocatorId("Delete"));
- deleteButton.setIcon(Window.getImgURL("[SKIN]/actions/remove.png"));
- deleteButton.setTooltip(MSG.view_configEdit_tooltip_1());
+ deleteButton.setIcon(Window.getImgURL(ImageManager.getRemoveIcon()));
+ deleteButton.setTooltip(MSG.view_configEdit_tooltip_1());
deleteButton.setDisabled(true);
deleteButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
@@ -1178,11 +1172,10 @@ public class ConfigurationEditor extends LocatableVLayout {
});
final IButton newButton = new LocatableIButton(vLayout.extendLocatorId("New"), MSG.common_button_new());
- newButton.setIcon(Window.getImgURL("[SKIN]/actions/add.png"));
+ newButton.setIcon(Window.getImgURL(ImageManager.getAddIcon()));
newButton.setTooltip(MSG.view_configEdit_tooltip_2());
newButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- // TODO: selenium locators
final Window popup = new Window();
popup.setTitle(MSG.view_configEdit_addItem());
popup.setWidth(300);
@@ -1276,7 +1269,7 @@ public class ConfigurationEditor extends LocatableVLayout {
return buildComplexPropertyField(vLayout);
}
- private LinkedHashMap<String, String> buildValueMap(PropertyList propertyList) {
+ private static LinkedHashMap<String, String> buildValueMap(PropertyList propertyList) {
LinkedHashMap<String, String> memberValueToIndexMap = new LinkedHashMap<String, String>();
List<Property> memberProperties = propertyList.getList();
int index = 0;
@@ -1296,13 +1289,14 @@ public class ConfigurationEditor extends LocatableVLayout {
protected FormItem buildSimpleField(final PropertyDefinitionSimple propertyDefinitionSimple,
final PropertySimple propertySimple) {
- Log.debug("Building simple field for " + propertySimple + "...");
FormItem valueItem = null;
boolean propertyIsReadOnly = isReadOnly(propertyDefinitionSimple, propertySimple);
+ Log.debug("Building simple field for " + propertySimple +"(read-only:"+propertyIsReadOnly+")...");
+
// TODO (ips, 03/25/11): We eventually want to use StaticTextItems for read-only PASSWORD props too, but we have
- // to wait until we implement masking/unmasking of PASSWORD props at the SLSB layer first.
+ // to wait until we implement masking/unmasking of PASSWORD props at the SLSB layer first.
if (propertyIsReadOnly && propertyDefinitionSimple.getType() != PropertySimpleType.PASSWORD) {
valueItem = new StaticTextItem();
} else {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
index ddf9784..6725e98 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
@@ -47,6 +47,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceD
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.MetadataType;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypeLoadedCallback;
+import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
@@ -190,7 +191,6 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
.view_configurationDetails_messageDetailed(version, resource.getName()),
Message.Severity.Info);
} else {
- // TODO: i18n
message = new Message(MSG.view_configurationDetails_configNotUpdatedDueToNoChange(),
Message.Severity.Warning);
}
commit d12f2d22940245491344cc4238eb7651cf18d1a6
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Tue Jun 26 13:36:05 2012 -0700
Minor: Change icon strings to IconEnum for better type safety.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/IconEnum.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/IconEnum.java
index 23bb13d..987dca6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/IconEnum.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/IconEnum.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client;
+
/**
* Adding type information around Icons instead of having plain Strings.
* Icons imply more than just a String type. There are attributes associated with icons
@@ -26,6 +27,7 @@ package org.rhq.enterprise.gui.coregui.client;
* This provides more type safety than the ImageManager class that deals only with String type.
* IDE's can quickly query on Icon Types and quickly see exactly where that image was used
* and understand the full ramifications of changing an image.
+ * Helps provide consistency of images throughout the app.
* By having the IconEnum represent the icon, we can defer the determination of the
* size of the icon to the implementation while still defining an icon.
* It is also very easy for a method signature to become ambiguous if the string is null.
@@ -58,6 +60,7 @@ public enum IconEnum {
TAGS("global/Tag_16.png","global/Tag_24.png" ),
REPORT("subsystems/report/Document_16.png","subsystems/report/Document_24.png" ),
SUSPECT_METRICS("subsystems/monitor/Monitor_failed_16.png","subsystems/monitor/Monitor_failed_24.png","subsystems/monitor/Monitor_grey_16.png",null),
+ RECENT_MEASUREMENTS("subsystems/monitor/Monitor_16.png","subsystems/monitor/Monitor_24.png"),
CONFIGURATION_HISTORY("subsystems/configure/Configure_16.png", "subsystems/configure/Configure_24.png","subsystems/configure/Configure_grey_16.png",null),
RECENT_OPERATIONS("subsystems/control/Operation_16.png","subsystems/control/Operation_24.png", "subsystems/control/Operation_grey_16.png",null),
RECENT_ALERTS("subsystems/alert/Alert_LOW_16.png"),
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
index 8d9680a..758d8eb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
@@ -55,6 +55,7 @@ import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.IconEnum;
import org.rhq.enterprise.gui.coregui.client.RefreshableView;
import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
@@ -172,7 +173,7 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
}
//recentMetrics.xhtml
- HLayout recentMetricsTitle = new TitleWithIcon("subsystems/monitor/Monitor_24.png", RECENT_MEASUREMENTS);
+ HLayout recentMetricsTitle = new TitleWithIcon(IconEnum.RECENT_MEASUREMENTS.getIcon24x24Path(), RECENT_MEASUREMENTS);
if ((resource != null) || ((group != null) && (groupCategory.equals(GroupCategory.COMPATIBLE)))) {//resource,CompatibleGroup
leftPane.addMember(recentMetricsTitle);
leftPane.addMember(recentMeasurementsContent);
@@ -180,12 +181,12 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
leftPane.addMember(divider1);
}
//recentAlerts.xhtml
- HLayout recentAlertsTitle = new TitleWithIcon("subsystems/alert/Flag_blue_24.png", RECENT_ALERTS);
+ HLayout recentAlertsTitle = new TitleWithIcon(IconEnum.RECENT_ALERTS.getIcon24x24Path(), RECENT_ALERTS);
leftPane.addMember(recentAlertsTitle);
leftPane.addMember(recentAlertsContent);
recentAlertsContent.setHeight(20);
//recentOOBs.xhtml
- HLayout recentOobsTitle = new TitleWithIcon("subsystems/monitor/Monitor_failed_24.png", RECENT_OOB);
+ HLayout recentOobsTitle = new TitleWithIcon(IconEnum.SUSPECT_METRICS.getIcon24x24Path(), RECENT_OOB);
recentOobContent.setHeight(20);
if ((resource != null) || ((group != null) && (groupCategory.equals(GroupCategory.COMPATIBLE)))) {//resource,CompatibleGroup
leftPane.addMember(divider2);
@@ -199,7 +200,7 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
rightPane.setAutoHeight();
firstRightPanePortletLoaded = false;
//recentConfigUpdates.xhtml
- HLayout recentConfigUpdatesTitle = new TitleWithIcon("subsystems/configure/Configure_24.png",
+ HLayout recentConfigUpdatesTitle = new TitleWithIcon(IconEnum.CONFIGURE.getIcon24x24Path(),
RECENT_CONFIGURATIONS);
recentConfigurationContent.setHeight(20);
if (((resource != null) && (resourceFacets.contains(ResourceTypeFacet.CONFIGURATION)))
@@ -210,7 +211,7 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
}
//recentOperations.xhtml
- HLayout recentOperationsTitle = new TitleWithIcon("subsystems/control/Operation_24.png", RECENT_OPERATIONS);
+ HLayout recentOperationsTitle = new TitleWithIcon(IconEnum.RECENT_OPERATIONS.getIcon24x24Path(), RECENT_OPERATIONS);
recentOperationsContent.setHeight(20);
if (((resource != null) && (resourceFacets.contains(ResourceTypeFacet.OPERATION)))
|| (displayGroupOperations(groupCategory, facets))) {//resource
@@ -222,7 +223,7 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
firstRightPanePortletLoaded = true;
}
//recentEventCounts.xhtml
- HLayout recentEventsTitle = new TitleWithIcon("subsystems/event/Events_24.png", RECENT_EVENTS);
+ HLayout recentEventsTitle = new TitleWithIcon(IconEnum.EVENTS.getIcon24x24Path(), RECENT_EVENTS);
recentEventsContent.setHeight(20);
if (((resource != null) && (resourceFacets.contains(ResourceTypeFacet.EVENT)))
|| displayGroupEvents(groupCategory, facets)) {//resource
@@ -234,7 +235,7 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
firstRightPanePortletLoaded = true;
}
//recentPackageHistory.xhtml
- HLayout recentPkgHistoryTitle = new TitleWithIcon("subsystems/content/Package_24.png", RECENT_PKG_HISTORY);
+ HLayout recentPkgHistoryTitle = new TitleWithIcon(IconEnum.CONTENT.getIcon24x24Path(),RECENT_PKG_HISTORY);
recentPkgHistoryContent.setHeight(20);
if ((resource != null) || ((group != null) && (groupCategory.equals(GroupCategory.COMPATIBLE)))) {//resource,CompatibleGroup
if (firstRightPanePortletLoaded) {
@@ -245,7 +246,7 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
}
//recent bundle deployments
- recentBundleDeployTitle = new TitleWithIcon("subsystems/content/Content_24.png", RECENT_BUNDLE_DEPLOY);
+ recentBundleDeployTitle = new TitleWithIcon(IconEnum.CONTENT.getIcon24x24Path(), RECENT_BUNDLE_DEPLOY);
recentBundleDeployTitle.setHeight(20);
deployBundleViewIfApplicable(resource, group);
@@ -513,7 +514,7 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
/** Takes the current value of the widget and persists it into the configuration object passed in.
*
- * @param configUpdateStatusSelector
+ * @param configStatusSelector
* @param portletConfig
* returns populated configuration object.
*/
commit cbb57a8b8b0a04eb680881f364598bb821cfb6c5
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 2 13:39:09 2012 -0400
[BZ 821058] refactor the unit test to use the templatized descriptor stuff. we now have a reusable descriptor that defines a server with two metrics that this test is using
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
index d94e32f..ed55d63 100644
--- a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
@@ -3,6 +3,7 @@ package org.rhq.core.pc.measurement;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
+import java.util.HashMap;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -36,11 +37,14 @@ import org.rhq.test.shrinkwrap.RhqAgentPluginArchive;
@RunDiscovery
public class ReadOnlyScheduleSetTest extends Arquillian {
- @Deployment(name = "bz821058Plugin")
+ @Deployment(name = "TwoMetricPlugin")
@TargetsContainer("connected-pc-with-metric-collection")
public static RhqAgentPluginArchive getTestPlugin() {
RhqAgentPluginArchive pluginJar = ShrinkWrap.create(RhqAgentPluginArchive.class, "bz821058-plugin-1.0.jar");
- return pluginJar.setPluginDescriptor("bz821058-rhq-plugin.xml").addClasses(
+ HashMap<String, String> replacements = new HashMap<String, String>();
+ replacements.put("@@@discovery@@@", SingleResourceDiscoveryComponent.class.getName());
+ replacements.put("@@@class@@@", BZ821058ResourceComponent.class.getName());
+ return pluginJar.setPluginDescriptorFromTemplate("two-metric-rhq-plugin.xml", replacements).addClasses(
SingleResourceDiscoveryComponent.class, BZ821058ResourceComponent.class);
}
@@ -53,10 +57,10 @@ public class ReadOnlyScheduleSetTest extends Arquillian {
private FakeServerInventory fakeServerInventory;
private FakeServerInventory.CompleteDiscoveryChecker discoveryCompleteChecker;
- @ResourceContainers(plugin = "bz821058Plugin", resourceType = "BZ821058Server")
+ @ResourceContainers(plugin = "TwoMetricPlugin", resourceType = "TwoMetricServer")
private Set<ResourceContainer> containers;
- @ResourceComponentInstances(plugin = "bz821058Plugin", resourceType = "BZ821058Server")
+ @ResourceComponentInstances(plugin = "TwoMetricPlugin", resourceType = "TwoMetricServer")
private Set<BZ821058ResourceComponent> components;
@BeforeDiscovery(testMethods = "testBZ821058")
diff --git a/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml b/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml
deleted file mode 100644
index c6adda6..0000000
--- a/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<plugin name="bz821058Plugin"
- displayName="Plugin to test BZ 821058"
- description="This will help test that measurement facet is given a read-only schedule set."
- version="1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin"
- xmlns:c="urn:xmlns:rhq-configuration">
-
- <server name="BZ821058Server"
- discovery="org.rhq.plugins.test.SingleResourceDiscoveryComponent"
- class="org.rhq.plugins.test.measurement.BZ821058ResourceComponent">
-
- <metric property="metric1"
- dataType="measurement"
- defaultOn="true"
- displayType="summary"
- defaultInterval="30000" />
-
- <metric property="metric2"
- dataType="measurement"
- defaultOn="true"
- displayType="summary"
- defaultInterval="30000" />
- </server>
-</plugin>
-
diff --git a/modules/core/plugin-container-itest/src/test/resources/two-metric-rhq-plugin.xml b/modules/core/plugin-container-itest/src/test/resources/two-metric-rhq-plugin.xml
new file mode 100644
index 0000000..4d9b7e1
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/resources/two-metric-rhq-plugin.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin name="TwoMetricPlugin"
+ displayName="Plugin that has a single server with a two enabled metrics."
+ description="This will help test measurement collections by providing a server with a two enabled metrics."
+ version="1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+ <server name="TwoMetricServer"
+ discovery="@@@discovery@@@"
+ class="@@@class@@@">
+
+ <metric property="metric1"
+ dataType="measurement"
+ defaultOn="true"
+ displayType="summary"
+ defaultInterval="30000" />
+
+ <metric property="metric2"
+ dataType="measurement"
+ defaultOn="true"
+ displayType="summary"
+ defaultInterval="30000" />
+ </server>
+</plugin>
commit 25b62b50adc3b8631f68e52304df22d7e8d7959a
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 2 11:31:33 2012 -0400
[BZ 826716] Improve error reporting in the UI
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/DuplicateExpressionTypeException.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/DuplicateExpressionTypeException.java
new file mode 100644
index 0000000..4d51fc9
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/DuplicateExpressionTypeException.java
@@ -0,0 +1,38 @@
+/*
+ *
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 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.domain.resource.group;
+
+/**
+ * @author John Sanda
+ */
+public class DuplicateExpressionTypeException extends InvalidExpressionException {
+
+ private static final long serialVersionUID = 1L;
+
+ private DuplicateExpressionTypeException() {
+ }
+
+ public DuplicateExpressionTypeException(String predicate) {
+ super("You cannot specify multiple " + predicate + " expressions.");
+ }
+
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/InvalidExpressionException.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/InvalidExpressionException.java
new file mode 100644
index 0000000..600ba04
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/InvalidExpressionException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.domain.resource.group;
+
+public class InvalidExpressionException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public InvalidExpressionException() {
+ }
+
+ public InvalidExpressionException(String message) {
+ super(message);
+ }
+
+ public InvalidExpressionException(Throwable cause) {
+ super(cause);
+ }
+
+ public InvalidExpressionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
index bd196fc..6cd1a43 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
@@ -27,6 +27,7 @@ import org.rhq.core.domain.resource.group.GroupDefinition;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.resource.group.DuplicateExpressionTypeException;
/**
* @author Greg Hinkle
@@ -64,9 +65,11 @@ public interface ResourceGroupGWTService extends RemoteService {
void setAssignedResources(int groupId, int[] resourceIds, boolean setType) throws RuntimeException;
- void recalculateGroupDefinitions(int[] groupDefinitionIds) throws RuntimeException;
+ void recalculateGroupDefinitions(int[] groupDefinitionIds)
+ throws DuplicateExpressionTypeException, RuntimeException;
- void updateGroupDefinition(GroupDefinition groupDefinition) throws RuntimeException;
+ void updateGroupDefinition(GroupDefinition groupDefinition)
+ throws DuplicateExpressionTypeException, RuntimeException;
void updateResourceGroup(ResourceGroup group) throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
index ff3cab2..74484dd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
@@ -33,6 +33,7 @@ import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria;
+import org.rhq.core.domain.resource.group.DuplicateExpressionTypeException;
import org.rhq.core.domain.resource.group.GroupDefinition;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
@@ -154,7 +155,11 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition, Re
new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_saveFailure(name), caught);
+ if (caught instanceof DuplicateExpressionTypeException) {
+ CoreGUI.getMessageCenter().notify(new Message(caught.getMessage(), Message.Severity.Warning));
+ } else {
+ CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_saveFailure(name), caught);
+ }
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
index 38b5165..0661533 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
@@ -18,6 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions;
+import java.util.Date;
+import java.util.Set;
+
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.ListGridFieldType;
@@ -26,20 +29,23 @@ import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.authz.Permission;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.components.table.*;
+import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.EscapedHtmlCellFormatter;
+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.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.TableUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
-
-import java.util.Date;
-import java.util.Set;
+import org.rhq.core.domain.resource.group.DuplicateExpressionTypeException;
/**
* @author Greg Hinkle
@@ -156,7 +162,12 @@ public class GroupDefinitionListView extends TableSection<GroupDefinitionDataSou
resourceGroupManager.recalculateGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_recalcFailureSelection(), caught);
+ if (caught instanceof DuplicateExpressionTypeException) {
+ CoreGUI.getMessageCenter().notify(new Message(caught.getMessage(),
+ Message.Severity.Warning));
+ } else {
+ CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_recalcFailureSelection(), caught);
+ }
}
public void onSuccess(Void result) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
index f55c37a..c417426 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
@@ -61,6 +61,7 @@ import com.smartgwt.client.widgets.layout.HLayout;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria;
+import org.rhq.core.domain.resource.group.DuplicateExpressionTypeException;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.GroupDefinition;
import org.rhq.core.domain.util.PageList;
@@ -239,7 +240,11 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_recalcFailure(), caught);
+ if (caught instanceof DuplicateExpressionTypeException) {
+ CoreGUI.getMessageCenter().notify(new Message(caught.getMessage(), Message.Severity.Warning));
+ } else {
+ CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_recalcFailure(), caught);
+ }
}
@Override
@@ -487,6 +492,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
MSG.view_dynagroup_loadDefinitionFailure(String.valueOf(groupDefinitionId)), caught);
+
History.back();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
index b098980..8c5c54d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
@@ -29,6 +29,7 @@ import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerLocal;
+import org.rhq.core.domain.resource.group.DuplicateExpressionTypeException;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -146,20 +147,28 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- public void updateGroupDefinition(GroupDefinition groupDefinition) throws RuntimeException {
+ public void updateGroupDefinition(GroupDefinition groupDefinition)
+ throws DuplicateExpressionTypeException, RuntimeException {
try {
definitionManager.updateGroupDefinition(getSessionSubject(), groupDefinition);
} catch (Throwable t) {
+ if (t instanceof DuplicateExpressionTypeException) {
+ throw (DuplicateExpressionTypeException) t;
+ }
throw getExceptionToThrowToClient(t);
}
}
- public void recalculateGroupDefinitions(int[] groupDefinitionIds) throws RuntimeException {
+ public void recalculateGroupDefinitions(int[] groupDefinitionIds)
+ throws DuplicateExpressionTypeException, RuntimeException {
try {
for (int nextGroupDefinitionId : groupDefinitionIds) {
definitionManager.calculateGroupMembership(getSessionSubject(), nextGroupDefinitionId);
}
} catch (Throwable t) {
+ if (t instanceof DuplicateExpressionTypeException) {
+ throw (DuplicateExpressionTypeException) t;
+ }
throw getExceptionToThrowToClient(t);
}
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java
index 262c173..b3a1edd 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java
@@ -31,7 +31,7 @@ import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.server.resource.group.ResourceGroupUpdateException;
import org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerLocal;
import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionException;
-import org.rhq.enterprise.server.resource.group.definition.framework.InvalidExpressionException;
+import org.rhq.core.domain.resource.group.InvalidExpressionException;
import org.rhq.enterprise.server.util.LookupUtil;
public class EditGroupDefinitionGeneralPropertiesUIBean {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
index 3776c70..190a169 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
@@ -62,7 +62,7 @@ import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefini
import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionNotFoundException;
import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionUpdateException;
import org.rhq.enterprise.server.resource.group.definition.framework.ExpressionEvaluator;
-import org.rhq.enterprise.server.resource.group.definition.framework.InvalidExpressionException;
+import org.rhq.core.domain.resource.group.InvalidExpressionException;
import org.rhq.enterprise.server.resource.group.definition.mbean.GroupDefinitionRecalculationThreadMonitor;
import org.rhq.enterprise.server.resource.group.definition.mbean.GroupDefinitionRecalculationThreadMonitorMBean;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerLocal.java
index d83c77c..b1d0d1d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerLocal.java
@@ -33,7 +33,7 @@ import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefini
import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionNotFoundException;
import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionUpdateException;
import org.rhq.enterprise.server.resource.group.definition.framework.ExpressionEvaluator;
-import org.rhq.enterprise.server.resource.group.definition.framework.InvalidExpressionException;
+import org.rhq.core.domain.resource.group.InvalidExpressionException;
@Local
public interface GroupDefinitionManagerLocal {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/DuplicateExpressionTypeException.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/DuplicateExpressionTypeException.java
deleted file mode 100644
index 2b34b05..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/DuplicateExpressionTypeException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- *
- * * RHQ Management Platform
- * * Copyright (C) 2005-2012 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.resource.group.definition.framework;
-
-/**
- * @author John Sanda
- */
-public class DuplicateExpressionTypeException extends InvalidExpressionException {
-
- private static final long serialVersionUID = 1L;
-
- private DuplicateExpressionTypeException() {
- }
-
- public DuplicateExpressionTypeException(String predicate) {
- super("You cannot specify multiple " + predicate + " expressions.");
- }
-
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java
index 925d59d..7f42f55 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java
@@ -28,7 +28,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.TreeSet;
+import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -39,6 +39,8 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.group.DuplicateExpressionTypeException;
+import org.rhq.core.domain.resource.group.InvalidExpressionException;
import org.rhq.enterprise.server.common.EntityManagerFacadeLocal;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.enterprise.server.util.QueryUtility;
@@ -93,7 +95,7 @@ public class ExpressionEvaluator implements Iterable<ExpressionEvaluator.Result>
private EntityManagerFacadeLocal entityManagerFacade;
- private Set<String> resourceExpressions = new TreeSet<String>();
+ private Map<String, String> resourceExpressions = new TreeMap<String, String>();
public ExpressionEvaluator() {
/*
@@ -129,69 +131,77 @@ public class ExpressionEvaluator implements Iterable<ExpressionEvaluator.Result>
*/
whereStatics.add("res.inventoryStatus = org.rhq.core.domain.resource.InventoryStatus.COMMITTED");
- resourceExpressions.add("res.id");
- resourceExpressions.add("child.id");
- resourceExpressions.add("res.parentResource.id");
- resourceExpressions.add("res.parentResource.parentResource.id");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.id");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.id");
-
- resourceExpressions.add("res.name");
- resourceExpressions.add("child.name");
- resourceExpressions.add("res.parentResource.name");
- resourceExpressions.add("res.parentResource.parentResource.name");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.name");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.name");
-
- resourceExpressions.add("res.version");
- resourceExpressions.add("child.version");
- resourceExpressions.add("res.parentResource.version");
- resourceExpressions.add("res.parentResource.parentResource.version");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.version");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.version");
-
-
- resourceExpressions.add("res.resourceType.plugin");
- resourceExpressions.add("res.resourceType.name");
- resourceExpressions.add("child.resourceType.plugin");
- resourceExpressions.add("child.resourceType.name");
- resourceExpressions.add("res.parentResource.resourceType.plugin");
- resourceExpressions.add("res.parentResource.resourceType.name");
- resourceExpressions.add("res.parentResource.parentResource.resourceType.plugin");
- resourceExpressions.add("res.parentResource.parentResource.resourceType.name");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.resourceType.plugin");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.resourceType.name");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.resourceType.plugin");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.resourceType.name");
-
-
- resourceExpressions.add("res.resourceType.category");
- resourceExpressions.add("child.resourceType.category");
- resourceExpressions.add("res.parentResource.resourceType.category");
- resourceExpressions.add("res.parentResource.parentResource.resourceType.category");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.resourceType.category");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.resourceType.category");
-
- resourceExpressions.add("avail.availabilityType");
- resourceExpressions.add("child.avail.availabilityType");
- resourceExpressions.add("res.parentResource.avail.availabilityType");
- resourceExpressions.add("res.parentResource.parentResource.avail.availabilityType");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.avail.availabilityType");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.avail.availabilityType");
-
- resourceExpressions.add("trait.value");
- resourceExpressions.add("child.trait.value");
- resourceExpressions.add("res.parentResource.trait.value");
- resourceExpressions.add("res.parentResource.parentResource.trait.value");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.trait.value");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.trait.value");
-
- resourceExpressions.add("simple.name");
- resourceExpressions.add("child.simple.name");
- resourceExpressions.add("res.parentResource.simple.name");
- resourceExpressions.add("res.parentResource.parentResource.simple.name");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.simple.name");
- resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.simple.name");
+ resourceExpressions.put("res.id", "resource id");
+ resourceExpressions.put("child.id", "resource id");
+ resourceExpressions.put("res.parentResource.id", "resource id");
+ resourceExpressions.put("res.parentResource.parentResource.id", "resource id");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.id", "resource id");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.parentResource.id", "resource id");
+
+ resourceExpressions.put("res.name", "resource name");
+ resourceExpressions.put("child.name", "resource name");
+ resourceExpressions.put("res.parentResource.name", "resource name");
+ resourceExpressions.put("res.parentResource.parentResource.name", "resource name");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.name", "resource name");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.parentResource.name",
+ "resource name");
+
+ resourceExpressions.put("res.version", "resource version");
+ resourceExpressions.put("child.version", "resource version");
+ resourceExpressions.put("res.parentResource.version", "resource version");
+ resourceExpressions.put("res.parentResource.parentResource.version", "resource version");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.version", "resource version");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.parentResource.version",
+ "resource version");
+
+ resourceExpressions.put("res.resourceType.plugin", "resource type");
+ resourceExpressions.put("res.resourceType.name", "resource type");
+ resourceExpressions.put("child.resourceType.plugin", "resource type");
+ resourceExpressions.put("child.resourceType.name", "resource type");
+ resourceExpressions.put("res.parentResource.resourceType.plugin", "resource type");
+ resourceExpressions.put("res.parentResource.resourceType.name", "resource type");
+ resourceExpressions.put("res.parentResource.parentResource.resourceType.plugin", "resource type");
+ resourceExpressions.put("res.parentResource.parentResource.resourceType.name", "resource type");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.resourceType.plugin",
+ "resource type");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.resourceType.name", "resource type");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.parentResource.resourceType.plugin",
+ "resource type");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.parentResource.resourceType.name",
+ "resource type");
+
+ resourceExpressions.put("res.resourceType.category", "resource category");
+ resourceExpressions.put("child.resourceType.category", "resource category");
+ resourceExpressions.put("res.parentResource.resourceType.category", "resource category");
+ resourceExpressions.put("res.parentResource.parentResource.resourceType.category", "resource category");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.resourceType.category",
+ "resource category");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.parentResource.resourceType.category",
+ "resource category");
+
+ resourceExpressions.put("avail.availabilityType", "availability");
+ resourceExpressions.put("child.avail.availabilityType", "availability");
+ resourceExpressions.put("res.parentResource.avail.availabilityType", "availability");
+ resourceExpressions.put("res.parentResource.parentResource.avail.availabilityType", "availability");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.avail.availabilityType",
+ "availability");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.parentResource.avail.availabilityType",
+ "availability");
+
+ resourceExpressions.put("trait.value", "trait");
+ resourceExpressions.put("child.trait.value", "trait");
+ resourceExpressions.put("res.parentResource.trait.value", "trait");
+ resourceExpressions.put("res.parentResource.parentResource.trait.value", "trait");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.trait.value", "trait");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.parentResource.trait.value", "trait");
+
+ resourceExpressions.put("simple.name", "configuration");
+ resourceExpressions.put("child.simple.name", "configuration");
+ resourceExpressions.put("res.parentResource.simple.name", "configuration");
+ resourceExpressions.put("res.parentResource.parentResource.simple.name", "configuration");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.simple.name", "configuration");
+ resourceExpressions.put("res.parentResource.parentResource.parentResource.parentResource.simple.name",
+ "configuration");
}
public class Result {
@@ -231,7 +241,7 @@ public class ExpressionEvaluator implements Iterable<ExpressionEvaluator.Result>
*
* @return a reference to itself, so that method chaining can be used
*
- * @throws InvalidExpressionException if the expression can not be parsed for any reason, the message will try to
+ * @throws org.rhq.core.domain.resource.group.InvalidExpressionException if the expression can not be parsed for any reason, the message will try to
* get the details as to the parse failure
*/
public ExpressionEvaluator addExpression(String expression) throws InvalidExpressionException {
@@ -779,8 +789,8 @@ public class ExpressionEvaluator implements Iterable<ExpressionEvaluator.Result>
+ "] for predicate population");
}
- if (resourceExpressions.contains(predicateName) && whereConditions.containsKey(predicateName)) {
- throw new DuplicateExpressionTypeException(predicateName);
+ if (resourceExpressions.containsKey(predicateName) && whereConditions.containsKey(predicateName)) {
+ throw new DuplicateExpressionTypeException(resourceExpressions.get(predicateName));
}
whereConditions.put(predicateName, argumentName);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/InvalidExpressionException.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/InvalidExpressionException.java
deleted file mode 100644
index 06c7558..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/InvalidExpressionException.java
+++ /dev/null
@@ -1,38 +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.enterprise.server.resource.group.definition.framework;
-
-public class InvalidExpressionException extends Exception {
- private static final long serialVersionUID = 1L;
-
- public InvalidExpressionException() {
- }
-
- public InvalidExpressionException(String message) {
- super(message);
- }
-
- public InvalidExpressionException(Throwable cause) {
- super(cause);
- }
-
- public InvalidExpressionException(String message, Throwable cause) {
- super(message, cause);
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java
index 76c5824..a1c8a65 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java
@@ -24,9 +24,9 @@ import java.util.List;
import org.testng.annotations.Test;
-import org.rhq.enterprise.server.resource.group.definition.framework.DuplicateExpressionTypeException;
+import org.rhq.core.domain.resource.group.DuplicateExpressionTypeException;
import org.rhq.enterprise.server.resource.group.definition.framework.ExpressionEvaluator;
-import org.rhq.enterprise.server.resource.group.definition.framework.InvalidExpressionException;
+import org.rhq.core.domain.resource.group.InvalidExpressionException;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.QueryUtility;
commit c97c6b90b7cd8d54c3974b8bddc61fe808e2b72b
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jun 27 14:19:03 2012 -0400
[BZ 826716] Adding tests for plugin and resource config expressions.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java
index 32565b6..925d59d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java
@@ -178,6 +178,20 @@ public class ExpressionEvaluator implements Iterable<ExpressionEvaluator.Result>
resourceExpressions.add("res.parentResource.parentResource.avail.availabilityType");
resourceExpressions.add("res.parentResource.parentResource.parentResource.avail.availabilityType");
resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.avail.availabilityType");
+
+ resourceExpressions.add("trait.value");
+ resourceExpressions.add("child.trait.value");
+ resourceExpressions.add("res.parentResource.trait.value");
+ resourceExpressions.add("res.parentResource.parentResource.trait.value");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.trait.value");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.trait.value");
+
+ resourceExpressions.add("simple.name");
+ resourceExpressions.add("child.simple.name");
+ resourceExpressions.add("res.parentResource.simple.name");
+ resourceExpressions.add("res.parentResource.parentResource.simple.name");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.simple.name");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.simple.name");
}
public class Result {
@@ -549,10 +563,6 @@ public class ExpressionEvaluator implements Iterable<ExpressionEvaluator.Result>
addJoinCondition(JoinCondition.AVAILABILITY);
populatePredicateCollections(JoinCondition.AVAILABILITY.alias + ".availabilityType", type);
} else if (context == ParseContext.Trait) {
- if (whereConditions.containsKey(TRAIT_ALIAS + ".value")) {
- throw new InvalidExpressionException("Cannot have multiple trait expressions.");
- }
-
// SELECT res.id FROM Resource res JOIN res.schedules sched, sched.definition def, MeasurementDataTrait trait
// WHERE def.name = :arg1 AND trait.value = :arg2 AND trait.schedule = sched AND trait.id.timestamp =
// (SELECT max(mdt.id.timestamp) FROM MeasurementDataTrait mdt WHERE sched.id = mdt.schedule.id)
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java
index 78ee34f..76c5824 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java
@@ -29,7 +29,6 @@ import org.rhq.enterprise.server.resource.group.definition.framework.ExpressionE
import org.rhq.enterprise.server.resource.group.definition.framework.InvalidExpressionException;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.QueryUtility;
-import org.rhq.test.TransactionCallback;
public class ExpressionEvaluatorTest extends AbstractEJB3Test {
@@ -158,7 +157,7 @@ public class ExpressionEvaluatorTest extends AbstractEJB3Test {
" AND simple.name = simpleDef.name AND simpleDef.type != 'PASSWORD' " }, };
}
-// @Test(groups = "integration.session")
+ @Test(groups = "integration.session")
public void testWellFormedExpressions() throws Exception {
String[][] successTestCases = getSuccessTestCases();
@@ -215,7 +214,7 @@ public class ExpressionEvaluatorTest extends AbstractEJB3Test {
}
}
-// @Test(groups = "integration.session")
+ @Test(groups = "integration.session")
public void testTokenizer() {
String[] input = { "resource.child.name", //
@@ -257,15 +256,6 @@ public class ExpressionEvaluatorTest extends AbstractEJB3Test {
}
}
- private void executeAndRollback(TransactionCallback callback) throws Exception {
- try {
- getTransactionManager().begin();
- callback.execute();
- } finally {
- getTransactionManager().rollback();
- }
- }
-
private static interface ExpressionGenerator {
String[] getExpressions();
}
@@ -284,34 +274,86 @@ public class ExpressionEvaluatorTest extends AbstractEJB3Test {
}
}
- @Test(expectedExceptions = InvalidExpressionException.class,
- expectedExceptionsMessageRegExp = ".*Cannot have multiple trait expressions.*")
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
public void doNotAllowMultipleResourceTraitExpressions() throws Exception {
- executeAndRollback(new TransactionCallback() {
+ evaluateExpressions(new ExpressionGenerator() {
@Override
- public void execute() throws Exception {
- ExpressionEvaluator evaluator = new ExpressionEvaluator();
- evaluator.addExpression("resource.trait[agentHomeDirectory] = /var/rhq-agent");
- evaluator.addExpression("resource.trait[reasonForLastRestart] = OOMError");
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.trait[agentHomeDirectory] = /var/rhq-agent",
+ "resource.trait[reasonForLastRestart] = OOMError"
+ };
+ }
+ });
+ }
- evaluator.execute();
- evaluator.iterator().next();
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleChildResourceTraitExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.child.trait[agentHomeDirectory] = /var/rhq-agent",
+ "resource.child.trait[reasonForLastRestart] = OOMError"
+ };
}
});
}
- @Test(expectedExceptions = InvalidExpressionException.class,
- expectedExceptionsMessageRegExp = ".*Cannot have multiple trait expressions.*")
- public void doNotAllowMultiplParentResourceTraitExpressions() throws Exception {
- executeAndRollback(new TransactionCallback() {
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleParentResourceTraitExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
@Override
- public void execute() throws Exception {
- ExpressionEvaluator evaluator = new ExpressionEvaluator();
- evaluator.addExpression("resource.parent.trait[agentHomeDirectory] = /var/rhq-agent");
- evaluator.addExpression("resource.parent.trait[reasonForLastRestart] = OOMError");
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.parent.trait[agentHomeDirectory] = /var/rhq-agent",
+ "resource.parent.trait[reasonForLastRestart] = OOMError"
+ };
+ }
+ });
+ }
- evaluator.execute();
- evaluator.iterator().next();
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGrandParentResourceTraitExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.grandParent.trait[agentHomeDirectory] = /var/rhq-agent",
+ "resource.grandParent.trait[reasonForLastRestart] = OOMError"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGrandParentResourceTraitExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.greatGrandParent.trait[agentHomeDirectory] = /var/rhq-agent",
+ "resource.greatGrandParent.trait[reasonForLastRestart] = OOMError"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGreatGrandParentResourceTraitExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.greatGreatGrandParent.trait[agentHomeDirectory] = /var/rhq-agent",
+ "resource.greatGreatGrandParent.trait[reasonForLastRestart] = OOMError"
+ };
}
});
}
@@ -748,6 +790,174 @@ public class ExpressionEvaluatorTest extends AbstractEJB3Test {
});
}
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleResourcePluginConfigExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.pluginConfiguration[x] = 1",
+ "resource.pluginConfiguration[y] = 2"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleChildResourcePluginConfigExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.child.pluginConfiguration[x] = 1",
+ "resource.child.pluginConfiguration[y] = 2"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleParentResourcePluginConfigExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.parent.pluginConfiguration[x] = 1",
+ "resource.parent.pluginConfiguration[y] = 2"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGrandParentResourcePluginConfigExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.grandParent.pluginConfiguration[x] = 1",
+ "resource.grandParent.pluginConfiguration[y] = 2"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGrandParentResourcePluginConfigExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.greatGrandParent.pluginConfiguration[x] = 1",
+ "resource.greatGrandParent.pluginConfiguration[y] = 2"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGreatGrandParentResourcePluginConfigExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.greatGreatGrandParent.pluginConfiguration[x] = 1",
+ "resource.greatGreatGrandParent.pluginConfiguration[y] = 2"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleResourceConfigExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.resourceConfiguration[x] = 1",
+ "resource.resourceConfiguration[y] = 2"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleChildResourceConfigExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.child.resourceConfiguration[x] = 1",
+ "resource.child.resourceConfiguration[y] = 2"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleParentResourceConfigExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.parent.resourceConfiguration[x] = 1",
+ "resource.parent.resourceConfiguration[y] = 2"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGrandParentResourceConfigExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.grandParent.resourceConfiguration[x] = 1",
+ "resource.grandParent.resourceConfiguration[y] = 2"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGrandParentResourceConfigExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.greatGrandParent.resourceConfiguration[x] = 1",
+ "resource.greatGrandParent.resourceConfiguration[y] = 2"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGreatGrandParentResourceConfigExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.greatGreatGrandParent.resourceConfiguration[x] = 1",
+ "resource.greatGreatGrandParent.resourceConfiguration[y] = 2"
+ };
+ }
+ });
+ }
+
private String cleanUp(String result) {
return result.replaceAll("\\s+", " ").trim();
}
commit 95a0bf5b8be8a17638bd1b6fbf740e959e19af31
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jun 26 17:04:29 2012 -0400
[BZ 667896] Adding more tests to verify we do not allow multiple expressions of the same type
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/DuplicateExpressionTypeException.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/DuplicateExpressionTypeException.java
new file mode 100644
index 0000000..2b34b05
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/DuplicateExpressionTypeException.java
@@ -0,0 +1,38 @@
+/*
+ *
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 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.resource.group.definition.framework;
+
+/**
+ * @author John Sanda
+ */
+public class DuplicateExpressionTypeException extends InvalidExpressionException {
+
+ private static final long serialVersionUID = 1L;
+
+ private DuplicateExpressionTypeException() {
+ }
+
+ public DuplicateExpressionTypeException(String predicate) {
+ super("You cannot specify multiple " + predicate + " expressions.");
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java
index 1f7e300..32565b6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java
@@ -28,6 +28,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -92,6 +93,8 @@ public class ExpressionEvaluator implements Iterable<ExpressionEvaluator.Result>
private EntityManagerFacadeLocal entityManagerFacade;
+ private Set<String> resourceExpressions = new TreeSet<String>();
+
public ExpressionEvaluator() {
/*
* used LinkedHashMap for whereConditions on purpose so that the iterator will return them in the same order
@@ -125,6 +128,56 @@ public class ExpressionEvaluator implements Iterable<ExpressionEvaluator.Result>
* initialization for special handling that all dynagroups should get
*/
whereStatics.add("res.inventoryStatus = org.rhq.core.domain.resource.InventoryStatus.COMMITTED");
+
+ resourceExpressions.add("res.id");
+ resourceExpressions.add("child.id");
+ resourceExpressions.add("res.parentResource.id");
+ resourceExpressions.add("res.parentResource.parentResource.id");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.id");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.id");
+
+ resourceExpressions.add("res.name");
+ resourceExpressions.add("child.name");
+ resourceExpressions.add("res.parentResource.name");
+ resourceExpressions.add("res.parentResource.parentResource.name");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.name");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.name");
+
+ resourceExpressions.add("res.version");
+ resourceExpressions.add("child.version");
+ resourceExpressions.add("res.parentResource.version");
+ resourceExpressions.add("res.parentResource.parentResource.version");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.version");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.version");
+
+
+ resourceExpressions.add("res.resourceType.plugin");
+ resourceExpressions.add("res.resourceType.name");
+ resourceExpressions.add("child.resourceType.plugin");
+ resourceExpressions.add("child.resourceType.name");
+ resourceExpressions.add("res.parentResource.resourceType.plugin");
+ resourceExpressions.add("res.parentResource.resourceType.name");
+ resourceExpressions.add("res.parentResource.parentResource.resourceType.plugin");
+ resourceExpressions.add("res.parentResource.parentResource.resourceType.name");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.resourceType.plugin");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.resourceType.name");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.resourceType.plugin");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.resourceType.name");
+
+
+ resourceExpressions.add("res.resourceType.category");
+ resourceExpressions.add("child.resourceType.category");
+ resourceExpressions.add("res.parentResource.resourceType.category");
+ resourceExpressions.add("res.parentResource.parentResource.resourceType.category");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.resourceType.category");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.resourceType.category");
+
+ resourceExpressions.add("avail.availabilityType");
+ resourceExpressions.add("child.avail.availabilityType");
+ resourceExpressions.add("res.parentResource.avail.availabilityType");
+ resourceExpressions.add("res.parentResource.parentResource.avail.availabilityType");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.avail.availabilityType");
+ resourceExpressions.add("res.parentResource.parentResource.parentResource.parentResource.avail.availabilityType");
}
public class Result {
@@ -716,6 +769,10 @@ public class ExpressionEvaluator implements Iterable<ExpressionEvaluator.Result>
+ "] for predicate population");
}
+ if (resourceExpressions.contains(predicateName) && whereConditions.containsKey(predicateName)) {
+ throw new DuplicateExpressionTypeException(predicateName);
+ }
+
whereConditions.put(predicateName, argumentName);
whereReplacements.put(argumentName, value);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java
index f0a64ff..78ee34f 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java
@@ -24,10 +24,12 @@ import java.util.List;
import org.testng.annotations.Test;
+import org.rhq.enterprise.server.resource.group.definition.framework.DuplicateExpressionTypeException;
import org.rhq.enterprise.server.resource.group.definition.framework.ExpressionEvaluator;
import org.rhq.enterprise.server.resource.group.definition.framework.InvalidExpressionException;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.QueryUtility;
+import org.rhq.test.TransactionCallback;
public class ExpressionEvaluatorTest extends AbstractEJB3Test {
@@ -255,24 +257,495 @@ public class ExpressionEvaluatorTest extends AbstractEJB3Test {
}
}
- @Test(expectedExceptions = InvalidExpressionException.class)
- public void throwExceptionWhenMultipleResourceTraitsSpecified() throws Exception {
- ExpressionEvaluator evaluator = new ExpressionEvaluator();
- evaluator.addExpression("resource.trait[agentHomeDirectory] = /var/rhq-agent");
- evaluator.addExpression("resource.trait[reasonForLastRestart] = OOMError");
+ private void executeAndRollback(TransactionCallback callback) throws Exception {
+ try {
+ getTransactionManager().begin();
+ callback.execute();
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
- evaluator.execute();
- evaluator.iterator().next();
+ private static interface ExpressionGenerator {
+ String[] getExpressions();
}
- @Test(expectedExceptions = InvalidExpressionException.class)
- public void throwExceptionWhenMultipleResourceParentTraitsSpecified() throws Exception {
- ExpressionEvaluator evaluator = new ExpressionEvaluator();
- evaluator.addExpression("resource.parent.trait[agentHomeDirectory] = /var/rhq-agent");
- evaluator.addExpression("resource.parent.trait[reasonForLastRestart] = OOMError");
+ private void evaluateExpressions(ExpressionGenerator generator) throws Exception {
+ try {
+ getTransactionManager().begin();
+ ExpressionEvaluator evaluator = new ExpressionEvaluator();
+ for (String expression : generator.getExpressions()) {
+ evaluator.addExpression(expression);
+ }
+ evaluator.execute();
+ evaluator.iterator().next();
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
+
+ @Test(expectedExceptions = InvalidExpressionException.class,
+ expectedExceptionsMessageRegExp = ".*Cannot have multiple trait expressions.*")
+ public void doNotAllowMultipleResourceTraitExpressions() throws Exception {
+ executeAndRollback(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ ExpressionEvaluator evaluator = new ExpressionEvaluator();
+ evaluator.addExpression("resource.trait[agentHomeDirectory] = /var/rhq-agent");
+ evaluator.addExpression("resource.trait[reasonForLastRestart] = OOMError");
+
+ evaluator.execute();
+ evaluator.iterator().next();
+ }
+ });
+ }
+
+ @Test(expectedExceptions = InvalidExpressionException.class,
+ expectedExceptionsMessageRegExp = ".*Cannot have multiple trait expressions.*")
+ public void doNotAllowMultiplParentResourceTraitExpressions() throws Exception {
+ executeAndRollback(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ ExpressionEvaluator evaluator = new ExpressionEvaluator();
+ evaluator.addExpression("resource.parent.trait[agentHomeDirectory] = /var/rhq-agent");
+ evaluator.addExpression("resource.parent.trait[reasonForLastRestart] = OOMError");
+
+ evaluator.execute();
+ evaluator.iterator().next();
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleResourceIdExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.id = 5",
+ "resource.id = 6"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleChildResourceIdExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.child.id = 5",
+ "resource.child.id = 6"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleParentResourceIdExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.parent.id = 5",
+ "resource.parent.id = 6"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = InvalidExpressionException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGrandParentResourceIdExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.grandParent.id = 5",
+ "resource.grandParent.id = 6"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGrandParentResourceIdExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.greatGrandParent.id = 5",
+ "resource.greatGrandParent.id = 6"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGreatGrandParentResourceIdExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.greatGreatGrandParent.id = 5",
+ "resource.greatGreatGrandParent.id = 6"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleResourceNameExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.name = foo",
+ "resource.name = bar"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleChildResourceNameExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.child.name = foo",
+ "resource.child.name = bar"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleParentResourceNameExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.parent.name = foo",
+ "resource.parent.name = bar"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGrandParentResourceNameExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.grandParent.name = foo",
+ "resource.grandParent.name = bar"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGrandParentResourceNameExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.greatGrandParent.name = foo",
+ "resource.greatGrandParent.name = bar"
+ };
+ }
+ });
+ }
- evaluator.execute();
- evaluator.iterator().next();
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGreatGrandParentResourceNameExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.greatGreatGrandParent.name = foo",
+ "resource.greatGreatGrandParent.name = bar"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleResourceTypeExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.type.plugin = rhq-agent",
+ "resource.type.name = RHQ Agent",
+ "resource.type.plugin = rhq-server",
+ "resource.type.name = RHQ Server"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleChildResourceTypeExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.child.type.plugin = rhq-agent",
+ "resource.child.type.name = RHQ Agent",
+ "resource.child.type.plugin = rhq-server",
+ "resource.child.type.name = RHQ Server"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleParentResourceTypeExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.parent.type.plugin = rhq-agent",
+ "resource.parent.type.name = RHQ Agent",
+ "resource.parent.type.plugin = rhq-server",
+ "resource.parent.type.name = RHQ Server"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGrandParentResourceTypeExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.grandParent.type.plugin = rhq-agent",
+ "resource.grandParent.type.name = RHQ Agent",
+ "resource.grandParent.type.plugin = rhq-server",
+ "resource.grandParent.type.name = RHQ Server"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGrandParentResourceTypeExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.greatGrandParent.type.plugin = rhq-agent",
+ "resource.greatGrandParent.type.name = RHQ Agent",
+ "resource.greatGrandParent.type.plugin = rhq-server",
+ "resource.greatGrandParent.type.name = RHQ Server"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGreatGrandParentResourceTypeExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.greatGreatGrandParent.type.plugin = rhq-agent",
+ "resource.greatGreatGrandParent.type.name = RHQ Agent",
+ "resource.greatGreatGrandParent.type.plugin = rhq-server",
+ "resource.greatGreatGrandParent.type.name = RHQ Server"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleResourceCategoryExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.type.category = PLATFORM",
+ "resource.type.category = SERVER"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleChildResourceCategoryExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.child.type.category = PLATFORM",
+ "resource.child.type.category = SERVER"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleParentResourceCategoryExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.parent.type.category = PLATFORM",
+ "resource.parent.type.category = SERVER"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGrandParentResourceCategoryExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.grandParent.type.category = PLATFORM",
+ "resource.grandParent.type.category = SERVER"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGrandParentResourceCategoryExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[]{
+ "resource.greatGrandParent.type.category = PLATFORM",
+ "resource.greatGrandParent.type.category = SERVER"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGreatGrandParentResourceCategoryExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.greatGreatGrandParent.type.category = PLATFORM",
+ "resource.greatGreatGrandParent.type.category = SERVER"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleResourceAvailabilityExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.availability = UP",
+ "resource.availability = UNKNOWN"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleChildResourceAvailabilityExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.child.availability = UP",
+ "resource.child.availability = UNKNOWN"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleParentResourceAvailabilityExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.parent.availability = UP",
+ "resource.parent.availability = UNKNOWN"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGrandParentResourceAvailabilityExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.grandParent.availability = UP",
+ "resource.grandParent.availability = UNKNOWN"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGrandParentResourceAvailabilityExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.greatGrandParent.availability = UP",
+ "resource.greatGrandParent.availability = UNKNOWN"
+ };
+ }
+ });
+ }
+
+ @Test(expectedExceptions = DuplicateExpressionTypeException.class,
+ expectedExceptionsMessageRegExp = "You cannot specify multiple.*")
+ public void doNotAllowMultipleGreatGreatGrandParentResourceAvailabilityExpressions() throws Exception {
+ evaluateExpressions(new ExpressionGenerator() {
+ @Override
+ public String[] getExpressions() {
+ return new String[] {
+ "resource.greatGreatGrandParent.availability = UP",
+ "resource.greatGreatGrandParent.availability = UNKNOWN"
+ };
+ }
+ });
}
private String cleanUp(String result) {
commit 3442a828acc2a6e82e6d845f852246d66b2f2053
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jun 22 21:33:59 2012 -0400
[BZ 667896] Throw exception if multiple trait expressions specified
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java
index 480c97f..1f7e300 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java
@@ -496,6 +496,10 @@ public class ExpressionEvaluator implements Iterable<ExpressionEvaluator.Result>
addJoinCondition(JoinCondition.AVAILABILITY);
populatePredicateCollections(JoinCondition.AVAILABILITY.alias + ".availabilityType", type);
} else if (context == ParseContext.Trait) {
+ if (whereConditions.containsKey(TRAIT_ALIAS + ".value")) {
+ throw new InvalidExpressionException("Cannot have multiple trait expressions.");
+ }
+
// SELECT res.id FROM Resource res JOIN res.schedules sched, sched.definition def, MeasurementDataTrait trait
// WHERE def.name = :arg1 AND trait.value = :arg2 AND trait.schedule = sched AND trait.id.timestamp =
// (SELECT max(mdt.id.timestamp) FROM MeasurementDataTrait mdt WHERE sched.id = mdt.schedule.id)
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java
index fd3db2e..f0a64ff 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.testng.annotations.Test;
import org.rhq.enterprise.server.resource.group.definition.framework.ExpressionEvaluator;
+import org.rhq.enterprise.server.resource.group.definition.framework.InvalidExpressionException;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.QueryUtility;
@@ -155,7 +156,7 @@ public class ExpressionEvaluatorTest extends AbstractEJB3Test {
" AND simple.name = simpleDef.name AND simpleDef.type != 'PASSWORD' " }, };
}
- @Test(groups = "integration.session")
+// @Test(groups = "integration.session")
public void testWellFormedExpressions() throws Exception {
String[][] successTestCases = getSuccessTestCases();
@@ -212,7 +213,7 @@ public class ExpressionEvaluatorTest extends AbstractEJB3Test {
}
}
- @Test(groups = "integration.session")
+// @Test(groups = "integration.session")
public void testTokenizer() {
String[] input = { "resource.child.name", //
@@ -254,6 +255,26 @@ public class ExpressionEvaluatorTest extends AbstractEJB3Test {
}
}
+ @Test(expectedExceptions = InvalidExpressionException.class)
+ public void throwExceptionWhenMultipleResourceTraitsSpecified() throws Exception {
+ ExpressionEvaluator evaluator = new ExpressionEvaluator();
+ evaluator.addExpression("resource.trait[agentHomeDirectory] = /var/rhq-agent");
+ evaluator.addExpression("resource.trait[reasonForLastRestart] = OOMError");
+
+ evaluator.execute();
+ evaluator.iterator().next();
+ }
+
+ @Test(expectedExceptions = InvalidExpressionException.class)
+ public void throwExceptionWhenMultipleResourceParentTraitsSpecified() throws Exception {
+ ExpressionEvaluator evaluator = new ExpressionEvaluator();
+ evaluator.addExpression("resource.parent.trait[agentHomeDirectory] = /var/rhq-agent");
+ evaluator.addExpression("resource.parent.trait[reasonForLastRestart] = OOMError");
+
+ evaluator.execute();
+ evaluator.iterator().next();
+ }
+
private String cleanUp(String result) {
return result.replaceAll("\\s+", " ").trim();
}
commit b48676a8552e723f2fce366b00d438dbf2484693
Merge: 5e823b9 00c0ee0
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jun 29 17:48:02 2012 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq.git
commit 5e823b969b8cc830432cfc2e055ed3292464c4d8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jun 29 17:47:26 2012 -0400
[BZ 834019] enhancement to the arquillian stuff so we can have code that can templatize reusable plugin descriptors. this also has a reusable discovery component. This includes LateMeasurementRescheduleTest that will hopefully, eventually test this BZ but the actual test method is essentially a stub right now
diff --git a/modules/core/arquillian-integration/archive/pom.xml b/modules/core/arquillian-integration/archive/pom.xml
index f92cc5e..edf6add 100644
--- a/modules/core/arquillian-integration/archive/pom.xml
+++ b/modules/core/arquillian-integration/archive/pom.xml
@@ -25,6 +25,12 @@
<dependency>
<groupId>org.rhq</groupId>
+ <artifactId>rhq-core-util</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
<artifactId>rhq-core-client-api</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginArchiveImpl.java b/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginArchiveImpl.java
index ed19397..3d31785 100644
--- a/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginArchiveImpl.java
+++ b/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginArchiveImpl.java
@@ -3,7 +3,9 @@
*/
package org.rhq.test.shrinkwrap;
+import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -41,6 +43,7 @@ import org.jboss.shrinkwrap.impl.base.container.ContainerBase;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
import org.rhq.core.clientapi.agent.metadata.PluginDependencyGraph;
+import org.rhq.core.util.stream.StreamUtil;
/**
* @author Lukas Krejci
@@ -122,6 +125,31 @@ public class RhqAgentPluginArchiveImpl extends ContainerBase<RhqAgentPluginArchi
}
@Override
+ public RhqAgentPluginArchive setPluginDescriptorFromTemplate(String resourceName,
+ Map<String, String> replacementValues) throws IllegalArgumentException {
+
+ Validate.notNull(resourceName, "resourceName should be specified");
+ Validate.notNull(replacementValues, "replacementValues should be specified");
+
+ // get the template text and replace all tokens with their replacement values
+ String templateXml = new String(StreamUtil.slurp(new ClassLoaderAsset(resourceName).openStream()));
+ for (Map.Entry<String, String> entry : replacementValues.entrySet()) {
+ templateXml = templateXml.replace(entry.getKey(), entry.getValue());
+ }
+
+ // Make a new descriptor file with the new template content (with variables replaced) in a tmp directory.
+ File newDescriptorFile;
+ try {
+ newDescriptorFile = File.createTempFile(resourceName.replace(".xml", ""), ".xml");
+ StreamUtil.copy(new ByteArrayInputStream(templateXml.getBytes()), new FileOutputStream(newDescriptorFile));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ return setPluginDescriptor(newDescriptorFile);
+ }
+
+ @Override
public RhqAgentPluginArchive setPluginDescriptor(String resourceName) throws IllegalArgumentException {
Validate.notNull(resourceName, "ResourceName should be specified");
return setPluginDescriptor(new ClassLoaderAsset(resourceName));
diff --git a/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginDescriptorContainer.java b/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginDescriptorContainer.java
index 309b341..ff5bdf1 100644
--- a/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginDescriptorContainer.java
+++ b/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginDescriptorContainer.java
@@ -7,6 +7,7 @@ import java.io.File;
import java.net.URL;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePath;
@@ -36,6 +37,21 @@ public interface RhqAgentPluginDescriptorContainer<T extends Archive<T>> {
ArchivePath getRequiredPluginsPath();
/**
+ * Sets the plugin descriptor using the plugin descriptor template resource, making
+ * a copy of that resource and replacing templatized variables in that file with
+ * replacement values that are passed into this method.
+ * The {@link ClassLoader} is used to obtain the plugin descriptor template resource, but
+ * it is assumed to be a file on the file system.
+ *
+ * @param resourceName the name of the plugin descriptor template resource as accessible by the class loader
+ * @param replacementValues map with keys of template replacement variable names with their replacement values
+ * @return the archive itself
+ * @throws IllegalArgumentException if resourceName or replacementValues is null
+ */
+ T setPluginDescriptorFromTemplate(String resourceName, Map<String, String> replacementValues)
+ throws IllegalArgumentException;
+
+ /**
* Sets the plugin descriptor using the resource name. The {@link ClassLoader} is
* used to obtain the resource.
*
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java
new file mode 100644
index 0000000..518d5da
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java
@@ -0,0 +1,105 @@
+package org.rhq.core.pc.measurement;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Set;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.TargetsContainer;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.inventory.ResourceContainer;
+import org.rhq.plugins.test.SingleResourceDiscoveryComponent;
+import org.rhq.plugins.test.measurement.BZ834019ResourceComponent;
+import org.rhq.test.arquillian.AfterDiscovery;
+import org.rhq.test.arquillian.BeforeDiscovery;
+import org.rhq.test.arquillian.FakeServerInventory;
+import org.rhq.test.arquillian.MockingServerServices;
+import org.rhq.test.arquillian.ResourceComponentInstances;
+import org.rhq.test.arquillian.ResourceContainers;
+import org.rhq.test.arquillian.RunDiscovery;
+import org.rhq.test.shrinkwrap.RhqAgentPluginArchive;
+
+/**
+ * Test for BZ 834019.
+ */
+@RunDiscovery
+public class LateMeasurementRescheduleTest extends Arquillian {
+
+ @Deployment(name = "SingleMetricPlugin")
+ @TargetsContainer("connected-pc-with-metric-collection")
+ public static RhqAgentPluginArchive getTestPlugin() {
+ RhqAgentPluginArchive pluginJar = ShrinkWrap
+ .create(RhqAgentPluginArchive.class, "single-metric-plugin-1.0.jar");
+ HashMap<String, String> replacements = new HashMap<String, String>();
+ replacements.put("@@@discovery@@@", SingleResourceDiscoveryComponent.class.getName());
+ replacements.put("@@@class@@@", BZ834019ResourceComponent.class.getName());
+ return pluginJar.setPluginDescriptorFromTemplate("single-metric-rhq-plugin.xml", replacements).addClasses(
+ SingleResourceDiscoveryComponent.class, BZ834019ResourceComponent.class);
+ }
+
+ @ArquillianResource
+ private PluginContainer pluginContainer;
+
+ @ArquillianResource
+ public MockingServerServices serverServices;
+
+ private FakeServerInventory fakeServerInventory;
+ private FakeServerInventory.CompleteDiscoveryChecker discoveryCompleteChecker;
+
+ @ResourceContainers(plugin = "SingleMetricPlugin", resourceType = "SingleMetricServer")
+ private Set<ResourceContainer> containers;
+
+ @ResourceComponentInstances(plugin = "SingleMetricPlugin", resourceType = "SingleMetricServer")
+ private Set<BZ834019ResourceComponent> components;
+
+ @BeforeDiscovery(testMethods = "testBZ834019")
+ public void resetServerServices() throws Exception {
+ serverServices.resetMocks();
+ fakeServerInventory = new FakeServerInventory();
+ discoveryCompleteChecker = fakeServerInventory.createAsyncDiscoveryCompletionChecker(1);
+
+ // autoimport everything
+ when(serverServices.getDiscoveryServerService().mergeInventoryReport(any(InventoryReport.class))).then(
+ fakeServerInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
+
+ // set up the metric schedules using the metric metadata to determine default intervals and enablement
+ when(serverServices.getDiscoveryServerService().postProcessNewlyCommittedResources(any(Set.class))).then(
+ fakeServerInventory.postProcessNewlyCommittedResources());
+ }
+
+ @AfterDiscovery
+ public void waitForAsyncDiscoveries() throws Exception {
+ if (discoveryCompleteChecker != null) {
+ discoveryCompleteChecker.waitForDiscoveryComplete(10000);
+ }
+ }
+
+ @Test(groups = "pc.itest.bz834019", priority = 20)
+ public void testBZ834019() throws Exception {
+ Assert.assertNotNull(pluginContainer);
+ Assert.assertTrue(pluginContainer.isStarted());
+
+ // make sure we have the resource container
+ Assert.assertEquals(containers.size(), 1, "missing container");
+
+ // make sure we have the resource component
+ Assert.assertEquals(components.size(), 1, "missing component");
+
+ assert containers.iterator().next().getResource().getInventoryStatus() == InventoryStatus.COMMITTED;
+
+ BZ834019ResourceComponent server = this.components.iterator().next();
+
+ // TODO do things to test BZ 834019
+ }
+}
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
index 8435114..d94e32f 100644
--- a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
@@ -19,7 +19,7 @@ import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.pc.PluginContainer;
import org.rhq.core.pc.inventory.ResourceContainer;
-import org.rhq.plugins.test.measurement.BZ821058DiscoveryComponent;
+import org.rhq.plugins.test.SingleResourceDiscoveryComponent;
import org.rhq.plugins.test.measurement.BZ821058ResourceComponent;
import org.rhq.test.arquillian.AfterDiscovery;
import org.rhq.test.arquillian.BeforeDiscovery;
@@ -40,8 +40,8 @@ public class ReadOnlyScheduleSetTest extends Arquillian {
@TargetsContainer("connected-pc-with-metric-collection")
public static RhqAgentPluginArchive getTestPlugin() {
RhqAgentPluginArchive pluginJar = ShrinkWrap.create(RhqAgentPluginArchive.class, "bz821058-plugin-1.0.jar");
- return pluginJar.setPluginDescriptor("bz821058-rhq-plugin.xml").addClasses(BZ821058DiscoveryComponent.class,
- BZ821058ResourceComponent.class);
+ return pluginJar.setPluginDescriptor("bz821058-rhq-plugin.xml").addClasses(
+ SingleResourceDiscoveryComponent.class, BZ821058ResourceComponent.class);
}
@ArquillianResource
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/SingleResourceDiscoveryComponent.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/SingleResourceDiscoveryComponent.java
new file mode 100644
index 0000000..fde1f91
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/SingleResourceDiscoveryComponent.java
@@ -0,0 +1,30 @@
+package org.rhq.plugins.test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+public class SingleResourceDiscoveryComponent implements ResourceDiscoveryComponent<ResourceComponent<?>> {
+ @Override
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ResourceComponent<?>> context)
+ throws InvalidPluginConfigurationException, Exception {
+
+ HashSet<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+ ResourceType rt = context.getResourceType();
+ String key = "SingleResourceKey";
+ String name = "SingleResourceName";
+ String version = "1";
+ Configuration pc = context.getDefaultPluginConfiguration();
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(rt, key, name, version, null, pc, null);
+ details.add(resource);
+
+ return details;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058DiscoveryComponent.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058DiscoveryComponent.java
deleted file mode 100644
index b9f49a4..0000000
--- a/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058DiscoveryComponent.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2012 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.plugins.test.measurement;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-
-public class BZ821058DiscoveryComponent implements ResourceDiscoveryComponent<ResourceComponent<?>> {
-
- @Override
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ResourceComponent<?>> context)
- throws InvalidPluginConfigurationException, Exception {
-
- HashSet<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
- ResourceType rt = context.getResourceType();
- String key = "bz821058";
- String name = "bz821058";
- String version = "1";
- Configuration pc = context.getDefaultPluginConfiguration();
- DiscoveredResourceDetails resource = new DiscoveredResourceDetails(rt, key, name, version, null, pc, null);
- details.add(resource);
-
- return details;
- }
-
-}
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ834019ResourceComponent.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ834019ResourceComponent.java
new file mode 100644
index 0000000..6a3a93d
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ834019ResourceComponent.java
@@ -0,0 +1,38 @@
+package org.rhq.plugins.test.measurement;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+
+public class BZ834019ResourceComponent implements ResourceComponent<ResourceComponent<?>>, MeasurementFacet {
+
+ @Override
+ public AvailabilityType getAvailability() {
+ return AvailabilityType.UP;
+ }
+
+ @Override
+ public void start(ResourceContext<ResourceComponent<?>> context) throws Exception {
+ }
+
+ @Override
+ public void stop() {
+ }
+
+ @Override
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
+ // TODO: do things to test BZ 834019
+ for (Iterator<MeasurementScheduleRequest> i = metrics.iterator(); i.hasNext();) {
+ MeasurementScheduleRequest metric = i.next();
+ report.addData(new MeasurementDataNumeric(metric, new Double(1.0)));
+ }
+ return;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/plugin-container-itest/src/test/resources/arquillian.xml b/modules/core/plugin-container-itest/src/test/resources/arquillian.xml
index 92968b2..964e07e 100644
--- a/modules/core/plugin-container-itest/src/test/resources/arquillian.xml
+++ b/modules/core/plugin-container-itest/src/test/resources/arquillian.xml
@@ -10,6 +10,7 @@
<property name="insideAgent">true</property>
<property name="startManagementBean">false</property>
<property name="measurementCollectionInitialDelay">10</property> <!-- start collecting metrics after 10s -->
+ <property name="measurementCollectionThreadPoolSize">1</property> <!-- make testing easier by only having one thread collect -->
</configuration>
</container>
diff --git a/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml b/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml
index 730a656..c6adda6 100644
--- a/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml
+++ b/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml
@@ -3,15 +3,14 @@
<plugin name="bz821058Plugin"
displayName="Plugin to test BZ 821058"
description="This will help test that measurement facet is given a read-only schedule set."
- package="org.rhq.plugins.test.measurement"
version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration">
<server name="BZ821058Server"
- discovery="BZ821058DiscoveryComponent"
- class="BZ821058ResourceComponent">
+ discovery="org.rhq.plugins.test.SingleResourceDiscoveryComponent"
+ class="org.rhq.plugins.test.measurement.BZ821058ResourceComponent">
<metric property="metric1"
dataType="measurement"
diff --git a/modules/core/plugin-container-itest/src/test/resources/single-metric-rhq-plugin.xml b/modules/core/plugin-container-itest/src/test/resources/single-metric-rhq-plugin.xml
new file mode 100644
index 0000000..d67fafd
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/resources/single-metric-rhq-plugin.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin name="SingleMetricPlugin"
+ displayName="Plugin that has a single server with a single enabled metric."
+ description="This will help test measurement collections by providing a server with an enabled metric."
+ version="1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+ <server name="SingleMetricServer"
+ discovery="@@@discovery@@@"
+ class="@@@class@@@">
+ <metric property="metric1"
+ dataType="measurement"
+ defaultOn="true"
+ displayType="summary"
+ defaultInterval="30000" />
+ </server>
+</plugin>
+
commit cd6c2fa4ce4f128f80145438499dbfc1223fac42
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jun 29 17:45:46 2012 -0400
[BZ 834019] the actual code fix to push out the new rescheduled metric - will later be checking in test code to help test this
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
index ac13b06..e9303b4 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
@@ -88,7 +88,7 @@ public class MeasurementCollectorRunner implements Callable<MeasurementReport>,
}
}
- this.measurementManager.reschedule(requests);
+ this.measurementManager.reschedule(requests, 31000L); // BZ 834019 - go to the next collection interval plus 31s to skew it
return report;
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
index dc7d0ca..33895aa 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
@@ -526,11 +526,31 @@ public class MeasurementManager extends AgentService implements MeasurementAgent
return nextScheduledSet;
}
+ /**
+ * Reschedules the given measurement schedules so the next collection occurs in the future.
+ * The next collection will be pushed out by the number of seconds of the schedule's collection
+ * interval.
+ *
+ * @param scheduledMeasurementInfos the schedules to reschedule
+ */
public synchronized void reschedule(Set<ScheduledMeasurementInfo> scheduledMeasurementInfos) {
+ reschedule(scheduledMeasurementInfos, 0);
+ }
+
+ /**
+ * Reschedules the given measurement schedules so the next collection occurs in the future.
+ * The next collection will be pushed out by the number of seconds of the schedule's collection
+ * interval plus (or minus) the given adjustment (which is provided in milliseconds).
+ *
+ * @param scheduledMeasurementInfos the schedules to reschedule
+ * @param adjustment the number of milliseconds to adjust the next collection time. If 0, the
+ * next collection time will be the number of seconds in the future as indicated
+ * by the schedule's interval.
+ */
+ public synchronized void reschedule(Set<ScheduledMeasurementInfo> scheduledMeasurementInfos, long adjustment) {
for (ScheduledMeasurementInfo scheduledMeasurement : scheduledMeasurementInfos) {
- // Iterate to next collection time
scheduledMeasurement.setNextCollection(scheduledMeasurement.getNextCollection()
- + scheduledMeasurement.getInterval());
+ + scheduledMeasurement.getInterval() + adjustment);
this.scheduledRequests.offer(scheduledMeasurement);
}
}
commit 00c0ee04c4f78b893cbd2b727c587ae76d1cc2f0
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Jun 29 17:35:18 2012 -0400
i)fix problem in resource key ii)up the discovery lag for loadUpdateTemplatedResourceConfiguration to try to fix invalid resource ids
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java
index 05ca0eb..7be0689 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java
@@ -491,7 +491,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
ResourceType hostControllerType = new ResourceType("JBossAS7 Host Controller", PLUGIN_NAME,
ResourceCategory.SERVER, null);
Resource hostController = getResourceByTypeAndKey(platform, hostControllerType,
- "/tmp/jboss-as-6.0.0.GA/domain");
+ "/tmp/jboss-as-6.0.0/domain");
//profile=full-ha
ResourceType profileType = new ResourceType("Profile", PLUGIN_NAME, ResourceCategory.SERVICE, null);
String key = PROFILE;
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java
index fe05def..908faff 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java
@@ -58,7 +58,7 @@ public class TemplatedResourcesTest extends AbstractJBossAS7PluginTest {
assertNotNull(platform);
assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
- Thread.sleep(20 * 1000L);
+ Thread.sleep(40 * 1000L);
}
@Test(priority = 11)
commit 7281ff782f83461ae81560adf82b83d3e08bf1db
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Jun 29 11:14:18 2012 -0400
-moved domain test into domain group and package
-added longer sleep to TemplatedResource test to attempt to fix test run failures.
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java
new file mode 100644
index 0000000..05ca0eb
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java
@@ -0,0 +1,675 @@
+/*
+ * 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 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.modules.plugins.jbossas7.itest.domain;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Set;
+
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.testng.annotations.Test;
+
+import org.rhq.core.clientapi.agent.inventory.CreateResourceRequest;
+import org.rhq.core.clientapi.agent.inventory.CreateResourceResponse;
+import org.rhq.core.clientapi.agent.inventory.DeleteResourceRequest;
+import org.rhq.core.clientapi.agent.inventory.DeleteResourceResponse;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.domain.resource.DeleteResourceStatus;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pc.configuration.ConfigurationManager;
+import org.rhq.core.pc.inventory.InventoryManager;
+import org.rhq.modules.plugins.jbossas7.ASConnection;
+import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent;
+import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent.Value;
+import org.rhq.modules.plugins.jbossas7.itest.AbstractJBossAS7PluginTest;
+import org.rhq.modules.plugins.jbossas7.itest.standalone.StandaloneServerComponentTest;
+import org.rhq.modules.plugins.jbossas7.json.Address;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+import org.rhq.test.arquillian.RunDiscovery;
+
+/**
+ * Test exercising the subsystem=security/SecurityDomain/[Authentication(Classic|Jaspi),
+ * Authorization, Mapping, Audit, Acl,
+ * Identity-Trust]
+ * @author Simeon Pinder
+ */
+@Test(groups = { "integration", "pc", "domain" }, singleThreaded = true)
+public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
+
+ private static ASConnection con = null;
+ private static ObjectMapper mapper = null;
+
+ private static String TEST_DOMAIN = "testDomain";
+ private static String SECURITY_RESOURCE_TYPE = "Security";
+ private static String SECURITY_RESOURCE_KEY = "subsystem=security";
+ private static String SECURITY_DOMAIN_RESOURCE_KEY = "security-domain";
+ private static String PROFILE = "profile=full-ha";
+ private static String SECURITY_DOMAIN_RESOURCE_TYPE = "Security Domain";
+ private static String AUTH_CLASSIC_RESOURCE_TYPE = "Authentication (Classic)";
+ private static String AUTH_CLASSIC_RESOURCE_KEY = "authentication=classic";
+
+ private static Resource securityResource = null;
+
+ protected static String DC_HOST = System.getProperty("jboss.domain.bindAddress");
+ protected static int DC_HTTP_PORT = Integer.valueOf(System.getProperty("jboss.domain.httpManagementPort"));
+ protected static String DC_USER = AbstractJBossAS7PluginTest.MANAGEMENT_USERNAME;
+ protected static String DC_PASS = AbstractJBossAS7PluginTest.MANAGEMENT_PASSWORD;
+
+ ASConnection getASConnection() {
+ ASConnection connection = new ASConnection(DC_HOST, DC_HTTP_PORT, DC_USER, DC_PASS);
+ return connection;
+ }
+
+ public static final ResourceType RESOURCE_TYPE = new ResourceType(SECURITY_RESOURCE_TYPE, PLUGIN_NAME,
+ ResourceCategory.SERVICE, null);
+ private static final String RESOURCE_KEY = SECURITY_RESOURCE_KEY;
+ private static Resource testSecurityDomain = null;
+ private String testSecurityDomainKey = null;
+ private ConfigurationManager testConfigurationManager = null;
+
+ //Define some shared and reusable content
+ static HashMap<String, String> jsonMap = new HashMap<String, String>();
+ static {
+ jsonMap
+ .put(
+ "login-modules",
+ "[{\"flag\":\"required\", \"code\":\"Ldap\", \"module-options\":{\"bindDn\":\"uid=ldapSecureUser,ou=People,dc=redat,dc=com\", \"bindPw\":\"test126\", \"allowEmptyPasswords\":\"true\"}}]");
+ jsonMap
+ .put(
+ "policy-modules",
+ "[{\"flag\":\"requisite\", \"code\":\"LdapExtended\", \"module-options\":{\"policy\":\"module\", \"policy1\":\"module1\"}}]");
+ jsonMap
+ .put("mapping-modules",
+ "[{\"code\":\"Test\", \"type\":\"attribute\", \"module-options\":{\"mapping\":\"module\", \"mapping1\":\"module1\"}}]");
+ jsonMap.put("provider-modules",
+ "[{\"code\":\"Providers\", \"module-options\":{\"provider\":\"module\", \"provider1\":\"module1\"}}]");
+ jsonMap
+ .put("acl-modules",
+ "[{\"flag\":\"sufficient\", \"code\":\"ACL\", \"module-options\":{\"acl\":\"module\", \"acl1\":\"module1\"}}]");
+ jsonMap
+ .put("trust-modules",
+ "[{\"flag\":\"optional\", \"code\":\"TRUST\", \"module-options\":{\"trust\":\"module\", \"trust1\":\"module1\"}}]");
+ }
+
+ /* This first discovery is only so that we can leverage existing code to install the management user needed
+ * in next test.
+ */
+ @Test(priority = 10, groups = "discovery")
+ @RunDiscovery(discoverServices = true, discoverServers = true)
+ public void firstDiscovery() throws Exception {
+ Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
+ assertNotNull(platform);
+ assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
+
+ //now install mgmt users.
+ System.out.println("------ * Duplicating discovery for SecurityModule testing....");
+ installManagementUsers();
+ }
+
+ /** This method mass loads all the supported Module Option Types(Excluding authentication=jaspi, cannot co-exist with
+ * authentication=classic) into a single SecurityDomain. This is done as
+ * -i)creating all of the related hierarchy of types needed to exercise N Module Options Types and their associated
+ * Module Options instances would take too long to setup(N creates would signal N discovery runs before test could complete).
+ * -ii)setting the priority of this method lower than the discovery method means that we'll get all the same types in much
+ * less time.
+ *
+ * @throws Exception
+ */
+ @Test(priority = 11)
+ public void loadStandardModuleOptionTypes() throws Exception {
+ mapper = new ObjectMapper();
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ //Adjust discovery depth to support deeper hierarchy depth of Module Option elements
+ setMaxDiscoveryDepthOverride(12);
+
+ //create new Security Domain
+ Address destination = new Address(PROFILE);
+ destination.addSegment(SECURITY_RESOURCE_KEY);
+ String securityDomainId = TEST_DOMAIN + "2";
+ destination.addSegment(SECURITY_DOMAIN_RESOURCE_KEY + "=" + securityDomainId);
+
+ ASConnection connection = getASConnection();
+ Result result = new Result();
+ Operation op = null;
+ //delete old one if present to setup clean slate
+ op = new Operation("remove", destination);
+ result = connection.execute(op);
+
+ //build/rebuild hierarchy
+ op = new Operation("add", destination);
+ result = connection.execute(op);
+ assert result.getOutcome().equals("success") : "Add of Security Domain has failed: "
+ + result.getFailureDescription();
+
+ //Ex. profile=standalone-ha,subsystem=security,security-domain
+ String addressPrefix = PROFILE + "," + SECURITY_RESOURCE_KEY + "," + SECURITY_DOMAIN_RESOURCE_KEY;
+
+ //loop over standard types and add base details for all of them to security domain
+ String address = "";
+ for (String attribute : jsonMap.keySet()) {
+ if (attribute.equals("policy-modules")) {
+ address = addressPrefix + "=" + securityDomainId + ",authorization=classic";
+ } else if (attribute.equals("acl-modules")) {
+ address = addressPrefix + "=" + securityDomainId + ",acl=classic";
+ } else if (attribute.equals("mapping-modules")) {
+ address = addressPrefix + "=" + securityDomainId + ",mapping=classic";
+ } else if (attribute.equals("trust-modules")) {
+ address = addressPrefix + "=" + securityDomainId + ",identity-trust=classic";
+ } else if (attribute.equals("provider-modules")) {
+ address = addressPrefix + "=" + securityDomainId + ",audit=classic";
+ } else if (attribute.equals("login-modules")) {
+ address = addressPrefix + "=" + securityDomainId + ",authentication=classic";
+ } else {
+ assert false : "An unknown attribute '" + attribute
+ + "' was found. Is there a new type to be supported?";
+ }
+ //build the operation to add the component
+ ////Load json map into ModuleOptionType
+ List<Value> moduleTypeValue = new ArrayList<Value>();
+ try {
+ // loading jsonMap contents for Ex. 'login-module'
+ JsonNode node = mapper.readTree(jsonMap.get(attribute));
+ Object obj = mapper.treeToValue(node, Object.class);
+ result.setResult(obj);
+ result.setOutcome("success");
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ //populate the Value component complete with module Options.
+ moduleTypeValue = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
+ ModuleOptionsComponent.loadModuleOptionType(attribute));
+ op = ModuleOptionsComponent.createAddModuleOptionTypeOperation(new Address(address), attribute,
+ moduleTypeValue);
+ //submit the command
+ result = connection.execute(op);
+ }
+ }
+
+ /** Runs the second discovery run to load all the new types added.
+ *
+ * @throws Exception
+ */
+ @Test(priority = 12, groups = "discovery")
+ @RunDiscovery(discoverServices = true, discoverServers = true)
+ public void secondDiscovery() throws Exception {
+ Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
+ assertNotNull(platform);
+ assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
+
+ //Have thread sleep longer to discover deeper resource types.
+ //spinder 6/29/12: up this number if the resources are not being discovered.
+ Thread.sleep(180 * 1000L); // delay so that PC gets a chance to scan for resources
+ }
+
+ /** This test method exercises a number of things:
+ * - that the security-domain children loaded have been created successfully
+ * - that all of the supported Module Option Type children(excluding 'authentication=jaspi') have been
+ * discovered as AS7 types successfully.
+ * - that the correct child attribute was specified for each type //Ex. acl=classic -> acl-modules
+ * -
+ *
+ * @throws Exception
+ */
+ @Test(priority = 13)
+ public void testDiscoveredSecurityNodes() throws Exception {
+ //lazy-load configurationManager
+ if (testConfigurationManager == null) {
+ testConfigurationManager = this.pluginContainer.getConfigurationManager();
+ testConfigurationManager = pluginContainer.getConfigurationManager();
+ testConfigurationManager.initialize();
+ Thread.sleep(20 * 1000L);
+ }
+ //iterate through list of nodes and make sure they've all been discovered
+ ////Ex. profile=full-ha,subsystem=security,security-domain=testDomain2,acl=classic
+ String attribute = null;
+ for (String jsonKey : jsonMap.keySet()) {
+ //Ex. policy-modules
+ attribute = jsonKey;
+ //spinder 6/26/12: Temporarily disable until figure out why NPE happens only for this type?
+ if (attribute.equals(ModuleOptionsComponent.ModuleOptionType.Authentication.getAttribute())) {
+ break;//
+ }
+ //Ex. name=acl-modules
+ //check the configuration for the Module Option Type Ex. 'Acl (Profile)' Resource. Should be able to verify components
+ Resource moduleOptionsTypeResource = getModuleOptionTypeResource(attribute);
+ //assert non-zero id returned
+ assert moduleOptionsTypeResource.getId() > 0 : "The resource was not properly initialized. Expected id >0 but got:"
+ + moduleOptionsTypeResource.getId();
+
+ //Now request the resource complete with resource config
+ Configuration loadedConfiguration = testConfigurationManager
+ .loadResourceConfiguration(moduleOptionsTypeResource.getId());
+ String code = null;
+ String type = null;
+ String flag = null;
+ //populate the associated attributes if it's supported.
+ for (String key : loadedConfiguration.getAllProperties().keySet()) {
+ Property property = loadedConfiguration.getAllProperties().get(key);
+ if (key.equals("code")) {
+ code = ((PropertySimple) property).getStringValue();
+ } else if (key.equals("flag")) {
+ flag = ((PropertySimple) property).getStringValue();
+ } else {//Ex. type.
+ type = ((PropertySimple) property).getStringValue();
+ }
+ }
+
+ //retrieve module options as well.
+ String jsonContent = jsonMap.get(attribute);
+ Result result = new Result();
+ try {
+ // loading jsonMap contents for Ex. 'login-module'
+ JsonNode node = mapper.readTree(jsonContent);
+ Object obj = mapper.treeToValue(node, Object.class);
+ result.setResult(obj);
+ result.setOutcome("success");
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ assert false;
+ } catch (IOException e) {
+ e.printStackTrace();
+ assert false;
+ }
+
+ //populate the Value component complete with module Options.
+ List<Value> moduleTypeValue = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
+ ModuleOptionsComponent.loadModuleOptionType(attribute));
+ Value moduleOptionType = moduleTypeValue.get(0);
+ //Ex. retrieve the acl-modules component and assert values.
+ //always test 'code'
+ assert moduleOptionType.getCode().equals(code) : "Module Option 'code' value is not correct. Expected '"
+ + code + "' but was '" + moduleOptionType.getCode() + "'";
+ if (attribute.equals(ModuleOptionsComponent.ModuleOptionType.Mapping.getAttribute())) {
+ assert moduleOptionType.getType().equals(type) : "Mapping Module 'type' value is not correct. Expected '"
+ + type + "' but was '" + moduleOptionType.getType() + "'";
+ } else if (!attribute.equals(ModuleOptionsComponent.ModuleOptionType.Audit.getAttribute())) {//Audit has no second parameter
+ assert moduleOptionType.getFlag().equals(flag) : "Provider Module 'flag' value is not correct. Expected '"
+ + flag + "' but was '" + moduleOptionType.getFlag() + "'";
+ }
+
+ //Retrieve Module Options and test
+ //Ex. Module Options for (Acl Modules - Profile)
+ Resource moduleOptionsResource = getModuleOptionsResource(moduleOptionsTypeResource, attribute);
+ //assert non-zero id returned
+ assert moduleOptionsResource.getId() > 0 : "The resource was not properly initialized. Expected id > 0 but got:"
+ + moduleOptionsResource.getId();
+ //fetch configuration for module options
+ //Now request the resource complete with resource config
+ Configuration loadedOptionsConfiguration = testConfigurationManager
+ .loadResourceConfiguration(moduleOptionsResource.getId());
+ for (String key : loadedOptionsConfiguration.getAllProperties().keySet()) {
+ //retrieve the open map of Module Options
+ PropertyMap map = ((PropertyMap) loadedOptionsConfiguration.getAllProperties().get(key));
+ LinkedHashMap<String, Object> options = moduleOptionType.getOptions();
+ for (String optionKey : map.getMap().keySet()) {
+ PropertySimple property = (PropertySimple) map.getMap().get(optionKey);
+ //test the key
+ assert options.containsKey(optionKey) : "Unable to find expected option key '" + optionKey
+ + "'. Check hierarchy.";
+ //now the value.
+ String value = String.valueOf(options.get(optionKey));
+ assert value.equals(property.getStringValue()) : "Unable to find expected Module Option mapping. Key '"
+ + optionKey
+ + "' did not map to expected value '"
+ + value
+ + "' but was '"
+ + property.getStringValue() + "'.";
+ }
+ }
+ }
+ }
+
+ @Test(priority = 14)
+ public void testCreateSecurityDomain() throws Exception {
+ //get the root security resource
+ securityResource = getResource();
+
+ //plugin config
+ Configuration createPlugConfig = new Configuration();
+ createPlugConfig.put(new PropertySimple("path", SECURITY_DOMAIN_RESOURCE_KEY += "=" + TEST_DOMAIN));
+
+ //resource config
+ Configuration createResConfig = new Configuration();
+ createResConfig.put(new PropertySimple("name", TEST_DOMAIN));
+
+ CreateResourceRequest request = new CreateResourceRequest();
+ request.setParentResourceId(securityResource.getId());
+ request.setPluginConfiguration(createPlugConfig);
+ request.setPluginName(PLUGIN_NAME);
+ request.setResourceConfiguration(createResConfig);
+ request.setResourceName(TEST_DOMAIN);
+ request.setResourceTypeName(SECURITY_DOMAIN_RESOURCE_TYPE);
+
+ CreateResourceResponse response = pluginContainer.getResourceFactoryManager().executeCreateResourceImmediately(
+ request);
+
+ assert response.getStatus() == CreateResourceStatus.SUCCESS : "The Security Domain creation failed with an error mesasge: "
+ + response.getErrorMessage();
+ }
+
+ @Test(priority = 15)
+ public void testAuthenticationClassic() throws Exception {
+ //get the root security resource
+ securityResource = getResource();
+
+ //find TEST_DOMAIN 'security-domain'
+ Resource securityDomain = null;
+ Set<Resource> childResources = securityResource.getChildResources();
+ for (Resource r : childResources) {
+ if (r.getName().indexOf(TEST_DOMAIN) > -1) {
+ securityDomain = r;
+ }
+ }
+
+ //plugin config
+ Configuration createPlugConfig = new Configuration();
+ createPlugConfig.put(new PropertySimple("path", AUTH_CLASSIC_RESOURCE_KEY));
+
+ //resource config
+ Configuration createResConfig = new Configuration();
+ createResConfig.put(new PropertySimple("code", "Ldap"));
+ createResConfig.put(new PropertySimple("flag", "requisite"));
+
+ CreateResourceRequest request = new CreateResourceRequest();
+ request.setParentResourceId(securityDomain.getId());
+ request.setPluginConfiguration(createPlugConfig);
+ request.setPluginName(PLUGIN_NAME);
+ request.setResourceConfiguration(createResConfig);
+ request.setResourceName("Test - notUsed.");
+
+ request.setResourceTypeName(AUTH_CLASSIC_RESOURCE_TYPE);
+
+ CreateResourceResponse response = pluginContainer.getResourceFactoryManager().executeCreateResourceImmediately(
+ request);
+
+ assert response.getStatus() == CreateResourceStatus.SUCCESS : "The 'Authentication (Classic)' node creation failed with an error mesasge: "
+ + response.getErrorMessage();
+ }
+
+ @Test(priority = 16)
+ public void testDeleteSecurityDomain() throws Exception {
+ //get the root security resource
+ securityResource = getResource();
+ Resource found = null;
+ Set<Resource> childResources = securityResource.getChildResources();
+ for (Resource r : childResources) {
+ if (r.getName().indexOf(TEST_DOMAIN) > -1) {
+ found = r;
+ }
+ }
+
+ //plugin config
+ Configuration deletePlugConfig = new Configuration();
+ deletePlugConfig.put(new PropertySimple("path", SECURITY_DOMAIN_RESOURCE_KEY += "=" + TEST_DOMAIN));
+
+ //resource config
+ Configuration deleteResConfig = new Configuration();
+ deleteResConfig.put(new PropertySimple("name", TEST_DOMAIN));
+
+ DeleteResourceRequest request = new DeleteResourceRequest();
+ if (found != null) {
+ request.setResourceId(found.getId());
+ }
+ DeleteResourceResponse response = pluginContainer.getResourceFactoryManager().executeDeleteResourceImmediately(
+ request);
+
+ assert response.getStatus() == DeleteResourceStatus.SUCCESS : "The Security Domain deletion failed with an error mesasge: "
+ + response.getErrorMessage();
+ }
+
+ // public static void main(String[] args) {
+ // SecurityModuleOptionsTest setup = new SecurityModuleOptionsTest();
+ // try {
+ // setup.loadStandardModuleOptionTypes();
+ // } catch (Exception e) {
+ // e.printStackTrace();
+ // }
+ // }
+
+ private Resource getResource() {
+
+ InventoryManager im = pluginContainer.getInventoryManager();
+ Resource platform = im.getPlatform();
+ Resource server = getResourceByTypeAndKey(platform, StandaloneServerComponentTest.RESOURCE_TYPE,
+ StandaloneServerComponentTest.RESOURCE_KEY);
+ Resource bindings = getResourceByTypeAndKey(server, RESOURCE_TYPE, RESOURCE_KEY);
+ return bindings;
+ }
+
+ /** Automates hierarchy creation for Module Option type resources and their parents
+ *
+ * @param optionAttributeType
+ * @return
+ */
+ private Resource getModuleOptionTypeResource(String optionAttributeType) {
+ Resource moduleOptionResource = null;
+ String securityDomainId = SECURITY_DOMAIN_RESOURCE_KEY + "=" + TEST_DOMAIN + "2";
+ if (testSecurityDomain == null) {
+ InventoryManager im = pluginContainer.getInventoryManager();
+ Resource platform = im.getPlatform();
+ //host controller
+ ResourceType hostControllerType = new ResourceType("JBossAS7 Host Controller", PLUGIN_NAME,
+ ResourceCategory.SERVER, null);
+ Resource hostController = getResourceByTypeAndKey(platform, hostControllerType,
+ "/tmp/jboss-as-6.0.0.GA/domain");
+ //profile=full-ha
+ ResourceType profileType = new ResourceType("Profile", PLUGIN_NAME, ResourceCategory.SERVICE, null);
+ String key = PROFILE;
+ Resource profile = getResourceByTypeAndKey(hostController, profileType, key);
+
+ //Security (Profile)
+ ResourceType securityType = new ResourceType("Security (Profile)", PLUGIN_NAME, ResourceCategory.SERVICE,
+ null);
+ key += "," + SECURITY_RESOURCE_KEY;
+ Resource security = getResourceByTypeAndKey(profile, securityType, key);
+
+ //Security Domain (Profile)
+ ResourceType domainType = new ResourceType("Security Domain (Profile)", PLUGIN_NAME,
+ ResourceCategory.SERVICE, null);
+ key += "," + securityDomainId;
+ testSecurityDomainKey = key;
+ testSecurityDomain = getResourceByTypeAndKey(security, domainType, key);
+ }
+
+ //acl=classic
+ String descriptorName = "";
+ String moduleAttribute = "";
+ //acl
+ if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Acl.getAttribute())) {
+ descriptorName = "ACL (Profile)";
+ moduleAttribute = "acl=classic";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Audit.getAttribute())) {
+ descriptorName = "Audit (Profile)";
+ moduleAttribute = "audit=classic";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Authentication.getAttribute())) {
+ descriptorName = "Authentication (Classic - Profile)";
+ moduleAttribute = "authentication=classic";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Authorization.getAttribute())) {
+ descriptorName = "Authorization (Profile)";
+ moduleAttribute = "authorization=classic";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.IdentityTrust.getAttribute())) {
+ descriptorName = "Identity Trust (Profile)";
+ moduleAttribute = "identity-trust=classic";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Mapping.getAttribute())) {
+ descriptorName = "Mapping (Profile)";
+ moduleAttribute = "mapping=classic";
+ }
+ //Build the right Module Option Type. Ex. ACL (Profile), etc.
+ ResourceType moduleOptionType = new ResourceType(descriptorName, PLUGIN_NAME, ResourceCategory.SERVICE, null);
+ ConfigurationDefinition cdef = new ConfigurationDefinition(descriptorName, null);
+ moduleOptionType.setResourceConfigurationDefinition(cdef);
+ //Ex. profile=full-ha,subsystem=security,security-domain=testDomain2,identity-trust=classic
+ String moduleOptionTypeKey = testSecurityDomainKey += "," + moduleAttribute;
+
+ if (!testSecurityDomainKey.endsWith(securityDomainId)) {
+ moduleOptionTypeKey = testSecurityDomainKey.substring(0, testSecurityDomainKey.indexOf(securityDomainId)
+ + securityDomainId.length())
+ + "," + moduleAttribute;
+ }
+
+ moduleOptionResource = getResourceByTypeAndKey(testSecurityDomain, moduleOptionType, moduleOptionTypeKey);
+
+ return moduleOptionResource;
+ }
+
+ /** Automates hierarchy creation for Module Option type resources and their parents
+ *
+ * @param optionAttributeType
+ * @return
+ */
+ private Resource getModuleOptionsResource(Resource parent, String optionAttributeType) {
+ Resource moduleOptionsResource = null;
+ String descriptorName = "";
+ String moduleAttribute = "";
+ String moduleOptionsDescriptor = "";
+ if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Acl.getAttribute())) {
+ // descriptorName = "ACL Modules (Profile)";
+ descriptorName = "Acl Modules (Profile)";
+ moduleAttribute = "acl=classic";
+ moduleOptionsDescriptor = "Module Options (Acl - Profile)";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Audit.getAttribute())) {
+ descriptorName = "Provider Modules (Profile)";
+ moduleAttribute = "audit=classic";
+ moduleOptionsDescriptor = "Module Options (Provider Modules - Profile)";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Authentication.getAttribute())) {
+ descriptorName = "Login Modules (Classic - Profile)";
+ moduleAttribute = "authentication=classic";
+ moduleOptionsDescriptor = "Module Options (Classic - Profile)";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Authorization.getAttribute())) {
+ descriptorName = "Authorization Modules (Profile)";
+ moduleAttribute = "authorization=classic";
+ moduleOptionsDescriptor = "Module Options (Authorization - Profile)";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.IdentityTrust.getAttribute())) {
+ descriptorName = "Identity Trust Modules (Profile)";
+ moduleAttribute = "identity-trust=classic";
+ moduleOptionsDescriptor = "Module Options (Identity Trust - Profile)";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Mapping.getAttribute())) {
+ descriptorName = "Mapping Modules (Profile)";
+ moduleAttribute = "mapping=classic";
+ moduleOptionsDescriptor = "Module Options (Mapping - Profile)";
+ }
+ //Build the right Module Option Type. Ex. ACL Modules (Profile), etc.
+ ResourceType modulesType = new ResourceType(descriptorName, PLUGIN_NAME, ResourceCategory.SERVICE, null);
+ //Ex. profile=full-ha,subsystem=security,security-domain=testDomain2,acl=classic,acl-modules:0
+ String sharedRoot = "profile=full-ha,subsystem=security,security-domain=testDomain2";
+ String moduleOptionTypeKey = sharedRoot += "," + moduleAttribute + ","
+ + optionAttributeType + ":0";
+ //Ex. Module Options Type children [ACL Modules (Profile),etc.]
+ Resource modulesInstance = getResourceByTypeAndKey(parent, modulesType, moduleOptionTypeKey);
+
+ //Module Options
+ ResourceType moduleOptionsType = new ResourceType(moduleOptionsDescriptor, PLUGIN_NAME,
+ ResourceCategory.SERVICE, null);
+ moduleOptionsResource = getResourceByTypeAndKey(modulesInstance, moduleOptionsType, moduleOptionTypeKey
+ + ",module-options");
+
+ return moduleOptionsResource;
+ }
+
+ private Resource getResource(Resource parentResource, String pluginDescriptorTypeName, String resourceKey) {
+ Resource resource = null;
+ if (((parentResource != null) & (pluginDescriptorTypeName != null) & (resourceKey != null))
+ & (((!pluginDescriptorTypeName.isEmpty()) & (!resourceKey.isEmpty())))) {
+ ResourceType resourceType = buildResourceType(pluginDescriptorTypeName);
+ resource = getResourceByTypeAndKey(parentResource, resourceType, resourceKey);
+ }
+ return resource;
+ }
+
+ private ResourceType buildResourceType(String pluginTypeName) {
+ ResourceType created = null;
+ if ((pluginTypeName != null) && (!pluginTypeName.isEmpty())) {
+ created = new ResourceType(pluginTypeName, PLUGIN_NAME, ResourceCategory.SERVICE, null);
+ }
+ return created;
+ }
+
+ /** For each operation
+ * - will write verbose json and operation details to system.out if verboseOutput = true;
+ * - will execute the operation against running server if execute = true.
+ *
+ * @param op
+ * @param execute
+ * @param verboseOutput
+ * @return
+ */
+ public static Result exerciseOperation(Operation op, boolean execute, boolean verboseOutput) {
+ //display operation as AS7 plugin will build it
+ if (verboseOutput) {
+ System.out.println("\tOperation is:" + op);
+ }
+
+ String jsonToSend = "";
+ try {
+ jsonToSend = mapper.defaultPrettyPrintingWriter().writeValueAsString(op);
+ } catch (JsonGenerationException e) {
+ e.printStackTrace();
+ } catch (JsonMappingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ //As generated by jackson mapper
+ if (verboseOutput) {
+ System.out.println("@@@@ OUTBOUND JSON#\n" + jsonToSend + "#");
+ }
+
+ //Execute the operation
+ Result result = new Result();
+ if (execute) {
+ result = con.execute(op);
+ } else {
+ if (verboseOutput) {
+ System.out.println("**** NOTE: Execution disabled . NOT exercising write-attribute operation. **** ");
+ }
+ }
+ if (verboseOutput) {
+ //result wrapper details
+ System.out.println("\tResult:" + result);
+ //detailed results
+ System.out.println("\tValue:" + result.getResult());
+ System.out.println("-----------------------------------------------------\n");
+ }
+ return result;
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java
deleted file mode 100644
index 452fdfb..0000000
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java
+++ /dev/null
@@ -1,674 +0,0 @@
-/*
- * 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 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.modules.plugins.jbossas7.itest.standalone;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Set;
-
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.JsonProcessingException;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.testng.annotations.Test;
-
-import org.rhq.core.clientapi.agent.inventory.CreateResourceRequest;
-import org.rhq.core.clientapi.agent.inventory.CreateResourceResponse;
-import org.rhq.core.clientapi.agent.inventory.DeleteResourceRequest;
-import org.rhq.core.clientapi.agent.inventory.DeleteResourceResponse;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertyMap;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.resource.CreateResourceStatus;
-import org.rhq.core.domain.resource.DeleteResourceStatus;
-import org.rhq.core.domain.resource.InventoryStatus;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.pc.configuration.ConfigurationManager;
-import org.rhq.core.pc.inventory.InventoryManager;
-import org.rhq.modules.plugins.jbossas7.ASConnection;
-import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent;
-import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent.Value;
-import org.rhq.modules.plugins.jbossas7.itest.AbstractJBossAS7PluginTest;
-import org.rhq.modules.plugins.jbossas7.json.Address;
-import org.rhq.modules.plugins.jbossas7.json.Operation;
-import org.rhq.modules.plugins.jbossas7.json.Result;
-import org.rhq.test.arquillian.RunDiscovery;
-
-/**
- * Test exercising the subsystem=security/SecurityDomain/[Authentication(Classic|Jaspi),
- * Authorization, Mapping, Audit, Acl,
- * Identity-Trust]
- * @author Simeon Pinder
- */
-@Test(groups = { "integration", "pc", "standalone" }, singleThreaded = true)
-public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
-
- private static ASConnection con = null;
- private static ObjectMapper mapper = null;
-
- private static String TEST_DOMAIN = "testDomain";
- private static String SECURITY_RESOURCE_TYPE = "Security";
- private static String SECURITY_RESOURCE_KEY = "subsystem=security";
- private static String SECURITY_DOMAIN_RESOURCE_KEY = "security-domain";
- private static String PROFILE = "profile=full-ha";
- private static String SECURITY_DOMAIN_RESOURCE_TYPE = "Security Domain";
- private static String AUTH_CLASSIC_RESOURCE_TYPE = "Authentication (Classic)";
- private static String AUTH_CLASSIC_RESOURCE_KEY = "authentication=classic";
-
- private static Resource securityResource = null;
-
- protected static String DC_HOST = System.getProperty("jboss.domain.bindAddress");
- protected static int DC_HTTP_PORT = Integer.valueOf(System.getProperty("jboss.domain.httpManagementPort"));
- protected static String DC_USER = AbstractJBossAS7PluginTest.MANAGEMENT_USERNAME;
- protected static String DC_PASS = AbstractJBossAS7PluginTest.MANAGEMENT_PASSWORD;
-
- ASConnection getASConnection() {
- ASConnection connection = new ASConnection(DC_HOST, DC_HTTP_PORT, DC_USER, DC_PASS);
- return connection;
- }
-
- public static final ResourceType RESOURCE_TYPE = new ResourceType(SECURITY_RESOURCE_TYPE, PLUGIN_NAME,
- ResourceCategory.SERVICE, null);
- private static final String RESOURCE_KEY = SECURITY_RESOURCE_KEY;
- private static Resource testSecurityDomain = null;
- private String testSecurityDomainKey = null;
- private ConfigurationManager testConfigurationManager = null;
-
- //Define some shared and reusable content
- static HashMap<String, String> jsonMap = new HashMap<String, String>();
- static {
- jsonMap
- .put(
- "login-modules",
- "[{\"flag\":\"required\", \"code\":\"Ldap\", \"module-options\":{\"bindDn\":\"uid=ldapSecureUser,ou=People,dc=redat,dc=com\", \"bindPw\":\"test126\", \"allowEmptyPasswords\":\"true\"}}]");
- jsonMap
- .put(
- "policy-modules",
- "[{\"flag\":\"requisite\", \"code\":\"LdapExtended\", \"module-options\":{\"policy\":\"module\", \"policy1\":\"module1\"}}]");
- jsonMap
- .put("mapping-modules",
- "[{\"code\":\"Test\", \"type\":\"attribute\", \"module-options\":{\"mapping\":\"module\", \"mapping1\":\"module1\"}}]");
- jsonMap.put("provider-modules",
- "[{\"code\":\"Providers\", \"module-options\":{\"provider\":\"module\", \"provider1\":\"module1\"}}]");
- jsonMap
- .put("acl-modules",
- "[{\"flag\":\"sufficient\", \"code\":\"ACL\", \"module-options\":{\"acl\":\"module\", \"acl1\":\"module1\"}}]");
- jsonMap
- .put("trust-modules",
- "[{\"flag\":\"optional\", \"code\":\"TRUST\", \"module-options\":{\"trust\":\"module\", \"trust1\":\"module1\"}}]");
- }
-
- /* This first discovery is only so that we can leverage existing code to install the management user needed
- * in next test.
- */
- @Test(priority = 10, groups = "discovery")
- @RunDiscovery(discoverServices = true, discoverServers = true)
- public void firstDiscovery() throws Exception {
- Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
- assertNotNull(platform);
- assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
-
- //now install mgmt users.
- System.out.println("------ * Duplicating discovery for SecurityModule testing....");
- installManagementUsers();
- }
-
- /** This method mass loads all the supported Module Option Types(Excluding authentication=jaspi, cannot co-exist with
- * authentication=classic) into a single SecurityDomain. This is done as
- * -i)creating all of the related hierarchy of types needed to exercise N Module Options Types and their associated
- * Module Options instances would take too long to setup(N creates would signal N discovery runs before test could complete).
- * -ii)setting the priority of this method lower than the discovery method means that we'll get all the same types in much
- * less time.
- *
- * @throws Exception
- */
- @Test(priority = 11)
- public void loadStandardModuleOptionTypes() throws Exception {
- mapper = new ObjectMapper();
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- //Adjust discovery depth to support deeper hierarchy depth of Module Option elements
- setMaxDiscoveryDepthOverride(12);
-
- //create new Security Domain
- Address destination = new Address(PROFILE);
- destination.addSegment(SECURITY_RESOURCE_KEY);
- String securityDomainId = TEST_DOMAIN + "2";
- destination.addSegment(SECURITY_DOMAIN_RESOURCE_KEY + "=" + securityDomainId);
-
- ASConnection connection = getASConnection();
- Result result = new Result();
- Operation op = null;
- //delete old one if present to setup clean slate
- op = new Operation("remove", destination);
- result = connection.execute(op);
-
- //build/rebuild hierarchy
- op = new Operation("add", destination);
- result = connection.execute(op);
- assert result.getOutcome().equals("success") : "Add of Security Domain has failed: "
- + result.getFailureDescription();
-
- //Ex. profile=standalone-ha,subsystem=security,security-domain
- String addressPrefix = PROFILE + "," + SECURITY_RESOURCE_KEY + "," + SECURITY_DOMAIN_RESOURCE_KEY;
-
- //loop over standard types and add base details for all of them to security domain
- String address = "";
- for (String attribute : jsonMap.keySet()) {
- if (attribute.equals("policy-modules")) {
- address = addressPrefix + "=" + securityDomainId + ",authorization=classic";
- } else if (attribute.equals("acl-modules")) {
- address = addressPrefix + "=" + securityDomainId + ",acl=classic";
- } else if (attribute.equals("mapping-modules")) {
- address = addressPrefix + "=" + securityDomainId + ",mapping=classic";
- } else if (attribute.equals("trust-modules")) {
- address = addressPrefix + "=" + securityDomainId + ",identity-trust=classic";
- } else if (attribute.equals("provider-modules")) {
- address = addressPrefix + "=" + securityDomainId + ",audit=classic";
- } else if (attribute.equals("login-modules")) {
- address = addressPrefix + "=" + securityDomainId + ",authentication=classic";
- } else {
- assert false : "An unknown attribute '" + attribute
- + "' was found. Is there a new type to be supported?";
- }
- //build the operation to add the component
- ////Load json map into ModuleOptionType
- List<Value> moduleTypeValue = new ArrayList<Value>();
- try {
- // loading jsonMap contents for Ex. 'login-module'
- JsonNode node = mapper.readTree(jsonMap.get(attribute));
- Object obj = mapper.treeToValue(node, Object.class);
- result.setResult(obj);
- result.setOutcome("success");
- } catch (JsonProcessingException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- //populate the Value component complete with module Options.
- moduleTypeValue = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
- ModuleOptionsComponent.loadModuleOptionType(attribute));
- op = ModuleOptionsComponent.createAddModuleOptionTypeOperation(new Address(address), attribute,
- moduleTypeValue);
- //submit the command
- result = connection.execute(op);
- }
- }
-
- /** Runs the second discovery run to load all the new types added.
- *
- * @throws Exception
- */
- @Test(priority = 12, groups = "discovery")
- @RunDiscovery(discoverServices = true, discoverServers = true)
- public void secondDiscovery() throws Exception {
- Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
- assertNotNull(platform);
- assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
-
- //Have thread sleep longer to discover deeper resource types.
- //spinder 6/29/12: up this number if the resources are not being discovered.
- Thread.sleep(180 * 1000L); // delay so that PC gets a chance to scan for resources
- }
-
- /** This test method exercises a number of things:
- * - that the security-domain children loaded have been created successfully
- * - that all of the supported Module Option Type children(excluding 'authentication=jaspi') have been
- * discovered as AS7 types successfully.
- * - that the correct child attribute was specified for each type //Ex. acl=classic -> acl-modules
- * -
- *
- * @throws Exception
- */
- @Test(priority = 13)
- public void testDiscoveredSecurityNodes() throws Exception {
- //lazy-load configurationManager
- if (testConfigurationManager == null) {
- testConfigurationManager = this.pluginContainer.getConfigurationManager();
- testConfigurationManager = pluginContainer.getConfigurationManager();
- testConfigurationManager.initialize();
- Thread.sleep(20 * 1000L);
- }
- //iterate through list of nodes and make sure they've all been discovered
- ////Ex. profile=full-ha,subsystem=security,security-domain=testDomain2,acl=classic
- String attribute = null;
- for (String jsonKey : jsonMap.keySet()) {
- //Ex. policy-modules
- attribute = jsonKey;
- //spinder 6/26/12: Temporarily disable until figure out why NPE happens only for this type?
- if (attribute.equals(ModuleOptionsComponent.ModuleOptionType.Authentication.getAttribute())) {
- break;//
- }
- //Ex. name=acl-modules
- //check the configuration for the Module Option Type Ex. 'Acl (Profile)' Resource. Should be able to verify components
- Resource moduleOptionsTypeResource = getModuleOptionTypeResource(attribute);
- //assert non-zero id returned
- assert moduleOptionsTypeResource.getId() > 0 : "The resource was not properly initialized. Expected id >0 but got:"
- + moduleOptionsTypeResource.getId();
-
- //Now request the resource complete with resource config
- Configuration loadedConfiguration = testConfigurationManager
- .loadResourceConfiguration(moduleOptionsTypeResource.getId());
- String code = null;
- String type = null;
- String flag = null;
- //populate the associated attributes if it's supported.
- for (String key : loadedConfiguration.getAllProperties().keySet()) {
- Property property = loadedConfiguration.getAllProperties().get(key);
- if (key.equals("code")) {
- code = ((PropertySimple) property).getStringValue();
- } else if (key.equals("flag")) {
- flag = ((PropertySimple) property).getStringValue();
- } else {//Ex. type.
- type = ((PropertySimple) property).getStringValue();
- }
- }
-
- //retrieve module options as well.
- String jsonContent = jsonMap.get(attribute);
- Result result = new Result();
- try {
- // loading jsonMap contents for Ex. 'login-module'
- JsonNode node = mapper.readTree(jsonContent);
- Object obj = mapper.treeToValue(node, Object.class);
- result.setResult(obj);
- result.setOutcome("success");
- } catch (JsonProcessingException e) {
- e.printStackTrace();
- assert false;
- } catch (IOException e) {
- e.printStackTrace();
- assert false;
- }
-
- //populate the Value component complete with module Options.
- List<Value> moduleTypeValue = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
- ModuleOptionsComponent.loadModuleOptionType(attribute));
- Value moduleOptionType = moduleTypeValue.get(0);
- //Ex. retrieve the acl-modules component and assert values.
- //always test 'code'
- assert moduleOptionType.getCode().equals(code) : "Module Option 'code' value is not correct. Expected '"
- + code + "' but was '" + moduleOptionType.getCode() + "'";
- if (attribute.equals(ModuleOptionsComponent.ModuleOptionType.Mapping.getAttribute())) {
- assert moduleOptionType.getType().equals(type) : "Mapping Module 'type' value is not correct. Expected '"
- + type + "' but was '" + moduleOptionType.getType() + "'";
- } else if (!attribute.equals(ModuleOptionsComponent.ModuleOptionType.Audit.getAttribute())) {//Audit has no second parameter
- assert moduleOptionType.getFlag().equals(flag) : "Provider Module 'flag' value is not correct. Expected '"
- + flag + "' but was '" + moduleOptionType.getFlag() + "'";
- }
-
- //Retrieve Module Options and test
- //Ex. Module Options for (Acl Modules - Profile)
- Resource moduleOptionsResource = getModuleOptionsResource(moduleOptionsTypeResource, attribute);
- //assert non-zero id returned
- assert moduleOptionsResource.getId() > 0 : "The resource was not properly initialized. Expected id > 0 but got:"
- + moduleOptionsResource.getId();
- //fetch configuration for module options
- //Now request the resource complete with resource config
- Configuration loadedOptionsConfiguration = testConfigurationManager
- .loadResourceConfiguration(moduleOptionsResource.getId());
- for (String key : loadedOptionsConfiguration.getAllProperties().keySet()) {
- //retrieve the open map of Module Options
- PropertyMap map = ((PropertyMap) loadedOptionsConfiguration.getAllProperties().get(key));
- LinkedHashMap<String, Object> options = moduleOptionType.getOptions();
- for (String optionKey : map.getMap().keySet()) {
- PropertySimple property = (PropertySimple) map.getMap().get(optionKey);
- //test the key
- assert options.containsKey(optionKey) : "Unable to find expected option key '" + optionKey
- + "'. Check hierarchy.";
- //now the value.
- String value = String.valueOf(options.get(optionKey));
- assert value.equals(property.getStringValue()) : "Unable to find expected Module Option mapping. Key '"
- + optionKey
- + "' did not map to expected value '"
- + value
- + "' but was '"
- + property.getStringValue() + "'.";
- }
- }
- }
- }
-
- @Test(priority = 14)
- public void testCreateSecurityDomain() throws Exception {
- //get the root security resource
- securityResource = getResource();
-
- //plugin config
- Configuration createPlugConfig = new Configuration();
- createPlugConfig.put(new PropertySimple("path", SECURITY_DOMAIN_RESOURCE_KEY += "=" + TEST_DOMAIN));
-
- //resource config
- Configuration createResConfig = new Configuration();
- createResConfig.put(new PropertySimple("name", TEST_DOMAIN));
-
- CreateResourceRequest request = new CreateResourceRequest();
- request.setParentResourceId(securityResource.getId());
- request.setPluginConfiguration(createPlugConfig);
- request.setPluginName(PLUGIN_NAME);
- request.setResourceConfiguration(createResConfig);
- request.setResourceName(TEST_DOMAIN);
- request.setResourceTypeName(SECURITY_DOMAIN_RESOURCE_TYPE);
-
- CreateResourceResponse response = pluginContainer.getResourceFactoryManager().executeCreateResourceImmediately(
- request);
-
- assert response.getStatus() == CreateResourceStatus.SUCCESS : "The Security Domain creation failed with an error mesasge: "
- + response.getErrorMessage();
- }
-
- @Test(priority = 15)
- public void testAuthenticationClassic() throws Exception {
- //get the root security resource
- securityResource = getResource();
-
- //find TEST_DOMAIN 'security-domain'
- Resource securityDomain = null;
- Set<Resource> childResources = securityResource.getChildResources();
- for (Resource r : childResources) {
- if (r.getName().indexOf(TEST_DOMAIN) > -1) {
- securityDomain = r;
- }
- }
-
- //plugin config
- Configuration createPlugConfig = new Configuration();
- createPlugConfig.put(new PropertySimple("path", AUTH_CLASSIC_RESOURCE_KEY));
-
- //resource config
- Configuration createResConfig = new Configuration();
- createResConfig.put(new PropertySimple("code", "Ldap"));
- createResConfig.put(new PropertySimple("flag", "requisite"));
-
- CreateResourceRequest request = new CreateResourceRequest();
- request.setParentResourceId(securityDomain.getId());
- request.setPluginConfiguration(createPlugConfig);
- request.setPluginName(PLUGIN_NAME);
- request.setResourceConfiguration(createResConfig);
- request.setResourceName("Test - notUsed.");
-
- request.setResourceTypeName(AUTH_CLASSIC_RESOURCE_TYPE);
-
- CreateResourceResponse response = pluginContainer.getResourceFactoryManager().executeCreateResourceImmediately(
- request);
-
- assert response.getStatus() == CreateResourceStatus.SUCCESS : "The 'Authentication (Classic)' node creation failed with an error mesasge: "
- + response.getErrorMessage();
- }
-
- @Test(priority = 16)
- public void testDeleteSecurityDomain() throws Exception {
- //get the root security resource
- securityResource = getResource();
- Resource found = null;
- Set<Resource> childResources = securityResource.getChildResources();
- for (Resource r : childResources) {
- if (r.getName().indexOf(TEST_DOMAIN) > -1) {
- found = r;
- }
- }
-
- //plugin config
- Configuration deletePlugConfig = new Configuration();
- deletePlugConfig.put(new PropertySimple("path", SECURITY_DOMAIN_RESOURCE_KEY += "=" + TEST_DOMAIN));
-
- //resource config
- Configuration deleteResConfig = new Configuration();
- deleteResConfig.put(new PropertySimple("name", TEST_DOMAIN));
-
- DeleteResourceRequest request = new DeleteResourceRequest();
- if (found != null) {
- request.setResourceId(found.getId());
- }
- DeleteResourceResponse response = pluginContainer.getResourceFactoryManager().executeDeleteResourceImmediately(
- request);
-
- assert response.getStatus() == DeleteResourceStatus.SUCCESS : "The Security Domain deletion failed with an error mesasge: "
- + response.getErrorMessage();
- }
-
- // public static void main(String[] args) {
- // SecurityModuleOptionsTest setup = new SecurityModuleOptionsTest();
- // try {
- // setup.loadStandardModuleOptionTypes();
- // } catch (Exception e) {
- // e.printStackTrace();
- // }
- // }
-
- private Resource getResource() {
-
- InventoryManager im = pluginContainer.getInventoryManager();
- Resource platform = im.getPlatform();
- Resource server = getResourceByTypeAndKey(platform, StandaloneServerComponentTest.RESOURCE_TYPE,
- StandaloneServerComponentTest.RESOURCE_KEY);
- Resource bindings = getResourceByTypeAndKey(server, RESOURCE_TYPE, RESOURCE_KEY);
- return bindings;
- }
-
- /** Automates hierarchy creation for Module Option type resources and their parents
- *
- * @param optionAttributeType
- * @return
- */
- private Resource getModuleOptionTypeResource(String optionAttributeType) {
- Resource moduleOptionResource = null;
- String securityDomainId = SECURITY_DOMAIN_RESOURCE_KEY + "=" + TEST_DOMAIN + "2";
- if (testSecurityDomain == null) {
- InventoryManager im = pluginContainer.getInventoryManager();
- Resource platform = im.getPlatform();
- //host controller
- ResourceType hostControllerType = new ResourceType("JBossAS7 Host Controller", PLUGIN_NAME,
- ResourceCategory.SERVER, null);
- Resource hostController = getResourceByTypeAndKey(platform, hostControllerType,
- "/tmp/jboss-as-6.0.0.GA/domain");
- //profile=full-ha
- ResourceType profileType = new ResourceType("Profile", PLUGIN_NAME, ResourceCategory.SERVICE, null);
- String key = PROFILE;
- Resource profile = getResourceByTypeAndKey(hostController, profileType, key);
-
- //Security (Profile)
- ResourceType securityType = new ResourceType("Security (Profile)", PLUGIN_NAME, ResourceCategory.SERVICE,
- null);
- key += "," + SECURITY_RESOURCE_KEY;
- Resource security = getResourceByTypeAndKey(profile, securityType, key);
-
- //Security Domain (Profile)
- ResourceType domainType = new ResourceType("Security Domain (Profile)", PLUGIN_NAME,
- ResourceCategory.SERVICE, null);
- key += "," + securityDomainId;
- testSecurityDomainKey = key;
- testSecurityDomain = getResourceByTypeAndKey(security, domainType, key);
- }
-
- //acl=classic
- String descriptorName = "";
- String moduleAttribute = "";
- //acl
- if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Acl.getAttribute())) {
- descriptorName = "ACL (Profile)";
- moduleAttribute = "acl=classic";
- } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Audit.getAttribute())) {
- descriptorName = "Audit (Profile)";
- moduleAttribute = "audit=classic";
- } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Authentication.getAttribute())) {
- descriptorName = "Authentication (Classic - Profile)";
- moduleAttribute = "authentication=classic";
- } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Authorization.getAttribute())) {
- descriptorName = "Authorization (Profile)";
- moduleAttribute = "authorization=classic";
- } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.IdentityTrust.getAttribute())) {
- descriptorName = "Identity Trust (Profile)";
- moduleAttribute = "identity-trust=classic";
- } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Mapping.getAttribute())) {
- descriptorName = "Mapping (Profile)";
- moduleAttribute = "mapping=classic";
- }
- //Build the right Module Option Type. Ex. ACL (Profile), etc.
- ResourceType moduleOptionType = new ResourceType(descriptorName, PLUGIN_NAME, ResourceCategory.SERVICE, null);
- ConfigurationDefinition cdef = new ConfigurationDefinition(descriptorName, null);
- moduleOptionType.setResourceConfigurationDefinition(cdef);
- //Ex. profile=full-ha,subsystem=security,security-domain=testDomain2,identity-trust=classic
- String moduleOptionTypeKey = testSecurityDomainKey += "," + moduleAttribute;
-
- if (!testSecurityDomainKey.endsWith(securityDomainId)) {
- moduleOptionTypeKey = testSecurityDomainKey.substring(0, testSecurityDomainKey.indexOf(securityDomainId)
- + securityDomainId.length())
- + "," + moduleAttribute;
- }
-
- moduleOptionResource = getResourceByTypeAndKey(testSecurityDomain, moduleOptionType, moduleOptionTypeKey);
-
- return moduleOptionResource;
- }
-
- /** Automates hierarchy creation for Module Option type resources and their parents
- *
- * @param optionAttributeType
- * @return
- */
- private Resource getModuleOptionsResource(Resource parent, String optionAttributeType) {
- Resource moduleOptionsResource = null;
- String descriptorName = "";
- String moduleAttribute = "";
- String moduleOptionsDescriptor = "";
- if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Acl.getAttribute())) {
- // descriptorName = "ACL Modules (Profile)";
- descriptorName = "Acl Modules (Profile)";
- moduleAttribute = "acl=classic";
- moduleOptionsDescriptor = "Module Options (Acl - Profile)";
- } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Audit.getAttribute())) {
- descriptorName = "Provider Modules (Profile)";
- moduleAttribute = "audit=classic";
- moduleOptionsDescriptor = "Module Options (Provider Modules - Profile)";
- } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Authentication.getAttribute())) {
- descriptorName = "Login Modules (Classic - Profile)";
- moduleAttribute = "authentication=classic";
- moduleOptionsDescriptor = "Module Options (Classic - Profile)";
- } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Authorization.getAttribute())) {
- descriptorName = "Authorization Modules (Profile)";
- moduleAttribute = "authorization=classic";
- moduleOptionsDescriptor = "Module Options (Authorization - Profile)";
- } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.IdentityTrust.getAttribute())) {
- descriptorName = "Identity Trust Modules (Profile)";
- moduleAttribute = "identity-trust=classic";
- moduleOptionsDescriptor = "Module Options (Identity Trust - Profile)";
- } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Mapping.getAttribute())) {
- descriptorName = "Mapping Modules (Profile)";
- moduleAttribute = "mapping=classic";
- moduleOptionsDescriptor = "Module Options (Mapping - Profile)";
- }
- //Build the right Module Option Type. Ex. ACL Modules (Profile), etc.
- ResourceType modulesType = new ResourceType(descriptorName, PLUGIN_NAME, ResourceCategory.SERVICE, null);
- //Ex. profile=full-ha,subsystem=security,security-domain=testDomain2,acl=classic,acl-modules:0
- String sharedRoot = "profile=full-ha,subsystem=security,security-domain=testDomain2";
- String moduleOptionTypeKey = sharedRoot += "," + moduleAttribute + ","
- + optionAttributeType + ":0";
- //Ex. Module Options Type children [ACL Modules (Profile),etc.]
- Resource modulesInstance = getResourceByTypeAndKey(parent, modulesType, moduleOptionTypeKey);
-
- //Module Options
- ResourceType moduleOptionsType = new ResourceType(moduleOptionsDescriptor, PLUGIN_NAME,
- ResourceCategory.SERVICE, null);
- moduleOptionsResource = getResourceByTypeAndKey(modulesInstance, moduleOptionsType, moduleOptionTypeKey
- + ",module-options");
-
- return moduleOptionsResource;
- }
-
- private Resource getResource(Resource parentResource, String pluginDescriptorTypeName, String resourceKey) {
- Resource resource = null;
- if (((parentResource != null) & (pluginDescriptorTypeName != null) & (resourceKey != null))
- & (((!pluginDescriptorTypeName.isEmpty()) & (!resourceKey.isEmpty())))) {
- ResourceType resourceType = buildResourceType(pluginDescriptorTypeName);
- resource = getResourceByTypeAndKey(parentResource, resourceType, resourceKey);
- }
- return resource;
- }
-
- private ResourceType buildResourceType(String pluginTypeName) {
- ResourceType created = null;
- if ((pluginTypeName != null) && (!pluginTypeName.isEmpty())) {
- created = new ResourceType(pluginTypeName, PLUGIN_NAME, ResourceCategory.SERVICE, null);
- }
- return created;
- }
-
- /** For each operation
- * - will write verbose json and operation details to system.out if verboseOutput = true;
- * - will execute the operation against running server if execute = true.
- *
- * @param op
- * @param execute
- * @param verboseOutput
- * @return
- */
- public static Result exerciseOperation(Operation op, boolean execute, boolean verboseOutput) {
- //display operation as AS7 plugin will build it
- if (verboseOutput) {
- System.out.println("\tOperation is:" + op);
- }
-
- String jsonToSend = "";
- try {
- jsonToSend = mapper.defaultPrettyPrintingWriter().writeValueAsString(op);
- } catch (JsonGenerationException e) {
- e.printStackTrace();
- } catch (JsonMappingException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- //As generated by jackson mapper
- if (verboseOutput) {
- System.out.println("@@@@ OUTBOUND JSON#\n" + jsonToSend + "#");
- }
-
- //Execute the operation
- Result result = new Result();
- if (execute) {
- result = con.execute(op);
- } else {
- if (verboseOutput) {
- System.out.println("**** NOTE: Execution disabled . NOT exercising write-attribute operation. **** ");
- }
- }
- if (verboseOutput) {
- //result wrapper details
- System.out.println("\tResult:" + result);
- //detailed results
- System.out.println("\tValue:" + result.getResult());
- System.out.println("-----------------------------------------------------\n");
- }
- return result;
- }
-}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java
index 5d64977..fe05def 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java
@@ -73,7 +73,7 @@ public class TemplatedResourcesTest extends AbstractJBossAS7PluginTest {
StandaloneServerComponentTest.RESOURCE_KEY);
inventoryManager.activateResource(server, platformContainer, false);
- Thread.sleep(20 * 1000L);
+ Thread.sleep(30 * 1000L);
for (ResourceData resourceData : testResourceData) {
ResourceType resourceType = new ResourceType(resourceData.resourceTypeName, PLUGIN_NAME,
@@ -100,6 +100,7 @@ public class TemplatedResourcesTest extends AbstractJBossAS7PluginTest {
for (Resource resourceUnderTest : foundResources) {
log.info(foundResources);
+ assert resourceUnderTest.getId() > 0 : "Resource not properly initialized. Id = 0. Try extending sleep after discovery.";
Configuration resourceUnderTestConfig = configurationManager
.loadResourceConfiguration(resourceUnderTest.getId());
commit 89fa0d623ae733febad51a61774782447bb07c41
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Jun 29 09:30:20 2012 -0400
Fix problem with test Resource discovery and cleaned up names and properties.
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java
index e3f88af..452fdfb 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java
@@ -24,12 +24,15 @@ import static org.testng.Assert.assertNotNull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
+import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.testng.annotations.Test;
@@ -39,6 +42,7 @@ import org.rhq.core.clientapi.agent.inventory.DeleteResourceRequest;
import org.rhq.core.clientapi.agent.inventory.DeleteResourceResponse;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.resource.CreateResourceStatus;
@@ -67,27 +71,24 @@ import org.rhq.test.arquillian.RunDiscovery;
@Test(groups = { "integration", "pc", "standalone" }, singleThreaded = true)
public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
- private static String user = "rhqadmin";
- private static String pass = "as7";
- private static String host = "localhost";
private static ASConnection con = null;
private static ObjectMapper mapper = null;
- private ModuleOptionsComponent moc = null;
private static String TEST_DOMAIN = "testDomain";
- private static Resource securityResource = null;
private static String SECURITY_RESOURCE_TYPE = "Security";
private static String SECURITY_RESOURCE_KEY = "subsystem=security";
- private static String SECURITY_DOMAIN_RESOURCE_TYPE = "Security Domain";
private static String SECURITY_DOMAIN_RESOURCE_KEY = "security-domain";
+ private static String PROFILE = "profile=full-ha";
+ private static String SECURITY_DOMAIN_RESOURCE_TYPE = "Security Domain";
private static String AUTH_CLASSIC_RESOURCE_TYPE = "Authentication (Classic)";
private static String AUTH_CLASSIC_RESOURCE_KEY = "authentication=classic";
- private static String PROFILE = "profile=full-ha";
- protected static final String DC_HOST = System.getProperty("jboss.domain.bindAddress");
- protected static final int DC_HTTP_PORT = Integer.valueOf(System.getProperty("jboss.domain.httpManagementPort"));
- protected static final String DC_USER = AbstractJBossAS7PluginTest.MANAGEMENT_USERNAME;
- protected static final String DC_PASS = AbstractJBossAS7PluginTest.MANAGEMENT_PASSWORD;
+ private static Resource securityResource = null;
+
+ protected static String DC_HOST = System.getProperty("jboss.domain.bindAddress");
+ protected static int DC_HTTP_PORT = Integer.valueOf(System.getProperty("jboss.domain.httpManagementPort"));
+ protected static String DC_USER = AbstractJBossAS7PluginTest.MANAGEMENT_USERNAME;
+ protected static String DC_PASS = AbstractJBossAS7PluginTest.MANAGEMENT_PASSWORD;
ASConnection getASConnection() {
ASConnection connection = new ASConnection(DC_HOST, DC_HTTP_PORT, DC_USER, DC_PASS);
@@ -125,6 +126,21 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
"[{\"flag\":\"optional\", \"code\":\"TRUST\", \"module-options\":{\"trust\":\"module\", \"trust1\":\"module1\"}}]");
}
+ /* This first discovery is only so that we can leverage existing code to install the management user needed
+ * in next test.
+ */
+ @Test(priority = 10, groups = "discovery")
+ @RunDiscovery(discoverServices = true, discoverServers = true)
+ public void firstDiscovery() throws Exception {
+ Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
+ assertNotNull(platform);
+ assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
+
+ //now install mgmt users.
+ System.out.println("------ * Duplicating discovery for SecurityModule testing....");
+ installManagementUsers();
+ }
+
/** This method mass loads all the supported Module Option Types(Excluding authentication=jaspi, cannot co-exist with
* authentication=classic) into a single SecurityDomain. This is done as
* -i)creating all of the related hierarchy of types needed to exercise N Module Options Types and their associated
@@ -134,13 +150,13 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
*
* @throws Exception
*/
- @Test(priority = 10)
- public void testLoadStandardModuleOptionTypes() throws Exception {
+ @Test(priority = 11)
+ public void loadStandardModuleOptionTypes() throws Exception {
mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
//Adjust discovery depth to support deeper hierarchy depth of Module Option elements
- setMaxDiscoveryDepthOverride(10);
+ setMaxDiscoveryDepthOverride(12);
//create new Security Domain
Address destination = new Address(PROFILE);
@@ -150,13 +166,16 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
ASConnection connection = getASConnection();
Result result = new Result();
+ Operation op = null;
//delete old one if present to setup clean slate
- Operation op = new Operation("remove", destination);
+ op = new Operation("remove", destination);
result = connection.execute(op);
//build/rebuild hierarchy
op = new Operation("add", destination);
result = connection.execute(op);
+ assert result.getOutcome().equals("success") : "Add of Security Domain has failed: "
+ + result.getFailureDescription();
//Ex. profile=standalone-ha,subsystem=security,security-domain
String addressPrefix = PROFILE + "," + SECURITY_RESOURCE_KEY + "," + SECURITY_DOMAIN_RESOURCE_KEY;
@@ -205,15 +224,20 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
}
}
- @Test(priority = 11, groups = "discovery")
+ /** Runs the second discovery run to load all the new types added.
+ *
+ * @throws Exception
+ */
+ @Test(priority = 12, groups = "discovery")
@RunDiscovery(discoverServices = true, discoverServers = true)
- public void initialDiscovery() throws Exception {
+ public void secondDiscovery() throws Exception {
Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
assertNotNull(platform);
assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
- //Have thread sleep longer to discover deeper resource types.
- Thread.sleep(120 * 1000L); // delay so that PC gets a chance to scan for resources
+ //Have thread sleep longer to discover deeper resource types.
+ //spinder 6/29/12: up this number if the resources are not being discovered.
+ Thread.sleep(180 * 1000L); // delay so that PC gets a chance to scan for resources
}
/** This test method exercises a number of things:
@@ -225,7 +249,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
*
* @throws Exception
*/
- @Test(priority = 12)
+ @Test(priority = 13)
public void testDiscoveredSecurityNodes() throws Exception {
//lazy-load configurationManager
if (testConfigurationManager == null) {
@@ -246,13 +270,14 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
}
//Ex. name=acl-modules
//check the configuration for the Module Option Type Ex. 'Acl (Profile)' Resource. Should be able to verify components
- Resource aclResource = getModuleOptionResourceResource(attribute);
+ Resource moduleOptionsTypeResource = getModuleOptionTypeResource(attribute);
//assert non-zero id returned
- assert aclResource.getId() > 0 : "The resource was not properly initialized. Expected id >0 but got:"
- + aclResource.getId();
+ assert moduleOptionsTypeResource.getId() > 0 : "The resource was not properly initialized. Expected id >0 but got:"
+ + moduleOptionsTypeResource.getId();
//Now request the resource complete with resource config
- Configuration loadedConfiguration = testConfigurationManager.loadResourceConfiguration(aclResource.getId());
+ Configuration loadedConfiguration = testConfigurationManager
+ .loadResourceConfiguration(moduleOptionsTypeResource.getId());
String code = null;
String type = null;
String flag = null;
@@ -300,11 +325,40 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
assert moduleOptionType.getFlag().equals(flag) : "Provider Module 'flag' value is not correct. Expected '"
+ flag + "' but was '" + moduleOptionType.getFlag() + "'";
}
+
+ //Retrieve Module Options and test
+ //Ex. Module Options for (Acl Modules - Profile)
+ Resource moduleOptionsResource = getModuleOptionsResource(moduleOptionsTypeResource, attribute);
+ //assert non-zero id returned
+ assert moduleOptionsResource.getId() > 0 : "The resource was not properly initialized. Expected id > 0 but got:"
+ + moduleOptionsResource.getId();
+ //fetch configuration for module options
+ //Now request the resource complete with resource config
+ Configuration loadedOptionsConfiguration = testConfigurationManager
+ .loadResourceConfiguration(moduleOptionsResource.getId());
+ for (String key : loadedOptionsConfiguration.getAllProperties().keySet()) {
+ //retrieve the open map of Module Options
+ PropertyMap map = ((PropertyMap) loadedOptionsConfiguration.getAllProperties().get(key));
+ LinkedHashMap<String, Object> options = moduleOptionType.getOptions();
+ for (String optionKey : map.getMap().keySet()) {
+ PropertySimple property = (PropertySimple) map.getMap().get(optionKey);
+ //test the key
+ assert options.containsKey(optionKey) : "Unable to find expected option key '" + optionKey
+ + "'. Check hierarchy.";
+ //now the value.
+ String value = String.valueOf(options.get(optionKey));
+ assert value.equals(property.getStringValue()) : "Unable to find expected Module Option mapping. Key '"
+ + optionKey
+ + "' did not map to expected value '"
+ + value
+ + "' but was '"
+ + property.getStringValue() + "'.";
+ }
+ }
}
- //TODO spinder 6-26-12: retrieve the Module Options and test them too.
}
- @Test(priority = 13)
+ @Test(priority = 14)
public void testCreateSecurityDomain() throws Exception {
//get the root security resource
securityResource = getResource();
@@ -332,7 +386,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
+ response.getErrorMessage();
}
- @Test(priority = 14)
+ @Test(priority = 15)
public void testAuthenticationClassic() throws Exception {
//get the root security resource
securityResource = getResource();
@@ -371,7 +425,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
+ response.getErrorMessage();
}
- @Test(priority = 15)
+ @Test(priority = 16)
public void testDeleteSecurityDomain() throws Exception {
//get the root security resource
securityResource = getResource();
@@ -405,7 +459,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
// public static void main(String[] args) {
// SecurityModuleOptionsTest setup = new SecurityModuleOptionsTest();
// try {
- // setup.testLoadStandardModuleOptionTypes();
+ // setup.loadStandardModuleOptionTypes();
// } catch (Exception e) {
// e.printStackTrace();
// }
@@ -421,12 +475,12 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
return bindings;
}
- /** Automates
+ /** Automates hierarchy creation for Module Option type resources and their parents
*
* @param optionAttributeType
* @return
*/
- private Resource getModuleOptionResourceResource(String optionAttributeType) {
+ private Resource getModuleOptionTypeResource(String optionAttributeType) {
Resource moduleOptionResource = null;
String securityDomainId = SECURITY_DOMAIN_RESOURCE_KEY + "=" + TEST_DOMAIN + "2";
if (testSecurityDomain == null) {
@@ -497,6 +551,60 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
return moduleOptionResource;
}
+ /** Automates hierarchy creation for Module Option type resources and their parents
+ *
+ * @param optionAttributeType
+ * @return
+ */
+ private Resource getModuleOptionsResource(Resource parent, String optionAttributeType) {
+ Resource moduleOptionsResource = null;
+ String descriptorName = "";
+ String moduleAttribute = "";
+ String moduleOptionsDescriptor = "";
+ if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Acl.getAttribute())) {
+ // descriptorName = "ACL Modules (Profile)";
+ descriptorName = "Acl Modules (Profile)";
+ moduleAttribute = "acl=classic";
+ moduleOptionsDescriptor = "Module Options (Acl - Profile)";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Audit.getAttribute())) {
+ descriptorName = "Provider Modules (Profile)";
+ moduleAttribute = "audit=classic";
+ moduleOptionsDescriptor = "Module Options (Provider Modules - Profile)";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Authentication.getAttribute())) {
+ descriptorName = "Login Modules (Classic - Profile)";
+ moduleAttribute = "authentication=classic";
+ moduleOptionsDescriptor = "Module Options (Classic - Profile)";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Authorization.getAttribute())) {
+ descriptorName = "Authorization Modules (Profile)";
+ moduleAttribute = "authorization=classic";
+ moduleOptionsDescriptor = "Module Options (Authorization - Profile)";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.IdentityTrust.getAttribute())) {
+ descriptorName = "Identity Trust Modules (Profile)";
+ moduleAttribute = "identity-trust=classic";
+ moduleOptionsDescriptor = "Module Options (Identity Trust - Profile)";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Mapping.getAttribute())) {
+ descriptorName = "Mapping Modules (Profile)";
+ moduleAttribute = "mapping=classic";
+ moduleOptionsDescriptor = "Module Options (Mapping - Profile)";
+ }
+ //Build the right Module Option Type. Ex. ACL Modules (Profile), etc.
+ ResourceType modulesType = new ResourceType(descriptorName, PLUGIN_NAME, ResourceCategory.SERVICE, null);
+ //Ex. profile=full-ha,subsystem=security,security-domain=testDomain2,acl=classic,acl-modules:0
+ String sharedRoot = "profile=full-ha,subsystem=security,security-domain=testDomain2";
+ String moduleOptionTypeKey = sharedRoot += "," + moduleAttribute + ","
+ + optionAttributeType + ":0";
+ //Ex. Module Options Type children [ACL Modules (Profile),etc.]
+ Resource modulesInstance = getResourceByTypeAndKey(parent, modulesType, moduleOptionTypeKey);
+
+ //Module Options
+ ResourceType moduleOptionsType = new ResourceType(moduleOptionsDescriptor, PLUGIN_NAME,
+ ResourceCategory.SERVICE, null);
+ moduleOptionsResource = getResourceByTypeAndKey(modulesInstance, moduleOptionsType, moduleOptionTypeKey
+ + ",module-options");
+
+ return moduleOptionsResource;
+ }
+
private Resource getResource(Resource parentResource, String pluginDescriptorTypeName, String resourceKey) {
Resource resource = null;
if (((parentResource != null) & (pluginDescriptorTypeName != null) & (resourceKey != null))
@@ -515,288 +623,52 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
return created;
}
- //##################################################################
- // /**The test reads the existing property values, deserializes them and writes the same
- // * contents back out to a running instance for all known ModuleOptionTypes.
- // *
- // * @throws Exception
- // */
- // public void testPopulateModuleOptionsAndTypes() throws Exception {
- //
- // //as7 node details.
- // String securityDomainId = "testDomain";
- // //TODO: spinder 6-6-12: this cannot run as a standalone itest until JIRA https://issues.jboss.org/browse/AS7-4951
- // // is addressed as there is no way to automate setup of the information being tested.
- // String address = "subsystem=security,security-domain=" + securityDomainId + ",authentication=classic";
- // boolean verboseOutput = true;
- // boolean executeOperation = true;
- // for (ModuleOptionType t : ModuleOptionType.values()) {
- // String attribute = t.getAttribute();
- // if (verboseOutput) {
- // System.out.println("======= Running with ModuleOptionType:" + t + " attribute:" + attribute + ":");
- // }
- // if (attribute.equals("policy-modules")) {
- // address = "subsystem=security,security-domain=" + securityDomainId + ",authorization=classic";
- // } else if (attribute.equals("acl-modules")) {
- // address = "subsystem=security,security-domain=" + securityDomainId + ",acl=classic";
- // } else if (attribute.equals("mapping-modules")) {
- // address = "subsystem=security,security-domain=" + securityDomainId + ",mapping=classic";
- // } else if (attribute.equals("trust-modules")) {
- // address = "subsystem=security,security-domain=" + securityDomainId + ",identity-trust=classic";
- // } else if (attribute.equals("provider-modules")) {
- // address = "subsystem=security,security-domain=" + securityDomainId + ",audit=classic";
- // } else if (attribute.equals("login-modules")) {
- // address = "subsystem=security,security-domain=" + securityDomainId + ",authentication=classic";
- // } else {
- // assert false : "An unknown attribute '" + attribute
- // + "' was found. Is there a new type to be supported?";
- // }
- //
- // //test operation- read property always available.
- // Operation op = null;
- //
- // //read the login-modules attribute
- // op = new ReadAttribute(new Address(address), attribute);
- // Result result = exerciseOperation(op, true, verboseOutput);
- // assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
- // + result.getFailureDescription();
- // //extract current results
- // Object rawResult = result.getResult();
- // assert rawResult != null : "Read of attribute'" + attribute + "' from address '" + address
- // + "' has returned no value. Are those values in the model?";
- //
- // List<Value> list2 = new ArrayList<Value>();
- // //populate the Value component complete with module Options.
- // list2 = moc.populateSecurityDomainModuleOptions(result,
- // ModuleOptionsComponent.loadModuleOptionType(attribute));
- // if (verboseOutput) {
- // if (rawResult != null) {
- // System.out.println("Raw Result is:" + rawResult + " and of type:" + rawResult.getClass());
- // } else {
- // System.out.println("Read of attribute'" + attribute + "' from address '" + address
- // + "' has returned no value. Are those values in the model?");
- // }
- // }
- // //write the login-modules attribute
- // op = new WriteAttribute(new Address(address));
- // op.addAdditionalProperty("name", attribute);//attribute to execute on
- // op.addAdditionalProperty("value", list2);
- //
- // //Now test the operation
- // result = exerciseOperation(op, executeOperation, verboseOutput);
- // assert ((result.isSuccess() == true) || (result.getOutcome() == null)) : "The operation '" + op
- // + "' failed to write the resource.." + result.getFailureDescription();
- //
- // //read the login-modules attribute
- // op = new ReadAttribute(new Address(address), attribute);
- // result = exerciseOperation(op, true, verboseOutput);
- // assert (result.isSuccess() == true) : "The operation '" + op + "' failed to read the resource."
- // + result.getFailureDescription();
- // }
- // if (verboseOutput) {
- // System.out.println("Successfully detected,read and wrote out attribute values for:");
- // for (ModuleOptionType type : ModuleOptionType.values()) {
- // System.out.println("\n" + type.ordinal() + " " + type.name());
- // }
- // }
- // }
- //
- // /**Attempts to create a new Authentication node(authentication=classic) with a
- // * 'login-modules' attribute complete with 'code':'Ldap' and 'flag':'required'
- // * and some sample 'module-options' values.
- // *
- // */
- // @Test(enabled = true)
- // public void testCreateSecurityDomainChildLoginModules() {
- // boolean execute = true;
- // boolean verboseOutput = false;
- // String address = "subsystem=security,security-domain=testDomain3,authentication=classic";
- // String attribute = ModuleOptionType.Authentication.getAttribute();
- //
- // //test operation- read property always available.
- // Operation op = null;
- //
- // //read the login-modules attribute
- // op = new ReadAttribute(new Address(address), attribute);
- // Result result = exerciseOperation(op, execute, verboseOutput);
- // assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
- // + result.getFailureDescription();
- //
- // //extract current results
- // Object rawResult = result.getResult();
- //
- // //#### Have to create new content for the new node.
- // List<Value> moduleTypeValue = new ArrayList<Value>();
- // try {
- // // loading 'login-module'
- // JsonNode node = mapper.readTree(jsonMap.get(attribute));
- // result.setResult(mapper.treeToValue(node, Object.class));
- // } catch (JsonProcessingException e) {
- // e.printStackTrace();
- // } catch (IOException e) {
- // e.printStackTrace();
- // }
- //
- // //populate the Value component complete with module Options.
- // moduleTypeValue = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
- // ModuleOptionsComponent.loadModuleOptionType(attribute));
- //
- // //add the login-modules attribute
- // op = ModuleOptionsComponent
- // .createAddModuleOptionTypeOperation(new Address(address), attribute, moduleTypeValue);
- //
- // result = exerciseOperation(op, execute, verboseOutput);
- // assert ((result.isSuccess() == true) || (result.getOutcome() == null)) : "The operation '" + op
- // + "' failed to write the resource.." + result.getFailureDescription();
- //
- // //read the login-modules attribute
- // op = new ReadAttribute(new Address(address), attribute);
- // result = exerciseOperation(op, execute, verboseOutput);
- // assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
- // + result.getFailureDescription();
- //
- // //exercise values retrieved from read
- // List<Value> serverResponse = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
- // ModuleOptionsComponent.loadModuleOptionType(attribute));
- // Value serverState = serverResponse.get(0);
- // assert serverState.getFlag().equals("required") : "Incorrect state retrieved for 'flag'. Expected 'required'.";
- // assert serverState.getCode().equals("Ldap") : "Incorrect state retrieved for 'code'. Expected 'Ldap'.";
- // LinkedHashMap<String, Object> options = serverState.getOptions();
- // assert options.size() == 3 : "Invalid number of module options returned. Expected 3.";
- // int found = 0;
- // for (String key : options.keySet()) {
- // if (key.equals("bindPw")) {
- // assert "test126".equals(options.get(key)) : "Module option value not correct for key '" + key + "'.";
- // found++;
- // } else if (key.equals("bindDn")) {
- // assert "uid=ldapSecureUser,ou=People,dc=redat,dc=com".equals(options.get(key)) : "Module option value not correct for key '"
- // + key + "'.";
- // found++;
- // } else if (key.equals("allowEmptyPasswords")) {
- // assert "true".equals(options.get(key)) : "Module option value not correct for key '" + key + "'.";
- // found++;
- // }
- // }
- // assert found == 3 : "All module options were not loaded.";
- //
- // //remove the original node to reset for next run.
- // op = new Remove(new Address(address));
- // result = exerciseOperation(op, execute, verboseOutput);
- // assert result.isSuccess() == true : "The operation '" + op + "' failed to remove the resource."
- // + result.getFailureDescription();
- // }
- //
- // /** For each operation
- // * - will write verbose json and operation details to system.out if verboseOutput = true;
- // * - will execute the operation against running server if execute = true.
- // *
- // * @param op
- // * @param execute
- // * @param verboseOutput
- // * @return
- // */
- // public static Result exerciseOperation(Operation op, boolean execute, boolean verboseOutput) {
- // //display operation as AS7 plugin will build it
- // if (verboseOutput) {
- // System.out.println("\tOperation is:" + op);
- // }
- //
- // String jsonToSend = "";
- // try {
- // jsonToSend = mapper.defaultPrettyPrintingWriter().writeValueAsString(op);
- // } catch (JsonGenerationException e) {
- // e.printStackTrace();
- // } catch (JsonMappingException e) {
- // e.printStackTrace();
- // } catch (IOException e) {
- // e.printStackTrace();
- // }
- // //As generated by jackson mapper
- // if (verboseOutput) {
- // System.out.println("@@@@ OUTBOUND JSON#\n" + jsonToSend + "#");
- // }
- //
- // //Execute the operation
- // Result result = new Result();
- // if (execute) {
- // result = con.execute(op);
- // } else {
- // if (verboseOutput) {
- // System.out.println("**** NOTE: Execution disabled . NOT exercising write-attribute operation. **** ");
- // }
- // }
- // if (verboseOutput) {
- // //result wrapper details
- // System.out.println("\tResult:" + result);
- // //detailed results
- // System.out.println("\tValue:" + result.getResult());
- // System.out.println("-----------------------------------------------------\n");
- // }
- // return result;
- // }
- //
- // @Test(priority = 10, groups = "discovery")
- // public void initialSetup() throws Exception {
- // String securityDomainId = TEST_DOMAIN + "1";
- // Result result = null;
- // Operation op = null;
- //
- // //create the initial securityDomain
- // op = new Operation("add", new Address("subsystem=security,security-domain=" + securityDomainId));
- // ASConnection connection = getASConnection();
- // con = connection;
- // mapper = new ObjectMapper();
- // mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
- //
- // moc = new ModuleOptionsComponent();
- // result = connection.execute(op);
- // System.out.println("#### Op is:" + op);
- // System.out.println("#### Result is:" + result);
- //
- // //iterate over jsonMap
- // for (String key : jsonMap.keySet()) {
- // String attribute = key;
- // String address = "";
- // if (attribute.equals("policy-modules")) {
- // address = "subsystem=security,security-domain=" + securityDomainId + ",authorization=classic";
- // } else if (attribute.equals("acl-modules")) {
- // address = "subsystem=security,security-domain=" + securityDomainId + ",acl=classic";
- // } else if (attribute.equals("mapping-modules")) {
- // address = "subsystem=security,security-domain=" + securityDomainId + ",mapping=classic";
- // } else if (attribute.equals("trust-modules")) {
- // address = "subsystem=security,security-domain=" + securityDomainId + ",identity-trust=classic";
- // } else if (attribute.equals("provider-modules")) {
- // address = "subsystem=security,security-domain=" + securityDomainId + ",audit=classic";
- // } else if (attribute.equals("login-modules")) {
- // address = "subsystem=security,security-domain=" + securityDomainId + ",authentication=classic";
- // } else {
- // assert false : "An unknown attribute '" + attribute
- // + "' was found. Is there a new type to be supported?";
- // }
- // //#### Have to create new content for the new node.
- // List<Value> moduleTypeValue = new ArrayList<Value>();
- //
- // try {
- // // loading 'login-module'
- // JsonNode node = mapper.readTree(jsonMap.get(attribute));
- // result.setResult(mapper.treeToValue(node, Object.class));
- // } catch (JsonProcessingException e) {
- // e.printStackTrace();
- // } catch (IOException e) {
- // e.printStackTrace();
- // }
- //
- // //populate the Value component complete with module Options.
- // moduleTypeValue = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
- // ModuleOptionsComponent.loadModuleOptionType(attribute));
- //
- // //add the login-modules attribute
- // op = ModuleOptionsComponent.createAddModuleOptionTypeOperation(new Address(address), attribute,
- // moduleTypeValue);
- //
- // result = exerciseOperation(op, true, true);
- // assert ((result.isSuccess() == true) || (result.getOutcome() == null)) : "The operation '" + op
- // + "' failed to write the resource.." + result.getFailureDescription();
- // }
- // }
+ /** For each operation
+ * - will write verbose json and operation details to system.out if verboseOutput = true;
+ * - will execute the operation against running server if execute = true.
+ *
+ * @param op
+ * @param execute
+ * @param verboseOutput
+ * @return
+ */
+ public static Result exerciseOperation(Operation op, boolean execute, boolean verboseOutput) {
+ //display operation as AS7 plugin will build it
+ if (verboseOutput) {
+ System.out.println("\tOperation is:" + op);
+ }
+
+ String jsonToSend = "";
+ try {
+ jsonToSend = mapper.defaultPrettyPrintingWriter().writeValueAsString(op);
+ } catch (JsonGenerationException e) {
+ e.printStackTrace();
+ } catch (JsonMappingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ //As generated by jackson mapper
+ if (verboseOutput) {
+ System.out.println("@@@@ OUTBOUND JSON#\n" + jsonToSend + "#");
+ }
+
+ //Execute the operation
+ Result result = new Result();
+ if (execute) {
+ result = con.execute(op);
+ } else {
+ if (verboseOutput) {
+ System.out.println("**** NOTE: Execution disabled . NOT exercising write-attribute operation. **** ");
+ }
+ }
+ if (verboseOutput) {
+ //result wrapper details
+ System.out.println("\tResult:" + result);
+ //detailed results
+ System.out.println("\tValue:" + result.getResult());
+ System.out.println("-----------------------------------------------------\n");
+ }
+ return result;
+ }
}
commit 8e3709f8d7a7ffce5b44322a656836be13a7a652
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jun 27 13:24:00 2012 -0400
[Bug 835113 - EJB2 MDBs are DOWN in JON UI]
Restructure getAvailability() and getManagedComponent() to remove
ambiguity in UNKNOWN runState handling as well as provide consistent
Exception throwing/handling, and ManagedComponent refresh. Simplify the
override point for getManagedComponent.
Remove Ejb2BeanComponent's special-handling for UNKNOWN runState, previously committed for
this fix, in favor of the new base handling.
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java
index c4ae68f..95ba080 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java
@@ -27,9 +27,7 @@ import java.util.Set;
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.RunState;
-import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.plugins.jbossas5.util.Ejb2BeanUtils;
/**
@@ -40,27 +38,15 @@ import org.rhq.plugins.jbossas5.util.Ejb2BeanUtils;
public class Ejb2BeanComponent extends AbstractEjbBeanComponent {
private static final ComponentType MDB_COMPONENT_TYPE = new ComponentType("EJB", "MDB");
+
@Override
- protected AvailabilityType getAvailabilityForRunState(RunState runState) {
- AvailabilityType avail;
- if (MDB_COMPONENT_TYPE.equals(getComponentType())) {
- // This is a workaround for if BZ 835113.
- avail = (runState == RunState.RUNNING || runState == RunState.UNKNOWN) ?
- AvailabilityType.UP : AvailabilityType.DOWN;
- } else {
- avail = super.getAvailabilityForRunState(runState);
+ protected ManagedComponent getManagedComponent(ManagementView mv) throws Exception {
+ if (null == mv) {
+ throw new IllegalArgumentException("managementView can not be null");
}
- return avail;
- }
- @Override
- protected ManagedComponent getManagedComponent() {
if (MDB_COMPONENT_TYPE.equals(getComponentType())) {
try {
- //we need to reload the management view here, because the MDBs might have changed since
- //the last call, because the @object-id is part of their names.
- ManagementView mv = getConnection().getManagementView();
-
Set<ManagedComponent> mdbs = mv.getComponentsForType(MDB_COMPONENT_TYPE);
for (ManagedComponent mdb : mdbs) {
@@ -73,7 +59,7 @@ public class Ejb2BeanComponent extends AbstractEjbBeanComponent {
throw new IllegalStateException(e);
}
} else {
- return super.getManagedComponent();
+ return super.getManagedComponent(mv);
}
return null;
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java
index a44cfc8..da0b24b 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java
@@ -104,19 +104,21 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
*/
private static final long AVAIL_REFRESH_INTERVAL = 1000 * 60 * 15; // 15 minutes
+ private long availRefreshInterval = AVAIL_REFRESH_INTERVAL;
+
/**
* The ManagedComponent is fetched from the server in {@link #getManagedComponent} throughout
* the life cycle of this resource component. For example during metrics collections
- * when getValues is invoked, getManagedComponent is called. Any time getManagedComponent
+ * when getValues() is invoked, getManagedComponent() is called. Any time getManagedComponent()
* is called the lastComponentRefresh timestamp is updated. This timestamp is used in
* {@link #getAvailability} to determine whether or not a component is needed to
* perform an availability check.
*/
private long lastComponentRefresh = 0L;
- private long availRefreshInterval = AVAIL_REFRESH_INTERVAL;
-
- private RunState runState = RunState.UNKNOWN;
+ // The last known runState for the component. This is used to determine the result of getAvailability(). We
+ // do *not* cache the entire ManagedComponent because it is potentially a huge object that would eat too much memory.
+ private RunState runState;
private String componentName;
private ComponentType componentType;
@@ -124,20 +126,19 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
// ResourceComponent Implementation --------------------------------------------
public AvailabilityType getAvailability() {
- if (lastComponentRefresh == 0) {
- // The managed component has not been refreshed at all yet.
- getManagedComponent();
- } else {
- long timeSinceComponentRefresh = System.currentTimeMillis() - lastComponentRefresh;
- if (timeSinceComponentRefresh > availRefreshInterval) {
- if (log.isDebugEnabled()) {
- log.debug("The availability refresh interval for [resourceKey: "
- + getResourceContext().getResourceKey() + ", type: " + componentType + ", name: " + componentName
- + "] has been exceeded by " + (timeSinceComponentRefresh - availRefreshInterval)
- + " ms. Reloading managed component...");
- }
- getManagedComponent();
+ long timeSinceComponentRefresh = System.currentTimeMillis() - lastComponentRefresh;
+ boolean refresh = timeSinceComponentRefresh > availRefreshInterval;
+
+ if (refresh) {
+ if (lastComponentRefresh > 0L && log.isDebugEnabled()) {
+ log.debug("The availability refresh interval for [resourceKey: "
+ + getResourceContext().getResourceKey() + ", type: " + componentType + ", name: " + componentName
+ + "] has been exceeded by " + (timeSinceComponentRefresh - availRefreshInterval)
+ + " ms. Reloading managed component...");
}
+
+ ManagedComponent managedComponent = getManagedComponent();
+ runState = managedComponent.getRunState();
}
return getAvailabilityForRunState(runState);
@@ -146,11 +147,14 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
protected AvailabilityType getAvailabilityForRunState(RunState runState) {
if (runState == RunState.RUNNING) {
return AvailabilityType.UP;
+
} else {
if (log.isDebugEnabled()) {
- log.debug(componentType + " component '" + componentName + "' was not running - state was [" + runState
- + "].");
+ log.debug("Returning DOWN avail for " + componentType + " component '" + componentName
+ + "' with runState [" + runState
+ + "].");
}
+
return AvailabilityType.DOWN;
}
}
@@ -438,29 +442,58 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
return componentName;
}
+ /**
+ * This method should most likely not be overridden. Instead, override {@link #getManagedComponent(ManagementView)}.
+ * <br/><br/>
+ * IMPORTANT!!! The returned ManagedComponent SHOULD NOT be cached in the instance. It is potentially a memory hog.
+ *
+ * @return The ManagedComponent
+ * @throws RuntimeException if fetching the ManagementView or getting the component fails
+ * @throws IllegalStateException if the managedComponent is null/not found
+ */
+ @NotNull
protected ManagedComponent getManagedComponent() {
ManagedComponent managedComponent;
+
try {
ManagementView managementView = getConnection().getManagementView();
- managedComponent = managementView.getComponent(this.componentName, this.componentType);
+ managedComponent = getManagedComponent(managementView);
} catch (Exception e) {
- runState = RunState.UNKNOWN;
throw new RuntimeException("Failed to load [" + this.componentType + "] ManagedComponent ["
+ this.componentName + "].", e);
}
+
+ // Even if not found, update the refresh time. It will avoid too many costly, and potentially fruitless, fetches
+ lastComponentRefresh = System.currentTimeMillis();
+
if (managedComponent == null) {
- runState = RunState.UNKNOWN;
throw new IllegalStateException("Failed to find [" + this.componentType + "] ManagedComponent named ["
+ this.componentName + "].");
}
+
if (log.isTraceEnabled()) {
log.trace("Retrieved " + toString(managedComponent) + ".");
}
- lastComponentRefresh = System.currentTimeMillis();
- runState = managedComponent.getRunState();
+
return managedComponent;
}
+ /**
+ * This is an override point. When actually fetching the managed component, this entry point should not be
+ * used. Instead, access should be via {@link #getManagedComponent()}.
+ *
+ * @param managementView
+ * @return the ManagedComponent. Null if not found.
+ * @Throws Exception if there is a problem getting the component.
+ */
+ protected ManagedComponent getManagedComponent(ManagementView managementView) throws Exception {
+ if (null == managementView) {
+ throw new IllegalArgumentException("managementView can not be null");
+ }
+
+ return managementView.getComponent(this.componentName, this.componentType);
+ }
+
@NotNull
private OperationDefinition getOperationDefinition(String operationName) {
ResourceType resourceType = getResourceContext().getResourceType();
commit 4699b70c9bde96b1c95c89e7e9b32e6ff73ad860
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Jun 27 15:55:28 2012 +0200
formatting only
diff --git a/modules/core/client-api/pom.xml b/modules/core/client-api/pom.xml
index 834ad85..6f6a937 100644
--- a/modules/core/client-api/pom.xml
+++ b/modules/core/client-api/pom.xml
@@ -1,285 +1,288 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-parent</artifactId>
- <version>4.5.0-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-parent</artifactId>
+ <version>4.5.0-SNAPSHOT</version>
+ </parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-client-api</artifactId>
- <packaging>jar</packaging>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-client-api</artifactId>
+ <packaging>jar</packaging>
- <name>RHQ Client API</name>
- <description>Server and Client APIs for invoking operations on the RHQ plugin container</description>
+ <name>RHQ Client API</name>
+ <description>Server and Client APIs for invoking operations on the RHQ plugin container</description>
- <dependencies>
+ <dependencies>
- <dependency>
- <groupId>${rhq.groupId}</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
- <dependency>
- <groupId>${rhq.groupId}</groupId>
- <artifactId>rhq-core-comm-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-core-comm-api</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
- <dependency>
- <groupId>${rhq.groupId}</groupId>
- <artifactId>rhq-common-drift</artifactId>
- <version>${project.version}</version>
- </dependency>
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-common-drift</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- TODO: This is a fix for the Javac bug requiring annotations to be
available when compiling dependent classes; it is fixed in JDK 6. -->
- <dependency>
- <groupId>jboss.jboss-embeddable-ejb3</groupId>
- <artifactId>hibernate-all</artifactId>
- <version>1.0.0.Alpha9</version>
- <scope>provided</scope>
+ <dependency>
+ <groupId>jboss.jboss-embeddable-ejb3</groupId>
+ <artifactId>hibernate-all</artifactId>
+ <version>1.0.0.Alpha9</version>
+ <scope>provided</scope>
<!-- set scope to 'provided', so Hibernate annotations can be used in the entities -->
- </dependency>
+ </dependency>
- <dependency>
- <groupId>jboss.jboss-embeddable-ejb3</groupId>
- <artifactId>jboss-ejb3-all</artifactId>
- <version>1.0.0.Alpha9</version>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>jboss.jboss-embeddable-ejb3</groupId>
+ <artifactId>jboss-ejb3-all</artifactId>
+ <version>1.0.0.Alpha9</version>
+ <scope>provided</scope>
+ </dependency>
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- </dependency>
+ </dependency>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
<!--<scope>test</scope> not sure about this -->
- </dependency>
+ </dependency>
- <dependency>
- <groupId>commons-jxpath</groupId>
- <artifactId>commons-jxpath</artifactId>
- <version>1.3</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>commons-jxpath</groupId>
+ <artifactId>commons-jxpath</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
- </dependencies>
+ </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>com.sun.tools.xjc.maven2</groupId>
- <artifactId>maven-jaxb-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.sun.tools.xjc.maven2</groupId>
+ <artifactId>maven-jaxb-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <generateDirectory>${basedir}/target/generated-sources/xjc</generateDirectory>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
<configuration>
- <generateDirectory>${basedir}/target/generated-sources/xjc</generateDirectory>
+ <includes>
+ <include>org/rhq/core/clientapi/shared/**</include>
+ </includes>
</configuration>
- </plugin>
+ </execution>
+ </executions>
+ </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-xjc-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
<configuration>
- <source>1.6</source>
+ <sources>
+ <source>${basedir}/target/generated-sources/xjc</source>
+ </sources>
</configuration>
- </plugin>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>test-jar</goal>
- </goals>
- <configuration>
- <includes>
- <include>org/rhq/core/clientapi/shared/**</include>
- </includes>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ <profiles>
+
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
+ <artifactId>maven-antrun-plugin</artifactId>
<executions>
+
<execution>
- <id>add-xjc-source</id>
- <phase>generate-sources</phase>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <target>
+ <mkdir dir="${rhq.deploymentDir}"/>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}"/>
+ </target>
+ </configuration>
<goals>
- <goal>add-source</goal>
+ <goal>run</goal>
</goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
<configuration>
- <sources>
- <source>${basedir}/target/generated-sources/xjc</source>
- </sources>
+ <target>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}"/>
+ </target>
</configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
</execution>
+
</executions>
</plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>dev</id>
-
- <properties>
- <rhq.rootDir>../../..</rhq.rootDir>
- <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
- </properties>
-
- <build>
- <plugins>
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
-
- <execution>
- <id>deploy</id>
- <phase>compile</phase>
- <configuration>
- <target>
- <mkdir dir="${rhq.deploymentDir}" />
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating ${deployment.file}...</echo>
- <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>undeploy</id>
- <phase>clean</phase>
- <configuration>
- <target>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Deleting ${deployment.file}...</echo>
- <delete file="${deployment.file}" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- </executions>
- </plugin>
-
- </plugins>
- </build>
- </profile>
+ </plugins>
+ </build>
+ </profile>
<profile>
<id>cobertura</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>net.sourceforge.cobertura</groupId>
- <artifactId>cobertura</artifactId>
- <version>${cobertura.version}</version>
- </dependency>
- </dependencies>
- <executions>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>net.sourceforge.cobertura</groupId>
+ <artifactId>cobertura</artifactId>
+ <version>${cobertura.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
<execution>
- <id>cobertura-instrument</id>
- <phase>process-test-classes</phase>
- <configuration>
- <target>
+ <id>cobertura-instrument</id>
+ <phase>process-test-classes</phase>
+ <configuration>
+ <target>
<!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/cobertura/backup" />
+ <mkdir dir="target/cobertura"/>
+ <mkdir dir="target/cobertura/backup"/>
<!-- backup all classes so that we can instrument the original classes-->
- <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
+ <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
<fileset dir="target/classes">
- <include name="**/*.class" />
+ <include name="**/*.class"/>
</fileset>
- </copy>
+ </copy>
<!-- create a properties file and save there location of cobertura data file-->
- <touch file="target/classes/cobertura.properties" />
- <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <touch file="target/classes/cobertura.properties"/>
+ <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties"/>
<!-- instrument all classes in target/classes directory -->
- <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes">
- <fileset dir="${project.build.directory}/classes">
- <include name="**/*.class" />
+ <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser"
+ todir="${project.build.directory}/classes">
+ <fileset dir="${project.build.directory}/classes">
+ <include name="**/*.class"/>
</fileset>
</cobertura-instrument>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
</execution>
<execution>
- <id>cobertura-report</id>
- <phase>prepare-package</phase>
- <configuration>
- <target>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <id>cobertura-report</id>
+ <phase>prepare-package</phase>
+ <configuration>
+ <target>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties"/>
<!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/site/cobertura" />
+ <mkdir dir="target/cobertura"/>
+ <mkdir dir="target/site/cobertura"/>
<!-- restore classes from backup folder to classes folder -->
- <copy toDir="target/classes" verbose="true" overwrite="true">
+ <copy toDir="target/classes" verbose="true" overwrite="true">
<fileset dir="target/cobertura/backup">
- <include name="**/*.class" />
+ <include name="**/*.class"/>
</fileset>
- </copy>
+ </copy>
<!-- delete backup folder-->
- <delete dir="target/cobertura/backup" />
+ <delete dir="target/cobertura/backup"/>
<!-- create a code coverage report -->
- <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura">
+ <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser"
+ destdir="${project.build.directory}/site/cobertura">
<fileset dir="${basedir}/src/main/java">
- <include name="**/*.java" />
+ <include name="**/*.java"/>
</fileset>
- </cobertura-report>
+ </cobertura-report>
<!-- delete cobertura.properties file -->
- <delete file="target/classes/cobertura.properties" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <delete file="target/classes/cobertura.properties"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
</executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index 29662c8..e3aca30 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -1,33 +1,34 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-parent</artifactId>
- <version>4.5.0-SNAPSHOT</version>
- <relativePath>../../../../pom.xml</relativePath>
- </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
<groupId>org.rhq</groupId>
- <artifactId>rhq-coregui</artifactId>
- <packaging>war</packaging>
+ <artifactId>rhq-parent</artifactId>
+ <version>4.5.0-SNAPSHOT</version>
+ <relativePath>../../../../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-coregui</artifactId>
+ <packaging>war</packaging>
- <name>RHQ Enterprise Core GUI</name>
- <description>the RHQ Enterprise Core GUI webapp</description>
+ <name>RHQ Enterprise Core GUI</name>
+ <description>the RHQ Enterprise Core GUI webapp</description>
- <properties>
+ <properties>
<!-- dependency versions -->
- <gwt.version>2.4.0</gwt.version>
- <smartgwt.version>3.0</smartgwt.version>
+ <gwt.version>2.4.0</gwt.version>
+ <smartgwt.version>3.0</smartgwt.version>
<!-- If this is too much memory to allocate to your gwt:debug process then override this property in
in your settings.xml -->
- <gwt-plugin.extraJvmArgs>-Xms512M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=256M</gwt-plugin.extraJvmArgs>
- <gwt-plugin.localWorkers>4</gwt-plugin.localWorkers>
+ <gwt-plugin.extraJvmArgs>-Xms512M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=256M</gwt-plugin.extraJvmArgs>
+ <gwt-plugin.localWorkers>4</gwt-plugin.localWorkers>
- <coreGuiParams />
- <coreGuiRunTarget>'http://localhost:7080/coregui/CoreGUI.html${coreGuiParams}'</coreGuiRunTarget>
+ <coreGuiParams/>
+ <coreGuiRunTarget>'http://localhost:7080/coregui/CoreGUI.html${coreGuiParams}'</coreGuiRunTarget>
<!--
This property is substituted, by the resource plugin during the resources phase, as the
@@ -52,201 +53,201 @@
Multiple agents can be specified as a comma-delimited list, as demonstrated by the default
value below.
-->
- <gwt.userAgent>ie8,ie9,gecko1_8,safari,opera</gwt.userAgent>
+ <gwt.userAgent>ie8,ie9,gecko1_8,safari,opera</gwt.userAgent>
<!-- Change this to "true" via the mvn command line or your ~/.m2/settings.xml to speed
up gwt compilation. -->
- <gwt.draftCompile>false</gwt.draftCompile>
+ <gwt.draftCompile>false</gwt.draftCompile>
<!-- Change this to "true" via the mvn command line or your ~/.m2/settings.xml to generate report -->
- <gwt.soyc>false</gwt.soyc>
+ <gwt.soyc>false</gwt.soyc>
<!-- Change this to "DETAILED" via the mvn command line or your ~/.m2/settings.xml to
make sure GWT-generated JavaScript code is not obfuscated. -->
- <gwt.style>PRETTY</gwt.style>
+ <gwt.style>PRETTY</gwt.style>
<!-- Comma-separated list of the locales that should be included during GWT compilation. The specified locales
should each have two corresponding message bundle properties files under
src/main/resources/org/rhq/enterprise/gui/coregui/client/. For example, the "ja" locale has
Messages_ja.properties and MessageConstants_ja.properties. -->
- <gwt.locale>en,de,ja,pt,zh,ru,cs</gwt.locale>
+ <gwt.locale>en,de,ja,pt,zh,ru,cs</gwt.locale>
<!-- The locale that GWT should fallback to if the user specified an unsupported locale via the 'locale' query
string parameter. -->
- <gwt.fallback.locale>en</gwt.fallback.locale>
-
- <enable.tags>true</enable.tags>
- </properties>
+ <gwt.fallback.locale>en</gwt.fallback.locale>
+
+ <enable.tags>true</enable.tags>
+ </properties>
- <dependencies>
+ <dependencies>
<!-- ============= Internal Deps ============= -->
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
<!-- by rhq.ear (as ejb-jar) -->
- </dependency>
+ </dependency>
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-enterprise-server</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
<!-- by rhq.ear (as ejb-jar) -->
- </dependency>
+ </dependency>
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-util</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-util</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
<!-- by rhq.ear -->
- </dependency>
+ </dependency>
<!-- =============== 3rd Party Deps =============== -->
- <dependency>
- <groupId>com.google.gwt</groupId>
- <artifactId>gwt-servlet</artifactId>
- <version>${gwt.version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>com.google.gwt</groupId>
- <artifactId>gwt-user</artifactId>
- <version>${gwt.version}</version>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwt-servlet</artifactId>
+ <version>${gwt.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwt-user</artifactId>
+ <version>${gwt.version}</version>
+ <scope>provided</scope>
+ </dependency>
<!-- This is so we can compile custom GWT Generators to be called during gwt compilation.
Is is not needed at runtime and so is not included in the WAR. -->
- <dependency>
- <groupId>com.google.gwt</groupId>
- <artifactId>gwt-dev</artifactId>
- <version>${gwt.version}</version>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwt-dev</artifactId>
+ <version>${gwt.version}</version>
+ <scope>provided</scope>
+ </dependency>
- <dependency>
- <groupId>com.smartgwt</groupId>
- <artifactId>smartgwt</artifactId>
- <version>${smartgwt.version}</version>
- </dependency>
+ <dependency>
+ <groupId>com.smartgwt</groupId>
+ <artifactId>smartgwt</artifactId>
+ <version>${smartgwt.version}</version>
+ </dependency>
<!-- the GWT graphing library (note, this provides jquery 1.3.2. If we get rid of GFlot we will need
to provide jquery explcitly for jquery.sparkline support. See CoreGUI.gwt.xml for the jquery.sparkline
declaration and coregui/webapp/js for the lib inclusion.) -->
- <dependency>
- <groupId>ca.nanometrics</groupId>
- <artifactId>gflot</artifactId>
- <version>1.0.0</version>
- </dependency>
+ <dependency>
+ <groupId>ca.nanometrics</groupId>
+ <artifactId>gflot</artifactId>
+ <version>1.0.0</version>
+ </dependency>
<!-- for file uploads -->
- <dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>1.2</version>
- </dependency>
-
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.3.1</version>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
- <scope>provided</scope>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.3.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <scope>provided</scope>
<!-- by JBossAS -->
- </dependency>
+ </dependency>
- <dependency>
- <groupId>org.opensymphony.quartz</groupId>
- <artifactId>quartz</artifactId>
+ <dependency>
+ <groupId>org.opensymphony.quartz</groupId>
+ <artifactId>quartz</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope>
+ <scope>provided</scope>
<!-- by JBossAS itself, which the container buildNodes has packaged with 1.6.5 -->
- </dependency>
+ </dependency>
<!-- needed for referenced domain entities that use Hibernate annotations (due to JDK5 bug) -->
- <dependency>
- <groupId>hibernate-annotations</groupId>
- <artifactId>hibernate-annotations</artifactId>
+ <dependency>
+ <groupId>hibernate-annotations</groupId>
+ <artifactId>hibernate-annotations</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope>
+ <scope>provided</scope>
<!-- by JBossAS -->
- </dependency>
+ </dependency>
<!-- transitive dependency needed for JspC -->
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- <scope>provided</scope>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
<!-- by JBossAS -->
- </dependency>
+ </dependency>
<!-- needed for referenced domain entities that use JPA annotations (due to JDK5 bug) -->
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
<!-- by JBossAS -->
- </dependency>
+ </dependency>
<!-- needed for EJB3 annotations (e.g. ApplicationException) -->
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-ejb3x</artifactId>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-ejb3x</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope>
+ <scope>provided</scope>
<!-- by JBossAS -->
- </dependency>
+ </dependency>
<!-- Needed due to JDK 1.5 bug. -->
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-annotations-ejb3</artifactId>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-annotations-ejb3</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope>
+ <scope>provided</scope>
<!-- by JBossAS -->
- </dependency>
+ </dependency>
- <dependency>
- <groupId>jboss.jbossws</groupId>
- <artifactId>jboss-jaxws</artifactId>
- <version>3.0.1-native-2.0.4.GA</version>
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
+ <dependency>
+ <groupId>jboss.jbossws</groupId>
+ <artifactId>jboss-jaxws</artifactId>
+ <version>3.0.1-native-2.0.4.GA</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxrs</artifactId>
- <version>${resteasy.version}</version>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>${resteasy.version}</version>
+ <scope>provided</scope>
+ </dependency>
- </dependencies>
+ </dependencies>
- <build>
- <finalName>coregui</finalName>
+ <build>
+ <finalName>coregui</finalName>
- <resources>
- <resource>
- <targetPath>${project.build.directory}/generated-sources/gwt</targetPath>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
+ <resources>
+ <resource>
+ <targetPath>${project.build.directory}/generated-sources/gwt</targetPath>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
<!--
Do NOT include java files here, because otherwise the java files from
resources would end up in WEB-INF/classes which definitely not something
@@ -259,110 +260,110 @@
need to replace the ${...} place-holders with the build-provided values
in there.
-->
- <includes>
- <include>**/*.gwt.xml</include>
- <include>**/*.properties</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include>**/*.java</include>
- </includes>
- </resource>
- </resources>
-
-
- <plugins>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>gwt-maven-plugin</artifactId>
- <version>2.4.0</version>
- <configuration>
- <noServer>true</noServer>
- <inplace>false</inplace>
+ <includes>
+ <include>**/*.gwt.xml</include>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </resource>
+ </resources>
+
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>gwt-maven-plugin</artifactId>
+ <version>2.4.0</version>
+ <configuration>
+ <noServer>true</noServer>
+ <inplace>false</inplace>
<!-- <logLevel>INFO' -bindAddress 0.0.0.0 -logLevel 'INFO</logLevel> -->
- <logLevel>INFO</logLevel>
- <runTarget>${coreGuiRunTarget}</runTarget>
- <extraJvmArgs>${gwt-plugin.extraJvmArgs}</extraJvmArgs>
- <localWorkers>${gwt-plugin.localWorkers}</localWorkers>
- <draftCompile>${gwt.draftCompile}</draftCompile>
- <soyc>${gwt.soyc}</soyc>
- <buildOutputDirectory>target/gwtclasses</buildOutputDirectory>
- <hostedWebapp>target/hostedWar</hostedWebapp>
- <debugSuspend>false</debugSuspend>
- <servicePattern>**/gwt/*GWTService.java</servicePattern>
- <i18nMessagesBundle>org.rhq.enterprise.gui.coregui.client.Messages</i18nMessagesBundle>
- <i18nConstantsWithLookupBundle>org.rhq.enterprise.gui.coregui.client.MessageConstants</i18nConstantsWithLookupBundle>
- <compileSourcesArtifact>org.rhq:rhq-core-domain</compileSourcesArtifact>
- <style>${gwt.style}</style>
- <strict>true</strict>
+ <logLevel>INFO</logLevel>
+ <runTarget>${coreGuiRunTarget}</runTarget>
+ <extraJvmArgs>${gwt-plugin.extraJvmArgs}</extraJvmArgs>
+ <localWorkers>${gwt-plugin.localWorkers}</localWorkers>
+ <draftCompile>${gwt.draftCompile}</draftCompile>
+ <soyc>${gwt.soyc}</soyc>
+ <buildOutputDirectory>target/gwtclasses</buildOutputDirectory>
+ <hostedWebapp>target/hostedWar</hostedWebapp>
+ <debugSuspend>false</debugSuspend>
+ <servicePattern>**/gwt/*GWTService.java</servicePattern>
+ <i18nMessagesBundle>org.rhq.enterprise.gui.coregui.client.Messages</i18nMessagesBundle>
+ <i18nConstantsWithLookupBundle>org.rhq.enterprise.gui.coregui.client.MessageConstants</i18nConstantsWithLookupBundle>
+ <compileSourcesArtifact>org.rhq:rhq-core-domain</compileSourcesArtifact>
+ <style>${gwt.style}</style>
+ <strict>true</strict>
<!-- compiles gwt artifacts like symbolMap outside of war so it doesnt get packaged -->
- <deploy>${project.build.directory}/gwt-deploy</deploy>
- </configuration>
-
- <executions>
- <execution>
- <id>gwt-goals</id>
- <goals>
- <goal>compile</goal>
- <goal>generateAsync</goal>
- <goal>i18n</goal>
- </goals>
- </execution>
- <execution>
+ <deploy>${project.build.directory}/gwt-deploy</deploy>
+ </configuration>
+
+ <executions>
+ <execution>
+ <id>gwt-goals</id>
+ <goals>
+ <goal>compile</goal>
+ <goal>generateAsync</goal>
+ <goal>i18n</goal>
+ </goals>
+ </execution>
+ <execution>
<!-- This id is what does the trick, don't change it. For this to work maven 2.2.0 and later is needed. -->
- <id>default-cli</id>
- <goals>
- <goal>debug</goal>
- </goals>
- <configuration>
- <module>org.rhq.enterprise.gui.coregui.CoreGUI</module>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- </manifest>
- <manifestEntries>
- <Build-Number>${buildNumber}</Build-Number>
- </manifestEntries>
- </archive>
- <webResources>
- <resource>
- <filtering>false</filtering>
- <directory>${basedir}/src/main/webapp</directory>
- </resource>
- </webResources>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-gwt-source</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>${basedir}/target/generated-sources/gwt</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ <id>default-cli</id>
+ <goals>
+ <goal>debug</goal>
+ </goals>
+ <configuration>
+ <module>org.rhq.enterprise.gui.coregui.CoreGUI</module>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ </manifest>
+ <manifestEntries>
+ <Build-Number>${buildNumber}</Build-Number>
+ </manifestEntries>
+ </archive>
+ <webResources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>${basedir}/src/main/webapp</directory>
+ </resource>
+ </webResources>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-gwt-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${basedir}/target/generated-sources/gwt</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
<!--
<plugin>
@@ -406,36 +407,36 @@
</executions>
</plugin>
-->
- </plugins>
+ </plugins>
- </build>
+ </build>
- <profiles>
- <profile>
- <id>dev</id>
+ <profiles>
+ <profile>
+ <id>dev</id>
- <properties>
- <rhq.rootDir>../../../..</rhq.rootDir>
- <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentName>${project.build.finalName}.war</rhq.deploymentName>
- <rhq.deploymentDir>
- ${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/${rhq.deploymentName}
+ <properties>
+ <rhq.rootDir>../../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentName>${project.build.finalName}.war</rhq.deploymentName>
+ <rhq.deploymentDir>
+ ${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/${rhq.deploymentName}
</rhq.deploymentDir>
- </properties>
+ </properties>
- <build>
- <plugins>
+ <build>
+ <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
- <execution>
- <id>deploy-classes</id>
- <phase>compile</phase>
- <configuration>
- <target>
+ <execution>
+ <id>deploy-classes</id>
+ <phase>compile</phase>
+ <configuration>
+ <target>
<!--
<property name="classes.dir" location="${rhq.deploymentDir}/WEB-INF/classes" />
<echo>*** Copying updated files from target/${project.buildNodes.finalName}/WEB-INF/classes to ${classes.dir}...</echo>
@@ -443,126 +444,126 @@
<fileset dir="war/WEB-INF/classes" />
</copy>
-->
- <property name="deployment.dir" location="${rhq.deploymentDir}" />
- <echo>*** Copying updated files from
- src${file.separator}main${file.separator}webapp${file.separator} to
- ${deployment.dir}${file.separator}...
+ <property name="deployment.dir" location="${rhq.deploymentDir}"/>
+ <echo>*** Copying updated files from
+ src${file.separator}main${file.separator}webapp${file.separator} to
+ ${deployment.dir}${file.separator}...
</echo>
- <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
- <fileset dir="${basedir}/src/main/webapp" />
- </copy>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>deploy</id>
- <phase>package</phase>
- <configuration>
- <target>
- <property name="deployment.dir" location="${rhq.deploymentDir}" />
- <echo>*** Copying updated files from
- target${file.separator}${project.build.finalName}${file.separator} to
- ${deployment.dir}${file.separator}...
+ <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
+ <fileset dir="${basedir}/src/main/webapp"/>
+ </copy>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>deploy</id>
+ <phase>package</phase>
+ <configuration>
+ <target>
+ <property name="deployment.dir" location="${rhq.deploymentDir}"/>
+ <echo>*** Copying updated files from
+ target${file.separator}${project.build.finalName}${file.separator} to
+ ${deployment.dir}${file.separator}...
</echo>
- <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
- <fileset dir="${basedir}/target/${project.build.finalName}" />
- </copy>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>undeploy</id>
- <phase>clean</phase>
- <configuration>
- <target>
- <property name="deployment.dir" location="${rhq.deploymentDir}" />
- <echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
- <delete dir="${deployment.dir}" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- </executions>
- </plugin>
-
- </plugins>
- </build>
- </profile>
+ <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
+ <fileset dir="${basedir}/target/${project.build.finalName}"/>
+ </copy>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <target>
+ <property name="deployment.dir" location="${rhq.deploymentDir}"/>
+ <echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
+ <delete dir="${deployment.dir}"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
<!-- Change the runTarget to not have single quotes. The quotes work for linux but not win -->
- <profile>
- <id>windows</id>
- <activation>
- <os>
- <family>Windows</family>
- </os>
- </activation>
- <properties>
- <coreGuiRunTarget>http://localhost:7080/coregui/CoreGUI.html${coreGuiParams}</coreGuiRunTarget>
- </properties>
- </profile>
-
- <profile>
- <id>msg</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <includes>
- <include>org/rhq/enterprise/gui/coregui/client/Messages*.java</include>
- </includes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>disable-tags</id>
- <activation>
- <property>
- <name>brew</name>
- </property>
- </activation>
- <properties>
- <enable.tags>false</enable.tags>
- </properties>
- </profile>
-
- </profiles>
-
-
- <repositories>
- <repository>
- <id>smartgwt</id>
- <name>SmartGWT Releases</name>
- <url>http://www.smartclient.com/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
-
- <repository>
- <id>codehaus</id>
- <name>Codehaus Releases</name>
- <url>http://repository.codehaus.org/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
-
- </repositories>
+ <profile>
+ <id>windows</id>
+ <activation>
+ <os>
+ <family>Windows</family>
+ </os>
+ </activation>
+ <properties>
+ <coreGuiRunTarget>http://localhost:7080/coregui/CoreGUI.html${coreGuiParams}</coreGuiRunTarget>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>msg</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>org/rhq/enterprise/gui/coregui/client/Messages*.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>disable-tags</id>
+ <activation>
+ <property>
+ <name>brew</name>
+ </property>
+ </activation>
+ <properties>
+ <enable.tags>false</enable.tags>
+ </properties>
+ </profile>
+
+ </profiles>
+
+
+ <repositories>
+ <repository>
+ <id>smartgwt</id>
+ <name>SmartGWT Releases</name>
+ <url>http://www.smartclient.com/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+
+ <repository>
+ <id>codehaus</id>
+ <name>Codehaus Releases</name>
+ <url>http://repository.codehaus.org/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+
+ </repositories>
</project>
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index bf10fc1..aa0aad3 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -1,95 +1,96 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-parent</artifactId>
- <version>4.5.0-SNAPSHOT</version>
- <relativePath>../../../../pom.xml</relativePath>
- </parent>
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-parent</artifactId>
+ <version>4.5.0-SNAPSHOT</version>
+ <relativePath>../../../../pom.xml</relativePath>
+ </parent>
- <artifactId>rhq-enterprise-server</artifactId>
- <packaging>ejb</packaging>
+ <artifactId>rhq-enterprise-server</artifactId>
+ <packaging>ejb</packaging>
- <name>RHQ Enterprise Server JAR</name>
- <description>RHQ enterprise server main JAR</description>
+ <name>RHQ Enterprise Server JAR</name>
+ <description>RHQ enterprise server main JAR</description>
- <properties>
- <rhq.server.datasource>java:/RHQDS</rhq.server.datasource>
- <rhq.server.ds-mapping>PostgreSQL</rhq.server.ds-mapping>
+ <properties>
+ <rhq.server.datasource>java:/RHQDS</rhq.server.datasource>
+ <rhq.server.ds-mapping>PostgreSQL</rhq.server.ds-mapping>
<!-- dependency versions -->
- <jboss-embeddable-ejb3.version>1.0.0.Alpha9</jboss-embeddable-ejb3.version>
+ <jboss-embeddable-ejb3.version>1.0.0.Alpha9</jboss-embeddable-ejb3.version>
- <clean.db>true</clean.db>
- </properties>
+ <clean.db>true</clean.db>
+ </properties>
- <dependencies>
+ <dependencies>
<!-- Internal Deps -->
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-enterprise-comm</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-enterprise-server-xml-schemas</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope> <!-- by ear -->
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-client-api</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-dbutils</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>safe-invoker</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-common-drift</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-container-lib</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>com.googlecode.java-diff-utils</groupId>
- <artifactId>diffutils</artifactId>
- <version>1.2.1</version>
- </dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-comm</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server-xml-schemas</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope> <!-- by ear -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-client-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-dbutils</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>safe-invoker</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-common-drift</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-container-lib</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.googlecode.java-diff-utils</groupId>
+ <artifactId>diffutils</artifactId>
+ <version>1.2.1</version>
+ </dependency>
<!--================ Test Deps ================-->
@@ -99,1103 +100,1114 @@
need the embeddable-ejb3 jar above the standard ejb3 jars because we need the embeddble packages
loaded when testing. -->
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>test-utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-core-client-api</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq.helpers</groupId>
- <artifactId>perftest-support</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- </exclusion>
- <exclusion>
- <groupId>ant</groupId>
- <artifactId>ant-launcher</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>jboss.jboss-embeddable-ejb3</groupId>
- <artifactId>jboss-ejb3-all</artifactId>
- <version>${jboss-embeddable-ejb3.version}</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-core-client-api</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq.helpers</groupId>
+ <artifactId>perftest-support</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss.jboss-embeddable-ejb3</groupId>
+ <artifactId>jboss-ejb3-all</artifactId>
+ <version>${jboss-embeddable-ejb3.version}</version>
+ <scope>test</scope>
+ </dependency>
<!-- NOTE: The remaining test deps correspond to the classes contained in hibernate-all.jar and thirdparty-all.jar. -->
- <dependency>
- <groupId>antlr</groupId>
- <artifactId>antlr</artifactId>
- <version>2.7.7</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>2.7.7</version>
+ <scope>test</scope>
+ </dependency>
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>trove</groupId>
- <artifactId>trove</artifactId>
- <version>1.0.2</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- <version>${xercesImpl.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>net.sf.opencsv</groupId>
- <artifactId>opencsv</artifactId>
- <version>1.8</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-jxpath</groupId>
- <artifactId>commons-jxpath</artifactId>
- <version>1.3</version>
- <scope>test</scope>
- </dependency>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>trove</groupId>
+ <artifactId>trove</artifactId>
+ <version>1.0.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>${xercesImpl.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sf.opencsv</groupId>
+ <artifactId>opencsv</artifactId>
+ <version>1.8</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-jxpath</groupId>
+ <artifactId>commons-jxpath</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
<!-- 3rd Party Deps -->
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr</artifactId>
- <version>3.2</version>
- </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>3.2</version>
+ </dependency>
<!-- Required by a couple APL and Lather classes - TODO: Remove this once APL and Lather have been excised. -->
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- <version>1.6.1</version>
- </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.6.1</version>
+ </dependency>
<!-- Required by a couple APL classes - TODO: Remove this once APL has been removed. -->
<!-- also required by EJB3 Embedded (test scope) -->
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2</version>
- </dependency>
-
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>3.0.1</version>
- </dependency>
-
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.4</version>
- </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
<!-- Required by a couple APL classes - TODO: Remove this once APL has been removed. -->
- <dependency>
- <groupId>commons-validator</groupId>
- <artifactId>commons-validator</artifactId>
- <version>1.1.4</version>
- </dependency>
+ <dependency>
+ <groupId>commons-validator</groupId>
+ <artifactId>commons-validator</artifactId>
+ <version>1.1.4</version>
+ </dependency>
<!-- required by RHQ server classes, as well as EJB3 Embedded -->
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>1.6.1-jboss</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>gnu-getopt</groupId>
- <artifactId>getopt</artifactId>
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ <version>1.6.1-jboss</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>gnu-getopt</groupId>
+ <artifactId>getopt</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- </dependency>
+ </dependency>
- <dependency>
- <groupId>hibernate</groupId>
- <artifactId>hibernate3</artifactId>
+ <dependency>
+ <groupId>hibernate</groupId>
+ <artifactId>hibernate3</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
- <dependency>
- <groupId>hibernate-annotations</groupId>
- <artifactId>hibernate-annotations</artifactId>
+ <dependency>
+ <groupId>hibernate-annotations</groupId>
+ <artifactId>hibernate-annotations</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
- <dependency>
- <groupId>hibernate-entitymanager</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
+ <dependency>
+ <groupId>hibernate-entitymanager</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
- <dependency>
- <groupId>i18nlog</groupId>
- <artifactId>i18nlog</artifactId>
- </dependency>
+ <dependency>
+ <groupId>i18nlog</groupId>
+ <artifactId>i18nlog</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-javamail_1.3.1_spec</artifactId>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-javamail_1.3.1_spec</artifactId>
<!-- The Sun javamail jar isn't available from a public repo due to licensing issues,
so use the Geronimo one instead. -->
- <version>1.3</version>
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
-
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.0</version>
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
-
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-annotations-ejb3</artifactId>
+ <version>1.3</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.0</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-annotations-ejb3</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-cache</artifactId>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-cache</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>compile</scope>
- </dependency>
+ <scope>compile</scope>
+ </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-common</artifactId>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-ejb3x</artifactId>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-ejb3x</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
<!-- includes the org.jboss.ejb3.StrictMaxPool class, which is needed by the PoolClass annotation used on some
of our SLSB's -->
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-ejb3</artifactId>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-ejb3</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-j2ee</artifactId>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-jmx</artifactId>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-system</artifactId>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jbosssx</artifactId>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jbosssx</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jbpm</artifactId>
- <version>3.1.1</version>
- </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jbpm</artifactId>
+ <version>3.1.1</version>
+ </dependency>
<!-- for the transaction interrupt EJB3 interceptor -->
- <dependency>
- <groupId>org.jboss.transaction</groupId>
- <artifactId>jboss-jta</artifactId>
+ <dependency>
+ <groupId>org.jboss.transaction</groupId>
+ <artifactId>jboss-jta</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS -->
- </dependency>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
<!-- TODO: remove this - tests should all be moved under the test source tree -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
-
- <dependency>
- <groupId>org.opensymphony.quartz</groupId>
- <artifactId>quartz</artifactId>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opensymphony.quartz</groupId>
+ <artifactId>quartz</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS itself, which the container build has packaged with 1.6.5 -->
- </dependency>
+ <scope>provided</scope> <!-- by JBossAS itself, which the container build has packaged with 1.6.5 -->
+ </dependency>
- <dependency>
- <groupId>org.opensymphony.quartz</groupId>
- <artifactId>quartz-oracle</artifactId>
+ <dependency>
+ <groupId>org.opensymphony.quartz</groupId>
+ <artifactId>quartz-oracle</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>provided</scope> <!-- by JBossAS itself, which the container build has packaged with 1.6.5 -->
- </dependency>
-
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <version>2.2</version>
- <scope>test</scope>
+ <scope>provided</scope> <!-- by JBossAS itself, which the container build has packaged with 1.6.5 -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
<!-- somehow this is needed otherwise the hibernate stuff doesn't initialize in our tests -->
- </dependency>
+ </dependency>
- <dependency>
- <groupId>org.snmp4j</groupId>
- <artifactId>snmp4j</artifactId>
- <version>1.8.2</version>
- </dependency>
+ <dependency>
+ <groupId>org.snmp4j</groupId>
+ <artifactId>snmp4j</artifactId>
+ <version>1.8.2</version>
+ </dependency>
<!-- required by RHQ server classes, as well as EJB3 Embedded -->
- <dependency>
- <groupId>oswego-concurrent</groupId>
- <artifactId>concurrent</artifactId>
- <version>1.3.4</version>
- </dependency>
+ <dependency>
+ <groupId>oswego-concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ <version>1.3.4</version>
+ </dependency>
<!-- TODO: Why is this needed? -->
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
<!--<scope>test</scope>-->
- </dependency>
-
- <dependency>
- <groupId>rss4j</groupId>
- <artifactId>rss4j</artifactId>
- <version>0.92-on.2</version>
- </dependency>
-
- <dependency>
- <groupId>tomcat</groupId>
- <artifactId>catalina</artifactId>
- <version>5.5.20</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>tomcat</groupId>
- <artifactId>tomcat-jk</artifactId>
- <version>4.1.31</version>
- <scope>provided</scope>
- </dependency>
+ </dependency>
+
+ <dependency>
+ <groupId>rss4j</groupId>
+ <artifactId>rss4j</artifactId>
+ <version>0.92-on.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>catalina</artifactId>
+ <version>5.5.20</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>tomcat-jk</artifactId>
+ <version>4.1.31</version>
+ <scope>provided</scope>
+ </dependency>
<!-- Needed by com.jboss.jbossnetwork.apl.actions.xml.XPathProcessor; TODO: Remove once APL has been excised. -->
- <dependency>
- <groupId>xalan</groupId>
- <artifactId>xalan</artifactId>
- <version>2.5.1</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>com.jcraft</groupId>
- <artifactId>jsch</artifactId>
- <version>0.1.29</version>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxrs</artifactId>
- <version>${resteasy.version}</version>
- <scope>provided</scope> <!-- by container -->
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jackson-provider</artifactId>
- <version>${resteasy.version}</version>
- <scope>provided</scope> <!-- by container -->
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-links</artifactId>
- <version>${resteasy.version}</version>
- <scope>provided</scope> <!-- by container -->
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-yaml-provider</artifactId>
- <version>${resteasy.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxb-provider</artifactId>
- <version>${resteasy.version}</version>
- <scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.sun.xml.stream</groupId>
- <artifactId>sjsxp</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>com.wordnik</groupId>
- <artifactId>swagger-annotations_2.9.1</artifactId>
- <version>1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.rhq.helpers</groupId>
- <artifactId>rest-docs-generator</artifactId>
- <version>${project.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.yaml</groupId>
- <artifactId>snakeyaml</artifactId>
- <version>1.8</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.el</groupId>
- <artifactId>jboss-el</artifactId>
- <version>2.0.1.GA</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.freemarker</groupId>
- <artifactId>freemarker</artifactId>
- <version>2.3.18</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-testng</artifactId>
- <version>${powermock.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>${powermock.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.liquibase</groupId>
- <artifactId>liquibase-core</artifactId>
- <version>2.0.3</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <finalName>${project.artifactId}</finalName>
-
- <resources>
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.5.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ <version>0.1.29</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>${resteasy.version}</version>
+ <scope>provided</scope> <!-- by container -->
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jackson-provider</artifactId>
+ <version>${resteasy.version}</version>
+ <scope>provided</scope> <!-- by container -->
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-links</artifactId>
+ <version>${resteasy.version}</version>
+ <scope>provided</scope> <!-- by container -->
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-yaml-provider</artifactId>
+ <version>${resteasy.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxb-provider</artifactId>
+ <version>${resteasy.version}</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.xml.stream</groupId>
+ <artifactId>sjsxp</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.wordnik</groupId>
+ <artifactId>swagger-annotations_2.9.1</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.rhq.helpers</groupId>
+ <artifactId>rest-docs-generator</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ <version>1.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.el</groupId>
+ <artifactId>jboss-el</artifactId>
+ <version>2.0.1.GA</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.freemarker</groupId>
+ <artifactId>freemarker</artifactId>
+ <version>2.3.18</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-testng</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.liquibase</groupId>
+ <artifactId>liquibase-core</artifactId>
+ <version>2.0.3</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+
+ <resources>
<!-- Redefine which directories to treat like resources (which are filtered). -->
- <resource>
- <directory>src/main/filtered-sources/java</directory>
- <filtering>true</filtering>
- <targetPath>../filtered-sources/java</targetPath>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
-
- <testResources>
- <testResource>
- <directory>src/test/resources</directory>
- <filtering>true</filtering>
- </testResource>
- </testResources>
-
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-ejb-plugin</artifactId>
- <version>2.3</version>
- <configuration>
- <generateClient>true</generateClient>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
-
- <execution>
- <phase>process-classes</phase>
- <configuration>
- <target>
+ <resource>
+ <directory>src/main/filtered-sources/java</directory>
+ <filtering>true</filtering>
+ <targetPath>../filtered-sources/java</targetPath>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ejb-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <generateClient>true</generateClient>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <phase>process-classes</phase>
+ <configuration>
+ <target>
<!-- generate the I18N resource bundles -->
- <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
+ <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask"/>
- <i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
- <classpath refid="maven.runtime.classpath" />
- <classfileset dir="${project.build.outputDirectory}">
- <include name="**/ServerI18NResourceKeys.class" />
- <include name="**/AlertI18NResourceKeys.class" />
- </classfileset>
- </i18n>
+ <i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false"
+ verify="true">
+ <classpath refid="maven.runtime.classpath"/>
+ <classfileset dir="${project.build.outputDirectory}">
+ <include name="**/ServerI18NResourceKeys.class"/>
+ <include name="**/AlertI18NResourceKeys.class"/>
+ </classfileset>
+ </i18n>
<!-- create our rhq-server-version.properties file that goes in our jar -->
- <tstamp>
- <format property="build.time" pattern="dd.MMM.yyyy HH.mm.ss z" />
- </tstamp>
-
- <echo file="${project.build.outputDirectory}/rhq-server-version.properties" append="false">Product-Name=${rhq.product.name}
-Product-Version=${project.version}
-Module-Name=${project.name}
-Module-Version=${project.version}
-Build-Number=${buildNumber}
-Build-Date=${build.time}
-Build-Jdk-Vendor=${java.vendor}
-Build-Jdk=${java.version}
-Build-OS-Name=${os.name}
-Build-OS-Version=${os.version}
+ <tstamp>
+ <format property="build.time" pattern="dd.MMM.yyyy HH.mm.ss z"/>
+ </tstamp>
+
+ <echo file="${project.build.outputDirectory}/rhq-server-version.properties" append="false">Product-Name=${rhq.product.name}
+ Product-Version=${project.version}
+ Module-Name=${project.name}
+ Module-Version=${project.version}
+ Build-Number=${buildNumber}
+ Build-Date=${build.time}
+ Build-Jdk-Vendor=${java.vendor}
+ Build-Jdk=${java.version}
+ Build-OS-Name=${os.name}
+ Build-OS-Version=${os.version}
</echo>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
<!-- in order to get JMS to work properly in embedded test container, extract jms-rs.rar classes -->
- <execution>
- <id>Extract JMS classes from RAR needed for JMS tests</id>
- <phase>process-classes</phase>
- <configuration>
- <target>
- <unzip src="src/test/resources/jms-ra.rar" dest="target">
- <patternset>
- <include name="jms-ra.jar"/>
- </patternset>
- </unzip>
- <unzip src="target/jms-ra.jar" dest="target/test-classes">
- <patternset>
- <include name="org/**"/>
- </patternset>
- </unzip>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <execution>
+ <id>Extract JMS classes from RAR needed for JMS tests</id>
+ <phase>process-classes</phase>
+ <configuration>
+ <target>
+ <unzip src="src/test/resources/jms-ra.rar" dest="target">
+ <patternset>
+ <include name="jms-ra.jar"/>
+ </patternset>
+ </unzip>
+ <unzip src="target/jms-ra.jar" dest="target/test-classes">
+ <patternset>
+ <include name="org/**"/>
+ </patternset>
+ </unzip>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
- </executions>
- </plugin>
+ </executions>
+ </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
<!-- Everything but the web service tests, this is the standard test execution -->
- <configuration>
- <skipTests>true</skipTests>
- <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
- <groups>${rhq.testng.includedGroups}</groups>
- <properties>
- <property>
- <name>listener</name>
- <value>org.rhq.test.testng.StdoutReporter</value>
- </property>
- </properties>
- <systemPropertyVariables>
- <embeddedDeployment>true</embeddedDeployment>
- <deploymentDirectory>target/classes</deploymentDirectory>
- <hibernate.dialect>${rhq.test.ds.hibernate-dialect}</hibernate.dialect>
- <clean.db>${clean.db}</clean.db>
- <log4j.configDebug>false</log4j.configDebug>
- </systemPropertyVariables>
- <additionalClasspathElements>
+ <configuration>
+ <skipTests>true</skipTests>
+ <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <groups>${rhq.testng.includedGroups}</groups>
+ <properties>
+ <property>
+ <name>listener</name>
+ <value>org.rhq.test.testng.StdoutReporter</value>
+ </property>
+ </properties>
+ <systemPropertyVariables>
+ <embeddedDeployment>true</embeddedDeployment>
+ <deploymentDirectory>target/classes</deploymentDirectory>
+ <hibernate.dialect>${rhq.test.ds.hibernate-dialect}</hibernate.dialect>
+ <clean.db>${clean.db}</clean.db>
+ <log4j.configDebug>false</log4j.configDebug>
+ </systemPropertyVariables>
+ <additionalClasspathElements>
<!-- The below is required for tests to run against Oracle. -->
- <additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc6/${ojdbc6.version}/ojdbc6-${ojdbc6.version}.jar</additionalClasspathElement>
- </additionalClasspathElements>
+ <additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc6/${ojdbc6.version}/ojdbc6-${ojdbc6.version}.jar</additionalClasspathElement>
+ </additionalClasspathElements>
+ </configuration>
+
+ <executions>
+
+ <execution>
+ <id>allExceptDbTests</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skipTests>${skipTests}</skipTests>
+ <excludes>
+ <exclude>com/**/*.java</exclude>
+ <exclude>org/rhq/**/performance/**/*.java</exclude>
+ <exclude>org/rhq/enterprise/server/db/**</exclude>
+ </excludes>
</configuration>
-
- <executions>
-
- <execution>
- <id>allExceptDbTests</id>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <skipTests>${skipTests}</skipTests>
- <excludes>
- <exclude>com/**/*.java</exclude>
- <exclude>org/rhq/**/performance/**/*.java</exclude>
- <exclude>org/rhq/enterprise/server/db/**</exclude>
- </excludes>
- </configuration>
- </execution>
-
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.antlr</groupId>
- <artifactId>antlr3-maven-plugin</artifactId>
- <version>3.2</version>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>antlr</goal>
- </goals>
- <configuration>
- <conversionTimeout>30000</conversionTimeout>
- <debug>false</debug>
- <dfa>false</dfa>
- <nfa>false</nfa>
- <excludes>
-
- </excludes>
- <includes>
-
- </includes>
- <libDirectory>src/main/antlr3/imports</libDirectory>
- <messageFormat>antlr</messageFormat>
- <outputDirectory>target/generated-sources/antlr3</outputDirectory>
- <printGrammar>false</printGrammar>
- <profile>false</profile>
- <report>false</report>
- <sourceDirectory>src/main/antlr3</sourceDirectory>
- <trace>false</trace>
- <verbose>true</verbose>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-filtered-sources</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>target/filtered-sources/java</source>
- </sources>
- </configuration>
- </execution>
- <execution>
- <id>add-antlr-sources</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>${basedir}/target/generated-sources/antlr3</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr3-maven-plugin</artifactId>
+ <version>3.2</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>antlr</goal>
+ </goals>
+ <configuration>
+ <conversionTimeout>30000</conversionTimeout>
+ <debug>false</debug>
+ <dfa>false</dfa>
+ <nfa>false</nfa>
+ <excludes>
+
+ </excludes>
+ <includes>
+
+ </includes>
+ <libDirectory>src/main/antlr3/imports</libDirectory>
+ <messageFormat>antlr</messageFormat>
+ <outputDirectory>target/generated-sources/antlr3</outputDirectory>
+ <printGrammar>false</printGrammar>
+ <profile>false</profile>
+ <report>false</report>
+ <sourceDirectory>src/main/antlr3</sourceDirectory>
+ <trace>false</trace>
+ <verbose>true</verbose>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-filtered-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/filtered-sources/java</source>
+ </sources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>add-antlr-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${basedir}/target/generated-sources/antlr3</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
<!-- Document generation from the Annotations on the REST-API. -->
<!-- TODO move to a better suited processing phase -->
- <plugin>
- <groupId>org.bsc.maven</groupId>
- <artifactId>maven-processor-plugin</artifactId>
- <version>2.0.6-redhat</version>
- <configuration>
- <processors>
- <processor>org.rhq.helpers.rest_docs_generator.ClassLevelProcessor</processor>
- </processors>
- <compilerArguments>-AtargetDirectory=${project.build.directory}/docs/xml</compilerArguments>
+ <plugin>
+ <groupId>org.bsc.maven</groupId>
+ <artifactId>maven-processor-plugin</artifactId>
+ <version>2.0.6-redhat</version>
+ <configuration>
+ <processors>
+ <processor>org.rhq.helpers.rest_docs_generator.ClassLevelProcessor</processor>
+ </processors>
+ <compilerArguments>-AtargetDirectory=${project.build.directory}/docs/xml</compilerArguments>
<!-- Comment the next line in to get more verbose output for debugging -->
<!--<compilerArguments>-Averbose=true</compilerArguments>-->
- </configuration>
- <executions>
- <execution>
- <id>create-rest-api-reports</id>
- <phase>process-classes</phase>
- <goals>
+ </configuration>
+ <executions>
+ <execution>
+ <id>create-rest-api-reports</id>
+ <phase>process-classes</phase>
+ <goals>
<!-- We want to process the classes in src/ -->
- <goal>process</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
+ <goal>process</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
<!-- Disable annotation processors during normal compilation -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <compilerArgument>-proc:none</compilerArgument>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>xml-maven-plugin</artifactId>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <goals>
- <goal>transform</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <transformationSets>
- <transformationSet>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>xml-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>transform</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <transformationSets>
+ <transformationSet>
<!-- org.rhq.helpers.rest_docs_generator.test plugin wrote to target/docs/xml (see -AtargetDirectory above) -->
- <dir>target/docs/xml</dir>
- <includes><include>rest-api-out.xml</include></includes>
- <stylesheet>src/main/xsl/apiout2html.xsl</stylesheet>
- <parameters>
- <parameter>
- <name>basePath</name>
- <value>http://localhost:7080/rest/1</value>
- </parameter>
- </parameters>
- <outputDir>${project.build.directory}/docs/html</outputDir>
- <fileMappers>
- <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
- <targetExtension>.html</targetExtension>
- </fileMapper>
- </fileMappers>
- </transformationSet>
- <transformationSet>
+ <dir>target/docs/xml</dir>
+ <includes>
+ <include>rest-api-out.xml</include>
+ </includes>
+ <stylesheet>src/main/xsl/apiout2html.xsl</stylesheet>
+ <parameters>
+ <parameter>
+ <name>basePath</name>
+ <value>http://localhost:7080/rest/1</value>
+ </parameter>
+ </parameters>
+ <outputDir>${project.build.directory}/docs/html</outputDir>
+ <fileMappers>
+ <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
+ <targetExtension>.html</targetExtension>
+ </fileMapper>
+ </fileMappers>
+ </transformationSet>
+ <transformationSet>
<!-- org.rhq.helpers.rest_docs_generator.test plugin wrote to target/docs/xml (see -AtargetDirectory above) -->
- <dir>target/docs/xml</dir>
- <includes><include>rest-api-out.xml</include></includes>
- <stylesheet>src/main/xsl/apiout2docbook.xsl</stylesheet>
- <parameters>
- <parameter>
- <name>basePath</name>
- <value>http://localhost:7080/rest/1</value>
- </parameter>
- </parameters>
- <outputDir>${project.build.directory}/docs/xml</outputDir>
- <fileMappers>
- <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
- <targetExtension>.dbx.xml</targetExtension>
- </fileMapper>
- </fileMappers>
- </transformationSet>
- </transformationSets>
- </configuration>
- </plugin>
- <plugin>
- <groupId>com.agilejava.docbkx</groupId>
- <artifactId>docbkx-maven-plugin</artifactId>
- <version>2.0.9</version>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <goals>
- <goal>generate-pdf</goal>
- <goal>generate-html</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <sourceDirectory>target/docs/xml</sourceDirectory> <!-- from previous plugin, 2nd transformation set -->
- <includes>rest-api-out.dbx.xml</includes>
- <hyphenate>false</hyphenate>
- <generateToc>true</generateToc>
- </configuration>
- </plugin>
-
- </plugins>
-
- </build>
+ <dir>target/docs/xml</dir>
+ <includes>
+ <include>rest-api-out.xml</include>
+ </includes>
+ <stylesheet>src/main/xsl/apiout2docbook.xsl</stylesheet>
+ <parameters>
+ <parameter>
+ <name>basePath</name>
+ <value>http://localhost:7080/rest/1</value>
+ </parameter>
+ </parameters>
+ <outputDir>${project.build.directory}/docs/xml</outputDir>
+ <fileMappers>
+ <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
+ <targetExtension>.dbx.xml</targetExtension>
+ </fileMapper>
+ </fileMappers>
+ </transformationSet>
+ </transformationSets>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.agilejava.docbkx</groupId>
+ <artifactId>docbkx-maven-plugin</artifactId>
+ <version>2.0.9</version>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>generate-pdf</goal>
+ <goal>generate-html</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <sourceDirectory>target/docs/xml</sourceDirectory> <!-- from previous plugin, 2nd transformation set -->
+ <includes>rest-api-out.dbx.xml</includes>
+ <hyphenate>false</hyphenate>
+ <generateToc>true</generateToc>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
<repositories>
<repository>
<!-- TODO change when the annotations are puplished. This is temporary for the swagger annotations for REST-docu -->
- <id>sonatype-oss-snapshot</id>
- <name>Sonatype OSS Snapshot repository</name>
- <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <id>sonatype-oss-snapshot</id>
+ <name>Sonatype OSS Snapshot repository</name>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
- <profiles>
+ <profiles>
- <profile>
+ <profile>
<!-- only if we are not running an individual set of tests via -Dtest do we do this -->
- <id>no-individual-test</id>
- <activation>
- <property><name>!test</name></property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
+ <id>no-individual-test</id>
+ <activation>
+ <property>
+ <name>!test</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
<!-- Everything but the web service tests, this is the standard test execution -->
- <configuration>
- <skipTests>true</skipTests>
- <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
- <groups>${rhq.testng.includedGroups}</groups>
- <properties>
- <property>
- <name>listener</name>
- <value>org.rhq.test.testng.StdoutReporter</value>
- </property>
- </properties>
- <systemPropertyVariables>
- <embeddedDeployment>true</embeddedDeployment>
- <deploymentDirectory>target/classes</deploymentDirectory>
- <hibernate.dialect>${rhq.test.ds.hibernate-dialect}</hibernate.dialect>
- <clean.db>${clean.db}</clean.db>
- <log4j.configDebug>false</log4j.configDebug>
- </systemPropertyVariables>
- <additionalClasspathElements>
+ <configuration>
+ <skipTests>true</skipTests>
+ <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <groups>${rhq.testng.includedGroups}</groups>
+ <properties>
+ <property>
+ <name>listener</name>
+ <value>org.rhq.test.testng.StdoutReporter</value>
+ </property>
+ </properties>
+ <systemPropertyVariables>
+ <embeddedDeployment>true</embeddedDeployment>
+ <deploymentDirectory>target/classes</deploymentDirectory>
+ <hibernate.dialect>${rhq.test.ds.hibernate-dialect}</hibernate.dialect>
+ <clean.db>${clean.db}</clean.db>
+ <log4j.configDebug>false</log4j.configDebug>
+ </systemPropertyVariables>
+ <additionalClasspathElements>
<!-- The below is required for tests to run against Oracle. -->
- <additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc6/${ojdbc6.version}/ojdbc6-${ojdbc6.version}.jar</additionalClasspathElement>
- </additionalClasspathElements>
- </configuration>
- <executions>
- <execution>
- <id>dbTestsOnly</id>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <skipTests>${skipTests}</skipTests>
- <includes>
- <include>org/rhq/enterprise/server/db/**</include>
- </includes>
- <failIfNoTests>false</failIfNoTests>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>dev</id>
-
- <properties>
- <rhq.rootDir>../../../..</rhq.rootDir>
- <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentName>${project.build.finalName}-ejb3.jar</rhq.deploymentName>
- <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/${rhq.deploymentName}</rhq.deploymentDir>
- </properties>
-
- <build>
- <plugins>
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
-
- <execution>
- <id>deploy</id>
- <phase>compile</phase>
- <configuration>
- <target>
- <property name="deployment.dir" location="${rhq.deploymentDir}" />
- <echo>*** Copying updated files from target/classes to ${deployment.dir}...</echo>
- <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
- <fileset dir="target/classes" />
- </copy>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc6/${ojdbc6.version}/ojdbc6-${ojdbc6.version}.jar</additionalClasspathElement>
+ </additionalClasspathElements>
+ </configuration>
+ <executions>
+ <execution>
+ <id>dbTestsOnly</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skipTests>${skipTests}</skipTests>
+ <includes>
+ <include>org/rhq/enterprise/server/db/**</include>
+ </includes>
+ <failIfNoTests>false</failIfNoTests>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentName>${project.build.finalName}-ejb3.jar</rhq.deploymentName>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/${rhq.deploymentName}</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <target>
+ <property name="deployment.dir" location="${rhq.deploymentDir}"/>
+ <echo>*** Copying updated files from target/classes to ${deployment.dir}...</echo>
+ <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
+ <fileset dir="target/classes"/>
+ </copy>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
<!--
NOTE: The below execution is necessary to make sure the META-INF/MANIFEST.MF and
META-INF/maven/** files, which get created by the ejb plugin during the package phase, get
copied over to the deployment dir.
-->
- <execution>
- <id>deploy-jar-meta-inf</id>
- <phase>package</phase>
- <configuration>
- <target>
- <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${rhq.deploymentDir}" overwrite="false">
- <patternset>
- <include name="META-INF/**" />
- </patternset>
- </unjar>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>undeploy</id>
- <phase>clean</phase>
- <configuration>
- <target>
- <property name="deployment.dir" location="${rhq.deploymentDir}" />
- <echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
- <delete dir="${deployment.dir}" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- </executions>
- </plugin>
-
- </plugins>
- </build>
- </profile>
+ <execution>
+ <id>deploy-jar-meta-inf</id>
+ <phase>package</phase>
+ <configuration>
+ <target>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${rhq.deploymentDir}"
+ overwrite="false">
+ <patternset>
+ <include name="META-INF/**"/>
+ </patternset>
+ </unjar>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
- <!-- Add dependencies need for jdk5 builds. Remove when we stop supporting jdk5 -->
- <profile>
- <id>java-5-dependencies</id>
- <activation>
- <jdk>1.5</jdk>
- <property>
- <name>java5.home</name>
- </property>
- </activation>
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <target>
+ <property name="deployment.dir" location="${rhq.deploymentDir}"/>
+ <echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
+ <delete dir="${deployment.dir}"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
- <dependencies>
- <dependency>
- <groupId>jboss.jbossws</groupId>
- <artifactId>jboss-jaxws</artifactId>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- Add dependencies need for jdk5 builds. Remove when we stop supporting jdk5 -->
+ <profile>
+ <id>java-5-dependencies</id>
+ <activation>
+ <jdk>1.5</jdk>
+ <property>
+ <name>java5.home</name>
+ </property>
+ </activation>
+
+ <dependencies>
+ <dependency>
+ <groupId>jboss.jbossws</groupId>
+ <artifactId>jboss-jaxws</artifactId>
<!-- NOTE: This version is old but is good enough to resolve the build dependency. -->
- <version>3.0.1-native-2.0.4.GA</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
- </profile>
-
- <profile>
- <id>javadoc</id>
- <activation>
- <property>
- <name>javadoc.outputDirectory</name>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
-
- <execution>
- <id>remote-api</id>
- <phase>compile</phase>
- <configuration>
- <target>
- <property name="javadoc.outputDirectory" value="${javadoc.outputDirectory}" />
- <property name="project.dir" value="./src/main/java/org/rhq/enterprise/server" />
- <property name="maven.compile.classpath" refid="maven.compile.classpath" />
-
- <mkdir dir="${javadoc.outputDirectory}/remote-api" />
- <javadoc destdir="${javadoc.outputDirectory}/remote-api" author="false" version="true" windowtitle="RHQ ${project.version} Remote API" noindex="false">
- <classpath>
- <pathelement path="${maven.compile.classpath}" />
- </classpath>
- <fileset dir="${project.dir}" defaultexcludes="yes">
- <include name="**/*Remote.java" />
- </fileset>
- <link href="../domain/" />
- <link href="http://download.oracle.com/javase/6/docs/api/" />
- <bottom><![CDATA[Copyright © 2005-2011 <a href="http://redhat.com/">Red Hat, Inc.</a>. All Rights Reserved.]]></bottom>
- </javadoc>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- </executions>
- </plugin>
- </plugins>
- </build>
-
- </profile>
-
- <profile>
- <id>cobertura</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>net.sourceforge.cobertura</groupId>
- <artifactId>cobertura</artifactId>
- <version>${cobertura.version}</version>
- </dependency>
- </dependencies>
- <executions>
+ <version>3.0.1-native-2.0.4.GA</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <profile>
+ <id>javadoc</id>
+ <activation>
+ <property>
+ <name>javadoc.outputDirectory</name>
+ </property>
+ </activation>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+
<execution>
- <id>cobertura-instrument</id>
- <phase>process-test-classes</phase>
- <configuration>
- <target>
+ <id>remote-api</id>
+ <phase>compile</phase>
+ <configuration>
+ <target>
+ <property name="javadoc.outputDirectory" value="${javadoc.outputDirectory}"/>
+ <property name="project.dir" value="./src/main/java/org/rhq/enterprise/server"/>
+ <property name="maven.compile.classpath" refid="maven.compile.classpath"/>
+
+ <mkdir dir="${javadoc.outputDirectory}/remote-api"/>
+ <javadoc destdir="${javadoc.outputDirectory}/remote-api" author="false" version="true"
+ windowtitle="RHQ ${project.version} Remote API" noindex="false">
+ <classpath>
+ <pathelement path="${maven.compile.classpath}"/>
+ </classpath>
+ <fileset dir="${project.dir}" defaultexcludes="yes">
+ <include name="**/*Remote.java"/>
+ </fileset>
+ <link href="../domain/"/>
+ <link href="http://download.oracle.com/javase/6/docs/api/"/>
+ <bottom><![CDATA[Copyright © 2005-2011 <a href="http://redhat.com/">Red Hat, Inc.</a>. All Rights Reserved.]]></bottom>
+ </javadoc>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ </profile>
+
+ <profile>
+ <id>cobertura</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>net.sourceforge.cobertura</groupId>
+ <artifactId>cobertura</artifactId>
+ <version>${cobertura.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>cobertura-instrument</id>
+ <phase>process-test-classes</phase>
+ <configuration>
+ <target>
<!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/cobertura/backup" />
+ <mkdir dir="target/cobertura"/>
+ <mkdir dir="target/cobertura/backup"/>
<!-- backup all classes so that we can instrument the original classes-->
- <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
+ <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
<fileset dir="target/classes">
- <include name="**/*.class" />
+ <include name="**/*.class"/>
</fileset>
- </copy>
+ </copy>
<!-- create a properties file and save there location of cobertura data file-->
- <touch file="target/classes/cobertura.properties" />
- <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <touch file="target/classes/cobertura.properties"/>
+ <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties"/>
<!-- instrument all classes in target/classes directory -->
- <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes">
- <fileset dir="${project.build.directory}/classes">
- <include name="**/*.class" />
- <exclude name="**/DynamicConfigurationPropertyLocal.class" />
- <exclude name="**/DynamicConfigurationPropertyBean.class" />
+ <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser"
+ todir="${project.build.directory}/classes">
+ <fileset dir="${project.build.directory}/classes">
+ <include name="**/*.class"/>
+ <exclude name="**/DynamicConfigurationPropertyLocal.class"/>
+ <exclude name="**/DynamicConfigurationPropertyBean.class"/>
</fileset>
</cobertura-instrument>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
</execution>
<execution>
- <id>cobertura-report</id>
- <phase>prepare-package</phase>
- <configuration>
- <target>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <id>cobertura-report</id>
+ <phase>prepare-package</phase>
+ <configuration>
+ <target>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties"/>
<!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/site/cobertura" />
+ <mkdir dir="target/cobertura"/>
+ <mkdir dir="target/site/cobertura"/>
<!-- restore classes from backup folder to classes folder -->
- <copy toDir="target/classes" verbose="true" overwrite="true">
+ <copy toDir="target/classes" verbose="true" overwrite="true">
<fileset dir="target/cobertura/backup">
- <include name="**/*.class" />
+ <include name="**/*.class"/>
</fileset>
- </copy>
+ </copy>
<!-- delete backup folder-->
- <delete dir="target/cobertura/backup" />
+ <delete dir="target/cobertura/backup"/>
<!-- create a code coverage report -->
- <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura">
+ <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser"
+ destdir="${project.build.directory}/site/cobertura">
<fileset dir="${basedir}/src/main/java">
- <include name="**/*.java" />
+ <include name="**/*.java"/>
</fileset>
- </cobertura-report>
+ </cobertura-report>
<!-- delete cobertura.properties file -->
- <delete file="target/classes/cobertura.properties" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <delete file="target/classes/cobertura.properties"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
</executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git a/modules/enterprise/server/xml-schemas/pom.xml b/modules/enterprise/server/xml-schemas/pom.xml
index 6923a7a..8e4bc21 100644
--- a/modules/enterprise/server/xml-schemas/pom.xml
+++ b/modules/enterprise/server/xml-schemas/pom.xml
@@ -1,82 +1,83 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-parent</artifactId>
- <version>4.5.0-SNAPSHOT</version>
- <relativePath>../../../../pom.xml</relativePath>
- </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
<groupId>org.rhq</groupId>
- <artifactId>rhq-enterprise-server-xml-schemas</artifactId>
- <packaging>jar</packaging>
+ <artifactId>rhq-parent</artifactId>
+ <version>4.5.0-SNAPSHOT</version>
+ <relativePath>../../../../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server-xml-schemas</artifactId>
+ <packaging>jar</packaging>
- <name>RHQ Server XML Schemas</name>
- <description>Server side XML schemas and JAXB APIs used mailing to support the RHQ Server plugin container</description>
+ <name>RHQ Server XML Schemas</name>
+ <description>Server side XML schemas and JAXB APIs used mailing to support the RHQ Server plugin container</description>
- <dependencies>
- <dependency>
- <groupId>${rhq.groupId}</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope> <!-- rhq.ear -->
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope> <!-- rhq.ear -->
+ </dependency>
- <dependency>
- <groupId>${rhq.groupId}</groupId>
- <artifactId>rhq-core-client-api</artifactId>
- <version>${project.version}</version>
- </dependency>
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-core-client-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- </dependency>
+ </dependency>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
<!--<scope>test</scope> not sure about this -->
- </dependency>
+ </dependency>
<!--
TODO: This is a fix for the Javac bug requiring annotations to be available when compiling dependent
classes; it is fixed in JDK 6.
-->
- <dependency>
- <groupId>jboss.jboss-embeddable-ejb3</groupId>
- <artifactId>hibernate-all</artifactId>
- <version>1.0.0.Alpha9</version>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>jboss.jboss-embeddable-ejb3</groupId>
+ <artifactId>hibernate-all</artifactId>
+ <version>1.0.0.Alpha9</version>
+ <scope>provided</scope>
+ </dependency>
- </dependencies>
+ </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>com.sun.tools.xjc.maven2</groupId>
- <artifactId>maven-jaxb-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <generateDirectory>${basedir}/target/generated-sources/xjc</generateDirectory>
- <schemaDirectory>${basedir}/target/classes</schemaDirectory>
- <includeSchemas>
- <includeSchema>*.xsd</includeSchema>
- </includeSchemas>
- </configuration>
- </plugin>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.sun.tools.xjc.maven2</groupId>
+ <artifactId>maven-jaxb-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <generateDirectory>${basedir}/target/generated-sources/xjc</generateDirectory>
+ <schemaDirectory>${basedir}/target/classes</schemaDirectory>
+ <includeSchemas>
+ <includeSchema>*.xsd</includeSchema>
+ </includeSchemas>
+ </configuration>
+ </plugin>
<!--
Because the JAXB generator needs all .xsd's available and in one place so they can reference each other
@@ -90,211 +91,213 @@
we still have a duplicate copy of the .xsd in our jar, but this is OK because it is a true duplicate
so it doesn't really matter that we have one copy here and one copy in client-api jar.
-->
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>Copy the schemas in one place, including rhq-configuration.xsd schema so we can reuse it</id>
- <phase>initialize</phase>
- <configuration>
- <target>
- <mkdir dir="${basedir}/target/classes" />
- <copy todir="${basedir}/target/classes">
- <fileset dir="${basedir}/src/main/resources">
- <include name="*.xsd" />
- </fileset>
- <fileset dir="${basedir}/../../../core/client-api/src/main/resources">
- <include name="rhq-configuration.xsd" />
- </fileset>
- </copy>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- <execution>
- <id>purge duplicated JAXB-generated configuration schema classes</id>
- <phase>process-sources</phase>
- <configuration>
- <target>
- <delete dir="${basedir}/target/generated-sources/xjc/org/rhq/core" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>Copy the schemas in one place, including rhq-configuration.xsd schema so we can reuse it</id>
+ <phase>initialize</phase>
+ <configuration>
+ <target>
+ <mkdir dir="${basedir}/target/classes"/>
+ <copy todir="${basedir}/target/classes">
+ <fileset dir="${basedir}/src/main/resources">
+ <include name="*.xsd"/>
+ </fileset>
+ <fileset dir="${basedir}/../../../core/client-api/src/main/resources">
+ <include name="rhq-configuration.xsd"/>
+ </fileset>
+ </copy>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>purge duplicated JAXB-generated configuration schema classes</id>
+ <phase>process-sources</phase>
+ <configuration>
+ <target>
+ <delete dir="${basedir}/target/generated-sources/xjc/org/rhq/core"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-xjc-source</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>${basedir}/target/generated-sources/xjc</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-xjc-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${basedir}/target/generated-sources/xjc</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
- <profiles>
+ <profiles>
- <profile>
- <id>dev</id>
+ <profile>
+ <id>dev</id>
- <properties>
- <rhq.rootDir>../../../..</rhq.rootDir>
- <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
- </properties>
+ <properties>
+ <rhq.rootDir>../../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
+ </properties>
- <build>
- <plugins>
+ <build>
+ <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
- <execution>
- <id>deploy</id>
- <phase>compile</phase>
- <configuration>
- <target>
- <mkdir dir="${rhq.deploymentDir}" />
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating ${deployment.file}...</echo>
- <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <target>
+ <mkdir dir="${rhq.deploymentDir}"/>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
- <execution>
- <id>undeploy</id>
- <phase>clean</phase>
- <configuration>
- <target>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Deleting ${deployment.file}...</echo>
- <delete file="${deployment.file}" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <target>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
- </executions>
- </plugin>
+ </executions>
+ </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
<id>cobertura</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>net.sourceforge.cobertura</groupId>
- <artifactId>cobertura</artifactId>
- <version>${cobertura.version}</version>
- </dependency>
- </dependencies>
- <executions>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>net.sourceforge.cobertura</groupId>
+ <artifactId>cobertura</artifactId>
+ <version>${cobertura.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
<execution>
- <id>cobertura-instrument</id>
- <phase>process-test-classes</phase>
- <configuration>
- <target>
+ <id>cobertura-instrument</id>
+ <phase>process-test-classes</phase>
+ <configuration>
+ <target>
<!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/cobertura/backup" />
+ <mkdir dir="target/cobertura"/>
+ <mkdir dir="target/cobertura/backup"/>
<!-- backup all classes so that we can instrument the original classes-->
- <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
+ <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
<fileset dir="target/classes">
- <include name="**/*.class" />
+ <include name="**/*.class"/>
</fileset>
- </copy>
+ </copy>
<!-- create a properties file and save there location of cobertura data file-->
- <touch file="target/classes/cobertura.properties" />
- <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <touch file="target/classes/cobertura.properties"/>
+ <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties"/>
<!-- instrument all classes in target/classes directory -->
- <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes">
- <fileset dir="${project.build.directory}/classes">
- <include name="**/*.class" />
+ <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser"
+ todir="${project.build.directory}/classes">
+ <fileset dir="${project.build.directory}/classes">
+ <include name="**/*.class"/>
</fileset>
</cobertura-instrument>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
</execution>
<execution>
- <id>cobertura-report</id>
- <phase>prepare-package</phase>
- <configuration>
- <target>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <id>cobertura-report</id>
+ <phase>prepare-package</phase>
+ <configuration>
+ <target>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties"/>
<!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/site/cobertura" />
+ <mkdir dir="target/cobertura"/>
+ <mkdir dir="target/site/cobertura"/>
<!-- restore classes from backup folder to classes folder -->
- <copy toDir="target/classes" verbose="true" overwrite="true">
+ <copy toDir="target/classes" verbose="true" overwrite="true">
<fileset dir="target/cobertura/backup">
- <include name="**/*.class" />
+ <include name="**/*.class"/>
</fileset>
- </copy>
+ </copy>
<!-- delete backup folder-->
- <delete dir="target/cobertura/backup" />
+ <delete dir="target/cobertura/backup"/>
<!-- create a code coverage report -->
- <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura">
+ <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser"
+ destdir="${project.build.directory}/site/cobertura">
<fileset dir="${basedir}/src/main/java">
- <include name="**/*.java" />
+ <include name="**/*.java"/>
</fileset>
- </cobertura-report>
+ </cobertura-report>
<!-- delete cobertura.properties file -->
- <delete file="target/classes/cobertura.properties" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <delete file="target/classes/cobertura.properties"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
</executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git a/modules/plugins/perftest/pom.xml b/modules/plugins/perftest/pom.xml
index e045081..9f93a29 100644
--- a/modules/plugins/perftest/pom.xml
+++ b/modules/plugins/perftest/pom.xml
@@ -1,291 +1,295 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-plugins-parent</artifactId>
- <version>4.5.0-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-plugins-parent</artifactId>
+ <version>4.5.0-SNAPSHOT</version>
+ </parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-perftest-plugin</artifactId>
- <packaging>jar</packaging>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-perftest-plugin</artifactId>
+ <packaging>jar</packaging>
- <name>RHQ Performance Test Plugin</name>
- <description>a plugin for performance testing</description>
+ <name>RHQ Performance Test Plugin</name>
+ <description>a plugin for performance testing</description>
- <dependencies>
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- </dependency>
+ </dependency>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- </dependency>
- </dependencies>
+ </dependency>
+ </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>com.sun.tools.xjc.maven2</groupId>
- <artifactId>maven-jaxb-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.sun.tools.xjc.maven2</groupId>
+ <artifactId>maven-jaxb-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <generatePackage>org.rhq.plugins.perftest.scenario</generatePackage>
+ <generateDirectory>${basedir}/target/generated-sources/xjc</generateDirectory>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-jaxb-deps</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
<configuration>
- <generatePackage>org.rhq.plugins.perftest.scenario</generatePackage>
- <generateDirectory>${basedir}/target/generated-sources/xjc</generateDirectory>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
</configuration>
- </plugin>
-
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-jaxb-deps</id>
- <phase>process-resources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- </artifactItem>
- <artifactItem>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- </artifactItem>
- </artifactItems>
- <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ </execution>
+ </executions>
+ </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-xjc-source</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>${basedir}/target/generated-sources/xjc</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-xjc-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
<configuration>
- <skip>true</skip>
+ <sources>
+ <source>${basedir}/target/generated-sources/xjc</source>
+ </sources>
</configuration>
- <executions>
- <execution>
- <id>surefire-it</id>
- <phase>integration-test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <skip>${maven.test.skip}</skip>
- <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
- <useSystemClassLoader>false</useSystemClassLoader>
- <argLine>-Djava.library.path=${basedir}/target/itest/lib</argLine>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <useSystemClassLoader>false</useSystemClassLoader>
+ <argLine>-Djava.library.path=${basedir}/target/itest/lib</argLine>
<!--
<argLine>-Djava.library.path=${basedir}/target/itest/lib -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>
-->
- <systemPropertyVariables>
- <project.artifactId>${project.artifactId}</project.artifactId>
- <project.version>${project.version}</project.version>
- </systemPropertyVariables>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ <systemPropertyVariables>
+ <project.artifactId>${project.artifactId}</project.artifactId>
+ <project.version>${project.version}</project.version>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
- </plugins>
- </build>
+ </plugins>
+ </build>
- <profiles>
+ <profiles>
- <profile>
- <id>dev</id>
+ <profile>
+ <id>dev</id>
- <properties>
- <rhq.rootDir>../../..</rhq.rootDir>
- <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins</rhq.deploymentDir>
- </properties>
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins</rhq.deploymentDir>
+ </properties>
- <build>
- <plugins>
+ <build>
+ <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
- <execution>
- <id>deploy</id>
- <phase>compile</phase>
- <configuration>
- <target>
- <mkdir dir="${rhq.deploymentDir}" />
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating ${deployment.file}...</echo>
- <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" update="true" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <target>
+ <mkdir dir="${rhq.deploymentDir}"/>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" update="true"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
- <execution>
- <id>deploy-jar-meta-inf</id>
- <phase>package</phase>
- <configuration>
- <target>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
- <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
- <patternset><include name="META-INF/**" /></patternset>
- </unjar>
- <jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF" update="true">
- </jar>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <execution>
+ <id>deploy-jar-meta-inf</id>
+ <phase>package</phase>
+ <configuration>
+ <target>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
+ <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
+ <patternset>
+ <include name="META-INF/**"/>
+ </patternset>
+ </unjar>
+ <jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
+ update="true">
+ </jar>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
- <execution>
- <id>undeploy</id>
- <phase>clean</phase>
- <configuration>
- <target>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Deleting ${deployment.file}...</echo>
- <delete file="${deployment.file}" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <target>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
- </executions>
- </plugin>
+ </executions>
+ </plugin>
- </plugins>
- </build>
- </profile>
+ </plugins>
+ </build>
+ </profile>
- <profile>
+ <profile>
<id>cobertura-plugins</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>net.sourceforge.cobertura</groupId>
- <artifactId>cobertura</artifactId>
- <version>${cobertura.version}</version>
- </dependency>
- </dependencies>
- <executions>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>net.sourceforge.cobertura</groupId>
+ <artifactId>cobertura</artifactId>
+ <version>${cobertura.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
<execution>
- <id>cobertura-instrument</id>
- <phase>pre-integration-test</phase>
- <configuration>
- <target>
+ <id>cobertura-instrument</id>
+ <phase>pre-integration-test</phase>
+ <configuration>
+ <target>
<!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/cobertura/backup" />
+ <mkdir dir="target/cobertura"/>
+ <mkdir dir="target/cobertura/backup"/>
<!-- backup all classes so that we can instrument the original classes-->
- <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
+ <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
<fileset dir="target/classes">
- <include name="**/*.class" />
+ <include name="**/*.class"/>
</fileset>
- </copy>
+ </copy>
<!-- create a properties file and save there location of cobertura data file-->
- <touch file="target/classes/cobertura.properties" />
- <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <touch file="target/classes/cobertura.properties"/>
+ <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties"/>
<!-- instrument all classes in target/classes directory -->
- <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes">
- <fileset dir="${project.build.directory}/classes">
- <include name="**/*.class" />
+ <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser"
+ todir="${project.build.directory}/classes">
+ <fileset dir="${project.build.directory}/classes">
+ <include name="**/*.class"/>
</fileset>
</cobertura-instrument>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
</execution>
<execution>
- <id>cobertura-report</id>
- <phase>post-integration-test</phase>
- <configuration>
- <target>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <id>cobertura-report</id>
+ <phase>post-integration-test</phase>
+ <configuration>
+ <target>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties"/>
<!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/site/cobertura" />
+ <mkdir dir="target/cobertura"/>
+ <mkdir dir="target/site/cobertura"/>
<!-- restore classes from backup folder to classes folder -->
- <copy toDir="target/classes" verbose="true" overwrite="true">
+ <copy toDir="target/classes" verbose="true" overwrite="true">
<fileset dir="target/cobertura/backup">
- <include name="**/*.class" />
+ <include name="**/*.class"/>
</fileset>
- </copy>
+ </copy>
<!-- delete backup folder-->
- <delete dir="target/cobertura/backup" />
+ <delete dir="target/cobertura/backup"/>
<!-- create a code coverage report -->
- <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura">
+ <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser"
+ destdir="${project.build.directory}/site/cobertura">
<fileset dir="${basedir}/src/main/java">
- <include name="**/*.java" />
+ <include name="**/*.java"/>
</fileset>
- </cobertura-report>
+ </cobertura-report>
<!-- delete cobertura.properties file -->
- <delete file="target/classes/cobertura.properties" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <delete file="target/classes/cobertura.properties"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
</executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
commit 5a714f3df86fe659cf2bc5938accaa72482c362d
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Jun 26 19:14:10 2012 -0400
-Add a few more itests for SecurityDomain
-exercises most of the Module Option Types
-Remove Authentication (Classic) from ignore list
-Add ability to override default discovery depth.
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractJBossAS7PluginTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractJBossAS7PluginTest.java
index 04c40de..43e6e06 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractJBossAS7PluginTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractJBossAS7PluginTest.java
@@ -18,6 +18,8 @@
*/
package org.rhq.modules.plugins.jbossas7.itest;
+import static org.testng.Assert.assertNotNull;
+
import java.util.Set;
import org.rhq.core.clientapi.agent.PluginContainerException;
@@ -35,8 +37,6 @@ import org.rhq.modules.plugins.jbossas7.itest.domain.DomainServerComponentTest;
import org.rhq.modules.plugins.jbossas7.itest.standalone.StandaloneServerComponentTest;
import org.rhq.test.arquillian.AfterDiscovery;
-import static org.testng.Assert.assertNotNull;
-
/**
* The base class for all as7 plugin integration tests.
*
@@ -51,6 +51,16 @@ public abstract class AbstractJBossAS7PluginTest extends AbstractAgentPluginTest
private static final int TYPE_HIERARCHY_DEPTH = 6;
+ private static int OVERRIDE_TYPE_HIERARCHY_DEPTH = -1;
+
+ public static int getMaxDiscoveryDepthOverride() {
+ return OVERRIDE_TYPE_HIERARCHY_DEPTH;
+ }
+
+ public static void setMaxDiscoveryDepthOverride(int overrideDepth) {
+ OVERRIDE_TYPE_HIERARCHY_DEPTH = overrideDepth;
+ }
+
private static boolean createdManagementUsers;
/**
@@ -115,6 +125,9 @@ public abstract class AbstractJBossAS7PluginTest extends AbstractAgentPluginTest
@Override
protected int getTypeHierarchyDepth() {
+ if (OVERRIDE_TYPE_HIERARCHY_DEPTH != -1) {
+ return OVERRIDE_TYPE_HIERARCHY_DEPTH;
+ }
return TYPE_HIERARCHY_DEPTH;
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/ResourcesStandaloneServerTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/ResourcesStandaloneServerTest.java
index bd904b9..aad8739 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/ResourcesStandaloneServerTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/ResourcesStandaloneServerTest.java
@@ -84,7 +84,7 @@ public class ResourcesStandaloneServerTest extends AbstractJBossAS7PluginTest {
ignoredResources.add("Load Metric");
//will revisit after BZ 826542 is resolved
- ignoredResources.add("Authentication (Classic)");
+ // ignoredResources.add("Authentication (Classic)");
Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
Resource server = getResourceByTypeAndKey(platform, StandaloneServerComponentTest.RESOURCE_TYPE,
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java
index 7f9464a..e3f88af 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java
@@ -21,9 +21,15 @@ package org.rhq.modules.plugins.jbossas7.itest.standalone;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Set;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.testng.annotations.Test;
@@ -32,17 +38,24 @@ import org.rhq.core.clientapi.agent.inventory.CreateResourceResponse;
import org.rhq.core.clientapi.agent.inventory.DeleteResourceRequest;
import org.rhq.core.clientapi.agent.inventory.DeleteResourceResponse;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.resource.CreateResourceStatus;
import org.rhq.core.domain.resource.DeleteResourceStatus;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pc.configuration.ConfigurationManager;
import org.rhq.core.pc.inventory.InventoryManager;
import org.rhq.modules.plugins.jbossas7.ASConnection;
import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent;
+import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent.Value;
import org.rhq.modules.plugins.jbossas7.itest.AbstractJBossAS7PluginTest;
+import org.rhq.modules.plugins.jbossas7.json.Address;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.Result;
import org.rhq.test.arquillian.RunDiscovery;
/**
@@ -69,6 +82,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
private static String SECURITY_DOMAIN_RESOURCE_KEY = "security-domain";
private static String AUTH_CLASSIC_RESOURCE_TYPE = "Authentication (Classic)";
private static String AUTH_CLASSIC_RESOURCE_KEY = "authentication=classic";
+ private static String PROFILE = "profile=full-ha";
protected static final String DC_HOST = System.getProperty("jboss.domain.bindAddress");
protected static final int DC_HTTP_PORT = Integer.valueOf(System.getProperty("jboss.domain.httpManagementPort"));
@@ -83,6 +97,9 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
public static final ResourceType RESOURCE_TYPE = new ResourceType(SECURITY_RESOURCE_TYPE, PLUGIN_NAME,
ResourceCategory.SERVICE, null);
private static final String RESOURCE_KEY = SECURITY_RESOURCE_KEY;
+ private static Resource testSecurityDomain = null;
+ private String testSecurityDomainKey = null;
+ private ConfigurationManager testConfigurationManager = null;
//Define some shared and reusable content
static HashMap<String, String> jsonMap = new HashMap<String, String>();
@@ -100,19 +117,194 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
"[{\"code\":\"Test\", \"type\":\"attribute\", \"module-options\":{\"mapping\":\"module\", \"mapping1\":\"module1\"}}]");
jsonMap.put("provider-modules",
"[{\"code\":\"Providers\", \"module-options\":{\"provider\":\"module\", \"provider1\":\"module1\"}}]");
+ jsonMap
+ .put("acl-modules",
+ "[{\"flag\":\"sufficient\", \"code\":\"ACL\", \"module-options\":{\"acl\":\"module\", \"acl1\":\"module1\"}}]");
+ jsonMap
+ .put("trust-modules",
+ "[{\"flag\":\"optional\", \"code\":\"TRUST\", \"module-options\":{\"trust\":\"module\", \"trust1\":\"module1\"}}]");
}
- @Test(priority = 10, groups = "discovery")
+ /** This method mass loads all the supported Module Option Types(Excluding authentication=jaspi, cannot co-exist with
+ * authentication=classic) into a single SecurityDomain. This is done as
+ * -i)creating all of the related hierarchy of types needed to exercise N Module Options Types and their associated
+ * Module Options instances would take too long to setup(N creates would signal N discovery runs before test could complete).
+ * -ii)setting the priority of this method lower than the discovery method means that we'll get all the same types in much
+ * less time.
+ *
+ * @throws Exception
+ */
+ @Test(priority = 10)
+ public void testLoadStandardModuleOptionTypes() throws Exception {
+ mapper = new ObjectMapper();
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ //Adjust discovery depth to support deeper hierarchy depth of Module Option elements
+ setMaxDiscoveryDepthOverride(10);
+
+ //create new Security Domain
+ Address destination = new Address(PROFILE);
+ destination.addSegment(SECURITY_RESOURCE_KEY);
+ String securityDomainId = TEST_DOMAIN + "2";
+ destination.addSegment(SECURITY_DOMAIN_RESOURCE_KEY + "=" + securityDomainId);
+
+ ASConnection connection = getASConnection();
+ Result result = new Result();
+ //delete old one if present to setup clean slate
+ Operation op = new Operation("remove", destination);
+ result = connection.execute(op);
+
+ //build/rebuild hierarchy
+ op = new Operation("add", destination);
+ result = connection.execute(op);
+
+ //Ex. profile=standalone-ha,subsystem=security,security-domain
+ String addressPrefix = PROFILE + "," + SECURITY_RESOURCE_KEY + "," + SECURITY_DOMAIN_RESOURCE_KEY;
+
+ //loop over standard types and add base details for all of them to security domain
+ String address = "";
+ for (String attribute : jsonMap.keySet()) {
+ if (attribute.equals("policy-modules")) {
+ address = addressPrefix + "=" + securityDomainId + ",authorization=classic";
+ } else if (attribute.equals("acl-modules")) {
+ address = addressPrefix + "=" + securityDomainId + ",acl=classic";
+ } else if (attribute.equals("mapping-modules")) {
+ address = addressPrefix + "=" + securityDomainId + ",mapping=classic";
+ } else if (attribute.equals("trust-modules")) {
+ address = addressPrefix + "=" + securityDomainId + ",identity-trust=classic";
+ } else if (attribute.equals("provider-modules")) {
+ address = addressPrefix + "=" + securityDomainId + ",audit=classic";
+ } else if (attribute.equals("login-modules")) {
+ address = addressPrefix + "=" + securityDomainId + ",authentication=classic";
+ } else {
+ assert false : "An unknown attribute '" + attribute
+ + "' was found. Is there a new type to be supported?";
+ }
+ //build the operation to add the component
+ ////Load json map into ModuleOptionType
+ List<Value> moduleTypeValue = new ArrayList<Value>();
+ try {
+ // loading jsonMap contents for Ex. 'login-module'
+ JsonNode node = mapper.readTree(jsonMap.get(attribute));
+ Object obj = mapper.treeToValue(node, Object.class);
+ result.setResult(obj);
+ result.setOutcome("success");
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ //populate the Value component complete with module Options.
+ moduleTypeValue = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
+ ModuleOptionsComponent.loadModuleOptionType(attribute));
+ op = ModuleOptionsComponent.createAddModuleOptionTypeOperation(new Address(address), attribute,
+ moduleTypeValue);
+ //submit the command
+ result = connection.execute(op);
+ }
+ }
+
+ @Test(priority = 11, groups = "discovery")
@RunDiscovery(discoverServices = true, discoverServers = true)
public void initialDiscovery() throws Exception {
Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
assertNotNull(platform);
assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
- Thread.sleep(20 * 1000L); // delay so that PC gets a chance to scan for resources
+ //Have thread sleep longer to discover deeper resource types.
+ Thread.sleep(120 * 1000L); // delay so that PC gets a chance to scan for resources
}
+ /** This test method exercises a number of things:
+ * - that the security-domain children loaded have been created successfully
+ * - that all of the supported Module Option Type children(excluding 'authentication=jaspi') have been
+ * discovered as AS7 types successfully.
+ * - that the correct child attribute was specified for each type //Ex. acl=classic -> acl-modules
+ * -
+ *
+ * @throws Exception
+ */
@Test(priority = 12)
+ public void testDiscoveredSecurityNodes() throws Exception {
+ //lazy-load configurationManager
+ if (testConfigurationManager == null) {
+ testConfigurationManager = this.pluginContainer.getConfigurationManager();
+ testConfigurationManager = pluginContainer.getConfigurationManager();
+ testConfigurationManager.initialize();
+ Thread.sleep(20 * 1000L);
+ }
+ //iterate through list of nodes and make sure they've all been discovered
+ ////Ex. profile=full-ha,subsystem=security,security-domain=testDomain2,acl=classic
+ String attribute = null;
+ for (String jsonKey : jsonMap.keySet()) {
+ //Ex. policy-modules
+ attribute = jsonKey;
+ //spinder 6/26/12: Temporarily disable until figure out why NPE happens only for this type?
+ if (attribute.equals(ModuleOptionsComponent.ModuleOptionType.Authentication.getAttribute())) {
+ break;//
+ }
+ //Ex. name=acl-modules
+ //check the configuration for the Module Option Type Ex. 'Acl (Profile)' Resource. Should be able to verify components
+ Resource aclResource = getModuleOptionResourceResource(attribute);
+ //assert non-zero id returned
+ assert aclResource.getId() > 0 : "The resource was not properly initialized. Expected id >0 but got:"
+ + aclResource.getId();
+
+ //Now request the resource complete with resource config
+ Configuration loadedConfiguration = testConfigurationManager.loadResourceConfiguration(aclResource.getId());
+ String code = null;
+ String type = null;
+ String flag = null;
+ //populate the associated attributes if it's supported.
+ for (String key : loadedConfiguration.getAllProperties().keySet()) {
+ Property property = loadedConfiguration.getAllProperties().get(key);
+ if (key.equals("code")) {
+ code = ((PropertySimple) property).getStringValue();
+ } else if (key.equals("flag")) {
+ flag = ((PropertySimple) property).getStringValue();
+ } else {//Ex. type.
+ type = ((PropertySimple) property).getStringValue();
+ }
+ }
+
+ //retrieve module options as well.
+ String jsonContent = jsonMap.get(attribute);
+ Result result = new Result();
+ try {
+ // loading jsonMap contents for Ex. 'login-module'
+ JsonNode node = mapper.readTree(jsonContent);
+ Object obj = mapper.treeToValue(node, Object.class);
+ result.setResult(obj);
+ result.setOutcome("success");
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ assert false;
+ } catch (IOException e) {
+ e.printStackTrace();
+ assert false;
+ }
+
+ //populate the Value component complete with module Options.
+ List<Value> moduleTypeValue = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
+ ModuleOptionsComponent.loadModuleOptionType(attribute));
+ Value moduleOptionType = moduleTypeValue.get(0);
+ //Ex. retrieve the acl-modules component and assert values.
+ //always test 'code'
+ assert moduleOptionType.getCode().equals(code) : "Module Option 'code' value is not correct. Expected '"
+ + code + "' but was '" + moduleOptionType.getCode() + "'";
+ if (attribute.equals(ModuleOptionsComponent.ModuleOptionType.Mapping.getAttribute())) {
+ assert moduleOptionType.getType().equals(type) : "Mapping Module 'type' value is not correct. Expected '"
+ + type + "' but was '" + moduleOptionType.getType() + "'";
+ } else if (!attribute.equals(ModuleOptionsComponent.ModuleOptionType.Audit.getAttribute())) {//Audit has no second parameter
+ assert moduleOptionType.getFlag().equals(flag) : "Provider Module 'flag' value is not correct. Expected '"
+ + flag + "' but was '" + moduleOptionType.getFlag() + "'";
+ }
+ }
+ //TODO spinder 6-26-12: retrieve the Module Options and test them too.
+ }
+
+ @Test(priority = 13)
public void testCreateSecurityDomain() throws Exception {
//get the root security resource
securityResource = getResource();
@@ -140,7 +332,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
+ response.getErrorMessage();
}
- @Test(priority = 13)
+ @Test(priority = 14)
public void testAuthenticationClassic() throws Exception {
//get the root security resource
securityResource = getResource();
@@ -179,7 +371,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
+ response.getErrorMessage();
}
- @Test(priority = 14)
+ @Test(priority = 15)
public void testDeleteSecurityDomain() throws Exception {
//get the root security resource
securityResource = getResource();
@@ -210,6 +402,15 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
+ response.getErrorMessage();
}
+ // public static void main(String[] args) {
+ // SecurityModuleOptionsTest setup = new SecurityModuleOptionsTest();
+ // try {
+ // setup.testLoadStandardModuleOptionTypes();
+ // } catch (Exception e) {
+ // e.printStackTrace();
+ // }
+ // }
+
private Resource getResource() {
InventoryManager im = pluginContainer.getInventoryManager();
@@ -220,6 +421,82 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
return bindings;
}
+ /** Automates
+ *
+ * @param optionAttributeType
+ * @return
+ */
+ private Resource getModuleOptionResourceResource(String optionAttributeType) {
+ Resource moduleOptionResource = null;
+ String securityDomainId = SECURITY_DOMAIN_RESOURCE_KEY + "=" + TEST_DOMAIN + "2";
+ if (testSecurityDomain == null) {
+ InventoryManager im = pluginContainer.getInventoryManager();
+ Resource platform = im.getPlatform();
+ //host controller
+ ResourceType hostControllerType = new ResourceType("JBossAS7 Host Controller", PLUGIN_NAME,
+ ResourceCategory.SERVER, null);
+ Resource hostController = getResourceByTypeAndKey(platform, hostControllerType,
+ "/tmp/jboss-as-6.0.0.GA/domain");
+ //profile=full-ha
+ ResourceType profileType = new ResourceType("Profile", PLUGIN_NAME, ResourceCategory.SERVICE, null);
+ String key = PROFILE;
+ Resource profile = getResourceByTypeAndKey(hostController, profileType, key);
+
+ //Security (Profile)
+ ResourceType securityType = new ResourceType("Security (Profile)", PLUGIN_NAME, ResourceCategory.SERVICE,
+ null);
+ key += "," + SECURITY_RESOURCE_KEY;
+ Resource security = getResourceByTypeAndKey(profile, securityType, key);
+
+ //Security Domain (Profile)
+ ResourceType domainType = new ResourceType("Security Domain (Profile)", PLUGIN_NAME,
+ ResourceCategory.SERVICE, null);
+ key += "," + securityDomainId;
+ testSecurityDomainKey = key;
+ testSecurityDomain = getResourceByTypeAndKey(security, domainType, key);
+ }
+
+ //acl=classic
+ String descriptorName = "";
+ String moduleAttribute = "";
+ //acl
+ if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Acl.getAttribute())) {
+ descriptorName = "ACL (Profile)";
+ moduleAttribute = "acl=classic";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Audit.getAttribute())) {
+ descriptorName = "Audit (Profile)";
+ moduleAttribute = "audit=classic";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Authentication.getAttribute())) {
+ descriptorName = "Authentication (Classic - Profile)";
+ moduleAttribute = "authentication=classic";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Authorization.getAttribute())) {
+ descriptorName = "Authorization (Profile)";
+ moduleAttribute = "authorization=classic";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.IdentityTrust.getAttribute())) {
+ descriptorName = "Identity Trust (Profile)";
+ moduleAttribute = "identity-trust=classic";
+ } else if (optionAttributeType.equals(ModuleOptionsComponent.ModuleOptionType.Mapping.getAttribute())) {
+ descriptorName = "Mapping (Profile)";
+ moduleAttribute = "mapping=classic";
+ }
+ //Build the right Module Option Type. Ex. ACL (Profile), etc.
+ ResourceType moduleOptionType = new ResourceType(descriptorName, PLUGIN_NAME, ResourceCategory.SERVICE, null);
+ ConfigurationDefinition cdef = new ConfigurationDefinition(descriptorName, null);
+ moduleOptionType.setResourceConfigurationDefinition(cdef);
+ //Ex. profile=full-ha,subsystem=security,security-domain=testDomain2,identity-trust=classic
+ String moduleOptionTypeKey = testSecurityDomainKey += "," + moduleAttribute;
+
+ if (!testSecurityDomainKey.endsWith(securityDomainId)) {
+ moduleOptionTypeKey = testSecurityDomainKey.substring(0, testSecurityDomainKey.indexOf(securityDomainId)
+ + securityDomainId.length())
+ + "," + moduleAttribute;
+ }
+
+ moduleOptionResource = getResourceByTypeAndKey(testSecurityDomain, moduleOptionType, moduleOptionTypeKey);
+
+ return moduleOptionResource;
+ }
+
private Resource getResource(Resource parentResource, String pluginDescriptorTypeName, String resourceKey) {
Resource resource = null;
if (((parentResource != null) & (pluginDescriptorTypeName != null) & (resourceKey != null))
commit 8f00d2c8e2fde0d6a2d627a2780cbd4e75e200b5
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Jun 27 14:13:52 2012 +0200
fix parametrization of class
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListDetailView.java
index 60cb4d3..b40ca54 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListDetailView.java
@@ -38,7 +38,7 @@ import org.rhq.enterprise.gui.coregui.client.components.table.Table;
*
* @author Ian Springer
*/
-public abstract class AbstractMeasurementDataTraitListDetailView extends Table {
+public abstract class AbstractMeasurementDataTraitListDetailView extends Table<AbstractMeasurementDataTraitDataSource> {
private static final String[] EXCLUDED_FIELD_NAMES = new String[] { MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME };
private static final SortSpecifier[] SORT_SPECIFIERS = new SortSpecifier[] {
commit 2d2ae3923fdaa1d94561f3995b4e59521e9267db
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jun 26 23:03:56 2012 -0500
[BZ 835710] Removed WebservicesComoponent class and moved the two resources using it to the generic BaseComponent.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebservicesComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebservicesComponent.java
deleted file mode 100644
index 0dea886..0000000
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebservicesComponent.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.rhq.modules.plugins.jbossas7;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
-import org.rhq.modules.plugins.jbossas7.json.Operation;
-import org.rhq.modules.plugins.jbossas7.json.Result;
-
-/**
- * Support for Webservices subsystem.
- *
- * @author Simeon Pinder
- */
-public class WebservicesComponent extends BaseComponent implements OperationFacet, ConfigurationFacet {
-
- @Override
- public Configuration loadResourceConfiguration() throws Exception {
- Configuration config = super.loadResourceConfiguration();
-
- return config;
- }
-
- @Override
- public void updateResourceConfiguration(ConfigurationUpdateReport report) {
-
- super.updateResourceConfiguration(report);
- }
-
- @Override
- public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
- Operation op = new Operation(name, getAddress());
- OperationResult operationResult = new OperationResult();
- Result result = null;
-
- if ("list-proxies".equals(name)) {
-
- } else {
- /*
- * This is a catch all for operations that are not explicitly treated above.
- */
- result = getASConnection().execute(op);
- if (result.isSuccess()) {
- operationResult.setSimpleResult("Success");
- }
- }
-
- if (!result.isSuccess()) {
- operationResult.setErrorMessage(result.getFailureDescription());
- }
-
- return operationResult;
- }
-}
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 ecbaea2..e096c0e 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
@@ -1745,7 +1745,7 @@
<service name="Webservices (Managed Server)"
discovery="SubsystemDiscovery"
- class="WebservicesComponent"
+ class="BaseComponent"
singleton="true">
<plugin-configuration>
@@ -3228,7 +3228,7 @@
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="login-modules" />
</plugin-configuration>
-
+
&loginModuleResourceConfig;
<service name="Module Options (Classic - Managed Server)" discovery="ModuleOptionsDiscoveryComponent"
@@ -6062,7 +6062,7 @@
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="login-modules" />
</plugin-configuration>
-
+
&loginModuleResourceConfig;
<service name="Module Options (Classic - Profile)" discovery="ModuleOptionsDiscoveryComponent" class="ModuleOptionsComponent"
@@ -8143,7 +8143,7 @@
<service name="Webservices"
discovery="SubsystemDiscovery"
- class="WebservicesComponent"
+ class="BaseComponent"
singleton="true">
<runs-inside>
@@ -10631,7 +10631,7 @@
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="policy-modules" />
</plugin-configuration>
-
+
&flagModuleResourceConfig;
<service name="Module Options (Authorization)" discovery="ModuleOptionsDiscoveryComponent" class="ModuleOptionsComponent"
commit aa77d7ee32f40ee646fec469cac8211bada3abd1
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Jun 26 16:35:36 2012 -0400
[BZ 835687] upgrade Postgres driver from 9.1-901.jdbc4 to 9.1-902.jdbc4 (https://bugzilla.redhat.com/show_bug.cgi?id=835687)
diff --git a/pom.xml b/pom.xml
index 210b697..603b89d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,7 +88,7 @@
<log4j.version>1.2.16</log4j.version>
<ojdbc6.version>11.2.0.3.0</ojdbc6.version>
<ems.version>1.3</ems.version>
- <postgresql.version>9.1-901.jdbc4</postgresql.version>
+ <postgresql.version>9.1-902.jdbc4</postgresql.version>
<h2.version>1.2.139</h2.version>
<jtds.version>1.2.2</jtds.version>
<richfaces.version>3.3.3.Final</richfaces.version>
@@ -179,7 +179,8 @@
<!-- NOTE: The below line is a workaround for a Maven bug, where it does not expand settings.* properties
used in the distributionManagement section of the POM. -->
<localRepository>${user.home}/.m2/repository</localRepository>
- <project.json.version>20080701</project.json.version>
+
+ <project.json.version>20080701</project.json.version>
</properties>
commit 2dc5e65abef4476d0b2a6247d258488688232888
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Tue Jun 26 18:02:25 2012 +0200
[BZ 835574 - When setting up workspace, the dynamically generated classes are not added to classpath] Solved using the org.codehaus.mojo:build-helper-maven-plugin. It adds the generated sources. NOTE: the mvn "process-resources" should be checked in the IDE Maven settings
diff --git a/modules/core/client-api/pom.xml b/modules/core/client-api/pom.xml
index b5f049f..834ad85 100644
--- a/modules/core/client-api/pom.xml
+++ b/modules/core/client-api/pom.xml
@@ -120,6 +120,25 @@
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-xjc-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${basedir}/target/generated-sources/xjc</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index aac9b9c..29662c8 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -345,6 +345,25 @@
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-gwt-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${basedir}/target/generated-sources/gwt</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
<!--
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 2ad20a2..bf10fc1 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -775,6 +775,18 @@ Build-OS-Version=${os.version}
</sources>
</configuration>
</execution>
+ <execution>
+ <id>add-antlr-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${basedir}/target/generated-sources/antlr3</source>
+ </sources>
+ </configuration>
+ </execution>
</executions>
</plugin>
diff --git a/modules/enterprise/server/xml-schemas/pom.xml b/modules/enterprise/server/xml-schemas/pom.xml
index d14f05d..6923a7a 100644
--- a/modules/enterprise/server/xml-schemas/pom.xml
+++ b/modules/enterprise/server/xml-schemas/pom.xml
@@ -129,6 +129,25 @@
</plugin>
<plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-xjc-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${basedir}/target/generated-sources/xjc</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
diff --git a/modules/plugins/perftest/pom.xml b/modules/plugins/perftest/pom.xml
index 739505b..e045081 100644
--- a/modules/plugins/perftest/pom.xml
+++ b/modules/plugins/perftest/pom.xml
@@ -77,6 +77,25 @@
</plugin>
<plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-xjc-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${basedir}/target/generated-sources/xjc</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
commit 9ee338547c8d09cb716b6982c74a11d22af212ec
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jun 26 11:04:45 2012 -0400
Provide more verbose Exception information in DEBUG mode.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index f7ae643..dce2e23 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -380,8 +380,8 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
// The most likely reason for a failure, although unlikely in itself, is that newly discovered resources
// are currently being merged into the platform, and associated with the doomed agent. In this case
// the user must wait until the merge is complete. Make sure the caller knows about this possibility.
- throw new IllegalStateException(
- "Failed to uninventory platform. This can happen if new resources were actively being imported. Please wait and try again shortly.");
+ String msg = "Failed to uninventory platform. This can happen if new resources were actively being imported. Please wait and try again shortly.";
+ throw new IllegalStateException(msg, (log.isDebugEnabled() ? e : null));
}
throw e;
commit 2af89d1a98d2a699590be823b3bb2d20d7ad2dea
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jun 25 15:39:44 2012 -0400
[BZ] protect measurement facet from mucking with the plugin container's metric schedules. the bulk of this commit is adding a unit test to the arquillian test framework
diff --git a/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java b/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
index 37e4ff2..b1ac175 100644
--- a/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
+++ b/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
@@ -32,6 +32,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -43,6 +44,12 @@ import org.rhq.core.clientapi.agent.upgrade.ResourceUpgradeResponse;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.discovery.MergeResourceResponse;
import org.rhq.core.domain.discovery.ResourceSyncInfo;
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.DisplayType;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.domain.measurement.NumericType;
+import org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceError;
@@ -61,7 +68,6 @@ import org.rhq.core.domain.resource.ResourceType;
*
* @author Lukas Krejci
*/
-// TODO (ips): Why don't we just make this implement DiscoveryServerService and use it as the actual server service?
public class FakeServerInventory {
private static final Log LOG = LogFactory.getLog(FakeServerInventory.class);
@@ -143,6 +149,7 @@ public class FakeServerInventory {
private Resource platform;
private Map<String, Resource> resourceStore = new HashMap<String, Resource>();
private int counter;
+ private AtomicInteger metricScheduleCounter = new AtomicInteger(1); // used when creating measurement schedules
private boolean failing;
private boolean failUpgrade;
@@ -364,6 +371,73 @@ public class FakeServerInventory {
};
}
+ // this expects the mock invocation to have two parameters - Set<Integer> resourceIds, Boolean getChildSchedules
+ public synchronized Answer<Set<ResourceMeasurementScheduleRequest>> getLatestSchedulesForResourceIds() {
+ return new Answer<Set<ResourceMeasurementScheduleRequest>>() {
+ @Override
+ @SuppressWarnings("unchecked")
+ public Set<ResourceMeasurementScheduleRequest> answer(InvocationOnMock invocation) throws Throwable {
+ Object[] args = invocation.getArguments();
+ Set<Integer> resourceIds = (Set<Integer>) args[0];
+ Boolean getChildSchedules = (Boolean) args[1];
+
+ Set<Resource> resources = getResources(resourceIds, getChildSchedules);
+ Set<ResourceMeasurementScheduleRequest> allSchedules = new HashSet<ResourceMeasurementScheduleRequest>();
+ for (Resource resource : resources) {
+ ResourceMeasurementScheduleRequest resourceSchedules = getDefaultMeasurementSchedules(resource);
+ if (resourceSchedules != null) {
+ allSchedules.add(resourceSchedules);
+ }
+ }
+ return allSchedules;
+ }
+ };
+ }
+
+ // this expects the mock invocation to have one parameter - Set<Integer> resourceIds
+ public synchronized Answer<Set<ResourceMeasurementScheduleRequest>> postProcessNewlyCommittedResources() {
+ return new Answer<Set<ResourceMeasurementScheduleRequest>>() {
+ @Override
+ @SuppressWarnings("unchecked")
+ public Set<ResourceMeasurementScheduleRequest> answer(InvocationOnMock invocation) throws Throwable {
+ Object[] args = invocation.getArguments();
+ Set<Integer> resourceIds = (Set<Integer>) args[0];
+
+ Set<Resource> resources = getResources(resourceIds, false);
+ Set<ResourceMeasurementScheduleRequest> allSchedules = new HashSet<ResourceMeasurementScheduleRequest>();
+ for (Resource resource : resources) {
+ ResourceMeasurementScheduleRequest resourceSchedules = getDefaultMeasurementSchedules(resource);
+ if (resourceSchedules != null) {
+ allSchedules.add(resourceSchedules);
+ }
+ }
+ return allSchedules;
+ }
+ };
+ }
+
+ private ResourceMeasurementScheduleRequest getDefaultMeasurementSchedules(Resource resource) {
+ ResourceType rt = resource.getResourceType();
+ Set<MeasurementDefinition> metrics = rt.getMetricDefinitions();
+ if (metrics == null || metrics.isEmpty()) {
+ return null;
+ }
+
+ ResourceMeasurementScheduleRequest resourceSchedules = new ResourceMeasurementScheduleRequest(resource.getId());
+ for (MeasurementDefinition metric : metrics) {
+ int id = this.metricScheduleCounter.getAndIncrement();
+ String name = metric.getName();
+ long interval = metric.getDefaultInterval();
+ boolean enabled = metric.isDefaultOn() || metric.getDisplayType() == DisplayType.SUMMARY;
+ DataType dataType = metric.getDataType();
+ NumericType nDataType = metric.getNumericType();
+ MeasurementScheduleRequest schedule = new MeasurementScheduleRequest(id, name, interval, enabled, dataType,
+ nDataType);
+ resourceSchedules.addMeasurementScheduleRequest(schedule);
+ }
+ return resourceSchedules;
+ }
+
public synchronized boolean isFailing() {
return failing;
}
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
new file mode 100644
index 0000000..8435114
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
@@ -0,0 +1,105 @@
+package org.rhq.core.pc.measurement;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.TargetsContainer;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.inventory.ResourceContainer;
+import org.rhq.plugins.test.measurement.BZ821058DiscoveryComponent;
+import org.rhq.plugins.test.measurement.BZ821058ResourceComponent;
+import org.rhq.test.arquillian.AfterDiscovery;
+import org.rhq.test.arquillian.BeforeDiscovery;
+import org.rhq.test.arquillian.FakeServerInventory;
+import org.rhq.test.arquillian.MockingServerServices;
+import org.rhq.test.arquillian.ResourceComponentInstances;
+import org.rhq.test.arquillian.ResourceContainers;
+import org.rhq.test.arquillian.RunDiscovery;
+import org.rhq.test.shrinkwrap.RhqAgentPluginArchive;
+
+/**
+ * Test for BZ 821058
+ */
+@RunDiscovery
+public class ReadOnlyScheduleSetTest extends Arquillian {
+
+ @Deployment(name = "bz821058Plugin")
+ @TargetsContainer("connected-pc-with-metric-collection")
+ public static RhqAgentPluginArchive getTestPlugin() {
+ RhqAgentPluginArchive pluginJar = ShrinkWrap.create(RhqAgentPluginArchive.class, "bz821058-plugin-1.0.jar");
+ return pluginJar.setPluginDescriptor("bz821058-rhq-plugin.xml").addClasses(BZ821058DiscoveryComponent.class,
+ BZ821058ResourceComponent.class);
+ }
+
+ @ArquillianResource
+ private PluginContainer pluginContainer;
+
+ @ArquillianResource
+ public MockingServerServices serverServices;
+
+ private FakeServerInventory fakeServerInventory;
+ private FakeServerInventory.CompleteDiscoveryChecker discoveryCompleteChecker;
+
+ @ResourceContainers(plugin = "bz821058Plugin", resourceType = "BZ821058Server")
+ private Set<ResourceContainer> containers;
+
+ @ResourceComponentInstances(plugin = "bz821058Plugin", resourceType = "BZ821058Server")
+ private Set<BZ821058ResourceComponent> components;
+
+ @BeforeDiscovery(testMethods = "testBZ821058")
+ public void resetServerServices() throws Exception {
+ serverServices.resetMocks();
+ fakeServerInventory = new FakeServerInventory();
+ discoveryCompleteChecker = fakeServerInventory.createAsyncDiscoveryCompletionChecker(1);
+
+ // autoimport everything
+ when(serverServices.getDiscoveryServerService().mergeInventoryReport(any(InventoryReport.class))).then(
+ fakeServerInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
+
+ // set up the metric schedules using the metric metadata to determine default intervals and enablement
+ when(serverServices.getDiscoveryServerService().postProcessNewlyCommittedResources(any(Set.class))).then(
+ fakeServerInventory.postProcessNewlyCommittedResources());
+ }
+
+ @AfterDiscovery
+ public void waitForAsyncDiscoveries() throws Exception {
+ if (discoveryCompleteChecker != null) {
+ discoveryCompleteChecker.waitForDiscoveryComplete(10000);
+ }
+ }
+
+ @Test(groups = "pc.itest.bz821058", priority = 20)
+ public void testBZ821058() throws Exception {
+ Assert.assertNotNull(pluginContainer);
+ Assert.assertTrue(pluginContainer.isStarted());
+
+ // make sure we have the resource container
+ Assert.assertEquals(containers.size(), 1, "missing container");
+
+ // make sure we have the resource component
+ Assert.assertEquals(components.size(), 1, "missing component");
+
+ assert containers.iterator().next().getResource().getInventoryStatus() == InventoryStatus.COMMITTED;
+
+ BZ821058ResourceComponent server = this.components.iterator().next();
+ // collection interval is set to 30s, and our container "connected-pc-with-metric-collection"
+ // is configured to start collecting metrics after an initial delay of 10s (see arquillian.xml).
+ // So let's give the test some time so the measurement facet can be called.
+ server.getValuesLatch.await(45, TimeUnit.SECONDS);
+
+ assert !server.errors.isEmpty() : "there should have been exceptions that occurred in the getValues method";
+ }
+}
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058DiscoveryComponent.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058DiscoveryComponent.java
new file mode 100644
index 0000000..b9f49a4
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058DiscoveryComponent.java
@@ -0,0 +1,51 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 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.plugins.test.measurement;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+public class BZ821058DiscoveryComponent implements ResourceDiscoveryComponent<ResourceComponent<?>> {
+
+ @Override
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ResourceComponent<?>> context)
+ throws InvalidPluginConfigurationException, Exception {
+
+ HashSet<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+ ResourceType rt = context.getResourceType();
+ String key = "bz821058";
+ String name = "bz821058";
+ String version = "1";
+ Configuration pc = context.getDefaultPluginConfiguration();
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(rt, key, name, version, null, pc, null);
+ details.add(resource);
+
+ return details;
+ }
+
+}
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058ResourceComponent.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058ResourceComponent.java
new file mode 100644
index 0000000..1ccadd6
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058ResourceComponent.java
@@ -0,0 +1,84 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 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.plugins.test.measurement;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+
+public class BZ821058ResourceComponent implements ResourceComponent<ResourceComponent<?>>, MeasurementFacet {
+
+ public List<Throwable> errors = Collections.synchronizedList(new ArrayList<Throwable>());
+ public CountDownLatch getValuesLatch = new CountDownLatch(1);
+
+ @Override
+ public AvailabilityType getAvailability() {
+ return AvailabilityType.UP;
+ }
+
+ @Override
+ public void start(ResourceContext<ResourceComponent<?>> context) throws Exception {
+ }
+
+ @Override
+ public void stop() {
+ }
+
+ /**
+ * To test BZ 821058, we just need to make sure we get exceptions if we try to
+ * manipulate the metrics set when this method is called by the PC.
+ */
+ @Override
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
+ try {
+ for (Iterator<MeasurementScheduleRequest> i = metrics.iterator(); i.hasNext();) {
+ MeasurementScheduleRequest metric = i.next();
+ report.addData(new MeasurementDataNumeric(metric, new Double(1.0)));
+ System.out.println("===============PRE REMOVE");
+ i.remove(); // this should not be allowed
+ System.out.println("===============POST REMOVE");
+ }
+ } catch (Throwable e) {
+ errors.add(e);
+ }
+
+ try {
+ System.out.println("===============PRE CLEAR");
+ metrics.clear(); // this should not be allowed
+ System.out.println("===============POST CLEAR");
+ } catch (Throwable e) {
+ errors.add(e);
+ }
+
+ getValuesLatch.countDown();
+ return;
+ }
+}
diff --git a/modules/core/plugin-container-itest/src/test/resources/arquillian.xml b/modules/core/plugin-container-itest/src/test/resources/arquillian.xml
index b8b9271..92968b2 100644
--- a/modules/core/plugin-container-itest/src/test/resources/arquillian.xml
+++ b/modules/core/plugin-container-itest/src/test/resources/arquillian.xml
@@ -4,6 +4,15 @@
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<group qualifier="pcs">
+ <container qualifier="connected-pc-with-metric-collection">
+ <configuration>
+ <property name="serverServicesImplementationClassName">org.rhq.test.arquillian.MockingServerServices</property>
+ <property name="insideAgent">true</property>
+ <property name="startManagementBean">false</property>
+ <property name="measurementCollectionInitialDelay">10</property> <!-- start collecting metrics after 10s -->
+ </configuration>
+ </container>
+
<container qualifier="connected-pc" default="true">
<configuration>
<property name="serverServicesImplementationClassName">org.rhq.test.arquillian.MockingServerServices</property>
diff --git a/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml b/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml
new file mode 100644
index 0000000..730a656
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin name="bz821058Plugin"
+ displayName="Plugin to test BZ 821058"
+ description="This will help test that measurement facet is given a read-only schedule set."
+ package="org.rhq.plugins.test.measurement"
+ version="1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+ <server name="BZ821058Server"
+ discovery="BZ821058DiscoveryComponent"
+ class="BZ821058ResourceComponent">
+
+ <metric property="metric1"
+ dataType="measurement"
+ defaultOn="true"
+ displayType="summary"
+ defaultInterval="30000" />
+
+ <metric property="metric2"
+ dataType="measurement"
+ defaultOn="true"
+ displayType="summary"
+ defaultInterval="30000" />
+ </server>
+</plugin>
+
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
index 3714ad9..ac13b06 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
@@ -23,6 +23,7 @@
package org.rhq.core.pc.measurement;
import java.util.ArrayDeque;
+import java.util.Collections;
import java.util.Date;
import java.util.Set;
import java.util.concurrent.Callable;
@@ -130,7 +131,7 @@ public class MeasurementCollectorRunner implements Callable<MeasurementReport>,
Set<? extends MeasurementScheduleRequest> requests, Resource resource) {
try {
long start = System.currentTimeMillis();
- measurementComponent.getValues(report, (Set<MeasurementScheduleRequest>) requests);
+ measurementComponent.getValues(report, Collections.unmodifiableSet(requests));
long duration = (System.currentTimeMillis() - start);
if (duration > 2000L) {
String message = "[PERF] Collection of measurements for [" + resource + "] (component=["
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
index 9ab82cb..dc7d0ca 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
@@ -469,7 +469,7 @@ public class MeasurementManager extends AgentService implements MeasurementAgent
}
try {
- measurementFacet.getValues(report, requests);
+ measurementFacet.getValues(report, Collections.unmodifiableSet(requests));
} catch (Throwable t) {
LOG.error("Could not get measurement values", t);
return Collections.emptySet();
commit 00ea14c228bd08d6572d0f17ef8040e447b9a0dd
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Jun 25 12:47:42 2012 -0400
[827647 Relative path for Drift Detections Definition Include/Excludes Path does not handle relative path alias or trailing file separator correctly]
There were two ways to go here. One was to add special case handling for
the various filter paths that equate to ".". The other was to normalize
in the Filter constructor. Since I tried option 1 and missed a spot in my
first try to fix it, I've now opted for option 2. The downside is only that
what the user types may get normalized to ".". But I added some more description
text to state as much. Also, existing Filter paths using "/" or "./" will
need to be updated to "." manually, but I doubt there are any out there
currently since it wasn't working.
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 dee6e01..5eaaeab 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
@@ -519,7 +519,7 @@ public class DriftConfigurationDefinition implements Serializable {
private static PropertyDefinitionSimple createIncludePath(boolean readOnly) {
String name = PROP_PATH;
- String description = "A file system directory path that is relative to (a sub-directory of) the base directory of the drift definition. The default is '.', the base directory itself.";
+ String description = "A file system directory path that is relative to (a sub-directory of) the base directory of the drift definition. The default is '.', the base directory itself. Note that '/' and './' will be normalized to '.' for consistent handling.";
boolean required = false;
PropertySimpleType type = PropertySimpleType.STRING;
@@ -592,7 +592,7 @@ public class DriftConfigurationDefinition implements Serializable {
private static PropertyDefinitionSimple createExcludePath(boolean readOnly) {
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 definition.";
+ String description = "A file system directory path that is relative to (a sub-directory of) the base directory of the drift definition. The default is '.', the base directory itself. Note that '/' and './' will be normalized to '.' for consistent handling.";
boolean required = true;
PropertySimpleType type = PropertySimpleType.STRING;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Filter.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Filter.java
index b57eb32..7e7bc43 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Filter.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Filter.java
@@ -41,7 +41,7 @@ public class Filter implements Serializable {
}
public void setPath(String path) {
- if (path == null) {
+ if (path == null || "./".equals(path) || "/".equals(path)) {
this.path = ".";
} else {
this.path = path;
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 92042e7..dbc7a1d 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
@@ -404,8 +404,7 @@ public class DriftDetector implements Runnable {
}
}
- // package-private for test accessibility
- static Set<File> getScanDirectories(final File basedir, List<Filter> includes) {
+ private static Set<File> getScanDirectories(final File basedir, List<Filter> includes) {
Set<File> directories = new HashSet<File>();
@@ -414,8 +413,7 @@ public class DriftDetector implements Runnable {
} else {
for (Filter filter : includes) {
String path = filter.getPath();
- // support various ways of expressing the base directory with relative paths
- if (".".equals(path) || "./".equals(path) || "/".equals(path)) {
+ if (".".equals(path)) {
directories.add(basedir);
} else {
directories.add(new File(basedir, path));
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/FilterFileVisitorTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/FilterFileVisitorTest.java
index d6812ba..eb3678c 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/FilterFileVisitorTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/FilterFileVisitorTest.java
@@ -31,10 +31,8 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
import org.apache.commons.io.FileUtils;
-import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -85,12 +83,7 @@ public class FilterFileVisitorTest {
List<Filter> includes = asList(new Filter(".", "foo*"), new Filter("./", "*.war"), new Filter("/", "goo*"));
List<Filter> excludes = emptyList();
TestVisitor visitor = new TestVisitor();
-
- // This call normalizes the basedir.
- Set<File> dirs = DriftDetector.getScanDirectories(basedir, includes);
- Assert.assertEquals(dirs.size(), 1, "Should just be the basedir");
- File normalizedBaseDir = dirs.iterator().next();
- forEachFile(normalizedBaseDir, new FilterFileVisitor(normalizedBaseDir, includes, excludes, visitor));
+ forEachFile(basedir, new FilterFileVisitor(basedir, includes, excludes, visitor));
assertCollectionEqualsNoOrder(asList(fooJar, gooJar, myapp), visitor.visitedFiles,
"Filtering failed with multiple includes and no excludes");
commit 1c7723b1fab7b3e0c16d94804014f70f3976960d
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Mon Jun 25 18:24:21 2012 +0200
[BZ 675150 - GWT: Alert definition : Conditions : metrics not sorted] Added new a class for serted version of the SelectItem
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/ServerPluginControlView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/ServerPluginControlView.java
index 597d158..df98a0a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/ServerPluginControlView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/ServerPluginControlView.java
@@ -47,6 +47,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.PluginGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -100,7 +101,7 @@ public class ServerPluginControlView extends LocatableVStack {
executeButton.setSrc(ImageManager.getOperationIcon());
executeButton.setPrompt(MSG.common_button_execute());
- final SelectItem controlNamesItem = new SelectItem("controlMenu", MSG.view_admin_plugins_serverControls_name());
+ final SelectItem controlNamesItem = new SortedSelectItem("controlMenu", MSG.view_admin_plugins_serverControls_name());
LinkedHashMap<String, String> controlNames = new LinkedHashMap<String, String>();
for (ServerPluginControlDefinition def : controlDefinitions) {
controlNames.put(def.getName(), def.getDisplayName());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java
index 225c5c5..f63eb55 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java
@@ -59,6 +59,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.form.RadioGroupWithComponentsItem;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.upload.DynamicFormHandler;
import org.rhq.enterprise.gui.coregui.client.components.upload.DynamicFormSubmitCompleteEvent;
import org.rhq.enterprise.gui.coregui.client.components.upload.PackageVersionFileUploadForm;
@@ -226,7 +227,7 @@ public class CliNotificationSenderForm extends AbstractNotificationSenderForm {
SectionItem userSection = new SectionItem("userSection");
userSection.setDefaultValue(MSG.view_alert_definition_notification_cliScript_editor_whichUser());
- repoSelector = new SelectItem(extendLocatorId("repoSelector"), MSG
+ repoSelector = new SortedSelectItem(extendLocatorId("repoSelector"), MSG
.view_alert_definition_notification_cliScript_editor_selectRepo());
repoSelector.setDefaultToFirstOption(true);
repoSelector.setWrapTitle(false);
@@ -557,7 +558,7 @@ public class CliNotificationSenderForm extends AbstractNotificationSenderForm {
private DynamicForm createExistingPackageForm() {
LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("existingPackageForm"));
form.setTitleOrientation(TitleOrientation.TOP);
- existingPackageSelector = new SelectItem(extendLocatorId("existingPackageSelector"), "");
+ existingPackageSelector = new SortedSelectItem(extendLocatorId("existingPackageSelector"), "");
existingPackageSelector.setDefaultToFirstOption(true);
existingPackageSelector.setWrapTitle(false);
existingPackageSelector.setRedrawOnChange(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index c9785b8..2687a87 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -24,14 +24,12 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
-import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
-import java.util.SortedSet;
import java.util.TreeSet;
import com.smartgwt.client.types.Alignment;
@@ -62,6 +60,7 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.form.DurationItem;
import org.rhq.enterprise.gui.coregui.client.components.form.NumberWithUnitsValidator;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.form.TimeUnit;
import org.rhq.enterprise.gui.coregui.client.util.measurement.MeasurementParser;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -176,7 +175,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
setMargin(20);
- conditionTypeSelectItem = new SelectItem("conditionType",
+ conditionTypeSelectItem = new SortedSelectItem("conditionType",
MSG.view_alert_definition_condition_editor_option_label());
LinkedHashMap<String, String> condTypes = new LinkedHashMap<String, String>(7);
condTypes.put(AlertConditionCategory.AVAILABILITY.name(),
@@ -761,7 +760,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
}
}
- SelectItem traitSelection = new SelectItem(TRAIT_METRIC_ITEMNAME,
+ SelectItem traitSelection = new SortedSelectItem(TRAIT_METRIC_ITEMNAME,
MSG.view_alert_definition_condition_editor_metric_trait_change_value());
traitSelection.setValueMap(traitsMap);
traitSelection.setDefaultValue(traitsMap.keySet().iterator().next()); // just use the first one
@@ -782,7 +781,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("availabilityHelp", helpStr, ifFunc);
formItems.add(helpItem);
- SelectItem selection = new SelectItem(AVAILABILITY_ITEMNAME,
+ SelectItem selection = new SortedSelectItem(AVAILABILITY_ITEMNAME,
MSG.view_alert_definition_condition_editor_availability_value());
LinkedHashMap<String, String> avails = new LinkedHashMap<String, String>(2);
avails.put(AlertConditionOperator.AVAIL_GOES_DOWN.name(),
@@ -815,7 +814,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("availabilityDurationHelp", helpStr, ifFunc);
formItems.add(helpItem);
- SelectItem selection = new SelectItem(AVAILABILITY_DURATION_ITEMNAME,
+ SelectItem selection = new SortedSelectItem(AVAILABILITY_DURATION_ITEMNAME,
MSG.view_alert_definition_condition_editor_availabilityDuration());
LinkedHashMap<String, String> avails = new LinkedHashMap<String, String>(2);
avails.put(AlertConditionOperator.AVAIL_DURATION_DOWN.name(),
@@ -856,7 +855,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
ops.put(opDef.getName(), opDef.getDisplayName());
}
- SelectItem opSelection = new SelectItem(OPERATION_NAME_ITEMNAME, MSG.common_title_value());
+ SelectItem opSelection = new SortedSelectItem(OPERATION_NAME_ITEMNAME, MSG.common_title_value());
opSelection.setValueMap(ops);
opSelection.setDefaultValue(ops.keySet().iterator().next()); // just use the first one
opSelection.setWidth("*");
@@ -864,7 +863,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
opSelection.setShowIfCondition(ifFunc);
formItems.add(opSelection);
- SelectItem opResultsSelection = new SelectItem(OPERATION_RESULTS_ITEMNAME, MSG.common_title_status());
+ SelectItem opResultsSelection = new SortedSelectItem(OPERATION_RESULTS_ITEMNAME, MSG.common_title_status());
LinkedHashMap<String, String> operationStatuses = new LinkedHashMap<String, String>(4);
operationStatuses.put(OperationRequestStatus.INPROGRESS.name(), MSG.common_status_inprogress());
operationStatuses.put(OperationRequestStatus.SUCCESS.name(), MSG.common_status_success());
@@ -969,15 +968,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
}
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
- SortedSet<MeasurementDefinition> sortedDefs = new TreeSet<MeasurementDefinition>(
- new Comparator<MeasurementDefinition>() {
-
- @Override
- public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
- return o1.getDisplayName().compareTo(o2.getDisplayName());
- }
- });
- sortedDefs.addAll(this.resourceType.getMetricDefinitions());
+ Set<MeasurementDefinition> sortedDefs = new HashSet<MeasurementDefinition>(this.resourceType.getMetricDefinitions());
for (MeasurementDefinition def : sortedDefs) {
if (def.getDataType() == DataType.MEASUREMENT) {
@@ -994,7 +985,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
return null; // all metrics should be hidden
}
- SelectItem metricSelection = new SelectItem(itemName,
+ SelectItem metricSelection = new SortedSelectItem(itemName,
MSG.view_alert_definition_condition_editor_metric_threshold_name());
metricSelection.setValueMap(metricsMap);
metricSelection.setDefaultValue(metricsMap.keySet().iterator().next()); // just use the first one
@@ -1013,7 +1004,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
}
}
- SelectItem metricSelection = new SelectItem(itemName,
+ SelectItem metricSelection = new SortedSelectItem(itemName,
MSG.view_alert_definition_condition_editor_metric_calltime_common_name());
metricSelection.setValueMap(metricsMap);
metricSelection.setDefaultValue(metricsMap.keySet().iterator().next()); // just use the first one
@@ -1033,7 +1024,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
comparators.put(">", "> (" + MSG.view_alert_definition_condition_editor_metric_threshold_comparator_greater()
+ ")");
- SelectItem comparatorSelection = new SelectItem(itemName,
+ SelectItem comparatorSelection = new SortedSelectItem(itemName,
MSG.view_alert_definition_condition_editor_metric_threshold_comparator());
comparatorSelection.setValueMap(comparators);
comparatorSelection.setDefaultValue("<");
@@ -1051,7 +1042,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
comparators.put("CH", MSG.view_alert_definition_condition_editor_metric_calltime_common_comparator_changes());
comparators.put("HI", MSG.view_alert_definition_condition_editor_metric_calltime_common_comparator_grows());
- SelectItem comparatorSelection = new SelectItem(itemName,
+ SelectItem comparatorSelection = new SortedSelectItem(itemName,
MSG.view_alert_definition_condition_editor_metric_calltime_common_comparator());
comparatorSelection.setValueMap(comparators);
comparatorSelection.setDefaultValue("CH");
@@ -1070,7 +1061,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
comparators.put("<=", MSG.view_alert_definition_condition_editor_metric_range_comparator_inside_inclusive());
comparators.put(">=", MSG.view_alert_definition_condition_editor_metric_range_comparator_outside_inclusive());
- SelectItem comparatorSelection = new SelectItem(itemName,
+ SelectItem comparatorSelection = new SortedSelectItem(itemName,
MSG.view_alert_definition_condition_editor_metric_range_comparator());
comparatorSelection.setValueMap(comparators);
comparatorSelection.setDefaultValue("<");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
index 666ecfa..9cf0850 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
@@ -45,6 +45,7 @@ import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
@@ -84,7 +85,7 @@ public class NewNotificationEditor extends LocatableDynamicForm {
senderCanvasItem.setShowTitle(false);
senderCanvasItem.setColSpan(2);
- notificationSenderSelectItem = new SelectItem("notificationSender", MSG
+ notificationSenderSelectItem = new SortedSelectItem("notificationSender", MSG
.view_alert_definition_notification_editor_sender());
notificationSenderSelectItem.setDefaultToFirstOption(true);
notificationSenderSelectItem.setWrapTitle(false);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
index 0e8f1b2..e34f2eb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
@@ -37,6 +37,7 @@ import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -171,7 +172,7 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements
.view_alert_definition_recovery_editor_disable_when_fired());
disableWhenFiredStatic.setWrapTitle(false);
- recoverAlertSelection = new SelectItem("recoveryAlert", MSG
+ recoverAlertSelection = new SortedSelectItem("recoveryAlert", MSG
.view_alert_definition_recovery_editor_recovery_alert());
recoverAlertSelection.setDefaultValue("0");
recoverAlertSelection.setWrapTitle(false);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
index 4a565a2..cc4e061 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
@@ -59,9 +59,10 @@ import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.alert.definitions.ResourceOperationNotificationInfo.ResourceSelectionMode;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.SingleResourcePicker;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourcePicker.OkHandler;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.SingleResourcePicker;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
@@ -109,7 +110,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
operationArgumentsCanvasItem.setHeight(400);
operationArgumentsCanvasItem.setWidth(500);
- operationSelectItem = new SelectItem("operationSelectItem", MSG
+ operationSelectItem = new SortedSelectItem("operationSelectItem", MSG
.view_alert_definition_notification_operation_editor_common_operation());
operationSelectItem.setStartRow(true);
operationSelectItem.setEndRow(true);
@@ -160,7 +161,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
// for RELATIVE mode
- ancestorTypeSelectItem = new SelectItem("ancestorTypeSelectItem", MSG
+ ancestorTypeSelectItem = new SortedSelectItem("ancestorTypeSelectItem", MSG
.view_alert_definition_notification_operation_editor_relative_ancestor());
ancestorTypeSelectItem.setStartRow(true);
ancestorTypeSelectItem.setEndRow(true);
@@ -178,7 +179,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
}
});
- descendantTypeSelectItem = new SelectItem("descendantTypeSelectItem", MSG
+ descendantTypeSelectItem = new SortedSelectItem("descendantTypeSelectItem", MSG
.view_alert_definition_notification_operation_editor_relative_descendant());
descendantTypeSelectItem.setStartRow(true);
descendantTypeSelectItem.setEndRow(false);
@@ -208,7 +209,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
// the mode selector menu
- modeSelectItem = new SelectItem("modeSelectItem", MSG
+ modeSelectItem = new SortedSelectItem("modeSelectItem", MSG
.view_alert_definition_notification_operation_editor_mode_title());
modeSelectItem.setStartRow(true);
modeSelectItem.setEndRow(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java
index fd1a659..037bc10 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java
@@ -32,6 +32,7 @@ import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.criteria.BundleCriteria;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.bundle.list.BundlesDataSource;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -54,7 +55,7 @@ public class BundleSelector extends AbstractSelector<Bundle, BundleCriteria> {
availableFilterForm.setNumCols(4);
final TextItem search = new TextItem("search", MSG.common_title_search());
- final SelectItem bundleTypeSelect = new SelectItem("bundleType", MSG.view_bundle_bundleType());
+ final SelectItem bundleTypeSelect = new SortedSelectItem("bundleType", MSG.view_bundle_bundleType());
bundleService.getAllBundleTypes(new AsyncCallback<ArrayList<BundleType>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.dataSource_bundle_loadFailed(), caught);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleTypeDropDownSelectItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleTypeDropDownSelectItem.java
index 959237b..572ad7e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleTypeDropDownSelectItem.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleTypeDropDownSelectItem.java
@@ -23,12 +23,12 @@ import java.util.HashMap;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -37,7 +37,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/**
* Provides a drop down menu that allows one to select a bundle type.
*/
-public class BundleTypeDropDownSelectItem extends SelectItem {
+public class BundleTypeDropDownSelectItem extends SortedSelectItem {
private final HashMap<String, BundleType> knownBundleTypes = new HashMap<String, BundleType>();
private BundleType selected = null;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleVersionStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleVersionStep.java
index e68d159..154217b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleVersionStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleVersionStep.java
@@ -34,6 +34,7 @@ import org.rhq.core.domain.criteria.BundleDeploymentCriteria;
import org.rhq.core.domain.criteria.BundleVersionCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -55,7 +56,7 @@ public class SelectBundleVersionStep extends AbstractWizardStep {
private DynamicForm form;
private RadioGroupItem radioGroupItem = new RadioGroupItem("options", "Deploy Options");
- private SelectItem selectVersionItem = new SelectItem("selectVersion", "Deployment Version");
+ private SelectItem selectVersionItem = new SortedSelectItem("selectVersion", "Deployment Version");
private LinkedHashMap<String, String> radioGroupValues = new LinkedHashMap<String, String>();
private LinkedHashMap<String, String> selectVersionValues = new LinkedHashMap<String, String>();
private PageList<BundleVersion> bundleVersions = null;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index dc32e91..4e3e9df 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -117,6 +117,7 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.components.form.IsLongValidator;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
@@ -830,7 +831,7 @@ public class ConfigurationEditor extends LocatableVLayout {
LocatableDynamicForm deleteForm = new LocatableDynamicForm(deleteControlsLayout.extendLocatorId("Form"));
deleteForm.setWidth100();
- final SelectItem selectItem = new SelectItem();
+ final SelectItem selectItem = new SortedSelectItem();
selectItem.setMultiple(true);
selectItem.setMultipleAppearance(MultipleAppearance.GRID);
selectItem.setTitle(MSG.common_button_delete());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
index 6b38965..b12382a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
@@ -69,6 +69,7 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.PopupWindow;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
@@ -755,12 +756,12 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
((ComboBoxItem) editorItem).setAddUnknownValues(true);
} else {
if (valueOptions.size() > 5) {
- editorItem = new SelectItem();
+ editorItem = new SortedSelectItem();
} else {
// TODO: we want RadioGroupItem, but smartgwt seems to have a bug and it won't render this when
// our listgrid does not have the "unset" boolean field also present. If its just the value
// field, the radio group editor won't show.
- editorItem = new SelectItem(); // new RadioGroupItem();
+ editorItem = new SortedSelectItem(); // new RadioGroupItem();
}
}
editorItem.setValueMap(valueOptions);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SortedSelectItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SortedSelectItem.java
new file mode 100644
index 0000000..4f483e9
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SortedSelectItem.java
@@ -0,0 +1,96 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 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.gui.coregui.client.components.form;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.LinkedHashMap;
+import java.util.Map.Entry;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+
+/**
+ * A convenience class for a sorted variant of {@link SelectItem}.
+ *
+ * @author Jirka Kremser
+ */
+public class SortedSelectItem extends SelectItem {
+ public SortedSelectItem() {
+ super();
+ }
+
+ public SortedSelectItem(JavaScriptObject jsObj) {
+ super(jsObj);
+ }
+
+ public SortedSelectItem(String name) {
+ super(name);
+ }
+
+ public SortedSelectItem(String name, String title) {
+ super(name, title);
+ }
+
+ @Override
+ public void setValueMap(@SuppressWarnings("rawtypes")
+ LinkedHashMap valueMap) {
+ if (valueMap == null) {
+ throw new IllegalArgumentException("valueMap cannot be null");
+ }
+ @SuppressWarnings("unchecked")
+ LinkedHashMap<String, String> safeValueMap = (LinkedHashMap<String, String>) valueMap;
+ LinkedHashMap<String, String> sortedValueMap = new LinkedHashMap<String, String>(valueMap.size());
+ SortedSet<Entry<String, String>> sortedEntries = new TreeSet<Entry<String, String>>(
+ new Comparator<Entry<String, String>>() {
+
+ @Override
+ public int compare(Entry<String, String> o1, Entry<String, String> o2) {
+ return o1.getValue().compareTo(o2.getValue());
+ }
+ });
+ sortedEntries.addAll(safeValueMap.entrySet());
+ for (Entry<String, String> entry : sortedEntries) {
+ sortedValueMap.put(entry.getKey(), entry.getValue());
+ }
+
+ super.setValueMap(sortedValueMap);
+ }
+
+ @Override
+ public void setValueMap(String... valueMap) {
+ if (valueMap == null) {
+ throw new IllegalArgumentException("valueMap cannot be null");
+ }
+ String[] sortedValueArray = new String[valueMap.length];
+ System.arraycopy(valueMap, 0, sortedValueArray, 0, valueMap.length);
+ Arrays.sort(sortedValueArray);
+
+ super.setValueMap(sortedValueArray);
+ }
+
+ @Override
+ public void setValues(String... valueMap) {
+ setValueMap(valueMap);
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java
index d91fc3b..7e75fae 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java
@@ -35,6 +35,7 @@ import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.resource.group.GroupCategory;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.selector.AssignedItemsChangedEvent;
import org.rhq.enterprise.gui.coregui.client.components.selector.AssignedItemsChangedHandler;
import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
@@ -125,7 +126,7 @@ public class ResourceGroupGraphPortlet extends ResourceGroupMetricGraphView impl
//rec.setAttribute("name", "current");
//resourceGroupSelector.setAssigned(new ListGridRecord[] { rec });
- final SelectItem metric = new SelectItem(CFG_DEFINITION_ID, MSG.common_title_metric()) {
+ final SelectItem metric = new SortedSelectItem(CFG_DEFINITION_ID, MSG.common_title_metric()) {
@Override
protected Criteria getPickListFilterCriteria() {
Criteria criteria = new Criteria();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddDefinitionWizardInfoStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddDefinitionWizardInfoStep.java
index c2139c1..63722cc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddDefinitionWizardInfoStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddDefinitionWizardInfoStep.java
@@ -38,6 +38,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.drift.DriftConfigurationDefinition;
import org.rhq.core.domain.drift.DriftDefinitionTemplate;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
import org.rhq.enterprise.gui.coregui.client.util.FormUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
@@ -76,7 +77,7 @@ public class DriftAddDefinitionWizardInfoStep extends AbstractWizardStep {
SpacerItem spacerItem = new SpacerItem("Spacer");
formItems.add(spacerItem);
- SelectItem templateSelectItem = new SelectItem("Template", MSG.view_drift_wizard_addDef_templatePrompt());
+ SelectItem templateSelectItem = new SortedSelectItem("Template", MSG.view_drift_wizard_addDef_templatePrompt());
templateSelectItem.setTitleOrientation(TitleOrientation.TOP);
templateSelectItem.setAlign(Alignment.LEFT);
templateSelectItem.setWidth(300);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftPinTemplateWizardInfoStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftPinTemplateWizardInfoStep.java
index 742b44d..ee7da2a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftPinTemplateWizardInfoStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftPinTemplateWizardInfoStep.java
@@ -38,8 +38,9 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import org.rhq.core.domain.drift.DriftDefinitionComparator;
-import org.rhq.core.domain.drift.DriftDefinitionTemplate;
import org.rhq.core.domain.drift.DriftDefinitionComparator.CompareMode;
+import org.rhq.core.domain.drift.DriftDefinitionTemplate;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
import org.rhq.enterprise.gui.coregui.client.util.FormUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
@@ -59,7 +60,7 @@ public class DriftPinTemplateWizardInfoStep extends AbstractWizardStep {
private AbstractDriftPinTemplateWizard wizard;
private LocatableDynamicForm selectTemplateForm;
- SelectItem selectTemplateItem = new SelectItem("Template", MSG.view_drift_wizard_addDef_templatePrompt());
+ SelectItem selectTemplateItem = new SortedSelectItem("Template", MSG.view_drift_wizard_addDef_templatePrompt());
public DriftPinTemplateWizardInfoStep(AbstractDriftPinTemplateWizard wizard) {
this.wizard = wizard;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
index 1ac329d..c52eb30 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
@@ -60,6 +60,7 @@ import org.rhq.enterprise.gui.coregui.client.components.configuration.Configurat
import org.rhq.enterprise.gui.coregui.client.components.form.AbstractRecordEditor;
import org.rhq.enterprise.gui.coregui.client.components.form.DurationItem;
import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.form.TimeUnit;
import org.rhq.enterprise.gui.coregui.client.components.form.UnitType;
import org.rhq.enterprise.gui.coregui.client.components.trigger.JobTriggerEditor;
@@ -188,7 +189,7 @@ public abstract class AbstractOperationScheduleDetailsView extends
items.add(idItem);
}
- SelectItem operationNameItem = new SelectItem(AbstractOperationScheduleDataSource.Field.OPERATION_NAME);
+ SelectItem operationNameItem = new SortedSelectItem(AbstractOperationScheduleDataSource.Field.OPERATION_NAME);
operationNameItem.setShowTitle(true);
items.add(operationNameItem);
operationNameItem.addChangedHandler(new ChangedHandler() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionExpressionBuilder.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionExpressionBuilder.java
index d108dc4..2f99096 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionExpressionBuilder.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionExpressionBuilder.java
@@ -23,12 +23,26 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.events.CloseClickEvent;
import com.smartgwt.client.widgets.events.CloseClickHandler;
-import com.smartgwt.client.widgets.form.fields.*;
-import com.smartgwt.client.widgets.form.fields.events.*;
+import com.smartgwt.client.widgets.form.fields.ButtonItem;
+import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.TextAreaItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
+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.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+
import org.rhq.core.domain.criteria.Criteria.Restriction;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
import org.rhq.core.domain.plugin.Plugin;
@@ -36,16 +50,13 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.GroupDefinitionExpressionBuilderGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-
/**
* A dialog window that lets you build custom dynagroup expressions.
*
@@ -121,7 +132,7 @@ public class GroupDefinitionExpressionBuilder extends LocatableWindow {
}
});
- this.compareTypeItem = new SelectItem("compareType", MSG.view_dynagroup_exprBuilder_comparisonType());
+ this.compareTypeItem = new SortedSelectItem("compareType", MSG.view_dynagroup_exprBuilder_comparisonType());
this.compareTypeItem.setTooltip(MSG.view_dynagroup_exprBuilder_comparisonType_tooltip());
this.compareTypeItem.setHoverWidth(250);
this.compareTypeItem.setRedrawOnChange(true);
@@ -166,7 +177,7 @@ public class GroupDefinitionExpressionBuilder extends LocatableWindow {
}
});
- this.resourceTypeItem = new SelectItem("resourceType", MSG.view_dynagroup_exprBuilder_resourceType());
+ this.resourceTypeItem = new SortedSelectItem("resourceType", MSG.view_dynagroup_exprBuilder_resourceType());
this.resourceTypeItem.setTooltip(MSG.view_dynagroup_exprBuilder_resourceType_tooltip());
this.resourceTypeItem.setHoverWidth(250);
this.resourceTypeItem.setRedrawOnChange(true);
@@ -180,7 +191,7 @@ public class GroupDefinitionExpressionBuilder extends LocatableWindow {
}
});
- this.pluginItem = new SelectItem("plugin", MSG.view_dynagroup_exprBuilder_definingPlugin());
+ this.pluginItem = new SortedSelectItem("plugin", MSG.view_dynagroup_exprBuilder_definingPlugin());
this.pluginItem.setTooltip(MSG.view_dynagroup_exprBuilder_definingPlugin_tooltip());
this.pluginItem.setHoverWidth(250);
this.pluginItem.setRedrawOnChange(true);
@@ -223,7 +234,7 @@ public class GroupDefinitionExpressionBuilder extends LocatableWindow {
}
});
- this.expressionTypeItem = new SelectItem("expressionType", MSG.view_dynagroup_exprBuilder_expressionType());
+ this.expressionTypeItem = new SortedSelectItem("expressionType", MSG.view_dynagroup_exprBuilder_expressionType());
this.expressionTypeItem.setTooltip(MSG.view_dynagroup_exprBuilder_expressionType_tooltip());
this.expressionTypeItem.setHoverWidth(250);
this.expressionTypeItem.setRedrawOnChange(true);
@@ -243,7 +254,7 @@ public class GroupDefinitionExpressionBuilder extends LocatableWindow {
}
});
- this.resourceItem = new SelectItem("resource", MSG.view_dynagroup_exprBuilder_resource());
+ this.resourceItem = new SortedSelectItem("resource", MSG.view_dynagroup_exprBuilder_resource());
this.resourceItem.setTooltip(MSG.view_dynagroup_exprBuilder_resource_tooltip());
this.resourceItem.setHoverWidth(250);
this.resourceItem.setRedrawOnChange(true);
@@ -430,7 +441,6 @@ public class GroupDefinitionExpressionBuilder extends LocatableWindow {
typeNames.add(type.getName());
resourceTypeIds.put(type.getName(), Integer.valueOf(type.getId()));
}
- Collections.sort(typeNames);
resourceTypeItem.setValueMap(typeNames.toArray(new String[typeNames.size()]));
} else {
resourceTypeItem.setValueMap(new String[0]);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryInfoStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryInfoStep.java
index 20ebf5f..329c7f9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryInfoStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryInfoStep.java
@@ -37,6 +37,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.content.Architecture;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
@@ -147,7 +148,7 @@ public class ResourceFactoryInfoStep extends AbstractWizardStep {
}
if (null != templatePrompt) {
- SelectItem templateSelect = new SelectItem("template", templatePrompt);
+ SelectItem templateSelect = new SortedSelectItem("template", templatePrompt);
templateSelect.setTitleOrientation(TitleOrientation.TOP);
templateSelect.setAlign(Alignment.LEFT);
templateSelect.setWidth(300);
commit 841e1f0adfabed848b9f841b1856e4abecf1620a
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Jun 25 12:17:46 2012 -0400
[BZ 835113] fix so EJB2 MDB Resources do not erroneously return an avail of DOWN (https://bugzilla.redhat.com/show_bug.cgi?id=835113)
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java
index ebbf9bb..c4ae68f 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/Ejb2BeanComponent.java
@@ -1,6 +1,6 @@
/*
* Jopr Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * Copyright (C) 2005-2012 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -27,7 +27,9 @@ import java.util.Set;
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.RunState;
+import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.plugins.jbossas5.util.Ejb2BeanUtils;
/**
@@ -39,6 +41,19 @@ public class Ejb2BeanComponent extends AbstractEjbBeanComponent {
private static final ComponentType MDB_COMPONENT_TYPE = new ComponentType("EJB", "MDB");
@Override
+ protected AvailabilityType getAvailabilityForRunState(RunState runState) {
+ AvailabilityType avail;
+ if (MDB_COMPONENT_TYPE.equals(getComponentType())) {
+ // This is a workaround for if BZ 835113.
+ avail = (runState == RunState.RUNNING || runState == RunState.UNKNOWN) ?
+ AvailabilityType.UP : AvailabilityType.DOWN;
+ } else {
+ avail = super.getAvailabilityForRunState(runState);
+ }
+ return avail;
+ }
+
+ @Override
protected ManagedComponent getManagedComponent() {
if (MDB_COMPONENT_TYPE.equals(getComponentType())) {
try {
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java
index 5d28473..a44cfc8 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java
@@ -124,22 +124,32 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
// ResourceComponent Implementation --------------------------------------------
public AvailabilityType getAvailability() {
- long timeSinceComponentRefresh = System.currentTimeMillis() - lastComponentRefresh;
- if (timeSinceComponentRefresh > availRefreshInterval) {
- if (log.isDebugEnabled()) {
- log.debug("The availability refresh interval for [resourceKey: "
- + getResourceContext().getResourceKey() + ", type: " + componentType + ", name: " + componentName
- + "] has been exceeded by " + (timeSinceComponentRefresh - availRefreshInterval)
- + " ms. Reloading managed component.");
- }
+ if (lastComponentRefresh == 0) {
+ // The managed component has not been refreshed at all yet.
getManagedComponent();
+ } else {
+ long timeSinceComponentRefresh = System.currentTimeMillis() - lastComponentRefresh;
+ if (timeSinceComponentRefresh > availRefreshInterval) {
+ if (log.isDebugEnabled()) {
+ log.debug("The availability refresh interval for [resourceKey: "
+ + getResourceContext().getResourceKey() + ", type: " + componentType + ", name: " + componentName
+ + "] has been exceeded by " + (timeSinceComponentRefresh - availRefreshInterval)
+ + " ms. Reloading managed component...");
+ }
+ getManagedComponent();
+ }
}
+ return getAvailabilityForRunState(runState);
+ }
+
+ protected AvailabilityType getAvailabilityForRunState(RunState runState) {
if (runState == RunState.RUNNING) {
return AvailabilityType.UP;
} else {
if (log.isDebugEnabled()) {
- log.debug(componentType + " component '" + componentName + "' was not running, state was : " + runState);
+ log.debug(componentType + " component '" + componentName + "' was not running - state was [" + runState
+ + "].");
}
return AvailabilityType.DOWN;
}
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/serviceBinding/ManagerComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/serviceBinding/ManagerComponent.java
index ba2a4c9..eae8b13 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/serviceBinding/ManagerComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/serviceBinding/ManagerComponent.java
@@ -71,13 +71,13 @@ public class ManagerComponent extends ManagedComponentComponent implements Creat
private static final String RESOURCE_KEY_SEPARATOR = "!)@(#*";
@Override
- public AvailabilityType getAvailability() {
- RunState runState = getManagedComponent().getRunState();
- return (runState == RunState.RUNNING || runState == RunState.UNKNOWN) ? AvailabilityType.UP
- : AvailabilityType.DOWN;
+ protected AvailabilityType getAvailabilityForRunState(RunState runState) {
+ // This is a workaround for a bug where the binding manager MO will return a run state of UNKNOWN even when it's
+ // happily running.
+ return (runState == RunState.RUNNING || runState == RunState.UNKNOWN) ?
+ AvailabilityType.UP : AvailabilityType.DOWN;
}
-
// ConfigurationFacet -----------------------------
@Override
commit b352ab20a4e0deb0d9eccf1d492de2917d2098c2
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Mon Jun 25 15:16:12 2012 +0200
[BZ 815321 - Platform alert conditions for availability (Goes Disabled and Goes Unknown ) should be removed] Options have been reomved when adding alert condition for resource of type platform
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 61e2f21..c9785b8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -57,6 +57,7 @@ import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.core.domain.measurement.NumericType;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.form.DurationItem;
@@ -786,10 +787,13 @@ public class NewConditionEditor extends LocatableDynamicForm {
LinkedHashMap<String, String> avails = new LinkedHashMap<String, String>(2);
avails.put(AlertConditionOperator.AVAIL_GOES_DOWN.name(),
MSG.view_alert_definition_condition_editor_operator_availability_goesDown());
- avails.put(AlertConditionOperator.AVAIL_GOES_DISABLED.name(),
- MSG.view_alert_definition_condition_editor_operator_availability_goesDisabled());
- avails.put(AlertConditionOperator.AVAIL_GOES_UNKNOWN.name(),
- MSG.view_alert_definition_condition_editor_operator_availability_goesUnknown());
+ // do not add 'Goes Disabled' and 'Goes Unknown' for platform
+ if (resourceType.getCategory() != ResourceCategory.PLATFORM) {
+ avails.put(AlertConditionOperator.AVAIL_GOES_DISABLED.name(),
+ MSG.view_alert_definition_condition_editor_operator_availability_goesDisabled());
+ avails.put(AlertConditionOperator.AVAIL_GOES_UNKNOWN.name(),
+ MSG.view_alert_definition_condition_editor_operator_availability_goesUnknown());
+ }
avails.put(AlertConditionOperator.AVAIL_GOES_NOT_UP.name(),
MSG.view_alert_definition_condition_editor_operator_availability_goesNotUp());
avails.put(AlertConditionOperator.AVAIL_GOES_UP.name(),
commit 1fb0b4a36e7c66607dea51cc539511352702ed3f
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Jun 22 17:21:57 2012 -0400
delete the itest AS7 home dir before, as well as after, the itests run
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index 16eb982..a640c0541 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -305,9 +305,9 @@
location="${java.io.tmpdir}/jboss-${as7.product}-${as7.version}.zip"/>
<get src="${as7.url}" dest="${as7.zipfile}" usetimestamp="true" verbose="true"/>
<unzip src="${as7.zipfile}" dest="${java.io.tmpdir}"/>
+ <delete dir="${jboss7.home}" verbose="true"/>
<move file="${java.io.tmpdir}/jboss-eap-6.0"
- tofile="${java.io.tmpdir}/jboss-as-${as7.version}" failonerror="false"
- overwrite="false"/>
+ tofile="${jboss7.home}" failonerror="false"/>
<chmod perm="u+rx">
<fileset dir="${jboss7.home}/bin" includes="*.sh"/>
@@ -332,7 +332,7 @@
</goals>
<configuration>
<target>
- <delete dir="${jboss7.home}"/>
+ <delete dir="${jboss7.home}" verbose="true"/>
</target>
</configuration>
</execution>
commit d6eef33569e9285f488f047c30017c03215e85c6
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jun 22 17:19:59 2012 -0400
Another attempt at fixing this test failure. It's hard to fix linux failures on win :)
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/FilterFileVisitorTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/FilterFileVisitorTest.java
index 8d31a82..d6812ba 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/FilterFileVisitorTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/FilterFileVisitorTest.java
@@ -89,7 +89,8 @@ public class FilterFileVisitorTest {
// This call normalizes the basedir.
Set<File> dirs = DriftDetector.getScanDirectories(basedir, includes);
Assert.assertEquals(dirs.size(), 1, "Should just be the basedir");
- forEachFile(dirs.iterator().next(), new FilterFileVisitor(basedir, includes, excludes, visitor));
+ File normalizedBaseDir = dirs.iterator().next();
+ forEachFile(normalizedBaseDir, new FilterFileVisitor(normalizedBaseDir, includes, excludes, visitor));
assertCollectionEqualsNoOrder(asList(fooJar, gooJar, myapp), visitor.visitedFiles,
"Filtering failed with multiple includes and no excludes");
commit 2fb2a5092243c7a6b1448474106df8e1c2c023e3
Merge: cd526ab 2c5974f
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Jun 22 13:54:31 2012 -0700
Merge from master
commit 2c5974fbda6a05ab0d7d233c190740d45df067d5
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jun 22 16:09:36 2012 -0400
[830463 - Re-enabling (actually, updating) an alert definition clears condition logs for existing alerts]
Some follow-on work. Add optimization such that if conditions are not being
updated we don't detach the AlertCondition from the def, since they are
unchanged.
- Add related unit testing
- re-enable the tests in AlertConditionTest, which pass but for some
reason were not enabled.
- Fix a few parameter names that I missed updating last time.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index 397e254..71ca46c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -62,7 +62,7 @@ import org.rhq.core.domain.resource.group.ResourceGroup;
* @author Joseph Marques
*/
@Entity
-@NamedQueries( { //
+@NamedQueries({ //
@NamedQuery(name = AlertDefinition.QUERY_FIND_ALL, query = "" //
+ "SELECT a " //
+ " FROM AlertDefinition a " //
@@ -409,6 +409,16 @@ public class AlertDefinition implements Serializable {
}
public void update(AlertDefinition alertDef) {
+ update(alertDef, true);
+ }
+
+ /**
+ * @param alertDef
+ * @param updateConditions set to true if conditions are being updated. This incurs overhead because the
+ * old AlertConditions get detached and replaced for no good reason, becoming a cleanup burden later on. Only
+ * set to false if you are sure the conditions are not being updated. If false the conditions will not be updated.
+ */
+ public void update(AlertDefinition alertDef, boolean updateConditions) {
/*
* Don't copy the id, ctime, or mtime.
*/
@@ -440,15 +450,17 @@ public class AlertDefinition implements Serializable {
this.recoveryId = alertDef.recoveryId;
- // copy conditions
- List<AlertCondition> copiedConditions = new ArrayList<AlertCondition>();
- for (AlertCondition oldCondition : alertDef.getConditions()) {
- AlertCondition newCondition = new AlertCondition(oldCondition);
- newCondition.setAlertDefinition(this);
- copiedConditions.add(newCondition);
+ // copy conditions if necessary
+ if (updateConditions) {
+ List<AlertCondition> copiedConditions = new ArrayList<AlertCondition>();
+ for (AlertCondition oldCondition : alertDef.getConditions()) {
+ AlertCondition newCondition = new AlertCondition(oldCondition);
+ newCondition.setAlertDefinition(this);
+ copiedConditions.add(newCondition);
+ }
+ this.removeAllConditions();
+ this.getConditions().addAll(copiedConditions);
}
- this.removeAllConditions();
- this.getConditions().addAll(copiedConditions);
// copy notifications
List<AlertNotification> copiedNotifications = new ArrayList<AlertNotification>();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
index 987e62f..0c710b4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
@@ -206,7 +206,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- protected void commitAlertDefinition(final AlertDefinition alertDefinition, boolean purgeInternals) {
+ protected void commitAlertDefinition(final AlertDefinition alertDefinition, boolean resetMatching) {
if (alertDefinition.getId() == 0) {
GWTServiceLookup.getAlertTemplateService().createAlertTemplate(alertDefinition,
Integer.valueOf(this.resourceType.getId()), new AsyncCallback<Integer>() {
@@ -224,7 +224,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
});
} else {
- GWTServiceLookup.getAlertTemplateService().updateAlertTemplate(alertDefinition, purgeInternals,
+ GWTServiceLookup.getAlertTemplateService().updateAlertTemplate(alertDefinition, resetMatching,
new AsyncCallback<AlertDefinition>() {
@Override
public void onSuccess(AlertDefinition result) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertTemplateGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertTemplateGWTService.java
index e9af2cc..0a7f27b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertTemplateGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertTemplateGWTService.java
@@ -30,11 +30,11 @@ public interface AlertTemplateGWTService extends RemoteService {
* Updates a alert template definition.
*
* @param alertDefinition
- * @param purgeInternals must be true if you are updating conditions or dampening settings, can be false otherwise
+ * @param resetMatching must be true if you are updating conditions, condition expression, or dampening settings, can be false otherwise
* @return the updated definition
* @throws Exception
*/
- AlertDefinition updateAlertTemplate(AlertDefinition alertDefinition, boolean purgeInternals)
+ AlertDefinition updateAlertTemplate(AlertDefinition alertDefinition, boolean resetMatching)
throws RuntimeException;
void enableAlertTemplates(Integer[] alertDefinitionIds) throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java
index ceddfa7..7e1fd44 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java
@@ -41,11 +41,11 @@ public class AlertTemplateGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
@Override
- public AlertDefinition updateAlertTemplate(AlertDefinition alertDefinition, boolean purgeInternals)
+ public AlertDefinition updateAlertTemplate(AlertDefinition alertDefinition, boolean resetMatching)
throws RuntimeException {
try {
AlertDefinition results = alertTemplateManager.updateAlertTemplate(getSessionSubject(), alertDefinition,
- purgeInternals);
+ resetMatching);
return SerialUtility.prepare(results, "AlertTemplateService.updateAlertTemplate");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
index 5da131e..c4fdcda 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
@@ -60,8 +60,8 @@ import org.rhq.enterprise.server.cloud.StatusManagerLocal;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSender;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
-import org.rhq.enterprise.server.util.CriteriaQueryRunner;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator.AuthorizationTokenType;
+import org.rhq.enterprise.server.util.CriteriaQueryRunner;
/**
* @author Joseph Marques
@@ -519,7 +519,7 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
alertDefinition.setConditionExpression(BooleanExpression.ANY);
}
- oldAlertDefinition.update(alertDefinition);
+ oldAlertDefinition.update(alertDefinition, resetMatching);
if (LOG.isDebugEnabled()) {
LOG.debug("Updating: " + oldAlertDefinition);
for (AlertCondition nextCondition : oldAlertDefinition.getConditions()) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java
index 94f1d35..5b4ad77 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java
@@ -231,7 +231,7 @@ public class AlertTemplateManagerBean implements AlertTemplateManagerLocal {
@RequiredPermission(Permission.MANAGE_SETTINGS)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
- public AlertDefinition updateAlertTemplate(Subject user, AlertDefinition alertTemplate, boolean purgeInternals)
+ public AlertDefinition updateAlertTemplate(Subject user, AlertDefinition alertTemplate, boolean resetMatching)
throws InvalidAlertDefinitionException, AlertDefinitionUpdateException, AlertNotificationValidationException {
if (LOG.isDebugEnabled()) {
LOG.debug("updateAlertTemplate: " + alertTemplate);
@@ -241,7 +241,7 @@ public class AlertTemplateManagerBean implements AlertTemplateManagerLocal {
AlertDefinition updated = null;
try {
updated = alertDefinitionManager.updateAlertDefinition(user, alertTemplate.getId(), alertTemplate,
- purgeInternals); // do not allow direct undeletes of an alert definition
+ resetMatching); // do not allow direct undeletes of an alert definition
} catch (Throwable t) {
throw new AlertDefinitionUpdateException("Failed to update an AlertTemplate "
+ alertTemplate.toSimpleString(), t);
@@ -260,7 +260,7 @@ public class AlertTemplateManagerBean implements AlertTemplateManagerLocal {
for (Integer alertDefinitionId : alertDefinitions) {
try {
alertDefinitionManager
- .updateAlertDefinition(overlord, alertDefinitionId, alertTemplate, purgeInternals);
+ .updateAlertDefinition(overlord, alertDefinitionId, alertTemplate, resetMatching);
} catch (Throwable t) {
// continue on error, update as many as possible
if (firstThrowable == null) {
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertConditionTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertConditionTest.java
index 645d049..47ba274 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertConditionTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertConditionTest.java
@@ -20,12 +20,14 @@
package org.rhq.enterprise.server.alert.test;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.transaction.TransactionManager;
+import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
@@ -70,7 +72,7 @@ import org.rhq.test.TransactionCallbackWithContext;
@Test
public class AlertConditionTest extends UpdatePluginMetadataTestBase {
- private static final boolean ENABLED = false;
+ private static final boolean ENABLED = true;
// this must match the constant found in ServerManagerBean
private static final String RHQ_SERVER_NAME_PROPERTY = "rhq.server.high-availability.name";
@@ -343,10 +345,84 @@ public class AlertConditionTest extends UpdatePluginMetadataTestBase {
}
}
+ @Test(enabled = ENABLED)
+ public void testBZ830463_updateDef() throws Exception {
+ // create our resource with alert definition
+ MeasurementDefinition metricDef = createResourceWithMetricSchedule();
+ AlertDefinition alertDef = createAlertDefinitionWithOneInsideRangeCondition(metricDef, resource.getId());
+
+ assert alertDef.getConditions().size() == 1 : "1 alertDef condition should exist";
+ AlertCondition condition = alertDef.getConditions().iterator().next();
+ int conditionId = condition.getId();
+
+ // re-load the resource so we get the measurement schedule
+ Resource resourceWithSchedules = loadResourceWithSchedules(resource.getId());
+ MeasurementSchedule schedule = resourceWithSchedules.getSchedules().iterator().next();
+
+ // simulate a measurement report coming from the agent - one values that fits in our range, so 1 alert is fired
+ MeasurementScheduleRequest request = new MeasurementScheduleRequest(schedule);
+ MeasurementReport report = new MeasurementReport();
+ report.addData(new MeasurementDataNumeric(getTimestamp(15), request, Double.valueOf(50.0))); // 50 < 60 AND 50 > 40
+ MeasurementDataManagerLocal dataManager = LookupUtil.getMeasurementDataManager();
+ dataManager.mergeMeasurementReport(report);
+
+ // wait for our JMS messages to process and see if we get any alerts
+ Thread.sleep(5000);
+
+ // make sure one alert was triggered
+ List<Alert> alerts = getAlerts(resourceWithSchedules.getId());
+ assert alerts.size() == 1 : "1 alert should have fired: " + alerts;
+ Alert alert = alerts.get(0);
+
+ assert alert.getConditionLogs().size() == 1 : "1 condition log should exist";
+ AlertConditionLog conditionLog = alert.getConditionLogs().iterator().next();
+ Assert.assertEquals(conditionLog.getCondition().getId(), conditionId,
+ "original condition should have been associated with the alert");
+
+ // update a non-condition aspect of the def and then update the def
+ String updatedDesc = "Updated Description";
+ alertDef.setDescription(updatedDesc);
+ AlertDefinition updatedAlertDef = LookupUtil.getAlertDefinitionManager().updateAlertDefinition(getOverlord(),
+ alertDef.getId(), alertDef, false); // note that resetMatching is false
+ assert updatedDesc.equals(updatedAlertDef.getDescription()) : "Description should be updated";
+ assert updatedAlertDef.getConditions().size() == 1 : "1 alertDef condition should exist after the update";
+ assert updatedAlertDef.getConditions().iterator().next().getId() == condition.getId() : "condition should not be updated";
+
+ // get the alert again, and make sure it still has a log with the same condition
+ alerts = getAlerts(resourceWithSchedules.getId());
+ assert alerts.size() == 1 : "1 alert should have fired: " + alerts;
+ alert = alerts.get(0);
+
+ assert alert.getConditionLogs().size() == 1 : "1 condition log should exist after the update";
+ conditionLog = alert.getConditionLogs().iterator().next();
+ Assert.assertEquals(conditionLog.getCondition().getId(), conditionId,
+ "original condition should still have been associated with the alert");
+
+ // update the condition on the def and then update the def
+ condition.setThreshold(Double.valueOf(41.0));
+ updatedAlertDef = LookupUtil.getAlertDefinitionManager().updateAlertDefinition(getOverlord(), alertDef.getId(),
+ alertDef, true); // note that resetMatching is true
+ assert updatedAlertDef.getConditions().size() == 1 : "1 alertDef condition should exist after the update";
+ assert updatedAlertDef.getConditions().iterator().next().getId() != condition.getId() : "condition should be updated";
+
+ // get the alert again, and make sure it still has a log with the same condition
+ alerts = getAlerts(resourceWithSchedules.getId());
+ assert alerts.size() == 1 : "1 alert should have fired: " + alerts;
+ alert = alerts.get(0);
+
+ assert alert.getConditionLogs().size() == 1 : "1 condition log should exist after the update";
+ conditionLog = alert.getConditionLogs().iterator().next();
+ Assert.assertEquals(conditionLog.getCondition().getId(), conditionId,
+ "original condition should still have been associated with the alert");
+
+ return;
+ }
+
private PageList<Alert> getAlerts(int resourceId) {
AlertManagerLocal alertManager = LookupUtil.getAlertManager();
AlertCriteria alertCriteria = new AlertCriteria();
alertCriteria.addFilterResourceIds(resourceId);
+ alertCriteria.fetchConditionLogs(true);
PageList<Alert> alerts = alertManager.findAlertsByCriteria(getOverlord(), alertCriteria);
return alerts;
}
commit bcfdd405b76502e63573c0806e821ba900a205dc
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Jun 22 11:31:55 2012 -0700
[BZ 825230] Eliminate some of the space in the layout between the resource measurement sparkline graphs and the resource name link.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
index 8fb8f80..c27e626 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
@@ -240,16 +240,15 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet {
LocatableDynamicForm row = new LocatableDynamicForm(
recentMeasurementsContent.extendLocatorId(md.getName()));
row.setNumCols(3);
+ row.setColWidths(65,"*","*");
row.setWidth100();
HTMLFlow graph = new HTMLFlow();
- // String contents = "<span id='sparkline_" + index + "' class='dynamicsparkline' width='0'>"
- // + commaDelimitedList + "</span>";
String contents = "<span id='sparkline_" + index
+ "' class='dynamicsparkline' width='0' " + "values='"
+ commaDelimitedList + "'>...</span>";
graph.setContents(contents);
graph.setContentsType(ContentsType.PAGE);
- //diable scrollbars on span
+ //disable scrollbars on span
graph.setScrollbarSize(0);
CanvasItem graphContainer = new CanvasItem();
commit 93eafb3a0f72c469935a1d35da310826b9037eb5
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Jun 22 14:08:09 2012 -0400
Revert " Adding ability to disable deletion of as7 artifacts after an integration test run. Ex. -Ditest.deleteRoot=false" This is not consistently working.
This reverts commit 37ba7b7ad179000571944b602a2cf6d0993632f2.
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index 7230b59..16eb982 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -331,22 +331,10 @@
<goal>run</goal>
</goals>
<configuration>
- <tasks>
- <taskdef resource="net/sf/antcontrib/antcontrib.properties"
- classpathref="maven.plugin.classpath" />
- <if>
- <equals arg1="${itest.deleteRoot}" arg2="false" />
- <then>
- <echo message="*** By request not deleting the AS7 instances after 'integration-test' run." />
- </then>
- <else>
<target>
<delete dir="${jboss7.home}"/>
</target>
- </else>
- </if>
- </tasks>
- </configuration>
+ </configuration>
</execution>
</executions>
</plugin>
commit 5f8827fef9f40546edae97fc2747bd6f1cbf75df
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Jun 22 09:51:49 2012 -0700
[BZ 825230] Some measure names are not readable in JON EPP plugin. This is actually a global layout issue in the resource measurements portlet.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
index a625edf..8fb8f80 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
@@ -100,6 +100,7 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet {
//display container
final VLayout column = new VLayout();
column.setHeight(10);//pack
+ column.setWidth100();
//initialize to defaults
end = System.currentTimeMillis();
@@ -267,6 +268,7 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet {
destination);
link.setTitleVAlign(VerticalAlignment.TOP);
link.setAlign(Alignment.LEFT);
+ link.setClipValue(false);
link.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
@@ -291,6 +293,7 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet {
value.setVAlign(VerticalAlignment.TOP);
row.setItems(graphContainer, link, value);
+ row.setWidth100();
//if graph content returned
if ((md.getName().trim().indexOf("Trait.") == -1)
commit e27fe0d95627f061e9c9c9253d656f20662234cf
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jun 22 12:01:04 2012 -0400
Fix test that was failingon Linux because it wasn't properly normalizing
the include filter's basedir path. This was a test-only problem and does
not affect production code.
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 1c9e50c..92042e7 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
@@ -404,7 +404,8 @@ public class DriftDetector implements Runnable {
}
}
- private Set<File> getScanDirectories(final File basedir, List<Filter> includes) {
+ // package-private for test accessibility
+ static Set<File> getScanDirectories(final File basedir, List<Filter> includes) {
Set<File> directories = new HashSet<File>();
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/FilterFileVisitorTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/FilterFileVisitorTest.java
index a654607..8d31a82 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/FilterFileVisitorTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/FilterFileVisitorTest.java
@@ -31,8 +31,10 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import org.apache.commons.io.FileUtils;
+import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -71,6 +73,7 @@ public class FilterFileVisitorTest {
visitor.visitedFiles, "Visitor should be called for every file when no filters specified");
}
+ // This could be a DriftDetectorTest but fits well here.
@Test
public void visitBaseDirFilesThatMatchFilters() throws Exception {
File fooJar = touch(basedir, "foo.jar");
@@ -78,11 +81,15 @@ public class FilterFileVisitorTest {
File myapp = touch(basedir, "myapp.war");
touch(basedir, "bar.jar");
+ // These filter paths should all normalize to the same directory
List<Filter> includes = asList(new Filter(".", "foo*"), new Filter("./", "*.war"), new Filter("/", "goo*"));
List<Filter> excludes = emptyList();
TestVisitor visitor = new TestVisitor();
- forEachFile(basedir, new FilterFileVisitor(basedir, includes, excludes, visitor));
+ // This call normalizes the basedir.
+ Set<File> dirs = DriftDetector.getScanDirectories(basedir, includes);
+ Assert.assertEquals(dirs.size(), 1, "Should just be the basedir");
+ forEachFile(dirs.iterator().next(), new FilterFileVisitor(basedir, includes, excludes, visitor));
assertCollectionEqualsNoOrder(asList(fooJar, gooJar, myapp), visitor.visitedFiles,
"Filtering failed with multiple includes and no excludes");
commit b5ab75a28ec1a0bd62b914de1e52869f1bf6a9f1
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Jun 22 11:41:22 2012 -0400
get the as5 plugin descriptor generator compiling again
diff --git a/modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml b/modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml
index 965002a..dbeec8f 100644
--- a/modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml
+++ b/modules/jopr/tools/jbas5-plugin-descriptor-gen/pom.xml
@@ -9,7 +9,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.3.0-SNAPSHOT</version>
+ <version>4.5.0-SNAPSHOT</version>
<relativePath>../../../../pom.xml</relativePath>
</parent>
@@ -313,43 +313,33 @@ t section. -->
<build>
<plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- </configuration>
- </plugin>
<plugin>
- <artifactId>maven-dependency-plugin</artifactId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ <archive>
+ <manifest>
+ <mainClass>org.jboss.jopr.tool.jbas5.PluginDescriptorGenerator</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
<executions>
<execution>
- <id>copy-dependencies</id>
+ <id>make-assembly</id>
+ <!-- this is used for inheritance merges -->
<phase>package</phase>
+ <!-- bind to the packaging phase -->
<goals>
- <goal>copy-dependencies</goal>
+ <goal>single</goal>
</goals>
- <configuration>
- <includeScope>runtime</includeScope>
- <excludeTransitive>true</excludeTransitive>
- <outputDirectory>target/lib</outputDirectory>
- </configuration>
</execution>
</executions>
</plugin>
-
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <mainClass>org.jboss.jopr.tool.jbas5.PluginDescriptorGenerator</mainClass>
- <addClasspath>true</addClasspath>
- <classpathPrefix>lib</classpathPrefix>
- </manifest>
- </archive>
- </configuration>
- </plugin>
+
</plugins>
</build>
diff --git a/modules/jopr/tools/jbas5-plugin-descriptor-gen/src/main/java/org/jboss/jopr/tool/jbas5/PluginDescriptorGenerator.java b/modules/jopr/tools/jbas5-plugin-descriptor-gen/src/main/java/org/jboss/jopr/tool/jbas5/PluginDescriptorGenerator.java
index 5019fea..31de2a8 100644
--- a/modules/jopr/tools/jbas5-plugin-descriptor-gen/src/main/java/org/jboss/jopr/tool/jbas5/PluginDescriptorGenerator.java
+++ b/modules/jopr/tools/jbas5-plugin-descriptor-gen/src/main/java/org/jboss/jopr/tool/jbas5/PluginDescriptorGenerator.java
@@ -26,6 +26,8 @@ import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
+import java.lang.String;
+import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -232,7 +234,7 @@ public class PluginDescriptorGenerator
if (metricDef.getCategory() != null)
metricDescriptor.setCategory(metricDef.getCategory().name().toLowerCase());
metricDescriptor.setDataType(metricDef.getDataType().name().toLowerCase());
- metricDescriptor.setDefaultInterval((int)metricDef.getDefaultInterval());
+ metricDescriptor.setDefaultInterval(new BigInteger(String.valueOf(metricDef.getDefaultInterval())));
metricDescriptor.setDefaultOn(metricDef.isDefaultOn());
metricDescriptor.setDescription(metricDef.getDescription());
metricDescriptor.setDestinationType(metricDef.getDestinationType());
@@ -312,7 +314,7 @@ public class PluginDescriptorGenerator
{
PropertyDefinitionMap propDefMap = (PropertyDefinitionMap)propDef;
MapProperty mapProp = new MapProperty();
- for (PropertyDefinition itemPropDef : propDefMap.getPropertyDefinitions().values())
+ for (PropertyDefinition itemPropDef : propDefMap.getPropertyDefinitions())
{
ConfigurationProperty itemConfigProp = convertPropertyDefinitionToConfigurationProperty(itemPropDef);
JAXBElement propElement = getJAXBElement(itemConfigProp);
commit 6b1069c1b97337b69b3e9951e4b6df7a2c692646
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri Jun 22 15:23:24 2012 +0200
[BZ 815421 - Discovery Q: even with no entry, "select all" is active] If there are no enties, "select all" button is disabled
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
index 0e473a7..a7f20c0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
@@ -18,17 +18,18 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.types.Autofit;
import com.smartgwt.client.types.SelectionAppearance;
-import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.util.BooleanCallback;
import com.smartgwt.client.util.SC;
-import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.IButton;
-import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -40,17 +41,16 @@ import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
import com.smartgwt.client.widgets.grid.events.SelectionEvent;
-import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeGridField;
import com.smartgwt.client.widgets.tree.TreeNode;
+
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.IconEnum;
import org.rhq.enterprise.gui.coregui.client.RefreshableView;
-import org.rhq.enterprise.gui.coregui.client.components.TitleBar;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.view.HasViewName;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
@@ -63,10 +63,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.List;
-
/**
* @author Greg Hinkle
*/
@@ -372,7 +368,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout implements Refre
private void updateButtonEnablement(IButton selectAllButton, IButton deselectAllButton, IButton importButton,
IButton ignoreButton, IButton unignoreButton) {
if (treeGrid.getSelectedRecords().length == 0) {
- selectAllButton.setDisabled(false);
+ selectAllButton.setDisabled(treeGrid.getRecords().length == 0);
deselectAllButton.setDisabled(true);
importButton.setDisabled(true);
ignoreButton.setDisabled(true);
commit 7b77b38e5bdaa2b87f05be70bea8c1cdb08d14d8
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Jun 22 08:46:14 2012 -0400
[BZ 826542] add a few tests to exercise crud of Security Domain and some of Module Option framework.
- only added one of this type as discovery needs to complete in between creates and slows down process significantly.
- we need to come up with another way of prepopulating the other SecurityDomain types before full discovery.
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/SecurityModuleOptionsTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/SecurityModuleOptionsTest.java
deleted file mode 100644
index e80ddec..0000000
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/SecurityModuleOptionsTest.java
+++ /dev/null
@@ -1,319 +0,0 @@
-///*
-// * 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 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.modules.plugins.jbossas7;
-//
-//import java.io.IOException;
-//import java.util.ArrayList;
-//import java.util.HashMap;
-//import java.util.LinkedHashMap;
-//import java.util.List;
-//
-//import org.codehaus.jackson.JsonGenerationException;
-//import org.codehaus.jackson.JsonNode;
-//import org.codehaus.jackson.JsonProcessingException;
-//import org.codehaus.jackson.map.JsonMappingException;
-//import org.codehaus.jackson.map.ObjectMapper;
-//import org.codehaus.jackson.map.SerializationConfig;
-//import org.testng.annotations.BeforeSuite;
-//import org.testng.annotations.Test;
-//
-//import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent.ModuleOptionType;
-//import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent.Value;
-//import org.rhq.modules.plugins.jbossas7.json.Address;
-//import org.rhq.modules.plugins.jbossas7.json.Operation;
-//import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
-//import org.rhq.modules.plugins.jbossas7.json.Remove;
-//import org.rhq.modules.plugins.jbossas7.json.Result;
-//import org.rhq.modules.plugins.jbossas7.json.WriteAttribute;
-//
-///**
-// * Test exercising the subsystem=security/SecurityDomain/[Authentication, Authorization, Mapping, Audit, Acl,
-// * Identity-Trust]
-// * @author Simeon Pinder
-// */
-//@Test(groups = "unit")
-//public class SecurityModuleOptionsTest extends AbstractConfigurationHandlingTest {
-//
-// private static String user = "rhqadmin";
-// private static String pass = "as7";
-// private static String host = "localhost";
-// private static ASConnection con = null;
-// private static ObjectMapper mapper = null;
-// private ModuleOptionsComponent moc = null;
-//
-// //Define some shared and reusable content
-// static HashMap<String, String> jsonMap = new HashMap<String, String>();
-// static {
-// jsonMap
-// .put(
-// "login-modules",
-// "[{\"flag\":\"required\", \"code\":\"Ldap\", \"module-options\":{\"bindDn\":\"uid=ldapSecureUser,ou=People,dc=redat,dc=com\", \"bindPw\":\"test126\", \"allowEmptyPasswords\":\"true\"}}]");
-// // "[{\"flag\":\"required\", \"code\":\"Ldap\"}]");
-// jsonMap
-// .put(
-// "policy-modules",
-// "[{\"flag\":\"requisite\", \"code\":\"LdapExtended\", \"module-options\":{\"policy\":\"module\", \"policy1\":\"module1\"}}]");
-// jsonMap
-// .put("mapping-modules",
-// "[{\"code\":\"Test\", \"type\":\"attribute\", \"module-options\":{\"mapping\":\"module\", \"mapping1\":\"module1\"}}]");
-// jsonMap.put("provider-modules",
-// "[{\"code\":\"Providers\", \"module-options\":{\"provider\":\"module\", \"provider1\":\"module1\"}}]");
-// }
-//
-// @BeforeSuite
-// private void initializeConnectionDetails() {
-// con = new ASConnection(host, 9990, user, pass);
-// mapper = new ObjectMapper();
-// mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
-//
-// moc = new ModuleOptionsComponent();
-// }
-//
-// public static void main(String[] args) {
-// SecurityModuleOptionsTest test = new SecurityModuleOptionsTest();
-// try {
-// test.initializeConnectionDetails();
-// test.testPopulateModuleOptionsAndTypes();
-// } catch (Exception e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-//
-// }
-//
-// /**The test reads the existing property values, deserializes them and writes the same
-// * contents back out to a running instance for all known ModuleOptionTypes.
-// *
-// * @throws Exception
-// */
-// public void testPopulateModuleOptionsAndTypes() throws Exception {
-//
-// //as7 node details.
-// String securityDomainId = "testDomain";
-// //TODO: spinder 6-6-12: this cannot run as a standalone itest until JIRA https://issues.jboss.org/browse/AS7-4951
-// // is addressed as there is no way to automate setup of the information being tested.
-// String address = "subsystem=security,security-domain=" + securityDomainId + ",authentication=classic";
-// boolean verboseOutput = true;
-// boolean executeOperation = true;
-// for (ModuleOptionType t : ModuleOptionType.values()) {
-// String attribute = t.getAttribute();
-// if (verboseOutput) {
-// System.out.println("======= Running with ModuleOptionType:" + t + " attribute:" + attribute + ":");
-// }
-// if (attribute.equals("policy-modules")) {
-// address = "subsystem=security,security-domain=" + securityDomainId + ",authorization=classic";
-// } else if (attribute.equals("acl-modules")) {
-// address = "subsystem=security,security-domain=" + securityDomainId + ",acl=classic";
-// } else if (attribute.equals("mapping-modules")) {
-// address = "subsystem=security,security-domain=" + securityDomainId + ",mapping=classic";
-// } else if (attribute.equals("trust-modules")) {
-// address = "subsystem=security,security-domain=" + securityDomainId + ",identity-trust=classic";
-// } else if (attribute.equals("provider-modules")) {
-// address = "subsystem=security,security-domain=" + securityDomainId + ",audit=classic";
-// } else if (attribute.equals("login-modules")) {
-// address = "subsystem=security,security-domain=" + securityDomainId + ",authentication=classic";
-// } else {
-// assert false : "An unknown attribute '" + attribute
-// + "' was found. Is there a new type to be supported?";
-// }
-//
-// //test operation- read property always available.
-// Operation op = null;
-//
-// //read the login-modules attribute
-// op = new ReadAttribute(new Address(address), attribute);
-// Result result = exerciseOperation(op, true, verboseOutput);
-// assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
-// + result.getFailureDescription();
-// //extract current results
-// Object rawResult = result.getResult();
-// assert rawResult != null : "Read of attribute'" + attribute + "' from address '" + address
-// + "' has returned no value. Are those values in the model?";
-//
-// List<Value> list2 = new ArrayList<Value>();
-// //populate the Value component complete with module Options.
-// list2 = moc.populateSecurityDomainModuleOptions(result,
-// ModuleOptionsComponent.loadModuleOptionType(attribute));
-// if (verboseOutput) {
-// if (rawResult != null) {
-// System.out.println("Raw Result is:" + rawResult + " and of type:" + rawResult.getClass());
-// } else {
-// System.out.println("Read of attribute'" + attribute + "' from address '" + address
-// + "' has returned no value. Are those values in the model?");
-// }
-// }
-// //write the login-modules attribute
-// op = new WriteAttribute(new Address(address));
-// op.addAdditionalProperty("name", attribute);//attribute to execute on
-// op.addAdditionalProperty("value", list2);
-//
-// //Now test the operation
-// result = exerciseOperation(op, executeOperation, verboseOutput);
-// assert ((result.isSuccess() == true) || (result.getOutcome() == null)) : "The operation '" + op
-// + "' failed to write the resource.." + result.getFailureDescription();
-//
-// //read the login-modules attribute
-// op = new ReadAttribute(new Address(address), attribute);
-// result = exerciseOperation(op, true, verboseOutput);
-// assert (result.isSuccess() == true) : "The operation '" + op + "' failed to read the resource."
-// + result.getFailureDescription();
-// }
-// if (verboseOutput) {
-// System.out.println("Successfully detected,read and wrote out attribute values for:");
-// for (ModuleOptionType type : ModuleOptionType.values()) {
-// System.out.println("\n" + type.ordinal() + " " + type.name());
-// }
-// }
-// }
-//
-// /**Attempts to create a new Authentication node(authentication=classic) with a
-// * 'login-modules' attribute complete with 'code':'Ldap' and 'flag':'required'
-// * and some sample 'module-options' values.
-// *
-// */
-// @Test(enabled = true)
-// public void testCreateSecurityDomainChildLoginModules() {
-// boolean execute = true;
-// boolean verboseOutput = false;
-// String address = "subsystem=security,security-domain=testDomain3,authentication=classic";
-// String attribute = ModuleOptionType.Authentication.getAttribute();
-//
-// //test operation- read property always available.
-// Operation op = null;
-//
-// //read the login-modules attribute
-// op = new ReadAttribute(new Address(address), attribute);
-// Result result = exerciseOperation(op, execute, verboseOutput);
-// assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
-// + result.getFailureDescription();
-//
-// //extract current results
-// Object rawResult = result.getResult();
-//
-// //#### Have to create new content for the new node.
-// List<Value> moduleTypeValue = new ArrayList<Value>();
-// try {
-// // loading 'login-module'
-// JsonNode node = mapper.readTree(jsonMap.get(attribute));
-// result.setResult(mapper.treeToValue(node, Object.class));
-// } catch (JsonProcessingException e) {
-// e.printStackTrace();
-// } catch (IOException e) {
-// e.printStackTrace();
-// }
-//
-// //populate the Value component complete with module Options.
-// moduleTypeValue = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
-// ModuleOptionsComponent.loadModuleOptionType(attribute));
-//
-// //add the login-modules attribute
-// op = ModuleOptionsComponent
-// .createAddModuleOptionTypeOperation(new Address(address), attribute, moduleTypeValue);
-//
-// result = exerciseOperation(op, execute, verboseOutput);
-// assert ((result.isSuccess() == true) || (result.getOutcome() == null)) : "The operation '" + op
-// + "' failed to write the resource.." + result.getFailureDescription();
-//
-// //read the login-modules attribute
-// op = new ReadAttribute(new Address(address), attribute);
-// result = exerciseOperation(op, execute, verboseOutput);
-// assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
-// + result.getFailureDescription();
-//
-// //exercise values retrieved from read
-// List<Value> serverResponse = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
-// ModuleOptionsComponent.loadModuleOptionType(attribute));
-// Value serverState = serverResponse.get(0);
-// assert serverState.getFlag().equals("required") : "Incorrect state retrieved for 'flag'. Expected 'required'.";
-// assert serverState.getCode().equals("Ldap") : "Incorrect state retrieved for 'code'. Expected 'Ldap'.";
-// LinkedHashMap<String, Object> options = serverState.getOptions();
-// assert options.size() == 3 : "Invalid number of module options returned. Expected 3.";
-// int found = 0;
-// for (String key : options.keySet()) {
-// if (key.equals("bindPw")) {
-// assert "test126".equals(options.get(key)) : "Module option value not correct for key '" + key + "'.";
-// found++;
-// } else if (key.equals("bindDn")) {
-// assert "uid=ldapSecureUser,ou=People,dc=redat,dc=com".equals(options.get(key)) : "Module option value not correct for key '"
-// + key + "'.";
-// found++;
-// } else if (key.equals("allowEmptyPasswords")) {
-// assert "true".equals(options.get(key)) : "Module option value not correct for key '" + key + "'.";
-// found++;
-// }
-// }
-// assert found == 3 : "All module options were not loaded.";
-//
-// //remove the original node to reset for next run.
-// op = new Remove(new Address(address));
-// result = exerciseOperation(op, execute, verboseOutput);
-// assert result.isSuccess() == true : "The operation '" + op + "' failed to remove the resource."
-// + result.getFailureDescription();
-// }
-//
-// /** For each operation
-// * - will write verbose json and operation details to system.out if verboseOutput = true;
-// * - will execute the operation against running server if execute = true.
-// *
-// * @param op
-// * @param execute
-// * @param verboseOutput
-// * @return
-// */
-// public static Result exerciseOperation(Operation op, boolean execute, boolean verboseOutput) {
-// //display operation as AS7 plugin will build it
-// if (verboseOutput) {
-// System.out.println("\tOperation is:" + op);
-// }
-//
-// String jsonToSend = "";
-// try {
-// // jsonToSend = mapper.writeValueAsString(op);
-// jsonToSend = mapper.defaultPrettyPrintingWriter().writeValueAsString(op);
-// } catch (JsonGenerationException e) {
-// e.printStackTrace();
-// } catch (JsonMappingException e) {
-// e.printStackTrace();
-// } catch (IOException e) {
-// e.printStackTrace();
-// }
-// //As generated by jackson mapper
-// if (verboseOutput) {
-// System.out.println("@@@@ OUTBOUND JSON#\n" + jsonToSend + "#");
-// }
-//
-// //Execute the operation
-// Result result = new Result();
-// if (execute) {
-// result = con.execute(op);
-// } else {
-// if (verboseOutput) {
-// System.out.println("**** NOTE: Execution disabled . NOT exercising write-attribute operation. **** ");
-// }
-// }
-// if (verboseOutput) {
-// //result wrapper details
-// System.out.println("\tResult:" + result);
-// //detailed results
-// System.out.println("\tValue:" + result.getResult());
-// System.out.println("-----------------------------------------------------\n");
-// }
-// return result;
-// }
-//}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java
new file mode 100644
index 0000000..7f9464a
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SecurityModuleOptionsTest.java
@@ -0,0 +1,525 @@
+/*
+ * 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 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.modules.plugins.jbossas7.itest.standalone;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.HashMap;
+import java.util.Set;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.testng.annotations.Test;
+
+import org.rhq.core.clientapi.agent.inventory.CreateResourceRequest;
+import org.rhq.core.clientapi.agent.inventory.CreateResourceResponse;
+import org.rhq.core.clientapi.agent.inventory.DeleteResourceRequest;
+import org.rhq.core.clientapi.agent.inventory.DeleteResourceResponse;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.domain.resource.DeleteResourceStatus;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pc.inventory.InventoryManager;
+import org.rhq.modules.plugins.jbossas7.ASConnection;
+import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent;
+import org.rhq.modules.plugins.jbossas7.itest.AbstractJBossAS7PluginTest;
+import org.rhq.test.arquillian.RunDiscovery;
+
+/**
+ * Test exercising the subsystem=security/SecurityDomain/[Authentication(Classic|Jaspi),
+ * Authorization, Mapping, Audit, Acl,
+ * Identity-Trust]
+ * @author Simeon Pinder
+ */
+@Test(groups = { "integration", "pc", "standalone" }, singleThreaded = true)
+public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
+
+ private static String user = "rhqadmin";
+ private static String pass = "as7";
+ private static String host = "localhost";
+ private static ASConnection con = null;
+ private static ObjectMapper mapper = null;
+ private ModuleOptionsComponent moc = null;
+
+ private static String TEST_DOMAIN = "testDomain";
+ private static Resource securityResource = null;
+ private static String SECURITY_RESOURCE_TYPE = "Security";
+ private static String SECURITY_RESOURCE_KEY = "subsystem=security";
+ private static String SECURITY_DOMAIN_RESOURCE_TYPE = "Security Domain";
+ private static String SECURITY_DOMAIN_RESOURCE_KEY = "security-domain";
+ private static String AUTH_CLASSIC_RESOURCE_TYPE = "Authentication (Classic)";
+ private static String AUTH_CLASSIC_RESOURCE_KEY = "authentication=classic";
+
+ protected static final String DC_HOST = System.getProperty("jboss.domain.bindAddress");
+ protected static final int DC_HTTP_PORT = Integer.valueOf(System.getProperty("jboss.domain.httpManagementPort"));
+ protected static final String DC_USER = AbstractJBossAS7PluginTest.MANAGEMENT_USERNAME;
+ protected static final String DC_PASS = AbstractJBossAS7PluginTest.MANAGEMENT_PASSWORD;
+
+ ASConnection getASConnection() {
+ ASConnection connection = new ASConnection(DC_HOST, DC_HTTP_PORT, DC_USER, DC_PASS);
+ return connection;
+ }
+
+ public static final ResourceType RESOURCE_TYPE = new ResourceType(SECURITY_RESOURCE_TYPE, PLUGIN_NAME,
+ ResourceCategory.SERVICE, null);
+ private static final String RESOURCE_KEY = SECURITY_RESOURCE_KEY;
+
+ //Define some shared and reusable content
+ static HashMap<String, String> jsonMap = new HashMap<String, String>();
+ static {
+ jsonMap
+ .put(
+ "login-modules",
+ "[{\"flag\":\"required\", \"code\":\"Ldap\", \"module-options\":{\"bindDn\":\"uid=ldapSecureUser,ou=People,dc=redat,dc=com\", \"bindPw\":\"test126\", \"allowEmptyPasswords\":\"true\"}}]");
+ jsonMap
+ .put(
+ "policy-modules",
+ "[{\"flag\":\"requisite\", \"code\":\"LdapExtended\", \"module-options\":{\"policy\":\"module\", \"policy1\":\"module1\"}}]");
+ jsonMap
+ .put("mapping-modules",
+ "[{\"code\":\"Test\", \"type\":\"attribute\", \"module-options\":{\"mapping\":\"module\", \"mapping1\":\"module1\"}}]");
+ jsonMap.put("provider-modules",
+ "[{\"code\":\"Providers\", \"module-options\":{\"provider\":\"module\", \"provider1\":\"module1\"}}]");
+ }
+
+ @Test(priority = 10, groups = "discovery")
+ @RunDiscovery(discoverServices = true, discoverServers = true)
+ public void initialDiscovery() throws Exception {
+ Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
+ assertNotNull(platform);
+ assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
+
+ Thread.sleep(20 * 1000L); // delay so that PC gets a chance to scan for resources
+ }
+
+ @Test(priority = 12)
+ public void testCreateSecurityDomain() throws Exception {
+ //get the root security resource
+ securityResource = getResource();
+
+ //plugin config
+ Configuration createPlugConfig = new Configuration();
+ createPlugConfig.put(new PropertySimple("path", SECURITY_DOMAIN_RESOURCE_KEY += "=" + TEST_DOMAIN));
+
+ //resource config
+ Configuration createResConfig = new Configuration();
+ createResConfig.put(new PropertySimple("name", TEST_DOMAIN));
+
+ CreateResourceRequest request = new CreateResourceRequest();
+ request.setParentResourceId(securityResource.getId());
+ request.setPluginConfiguration(createPlugConfig);
+ request.setPluginName(PLUGIN_NAME);
+ request.setResourceConfiguration(createResConfig);
+ request.setResourceName(TEST_DOMAIN);
+ request.setResourceTypeName(SECURITY_DOMAIN_RESOURCE_TYPE);
+
+ CreateResourceResponse response = pluginContainer.getResourceFactoryManager().executeCreateResourceImmediately(
+ request);
+
+ assert response.getStatus() == CreateResourceStatus.SUCCESS : "The Security Domain creation failed with an error mesasge: "
+ + response.getErrorMessage();
+ }
+
+ @Test(priority = 13)
+ public void testAuthenticationClassic() throws Exception {
+ //get the root security resource
+ securityResource = getResource();
+
+ //find TEST_DOMAIN 'security-domain'
+ Resource securityDomain = null;
+ Set<Resource> childResources = securityResource.getChildResources();
+ for (Resource r : childResources) {
+ if (r.getName().indexOf(TEST_DOMAIN) > -1) {
+ securityDomain = r;
+ }
+ }
+
+ //plugin config
+ Configuration createPlugConfig = new Configuration();
+ createPlugConfig.put(new PropertySimple("path", AUTH_CLASSIC_RESOURCE_KEY));
+
+ //resource config
+ Configuration createResConfig = new Configuration();
+ createResConfig.put(new PropertySimple("code", "Ldap"));
+ createResConfig.put(new PropertySimple("flag", "requisite"));
+
+ CreateResourceRequest request = new CreateResourceRequest();
+ request.setParentResourceId(securityDomain.getId());
+ request.setPluginConfiguration(createPlugConfig);
+ request.setPluginName(PLUGIN_NAME);
+ request.setResourceConfiguration(createResConfig);
+ request.setResourceName("Test - notUsed.");
+
+ request.setResourceTypeName(AUTH_CLASSIC_RESOURCE_TYPE);
+
+ CreateResourceResponse response = pluginContainer.getResourceFactoryManager().executeCreateResourceImmediately(
+ request);
+
+ assert response.getStatus() == CreateResourceStatus.SUCCESS : "The 'Authentication (Classic)' node creation failed with an error mesasge: "
+ + response.getErrorMessage();
+ }
+
+ @Test(priority = 14)
+ public void testDeleteSecurityDomain() throws Exception {
+ //get the root security resource
+ securityResource = getResource();
+ Resource found = null;
+ Set<Resource> childResources = securityResource.getChildResources();
+ for (Resource r : childResources) {
+ if (r.getName().indexOf(TEST_DOMAIN) > -1) {
+ found = r;
+ }
+ }
+
+ //plugin config
+ Configuration deletePlugConfig = new Configuration();
+ deletePlugConfig.put(new PropertySimple("path", SECURITY_DOMAIN_RESOURCE_KEY += "=" + TEST_DOMAIN));
+
+ //resource config
+ Configuration deleteResConfig = new Configuration();
+ deleteResConfig.put(new PropertySimple("name", TEST_DOMAIN));
+
+ DeleteResourceRequest request = new DeleteResourceRequest();
+ if (found != null) {
+ request.setResourceId(found.getId());
+ }
+ DeleteResourceResponse response = pluginContainer.getResourceFactoryManager().executeDeleteResourceImmediately(
+ request);
+
+ assert response.getStatus() == DeleteResourceStatus.SUCCESS : "The Security Domain deletion failed with an error mesasge: "
+ + response.getErrorMessage();
+ }
+
+ private Resource getResource() {
+
+ InventoryManager im = pluginContainer.getInventoryManager();
+ Resource platform = im.getPlatform();
+ Resource server = getResourceByTypeAndKey(platform, StandaloneServerComponentTest.RESOURCE_TYPE,
+ StandaloneServerComponentTest.RESOURCE_KEY);
+ Resource bindings = getResourceByTypeAndKey(server, RESOURCE_TYPE, RESOURCE_KEY);
+ return bindings;
+ }
+
+ private Resource getResource(Resource parentResource, String pluginDescriptorTypeName, String resourceKey) {
+ Resource resource = null;
+ if (((parentResource != null) & (pluginDescriptorTypeName != null) & (resourceKey != null))
+ & (((!pluginDescriptorTypeName.isEmpty()) & (!resourceKey.isEmpty())))) {
+ ResourceType resourceType = buildResourceType(pluginDescriptorTypeName);
+ resource = getResourceByTypeAndKey(parentResource, resourceType, resourceKey);
+ }
+ return resource;
+ }
+
+ private ResourceType buildResourceType(String pluginTypeName) {
+ ResourceType created = null;
+ if ((pluginTypeName != null) && (!pluginTypeName.isEmpty())) {
+ created = new ResourceType(pluginTypeName, PLUGIN_NAME, ResourceCategory.SERVICE, null);
+ }
+ return created;
+ }
+
+ //##################################################################
+ // /**The test reads the existing property values, deserializes them and writes the same
+ // * contents back out to a running instance for all known ModuleOptionTypes.
+ // *
+ // * @throws Exception
+ // */
+ // public void testPopulateModuleOptionsAndTypes() throws Exception {
+ //
+ // //as7 node details.
+ // String securityDomainId = "testDomain";
+ // //TODO: spinder 6-6-12: this cannot run as a standalone itest until JIRA https://issues.jboss.org/browse/AS7-4951
+ // // is addressed as there is no way to automate setup of the information being tested.
+ // String address = "subsystem=security,security-domain=" + securityDomainId + ",authentication=classic";
+ // boolean verboseOutput = true;
+ // boolean executeOperation = true;
+ // for (ModuleOptionType t : ModuleOptionType.values()) {
+ // String attribute = t.getAttribute();
+ // if (verboseOutput) {
+ // System.out.println("======= Running with ModuleOptionType:" + t + " attribute:" + attribute + ":");
+ // }
+ // if (attribute.equals("policy-modules")) {
+ // address = "subsystem=security,security-domain=" + securityDomainId + ",authorization=classic";
+ // } else if (attribute.equals("acl-modules")) {
+ // address = "subsystem=security,security-domain=" + securityDomainId + ",acl=classic";
+ // } else if (attribute.equals("mapping-modules")) {
+ // address = "subsystem=security,security-domain=" + securityDomainId + ",mapping=classic";
+ // } else if (attribute.equals("trust-modules")) {
+ // address = "subsystem=security,security-domain=" + securityDomainId + ",identity-trust=classic";
+ // } else if (attribute.equals("provider-modules")) {
+ // address = "subsystem=security,security-domain=" + securityDomainId + ",audit=classic";
+ // } else if (attribute.equals("login-modules")) {
+ // address = "subsystem=security,security-domain=" + securityDomainId + ",authentication=classic";
+ // } else {
+ // assert false : "An unknown attribute '" + attribute
+ // + "' was found. Is there a new type to be supported?";
+ // }
+ //
+ // //test operation- read property always available.
+ // Operation op = null;
+ //
+ // //read the login-modules attribute
+ // op = new ReadAttribute(new Address(address), attribute);
+ // Result result = exerciseOperation(op, true, verboseOutput);
+ // assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
+ // + result.getFailureDescription();
+ // //extract current results
+ // Object rawResult = result.getResult();
+ // assert rawResult != null : "Read of attribute'" + attribute + "' from address '" + address
+ // + "' has returned no value. Are those values in the model?";
+ //
+ // List<Value> list2 = new ArrayList<Value>();
+ // //populate the Value component complete with module Options.
+ // list2 = moc.populateSecurityDomainModuleOptions(result,
+ // ModuleOptionsComponent.loadModuleOptionType(attribute));
+ // if (verboseOutput) {
+ // if (rawResult != null) {
+ // System.out.println("Raw Result is:" + rawResult + " and of type:" + rawResult.getClass());
+ // } else {
+ // System.out.println("Read of attribute'" + attribute + "' from address '" + address
+ // + "' has returned no value. Are those values in the model?");
+ // }
+ // }
+ // //write the login-modules attribute
+ // op = new WriteAttribute(new Address(address));
+ // op.addAdditionalProperty("name", attribute);//attribute to execute on
+ // op.addAdditionalProperty("value", list2);
+ //
+ // //Now test the operation
+ // result = exerciseOperation(op, executeOperation, verboseOutput);
+ // assert ((result.isSuccess() == true) || (result.getOutcome() == null)) : "The operation '" + op
+ // + "' failed to write the resource.." + result.getFailureDescription();
+ //
+ // //read the login-modules attribute
+ // op = new ReadAttribute(new Address(address), attribute);
+ // result = exerciseOperation(op, true, verboseOutput);
+ // assert (result.isSuccess() == true) : "The operation '" + op + "' failed to read the resource."
+ // + result.getFailureDescription();
+ // }
+ // if (verboseOutput) {
+ // System.out.println("Successfully detected,read and wrote out attribute values for:");
+ // for (ModuleOptionType type : ModuleOptionType.values()) {
+ // System.out.println("\n" + type.ordinal() + " " + type.name());
+ // }
+ // }
+ // }
+ //
+ // /**Attempts to create a new Authentication node(authentication=classic) with a
+ // * 'login-modules' attribute complete with 'code':'Ldap' and 'flag':'required'
+ // * and some sample 'module-options' values.
+ // *
+ // */
+ // @Test(enabled = true)
+ // public void testCreateSecurityDomainChildLoginModules() {
+ // boolean execute = true;
+ // boolean verboseOutput = false;
+ // String address = "subsystem=security,security-domain=testDomain3,authentication=classic";
+ // String attribute = ModuleOptionType.Authentication.getAttribute();
+ //
+ // //test operation- read property always available.
+ // Operation op = null;
+ //
+ // //read the login-modules attribute
+ // op = new ReadAttribute(new Address(address), attribute);
+ // Result result = exerciseOperation(op, execute, verboseOutput);
+ // assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
+ // + result.getFailureDescription();
+ //
+ // //extract current results
+ // Object rawResult = result.getResult();
+ //
+ // //#### Have to create new content for the new node.
+ // List<Value> moduleTypeValue = new ArrayList<Value>();
+ // try {
+ // // loading 'login-module'
+ // JsonNode node = mapper.readTree(jsonMap.get(attribute));
+ // result.setResult(mapper.treeToValue(node, Object.class));
+ // } catch (JsonProcessingException e) {
+ // e.printStackTrace();
+ // } catch (IOException e) {
+ // e.printStackTrace();
+ // }
+ //
+ // //populate the Value component complete with module Options.
+ // moduleTypeValue = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
+ // ModuleOptionsComponent.loadModuleOptionType(attribute));
+ //
+ // //add the login-modules attribute
+ // op = ModuleOptionsComponent
+ // .createAddModuleOptionTypeOperation(new Address(address), attribute, moduleTypeValue);
+ //
+ // result = exerciseOperation(op, execute, verboseOutput);
+ // assert ((result.isSuccess() == true) || (result.getOutcome() == null)) : "The operation '" + op
+ // + "' failed to write the resource.." + result.getFailureDescription();
+ //
+ // //read the login-modules attribute
+ // op = new ReadAttribute(new Address(address), attribute);
+ // result = exerciseOperation(op, execute, verboseOutput);
+ // assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
+ // + result.getFailureDescription();
+ //
+ // //exercise values retrieved from read
+ // List<Value> serverResponse = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
+ // ModuleOptionsComponent.loadModuleOptionType(attribute));
+ // Value serverState = serverResponse.get(0);
+ // assert serverState.getFlag().equals("required") : "Incorrect state retrieved for 'flag'. Expected 'required'.";
+ // assert serverState.getCode().equals("Ldap") : "Incorrect state retrieved for 'code'. Expected 'Ldap'.";
+ // LinkedHashMap<String, Object> options = serverState.getOptions();
+ // assert options.size() == 3 : "Invalid number of module options returned. Expected 3.";
+ // int found = 0;
+ // for (String key : options.keySet()) {
+ // if (key.equals("bindPw")) {
+ // assert "test126".equals(options.get(key)) : "Module option value not correct for key '" + key + "'.";
+ // found++;
+ // } else if (key.equals("bindDn")) {
+ // assert "uid=ldapSecureUser,ou=People,dc=redat,dc=com".equals(options.get(key)) : "Module option value not correct for key '"
+ // + key + "'.";
+ // found++;
+ // } else if (key.equals("allowEmptyPasswords")) {
+ // assert "true".equals(options.get(key)) : "Module option value not correct for key '" + key + "'.";
+ // found++;
+ // }
+ // }
+ // assert found == 3 : "All module options were not loaded.";
+ //
+ // //remove the original node to reset for next run.
+ // op = new Remove(new Address(address));
+ // result = exerciseOperation(op, execute, verboseOutput);
+ // assert result.isSuccess() == true : "The operation '" + op + "' failed to remove the resource."
+ // + result.getFailureDescription();
+ // }
+ //
+ // /** For each operation
+ // * - will write verbose json and operation details to system.out if verboseOutput = true;
+ // * - will execute the operation against running server if execute = true.
+ // *
+ // * @param op
+ // * @param execute
+ // * @param verboseOutput
+ // * @return
+ // */
+ // public static Result exerciseOperation(Operation op, boolean execute, boolean verboseOutput) {
+ // //display operation as AS7 plugin will build it
+ // if (verboseOutput) {
+ // System.out.println("\tOperation is:" + op);
+ // }
+ //
+ // String jsonToSend = "";
+ // try {
+ // jsonToSend = mapper.defaultPrettyPrintingWriter().writeValueAsString(op);
+ // } catch (JsonGenerationException e) {
+ // e.printStackTrace();
+ // } catch (JsonMappingException e) {
+ // e.printStackTrace();
+ // } catch (IOException e) {
+ // e.printStackTrace();
+ // }
+ // //As generated by jackson mapper
+ // if (verboseOutput) {
+ // System.out.println("@@@@ OUTBOUND JSON#\n" + jsonToSend + "#");
+ // }
+ //
+ // //Execute the operation
+ // Result result = new Result();
+ // if (execute) {
+ // result = con.execute(op);
+ // } else {
+ // if (verboseOutput) {
+ // System.out.println("**** NOTE: Execution disabled . NOT exercising write-attribute operation. **** ");
+ // }
+ // }
+ // if (verboseOutput) {
+ // //result wrapper details
+ // System.out.println("\tResult:" + result);
+ // //detailed results
+ // System.out.println("\tValue:" + result.getResult());
+ // System.out.println("-----------------------------------------------------\n");
+ // }
+ // return result;
+ // }
+ //
+ // @Test(priority = 10, groups = "discovery")
+ // public void initialSetup() throws Exception {
+ // String securityDomainId = TEST_DOMAIN + "1";
+ // Result result = null;
+ // Operation op = null;
+ //
+ // //create the initial securityDomain
+ // op = new Operation("add", new Address("subsystem=security,security-domain=" + securityDomainId));
+ // ASConnection connection = getASConnection();
+ // con = connection;
+ // mapper = new ObjectMapper();
+ // mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
+ //
+ // moc = new ModuleOptionsComponent();
+ // result = connection.execute(op);
+ // System.out.println("#### Op is:" + op);
+ // System.out.println("#### Result is:" + result);
+ //
+ // //iterate over jsonMap
+ // for (String key : jsonMap.keySet()) {
+ // String attribute = key;
+ // String address = "";
+ // if (attribute.equals("policy-modules")) {
+ // address = "subsystem=security,security-domain=" + securityDomainId + ",authorization=classic";
+ // } else if (attribute.equals("acl-modules")) {
+ // address = "subsystem=security,security-domain=" + securityDomainId + ",acl=classic";
+ // } else if (attribute.equals("mapping-modules")) {
+ // address = "subsystem=security,security-domain=" + securityDomainId + ",mapping=classic";
+ // } else if (attribute.equals("trust-modules")) {
+ // address = "subsystem=security,security-domain=" + securityDomainId + ",identity-trust=classic";
+ // } else if (attribute.equals("provider-modules")) {
+ // address = "subsystem=security,security-domain=" + securityDomainId + ",audit=classic";
+ // } else if (attribute.equals("login-modules")) {
+ // address = "subsystem=security,security-domain=" + securityDomainId + ",authentication=classic";
+ // } else {
+ // assert false : "An unknown attribute '" + attribute
+ // + "' was found. Is there a new type to be supported?";
+ // }
+ // //#### Have to create new content for the new node.
+ // List<Value> moduleTypeValue = new ArrayList<Value>();
+ //
+ // try {
+ // // loading 'login-module'
+ // JsonNode node = mapper.readTree(jsonMap.get(attribute));
+ // result.setResult(mapper.treeToValue(node, Object.class));
+ // } catch (JsonProcessingException e) {
+ // e.printStackTrace();
+ // } catch (IOException e) {
+ // e.printStackTrace();
+ // }
+ //
+ // //populate the Value component complete with module Options.
+ // moduleTypeValue = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
+ // ModuleOptionsComponent.loadModuleOptionType(attribute));
+ //
+ // //add the login-modules attribute
+ // op = ModuleOptionsComponent.createAddModuleOptionTypeOperation(new Address(address), attribute,
+ // moduleTypeValue);
+ //
+ // result = exerciseOperation(op, true, true);
+ // assert ((result.isSuccess() == true) || (result.getOutcome() == null)) : "The operation '" + op
+ // + "' failed to write the resource.." + result.getFailureDescription();
+ // }
+ // }
+}
commit 37ba7b7ad179000571944b602a2cf6d0993632f2
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Jun 22 02:51:27 2012 -0400
Adding ability to disable deletion of as7 artifacts after an integration test run. Ex. -Ditest.deleteRoot=false
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index 16eb982..7230b59 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -331,10 +331,22 @@
<goal>run</goal>
</goals>
<configuration>
+ <tasks>
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties"
+ classpathref="maven.plugin.classpath" />
+ <if>
+ <equals arg1="${itest.deleteRoot}" arg2="false" />
+ <then>
+ <echo message="*** By request not deleting the AS7 instances after 'integration-test' run." />
+ </then>
+ <else>
<target>
<delete dir="${jboss7.home}"/>
</target>
- </configuration>
+ </else>
+ </if>
+ </tasks>
+ </configuration>
</execution>
</executions>
</plugin>
commit 251a17e5a6f972a57c53431b02b6f16867cf463c
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Jun 21 17:46:45 2012 -0400
[BZ 834434] add tooltips to STRING and LONG_STRING simple props that show full property values (https://bugzilla.redhat.com/show_bug.cgi?id=834434)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 5748811..dc32e91 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -1401,6 +1401,8 @@ public class ConfigurationEditor extends LocatableVLayout {
}
valueItem.setValue(value);
+ setValueAsTooltipIfAppropriate(valueItem, value);
+
valueItem.setRequired(propertyDefinitionSimple.isRequired());
valueItem.setWidth(220);
@@ -1419,6 +1421,13 @@ public class ConfigurationEditor extends LocatableVLayout {
return valueItem;
}
+ private void setValueAsTooltipIfAppropriate(FormItem formItem, String value) {
+ if (((formItem instanceof TextItem) && !(formItem instanceof PasswordItem)) ||
+ (formItem instanceof TextAreaItem)) {
+ formItem.setTooltip(value);
+ }
+ }
+
protected boolean shouldFireEventOnPropertyValueChange(FormItem formItem,
PropertyDefinitionSimple propertyDefinitionSimple, PropertySimple propertySimple) {
PropertyMap parentMap = propertySimple.getParentMap();
@@ -1429,6 +1438,9 @@ public class ConfigurationEditor extends LocatableVLayout {
PropertyDefinitionSimple propertyDefinitionSimple) {
propertySimple.setErrorMessage(null);
propertySimple.setValue(value);
+
+ String stringValue = (value != null) ? value.toString() : null;
+ setValueAsTooltipIfAppropriate(formItem, stringValue);
}
protected static PropertyDefinition getTopLevelPropertyDefinition(PropertyDefinition propertyDefinition) {
commit 2652ac657bd0f7527d231bbfb7d464d1cd6ab3ce
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jun 21 14:13:40 2012 -0400
add oracle and snmptrapd plugin test modules to eclipse classpath
diff --git a/.classpath b/.classpath
index 9362891..443abde 100644
--- a/.classpath
+++ b/.classpath
@@ -106,6 +106,7 @@
<classpathentry kind="src" path="modules/plugins/postgres/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/mysql/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/oracle/src/main/java"/>
+ <classpathentry kind="src" path="modules/plugins/oracle/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/apache/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/apache/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/script/src/main/java"/>
@@ -115,6 +116,7 @@
<classpathentry kind="src" path="modules/plugins/filetemplate-bundle/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/filetemplate-bundle/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/snmptrapd/src/main/java"/>
+ <classpathentry kind="src" path="modules/plugins/snmptrapd/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/byteman/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/iis/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/sshd/src/main/java"/>
commit cb316267fac790327fe62d1ac8c9ea9bccd3dbe7
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Jun 21 11:55:32 2012 -0400
[BZ 834353] update discovery to recognize BRMS as a separate product type (https://bugzilla.redhat.com/show_bug.cgi?id=834353)
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
index 31c6ab3..01eb105 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
@@ -576,11 +576,16 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom
ComparableVersion version = new ComparableVersion(installInfo.getVersion());
JBossProductType productType = installInfo.getProductType();
ComparableVersion minimumVersion = MINIMUM_PRODUCT_VERSIONS.get(productType);
- // The product is supported if the version is greater than or equal to the minimum version.
- boolean supported = (version.compareTo(minimumVersion) >= 0);
- if (!supported) {
- log.debug(productType + " version " + version + " is not supported by this plugin (minimum " + productType
- + " version is " + minimumVersion + ") - skipping...");
+ boolean supported;
+ if (minimumVersion != null) {
+ // The product is supported if the version is greater than or equal to the minimum version.
+ supported = (version.compareTo(minimumVersion) >= 0);
+ if (!supported) {
+ log.debug(productType + " version " + version + " is not supported by this plugin (minimum " + productType
+ + " version is " + minimumVersion + ") - skipping...");
+ }
+ } else {
+ supported = true;
}
return supported;
}
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java
index 818658b..de5d837 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java
@@ -1,6 +1,6 @@
/*
* Jopr Management Platform
-* Copyright (C) 2005-2010 Red Hat, Inc.
+* Copyright (C) 2005-2012 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -31,10 +31,11 @@ import java.util.jar.Attributes;
* @author Ian Springer
*/
public enum JBossProductType {
- AS("JBoss AS", "JBoss Application Server", "default"), // the public offering
- EAP("JBoss EAP", "JBoss Enterprise Application Platform", "default"), // the customer offering
- EWP("JBoss EWP", "JBoss Enterprise Web Platform", "default"), // the customer offering
- SOA("JBoss SOA-P", "JBoss Enterprise SOA Platform", "default"); // the customer SOA platform
+ AS("JBoss AS", "JBoss Application Server", "default"),
+ EAP("JBoss EAP", "JBoss Enterprise Application Platform", "default"),
+ EWP("JBoss EWP", "JBoss Enterprise Web Platform", "default"),
+ SOA("JBoss SOA-P", "JBoss Enterprise SOA Platform", "default"),
+ BRMS("JBoss BRMS", "JBoss Business Rules Management System", "default");
public final String NAME;
public final String DESCRIPTION;
@@ -43,6 +44,7 @@ public enum JBossProductType {
private static final String EAP_IMPLEMENTATION_TITLE = "JBoss [EAP]";
private static final String EWP_IMPLEMENTATION_TITLE = "JBoss [EWP]";
private static final String SOA_IMPLEMENTATION_TITLE = "JBoss [SOA]";
+ private static final String BRMS_IMPLEMENTATION_TITLE = "JBoss [BRMS]";
JBossProductType(String name, String description, String defaultConfigName) {
this.NAME = name;
@@ -68,6 +70,8 @@ public enum JBossProductType {
result = JBossProductType.EWP;
} else if (implementationTitle.equalsIgnoreCase(SOA_IMPLEMENTATION_TITLE)) {
result = JBossProductType.SOA;
+ } else if (implementationTitle.equalsIgnoreCase(BRMS_IMPLEMENTATION_TITLE)) {
+ result = JBossProductType.BRMS;
}
}
return result;
commit a5ef337f5921c5cc52fd6a96c084925c46b8f4a1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jun 20 17:26:41 2012 -0400
[BZ 828843] fix bundle deploy wizard's configuration editor initialization so required properties that didn't exist in the live deployment config are set to their default values
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
index 85ae0bb..6420978 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
@@ -22,31 +22,20 @@
*/
package org.rhq.core.clientapi.agent.configuration;
-import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.rhq.core.domain.configuration.AbstractPropertyMap;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.configuration.PropertyMap;
-import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
-import org.rhq.core.domain.configuration.definition.PropertyDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
/**
* Utility methods for working with {@link Configuration}s.
*
* @author Ian Springer
+ *
+ * @deprecated use the utility found in the domain module -org.rhq.core.domain.configuration.ConfigurationUtility
*/
public abstract class ConfigurationUtility {
@@ -60,21 +49,11 @@ public abstract class ConfigurationUtility {
* for it, this method is a no-op and will return immediately.
*
* @param configDef the configuration definition whose default template is to be created and set
+ *
+ * @deprecated use the utility found in the domain module -org.rhq.core.domain.configuration.ConfigurationUtility
*/
public static void initializeDefaultTemplate(ConfigurationDefinition configDef) {
- ConfigurationTemplate defaultTemplate = configDef.getDefaultTemplate();
- if (defaultTemplate == null) {
- Configuration defaultConfig = createDefaultConfiguration(configDef);
- // not everything should have a default template - only stuff that has default values
- if (!defaultConfig.getProperties().isEmpty()) {
- defaultTemplate = new ConfigurationTemplate(ConfigurationTemplate.DEFAULT_TEMPLATE_NAME,
- ConfigurationTemplate.DEFAULT_TEMPLATE_NAME);
- defaultTemplate.setDefault(true);
- defaultTemplate.setConfiguration(defaultConfig);
- configDef.putTemplate(defaultTemplate);
- }
- }
- return;
+ org.rhq.core.domain.configuration.ConfigurationUtility.initializeDefaultTemplate(configDef);
}
/**
@@ -87,17 +66,12 @@ public abstract class ConfigurationUtility {
*
* @param configurationDefinition the configuration definition whose default configuration is to be created
* @return configuration the default configuration
+ *
+ * @deprecated use the utility found in the domain module -org.rhq.core.domain.configuration.ConfigurationUtility
*/
public static Configuration createDefaultConfiguration(ConfigurationDefinition configurationDefinition) {
- if (configurationDefinition == null) {
- throw new IllegalArgumentException("configurationDefinition == null");
- }
- Configuration defaultConfig = new Configuration();
- Map<String, PropertyDefinition> childPropertyDefinitions = configurationDefinition.getPropertyDefinitions();
- for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
- createDefaultProperty(childPropertyDefinition, defaultConfig);
- }
- return defaultConfig;
+ return org.rhq.core.domain.configuration.ConfigurationUtility
+ .createDefaultConfiguration(configurationDefinition);
}
/**
@@ -107,19 +81,13 @@ public abstract class ConfigurationUtility {
*
* @param configuration the configuration to be normalized
* @param configurationDefinition the configuration definition to normalize the configuration against
+ *
+ * @deprecated use the utility found in the domain module -org.rhq.core.domain.configuration.ConfigurationUtility
*/
public static void normalizeConfiguration(@NotNull Configuration configuration,
@Nullable ConfigurationDefinition configurationDefinition) {
- //noinspection ConstantConditions
- if (configuration == null) {
- throw new IllegalArgumentException("Configuration parameter is null.");
- }
- if (configurationDefinition != null) {
- Map<String, PropertyDefinition> childPropertyDefinitions = configurationDefinition.getPropertyDefinitions();
- for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
- normalizeProperty(childPropertyDefinition, configuration);
- }
- }
+ org.rhq.core.domain.configuration.ConfigurationUtility.normalizeConfiguration(configuration,
+ configurationDefinition, false, false);
}
/**
@@ -132,191 +100,13 @@ public abstract class ConfigurationUtility {
* @param configurationDefinition the configuration definition to validate the configuration against
*
* @return a list of messages describing any errors that were found
+ *
+ * @deprecated use the utility found in the domain module -org.rhq.core.domain.configuration.ConfigurationUtility
*/
@NotNull
public static List<String> validateConfiguration(@NotNull Configuration configuration,
@Nullable ConfigurationDefinition configurationDefinition) {
- List<String> errorMessages = new ArrayList<String>();
- if (configurationDefinition != null) {
- Map<String, PropertyDefinition> childPropertyDefinitions = configurationDefinition.getPropertyDefinitions();
- for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
- validateProperty(childPropertyDefinition, configuration, errorMessages);
- }
- }
- return errorMessages;
- }
-
- private static void createDefaultProperty(PropertyDefinition propertyDefinition,
- AbstractPropertyMap parentPropertyMap) {
-
- Property property = null;
-
- if (propertyDefinition instanceof PropertyDefinitionSimple) {
- String defaultValue = ((PropertyDefinitionSimple) propertyDefinition).getDefaultValue();
- if (defaultValue != null || propertyDefinition.isRequired()) {
- property = new PropertySimple(propertyDefinition.getName(), defaultValue);
- }
- } else if (propertyDefinition.isRequired()) {
- if (propertyDefinition instanceof PropertyDefinitionMap) {
- property = new PropertyMap(propertyDefinition.getName());
- Map<String, PropertyDefinition> childPropertyDefinitions = ((PropertyDefinitionMap) propertyDefinition)
- .getMap();
- for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
- createDefaultProperty(childPropertyDefinition, (PropertyMap) property);
- }
- } else if (propertyDefinition instanceof PropertyDefinitionList) {
- property = new PropertyList(propertyDefinition.getName());
- PropertyDefinition listMemberPropertyDefinition = ((PropertyDefinitionList) propertyDefinition)
- .getMemberDefinition();
- if (listMemberPropertyDefinition.isRequired()) {
- if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
- // member property is a list-o-maps, create a default child map if appropriate
- PropertyDefinitionMap listMemberDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
- PropertyMap listMap = new PropertyMap(listMemberDefinitionMap.getName());
- createDefaultProperty(listMemberDefinitionMap, listMap);
- ((PropertyList) property).add(listMap);
- } else if (listMemberPropertyDefinition instanceof PropertyDefinitionSimple) {
- // member property is a simple, create a single list entry as its default if appropriate
- PropertyDefinitionSimple listMemberDefinitionSimple = (PropertyDefinitionSimple) listMemberPropertyDefinition;
- String defaultValue = listMemberDefinitionSimple.getDefaultValue();
- if (defaultValue != null || listMemberDefinitionSimple.isRequired()) {
- PropertySimple listSimple = new PropertySimple(listMemberDefinitionSimple.getName(),
- defaultValue);
- ((PropertyList) property).add(listSimple);
- }
- }
- }
- } else if (propertyDefinition instanceof PropertyDefinitionDynamic) {
- // Dynamic property values should simply be stored as simple
- property = new PropertySimple(propertyDefinition.getName(), null);
- } else {
- throw new IllegalStateException("Unsupported PropertyDefinition subclass: "
- + propertyDefinition.getClass().getName());
- }
- }
-
- if (property != null) {
- parentPropertyMap.put(property);
- }
- }
-
- private static void normalizeProperty(PropertyDefinition propertyDefinition, AbstractPropertyMap parentPropertyMap) {
- if (parentPropertyMap.getMap().keySet().contains(propertyDefinition.getName())) // property is already set
- {
- if (propertyDefinition instanceof PropertyDefinitionSimple) {
- PropertySimple propertySimple = parentPropertyMap.getSimple(propertyDefinition.getName());
- String value = propertySimple.getStringValue();
- if (value != null) {
- if (value.equals("")) {
- // Normalize "" to null, since Oracle will do the same upon persistence.
- propertySimple.setStringValue(null);
- } else if (value.length() > PropertySimple.MAX_VALUE_LENGTH) {
- // Truncate the value to the max length allowed by the DB schema.
- propertySimple.setStringValue(value.substring(0, PropertySimple.MAX_VALUE_LENGTH));
- }
- }
- }
-
- // If the property is a Map, recurse into it and normalize its child properties.
- else if (propertyDefinition instanceof PropertyDefinitionMap) {
- PropertyMap propertyMap = parentPropertyMap.getMap(propertyDefinition.getName());
- PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) propertyDefinition;
- normalizePropertyMap(propertyMap, propertyDefinitionMap);
- } else if (propertyDefinition instanceof PropertyDefinitionList) {
- PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
- PropertyDefinition listMemberPropertyDefinition = propertyDefinitionList.getMemberDefinition();
-
- // If the property is a List of Maps, iterate the list, and recurse into each Map and verify its child
- // properties.
- if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
- PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
- PropertyList propertyList = parentPropertyMap.getList(propertyDefinition.getName());
- for (Property property : propertyList.getList()) {
- PropertyMap propertyMap = (PropertyMap) property;
- normalizePropertyMap(propertyMap, propertyDefinitionMap);
- }
- }
- }
- } else // property is not set yet
- {
- Property property;
- if (propertyDefinition instanceof PropertyDefinitionSimple) {
- property = new PropertySimple(propertyDefinition.getName(), null);
- } else if (propertyDefinition instanceof PropertyDefinitionMap) {
- property = new PropertyMap(propertyDefinition.getName());
- } else if (propertyDefinition instanceof PropertyDefinitionList) {
- property = new PropertyList(propertyDefinition.getName());
- } else if (propertyDefinition instanceof PropertyDefinitionDynamic) {
- // Dynamic property values should simply be stored as simple
- property = new PropertySimple(propertyDefinition.getName(), null);
- } else {
- throw new IllegalStateException("Unsupported PropertyDefinition subclass: "
- + propertyDefinition.getClass().getName());
- }
-
- parentPropertyMap.put(property);
- }
- }
-
- private static void normalizePropertyMap(AbstractPropertyMap propertyMap,
- PropertyDefinitionMap propertyDefinitionMap) {
- Map<String, PropertyDefinition> childPropertyDefinitions = propertyDefinitionMap.getMap();
- for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
- normalizeProperty(childPropertyDefinition, propertyMap);
- }
- }
-
- private static void validateProperty(PropertyDefinition propertyDefinition, AbstractPropertyMap parentPropertyMap,
- List<String> errorMessages) {
- if (parentPropertyMap.getMap().keySet().contains(propertyDefinition.getName())) // property is already set
- {
- if (propertyDefinition instanceof PropertyDefinitionSimple) {
- PropertySimple propertySimple = parentPropertyMap.getSimple(propertyDefinition.getName());
- if (propertyDefinition.isRequired() && (propertySimple.getStringValue() == null)) {
- errorMessages.add("Required property '" + propertyDefinition.getName() + "' has a null value in "
- + parentPropertyMap + ".");
- propertySimple.setStringValue("");
- }
- }
-
- // If the property is a Map, recurse into it and validate its child properties.
- else if (propertyDefinition instanceof PropertyDefinitionMap) {
- PropertyMap propertyMap = parentPropertyMap.getMap(propertyDefinition.getName());
- PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) propertyDefinition;
- validatePropertyMap(propertyMap, propertyDefinitionMap, errorMessages);
- } else if (propertyDefinition instanceof PropertyDefinitionList) {
- PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
- PropertyDefinition listMemberPropertyDefinition = propertyDefinitionList.getMemberDefinition();
-
- // If the property is a List of Maps, iterate the list, and recurse into each Map and validate its child
- // properties.
- if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
- PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
- PropertyList propertyList = parentPropertyMap.getList(propertyDefinition.getName());
- for (Property property : propertyList.getList()) {
- PropertyMap propertyMap = (PropertyMap) property;
- validatePropertyMap(propertyMap, propertyDefinitionMap, errorMessages);
- }
- }
- }
- } else // property is not set yet
- {
- if (propertyDefinition.isRequired()) {
- errorMessages.add("Required property '" + propertyDefinition.getName() + "' was not set in "
- + parentPropertyMap + ".");
- if (propertyDefinition instanceof PropertyDefinitionSimple) {
- PropertySimple propertySimple = new PropertySimple(propertyDefinition.getName(), "");
- parentPropertyMap.put(propertySimple);
- }
- }
- }
- }
-
- private static void validatePropertyMap(AbstractPropertyMap propertyMap,
- PropertyDefinitionMap propertyDefinitionMap, List<String> errorMessages) {
- Map<String, PropertyDefinition> childPropertyDefinitions = propertyDefinitionMap.getMap();
- for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
- validateProperty(childPropertyDefinition, propertyMap, errorMessages);
- }
+ return org.rhq.core.domain.configuration.ConfigurationUtility.validateConfiguration(configuration,
+ configurationDefinition);
}
}
\ No newline at end of file
diff --git a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtilityTest.java b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtilityTest.java
deleted file mode 100644
index 3f3dccd..0000000
--- a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtilityTest.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.clientapi.agent.configuration;
-
-import org.testng.annotations.Test;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.configuration.PropertyMap;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
-import org.rhq.core.domain.configuration.definition.PropertySimpleType;
-
-@Test
-public class ConfigurationUtilityTest {
- public void testCreateDefaultNone() {
- // no defaults, no required props - returned config should be empty
- ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
-
- PropertyDefinitionSimple simple = new PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
- PropertyDefinitionMap map = new PropertyDefinitionMap("map", null, false, simple);
- PropertyDefinitionList list = new PropertyDefinitionList("list", null, false, simple);
-
- configDef.put(simple);
- configDef.put(map);
- configDef.put(list);
-
- Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
- assert config != null;
- assert config.getProperties().size() == 0;
- }
-
- public void testCreateDefaultSimple() {
- ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
-
- PropertyDefinitionSimple simple = new PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
- PropertyDefinitionSimple simpleRequired = new PropertyDefinitionSimple("simpleRequired", null, true,
- PropertySimpleType.STRING);
- PropertyDefinitionSimple simpleDefault = new PropertyDefinitionSimple("simpleDefault", null, false,
- PropertySimpleType.STRING);
- PropertyDefinitionSimple simpleRequiredDefault = new PropertyDefinitionSimple("simpleRequiredDefault", null,
- true, PropertySimpleType.STRING);
-
- simpleDefault.setDefaultValue("!!simpleDefaultValue!!");
- simpleRequiredDefault.setDefaultValue("!!simpleRequiredDefaultValue!!");
-
- configDef.put(simple);
- configDef.put(simpleRequired);
- configDef.put(simpleDefault);
- configDef.put(simpleRequiredDefault);
-
- Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
- assert config != null;
- assert config.getProperties().size() == 3; // simple is not required with no default - its not in the config
- assert config.getSimple(simple.getName()) == null;
- assert config.getSimpleValue(simpleRequired.getName(), null) == null;
- assert config.getSimpleValue(simpleDefault.getName(), null).equals("!!simpleDefaultValue!!");
- assert config.getSimpleValue(simpleRequiredDefault.getName(), null).equals("!!simpleRequiredDefaultValue!!");
- }
-
- public void testCreateDefaultMap() {
- ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
-
- // a=not required, no default; c=not required, has default; d=required, has default
- PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null, false, PropertySimpleType.STRING);
- PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null, false, PropertySimpleType.STRING);
- PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
- b.setDefaultValue("!!bDefaultValue!!");
- c.setDefaultValue("!!cDefaultValue!!");
-
- PropertyDefinitionMap map1 = new PropertyDefinitionMap("map1", null, false, a, b, c);
- PropertyDefinitionMap mapRequired1 = new PropertyDefinitionMap("mapRequired1", null, true, a, b, c);
- PropertyDefinitionMap mapRequiredDefault1 = new PropertyDefinitionMap("mapRequiredDefault1", null, true, a, b,
- c);
-
- configDef.put(map1);
- configDef.put(mapRequired1);
- configDef.put(mapRequiredDefault1);
-
- Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
- assert config != null;
- assert config.getProperties().size() == 2; // map is not required with no default - its not in the config
- assert config.getMap(map1.getName()) == null;
-
- // the two required maps have the same definitions - a,b,c as above. since a isn't required with no default, its not there
- PropertyMap mapProp1 = config.getMap(mapRequired1.getName());
- assert mapProp1 != null;
- assert mapProp1.getSimple(a.getName()) == null;
- assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
- assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");
-
- mapProp1 = config.getMap(mapRequiredDefault1.getName());
- assert mapProp1 != null;
- assert mapProp1.getSimple(a.getName()) == null;
- assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
- assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");
- }
-
- public void testCreateDefaultList() {
- ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
-
- // a=not required, no default, b=required, has default
- PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null, false, PropertySimpleType.STRING);
- PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
- c.setDefaultValue("!!cDefaultValue!!");
-
- PropertyDefinitionList list1 = new PropertyDefinitionList("list1", null, false, a);
- PropertyDefinitionList listRequired1 = new PropertyDefinitionList("listRequired1", null, true, a);
- PropertyDefinitionList listRequiredDefault1 = new PropertyDefinitionList("listRequiredDefault1", null, true, c);
-
- configDef.put(list1);
- configDef.put(listRequired1);
- configDef.put(listRequiredDefault1);
-
- Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
- assert config != null;
- assert config.getProperties().size() == 2; // list is not required with no default - its not in the config
- assert config.getList(list1.getName()) == null;
-
- PropertyList listProp1 = config.getList(listRequired1.getName());
- assert listProp1 != null;
- assert listProp1.getList().isEmpty(); // has "a" definition, which is not required and has no default
-
- listProp1 = config.getList(listRequiredDefault1.getName());
- assert listProp1 != null;
- assert listProp1.getList().get(0).getName().equals(c.getName());
- assert ((PropertySimple) listProp1.getList().get(0)).getStringValue().equals("!!cDefaultValue!!");
- }
-
- public void testCreateDefaultListOMaps() {
- ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
-
- // a=not required, no default; c=not required, has default; d=required, has default
- PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null, false, PropertySimpleType.STRING);
- PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null, false, PropertySimpleType.STRING);
- PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
- b.setDefaultValue("!!bDefaultValue!!");
- c.setDefaultValue("!!cDefaultValue!!");
-
- PropertyDefinitionMap map2 = new PropertyDefinitionMap("map2", null, false, a, b, c);
- PropertyDefinitionMap mapRequired2 = new PropertyDefinitionMap("mapRequired2", null, true, a, b, c);
- PropertyDefinitionMap mapRequiredDefault2 = new PropertyDefinitionMap("mapRequiredDefault2", null, true, a, b,
- c);
-
- PropertyDefinitionList listX = new PropertyDefinitionList("listX", null, true, map2);
- PropertyDefinitionList listY = new PropertyDefinitionList("listY", null, true, mapRequired2);
- PropertyDefinitionList listZ = new PropertyDefinitionList("listZ", null, true, mapRequiredDefault2);
-
- configDef.put(listX);
- configDef.put(listY);
- configDef.put(listZ);
-
- Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
-
- assert config != null;
- assert config.getProperties().size() == 3;
-
- PropertyList listPropTest = config.getList(listX.getName());
- assert listPropTest != null;
- assert listPropTest.getList().isEmpty();
-
- listPropTest = config.getList(listY.getName());
- assert listPropTest != null;
- PropertyMap childMap2 = (PropertyMap) listPropTest.getList().get(0);
-
- listPropTest = config.getList(listZ.getName());
- assert listPropTest != null;
- PropertyMap childMap3 = (PropertyMap) listPropTest.getList().get(0);
-
- assert childMap2.getName().equals(mapRequired2.getName());
- assert childMap3.getName().equals(mapRequiredDefault2.getName());
- }
-
- public void testCreateDefaultAllSimpleMapList() {
- // tests a big config def that has simples, lists, maps - combination of the other individual tests
- ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
-
- // SETUP SIMPLE
-
- PropertyDefinitionSimple simple = new PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
- PropertyDefinitionSimple simpleRequired = new PropertyDefinitionSimple("simpleRequired", null, true,
- PropertySimpleType.STRING);
- PropertyDefinitionSimple simpleDefault = new PropertyDefinitionSimple("simpleDefault", null, false,
- PropertySimpleType.STRING);
- PropertyDefinitionSimple simpleRequiredDefault = new PropertyDefinitionSimple("simpleRequiredDefault", null,
- true, PropertySimpleType.STRING);
-
- simpleDefault.setDefaultValue("!!simpleDefaultValue!!");
- simpleRequiredDefault.setDefaultValue("!!simpleRequiredDefaultValue!!");
-
- configDef.put(simple);
- configDef.put(simpleRequired);
- configDef.put(simpleDefault);
- configDef.put(simpleRequiredDefault);
-
- // SETUP MAP
-
- // a=not required, no default; c=not required, has default; d=required, has default
- PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null, false, PropertySimpleType.STRING);
- PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null, false, PropertySimpleType.STRING);
- PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
- b.setDefaultValue("!!bDefaultValue!!");
- c.setDefaultValue("!!cDefaultValue!!");
-
- PropertyDefinitionMap map1 = new PropertyDefinitionMap("map1", null, false, a, b, c);
- PropertyDefinitionMap mapRequired1 = new PropertyDefinitionMap("mapRequired1", null, true, a, b, c);
- PropertyDefinitionMap mapRequiredDefault1 = new PropertyDefinitionMap("mapRequiredDefault1", null, true, a, b,
- c);
-
- configDef.put(map1);
- configDef.put(mapRequired1);
- configDef.put(mapRequiredDefault1);
-
- // SETUP LIST
-
- PropertyDefinitionList list1 = new PropertyDefinitionList("list1", null, false, a);
- PropertyDefinitionList listRequired1 = new PropertyDefinitionList("listRequired1", null, true, a);
- PropertyDefinitionList listRequiredDefault1 = new PropertyDefinitionList("listRequiredDefault1", null, true, c);
-
- configDef.put(list1);
- configDef.put(listRequired1);
- configDef.put(listRequiredDefault1);
-
- // SETUP LIST-O-MAPS
-
- PropertyDefinitionMap map2 = new PropertyDefinitionMap("map2", null, false, a, b, c);
- PropertyDefinitionMap mapRequired2 = new PropertyDefinitionMap("mapRequired2", null, true, a, b, c);
- PropertyDefinitionMap mapRequiredDefault2 = new PropertyDefinitionMap("mapRequiredDefault2", null, true, a, b,
- c);
-
- PropertyDefinitionList listX = new PropertyDefinitionList("listX", null, true, map2);
- PropertyDefinitionList listY = new PropertyDefinitionList("listY", null, true, mapRequired2);
- PropertyDefinitionList listZ = new PropertyDefinitionList("listZ", null, true, mapRequiredDefault2);
-
- configDef.put(listX);
- configDef.put(listY);
- configDef.put(listZ);
-
- // get the default config
- Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
- assert config != null;
- assert config.getProperties().size() == 10;
-
- // ASSERT SIMPLE
-
- assert config.getSimple(simple.getName()) == null;
- assert config.getSimpleValue(simpleRequired.getName(), null) == null;
- assert config.getSimpleValue(simpleDefault.getName(), null).equals("!!simpleDefaultValue!!");
- assert config.getSimpleValue(simpleRequiredDefault.getName(), null).equals("!!simpleRequiredDefaultValue!!");
-
- // ASSERT MAP
-
- assert config.getMap(map1.getName()) == null;
-
- // the two required maps have the same definitions - a,b,c as above. since a isn't required with no default, its not there
- PropertyMap mapProp1 = config.getMap(mapRequired1.getName());
- assert mapProp1 != null;
- assert mapProp1.getSimple(a.getName()) == null;
- assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
- assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");
-
- mapProp1 = config.getMap(mapRequiredDefault1.getName());
- assert mapProp1 != null;
- assert mapProp1.getSimple(a.getName()) == null;
- assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
- assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");
-
- // ASSERT LIST
-
- assert config.getList(list1.getName()) == null;
-
- PropertyList listProp1 = config.getList(listRequired1.getName());
- assert listProp1 != null;
- assert listProp1.getList().isEmpty(); // has "a" definition, which is not required and has no default
-
- listProp1 = config.getList(listRequiredDefault1.getName());
- assert listProp1 != null;
- assert listProp1.getList().get(0).getName().equals(c.getName());
- assert ((PropertySimple) listProp1.getList().get(0)).getStringValue().equals("!!cDefaultValue!!");
-
- // ASSERT LIST-O-MAPS
-
- PropertyList listPropTest = config.getList(listX.getName());
- assert listPropTest != null;
- assert listPropTest.getList().isEmpty();
-
- listPropTest = config.getList(listY.getName());
- assert listPropTest != null;
- PropertyMap childMap2 = (PropertyMap) listPropTest.getList().get(0);
-
- listPropTest = config.getList(listZ.getName());
- assert listPropTest != null;
- PropertyMap childMap3 = (PropertyMap) listPropTest.getList().get(0);
-
- assert childMap2.getName().equals(mapRequired2.getName());
- assert childMap3.getName().equals(mapRequiredDefault2.getName());
- }
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUtility.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUtility.java
new file mode 100644
index 0000000..1c32526
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUtility.java
@@ -0,0 +1,334 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+
+/**
+ * Utility methods for working with {@link Configuration}s.
+ *
+ * @author Ian Springer
+ */
+public abstract class ConfigurationUtility {
+
+ /**
+ * This will populate the given configuration definition with a default template.
+ * A default template will only be created if one or more properties are required
+ * or have default values. If no property definition is required or has a default value,
+ * the default template will remain <code>null</code> in the given config definition.
+ *
+ * Note that if the given configuration definition already has a default template defined
+ * for it, this method is a no-op and will return immediately.
+ *
+ * @param configDef the configuration definition whose default template is to be created and set
+ */
+ public static void initializeDefaultTemplate(ConfigurationDefinition configDef) {
+ ConfigurationTemplate defaultTemplate = configDef.getDefaultTemplate();
+ if (defaultTemplate == null) {
+ Configuration defaultConfig = createDefaultConfiguration(configDef);
+ // not everything should have a default template - only stuff that has default values
+ if (!defaultConfig.getProperties().isEmpty()) {
+ defaultTemplate = new ConfigurationTemplate(ConfigurationTemplate.DEFAULT_TEMPLATE_NAME,
+ ConfigurationTemplate.DEFAULT_TEMPLATE_NAME);
+ defaultTemplate.setDefault(true);
+ defaultTemplate.setConfiguration(defaultConfig);
+ configDef.putTemplate(defaultTemplate);
+ }
+ }
+ return;
+ }
+
+ /**
+ * Given a configuration definition, this will build and return a "default configuration" that
+ * can be validated with the definition. All required properties are set and all properties
+ * that define a default value are also set. If a required property does not have a default
+ * value defined in the definition, the property value will be set to <code>null</code>.
+ *
+ * Use this to help create the definition's default template.
+ *
+ * @param configurationDefinition the configuration definition whose default configuration is to be created
+ * @return configuration the default configuration
+ */
+ public static Configuration createDefaultConfiguration(ConfigurationDefinition configurationDefinition) {
+ if (configurationDefinition == null) {
+ throw new IllegalArgumentException("configurationDefinition == null");
+ }
+ Configuration defaultConfig = new Configuration();
+ Map<String, PropertyDefinition> childPropertyDefinitions = configurationDefinition.getPropertyDefinitions();
+ for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
+ createDefaultProperty(childPropertyDefinition, defaultConfig);
+ }
+ return defaultConfig;
+ }
+
+ /**
+ * "Normalize" the given configuration according to the given configuration definition. That is, for any optional
+ * properties that are not defined in the top-level configuration Map or any sub-Maps, set them.
+ * Map properties are set with an empty Map, and List properties with an empty List. By default, simple
+ * properties that are missing will be created and set with a null value. However, if normalizeRequiredDefaults is true,
+ * and a simple property is required with a default, this will set the required property to that default value.
+ * If normalizeOptionalDefaults is true, and a simple property is not required but has a default, this will set the
+ * optional property to that default. If a simple property does not have a default defined, no matter what those
+ * "normalize" booleans are, the simple property will still be set to null since this method won't know what value
+ * to set it to anyway.
+ *
+ * @param configuration the configuration to be normalized (must not be null)
+ * @param configurationDefinition the configuration definition to normalize the configuration against (may be null)
+ * @param normalizeRequiredDefaults if true, and a property is required, its default will be set as that property's value
+ * @param normalizeOptionalDefaults if true, and a property is optional, its default will be set as that property's value
+ */
+ public static void normalizeConfiguration(Configuration configuration,
+ ConfigurationDefinition configurationDefinition, boolean normalizeRequiredDefaults,
+ boolean normalizeOptionalDefaults) {
+ if (configuration == null) {
+ throw new IllegalArgumentException("Configuration parameter is null.");
+ }
+ if (configurationDefinition != null) {
+ Map<String, PropertyDefinition> childPropertyDefinitions = configurationDefinition.getPropertyDefinitions();
+ for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
+ normalizeProperty(childPropertyDefinition, configuration, normalizeRequiredDefaults,
+ normalizeOptionalDefaults);
+ }
+ }
+ }
+
+ /**
+ * Validate the given configuration according to the given configuration definition. That is, check that any
+ * required properties in the top-level configuration Map or any sub-Maps, are defined and, in the case of simple
+ * properties, check that they have a non-null value. A list of messages describing any errors that were found is
+ * returned. Additionally, any undefined or null simple properties will be assigned a value of "".
+ *
+ * @param configuration the configuration to be validated (must not be null)
+ * @param configurationDefinition the configuration definition to validate the configuration against (may be null)
+ *
+ * @return a list of messages describing any errors that were found - will be empty if there are no messagse
+ */
+ public static List<String> validateConfiguration(Configuration configuration,
+ ConfigurationDefinition configurationDefinition) {
+ List<String> errorMessages = new ArrayList<String>();
+ if (configurationDefinition != null) {
+ Map<String, PropertyDefinition> childPropertyDefinitions = configurationDefinition.getPropertyDefinitions();
+ for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
+ validateProperty(childPropertyDefinition, configuration, errorMessages);
+ }
+ }
+ return errorMessages;
+ }
+
+ private static void createDefaultProperty(PropertyDefinition propertyDefinition,
+ AbstractPropertyMap parentPropertyMap) {
+
+ Property property = null;
+
+ if (propertyDefinition instanceof PropertyDefinitionSimple) {
+ String defaultValue = ((PropertyDefinitionSimple) propertyDefinition).getDefaultValue();
+ if (defaultValue != null || propertyDefinition.isRequired()) {
+ property = new PropertySimple(propertyDefinition.getName(), defaultValue);
+ }
+ } else if (propertyDefinition.isRequired()) {
+ if (propertyDefinition instanceof PropertyDefinitionMap) {
+ property = new PropertyMap(propertyDefinition.getName());
+ Map<String, PropertyDefinition> childPropertyDefinitions = ((PropertyDefinitionMap) propertyDefinition)
+ .getMap();
+ for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
+ createDefaultProperty(childPropertyDefinition, (PropertyMap) property);
+ }
+ } else if (propertyDefinition instanceof PropertyDefinitionList) {
+ property = new PropertyList(propertyDefinition.getName());
+ PropertyDefinition listMemberPropertyDefinition = ((PropertyDefinitionList) propertyDefinition)
+ .getMemberDefinition();
+ if (listMemberPropertyDefinition.isRequired()) {
+ if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
+ // member property is a list-o-maps, create a default child map if appropriate
+ PropertyDefinitionMap listMemberDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
+ PropertyMap listMap = new PropertyMap(listMemberDefinitionMap.getName());
+ createDefaultProperty(listMemberDefinitionMap, listMap);
+ ((PropertyList) property).add(listMap);
+ } else if (listMemberPropertyDefinition instanceof PropertyDefinitionSimple) {
+ // member property is a simple, create a single list entry as its default if appropriate
+ PropertyDefinitionSimple listMemberDefinitionSimple = (PropertyDefinitionSimple) listMemberPropertyDefinition;
+ String defaultValue = listMemberDefinitionSimple.getDefaultValue();
+ if (defaultValue != null || listMemberDefinitionSimple.isRequired()) {
+ PropertySimple listSimple = new PropertySimple(listMemberDefinitionSimple.getName(),
+ defaultValue);
+ ((PropertyList) property).add(listSimple);
+ }
+ }
+ }
+ } else if (propertyDefinition instanceof PropertyDefinitionDynamic) {
+ // Dynamic property values should simply be stored as simple
+ property = new PropertySimple(propertyDefinition.getName(), null);
+ } else {
+ throw new IllegalStateException("Unsupported PropertyDefinition subclass: "
+ + propertyDefinition.getClass().getName());
+ }
+ }
+
+ if (property != null) {
+ parentPropertyMap.put(property);
+ }
+ }
+
+ private static void normalizeProperty(PropertyDefinition propertyDefinition, AbstractPropertyMap parentPropertyMap,
+ boolean normalizeRequiredDefaults, boolean normalizeOptionalDefaults) {
+ if (parentPropertyMap.getMap().keySet().contains(propertyDefinition.getName())) // property is already set
+ {
+ if (propertyDefinition instanceof PropertyDefinitionSimple) {
+ PropertySimple propertySimple = parentPropertyMap.getSimple(propertyDefinition.getName());
+ String value = propertySimple.getStringValue();
+ if (value != null) {
+ if (value.equals("")) {
+ // Normalize "" to null, since Oracle will do the same upon persistence.
+ propertySimple.setStringValue(null);
+ } else if (value.length() > PropertySimple.MAX_VALUE_LENGTH) {
+ // Truncate the value to the max length allowed by the DB schema.
+ propertySimple.setStringValue(value.substring(0, PropertySimple.MAX_VALUE_LENGTH));
+ }
+ }
+ }
+
+ // If property is a Map, recurse into it and normalize its child properties.
+ else if (propertyDefinition instanceof PropertyDefinitionMap) {
+ PropertyMap propertyMap = parentPropertyMap.getMap(propertyDefinition.getName());
+ PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) propertyDefinition;
+ normalizePropertyMap(propertyMap, propertyDefinitionMap, false, false); // TODO do we want to pass normalizeRequired/OptionalDefaults?
+ } else if (propertyDefinition instanceof PropertyDefinitionList) {
+ PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
+ PropertyDefinition listMemberPropertyDefinition = propertyDefinitionList.getMemberDefinition();
+
+ // If property is a List of Maps, iterate the list and recurse into each Map and normalize its child properties.
+ if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
+ PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
+ PropertyList propertyList = parentPropertyMap.getList(propertyDefinition.getName());
+ for (Property property : propertyList.getList()) {
+ PropertyMap propertyMap = (PropertyMap) property;
+ normalizePropertyMap(propertyMap, propertyDefinitionMap, false, false); // TODO do we want to pass normalizeRequired/OptionalDefaults?
+ }
+ }
+ }
+ } else // property is not set yet
+ {
+ Property property;
+ if (propertyDefinition instanceof PropertyDefinitionSimple) {
+ String value = null;
+ if (normalizeRequiredDefaults || normalizeOptionalDefaults) {
+ if (propertyDefinition.isRequired()) {
+ if (normalizeRequiredDefaults) {
+ value = ((PropertyDefinitionSimple) propertyDefinition).getDefaultValue();
+ }
+ } else {
+ if (normalizeOptionalDefaults) {
+ value = ((PropertyDefinitionSimple) propertyDefinition).getDefaultValue();
+ }
+ }
+ }
+ property = new PropertySimple(propertyDefinition.getName(), value);
+ } else if (propertyDefinition instanceof PropertyDefinitionMap) {
+ property = new PropertyMap(propertyDefinition.getName());
+ } else if (propertyDefinition instanceof PropertyDefinitionList) {
+ property = new PropertyList(propertyDefinition.getName());
+ } else if (propertyDefinition instanceof PropertyDefinitionDynamic) {
+ // Dynamic property values should simply be stored as simple
+ property = new PropertySimple(propertyDefinition.getName(), null);
+ } else {
+ throw new IllegalStateException("Unsupported PropertyDefinition subclass: "
+ + propertyDefinition.getClass().getName());
+ }
+
+ parentPropertyMap.put(property);
+ }
+ }
+
+ private static void normalizePropertyMap(AbstractPropertyMap propertyMap,
+ PropertyDefinitionMap propertyDefinitionMap, boolean normalizeRequiredDefaults,
+ boolean normalizeOptionalDefaults) {
+ Map<String, PropertyDefinition> childPropertyDefinitions = propertyDefinitionMap.getMap();
+ for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
+ normalizeProperty(childPropertyDefinition, propertyMap, normalizeRequiredDefaults,
+ normalizeOptionalDefaults);
+ }
+ }
+
+ private static void validateProperty(PropertyDefinition propertyDefinition, AbstractPropertyMap parentPropertyMap,
+ List<String> errorMessages) {
+ if (parentPropertyMap.getMap().keySet().contains(propertyDefinition.getName())) // property is already set
+ {
+ if (propertyDefinition instanceof PropertyDefinitionSimple) {
+ PropertySimple propertySimple = parentPropertyMap.getSimple(propertyDefinition.getName());
+ if (propertyDefinition.isRequired() && (propertySimple.getStringValue() == null)) {
+ errorMessages.add("Required property '" + propertyDefinition.getName() + "' has a null value in "
+ + parentPropertyMap + ".");
+ propertySimple.setStringValue("");
+ }
+ }
+
+ // If the property is a Map, recurse into it and validate its child properties.
+ else if (propertyDefinition instanceof PropertyDefinitionMap) {
+ PropertyMap propertyMap = parentPropertyMap.getMap(propertyDefinition.getName());
+ PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) propertyDefinition;
+ validatePropertyMap(propertyMap, propertyDefinitionMap, errorMessages);
+ } else if (propertyDefinition instanceof PropertyDefinitionList) {
+ PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
+ PropertyDefinition listMemberPropertyDefinition = propertyDefinitionList.getMemberDefinition();
+
+ // If the property is a List of Maps, iterate the list, and recurse into each Map and validate its child
+ // properties.
+ if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
+ PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
+ PropertyList propertyList = parentPropertyMap.getList(propertyDefinition.getName());
+ for (Property property : propertyList.getList()) {
+ PropertyMap propertyMap = (PropertyMap) property;
+ validatePropertyMap(propertyMap, propertyDefinitionMap, errorMessages);
+ }
+ }
+ }
+ } else // property is not set yet
+ {
+ if (propertyDefinition.isRequired()) {
+ errorMessages.add("Required property '" + propertyDefinition.getName() + "' was not set in "
+ + parentPropertyMap + ".");
+ if (propertyDefinition instanceof PropertyDefinitionSimple) {
+ PropertySimple propertySimple = new PropertySimple(propertyDefinition.getName(), "");
+ parentPropertyMap.put(propertySimple);
+ }
+ }
+ }
+ }
+
+ private static void validatePropertyMap(AbstractPropertyMap propertyMap,
+ PropertyDefinitionMap propertyDefinitionMap, List<String> errorMessages) {
+ Map<String, PropertyDefinition> childPropertyDefinitions = propertyDefinitionMap.getMap();
+ for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
+ validateProperty(childPropertyDefinition, propertyMap, errorMessages);
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationUtilityTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationUtilityTest.java
new file mode 100644
index 0000000..7c49296
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationUtilityTest.java
@@ -0,0 +1,363 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.configuration;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+
+@Test
+public class ConfigurationUtilityTest {
+ public void testNormalizeDefaultSimple() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+
+ PropertyDefinitionSimple simple = new PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequired = new PropertyDefinitionSimple("simpleRequired", null, true,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleDefault = new PropertyDefinitionSimple("simpleDefault", null, false,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequiredDefault = new PropertyDefinitionSimple("simpleRequiredDefault", null,
+ true, PropertySimpleType.STRING);
+
+ simpleDefault.setDefaultValue("!!simpleDefaultValue!!");
+ simpleRequiredDefault.setDefaultValue("!!simpleRequiredDefaultValue!!");
+
+ configDef.put(simple);
+ configDef.put(simpleRequired);
+ configDef.put(simpleDefault);
+ configDef.put(simpleRequiredDefault);
+
+ // test normalization
+ Configuration config = new Configuration();
+ ConfigurationUtility.normalizeConfiguration(config, configDef, false, false);
+ assert config.getProperties().size() == 4;
+ assert config.getSimpleValue(simple.getName(), null) == null;
+ assert config.getSimpleValue(simpleRequired.getName(), null) == null;
+ assert config.getSimpleValue(simpleDefault.getName(), null) == null;
+ assert config.getSimpleValue(simpleRequiredDefault.getName(), null) == null;
+
+ config = new Configuration();
+ ConfigurationUtility.normalizeConfiguration(config, configDef, true, false);
+ assert config.getProperties().size() == 4;
+ assert config.getSimpleValue(simple.getName(), null) == null;
+ assert config.getSimpleValue(simpleRequired.getName(), null) == null; // there is no default, so nothing to set
+ assert config.getSimpleValue(simpleDefault.getName(), null) == null;
+ assert config.getSimpleValue(simpleRequiredDefault.getName(), null).equals("!!simpleRequiredDefaultValue!!");
+
+ config = new Configuration();
+ ConfigurationUtility.normalizeConfiguration(config, configDef, false, true);
+ assert config.getProperties().size() == 4;
+ assert config.getSimpleValue(simple.getName(), null) == null; // there is no default, so nothing to set
+ assert config.getSimpleValue(simpleRequired.getName(), null) == null;
+ assert config.getSimpleValue(simpleDefault.getName(), null).equals("!!simpleDefaultValue!!");
+ assert config.getSimpleValue(simpleRequiredDefault.getName(), null) == null;
+ }
+
+ public void testCreateDefaultNone() {
+ // no defaults, no required props - returned config should be empty
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+
+ PropertyDefinitionSimple simple = new PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionMap map = new PropertyDefinitionMap("map", null, false, simple);
+ PropertyDefinitionList list = new PropertyDefinitionList("list", null, false, simple);
+
+ configDef.put(simple);
+ configDef.put(map);
+ configDef.put(list);
+
+ Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 0;
+ }
+
+ public void testCreateDefaultSimple() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+
+ PropertyDefinitionSimple simple = new PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequired = new PropertyDefinitionSimple("simpleRequired", null, true,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleDefault = new PropertyDefinitionSimple("simpleDefault", null, false,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequiredDefault = new PropertyDefinitionSimple("simpleRequiredDefault", null,
+ true, PropertySimpleType.STRING);
+
+ simpleDefault.setDefaultValue("!!simpleDefaultValue!!");
+ simpleRequiredDefault.setDefaultValue("!!simpleRequiredDefaultValue!!");
+
+ configDef.put(simple);
+ configDef.put(simpleRequired);
+ configDef.put(simpleDefault);
+ configDef.put(simpleRequiredDefault);
+
+ Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 3; // simple is not required with no default - its not in the config
+ assert config.getSimple(simple.getName()) == null;
+ assert config.getSimpleValue(simpleRequired.getName(), null) == null;
+ assert config.getSimpleValue(simpleDefault.getName(), null).equals("!!simpleDefaultValue!!");
+ assert config.getSimpleValue(simpleRequiredDefault.getName(), null).equals("!!simpleRequiredDefaultValue!!");
+ }
+
+ public void testCreateDefaultMap() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+
+ // a=not required, no default; c=not required, has default; d=required, has default
+ PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
+ b.setDefaultValue("!!bDefaultValue!!");
+ c.setDefaultValue("!!cDefaultValue!!");
+
+ PropertyDefinitionMap map1 = new PropertyDefinitionMap("map1", null, false, a, b, c);
+ PropertyDefinitionMap mapRequired1 = new PropertyDefinitionMap("mapRequired1", null, true, a, b, c);
+ PropertyDefinitionMap mapRequiredDefault1 = new PropertyDefinitionMap("mapRequiredDefault1", null, true, a, b,
+ c);
+
+ configDef.put(map1);
+ configDef.put(mapRequired1);
+ configDef.put(mapRequiredDefault1);
+
+ Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 2; // map is not required with no default - its not in the config
+ assert config.getMap(map1.getName()) == null;
+
+ // the two required maps have the same definitions - a,b,c as above. since a isn't required with no default, its not there
+ PropertyMap mapProp1 = config.getMap(mapRequired1.getName());
+ assert mapProp1 != null;
+ assert mapProp1.getSimple(a.getName()) == null;
+ assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
+ assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");
+
+ mapProp1 = config.getMap(mapRequiredDefault1.getName());
+ assert mapProp1 != null;
+ assert mapProp1.getSimple(a.getName()) == null;
+ assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
+ assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");
+ }
+
+ public void testCreateDefaultList() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+
+ // a=not required, no default, b=required, has default
+ PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
+ c.setDefaultValue("!!cDefaultValue!!");
+
+ PropertyDefinitionList list1 = new PropertyDefinitionList("list1", null, false, a);
+ PropertyDefinitionList listRequired1 = new PropertyDefinitionList("listRequired1", null, true, a);
+ PropertyDefinitionList listRequiredDefault1 = new PropertyDefinitionList("listRequiredDefault1", null, true, c);
+
+ configDef.put(list1);
+ configDef.put(listRequired1);
+ configDef.put(listRequiredDefault1);
+
+ Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 2; // list is not required with no default - its not in the config
+ assert config.getList(list1.getName()) == null;
+
+ PropertyList listProp1 = config.getList(listRequired1.getName());
+ assert listProp1 != null;
+ assert listProp1.getList().isEmpty(); // has "a" definition, which is not required and has no default
+
+ listProp1 = config.getList(listRequiredDefault1.getName());
+ assert listProp1 != null;
+ assert listProp1.getList().get(0).getName().equals(c.getName());
+ assert ((PropertySimple) listProp1.getList().get(0)).getStringValue().equals("!!cDefaultValue!!");
+ }
+
+ public void testCreateDefaultListOMaps() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+
+ // a=not required, no default; c=not required, has default; d=required, has default
+ PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
+ b.setDefaultValue("!!bDefaultValue!!");
+ c.setDefaultValue("!!cDefaultValue!!");
+
+ PropertyDefinitionMap map2 = new PropertyDefinitionMap("map2", null, false, a, b, c);
+ PropertyDefinitionMap mapRequired2 = new PropertyDefinitionMap("mapRequired2", null, true, a, b, c);
+ PropertyDefinitionMap mapRequiredDefault2 = new PropertyDefinitionMap("mapRequiredDefault2", null, true, a, b,
+ c);
+
+ PropertyDefinitionList listX = new PropertyDefinitionList("listX", null, true, map2);
+ PropertyDefinitionList listY = new PropertyDefinitionList("listY", null, true, mapRequired2);
+ PropertyDefinitionList listZ = new PropertyDefinitionList("listZ", null, true, mapRequiredDefault2);
+
+ configDef.put(listX);
+ configDef.put(listY);
+ configDef.put(listZ);
+
+ Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
+
+ assert config != null;
+ assert config.getProperties().size() == 3;
+
+ PropertyList listPropTest = config.getList(listX.getName());
+ assert listPropTest != null;
+ assert listPropTest.getList().isEmpty();
+
+ listPropTest = config.getList(listY.getName());
+ assert listPropTest != null;
+ PropertyMap childMap2 = (PropertyMap) listPropTest.getList().get(0);
+
+ listPropTest = config.getList(listZ.getName());
+ assert listPropTest != null;
+ PropertyMap childMap3 = (PropertyMap) listPropTest.getList().get(0);
+
+ assert childMap2.getName().equals(mapRequired2.getName());
+ assert childMap3.getName().equals(mapRequiredDefault2.getName());
+ }
+
+ public void testCreateDefaultAllSimpleMapList() {
+ // tests a big config def that has simples, lists, maps - combination of the other individual tests
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+
+ // SETUP SIMPLE
+
+ PropertyDefinitionSimple simple = new PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequired = new PropertyDefinitionSimple("simpleRequired", null, true,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleDefault = new PropertyDefinitionSimple("simpleDefault", null, false,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequiredDefault = new PropertyDefinitionSimple("simpleRequiredDefault", null,
+ true, PropertySimpleType.STRING);
+
+ simpleDefault.setDefaultValue("!!simpleDefaultValue!!");
+ simpleRequiredDefault.setDefaultValue("!!simpleRequiredDefaultValue!!");
+
+ configDef.put(simple);
+ configDef.put(simpleRequired);
+ configDef.put(simpleDefault);
+ configDef.put(simpleRequiredDefault);
+
+ // SETUP MAP
+
+ // a=not required, no default; c=not required, has default; d=required, has default
+ PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
+ b.setDefaultValue("!!bDefaultValue!!");
+ c.setDefaultValue("!!cDefaultValue!!");
+
+ PropertyDefinitionMap map1 = new PropertyDefinitionMap("map1", null, false, a, b, c);
+ PropertyDefinitionMap mapRequired1 = new PropertyDefinitionMap("mapRequired1", null, true, a, b, c);
+ PropertyDefinitionMap mapRequiredDefault1 = new PropertyDefinitionMap("mapRequiredDefault1", null, true, a, b,
+ c);
+
+ configDef.put(map1);
+ configDef.put(mapRequired1);
+ configDef.put(mapRequiredDefault1);
+
+ // SETUP LIST
+
+ PropertyDefinitionList list1 = new PropertyDefinitionList("list1", null, false, a);
+ PropertyDefinitionList listRequired1 = new PropertyDefinitionList("listRequired1", null, true, a);
+ PropertyDefinitionList listRequiredDefault1 = new PropertyDefinitionList("listRequiredDefault1", null, true, c);
+
+ configDef.put(list1);
+ configDef.put(listRequired1);
+ configDef.put(listRequiredDefault1);
+
+ // SETUP LIST-O-MAPS
+
+ PropertyDefinitionMap map2 = new PropertyDefinitionMap("map2", null, false, a, b, c);
+ PropertyDefinitionMap mapRequired2 = new PropertyDefinitionMap("mapRequired2", null, true, a, b, c);
+ PropertyDefinitionMap mapRequiredDefault2 = new PropertyDefinitionMap("mapRequiredDefault2", null, true, a, b,
+ c);
+
+ PropertyDefinitionList listX = new PropertyDefinitionList("listX", null, true, map2);
+ PropertyDefinitionList listY = new PropertyDefinitionList("listY", null, true, mapRequired2);
+ PropertyDefinitionList listZ = new PropertyDefinitionList("listZ", null, true, mapRequiredDefault2);
+
+ configDef.put(listX);
+ configDef.put(listY);
+ configDef.put(listZ);
+
+ // get the default config
+ Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 10;
+
+ // ASSERT SIMPLE
+
+ assert config.getSimple(simple.getName()) == null;
+ assert config.getSimpleValue(simpleRequired.getName(), null) == null;
+ assert config.getSimpleValue(simpleDefault.getName(), null).equals("!!simpleDefaultValue!!");
+ assert config.getSimpleValue(simpleRequiredDefault.getName(), null).equals("!!simpleRequiredDefaultValue!!");
+
+ // ASSERT MAP
+
+ assert config.getMap(map1.getName()) == null;
+
+ // the two required maps have the same definitions - a,b,c as above. since a isn't required with no default, its not there
+ PropertyMap mapProp1 = config.getMap(mapRequired1.getName());
+ assert mapProp1 != null;
+ assert mapProp1.getSimple(a.getName()) == null;
+ assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
+ assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");
+
+ mapProp1 = config.getMap(mapRequiredDefault1.getName());
+ assert mapProp1 != null;
+ assert mapProp1.getSimple(a.getName()) == null;
+ assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
+ assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");
+
+ // ASSERT LIST
+
+ assert config.getList(list1.getName()) == null;
+
+ PropertyList listProp1 = config.getList(listRequired1.getName());
+ assert listProp1 != null;
+ assert listProp1.getList().isEmpty(); // has "a" definition, which is not required and has no default
+
+ listProp1 = config.getList(listRequiredDefault1.getName());
+ assert listProp1 != null;
+ assert listProp1.getList().get(0).getName().equals(c.getName());
+ assert ((PropertySimple) listProp1.getList().get(0)).getStringValue().equals("!!cDefaultValue!!");
+
+ // ASSERT LIST-O-MAPS
+
+ PropertyList listPropTest = config.getList(listX.getName());
+ assert listPropTest != null;
+ assert listPropTest.getList().isEmpty();
+
+ listPropTest = config.getList(listY.getName());
+ assert listPropTest != null;
+ PropertyMap childMap2 = (PropertyMap) listPropTest.getList().get(0);
+
+ listPropTest = config.getList(listZ.getName());
+ assert listPropTest != null;
+ PropertyMap childMap3 = (PropertyMap) listPropTest.getList().get(0);
+
+ assert childMap2.getName().equals(mapRequired2.getName());
+ assert childMap3.getName().equals(mapRequiredDefault2.getName());
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDeploymentConfigStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDeploymentConfigStep.java
index 7fc0363..c295b74 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDeploymentConfigStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDeploymentConfigStep.java
@@ -19,13 +19,14 @@
package org.rhq.enterprise.gui.coregui.client.bundle.deploy;
import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUtility;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
-import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
@@ -58,8 +59,11 @@ public class GetDeploymentConfigStep extends AbstractWizardStep {
// This has started behaving badly. Instead of moving ahead let's give them a message
// and a chance to go back to the previous screen.
// this.wizard.getView().incrementStep();
- HeaderLabel label = new HeaderLabel(MSG.view_bundle_deployWizard_getConfigSkip());
+ HTMLFlow label = new HTMLFlow(MSG.view_bundle_deployWizard_getConfigSkip());
label.setWidth100();
+ label.setHeight(50);
+ label.setStylePrimaryName("HeaderLabel");
+ label.setStyleName("HeaderLabel");
editor = new VLayout();
editor.addMember(label);
} else {
@@ -100,9 +104,7 @@ public class GetDeploymentConfigStep extends AbstractWizardStep {
config = new Configuration();
} else {
config = config.deepCopy(false);
- //TODO: get access to this method, may need to add slsb call
- // also, may need to enhance this drop unnecessary config (maybe it can just stay around)
- //ConfigurationUtility.normalizeConfiguration(config, configDef);
+ ConfigurationUtility.normalizeConfiguration(config, configDef, true, false);
}
return config;
commit 8c13179ae885c491088980a88aee43d7b7bf77dd
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Jun 20 12:53:30 2012 -0700
[BZ 830323] Large artifacts get packaged in war file. Remove symbolMap data from GWT compiled war file.
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index 45308cc..aac9b9c 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -298,6 +298,8 @@
<compileSourcesArtifact>org.rhq:rhq-core-domain</compileSourcesArtifact>
<style>${gwt.style}</style>
<strict>true</strict>
+ <!-- compiles gwt artifacts like symbolMap outside of war so it doesnt get packaged -->
+ <deploy>${project.build.directory}/gwt-deploy</deploy>
</configuration>
<executions>
commit 3bbec0bbb45429d1f0769753466faa3e26e5623f
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jun 20 15:40:39 2012 -0400
[830463 - Re-enabling (actually, updating) an alert definition clears condition logs for existing alerts]
This is sort of complex. The underlying issue is that
AlertDefinitionManagerBean.updateAlertDefinition(updatedDef) replaces
existing AlertConditions with updatedDef.conditions. The detached
conditions were deleted (via Hibernate and DELETE_ORPHAN) regardless of the
fact that they very possibly linked to AlertConditionLog records for existing
Alerts. These log records are what you need to display the actual condition
evaluations that explain why the alert was fired.
The fix was to allow the detached AlertCondition records to stay around and
to deal with the fallout of doing that:
- clean up orphaned AlertConditions (no def and no logs) in the data purge job
- update queries backing AlertManager.deleteAlertsByContext()
- update queries backing resource uninventory bulk delete
Additionally, there was a lot of confusion around the 'purgeInternals' parameter
for updateAlertDefinition(). It was initially thought that setting this true
was responsible for the loss of AlertConditions backing the Alerts. Actually,
what this flag does, when set to true, is to erase any partial condition
matching that has taken place. It must be set true if conditions, dampening rules,
or the condition expression (All vs Any matching) are being updated. Otherwise
it can be false.
I renamed this flag to be 'resetMatching' to hopefully be more clear, and
added some jdoc for the relevant methods.
I had already refactored CoreGUI's editor to correctly set this flag before
realizing it was not the root cause. So that logic is in place and
will optimize the update to some degree.
I think the backend logic can be further optimized using this setting more
intelligently. I plan a subsequent check-in for that before setting to ON_QA.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
index 064400c..8a72244 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
@@ -290,7 +290,11 @@ import org.rhq.core.domain.operation.OperationRequestStatus;
+ " FROM AlertCondition AS ac " //
+ " JOIN ac.alertDefinition ad " //
+ " JOIN ad.resource res " //
- + " WHERE ac.id = :alertConditionId ") })
+ + " WHERE ac.id = :alertConditionId "),
+ @NamedQuery(name = AlertCondition.QUERY_DELETE_ORPHANED, query = "" //
+ + " DELETE FROM AlertCondition ac " //
+ + " WHERE ac.alertDefinition IS NULL " //
+ + " AND NOT EXISTS ( SELECT acl FROM AlertConditionLog acl WHERE acl.condition.id = ac.id ) ") })
@SequenceGenerator(name = "RHQ_ALERT_CONDITION_ID_SEQ", sequenceName = "RHQ_ALERT_CONDITION_ID_SEQ")
@Table(name = "RHQ_ALERT_CONDITION")
@XmlAccessorType(XmlAccessType.FIELD)
@@ -314,6 +318,8 @@ public class AlertCondition implements Serializable {
public static final String QUERY_FIND_RESOURCE_STATUS_BY_CONDITION_ID = "AlertCondition.findResourceStatus";
+ public static final String QUERY_DELETE_ORPHANED = "AlertCondition.deleteOrphaned";
+
public static final String RECOVERY_CONDITIONAL_EXPRESSION = "" //
+ " ( ad.recoveryId = 0 " //
+ " OR ( ad.recoveryId <> 0 " //
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionLog.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionLog.java
index d43bb7f..28355be 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionLog.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionLog.java
@@ -42,7 +42,7 @@ import javax.persistence.Table;
* @author Joseph Marques
*/
@Entity
-@NamedQueries( {
+@NamedQueries({
@NamedQuery(name = AlertConditionLog.QUERY_FIND_UNMATCHED_LOG_BY_ALERT_CONDITION_ID, //
query = "SELECT acl " //
+ " FROM AlertConditionLog AS acl " //
@@ -63,16 +63,27 @@ import javax.persistence.Table;
+ " FROM Alert a " //
+ " JOIN a.conditionLogs ac" //
+ " WHERE a.id IN ( :alertIds ) )"),
- // deletes condition logs via the alert def, not alerts, because not every condition log may not
- // yet be associated with an alert. Also, avoids joining with the potentially large alert table
- @NamedQuery(name = AlertConditionLog.QUERY_DELETE_BY_RESOURCES, //
+ // This query removes condition logs via the alert def, not alerts, because not every condition log may
+ // yet be associated with an alert. This is required by Resource bulk delete to pick up the condition logs missed
+ // by QUERY_DELETE_BY_RESOURCES. It will not get the logs for AlertConditions detached from the AlertDefinition.
+ @NamedQuery(name = AlertConditionLog.QUERY_DELETE_BY_RESOURCES_BULK_DELETE, //
query = "DELETE AlertConditionLog acl " //
+ " WHERE acl.condition.id IN ( SELECT ac.id " //
+ " FROM AlertCondition ac " //
+ " JOIN ac.alertDefinition ad " //
+ " WHERE ad.resource.id IN ( :resourceIds ) ))"),
+ // This query will remove condition logs for conditions that are associated with alerts, regardless of whether
+ // the AlertCondition has been detached from the AlertDef. This is what you want if you are deleting alerts for
+ // a resource. It does not fully satisfy Resource bulk delete.
+ @NamedQuery(name = AlertConditionLog.QUERY_DELETE_BY_RESOURCES, //
+ query = "DELETE AlertConditionLog acl " //
+ + " WHERE acl.alert.id IN ( SELECT alert.id " //
+ + " FROM AlertDefinition alertDef " //
+ + " JOIN alertDef.alerts alert " //
+ + " WHERE alertDef.resource.id IN ( :resourceIds ) ))"),
@NamedQuery(name = AlertConditionLog.QUERY_DELETE_BY_RESOURCE_TEMPLATE, //
- query = "DELETE AlertConditionLog log " + " WHERE log.alert.id IN (SELECT alert.id "
+ query = "DELETE AlertConditionLog acl " //
+ + " WHERE acl.alert.id IN (SELECT alert.id "
+ " FROM AlertDefinition alertDef "
+ " JOIN alertDef.alerts alert "
+ " WHERE alertDef.resourceType.id = :resourceTypeId)"),
@@ -104,6 +115,7 @@ public class AlertConditionLog implements Serializable {
public static final String QUERY_DELETE_ALL = "AlertConditionLog.deleteByAll";
public static final String QUERY_DELETE_BY_ALERT_IDS = "AlertConditionLog.deleteByAlertIds";
public static final String QUERY_DELETE_BY_RESOURCES = "AlertConditionLog.deleteByResources";
+ public static final String QUERY_DELETE_BY_RESOURCES_BULK_DELETE = "AlertConditionLog.deleteByResourcesBulkDelete";
public static final String QUERY_DELETE_BY_RESOURCE_TEMPLATE = "AlertConditionLog.deleteByResourceType";
public static final String QUERY_DELETE_BY_RESOURCE_GROUPS = "AlertConditionLog.deleteByResourceGroups";
public static final String QUERY_DELETE_BY_ALERT_CTIME = "AlertConditionLog.deleteByAlertCTime";
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index 7d5e3e8..397e254 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -354,11 +354,17 @@ public class AlertDefinition implements Serializable {
@OneToMany(mappedBy = "alertDefinition", cascade = CascadeType.ALL)
@OrderBy
- @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
- // primary key
+ // We used to use DELETE_ORPHAN here. But the problem is that the the AlertCondition record is needed by the
+ // associated AlertConditionLog for presentation purposes. So, keep the AlertCondition records even if they
+ // are detached from the AlertDefinition (e.g. when the def is updated, see update() below). They will be
+ // cleaned up in the DataPurge job after all relevant alerts have been removed and there are no longer any
+ // referencing AlertConditionLog records.
private Set<AlertCondition> conditions = new LinkedHashSet<AlertCondition>(1); // Most alerts will only have one condition.
@OneToMany(mappedBy = "alertDefinition", cascade = CascadeType.ALL)
+ // Although similar to AlertCondition, we do use DELETE_ORPHAN here. The reason is because AlertNotificationLog
+ // does not refer back to the AlertNotification record and therefore the notification logs are not affected
+ // by the loss of the AlertNotification that spawned the notification.
@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private List<AlertNotification> alertNotifications = new ArrayList<AlertNotification>();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index 7f2cce0..6a2fbf5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -199,5 +199,5 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
protected abstract void disableButtonPressed(ListGridRecord[] selection);
- protected abstract void commitAlertDefinition(AlertDefinition alertDefinition);
+ protected abstract void commitAlertDefinition(AlertDefinition alertDefinition, boolean isPurgeInternals);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
index d762b23..3b564d4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
@@ -58,6 +58,7 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
private StaticTextItem conditionExpressionStatic;
private boolean formBuilt = false;
+ private boolean updated;
public ConditionsAlertDefinitionForm(String locatorId, ResourceType resourceType) {
this(locatorId, resourceType, null);
@@ -67,6 +68,7 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
super(locatorId);
this.resourceType = resourceType;
this.alertDefinition = alertDefinition;
+ this.updated = false;
}
@Override
@@ -86,6 +88,11 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
}
@Override
+ public boolean isResetMatching() {
+ return updated || conditionsEditor.isUpdated();
+ }
+
+ @Override
public void setAlertDefinition(AlertDefinition alertDef) {
alertDefinition = alertDef;
@@ -113,8 +120,12 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
@Override
public void makeViewOnly() {
+ updated = false;
+
conditionExpression.hide();
conditionsEditor.setEditable(false);
+ conditionsEditor.setUpdated(false);
+
conditionExpressionStatic.show();
markForRedraw();
@@ -122,11 +133,15 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
@Override
public void saveAlertDefinition() {
+ updated = false;
+
String condExpr = conditionExpression.getValue().toString();
alertDefinition.setConditionExpression(BooleanExpression.valueOf(condExpr));
HashSet<AlertCondition> conditions = conditionsEditor.getConditions();
alertDefinition.setConditions(conditions);
+
+ conditionsEditor.setUpdated(false);
}
@Override
@@ -167,6 +182,8 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
conditionExpression.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
+ updated = true;
+
// Find out if this is using the ALL conjunction - if it is, we can't have more than one conditional use the same metric.
// If we do, immediately abort and warn the user. See BZ 737565
if ((BooleanExpression.ALL.name().equals(event.getValue().toString()))
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 18b9beb..f3317ed 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -22,6 +22,11 @@
*/
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSourceField;
@@ -33,6 +38,7 @@ import com.smartgwt.client.widgets.events.CloseClickEvent;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.drift.DriftDefinitionTemplate;
@@ -48,11 +54,6 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
/**
* @author John Mazzitelli
*/
@@ -62,12 +63,14 @@ public class ConditionsEditor extends LocatableVLayout {
private HashSet<AlertCondition> conditions;
private Table<ConditionDataSource> table;
private final SelectItem conditionExpression;
+ private boolean updated;
public ConditionsEditor(String locatorId, SelectItem conditionExpression, ResourceType resourceType,
HashSet<AlertCondition> conditions) {
super(locatorId);
this.conditionExpression = conditionExpression;
this.resourceType = resourceType;
+ this.updated = false;
setConditions(conditions);
}
@@ -133,6 +136,14 @@ public class ConditionsEditor extends LocatableVLayout {
table.setTableActionDisableOverride(!editable);
}
+ public boolean isUpdated() {
+ return updated;
+ }
+
+ public void setUpdated(boolean updated) {
+ this.updated = updated;
+ }
+
private class ConditionsTable extends Table<ConditionDataSource> {
private ConditionsTable(String locatorId) {
super(locatorId);
@@ -191,12 +202,14 @@ public class ConditionsEditor extends LocatableVLayout {
}
});
+ final int numConditions = conditions.size();
NewConditionEditor newConditionEditor = new NewConditionEditor(
extendLocatorId("newConditionEditor"), conditions,
ConditionsEditor.this.conditionExpression, ConditionsEditor.this.resourceType,
new Runnable() {
@Override
public void run() {
+ updated = updated || numConditions != conditions.size();
winModal.markForDestroy();
refresh();
}
@@ -215,6 +228,7 @@ public class ConditionsEditor extends LocatableVLayout {
for (ListGridRecord record : selection) {
AlertCondition cond = getDataSource().copyValues(record);
conditions.remove(cond);
+ updated = true;
}
refresh();
}
@@ -237,8 +251,8 @@ public class ConditionsEditor extends LocatableVLayout {
protected List<DataSourceField> addDataSourceFields() {
List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceTextField conditionField = new DataSourceTextField(FIELD_CONDITION, MSG
- .view_alert_common_tab_conditions_text());
+ DataSourceTextField conditionField = new DataSourceTextField(FIELD_CONDITION,
+ MSG.view_alert_common_tab_conditions_text());
fields.add(conditionField);
return fields;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
index 3ba2182..c5ccfe3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
@@ -34,9 +34,9 @@ import com.smartgwt.client.widgets.form.fields.events.ItemHoverEvent;
import com.smartgwt.client.widgets.form.fields.events.ItemHoverHandler;
import org.rhq.core.domain.alert.AlertDampening;
-import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertDampening.Category;
import org.rhq.core.domain.alert.AlertDampening.TimeUnits;
+import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -69,6 +69,8 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
private SelectItem durationTimeUnitsSelection;
private StaticTextItem durationTimeUnitsStatic;
+ private boolean updated;
+
public DampeningAlertDefinitionForm(String locatorId) {
this(locatorId, null);
}
@@ -76,6 +78,7 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
public DampeningAlertDefinitionForm(String locatorId, AlertDefinition alertDefinition) {
super(locatorId);
this.alertDefinition = alertDefinition;
+ this.updated = false;
}
@Override
@@ -237,6 +240,8 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
@Override
public void makeViewOnly() {
+ updated = false;
+
dampeningRuleSelection.hide();
dampeningRuleStatic.show();
@@ -318,6 +323,8 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
@Override
public void saveAlertDefinition() {
+ updated = false;
+
AlertDampening.Category cat = AlertDampening.Category.valueOf(dampeningRuleSelection.getValue().toString());
AlertDampening alertDampening = new AlertDampening(cat);
switch (cat) {
@@ -381,6 +388,11 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
markForRedraw();
}
+ @Override
+ public boolean isResetMatching() {
+ return updated;
+ }
+
private void buildForm() {
if (!formBuilt) {
dampeningRuleSelection = new SelectItem("dampeningRule", MSG.view_alert_common_tab_dampening());
@@ -413,8 +425,8 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
// nothing to do - the none category has no ui components to render
// CONSECUTIVE_COUNT
- consecutiveOccurrencesSpinner = new SpinnerItem("consecutiveOccurrencesSpinner", MSG
- .view_alert_common_tab_dampening_consecutive_occurrences_label());
+ consecutiveOccurrencesSpinner = new SpinnerItem("consecutiveOccurrencesSpinner",
+ MSG.view_alert_common_tab_dampening_consecutive_occurrences_label());
consecutiveOccurrencesSpinner.setWrapTitle(false);
consecutiveOccurrencesSpinner.setMin(1);
consecutiveOccurrencesSpinner.setMax(999999);
@@ -423,13 +435,19 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
consecutiveOccurrencesSpinner.setHoverWidth(300);
consecutiveOccurrencesSpinner.setTooltip(MSG
.view_alert_common_tab_dampening_consecutive_occurrences_label_tooltip());
- consecutiveOccurrencesStatic = new StaticTextItem("consecutiveOccurrencesStatic", MSG
- .view_alert_common_tab_dampening_consecutive_occurrences_label());
+ consecutiveOccurrencesStatic = new StaticTextItem("consecutiveOccurrencesStatic",
+ MSG.view_alert_common_tab_dampening_consecutive_occurrences_label());
consecutiveOccurrencesStatic.setWrapTitle(false);
+ consecutiveOccurrencesSpinner.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ updated = true;
+ }
+ });
+
// PARTIAL_COUNT
- partialOccurrencesSpinner = new SpinnerItem("partialOccurrencesSpinner", MSG
- .view_alert_common_tab_dampening_partial_occurrences_label());
+ partialOccurrencesSpinner = new SpinnerItem("partialOccurrencesSpinner",
+ MSG.view_alert_common_tab_dampening_partial_occurrences_label());
partialOccurrencesSpinner.setWrapTitle(false);
partialOccurrencesSpinner.setMin(1);
partialOccurrencesSpinner.setMax(999999);
@@ -438,12 +456,18 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
partialOccurrencesSpinner.setHoverWidth(300);
partialOccurrencesSpinner.setTooltip(MSG
.view_alert_common_tab_dampening_partial_occurrences_label_tooltip());
- partialOccurrencesStatic = new StaticTextItem("partialOccurrencesStatic", MSG
- .view_alert_common_tab_dampening_partial_occurrences_label());
+ partialOccurrencesStatic = new StaticTextItem("partialOccurrencesStatic",
+ MSG.view_alert_common_tab_dampening_partial_occurrences_label());
partialOccurrencesStatic.setWrapTitle(false);
- partialEvaluationsSpinner = new SpinnerItem("partialEvaluationsSpinner", MSG
- .view_alert_common_tab_dampening_partial_evalatuions_label());
+ partialOccurrencesSpinner.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ updated = true;
+ }
+ });
+
+ partialEvaluationsSpinner = new SpinnerItem("partialEvaluationsSpinner",
+ MSG.view_alert_common_tab_dampening_partial_evalatuions_label());
partialEvaluationsSpinner.setWrapTitle(false);
partialEvaluationsSpinner.setMin(1);
partialEvaluationsSpinner.setMax(999999);
@@ -452,13 +476,19 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
partialEvaluationsSpinner.setHoverWidth(300);
partialEvaluationsSpinner.setTooltip(MSG
.view_alert_common_tab_dampening_partial_evalatuions_label_tooltip());
- partialEvaluationsStatic = new StaticTextItem("partialEvaluationStatic", MSG
- .view_alert_common_tab_dampening_partial_evalatuions_label());
+ partialEvaluationsStatic = new StaticTextItem("partialEvaluationStatic",
+ MSG.view_alert_common_tab_dampening_partial_evalatuions_label());
partialEvaluationsStatic.setWrapTitle(false);
+ partialEvaluationsSpinner.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ updated = true;
+ }
+ });
+
// DURATION_COUNT
- durationOccurrencesSpinner = new SpinnerItem("durationOccurrencesSpinner", MSG
- .view_alert_common_tab_dampening_duration_occurrences_label());
+ durationOccurrencesSpinner = new SpinnerItem("durationOccurrencesSpinner",
+ MSG.view_alert_common_tab_dampening_duration_occurrences_label());
durationOccurrencesSpinner.setWrapTitle(false);
durationOccurrencesSpinner.setMin(1);
durationOccurrencesSpinner.setMax(999999);
@@ -467,12 +497,18 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
durationOccurrencesSpinner.setHoverWidth(300);
durationOccurrencesSpinner.setTooltip(MSG
.view_alert_common_tab_dampening_duration_occurrences_label_tooltip());
- durationOccurrencesStatic = new StaticTextItem("durationOccurrencesStatic", MSG
- .view_alert_common_tab_dampening_duration_occurrences_label());
+ durationOccurrencesStatic = new StaticTextItem("durationOccurrencesStatic",
+ MSG.view_alert_common_tab_dampening_duration_occurrences_label());
durationOccurrencesStatic.setWrapTitle(false);
- durationTimePeriodSpinner = new SpinnerItem("durationTimePeriodSpinner", MSG
- .view_alert_common_tab_dampening_duration_period_label());
+ durationOccurrencesSpinner.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ updated = true;
+ }
+ });
+
+ durationTimePeriodSpinner = new SpinnerItem("durationTimePeriodSpinner",
+ MSG.view_alert_common_tab_dampening_duration_period_label());
durationTimePeriodSpinner.setWrapTitle(false);
durationTimePeriodSpinner.setMin(1);
durationTimePeriodSpinner.setMax(999999);
@@ -480,10 +516,16 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
durationTimePeriodSpinner.setDefaultValue(1);
durationTimePeriodSpinner.setHoverWidth(300);
durationTimePeriodSpinner.setTooltip(MSG.view_alert_common_tab_dampening_duration_period_label_tooltip());
- durationTimePeriodStatic = new StaticTextItem("durationTimePeriodStatic", MSG
- .view_alert_common_tab_dampening_duration_period_label());
+ durationTimePeriodStatic = new StaticTextItem("durationTimePeriodStatic",
+ MSG.view_alert_common_tab_dampening_duration_period_label());
durationTimePeriodStatic.setWrapTitle(false);
+ durationTimePeriodSpinner.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ updated = true;
+ }
+ });
+
durationTimeUnitsSelection = new SelectItem("durationTimeUnits", "");
LinkedHashMap<String, String> units = new LinkedHashMap<String, String>(4);
units.put(AlertDampening.TimeUnits.MINUTES.name(), getTimeUnitsTitle(AlertDampening.TimeUnits.MINUTES));
@@ -494,9 +536,17 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
durationTimeUnitsSelection.setDefaultValue(AlertDampening.TimeUnits.MINUTES.name());
durationTimeUnitsStatic = new StaticTextItem("durationTimeUnitsStatic", "");
+ durationTimeUnitsSelection.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ updated = true;
+ }
+ });
+
dampeningRuleSelection.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
+ updated = true;
+
Category cat = AlertDampening.Category.valueOf(event.getValue().toString());
switch (cat) {
case NONE: {
@@ -536,8 +586,8 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
break;
}
default: {
- throw new IllegalStateException(MSG
- .view_alert_common_tab_invalid_dampening_category(cat.name())); // should never happen
+ throw new IllegalStateException(
+ MSG.view_alert_common_tab_invalid_dampening_category(cat.name())); // should never happen
}
}
markForRedraw();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
index 439ed3e..da4dfd3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
@@ -9,6 +9,8 @@ public interface EditAlertDefinitionForm {
AlertDefinition getAlertDefinition();
+ boolean isResetMatching();
+
void setAlertDefinition(AlertDefinition alertDef);
void makeEditable();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
index f154b26..fd07a64 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
@@ -32,8 +32,8 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.components.form.SimpleEditableTextAreaFormItem;
import org.rhq.enterprise.gui.coregui.client.components.form.SimpleEditableFormItem;
+import org.rhq.enterprise.gui.coregui.client.components.form.SimpleEditableTextAreaFormItem;
import org.rhq.enterprise.gui.coregui.client.components.form.StringLengthValidator;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -197,6 +197,10 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
markForRedraw();
}
+ @Override
+ public boolean isResetMatching() {
+ return false;
+ }
private void buildForm() {
if (!formBuilt) {
nameField = new SimpleEditableFormItem("name", MSG.common_title_name());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
index fc0dbb1..b277077 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -198,7 +198,7 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- protected void commitAlertDefinition(final AlertDefinition alertDefinition) {
+ protected void commitAlertDefinition(final AlertDefinition alertDefinition, boolean purgeInternals) {
if (alertDefinition.getId() == 0) {
GWTServiceLookup.getGroupAlertDefinitionService().createGroupAlertDefinitions(alertDefinition,
Integer.valueOf(this.group.getId()), new AsyncCallback<Integer>() {
@@ -216,7 +216,8 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
});
} else {
- GWTServiceLookup.getGroupAlertDefinitionService().updateGroupAlertDefinitions(alertDefinition, true,
+ GWTServiceLookup.getGroupAlertDefinitionService().updateGroupAlertDefinitions(alertDefinition,
+ purgeInternals,
new AsyncCallback<AlertDefinition>() {
@Override
public void onSuccess(AlertDefinition result) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
index 26dbae8..8a428df 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -23,6 +23,9 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.ArrayList;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -38,6 +41,7 @@ import com.smartgwt.client.widgets.events.DoubleClickHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.criteria.Criteria;
@@ -50,9 +54,6 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author John Mazzitelli
*/
@@ -142,6 +143,11 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
markForRedraw();
}
+ @Override
+ public boolean isResetMatching() {
+ return false;
+ }
+
private void buildForm() {
if (!formBuilt) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
index a3cfea1..0e8f1b2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
@@ -148,6 +148,11 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements
markForRedraw();
}
+ @Override
+ public boolean isResetMatching() {
+ return false;
+ }
+
private void buildForm() {
if (!formBuilt) {
disableWhenFiredSelection = new RadioGroupItem("disableWhenFired", MSG
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index e31e554..00aa951 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -194,7 +194,7 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- protected void commitAlertDefinition(final AlertDefinition alertDefinition) {
+ protected void commitAlertDefinition(final AlertDefinition alertDefinition, boolean purgeInternals) {
if (alertDefinition.getId() == 0) {
GWTServiceLookup.getAlertDefinitionService().createAlertDefinition(alertDefinition,
Integer.valueOf(resource.getId()), new AsyncCallback<Integer>() {
@@ -213,7 +213,7 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
});
} else {
GWTServiceLookup.getAlertDefinitionService().updateAlertDefinition(alertDefinition.getId(),
- alertDefinition, true, new AsyncCallback<AlertDefinition>() {
+ alertDefinition, purgeInternals, new AsyncCallback<AlertDefinition>() {
@Override
public void onSuccess(AlertDefinition result) {
CoreGUI.getMessageCenter().notify(
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index f276937..f2007ce 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -70,8 +70,8 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
final LocatableTabSet tabSet = new LocatableTabSet(this.getLocatorId());
tabSet.setHeight100();
- final Tab generalPropertiesTab = new LocatableTab(tabSet.extendLocatorId("General"), MSG
- .view_alert_common_tab_general());
+ final Tab generalPropertiesTab = new LocatableTab(tabSet.extendLocatorId("General"),
+ MSG.view_alert_common_tab_general());
generalProperties = new GeneralPropertiesAlertDefinitionForm(this.getLocatorId(), alertDefinition);
generalPropertiesTab.setPane(generalProperties);
generalPropertiesTab.addTabDeselectedHandler(new TabDeselectedHandler() {
@@ -84,14 +84,14 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
}
});
- Tab conditionsTab = new LocatableTab(tabSet.extendLocatorId("Conditions"), MSG
- .view_alert_common_tab_conditions());
+ Tab conditionsTab = new LocatableTab(tabSet.extendLocatorId("Conditions"),
+ MSG.view_alert_common_tab_conditions());
conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), alertDefView.getResourceType(),
alertDefinition);
conditionsTab.setPane(conditions);
- Tab notificationsTab = new LocatableTab(tabSet.extendLocatorId("Notifications"), MSG
- .view_alert_common_tab_notifications());
+ Tab notificationsTab = new LocatableTab(tabSet.extendLocatorId("Notifications"),
+ MSG.view_alert_common_tab_notifications());
notifications = new NotificationsAlertDefinitionForm(this.getLocatorId(), alertDefinition);
notificationsTab.setPane(notifications);
@@ -134,11 +134,12 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
@Override
public void onClick(ClickEvent event) {
if (generalProperties.validate()) {
+ boolean resetMatching = isResetMatching();
saveAlertDefinition();
setAlertDefinition(getAlertDefinition()); // loads data into static fields
makeViewOnly();
- alertDefView.commitAlertDefinition(getAlertDefinition());
+ alertDefView.commitAlertDefinition(getAlertDefinition(), resetMatching);
} else {
tabSet.selectTab(generalPropertiesTab);
}
@@ -162,6 +163,10 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
return alertDefinition;
}
+ public boolean isResetMatching() {
+ return conditions.isResetMatching() || dampening.isResetMatching();
+ }
+
public void setAlertDefinition(AlertDefinition alertDef) {
alertDefinition = alertDef;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
index 93b3a91..987e62f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
@@ -206,7 +206,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- protected void commitAlertDefinition(final AlertDefinition alertDefinition) {
+ protected void commitAlertDefinition(final AlertDefinition alertDefinition, boolean purgeInternals) {
if (alertDefinition.getId() == 0) {
GWTServiceLookup.getAlertTemplateService().createAlertTemplate(alertDefinition,
Integer.valueOf(this.resourceType.getId()), new AsyncCallback<Integer>() {
@@ -224,7 +224,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
});
} else {
- GWTServiceLookup.getAlertTemplateService().updateAlertTemplate(alertDefinition, true,
+ GWTServiceLookup.getAlertTemplateService().updateAlertTemplate(alertDefinition, purgeInternals,
new AsyncCallback<AlertDefinition>() {
@Override
public void onSuccess(AlertDefinition result) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
index ce73f0e..a356ff8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
@@ -32,8 +32,8 @@ public interface AlertDefinitionGWTService extends RemoteService {
int createAlertDefinition(AlertDefinition alertDefinition, Integer resourceId) throws RuntimeException;
- AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition,
- boolean updateInternals) throws RuntimeException;
+ AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition, boolean purgeInternals)
+ throws RuntimeException;
int enableAlertDefinitions(int[] alertDefinitionIds) throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
index 88a134a..01ba237 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
@@ -74,10 +74,10 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
@Override
public AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition,
- boolean updateInternals) throws RuntimeException {
+ boolean resetMatching) throws RuntimeException {
try {
AlertDefinition results = alertDefManager.updateAlertDefinition(getSessionSubject(), alertDefinitionId,
- alertDefinition, updateInternals);
+ alertDefinition, resetMatching);
return SerialUtility.prepare(results, "updateAlertDefinition");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionLogManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionLogManagerBean.java
index a26472e..bf87585 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionLogManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionLogManagerBean.java
@@ -102,9 +102,6 @@ public class AlertConditionLogManagerBean implements AlertConditionLogManagerLoc
} catch (NoResultException nre) { // this is the expected case 90% of the time
// lookup the condition entity
AlertCondition condition = entityManager.find(AlertCondition.class, alertConditionId);
- if (condition == null) {
- // the associated AlertDefinition must have been updated, which removes all previous AlertConditions
- }
// persist the log entry
AlertConditionLog conditionLog = new AlertConditionLog(condition, ctime);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java
index fa03aaf..6953bfc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java
@@ -60,6 +60,7 @@ public class AlertConditionManagerBean implements AlertConditionManagerLocal {
private AuthorizationManagerLocal authorizationManager;
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ @Override
public Integer getAlertDefinitionByConditionIdInNewTransaction(int alertConditionId) {
try {
Query query = entityManager.createNamedQuery(AlertDefinition.QUERY_FIND_DEFINITION_ID_BY_CONDITION_ID);
@@ -77,6 +78,7 @@ public class AlertConditionManagerBean implements AlertConditionManagerLocal {
@SuppressWarnings("unchecked")
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ @Override
public PageList<? extends AbstractAlertConditionCategoryComposite> getAlertConditionComposites(Subject user,
Integer agentId, AlertConditionCategory category, PageControl pageControl) {
if (authorizationManager.isOverlord(user) == false) {
@@ -151,6 +153,7 @@ public class AlertConditionManagerBean implements AlertConditionManagerLocal {
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ @Override
public InventoryStatus getResourceStatusByConditionId(int alertConditionId) {
try {
Query query = entityManager.createNamedQuery(AlertCondition.QUERY_FIND_RESOURCE_STATUS_BY_CONDITION_ID);
@@ -165,4 +168,10 @@ public class AlertConditionManagerBean implements AlertConditionManagerLocal {
}
}
+ @Override
+ public int purgeOrphanedAlertConditions() {
+ Query purgeQuery = entityManager.createNamedQuery(AlertCondition.QUERY_DELETE_ORPHANED);
+ return purgeQuery.executeUpdate();
+ }
+
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerLocal.java
index f659716..4c27c75 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerLocal.java
@@ -44,4 +44,6 @@ public interface AlertConditionManagerLocal {
InventoryStatus getResourceStatusByConditionId(int alertConditionId);
+ int purgeOrphanedAlertConditions();
+
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
index c1c9d93..5da131e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
@@ -451,9 +451,9 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public AlertDefinition updateAlertDefinition(Subject subject, int alertDefinitionId,
- AlertDefinition alertDefinition, boolean purgeInternals) throws InvalidAlertDefinitionException,
+ AlertDefinition alertDefinition, boolean resetMatching) throws InvalidAlertDefinitionException,
AlertDefinitionUpdateException {
- if (purgeInternals) {
+ if (resetMatching) {
alertDefinitionManager.purgeInternals(alertDefinitionId);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
index 03c8945..d663198 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
@@ -60,8 +60,19 @@ public interface AlertDefinitionManagerLocal {
void copyAlertDefinitions(Subject subject, Integer[] alertDefinitionIds);
+ /**
+ * @param subject
+ * @param alertDefinitionId
+ * @param alertDefinition
+ * @param resetMatching Incur the overhead of resetting any partial alert matching that has taken place. This *must*
+ * be set true if updating conditions, dampening rules or the conditionExpressin (ANY vs ALL). If in doubt, set to true
+ * as the loss of partial matching is better than corrupted matching.
+ * @return
+ * @throws InvalidAlertDefinitionException
+ * @throws AlertDefinitionUpdateException
+ */
AlertDefinition updateAlertDefinition(Subject subject, int alertDefinitionId, AlertDefinition alertDefinition,
- boolean updateInternals) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException;
+ boolean resetMatching) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException;
int purgeUnusedAlertDefinitions();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java
index 8974c30..cde2f04 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java
@@ -216,7 +216,7 @@ public class GroupAlertDefinitionManagerBean implements GroupAlertDefinitionMana
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public AlertDefinition updateGroupAlertDefinitions(Subject subject, AlertDefinition groupAlertDefinition,
- boolean purgeInternals) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException {
+ boolean resetMatching) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException {
if (LOG.isDebugEnabled()) {
LOG.debug("updateGroupAlertDefinition: " + groupAlertDefinition);
}
@@ -225,7 +225,7 @@ public class GroupAlertDefinitionManagerBean implements GroupAlertDefinitionMana
AlertDefinition updated = null;
try {
updated = alertDefinitionManager.updateAlertDefinition(subject, groupAlertDefinition.getId(),
- groupAlertDefinition, purgeInternals); // do not allow direct undeletes of an alert definition
+ groupAlertDefinition, resetMatching); // do not allow direct undeletes of an alert definition
} catch (Throwable t) {
throw new AlertDefinitionUpdateException("Failed to update a GroupAlertDefinition: "
+ groupAlertDefinition.toSimpleString(), t);
@@ -244,7 +244,7 @@ public class GroupAlertDefinitionManagerBean implements GroupAlertDefinitionMana
for (Integer alertDefinitionId : alertDefinitions) {
try {
alertDefinitionManager.updateAlertDefinition(overlord, alertDefinitionId, groupAlertDefinition,
- purgeInternals);
+ resetMatching);
} catch (Throwable t) {
// continue on error, update as many as possible
if (firstThrowable == null) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerLocal.java
index 3db4ea9..13faf1d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerLocal.java
@@ -41,8 +41,18 @@ public interface GroupAlertDefinitionManagerLocal {
int disableGroupAlertDefinitions(Subject subject, Integer[] groupAlertDefinitionIds);
+ /**
+ * @param subject
+ * @param groupAlertDefinition
+ * @param resetMatching Incur the overhead of resetting any partial alert matching that has taken place. This *must*
+ * be set true if updating conditions, dampening rules or the conditionExpressin (ANY vs ALL). If in doubt, set to true
+ * as the loss of partial matching is better than corrupted matching.
+ * @return
+ * @throws InvalidAlertDefinitionException
+ * @throws AlertDefinitionUpdateException
+ */
AlertDefinition updateGroupAlertDefinitions(Subject subject, AlertDefinition groupAlertDefinition,
- boolean purgeInternals) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException;
+ boolean resetMatching) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException;
// required to implement system side-effects as a result of modifying group membership or deleting groups
void addGroupAlertDefinitions(Subject subject, int groupId, int[] resourcesIdsToAdd)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 79c7935..f7ae643 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -511,13 +511,14 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
PluginConfigurationUpdate.QUERY_DELETE_BY_RESOURCES_1, // first, delete the raw configs for the config
PluginConfigurationUpdate.QUERY_DELETE_BY_RESOURCES_2, // then delete the config objects
PluginConfigurationUpdate.QUERY_DELETE_BY_RESOURCES_3, // then the history objects wrapping those configs
- AlertConditionLog.QUERY_DELETE_BY_RESOURCES, // Don't
- AlertNotificationLog.QUERY_DELETE_BY_RESOURCES, // alter
- Alert.QUERY_DELETE_BY_RESOURCES, // order
- AlertCondition.QUERY_DELETE_BY_RESOURCES, // of
- AlertDampeningEvent.QUERY_DELETE_BY_RESOURCES, // alert-
- AlertNotification.QUERY_DELETE_BY_RESOURCES, // related
- AlertDefinition.QUERY_DELETE_BY_RESOURCES, // deletes
+ AlertConditionLog.QUERY_DELETE_BY_RESOURCES, // Don't
+ AlertConditionLog.QUERY_DELETE_BY_RESOURCES_BULK_DELETE, // alter
+ AlertNotificationLog.QUERY_DELETE_BY_RESOURCES, // the
+ Alert.QUERY_DELETE_BY_RESOURCES, // order
+ AlertCondition.QUERY_DELETE_BY_RESOURCES, // of
+ AlertDampeningEvent.QUERY_DELETE_BY_RESOURCES, // alert-
+ AlertNotification.QUERY_DELETE_BY_RESOURCES, // related
+ AlertDefinition.QUERY_DELETE_BY_RESOURCES, // deletes
JPADrift.QUERY_DELETE_BY_RESOURCES, // drift before changeset
JPADriftChangeSet.QUERY_DELETE_BY_RESOURCES };
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJob.java
index 0cc04f4..dc8275c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJob.java
@@ -32,6 +32,7 @@ import org.quartz.StatefulJob;
import org.rhq.core.domain.auth.Subject;
import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.enterprise.server.alert.AlertConditionManagerLocal;
import org.rhq.enterprise.server.alert.AlertDefinitionManagerLocal;
import org.rhq.enterprise.server.alert.AlertManagerLocal;
import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
@@ -56,7 +57,6 @@ public class DataPurgeJob extends AbstractStatefulJob {
private static final Log LOG = LogFactory.getLog(DataPurgeJob.class);
private static long HOUR = 60 * 60 * 1000L;
- private static long DAY = 24L * HOUR;
/**
* Schedules a purge job to trigger right now. This will not block - it schedules the job to trigger but immediately
@@ -118,6 +118,7 @@ public class DataPurgeJob extends AbstractStatefulJob {
purgeEventData(LookupUtil.getEventManager(), systemConfig);
purgeAlertData(LookupUtil.getAlertManager(), systemConfig);
purgeUnusedAlertDefinitions(LookupUtil.getAlertDefinitionManager());
+ purgeOrphanedAlertConditions(LookupUtil.getAlertConditionManager());
purgeOrphanedAlertNotifications(LookupUtil.getAlertNotificationManager());
purgeMeasurementTraitData(LookupUtil.getMeasurementDataManager(), systemConfig);
purgeAvailabilityData(LookupUtil.getAvailabilityManager(), systemConfig);
@@ -239,6 +240,21 @@ public class DataPurgeJob extends AbstractStatefulJob {
}
}
+ private void purgeOrphanedAlertConditions(AlertConditionManagerLocal alertConditionManager) {
+ long timeStart = System.currentTimeMillis();
+ LOG.info("Alert condition orphan purge starting at " + new Date(timeStart));
+ int orphansPurged = 0;
+
+ try {
+ orphansPurged = alertConditionManager.purgeOrphanedAlertConditions();
+ } catch (Exception e) {
+ LOG.error("Failed to purge alert condition data. Cause: " + e, e);
+ } finally {
+ long duration = System.currentTimeMillis() - timeStart;
+ LOG.info("Purged [" + orphansPurged + "] orphan alert conditions - completed in [" + duration + "]ms");
+ }
+ }
+
private void purgeOrphanedAlertNotifications(AlertNotificationManagerLocal alertNotificationManager) {
long timeStart = System.currentTimeMillis();
LOG.info("Alert notification orphan purge starting at " + new Date(timeStart));
commit 18f46f5624b562364e6063451392905dc6e95725
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jun 20 14:04:02 2012 -0400
fix eclipse classpath - location for swizzle is wrong
diff --git a/.classpath b/.classpath
index 76e080c..9362891 100644
--- a/.classpath
+++ b/.classpath
@@ -241,7 +241,7 @@
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/jbossws/jbossws-native-core/3.1.1.GA/jbossws-native-core-3.1.1.GA.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/maven/maven-project/2.0.8/maven-project-2.0.8.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/maven/maven-plugin-api/2.0.8/maven-plugin-api-2.0.8.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/codehaus/swizzle/1.6.1/swizzle-confluence-1.6.1.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/codehaus/swizzle/swizzle-confluence/1.6.1/swizzle-confluence-1.6.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/jvnet/inflector/0.7.0/inflector-0.7.0.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/net/augeas/augeas/0.0.2/augeas-0.0.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/json/json/20080701/json-20080701.jar"/>
commit 4482e902d123cc6881fe5b4308bbcf0ee9ff4846
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jun 20 12:31:33 2012 -0400
add the ability to inspect the changed configuration in the test page that tests the config editor
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java
index 3f3e154..31d17a3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java
@@ -28,6 +28,10 @@ import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.LayoutSpacer;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
@@ -133,9 +137,37 @@ public class TestConfigurationView
}
private void save() {
- CoreGUI.getMessageCenter().notify(
- new Message("Configuration updated.", "Test configuration updated."));
+ StringBuilder str = new StringBuilder("=~pre~=");
+ Configuration c = editor.getConfiguration();
+ Map<String, Property> allProps = c.getAllProperties();
+ for (Property prop : allProps.values()) {
+ getPropertyStrings(prop, str, "");
+ }
+ str.append("=~/pre~=");
+ CoreGUI.getMessageCenter().notify(new Message("Configuration updated.", str.toString()));
reloadConfiguration();
}
+ private void getPropertyStrings(Property prop, StringBuilder str, String indent) {
+ if (prop instanceof PropertySimple) {
+ String value = ((PropertySimple) prop).getStringValue();
+ str.append(indent + prop.getName() + "=" + ((value != null) ? value : "~~VALUE WAS NULL~~"));
+ str.append("\n");
+ } else if (prop instanceof PropertyMap) {
+ str.append(indent + prop.getName() + " MAP:\n");
+ PropertyMap propMap = (PropertyMap) prop;
+ Map<String, Property> map = propMap.getMap();
+ for (Property val : map.values()) {
+ getPropertyStrings(val, str, indent + " ");
+ }
+ } else if (prop instanceof PropertyList) {
+ str.append(indent + prop.getName() + " LIST:\n");
+ PropertyList propList = (PropertyList) prop;
+ for (Property val : propList.getList()) {
+ getPropertyStrings(val, str, indent + " ");
+ }
+ } else {
+ str.append("unknown prop type: " + prop);
+ }
+ }
}
commit 953419eaa4392cb2826b76351e72ef30789d6b92
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jun 20 11:35:52 2012 -0400
provide an eclipse external tool to allow eclipse developer to easily purge their RHQ dev-container server from extra plugins. this leaves intact a small subset of plugins. this allows for faster rhq server startup.
diff --git a/etc/eclipse-tools/maven/RHQ Delete Extra Plugins From Dev Container.launch b/etc/eclipse-tools/maven/RHQ Delete Extra Plugins From Dev Container.launch
new file mode 100644
index 0000000..1fa6810
--- /dev/null
+++ b/etc/eclipse-tools/maven/RHQ Delete Extra Plugins From Dev Container.launch
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
+<stringAttribute key="bad_container_name" value="\rhq\etc\eclipse-tools\maven"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${system_path:sh}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-c "rm hadoop* jopr-jboss-as-5* jopr-jboss-cache* jopr-tomcat* modcluster* pattern* rhq-augeas* rhq-aliases* rhq-apache* rhq-byteman* rhq-cobbler* rhq-cron* rhq-database* rhq-grub* rhq-hosts* rhq-hudson* rhq-iis* rhq-irc* rhq-jboss-as-7* rhq-kickstart* rhq-mysql* rhq-netservices* rhq-oracle* rhq-postgres* rhq-postfix* rhq-samba* rhq-script2* rhq-snmp* rhq-sshd* rhq-sudoers* rhq-twitter* rhq-virt*""/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq/dev-container/jbossas/server/default/deploy/rhq.ear/rhq-downloads/rhq-plugins}"/>
+</launchConfiguration>
commit 51d5d2537e1dc159f7c1a71302be9f810ba63613
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Jun 20 08:56:40 2012 -0400
[BZ 826542] disable incorrect unit tests. More work necessary to get this to pass with Arquillian properly.
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/SecurityModuleOptionsTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/SecurityModuleOptionsTest.java
index 49d8040..e80ddec 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/SecurityModuleOptionsTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/SecurityModuleOptionsTest.java
@@ -1,319 +1,319 @@
-/*
- * 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 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.modules.plugins.jbossas7;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.JsonProcessingException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.SerializationConfig;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.Test;
-
-import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent.ModuleOptionType;
-import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent.Value;
-import org.rhq.modules.plugins.jbossas7.json.Address;
-import org.rhq.modules.plugins.jbossas7.json.Operation;
-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
-import org.rhq.modules.plugins.jbossas7.json.Remove;
-import org.rhq.modules.plugins.jbossas7.json.Result;
-import org.rhq.modules.plugins.jbossas7.json.WriteAttribute;
-
-/**
- * Test exercising the subsystem=security/SecurityDomain/[Authentication, Authorization, Mapping, Audit, Acl,
- * Identity-Trust]
- * @author Simeon Pinder
- */
-@Test(groups = "unit")
-public class SecurityModuleOptionsTest extends AbstractConfigurationHandlingTest {
-
- private static String user = "rhqadmin";
- private static String pass = "as7";
- private static String host = "localhost";
- private static ASConnection con = null;
- private static ObjectMapper mapper = null;
- private ModuleOptionsComponent moc = null;
-
- //Define some shared and reusable content
- static HashMap<String, String> jsonMap = new HashMap<String, String>();
- static {
- jsonMap
- .put(
- "login-modules",
- "[{\"flag\":\"required\", \"code\":\"Ldap\", \"module-options\":{\"bindDn\":\"uid=ldapSecureUser,ou=People,dc=redat,dc=com\", \"bindPw\":\"test126\", \"allowEmptyPasswords\":\"true\"}}]");
- // "[{\"flag\":\"required\", \"code\":\"Ldap\"}]");
- jsonMap
- .put(
- "policy-modules",
- "[{\"flag\":\"requisite\", \"code\":\"LdapExtended\", \"module-options\":{\"policy\":\"module\", \"policy1\":\"module1\"}}]");
- jsonMap
- .put("mapping-modules",
- "[{\"code\":\"Test\", \"type\":\"attribute\", \"module-options\":{\"mapping\":\"module\", \"mapping1\":\"module1\"}}]");
- jsonMap.put("provider-modules",
- "[{\"code\":\"Providers\", \"module-options\":{\"provider\":\"module\", \"provider1\":\"module1\"}}]");
- }
-
- @BeforeSuite
- private void initializeConnectionDetails() {
- con = new ASConnection(host, 9990, user, pass);
- mapper = new ObjectMapper();
- mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
-
- moc = new ModuleOptionsComponent();
- }
-
- public static void main(String[] args) {
- SecurityModuleOptionsTest test = new SecurityModuleOptionsTest();
- try {
- test.initializeConnectionDetails();
- test.testPopulateModuleOptionsAndTypes();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- /**The test reads the existing property values, deserializes them and writes the same
- * contents back out to a running instance for all known ModuleOptionTypes.
- *
- * @throws Exception
- */
- public void testPopulateModuleOptionsAndTypes() throws Exception {
-
- //as7 node details.
- String securityDomainId = "testDomain";
- //TODO: spinder 6-6-12: this cannot run as a standalone itest until JIRA https://issues.jboss.org/browse/AS7-4951
- // is addressed as there is no way to automate setup of the information being tested.
- String address = "subsystem=security,security-domain=" + securityDomainId + ",authentication=classic";
- boolean verboseOutput = true;
- boolean executeOperation = true;
- for (ModuleOptionType t : ModuleOptionType.values()) {
- String attribute = t.getAttribute();
- if (verboseOutput) {
- System.out.println("======= Running with ModuleOptionType:" + t + " attribute:" + attribute + ":");
- }
- if (attribute.equals("policy-modules")) {
- address = "subsystem=security,security-domain=" + securityDomainId + ",authorization=classic";
- } else if (attribute.equals("acl-modules")) {
- address = "subsystem=security,security-domain=" + securityDomainId + ",acl=classic";
- } else if (attribute.equals("mapping-modules")) {
- address = "subsystem=security,security-domain=" + securityDomainId + ",mapping=classic";
- } else if (attribute.equals("trust-modules")) {
- address = "subsystem=security,security-domain=" + securityDomainId + ",identity-trust=classic";
- } else if (attribute.equals("provider-modules")) {
- address = "subsystem=security,security-domain=" + securityDomainId + ",audit=classic";
- } else if (attribute.equals("login-modules")) {
- address = "subsystem=security,security-domain=" + securityDomainId + ",authentication=classic";
- } else {
- assert false : "An unknown attribute '" + attribute
- + "' was found. Is there a new type to be supported?";
- }
-
- //test operation- read property always available.
- Operation op = null;
-
- //read the login-modules attribute
- op = new ReadAttribute(new Address(address), attribute);
- Result result = exerciseOperation(op, true, verboseOutput);
- assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
- + result.getFailureDescription();
- //extract current results
- Object rawResult = result.getResult();
- assert rawResult != null : "Read of attribute'" + attribute + "' from address '" + address
- + "' has returned no value. Are those values in the model?";
-
- List<Value> list2 = new ArrayList<Value>();
- //populate the Value component complete with module Options.
- list2 = moc.populateSecurityDomainModuleOptions(result,
- ModuleOptionsComponent.loadModuleOptionType(attribute));
- if (verboseOutput) {
- if (rawResult != null) {
- System.out.println("Raw Result is:" + rawResult + " and of type:" + rawResult.getClass());
- } else {
- System.out.println("Read of attribute'" + attribute + "' from address '" + address
- + "' has returned no value. Are those values in the model?");
- }
- }
- //write the login-modules attribute
- op = new WriteAttribute(new Address(address));
- op.addAdditionalProperty("name", attribute);//attribute to execute on
- op.addAdditionalProperty("value", list2);
-
- //Now test the operation
- result = exerciseOperation(op, executeOperation, verboseOutput);
- assert ((result.isSuccess() == true) || (result.getOutcome() == null)) : "The operation '" + op
- + "' failed to write the resource.." + result.getFailureDescription();
-
- //read the login-modules attribute
- op = new ReadAttribute(new Address(address), attribute);
- result = exerciseOperation(op, true, verboseOutput);
- assert (result.isSuccess() == true) : "The operation '" + op + "' failed to read the resource."
- + result.getFailureDescription();
- }
- if (verboseOutput) {
- System.out.println("Successfully detected,read and wrote out attribute values for:");
- for (ModuleOptionType type : ModuleOptionType.values()) {
- System.out.println("\n" + type.ordinal() + " " + type.name());
- }
- }
- }
-
- /**Attempts to create a new Authentication node(authentication=classic) with a
- * 'login-modules' attribute complete with 'code':'Ldap' and 'flag':'required'
- * and some sample 'module-options' values.
- *
- */
- @Test(enabled = true)
- public void testCreateSecurityDomainChildLoginModules() {
- boolean execute = true;
- boolean verboseOutput = false;
- String address = "subsystem=security,security-domain=testDomain3,authentication=classic";
- String attribute = ModuleOptionType.Authentication.getAttribute();
-
- //test operation- read property always available.
- Operation op = null;
-
- //read the login-modules attribute
- op = new ReadAttribute(new Address(address), attribute);
- Result result = exerciseOperation(op, execute, verboseOutput);
- assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
- + result.getFailureDescription();
-
- //extract current results
- Object rawResult = result.getResult();
-
- //#### Have to create new content for the new node.
- List<Value> moduleTypeValue = new ArrayList<Value>();
- try {
- // loading 'login-module'
- JsonNode node = mapper.readTree(jsonMap.get(attribute));
- result.setResult(mapper.treeToValue(node, Object.class));
- } catch (JsonProcessingException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- //populate the Value component complete with module Options.
- moduleTypeValue = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
- ModuleOptionsComponent.loadModuleOptionType(attribute));
-
- //add the login-modules attribute
- op = ModuleOptionsComponent
- .createAddModuleOptionTypeOperation(new Address(address), attribute, moduleTypeValue);
-
- result = exerciseOperation(op, execute, verboseOutput);
- assert ((result.isSuccess() == true) || (result.getOutcome() == null)) : "The operation '" + op
- + "' failed to write the resource.." + result.getFailureDescription();
-
- //read the login-modules attribute
- op = new ReadAttribute(new Address(address), attribute);
- result = exerciseOperation(op, execute, verboseOutput);
- assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
- + result.getFailureDescription();
-
- //exercise values retrieved from read
- List<Value> serverResponse = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
- ModuleOptionsComponent.loadModuleOptionType(attribute));
- Value serverState = serverResponse.get(0);
- assert serverState.getFlag().equals("required") : "Incorrect state retrieved for 'flag'. Expected 'required'.";
- assert serverState.getCode().equals("Ldap") : "Incorrect state retrieved for 'code'. Expected 'Ldap'.";
- LinkedHashMap<String, Object> options = serverState.getOptions();
- assert options.size() == 3 : "Invalid number of module options returned. Expected 3.";
- int found = 0;
- for (String key : options.keySet()) {
- if (key.equals("bindPw")) {
- assert "test126".equals(options.get(key)) : "Module option value not correct for key '" + key + "'.";
- found++;
- } else if (key.equals("bindDn")) {
- assert "uid=ldapSecureUser,ou=People,dc=redat,dc=com".equals(options.get(key)) : "Module option value not correct for key '"
- + key + "'.";
- found++;
- } else if (key.equals("allowEmptyPasswords")) {
- assert "true".equals(options.get(key)) : "Module option value not correct for key '" + key + "'.";
- found++;
- }
- }
- assert found == 3 : "All module options were not loaded.";
-
- //remove the original node to reset for next run.
- op = new Remove(new Address(address));
- result = exerciseOperation(op, execute, verboseOutput);
- assert result.isSuccess() == true : "The operation '" + op + "' failed to remove the resource."
- + result.getFailureDescription();
- }
-
- /** For each operation
- * - will write verbose json and operation details to system.out if verboseOutput = true;
- * - will execute the operation against running server if execute = true.
- *
- * @param op
- * @param execute
- * @param verboseOutput
- * @return
- */
- public static Result exerciseOperation(Operation op, boolean execute, boolean verboseOutput) {
- //display operation as AS7 plugin will build it
- if (verboseOutput) {
- System.out.println("\tOperation is:" + op);
- }
-
- String jsonToSend = "";
- try {
- // jsonToSend = mapper.writeValueAsString(op);
- jsonToSend = mapper.defaultPrettyPrintingWriter().writeValueAsString(op);
- } catch (JsonGenerationException e) {
- e.printStackTrace();
- } catch (JsonMappingException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- //As generated by jackson mapper
- if (verboseOutput) {
- System.out.println("@@@@ OUTBOUND JSON#\n" + jsonToSend + "#");
- }
-
- //Execute the operation
- Result result = new Result();
- if (execute) {
- result = con.execute(op);
- } else {
- if (verboseOutput) {
- System.out.println("**** NOTE: Execution disabled . NOT exercising write-attribute operation. **** ");
- }
- }
- if (verboseOutput) {
- //result wrapper details
- System.out.println("\tResult:" + result);
- //detailed results
- System.out.println("\tValue:" + result.getResult());
- System.out.println("-----------------------------------------------------\n");
- }
- return result;
- }
-}
+///*
+// * 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 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.modules.plugins.jbossas7;
+//
+//import java.io.IOException;
+//import java.util.ArrayList;
+//import java.util.HashMap;
+//import java.util.LinkedHashMap;
+//import java.util.List;
+//
+//import org.codehaus.jackson.JsonGenerationException;
+//import org.codehaus.jackson.JsonNode;
+//import org.codehaus.jackson.JsonProcessingException;
+//import org.codehaus.jackson.map.JsonMappingException;
+//import org.codehaus.jackson.map.ObjectMapper;
+//import org.codehaus.jackson.map.SerializationConfig;
+//import org.testng.annotations.BeforeSuite;
+//import org.testng.annotations.Test;
+//
+//import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent.ModuleOptionType;
+//import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent.Value;
+//import org.rhq.modules.plugins.jbossas7.json.Address;
+//import org.rhq.modules.plugins.jbossas7.json.Operation;
+//import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
+//import org.rhq.modules.plugins.jbossas7.json.Remove;
+//import org.rhq.modules.plugins.jbossas7.json.Result;
+//import org.rhq.modules.plugins.jbossas7.json.WriteAttribute;
+//
+///**
+// * Test exercising the subsystem=security/SecurityDomain/[Authentication, Authorization, Mapping, Audit, Acl,
+// * Identity-Trust]
+// * @author Simeon Pinder
+// */
+//@Test(groups = "unit")
+//public class SecurityModuleOptionsTest extends AbstractConfigurationHandlingTest {
+//
+// private static String user = "rhqadmin";
+// private static String pass = "as7";
+// private static String host = "localhost";
+// private static ASConnection con = null;
+// private static ObjectMapper mapper = null;
+// private ModuleOptionsComponent moc = null;
+//
+// //Define some shared and reusable content
+// static HashMap<String, String> jsonMap = new HashMap<String, String>();
+// static {
+// jsonMap
+// .put(
+// "login-modules",
+// "[{\"flag\":\"required\", \"code\":\"Ldap\", \"module-options\":{\"bindDn\":\"uid=ldapSecureUser,ou=People,dc=redat,dc=com\", \"bindPw\":\"test126\", \"allowEmptyPasswords\":\"true\"}}]");
+// // "[{\"flag\":\"required\", \"code\":\"Ldap\"}]");
+// jsonMap
+// .put(
+// "policy-modules",
+// "[{\"flag\":\"requisite\", \"code\":\"LdapExtended\", \"module-options\":{\"policy\":\"module\", \"policy1\":\"module1\"}}]");
+// jsonMap
+// .put("mapping-modules",
+// "[{\"code\":\"Test\", \"type\":\"attribute\", \"module-options\":{\"mapping\":\"module\", \"mapping1\":\"module1\"}}]");
+// jsonMap.put("provider-modules",
+// "[{\"code\":\"Providers\", \"module-options\":{\"provider\":\"module\", \"provider1\":\"module1\"}}]");
+// }
+//
+// @BeforeSuite
+// private void initializeConnectionDetails() {
+// con = new ASConnection(host, 9990, user, pass);
+// mapper = new ObjectMapper();
+// mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
+//
+// moc = new ModuleOptionsComponent();
+// }
+//
+// public static void main(String[] args) {
+// SecurityModuleOptionsTest test = new SecurityModuleOptionsTest();
+// try {
+// test.initializeConnectionDetails();
+// test.testPopulateModuleOptionsAndTypes();
+// } catch (Exception e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+//
+// }
+//
+// /**The test reads the existing property values, deserializes them and writes the same
+// * contents back out to a running instance for all known ModuleOptionTypes.
+// *
+// * @throws Exception
+// */
+// public void testPopulateModuleOptionsAndTypes() throws Exception {
+//
+// //as7 node details.
+// String securityDomainId = "testDomain";
+// //TODO: spinder 6-6-12: this cannot run as a standalone itest until JIRA https://issues.jboss.org/browse/AS7-4951
+// // is addressed as there is no way to automate setup of the information being tested.
+// String address = "subsystem=security,security-domain=" + securityDomainId + ",authentication=classic";
+// boolean verboseOutput = true;
+// boolean executeOperation = true;
+// for (ModuleOptionType t : ModuleOptionType.values()) {
+// String attribute = t.getAttribute();
+// if (verboseOutput) {
+// System.out.println("======= Running with ModuleOptionType:" + t + " attribute:" + attribute + ":");
+// }
+// if (attribute.equals("policy-modules")) {
+// address = "subsystem=security,security-domain=" + securityDomainId + ",authorization=classic";
+// } else if (attribute.equals("acl-modules")) {
+// address = "subsystem=security,security-domain=" + securityDomainId + ",acl=classic";
+// } else if (attribute.equals("mapping-modules")) {
+// address = "subsystem=security,security-domain=" + securityDomainId + ",mapping=classic";
+// } else if (attribute.equals("trust-modules")) {
+// address = "subsystem=security,security-domain=" + securityDomainId + ",identity-trust=classic";
+// } else if (attribute.equals("provider-modules")) {
+// address = "subsystem=security,security-domain=" + securityDomainId + ",audit=classic";
+// } else if (attribute.equals("login-modules")) {
+// address = "subsystem=security,security-domain=" + securityDomainId + ",authentication=classic";
+// } else {
+// assert false : "An unknown attribute '" + attribute
+// + "' was found. Is there a new type to be supported?";
+// }
+//
+// //test operation- read property always available.
+// Operation op = null;
+//
+// //read the login-modules attribute
+// op = new ReadAttribute(new Address(address), attribute);
+// Result result = exerciseOperation(op, true, verboseOutput);
+// assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
+// + result.getFailureDescription();
+// //extract current results
+// Object rawResult = result.getResult();
+// assert rawResult != null : "Read of attribute'" + attribute + "' from address '" + address
+// + "' has returned no value. Are those values in the model?";
+//
+// List<Value> list2 = new ArrayList<Value>();
+// //populate the Value component complete with module Options.
+// list2 = moc.populateSecurityDomainModuleOptions(result,
+// ModuleOptionsComponent.loadModuleOptionType(attribute));
+// if (verboseOutput) {
+// if (rawResult != null) {
+// System.out.println("Raw Result is:" + rawResult + " and of type:" + rawResult.getClass());
+// } else {
+// System.out.println("Read of attribute'" + attribute + "' from address '" + address
+// + "' has returned no value. Are those values in the model?");
+// }
+// }
+// //write the login-modules attribute
+// op = new WriteAttribute(new Address(address));
+// op.addAdditionalProperty("name", attribute);//attribute to execute on
+// op.addAdditionalProperty("value", list2);
+//
+// //Now test the operation
+// result = exerciseOperation(op, executeOperation, verboseOutput);
+// assert ((result.isSuccess() == true) || (result.getOutcome() == null)) : "The operation '" + op
+// + "' failed to write the resource.." + result.getFailureDescription();
+//
+// //read the login-modules attribute
+// op = new ReadAttribute(new Address(address), attribute);
+// result = exerciseOperation(op, true, verboseOutput);
+// assert (result.isSuccess() == true) : "The operation '" + op + "' failed to read the resource."
+// + result.getFailureDescription();
+// }
+// if (verboseOutput) {
+// System.out.println("Successfully detected,read and wrote out attribute values for:");
+// for (ModuleOptionType type : ModuleOptionType.values()) {
+// System.out.println("\n" + type.ordinal() + " " + type.name());
+// }
+// }
+// }
+//
+// /**Attempts to create a new Authentication node(authentication=classic) with a
+// * 'login-modules' attribute complete with 'code':'Ldap' and 'flag':'required'
+// * and some sample 'module-options' values.
+// *
+// */
+// @Test(enabled = true)
+// public void testCreateSecurityDomainChildLoginModules() {
+// boolean execute = true;
+// boolean verboseOutput = false;
+// String address = "subsystem=security,security-domain=testDomain3,authentication=classic";
+// String attribute = ModuleOptionType.Authentication.getAttribute();
+//
+// //test operation- read property always available.
+// Operation op = null;
+//
+// //read the login-modules attribute
+// op = new ReadAttribute(new Address(address), attribute);
+// Result result = exerciseOperation(op, execute, verboseOutput);
+// assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
+// + result.getFailureDescription();
+//
+// //extract current results
+// Object rawResult = result.getResult();
+//
+// //#### Have to create new content for the new node.
+// List<Value> moduleTypeValue = new ArrayList<Value>();
+// try {
+// // loading 'login-module'
+// JsonNode node = mapper.readTree(jsonMap.get(attribute));
+// result.setResult(mapper.treeToValue(node, Object.class));
+// } catch (JsonProcessingException e) {
+// e.printStackTrace();
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+//
+// //populate the Value component complete with module Options.
+// moduleTypeValue = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
+// ModuleOptionsComponent.loadModuleOptionType(attribute));
+//
+// //add the login-modules attribute
+// op = ModuleOptionsComponent
+// .createAddModuleOptionTypeOperation(new Address(address), attribute, moduleTypeValue);
+//
+// result = exerciseOperation(op, execute, verboseOutput);
+// assert ((result.isSuccess() == true) || (result.getOutcome() == null)) : "The operation '" + op
+// + "' failed to write the resource.." + result.getFailureDescription();
+//
+// //read the login-modules attribute
+// op = new ReadAttribute(new Address(address), attribute);
+// result = exerciseOperation(op, execute, verboseOutput);
+// assert result.isSuccess() == true : "The operation '" + op + "' failed to read the resource."
+// + result.getFailureDescription();
+//
+// //exercise values retrieved from read
+// List<Value> serverResponse = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
+// ModuleOptionsComponent.loadModuleOptionType(attribute));
+// Value serverState = serverResponse.get(0);
+// assert serverState.getFlag().equals("required") : "Incorrect state retrieved for 'flag'. Expected 'required'.";
+// assert serverState.getCode().equals("Ldap") : "Incorrect state retrieved for 'code'. Expected 'Ldap'.";
+// LinkedHashMap<String, Object> options = serverState.getOptions();
+// assert options.size() == 3 : "Invalid number of module options returned. Expected 3.";
+// int found = 0;
+// for (String key : options.keySet()) {
+// if (key.equals("bindPw")) {
+// assert "test126".equals(options.get(key)) : "Module option value not correct for key '" + key + "'.";
+// found++;
+// } else if (key.equals("bindDn")) {
+// assert "uid=ldapSecureUser,ou=People,dc=redat,dc=com".equals(options.get(key)) : "Module option value not correct for key '"
+// + key + "'.";
+// found++;
+// } else if (key.equals("allowEmptyPasswords")) {
+// assert "true".equals(options.get(key)) : "Module option value not correct for key '" + key + "'.";
+// found++;
+// }
+// }
+// assert found == 3 : "All module options were not loaded.";
+//
+// //remove the original node to reset for next run.
+// op = new Remove(new Address(address));
+// result = exerciseOperation(op, execute, verboseOutput);
+// assert result.isSuccess() == true : "The operation '" + op + "' failed to remove the resource."
+// + result.getFailureDescription();
+// }
+//
+// /** For each operation
+// * - will write verbose json and operation details to system.out if verboseOutput = true;
+// * - will execute the operation against running server if execute = true.
+// *
+// * @param op
+// * @param execute
+// * @param verboseOutput
+// * @return
+// */
+// public static Result exerciseOperation(Operation op, boolean execute, boolean verboseOutput) {
+// //display operation as AS7 plugin will build it
+// if (verboseOutput) {
+// System.out.println("\tOperation is:" + op);
+// }
+//
+// String jsonToSend = "";
+// try {
+// // jsonToSend = mapper.writeValueAsString(op);
+// jsonToSend = mapper.defaultPrettyPrintingWriter().writeValueAsString(op);
+// } catch (JsonGenerationException e) {
+// e.printStackTrace();
+// } catch (JsonMappingException e) {
+// e.printStackTrace();
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// //As generated by jackson mapper
+// if (verboseOutput) {
+// System.out.println("@@@@ OUTBOUND JSON#\n" + jsonToSend + "#");
+// }
+//
+// //Execute the operation
+// Result result = new Result();
+// if (execute) {
+// result = con.execute(op);
+// } else {
+// if (verboseOutput) {
+// System.out.println("**** NOTE: Execution disabled . NOT exercising write-attribute operation. **** ");
+// }
+// }
+// if (verboseOutput) {
+// //result wrapper details
+// System.out.println("\tResult:" + result);
+// //detailed results
+// System.out.println("\tValue:" + result.getResult());
+// System.out.println("-----------------------------------------------------\n");
+// }
+// return result;
+// }
+//}
commit c9b69bbf92000a6cee0773eb51a34aaf41e57fff
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 20 11:28:09 2012 +0200
Expose more group properties.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
index 7f13618..5fa0089 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
@@ -249,13 +249,9 @@ public class GroupHandlerBean extends AbstractRestBean implements GroupHandlerLo
*/
private ResourceGroup fetchGroup(int groupId) {
ResourceGroup resourceGroup;
- resourceGroup = getFromCache(groupId,ResourceGroup.class);
- if (resourceGroup==null) {
- resourceGroup = resourceGroupManager.getResourceGroup(caller, groupId);
- if (resourceGroup==null)
- throw new StuffNotFoundException("Group with id " + groupId);
- putToCache(groupId,ResourceGroup.class,resourceGroup);
- }
+ resourceGroup = resourceGroupManager.getResourceGroup(caller, groupId);
+ if (resourceGroup==null)
+ throw new StuffNotFoundException("Group with id " + groupId);
return resourceGroup;
}
@@ -267,6 +263,10 @@ public class GroupHandlerBean extends AbstractRestBean implements GroupHandlerLo
gr.setId(group.getId());
gr.setCategory(group.getGroupCategory());
gr.setRecursive(group.isRecursive());
+ if (group.getGroupDefinition()!=null)
+ gr.setDynaGroupDefinitionId(group.getGroupDefinition().getId());
+ gr.setExplicitCount(group.getExplicitResources().size());
+ gr.setImplicitCount(group.getImplicitResources().size());
UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
uriBuilder.path("/group/{id}");
URI uri = uriBuilder.build(group.getId());
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java
index 4c9079b..c43f911 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/GroupRest.java
@@ -21,6 +21,9 @@ public class GroupRest {
private Integer resourceTypeId;
private boolean recursive;
private GroupCategory category;
+ private int dynaGroupDefinitionId;
+ private int explicitCount;
+ private int implicitCount;
List<Link> links = new ArrayList<Link>();
@@ -79,4 +82,28 @@ public class GroupRest {
public void setLinks(List<Link> links) {
this.links = links;
}
+
+ public int getDynaGroupDefinitionId() {
+ return dynaGroupDefinitionId;
+ }
+
+ public void setDynaGroupDefinitionId(int dynaGroupDefinitionId) {
+ this.dynaGroupDefinitionId = dynaGroupDefinitionId;
+ }
+
+ public int getExplicitCount() {
+ return explicitCount;
+ }
+
+ public void setExplicitCount(int explicitCount) {
+ this.explicitCount = explicitCount;
+ }
+
+ public int getImplicitCount() {
+ return implicitCount;
+ }
+
+ public void setImplicitCount(int implicitCount) {
+ this.implicitCount = implicitCount;
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/resources/rest_templates/group.ftl b/modules/enterprise/server/jar/src/main/resources/rest_templates/group.ftl
index 6edaf99..03a69bb 100644
--- a/modules/enterprise/server/jar/src/main/resources/rest_templates/group.ftl
+++ b/modules/enterprise/server/jar/src/main/resources/rest_templates/group.ftl
@@ -44,6 +44,17 @@
<tr>
<td>Recursive</td><td>${var.recursive?string("Yes","No")}</td>
</tr>
+ <tr>
+ <td>DynaGroup</td><td>${(var.dynaGroupDefinitionId > 0)?string("Yes","No")}</td>
+ </tr>
+ <tr>
+ <td>Resource Count</td>
+ <td>${var.explicitCount}
+ <#if var.recursive>
+ ( Implicit: ${var.implicitCount} )
+ </#if>
+ </td>
+ </tr>
</table>
<a href="/rest/1/group/${var.id?c}/resources.html">Resources</a><br/>
</html>
commit 76dee23a84b0a14362f8ed22be6f5e8b6e4ba707
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 19 21:10:16 2012 +0200
Use the same job id over the place to prevent IndexOutOfBoundExceptions later.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java
index cb233f8..d8b9851 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java
@@ -296,13 +296,14 @@ public class OperationsHandlerBean extends AbstractRestBean implements Operation
MediaType mediaType = httpHeaders.getAcceptableMediaTypes().get(0);
ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
- criteria.addFilterJobId(new JobId(jobName));
+ JobId jobId = new JobId(jobName);
+ criteria.addFilterJobId(jobId);
ResourceOperationHistory history ;//= opsManager.getOperationHistoryByJobId(caller,jobName);
List<ResourceOperationHistory> list = opsManager.findResourceOperationHistoriesByCriteria(caller,criteria);
if (list==null || list.isEmpty()) {
- log.info("No history with id " + new HistoryJobId(jobName) + " found");
- throw new StuffNotFoundException("OperationHistory with id " + new HistoryJobId(jobName));
+ log.info("No history with id " + jobId + " found");
+ throw new StuffNotFoundException("OperationHistory with id " + jobId);
}
history = list.get(0);
commit 6528df9ea4eb462faed0504089faa21b55671a79
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 19 18:07:05 2012 +0200
Prevent a possible "No session exception"
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java
index a4bc84e..79012a1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java
@@ -327,13 +327,13 @@ public class AbstractRestBean {
return true;
}
- public ResourceWithType fillRWT(org.rhq.core.domain.resource.Resource res, UriInfo uriInfo) {
+ public ResourceWithType fillRWT(Resource res, UriInfo uriInfo) {
ResourceType resourceType = res.getResourceType();
ResourceWithType rwt = new ResourceWithType(res.getName(),res.getId());
rwt.setTypeName(resourceType.getName());
rwt.setTypeId(resourceType.getId());
rwt.setPluginName(resourceType.getPlugin());
- org.rhq.core.domain.resource.Resource parent = res.getParentResource();
+ Resource parent = res.getParentResource();
if (parent!=null) {
rwt.setParentId(parent.getId());
}
@@ -382,6 +382,10 @@ public class AbstractRestBean {
protected Resource fetchResource(int resourceId) {
Resource res;
+ res = resMgr.getResource(caller, resourceId);
+ if (res==null)
+ throw new StuffNotFoundException("Resource with id " + resourceId);
+/*
res = getFromCache(resourceId, Resource.class);
if (res == null) {
res = resMgr.getResource(caller, resourceId);
@@ -390,6 +394,7 @@ public class AbstractRestBean {
else
throw new StuffNotFoundException("Resource with id " + resourceId);
}
+*/
return res;
}
}
11 years, 10 months
[rhq] 2 commits - modules/core modules/enterprise
by mike thompson
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionList.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 406 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java | 24
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java | 40
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_cs.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_ru.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 2
13 files changed, 267 insertions(+), 241 deletions(-)
New commits:
commit c80c45065a6e0f1977e0c04fae5a8f05593ecd40
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Thu Jul 12 14:14:36 2012 -0700
For Test page move save button to bottom of screen for consistency.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
index 9d2d1a2..52e3c69 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
@@ -80,13 +80,11 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
protected void onDraw() {
super.onDraw();
- //createButtonBar();
-
refresh();
if (!this.resourcePermission.isConfigureWrite()) {
- Message message = new Message(MSG.view_configurationDetails_noPermission(), Message.Severity.Info, EnumSet
- .of(Message.Option.Transient, Message.Option.Sticky));
+ Message message = new Message(MSG.view_configurationDetails_noPermission(), Message.Severity.Info,
+ EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
CoreGUI.getMessageCenter().notify(message);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java
index 31d17a3..b0d9154 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java
@@ -51,6 +51,7 @@ public class TestConfigurationView
private ConfigurationEditor editor;
private LocatableIButton saveButton;
+ private LocatableToolStrip buttonBar;
private ConfigurationDefinition configurationDefinition;
private Configuration configuration;
@@ -67,7 +68,16 @@ public class TestConfigurationView
public void build() {
setWidth100();
setHeight100();
-
+
+ buttonBar = createButtonBar();
+
+ this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition();
+ this.configuration = TestConfigurationFactory.createConfiguration();
+
+ reloadConfiguration();
+ }
+
+ private LocatableToolStrip createButtonBar() {
LocatableToolStrip toolStrip = new LocatableToolStrip(extendLocatorId("ToolStrip"));
toolStrip.setWidth100();
@@ -81,13 +91,8 @@ public class TestConfigurationView
});
this.saveButton.disable();
toolStrip.addMember(this.saveButton);
-
- addMember(toolStrip);
-
- this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition();
- this.configuration = TestConfigurationFactory.createConfiguration();
-
- reloadConfiguration();
+ toolStrip.addSpacer(40);
+ return toolStrip;
}
@Override
@@ -120,10 +125,13 @@ public class TestConfigurationView
if (editor != null) {
editor.destroy();
removeMember(editor);
+ buttonBar.destroy();
+ removeMember(buttonBar);
}
editor = createConfigurationEditor();
addMember(editor);
+ addMember(createButtonBar());
markForRedraw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java
index d2d9c94..054af8e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java
@@ -53,6 +53,7 @@ public class TestGroupConfigurationView
private ConfigurationEditor editor;
private LocatableIButton saveButton;
+ private ToolStrip buttonBar;
private ConfigurationDefinition configurationDefinition;
private List<GroupMemberConfiguration> memberConfigurations;
@@ -67,22 +68,6 @@ public class TestGroupConfigurationView
setWidth100();
setHeight100();
- ToolStrip toolStrip = new ToolStrip();
- toolStrip.setWidth100();
-
- toolStrip.addMember(new LayoutSpacer());
-
- this.saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
- this.saveButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- save();
- }
- });
- this.saveButton.disable();
- toolStrip.addMember(this.saveButton);
-
- addMember(toolStrip);
-
this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition();
this.memberConfigurations = new ArrayList<GroupMemberConfiguration>(GROUP_SIZE);
for (int i = 0; i < GROUP_SIZE; i++) {
@@ -91,10 +76,26 @@ public class TestGroupConfigurationView
configuration);
this.memberConfigurations.add(memberConfiguration);
}
-
reloadConfiguration();
}
+ private ToolStrip createButtonBar() {
+ buttonBar = new ToolStrip();
+ buttonBar.setWidth100();
+ buttonBar.addMember(new LayoutSpacer());
+
+ this.saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
+ this.saveButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ save();
+ }
+ });
+ this.saveButton.disable();
+ buttonBar.addMember(this.saveButton);
+ buttonBar.addSpacer(40);
+ return buttonBar;
+ }
+
@Override
public void propertyValueChanged(PropertyValueChangeEvent event) {
MessageCenter messageCenter = CoreGUI.getMessageCenter();
@@ -120,14 +121,17 @@ public class TestGroupConfigurationView
}
private void reloadConfiguration() {
- this.saveButton.disable();
if (editor != null) {
editor.destroy();
removeMember(editor);
+ buttonBar.destroy();
+ removeMember(buttonBar);
}
editor = createConfigurationEditor();
addMember(editor);
+ addMember(createButtonBar());
+ markForRedraw();
}
protected GroupConfigurationEditor createConfigurationEditor() {
commit 336ce7c5c794775f7517fbc3a0770ffa2d3e7974
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Thu Jul 12 13:02:59 2012 -0700
[BZ 815305] Min/max constraints on plugin PropertyList not honored in UI.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionList.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionList.java
index 4c85a62..92c8df6 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionList.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionList.java
@@ -33,6 +33,8 @@ import javax.xml.bind.annotation.XmlSeeAlso;
import org.jetbrains.annotations.NotNull;
+import java.lang.Integer;
+
/**
* The definition of a list of properties where each member of the list has the same definition. The definition of the
* entries may be null in the case of arbitrary lists.
@@ -46,17 +48,9 @@ import org.jetbrains.annotations.NotNull;
public class PropertyDefinitionList extends PropertyDefinition {
private static final long serialVersionUID = 1L;
- /**
- * See JBNADM-1595
- */
- @Transient
- private int min;
+ private int min = 0;
- /**
- * See JBNADM-1595
- */
- @Transient
- private int max;
+ private int max = Integer.MAX_VALUE;
@JoinColumn(name = "parent_list_definition_id")
@OneToOne(cascade = CascadeType.ALL)
@@ -99,4 +93,4 @@ public class PropertyDefinitionList extends PropertyDefinition {
public void setMin(int min) {
this.min = min;
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 48df2d6..aec7274 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -293,78 +293,86 @@ public class ConfigurationEditor extends LocatableVLayout {
if (configurationDefinition == null || configuration == null) {
if (configType == ConfigType.resource) {
- configurationService.getResourceConfiguration(resourceId, new AsyncCallback<Configuration>() {
- public void onFailure(Throwable caught) {
- showError(caught);
- if (loadHandler != null) {
- loadHandler.loadedConfiguration(null);
- }
- }
+ loadResourceConfiguration(start);
- public void onSuccess(Configuration result) {
- configuration = result;
- Log.info("Config retrieved in: " + (System.currentTimeMillis() - start));
- reload();
- if (loadHandler != null) {
- loadHandler.loadedConfiguration(configuration);
- }
- }
- });
+ } else if (configType == ConfigType.plugin) {
+ loadPluginConfiguration(start);
+ }
+ }
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(new Integer[] { resourceTypeId },
- EnumSet.of(ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
- new ResourceTypeRepository.TypesLoadedCallback() {
- public void onTypesLoaded(Map<Integer, ResourceType> types) {
- Log.debug("ConfigDef retrieved in: " + (System.currentTimeMillis() - start));
- configurationDefinition = types.get(resourceTypeId).getResourceConfigurationDefinition();
- if (configurationDefinition == null) {
- loadingLabel.hide();
- showError(MSG.view_configEdit_error_1());
- }
- reload();
- if (loadHandler != null) {
- loadHandler.loadedConfigurationDefinition(configurationDefinition);
- }
- }
- });
+ reload();
+ }
- } else if (configType == ConfigType.plugin) {
- configurationService.getPluginConfiguration(resourceId, new AsyncCallback<Configuration>() {
- public void onFailure(Throwable caught) {
- showError(caught);
- if (loadHandler != null) {
- loadHandler.loadedConfiguration(null);
- }
- }
+ private void loadPluginConfiguration(final long start) {
+ configurationService.getPluginConfiguration(resourceId, new AsyncCallback<Configuration>() {
+ public void onFailure(Throwable caught) {
+ showError(caught);
+ if (loadHandler != null) {
+ loadHandler.loadedConfiguration(null);
+ }
+ }
- public void onSuccess(Configuration result) {
- configuration = result;
- reload();
- if (loadHandler != null) {
- loadHandler.loadedConfiguration(configuration);
- }
+ public void onSuccess(Configuration result) {
+ configuration = result;
+ reload();
+ if (loadHandler != null) {
+ loadHandler.loadedConfiguration(configuration);
+ }
+ }
+ });
+
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(new Integer[] { resourceTypeId },
+ EnumSet.of(ResourceTypeRepository.MetadataType.pluginConfigurationDefinition),
+ new ResourceTypeRepository.TypesLoadedCallback() {
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ Log.debug("ConfigDef retrieved in: " + (System.currentTimeMillis() - start));
+ configurationDefinition = types.get(resourceTypeId).getPluginConfigurationDefinition();
+ if (configurationDefinition == null) {
+ showError(MSG.view_configEdit_error_2());
}
- });
+ reload();
+ if (loadHandler != null) {
+ loadHandler.loadedConfigurationDefinition(configurationDefinition);
+ }
+ }
+ });
+ }
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(new Integer[] { resourceTypeId },
- EnumSet.of(ResourceTypeRepository.MetadataType.pluginConfigurationDefinition),
- new ResourceTypeRepository.TypesLoadedCallback() {
- public void onTypesLoaded(Map<Integer, ResourceType> types) {
- Log.debug("ConfigDef retrieved in: " + (System.currentTimeMillis() - start));
- configurationDefinition = types.get(resourceTypeId).getPluginConfigurationDefinition();
- if (configurationDefinition == null) {
- showError(MSG.view_configEdit_error_2());
- }
- reload();
- if (loadHandler != null) {
- loadHandler.loadedConfigurationDefinition(configurationDefinition);
- }
- }
- });
+ private void loadResourceConfiguration(final long start) {
+ configurationService.getResourceConfiguration(resourceId, new AsyncCallback<Configuration>() {
+ public void onFailure(Throwable caught) {
+ showError(caught);
+ if (loadHandler != null) {
+ loadHandler.loadedConfiguration(null);
+ }
}
- }
- reload();
+ public void onSuccess(Configuration result) {
+ configuration = result;
+ Log.info("Config retrieved in: " + (System.currentTimeMillis() - start));
+ reload();
+ if (loadHandler != null) {
+ loadHandler.loadedConfiguration(configuration);
+ }
+ }
+ });
+
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(new Integer[] { resourceTypeId },
+ EnumSet.of(ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
+ new ResourceTypeRepository.TypesLoadedCallback() {
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ Log.debug("ConfigDef retrieved in: " + (System.currentTimeMillis() - start));
+ configurationDefinition = types.get(resourceTypeId).getResourceConfigurationDefinition();
+ if (configurationDefinition == null) {
+ loadingLabel.hide();
+ showError(MSG.view_configEdit_error_1());
+ }
+ reload();
+ if (loadHandler != null) {
+ loadHandler.loadedConfigurationDefinition(configurationDefinition);
+ }
+ }
+ });
}
public void reload() {
@@ -389,7 +397,7 @@ public class ConfigurationEditor extends LocatableVLayout {
if (configurationDefinition.getConfigurationFormat() == ConfigurationFormat.STRUCTURED
|| configurationDefinition.getConfigurationFormat() == ConfigurationFormat.STRUCTURED_AND_RAW) {
- Log.info("Building structured configuration editor...");
+ Log.debug("Building structured configuration editor...");
LocatableVLayout structuredConfigLayout = buildStructuredPane();
addMember(structuredConfigLayout);
} else {
@@ -561,31 +569,18 @@ public class ConfigurationEditor extends LocatableVLayout {
}
private void addHeaderItems(List<FormItem> fields) {
- final String CELL_STYLE = "configurationEditorHeaderCell";
-
- StaticTextItem nameHeader = new StaticTextItem();
- nameHeader.setValue(MSG.view_configEdit_property());
- nameHeader.setShowTitle(false);
- nameHeader.setCellStyle(CELL_STYLE);
- fields.add(nameHeader);
+ fields.add(createHeaderTextItem(MSG.view_configEdit_property()));
+ fields.add(createHeaderTextItem(MSG.view_configEdit_unset()));
+ fields.add(createHeaderTextItem(MSG.common_title_value()));
+ fields.add(createHeaderTextItem(MSG.common_title_description()));
+ }
+ private StaticTextItem createHeaderTextItem(String value){
StaticTextItem unsetHeader = new StaticTextItem();
- unsetHeader.setValue(MSG.view_configEdit_unset());
+ unsetHeader.setValue(value);
unsetHeader.setShowTitle(false);
- unsetHeader.setCellStyle(CELL_STYLE);
- fields.add(unsetHeader);
-
- StaticTextItem valueHeader = new StaticTextItem();
- valueHeader.setValue(MSG.common_title_value());
- valueHeader.setShowTitle(false);
- valueHeader.setCellStyle(CELL_STYLE);
- fields.add(valueHeader);
-
- StaticTextItem descriptionHeader = new StaticTextItem();
- descriptionHeader.setValue(MSG.common_title_description());
- descriptionHeader.setShowTitle(false);
- descriptionHeader.setCellStyle(CELL_STYLE);
- fields.add(descriptionHeader);
+ unsetHeader.setCellStyle("configurationEditorHeaderCell");
+ return unsetHeader;
}
private void addItemsForPropertiesRecursively(String locatorId, Collection<PropertyDefinition> propertyDefinitions,
@@ -618,6 +613,7 @@ public class ConfigurationEditor extends LocatableVLayout {
fieldsForThisProperty = buildFieldsForPropertySimple(propertyDefinition, propertyDefinitionSimple,
propertySimple);
} else if (propertyDefinition instanceof PropertyDefinitionList) {
+ ///@TODO
PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
PropertyDefinition memberDefinition = propertyDefinitionList.getMemberDefinition();
PropertyList propertyList = (PropertyList) property;
@@ -688,7 +684,6 @@ public class ConfigurationEditor extends LocatableVLayout {
} else if (memberDefinition instanceof PropertyDefinitionSimple) {
SpacerItem spacerItem = new SpacerItem();
fields.add(spacerItem);
-
CanvasItem listOfSimplesItem = buildListOfSimplesField(locatorId, propertyDefinitionList, propertyList);
fields.add(listOfSimplesItem);
@@ -1005,12 +1000,16 @@ public class ConfigurationEditor extends LocatableVLayout {
SC.confirm(MSG.view_configEdit_confirm_2(), new BooleanCallback() {
public void execute(Boolean confirmed) {
if (confirmed) {
- PropertyMapListGridRecord recordToBeDeleted = (PropertyMapListGridRecord) recordClickEvent
- .getRecord();
- propertyList.getList().remove(recordToBeDeleted.getIndex());
- ListGridRecord[] rows = buildSummaryRecords(propertyList, propertyDefinitions);
- summaryTable.setData(rows);
- firePropertyChangedEvent(propertyList, propertyDefinitionList, true);
+ if( summaryTable.getRecordList().getLength() <= propertyDefinitionList.getMin()){
+ SC.say(MSG.view_configEdit_minBoundsExceeded(String.valueOf(propertyDefinitionList.getMin())));
+ }else {
+ PropertyMapListGridRecord recordToBeDeleted = (PropertyMapListGridRecord) recordClickEvent
+ .getRecord();
+ propertyList.getList().remove(recordToBeDeleted.getIndex());
+ ListGridRecord[] rows = buildSummaryRecords(propertyList, propertyDefinitions);
+ summaryTable.setData(rows);
+ firePropertyChangedEvent(propertyList, propertyDefinitionList, true);
+ }
}
}
});
@@ -1109,7 +1108,6 @@ public class ConfigurationEditor extends LocatableVLayout {
final DynamicForm listGrid = new DynamicForm();
vLayout.addMember(listGrid);
- // TODO (ips, 03/14/11): Make this a ListGrid, rather than a SelectItem.
final SelectItem membersItem = new SelectItem(propertyList.getName());
membersItem.setShowTitle(false);
membersItem.setMultiple(true);
@@ -1138,28 +1136,32 @@ public class ConfigurationEditor extends LocatableVLayout {
final String noun = (selectedValues.length == 1) ? MSG.common_label_item() : MSG
.common_label_items();
String message = MSG.view_configEdit_confirm_3(Integer.toString(selectedValues.length), noun);
- SC.ask(message, new BooleanCallback() {
- public void execute(Boolean confirmed) {
- if (confirmed) {
- for (int i = selectedValues.length - 1; i >= 0; i--) {
- String selectedValue = selectedValues[i];
- int index = Integer.valueOf(selectedValue);
- propertyList.getList().remove(index);
-
- // Rebuild the select item options.
- LinkedHashMap<String, String> memberValueToIndexMap = buildValueMap(propertyList);
- membersItem.setValueMap(memberValueToIndexMap);
-
- deleteButton.disable();
-
- firePropertyChangedEvent(propertyList, propertyDefinitionList, true);
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_configEdit_msg_3(Integer.toString(selectedValues.length),
- noun), EnumSet.of(Message.Option.Transient)));
+ if(propertyList.getList().size() <= propertyDefinitionList.getMin()){
+ SC.say("You cannot delete this entry because the minimum size bounds has been met: "+ propertyDefinitionList.getMin());
+ }else {
+ SC.ask(message, new BooleanCallback() {
+ public void execute(Boolean confirmed) {
+ if (confirmed) {
+ for (int i = selectedValues.length - 1; i >= 0; i--) {
+ String selectedValue = selectedValues[i];
+ int index = Integer.valueOf(selectedValue);
+ propertyList.getList().remove(index);
+
+ // Rebuild the select item options.
+ LinkedHashMap<String, String> memberValueToIndexMap = buildValueMap(propertyList);
+ membersItem.setValueMap(memberValueToIndexMap);
+
+ deleteButton.disable();
+
+ firePropertyChangedEvent(propertyList, propertyDefinitionList, true);
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_configEdit_msg_3(Integer.toString(selectedValues.length),
+ noun), EnumSet.of(Message.Option.Transient)));
+ }
}
}
- }
- });
+ });
+ }
}
});
footer.addMember(deleteButton);
@@ -1178,93 +1180,92 @@ public class ConfigurationEditor extends LocatableVLayout {
newButton.setTooltip(MSG.view_configEdit_tooltip_2());
newButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- final Window popup = new Window();
- popup.setTitle(MSG.view_configEdit_addItem());
- popup.setWidth(300);
- popup.setHeight(145);
- popup.setIsModal(true);
- popup.setShowModalMask(true);
- popup.setShowCloseButton(false);
- popup.centerInPage();
-
- VLayout vLayout = new VLayout();
- vLayout.setMargin(10);
-
- HTMLFlow description = new HTMLFlow(propertyDefinitionList.getDescription());
- vLayout.addMember(description);
-
- final DynamicForm form = new DynamicForm();
-
- PropertyDefinitionSimple memberPropertyDefinitionSimple = (PropertyDefinitionSimple) propertyDefinitionList
- .getMemberDefinition();
- final String propertyName = memberPropertyDefinitionSimple.getName();
- final PropertySimple newMemberPropertySimple = new PropertySimple(propertyName, null);
-
- FormItem simpleField = buildSimpleField(memberPropertyDefinitionSimple, newMemberPropertySimple);
- simpleField.setTitle(memberPropertyDefinitionSimple.getDisplayName());
- simpleField.setShowTitle(true);
- simpleField.setAlign(Alignment.CENTER);
- simpleField.setDisabled(false);
- simpleField.setRequired(true);
- simpleField.setEndRow(true);
-
- SpacerItem spacer = new SpacerItem();
- spacer.setHeight(9);
-
- form.setItems(simpleField, spacer);
- vLayout.addMember(form);
-
- final IButton okButton = new LocatableIButton(extendLocatorId("OK"), MSG.common_button_ok());
- okButton.disable();
- okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- propertyList.add(newMemberPropertySimple);
- // Rebuild the select item options.
- LinkedHashMap<String, String> memberValueToIndexMap = buildValueMap(propertyList);
- membersItem.setValueMap(memberValueToIndexMap);
+ if(propertyList.getList().size() >= propertyDefinitionList.getMax()){
+ SC.say(MSG.view_configEdit_maxBoundsExceeded(String.valueOf(propertyDefinitionList.getMax())));
+ }else {
+ final LocatableWindow popup = createPopup(MSG.view_configEdit_addItem(), 300, 145);
- firePropertyChangedEvent(propertyList, propertyDefinitionList, true);
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_configEdit_msg_4(), EnumSet.of(Message.Option.Transient)));
+ VLayout vLayout = new VLayout();
+ vLayout.setMargin(10);
- popup.destroy();
- }
- });
+ HTMLFlow description = new HTMLFlow(propertyDefinitionList.getDescription());
+ vLayout.addMember(description);
- form.addItemChangedHandler(new ItemChangedHandler() {
- public void onItemChanged(ItemChangedEvent itemChangedEvent) {
- Object newValue = itemChangedEvent.getNewValue();
- newMemberPropertySimple.setValue(newValue);
+ final DynamicForm form = new DynamicForm();
- // Only enable the OK button, allowing the user to add the property to the map, if the
- // property is valid.
- boolean isValid = form.validate();
- okButton.setDisabled(!isValid);
- }
- });
+ PropertyDefinitionSimple memberPropertyDefinitionSimple = (PropertyDefinitionSimple) propertyDefinitionList
+ .getMemberDefinition();
+ final String propertyName = memberPropertyDefinitionSimple.getName();
+ final PropertySimple newMemberPropertySimple = new PropertySimple(propertyName, null);
- final IButton cancelButton = new LocatableIButton(extendLocatorId("Cancel"), MSG
- .common_button_cancel());
- cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- popup.destroy();
- }
- });
+ FormItem simpleField = buildSimpleField(memberPropertyDefinitionSimple, newMemberPropertySimple);
+ simpleField.setTitle(memberPropertyDefinitionSimple.getDisplayName());
+ simpleField.setShowTitle(true);
+ simpleField.setAlign(Alignment.CENTER);
+ simpleField.setDisabled(false);
+ simpleField.setRequired(true);
+ simpleField.setEndRow(true);
+
+ SpacerItem spacer = new SpacerItem();
+ spacer.setHeight(9);
+
+ form.setItems(simpleField, spacer);
+ vLayout.addMember(form);
+
+ final IButton okButton = new LocatableIButton(extendLocatorId("OK"), MSG.common_button_ok());
+ okButton.disable();
+ okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ propertyList.add(newMemberPropertySimple);
+
+ // Rebuild the select item options.
+ LinkedHashMap<String, String> memberValueToIndexMap = buildValueMap(propertyList);
+ membersItem.setValueMap(memberValueToIndexMap);
+
+ firePropertyChangedEvent(propertyList, propertyDefinitionList, true);
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_configEdit_msg_4(), EnumSet.of(Message.Option.Transient)));
+
+ popup.destroy();
+ }
+ });
- HLayout buttons = new HLayout();
- buttons.setAlign(Alignment.CENTER);
- buttons.setTop(10);
- buttons.setMembersMargin(10);
- buttons.setMembers(okButton, cancelButton);
- vLayout.addMember(buttons);
+ form.addItemChangedHandler(new ItemChangedHandler() {
+ public void onItemChanged(ItemChangedEvent itemChangedEvent) {
+ Object newValue = itemChangedEvent.getNewValue();
+ newMemberPropertySimple.setValue(newValue);
- popup.addItem(vLayout);
- popup.show();
+ // Only enable the OK button, allowing the user to add the property to the map, if the
+ // property is valid.
+ boolean isValid = form.validate();
+ okButton.setDisabled(!isValid);
+ }
+ });
+
+ final IButton cancelButton = new LocatableIButton(extendLocatorId("Cancel"), MSG
+ .common_button_cancel());
+ cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ popup.destroy();
+ }
+ });
- simpleField.focusInItem();
+ HLayout buttons = new HLayout();
+ buttons.setAlign(Alignment.CENTER);
+ buttons.setTop(10);
+ buttons.setMembersMargin(10);
+ buttons.setMembers(okButton, cancelButton);
+ vLayout.addMember(buttons);
+
+ popup.addItem(vLayout);
+ popup.show();
+
+ simpleField.focusInItem();
}
+ }
});
+
footer.addMember(newButton);
}
@@ -1675,15 +1676,8 @@ public class ConfigurationEditor extends LocatableVLayout {
final PropertyMap workingMap = (newRow) ? new PropertyMap(memberMapDefinition.getName()) : memberMap
.deepCopy(true);
- final LocatableWindow popup = new LocatableWindow(extendLocatorId("MapEditor"));
- String title = (mapReadOnly) ? MSG.view_configEdit_viewRow() : MSG.view_configEdit_editRow();
- popup.setTitle(title);
- popup.setWidth(800);
- popup.setHeight(600);
- popup.setIsModal(true);
- popup.setShowModalMask(true);
- popup.setShowCloseButton(false);
- popup.centerInPage();
+ final String title = (mapReadOnly) ? MSG.view_configEdit_viewRow() : MSG.view_configEdit_editRow();
+ final LocatableWindow popup = createPopup(title, 800, 600);
final LocatableVLayout layout = new LocatableVLayout(popup.extendLocatorId("Layout"));
layout.setHeight100();
@@ -1756,6 +1750,18 @@ public class ConfigurationEditor extends LocatableVLayout {
popup.show();
}
+ private LocatableWindow createPopup(String title, int width, int height) {
+ final LocatableWindow popup = new LocatableWindow(extendLocatorId("MapEditor"));
+ popup.setTitle(title);
+ popup.setWidth(width);
+ popup.setHeight(height);
+ popup.setIsModal(true);
+ popup.setShowModalMask(true);
+ popup.setShowCloseButton(false);
+ popup.centerInPage();
+ return popup;
+ }
+
private void mergePropertyMap(PropertyMap sourceMap, PropertyMap targetMap,
List<PropertyDefinition> memberDefinitions) {
for (PropertyDefinition subDef : memberDefinitions) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
index 2142764..c4cc0f7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
@@ -138,6 +138,8 @@ public abstract class TestConfigurationFactory {
"a list of Integer simples", true, new PropertyDefinitionSimple("integer", "an integer", false,
PropertySimpleType.INTEGER));
listOfSimplesPropDef.setDisplayName(listOfSimplesPropDef.getName());
+ listOfSimplesPropDef.setMax(listOfSimplesPropDef.getMax());
+ listOfSimplesPropDef.setMin(listOfSimplesPropDef.getMin());
addPropertyDefinition(configDef, listOfSimplesPropDef, orderIndex++);
PropertyDefinitionMap mapInListPropDef =
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 e8d267b..56766cd 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
@@ -1176,6 +1176,8 @@ view_configEdit_error_3 = Cannot add property named [{0}]. The property name is
view_configEdit_files = Files
view_configEdit_hideAll = Hide All
view_configEdit_jumpToSection = Jump to Section
+view_configEdit_maxBoundsExceeded = Cannot add another entry because the maximum size bounds has been met: {0}
+view_configEdit_minBoundsExceeded = Cannot delete this entry as the minimum has been set to: {0}
view_configEdit_msg_1 = Added property [{0}] to the set.
view_configEdit_msg_2 = Removed properties from the set.
view_configEdit_msg_3 = [{0} {1}] deleted from list.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
index f02b83b..f7d4ef7 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
@@ -1195,6 +1195,8 @@ view_configEdit_error_3 = Nelze přidat vlastnost nazvanou [{0}]. Jméno té vla
view_configEdit_files = Soubory
view_configEdit_hideAll = Skrýt vše
view_configEdit_jumpToSection = Přejít na sekci
+##view_configEdit_maxBoundsExceeded = Cannot add another entry because the maximum size bounds has been met: {0}
+##view_configEdit_minBoundsExceeded = Cannot delete this entry as the minimum has been set to: {0}
view_configEdit_msg_1 = Přidána vlastnost [{0}]
view_configEdit_msg_2 = Vlastnost odebrána z množiny.
view_configEdit_msg_3 = [{0} {1}] smazáno ze seznamu.
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 4de4df2..a40cb2f 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
@@ -1060,6 +1060,8 @@ view_configEdit_confirm_2 = Sind Sie sicher dass sie diese Zeile löschen wollen
view_configEdit_files = Dateien
view_configEdit_hideAll = Alle verbergen
view_configEdit_jumpToSection = Zum Abschnitt springen
+##view_configEdit_maxBoundsExceeded = Cannot add another entry because the maximum size bounds has been met: {0}
+##view_configEdit_minBoundsExceeded = Cannot delete this entry as the minimum has been set to: {0}
view_configEdit_msg_1 = Eigentschaft [{0}] zur Menge hinzugefügt
##view_configEdit_msg_2 = Removed properties from the set.
view_configEdit_msg_3 = [{0} {1}] aus der Liste gelöscht.
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 ea692e6..e135c0d 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
@@ -1172,6 +1172,8 @@ view_configEdit_error_3 = [{0}] という名前のプロパティを追加でき
view_configEdit_files = ファイル
view_configEdit_hideAll = すべて隠す
view_configEdit_jumpToSection = セクションへのジャンプ
+##view_configEdit_maxBoundsExceeded = Cannot add another entry because the maximum size bounds has been met: {0}
+##view_configEdit_minBoundsExceeded = Cannot delete this entry as the minimum has been set to: {0}
view_configEdit_msg_1 = プロパティ [{0}] をセットに追加しました
view_configEdit_msg_2 = セットからプロパティを取り除きました
view_configEdit_msg_3 = [{0} {1}] がリストから削除されました
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 26f3ab8..843d5d2 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
@@ -1182,6 +1182,8 @@ view_configEdit_error_3 = N\u00E3o f\u00F3 poss\u00EDvel adicionar a propriedade
view_configEdit_files = Arquivos
view_configEdit_hideAll = Ocultar todos
view_configEdit_jumpToSection = Ir direto para a Sele\u00E7\u00E3o
+##view_configEdit_maxBoundsExceeded = Cannot add another entry because the maximum size bounds has been met: {0}
+##view_configEdit_minBoundsExceeded = Cannot delete this entry as the minimum has been set to: {0}
view_configEdit_msg_1 = Propriedade [{0}] adicionada ao conjunto.
view_configEdit_msg_2 = Propriedades removidas do conjunto.
view_configEdit_msg_3 = [{0} {1}] removido da lista.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
index 394ecc9..512e087 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
@@ -1165,6 +1165,8 @@
#view_configEdit_files = Files
#view_configEdit_hideAll = Hide All
#view_configEdit_jumpToSection = Jump to Section
+##view_configEdit_maxBoundsExceeded = Cannot add another entry because the maximum size bounds has been met: {0}
+##view_configEdit_minBoundsExceeded = Cannot delete this entry as the minimum has been set to: {0}
#view_configEdit_msg_1 = Added property [{0}] to the set.
#view_configEdit_msg_2 = Removed properties from the set.
#view_configEdit_msg_3 = [{0} {1}] deleted from list.
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 dff469a..269ed1c 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
@@ -1166,6 +1166,8 @@ view_configEdit_error_3 = \u65e0\u6cd5\u6dfb\u52a0\u540d\u4e3a[{0}]\u7684\u5c5e\
view_configEdit_files = \u6587\u4ef6
view_configEdit_hideAll = \u9690\u85cf\u6240\u6709
view_configEdit_jumpToSection = \u8df3\u81f3\u6a21\u5757
+##view_configEdit_maxBoundsExceeded = Cannot add another entry because the maximum size bounds has been met: {0}
+##view_configEdit_minBoundsExceeded = Cannot delete this entry as the minimum has been set to: {0}
view_configEdit_msg_1 = \u589e\u52a0\u5c5e\u6027 [{0}]\u5230\u96c6\u5408.
view_configEdit_msg_2 = \u79fb\u9664\u96c6\u5408\u5185\u6240\u6709\u7684\u5c5e\u6027.
view_configEdit_msg_3 = \u4ece\u5217\u8868\u4e2d\u5220\u9664[{0} {1}]\u6210\u529f.
11 years, 10 months
[rhq] modules/enterprise
by Heiko W. Rupp
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java | 7 ++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java | 1
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest.java | 22 +++++++++-
3 files changed, 27 insertions(+), 3 deletions(-)
New commits:
commit 4c3b4fdd3ad080d772b2932b526e08366694dc0f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jul 12 21:06:36 2012 +0200
Allow to pass the number of data points to the backend.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
index 163d48d..cb7cc5c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
@@ -166,13 +166,16 @@ public class MetricHandlerBean extends AbstractRestBean implements MetricHandle
}
public Response getMetricDataForGroupAndDefinition(int groupId, int definitionId, long startTime, long endTime,
- boolean hideEmpty, Request request, HttpHeaders headers) {
+ int dataPoints,boolean hideEmpty, Request request, HttpHeaders headers) {
if (startTime==0) {
endTime = System.currentTimeMillis();
startTime = endTime - EIGHT_HOURS;
}
+ if (dataPoints<1)
+ throw new IllegalArgumentException("datapoints must be >=0");
+
MediaType mediaType = headers.getAcceptableMediaTypes().get(0);
boolean isHtml = mediaType.equals(MediaType.TEXT_HTML_TYPE);
@@ -187,7 +190,7 @@ public class MetricHandlerBean extends AbstractRestBean implements MetricHandle
res.setGroup(true);
List<List<MeasurementDataNumericHighLowComposite>> listList = dataManager.findDataForCompatibleGroup(caller,
- groupId,definitionId,startTime,endTime,60); // TODO number of points
+ groupId,definitionId,startTime,endTime,dataPoints);
if (listList.isEmpty()) {
throw new StuffNotFoundException("Data for group with id " + groupId + " and definition " + definitionId);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java
index 4ea9343..4ae33f4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java
@@ -120,6 +120,7 @@ public interface MetricHandlerLocal {
@ApiParam("Id of the metric definition to retrieve") @PathParam("definitionId") int definitionId,
@ApiParam(value = "Start time since epoch.", defaultValue="End time - 8h") @QueryParam("startTime") long startTime,
@ApiParam(value = "End time since epoch.", defaultValue = "Now") @QueryParam("endTime") long endTime,
+ @ApiParam("Number of buckets - currently fixed at 60") @QueryParam("dataPoints") @DefaultValue("60") int dataPoints,
@ApiParam(value = "Hide rows that are NaN only", defaultValue = "false") @QueryParam("hideEmpty") boolean hideEmpty,
@Context Request request,
@Context HttpHeaders headers);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest.java
index 9b1d0bf..ec0fcd4 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest.java
@@ -1,3 +1,22 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 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.resource.metadata;
import static java.util.Arrays.asList;
@@ -32,8 +51,9 @@ public class PluginManagerBeanTest extends MetadataBeanTest {
private PluginDeploymentScanner pluginScanner;
@AfterClass
- public void afterClass() {
+ public void afterClass() throws Exception {
this.pluginScanner = null;
+ super.afterClass();
}
@Override
11 years, 10 months