[rhq] Branch 'stefan/dbreset' - 5 commits - modules/core modules/enterprise
by snegrea
modules/core/dbutils/pom.xml | 1081 ++++------
modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java | 172 +
modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java | 172 -
3 files changed, 676 insertions(+), 749 deletions(-)
New commits:
commit 911a6035859f0ddd62c5defad3d843d54fb01e8a
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 18:50:28 2011 -0500
Correct the class file name.
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
new file mode 100644
index 0000000..956e25e
--- /dev/null
+++ b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
@@ -0,0 +1,172 @@
+/*
+ * 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.enterprise.installer;
+
+import org.rhq.core.db.DbUtil;
+import org.rhq.core.db.setup.DBSetup;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.Properties;
+
+/**
+ * The tests in this class exercise the dbsetup/dbupgrade code that is run in the installer. The tests currently only
+ * run against postgresql. Support needs to be added for oracle. The tests do not do any post-install/upgrade
+ * verification at the time of this writing. They just simply exercise the dbsetup/dbupgrade scripts to ensure that
+ * they do not contain any errors.
+ *
+ * @author John Sanda
+ */
+public class DBInstallationTest {
+
+ private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
+ private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
+ private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
+ private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
+ private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
+ private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
+ private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
+ private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
+
+ private ServerInformation installer;
+
+ @BeforeMethod
+ public void prepareForInstallation() throws Exception {
+ initLogDirectory();
+ recreateTestDatabase();
+
+ installer = new ServerInformation();
+ installer.setLogDirectory(new File(LOG_DIRECTORY));
+ }
+
+ @Test
+ public void overwriteJON230Schema() throws Exception {
+ installSchemaAndData("2.3.0");
+ installer.createNewDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void upgradeJON230Schema() throws Exception {
+ installSchemaAndData("2.3.0");
+ installer.upgradeExistingDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void overwriteJON231Schema() throws Exception {
+ installSchemaAndData("2.3.1");
+ installer.createNewDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void upgradeJON231Schema() throws Exception {
+ installSchemaAndData("2.3.1");
+ installer.upgradeExistingDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void overwriteJON240Schema() throws Exception {
+ installSchemaAndData("2.4.0");
+ installer.createNewDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void upgradeJON240Schema() throws Exception {
+ installSchemaAndData("2.4.0");
+ installer.upgradeExistingDatabaseSchema(getInstallProperties());
+ }
+
+ private void initLogDirectory() {
+ File logDir = new File(LOG_DIRECTORY);
+ if (logDir.exists()) {
+ logDir.delete();
+ }
+ logDir.mkdirs();
+ }
+
+ private void recreateTestDatabase() throws Exception {
+ Connection connection = null;
+ Statement dropDB = null;
+ Statement createDB = null;
+
+ try {
+ connection = DbUtil.getConnection(DB_URL.replace(TEST_DB,"postgres"), ADMIN_USERNAME, ADMIN_PASSWORD);
+
+ dropDB = connection.createStatement();
+ dropDB.execute("drop database if exists " + TEST_DB);
+
+ createDB = connection.createStatement();
+ createDB.execute("create database " + TEST_DB + " with owner " + USERNAME);
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ if (dropDB != null) {
+ dropDB.close();
+ }
+ if (createDB != null) {
+ createDB.close();
+ }
+ }
+ }
+
+ private void installSchemaAndData(String jonVersion) throws Exception {
+ DBSetup dbsetup = new DBSetup(DB_URL, USERNAME, PASSWORD);
+ dbsetup.setup(getSchemaFile(jonVersion).getAbsolutePath());
+ dbsetup.setup(getDataFile(jonVersion).getAbsolutePath());
+ }
+
+ private File getSchemaFile(String version) throws Exception {
+ URL url = getClass().getResource("db-schema-combined-" + version + ".xml");
+
+ if (url == null) {
+ throw new RuntimeException("Failed to find schema file for version " + version);
+ }
+
+ return new File(url.toURI().getPath());
+ }
+
+ private File getDataFile(String version) throws Exception {
+ URL url = getClass().getResource("db-data-combined-" + version + ".xml");
+
+ if (url == null) {
+ throw new RuntimeException("Failed to find data file for version " + version);
+ }
+
+ return new File(url.toURI().getPath());
+ }
+
+ private Properties getInstallProperties() {
+ Properties dbProperties = new Properties();
+ dbProperties.put(ServerProperties.PROP_DATABASE_CONNECTION_URL, DB_URL);
+ dbProperties.put(ServerProperties.PROP_DATABASE_USERNAME, USERNAME);
+ dbProperties.put(ServerProperties.PROP_DATABASE_PASSWORD, PASSWORD);
+ dbProperties.put(ServerProperties.PROP_EMAIL_FROM_ADDRESS, "rhqadmin(a)localhost.com");
+ return dbProperties;
+ }
+}
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
deleted file mode 100644
index 579bebf..0000000
--- a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
+++ /dev/null
@@ -1,172 +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, 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.enterprise.installer;
-
-import org.rhq.core.db.DbUtil;
-import org.rhq.core.db.setup.DBSetup;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.net.URI;
-import java.net.URL;
-import java.sql.Connection;
-import java.sql.Statement;
-import java.util.Properties;
-
-/**
- * The tests in this class exercise the dbsetup/dbupgrade code that is run in the installer. The tests currently only
- * run against postgresql. Support needs to be added for oracle. The tests do not do any post-install/upgrade
- * verification at the time of this writing. They just simply exercise the dbsetup/dbupgrade scripts to ensure that
- * they do not contain any errors.
- *
- * @author John Sanda
- */
-public class DBInstallatonTest {
-
- private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
- private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
- private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
- private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
- private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
- private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
- private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
- private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
-
- private ServerInformation installer;
-
- @BeforeMethod
- public void prepareForInstallation() throws Exception {
- initLogDirectory();
- recreateTestDatabase();
-
- installer = new ServerInformation();
- installer.setLogDirectory(new File(LOG_DIRECTORY));
- }
-
- @Test
- public void overwriteJON230Schema() throws Exception {
- installSchemaAndData("2.3.0");
- installer.createNewDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void upgradeJON230Schema() throws Exception {
- installSchemaAndData("2.3.0");
- installer.upgradeExistingDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void overwriteJON231Schema() throws Exception {
- installSchemaAndData("2.3.1");
- installer.createNewDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void upgradeJON231Schema() throws Exception {
- installSchemaAndData("2.3.1");
- installer.upgradeExistingDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void overwriteJON240Schema() throws Exception {
- installSchemaAndData("2.4.0");
- installer.createNewDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void upgradeJON240Schema() throws Exception {
- installSchemaAndData("2.4.0");
- installer.upgradeExistingDatabaseSchema(getInstallProperties());
- }
-
- private void initLogDirectory() {
- File logDir = new File(LOG_DIRECTORY);
- if (logDir.exists()) {
- logDir.delete();
- }
- logDir.mkdirs();
- }
-
- private void recreateTestDatabase() throws Exception {
- Connection connection = null;
- Statement dropDB = null;
- Statement createDB = null;
-
- try {
- connection = DbUtil.getConnection(DB_URL.replace(TEST_DB,"postgres"), ADMIN_USERNAME, ADMIN_PASSWORD);
-
- dropDB = connection.createStatement();
- dropDB.execute("drop database if exists " + TEST_DB);
-
- createDB = connection.createStatement();
- createDB.execute("create database " + TEST_DB + " with owner " + USERNAME);
- } finally {
- if (connection != null) {
- connection.close();
- }
- if (dropDB != null) {
- dropDB.close();
- }
- if (createDB != null) {
- createDB.close();
- }
- }
- }
-
- private void installSchemaAndData(String jonVersion) throws Exception {
- DBSetup dbsetup = new DBSetup(DB_URL, USERNAME, PASSWORD);
- dbsetup.setup(getSchemaFile(jonVersion).getAbsolutePath());
- dbsetup.setup(getDataFile(jonVersion).getAbsolutePath());
- }
-
- private File getSchemaFile(String version) throws Exception {
- URL url = getClass().getResource("db-schema-combined-" + version + ".xml");
-
- if (url == null) {
- throw new RuntimeException("Failed to find schema file for version " + version);
- }
-
- return new File(url.toURI().getPath());
- }
-
- private File getDataFile(String version) throws Exception {
- URL url = getClass().getResource("db-data-combined-" + version + ".xml");
-
- if (url == null) {
- throw new RuntimeException("Failed to find data file for version " + version);
- }
-
- return new File(url.toURI().getPath());
- }
-
- private Properties getInstallProperties() {
- Properties dbProperties = new Properties();
- dbProperties.put(ServerProperties.PROP_DATABASE_CONNECTION_URL, DB_URL);
- dbProperties.put(ServerProperties.PROP_DATABASE_USERNAME, USERNAME);
- dbProperties.put(ServerProperties.PROP_DATABASE_PASSWORD, PASSWORD);
- dbProperties.put(ServerProperties.PROP_EMAIL_FROM_ADDRESS, "rhqadmin(a)localhost.com");
- return dbProperties;
- }
-}
commit 83aaa00ffc0af1b6817e6a11366c189bb89a6ecc
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 17:07:07 2011 -0500
Adding driver class to the property list.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index d2f7e16..318afde 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,6 +22,7 @@
<rhq.ds.connection-url>${rhq.test.ds.connection-url}</rhq.ds.connection-url>
<rhq.ds.user-name>${rhq.test.ds.user-name}</rhq.ds.user-name>
<rhq.ds.password>${rhq.test.ds.password}></rhq.ds.password>
+ <rhq.ds.driver-class>${rhq.test.ds.driver-class}</rhq.ds.driver-class>
</properties>
<dependencies>
<!-- 3rd Party Deps -->
@@ -165,6 +166,7 @@
<rhq.ds.connection-url>${rhq.dev.ds.connection-url}</rhq.ds.connection-url>
<rhq.ds.user-name>${rhq.dev.ds.user-name}</rhq.ds.user-name>
<rhq.ds.password>${rhq.dev.ds.password}></rhq.ds.password>
+ <rhq.ds.driver-class>${rhq.dev.ds.driver-class}</rhq.ds.driver-class>
</properties>
</profile>
commit e53fbd175f6b181f9e09580e4c067e923e92996e
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 16:33:35 2011 -0500
Move conditional properties to maven profiles. This reduces code duplication and makes the pom smaller and more manageable.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index b47e499..d2f7e16 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -17,6 +17,11 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
<db.schema.version>2.111</db.schema.version>
+ <rhq.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.ds.type-mapping>
+ <rhq.ds.db-name>${rhq.test.ds.db-name}</rhq.ds.db-name>
+ <rhq.ds.connection-url>${rhq.test.ds.connection-url}</rhq.ds.connection-url>
+ <rhq.ds.user-name>${rhq.test.ds.user-name}</rhq.ds.user-name>
+ <rhq.ds.password>${rhq.test.ds.password}></rhq.ds.password>
</properties>
<dependencies>
<!-- 3rd Party Deps -->
@@ -146,6 +151,24 @@
<profiles>
<profile>
+ <id>db.dev</id>
+ <activation>
+ <property>
+ <name>db</name>
+ <value>dev</value>
+ </property>
+ </activation>
+
+ <properties>
+ <rhq.ds.type-mapping>${rhq.dev.ds.type-mapping}</rhq.ds.type-mapping>
+ <rhq.ds.db-name>${rhq.dev.ds.db-name}</rhq.ds.db-name>
+ <rhq.ds.connection-url>${rhq.dev.ds.connection-url}</rhq.ds.connection-url>
+ <rhq.ds.user-name>${rhq.dev.ds.user-name}</rhq.ds.user-name>
+ <rhq.ds.password>${rhq.dev.ds.password}></rhq.ds.password>
+ </properties>
+ </profile>
+
+ <profile>
<id>latest</id>
<activation>
<property>
@@ -180,18 +203,6 @@
<phase>test</phase>
<configuration>
<tasks>
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -223,18 +234,6 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -264,21 +263,6 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -326,18 +310,6 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
commit 5fabd79e13498fc1fcbcb53b890d4968df87d3d6
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 15:50:19 2011 -0500
Complete format of the pom file to make it easier to read.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 6907de0..b47e499 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -1,180 +1,160 @@
<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-core-parent</artifactId>
- <version>4.1.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-dbutils</artifactId>
- <packaging>jar</packaging>
-
- <name>RHQ Database Utilities</name>
- <description>Database schema setup, upgrade and other utilities</description>
-
- <scm>
- <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/core/dbutils</connection>
- <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/core/dbutils</developerConnection>
- </scm>
-
- <properties>
- <scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.111</db.schema.version>
- </properties>
-
- <dependencies>
-
- <!-- 3rd Party Deps -->
-
- <dependency>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- <version>1.6.5</version>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- </dependency>
-
- <dependency>
- <groupId>ant</groupId>
- <artifactId>ant-launcher</artifactId>
- <version>1.6.5</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>i18nlog</groupId>
- <artifactId>i18nlog</artifactId>
- <version>${i18nlog.version}</version>
- </dependency>
-
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>net.sourceforge.jtds</groupId>
- <artifactId>jtds</artifactId>
- <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2</version>
- <dependencies>
- <dependency>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-parent</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-dbutils</artifactId>
+ <packaging>jar</packaging>
+ <name>RHQ Database Utilities</name>
+ <description>Database schema setup, upgrade and other utilities</description>
+ <scm>
+ <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/core/dbutils</connection>
+ <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/core/dbutils</developerConnection>
+ </scm>
+ <properties>
+ <scm.module.path>modules/core/dbutils/</scm.module.path>
+ <db.schema.version>2.111</db.schema.version>
+ </properties>
+ <dependencies>
+ <!-- 3rd Party Deps -->
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>1.6.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>i18nlog</groupId>
+ <artifactId>i18nlog</artifactId>
+ <version>${i18nlog.version}</version>
+ </dependency>
+ <dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
- <version>${postgresql.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
- <systemProperties>
- <systemProperty>
- <key>rhq.ds.type-mapping</key>
- <value>${rhq.ds.type-mapping}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.server-name</key>
- <value>${rhq.ds.server-name}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.db-name</key>
- <value>${rhq.ds.db-name}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.connection-url</key>
- <value>${rhq.ds.connection-url}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.db.admin.username</key>
- <value>${rhq.db.admin.username}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.db.admin.password</key>
- <value>${rhq.db.admin.password}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.user-name</key>
- <value>${rhq.ds.user-name}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.password</key>
- <value>${rhq.ds.password}</value>
- </systemProperty>
- </systemProperties>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemProperties>
- <property>
- <name>DatabaseTest.nofail</name>
- <value>${DatabaseTest.nofail}</value>
- </property>
- <property>
- <name>AntDatabaseTest.test-resources</name>
- <value>${basedir}/src/test/resources</value>
- </property>
- </systemProperties>
- <!-- The below is required for tests to run against Oracle. -->
- <additionalClasspathElements>
- <additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc5/${ojdbc5.version}/ojdbc5-${ojdbc5.version}.jar</additionalClasspathElement>
- </additionalClasspathElements>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>latest</id>
- <activation>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.jtds</groupId>
+ <artifactId>jtds</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
+ <dependencies>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>${postgresql.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <configuration>
+ <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
+ <systemProperties>
+ <systemProperty>
+ <key>rhq.ds.type-mapping</key>
+ <value>${rhq.ds.type-mapping}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.server-name</key>
+ <value>${rhq.ds.server-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.db-name</key>
+ <value>${rhq.ds.db-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.connection-url</key>
+ <value>${rhq.ds.connection-url}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.username</key>
+ <value>${rhq.db.admin.username}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.password</key>
+ <value>${rhq.db.admin.password}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.user-name</key>
+ <value>${rhq.ds.user-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.password</key>
+ <value>${rhq.ds.password}</value>
+ </systemProperty>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>DatabaseTest.nofail</name>
+ <value>${DatabaseTest.nofail}</value>
+ </property>
+ <property>
+ <name>AntDatabaseTest.test-resources</name>
+ <value>${basedir}/src/test/resources</value>
+ </property>
+ </systemProperties>
+ <!-- The below is required for tests to run against Oracle. -->
+ <additionalClasspathElements>
+ <additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc5/${ojdbc5.version}/ojdbc5-${ojdbc5.version}.jar</additionalClasspathElement>
+ </additionalClasspathElements>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>latest</id>
+ <activation>
<property>
<name>!jon.release</name>
</property>
</activation>
-
<build>
<plugins>
- <plugin>
+ <plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
@@ -183,7 +163,6 @@
<tasks>
<!-- generate the I18N resource bundles -->
<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}">
@@ -196,396 +175,365 @@
<goal>run</goal>
</goals>
</execution>
-
<execution>
<id>dbsetup-worker</id>
<phase>test</phase>
<configuration>
- <tasks>
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="dbsetup" value="${dbsetup}" />
- <property name="dbsetup-uninstall" value="${dbsetup-uninstall}" />
- <property name="dbsetup-upgrade" value="${dbsetup-upgrade}" />
- <property name="dbsetup-export" value="${dbsetup-export}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>generate-dbsetup-dbupgrade-xml-files</id>
- <phase>process-classes</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <!--
- This execution will abort the build if the database schema is not up to date.
- If you want the build to continue, regardless of your currently installed schema,
- then pass -Ddbsetup-do-not-check-schema to the mvn command line.
- -->
- <id>test-db-schema-version</id>
- <phase>test</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
+ <tasks>
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="dbsetup" value="${dbsetup}" />
+ <property name="dbsetup-uninstall" value="${dbsetup-uninstall}" />
+ <property name="dbsetup-upgrade" value="${dbsetup-upgrade}" />
+ <property name="dbsetup-export" value="${dbsetup-export}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generate-dbsetup-dbupgrade-xml-files</id>
+ <phase>process-classes</phase>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <!-- This execution will abort the build if the database schema is not up to date. If you want the build to continue, regardless of your currently installed
+ schema, then pass -Ddbsetup-do-not-check-schema to the mvn command line. -->
+ <id>test-db-schema-version</id>
+ <phase>test</phase>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
- <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>jon.release</id>
- <activation>
- <property>
- <name>jon.release</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-schema</id>
- <phase>test</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <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>
- <version>1.1</version>
- <executions>
-
- <execution>
- <id>deploy</id>
- <phase>compile</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}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>undeploy</id>
- <phase>clean</phase>
- <configuration>
- <tasks>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Deleting ${deployment.file}...</echo>
- <delete file="${deployment.file}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- </executions>
- </plugin>
-
- </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>
- <execution>
- <id>cobertura-instrument</id>
- <phase>process-test-classes</phase>
- <configuration>
- <tasks>
- <!-- prepare directory structure for cobertura-->
- <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">
- <fileset dir="target/classes">
- <include name="**/*.class" />
- </fileset>
- </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" />
- <!-- 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" />
- </fileset>
- </cobertura-instrument>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- <execution>
- <id>cobertura-report</id>
- <phase>prepare-package</phase>
- <configuration>
- <tasks>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
- <!-- prepare directory structure for 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">
- <fileset dir="target/cobertura/backup">
- <include name="**/*.class" />
- </fileset>
- </copy>
- <!-- delete backup folder-->
- <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">
- <fileset dir="${basedir}/src/main/java">
- <include name="**/*.java" />
- </fileset>
- </cobertura-report>
- <!-- delete cobertura.properties file -->
- <delete file="target/classes/cobertura.properties" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>ojdbc-driver</id>
- <dependencies>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc5</artifactId>
- <version>${ojdbc5.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2</version>
- <dependencies>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc5</artifactId>
- <version>${ojdbc5.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
- </profile>
+ <profile>
+ <id>jon.release</id>
+ <activation>
+ <property>
+ <name>jon.release</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-schema</id>
+ <phase>test</phase>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="jon.release" value="${jon.release}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <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>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>deploy</id>
+ <phase>compile</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}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </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>
+ <execution>
+ <id>cobertura-instrument</id>
+ <phase>process-test-classes</phase>
+ <configuration>
+ <tasks>
+ <!-- prepare directory structure for cobertura -->
+ <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">
+ <fileset dir="target/classes">
+ <include name="**/*.class" />
+ </fileset>
+ </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" />
+ <!-- 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" />
+ </fileset>
+ </cobertura-instrument>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>cobertura-report</id>
+ <phase>prepare-package</phase>
+ <configuration>
+ <tasks>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <!-- prepare directory structure for 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">
+ <fileset dir="target/cobertura/backup">
+ <include name="**/*.class" />
+ </fileset>
+ </copy>
+ <!-- delete backup folder -->
+ <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">
+ <fileset dir="${basedir}/src/main/java">
+ <include name="**/*.java" />
+ </fileset>
+ </cobertura-report>
+ <!-- delete cobertura.properties file -->
+ <delete file="target/classes/cobertura.properties" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>ojdbc-driver</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
-
- <pluginRepositories>
- <pluginRepository>
- <id>codehaus-snapshots</id>
- <name>codehaus snapshots</name>
- <url>http://snapshots.repository.codehaus.org</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
-
-</project>
-
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>codehaus-snapshots</id>
+ <name>codehaus snapshots</name>
+ <url>http://snapshots.repository.codehaus.org</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+</project>
\ No newline at end of file
commit f74c6545ec40b20691d4557d85da06e2ab9b4f89
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 15:44:22 2011 -0500
Stray changes from one more file reverted properly.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 996ae31..6907de0 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -35,13 +35,12 @@
<version>1.6.5</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
-
<dependency>
<groupId>ant</groupId>
<artifactId>ant-launcher</artifactId>
@@ -167,48 +166,54 @@
<profiles>
<profile>
<id>latest</id>
- <activation>
- <property>
- <name>!jon.release</name>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <configuration>
- <tasks>
- <!-- generate the I18N resource bundles -->
- <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="**/*I18NResourceKeys.class" />
- </classfileset>
- </i18n>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>dbsetup-worker</id>
- <phase>test</phase>
- <configuration>
+ <activation>
+ <property>
+ <name>!jon.release</name>
+ </property>
+ </activation>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <configuration>
+ <tasks>
+ <!-- generate the I18N resource bundles -->
+ <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="**/*I18NResourceKeys.class" />
+ </classfileset>
+ </i18n>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>dbsetup-worker</id>
+ <phase>test</phase>
+ <configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
- <property name="rhq.ds.password" value="${rhq.ds.password}"/>
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -243,21 +248,21 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -289,50 +294,50 @@
-->
<id>test-db-schema-version</id>
<phase>test</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
- <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
<goal>run</goal>
</goals>
</execution>
@@ -361,7 +366,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
<equals arg1="${db}" arg2="dev" />
</condition>
@@ -391,7 +396,7 @@
<property name="rhq.ds.password" value="${rhq.ds.password}" />
<property name="project.version" value="${project.version}" />
<property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
+ <property name="jon.release" value="${jon.release}" />
</ant>
</tasks>
</configuration>
12 years, 9 months
[rhq] modules/plugins
by ips
modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java | 90 ++++++++--
1 file changed, 73 insertions(+), 17 deletions(-)
New commits:
commit e4fa39acdcccd039950d5fac3c80cb5b95a0474b
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Aug 1 17:09:35 2011 -0400
[BZ 723025] add support for operationinfos with un-named parameterinfos, which is common for standard mbeans (https://bugzilla.redhat.com/show_bug.cgi?id=723025); map RHQ operation to MBean operation with not only the same name, but also the same # of params - this allows us to support MBeans that define multiple operations with the same name but different params
diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
index cb7f901..6a60a93 100644
--- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
+++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -33,6 +33,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.SortedSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -520,38 +521,72 @@ public class MBeanResourceComponent<T extends JMXComponent> implements Measureme
public OperationResult invokeOperation(String name, Configuration parameters, EmsBean emsBean) throws Exception {
if (emsBean == null) {
throw new Exception("Can not invoke operation [" + name
- + "], as we can't connect to the bean - is it down?");
+ + "], as we can't connect to the MBean - is it down?");
}
- EmsOperation operation = emsBean.getOperation(name);
+ Map<String, PropertySimple> paramProps = parameters.getSimpleProperties();
+ SortedSet<EmsOperation> emsOperations = emsBean.getOperations();
+ EmsOperation operation = null;
+ // There could be multiple operations with the same name but different parameters. Try to find one that has
+ // the same # of parameters as the RHQ operation def.
+ for (EmsOperation emsOperation : emsOperations) {
+ if (emsOperation.getName().equals(name) && (emsOperation.getParameters().size() == paramProps.size())) {
+ operation = emsOperation;
+ break;
+ }
+ }
+ if (operation == null) {
+ // We couldn't find an operation with the expected name and # of parameters, so as as a last ditch effort,
+ // see if there's an operation that at least has the expected name.
+ operation = emsBean.getOperation(name);
+ }
if (operation == null) {
- throw new Exception("Operation [" + name + "] not found on bean [" + emsBean.getBeanName() + "]");
+ throw new Exception("Operation [" + name + "] not found on MBean [" + emsBean.getBeanName() + "].");
}
- Object[] parameterValues = new Object[operation.getParameters().size()];
+ List<EmsParameter> emsParams = operation.getParameters();
+ Map<String, Integer> emsParamIndexesByName = new HashMap<String, Integer>();
+ for (int i = 0, emsParamsSize = emsParams.size(); i < emsParamsSize; i++) {
+ EmsParameter emsParam = emsParams.get(i);
+ if (emsParam.getName() != null) {
+ emsParamIndexesByName.put(emsParam.getName(), i);
+ }
+ }
- int i = 0;
- List<EmsParameter> params = operation.getParameters();
- for (EmsParameter param : params) {
- PropertySimple ps = parameters.getSimple(param.getName());
- if (param.getType().equals(String.class.getName())) {
- parameterValues[i] = (ps == null) ? null : ps.getStringValue();
- } else if (param.getType().equals(boolean.class.getName())) {
- parameterValues[i] = (ps == null) ? null : ps.getBooleanValue();
+ Object[] paramValues = new Object[operation.getParameters().size()];
+
+ for (String propName : paramProps.keySet()) {
+ Integer paramIndex;
+ if (propName.matches("\\[\\d+\\]")) {
+ paramIndex = Integer.valueOf(propName.substring(propName.indexOf('[') + 1, propName.indexOf(']')));
+ if (paramIndex < 0 || paramIndex >= emsParams.size()) {
+ throw new IllegalStateException("Index [" + paramIndex + "] specified for parameter of operation ["
+ + name + "] on MBean [" + emsBean.getBeanName() + "] is invalid. The MBean operation takes "
+ + emsParams.size() + " parameters.");
+ }
+ } else {
+ paramIndex = emsParamIndexesByName.get(propName);
+ if (paramIndex == null) {
+ throw new IllegalStateException("Name [" + propName + "] specified for parameter of operation ["
+ + name + "] on MBean [" + emsBean.getBeanName()
+ + "] is invalid. The MBean operation does not take a parameter by that name.");
+ }
}
+ EmsParameter emsParam = emsParams.get(paramIndex);
- // TODO GH: Handle rest of types. (I think i have a mapper for this in mc4j
- i++;
+ PropertySimple paramProp = paramProps.get(propName);
+ String emsParamType = emsParam.getType();
+ Object paramValue = getPropertyValueAsType(paramProp, emsParamType);
+ paramValues[paramIndex] = paramValue;
}
- Object resultObject = operation.invoke(parameterValues);
+ Object resultObject = operation.invoke(paramValues);
boolean hasVoidReturnType = (operation.getReturnType() == null
|| Void.class.getName().equals(operation.getReturnType()) || void.class.getName().equals(
operation.getReturnType()));
OperationResult resultToReturn;
-
if (resultObject == null && hasVoidReturnType) {
resultToReturn = null;
} else {
@@ -575,4 +610,25 @@ public class MBeanResourceComponent<T extends JMXComponent> implements Measureme
return resultToReturn;
}
+
+ private Object getPropertyValueAsType(PropertySimple propSimple, String typeName) {
+ Object value;
+ if (typeName.equals(String.class.getName())) {
+ value = (propSimple == null) ? null : propSimple.getStringValue();
+ } else if (typeName.equals(Boolean.class.getName()) || typeName.equals(boolean.class.getName())) {
+ value = (propSimple == null) ? null : propSimple.getBooleanValue();
+ } else if (typeName.equals(Integer.class.getName()) || typeName.equals(int.class.getName())) {
+ value = (propSimple == null) ? null : propSimple.getIntegerValue();
+ } else if (typeName.equals(Long.class.getName()) || typeName.equals(long.class.getName())) {
+ value = (propSimple == null) ? null : propSimple.getLongValue();
+ } else if (typeName.equals(Float.class.getName()) || typeName.equals(float.class.getName())) {
+ value = (propSimple == null) ? null : propSimple.getFloatValue();
+ } else if (typeName.equals(Double.class.getName()) || typeName.equals(double.class.getName())) {
+ value = (propSimple == null) ? null : propSimple.getDoubleValue();
+ } else {
+ throw new IllegalStateException("Operation parameter maps to MBean parameter with an unsupported type (" + typeName + ").");
+ }
+ // TODO GH: Handle rest of types. (I think i have a mapper for this in mc4j
+ return value;
+ }
}
12 years, 9 months
[rhq] Branch 'drift' - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 14 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PopupWindow.java | 63 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java | 59 +++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java | 12 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 3
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16_open.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/Drift_new_16.png |binary
12 files changed, 160 insertions(+), 3 deletions(-)
New commits:
commit efcf0c5f3ec664ee2899756cd45df7a591837d99
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Aug 1 16:18:28 2011 -0400
add change set menu item "show configuration" - not implemented yet until we get the proper composite query
added new icons for "coverage" change sets versus "drift"
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 a513687..4c1c429 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
@@ -79,7 +79,21 @@ public class ImageManager {
return "[SKIN]/actions/undo.png";
}
+ /**
+ * Returns a drift icon given the category of the drift.
+ * Note that if the category is null, it will be assumed the drift icon
+ * should be one that indicates the file is "new" (presumably from
+ * a coverage change set report - that is, its the first time the file
+ * has been seen).
+ *
+ * @param category
+ * @return path to icon
+ */
public static String getDriftCategoryIcon(DriftCategory category) {
+ if (category == null) {
+ return "subsystems/drift/Drift_new_16.png";
+ }
+
switch (category) {
case FILE_ADDED:
return "subsystems/drift/Drift_add_16.png";
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PopupWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PopupWindow.java
new file mode 100644
index 0000000..e72518a
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PopupWindow.java
@@ -0,0 +1,63 @@
+/*
+ * 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.enterprise.gui.coregui.client;
+
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+
+/**
+ * Generic window that you can use to popup details. Populate the popup
+ * window with any canvas.
+ *
+ * @author John Mazzitelli
+ */
+public class PopupWindow extends LocatableWindow {
+ /**
+ * Create the popup dialog window.
+ *
+ * @param locatorId
+ * @param canvas if not <code>null</code>, this will be added to the window.
+ */
+ public PopupWindow(String locatorId, Canvas canvas) {
+ super(locatorId);
+ setTitle(MSG.common_title_details());
+ setShowMinimizeButton(false);
+ setShowMaximizeButton(true);
+ setIsModal(true);
+ setShowModalMask(true);
+ setWidth(600);
+ setHeight(400);
+ setAutoCenter(true);
+ setShowResizer(true);
+ setCanDragResize(true);
+ centerInPage();
+ addCloseClickHandler(new CloseClickHandler() {
+ public void onCloseClick(CloseClientEvent event) {
+ markForDestroy();
+ }
+ });
+ if (canvas != null) {
+ addItem(canvas);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 8203361..20e5bf1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -40,12 +40,17 @@ import com.smartgwt.client.widgets.tree.TreeNode;
import com.smartgwt.client.widgets.tree.events.NodeContextClickEvent;
import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftConfigurationDefinition;
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.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
@@ -230,9 +235,42 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
});
contextMenu.addItem(deleteItem);
+ // item that shows the drift configuration
+ MenuItem configItem = new MenuItem(MSG.view_drift_changeset_tree_showConfiguration());
+ configItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ showDriftConfiguration(node.getChangeSetId());
+ }
+ });
+ contextMenu.addItem(configItem);
+
return contextMenu;
}
+ protected void showDriftConfiguration(final String changeSetId) {
+ ConfigurationDefinition def = DriftConfigurationDefinition.getInstance();
+ Configuration config = new Configuration();
+ ConfigurationEditor editor = new ConfigurationEditor(extendLocatorId("driftConfigEditor"), def, config);
+ editor.setReadOnly(true);
+ PopupWindow window = new PopupWindow("details", editor);
+ window.show();
+
+ // DriftChangeSetCriteria criteria = new BasicDriftChangeSetCriteria();
+ // criteria.addFilterId(changeSetId);
+ // criteria.fetchDriftConfiguration(true);
+ // GWTServiceLookup.getDriftService().findDriftChangeSetCompositesByCriteria(criteria,
+ // new AsyncCallback<PageList<DriftChangeSet>>() {
+ // public void onSuccess(PageList<DriftChangeSet> result) {
+ // // TODO
+ // }
+ //
+ // public void onFailure(Throwable t) {
+ // CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadConfigFailure(changeSetId),
+ // t);
+ // }
+ // });
+ }
+
/**
* We override this because we know all of our nodes will have titles. Without this,
* I could not get the title of change set nodes to show - it always fell back to using
@@ -248,11 +286,23 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
static class ChangeSetTreeNode extends TreeNode {
public ChangeSetTreeNode(DriftChangeSet changeset) {
setIsFolder(true);
- setIcon("subsystems/drift/ChangeSet_16.png");
setShowOpenIcon(true);
setID(changeset.getId());
setName(padWithZeroes(changeset.getVersion())); // we sort on this column, hence we make sure the version # is padded
setTitle(buildDriftChangeSetNodeName(changeset));
+
+ switch (changeset.getCategory()) {
+ case COVERAGE:
+ setIcon("subsystems/drift/ChangeSet_Coverage_16.png");
+ break;
+ case DRIFT:
+ setIcon("subsystems/drift/ChangeSet_16.png");
+ break;
+ }
+ }
+
+ public String getChangeSetId() {
+ return getAttribute("id");
}
private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
@@ -263,7 +313,7 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
str.append(" (");
str.append(TimestampCellFormatter.format(changeset.getCtime(),
TimestampCellFormatter.DATE_TIME_FORMAT_SHORT));
- str.append(')');
+ str.append(")");
return str.toString();
}
@@ -285,6 +335,11 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setParentID(parentID);
setID(parentID + '_' + drift.getId());
setName(drift.getPath()); // we sort on this column
+ setAttribute("driftId", drift.getId());
+ }
+
+ public String getDriftId() {
+ return getAttribute("driftId");
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
index 0d59be8..8a6c448 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
@@ -63,6 +63,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
*/
public class DriftDataSource extends RPCDataSource<DriftComposite, DriftCriteria> {
+ public static final String CATEGORY_ICON_NEW = ImageManager.getDriftCategoryIcon(null);
public static final String CATEGORY_ICON_ADD = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_ADDED);
public static final String CATEGORY_ICON_CHANGE = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_CHANGED);
public static final String CATEGORY_ICON_REMOVE = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_REMOVED);
@@ -121,6 +122,8 @@ public class DriftDataSource extends RPCDataSource<DriftComposite, DriftCriteria
return MSG.view_drift_category_fileChanged();
} else if (CATEGORY_ICON_REMOVE.equals(cat)) {
return MSG.view_drift_category_fileRemoved();
+ } else if (CATEGORY_ICON_NEW.equals(cat)) {
+ return MSG.view_drift_category_fileNew();
} else {
return ""; // will never get here
}
@@ -304,7 +307,14 @@ public class DriftDataSource extends RPCDataSource<DriftComposite, DriftCriteria
Drift drift = from.getDrift();
record.setAttribute(ATTR_ID, drift.getId());
record.setAttribute(ATTR_CTIME, new Date(drift.getCtime()));
- record.setAttribute(ATTR_CATEGORY, ImageManager.getDriftCategoryIcon(drift.getCategory()));
+ switch (drift.getChangeSet().getCategory()) {
+ case COVERAGE:
+ record.setAttribute(ATTR_CATEGORY, ImageManager.getDriftCategoryIcon(null));
+ break;
+ case DRIFT:
+ record.setAttribute(ATTR_CATEGORY, ImageManager.getDriftCategoryIcon(drift.getCategory()));
+ break;
+ }
record.setAttribute(ATTR_PATH, drift.getPath());
record.setAttribute(ATTR_CHANGESET_VERSION, drift.getChangeSet().getVersion());
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 ea8c956..0ba3347 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
@@ -1120,10 +1120,13 @@ view_drift = Drift
view_drift_button_detectNow = Detect Now
view_drift_category_fileAdded = File Added
view_drift_category_fileChanged = File Changed
+view_drift_category_fileNew = New Detection
view_drift_category_fileRemoved = File Removed
view_drift_changeSets = Change Sets
view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+view_drift_changeset_tree_loadConfigFailure = Failed to load drift configuration for change set id [{0}]
view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
+view_drift_changeset_tree_showConfiguration = Show Configuration
view_drift_delete_confirm = Delete the selected drift(s)?
view_drift_delete_confirmAll = Delete all drifts from this source?
view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
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 a07568a..977f4a4 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
@@ -938,10 +938,13 @@ view_dashboards_title = Dashboard
##view_drift_button_detectNow = Detect Now
##view_drift_category_fileAdded = File Added
##view_drift_category_fileChanged = File Changed
+##view_drift_category_fileNew = New Detection
##view_drift_category_fileRemoved = File Removed
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadConfigFailure = Failed to load drift configuration for change set id [{0}]
##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
+##view_drift_changeset_tree_showConfiguration = Show Configuration
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
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 6e68cff..6af4be0 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
@@ -1104,9 +1104,12 @@ view_dashboards_portlets_refresh_success1 = ポートレットの自動リフレ
view_dashboards_portlets_refresh_success2 = 自動リフレッシュするポートレットのリロードを停止しています
view_dashboards_title = ダッシュボード
##view_drift = Drift
+##view_drift_category_fileNew = New Detection
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadConfigFailure = Failed to load drift configuration for change set id [{0}]
##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
+##view_drift_changeset_tree_showConfiguration = Show Configuration
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index fa86006..0d1e7c9 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
@@ -1138,10 +1138,13 @@ view_dashboards_title = Dashboard~
##view_drift_button_detectNow = Detect Now
##view_drift_category_fileAdded = File Added
##view_drift_category_fileChanged = File Changed
+##view_drift_category_fileNew = New Detection
##view_drift_category_fileRemoved = File Removed
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadConfigFailure = Failed to load drift configuration for change set id [{0}]
##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
+##view_drift_changeset_tree_showConfiguration = Show Configuration
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
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 79816c5..a6c6880 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
@@ -1113,9 +1113,12 @@ view_dashboards_portlets_refresh_success1 = \u6210\u529f\u4fee\u6539portlets\u81
view_dashboards_portlets_refresh_success2 = \u6210\u529f\u505c\u7528portlets\u81ea\u52a8\u5237\u65b0\u7684\u91cd\u8f7d
view_dashboards_title = \u7edf\u8ba1\u8868\u76d8
##view_drift = Drift
+##view_drift_category_fileNew = New Detection
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadConfigFailure = Failed to load drift configuration for change set id [{0}]
##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
+##view_drift_changeset_tree_showConfiguration = Show Configuration
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16.png
new file mode 100644
index 0000000..7ae8f52
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16_open.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16_open.png
new file mode 100644
index 0000000..85e3cf4
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16_open.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/Drift_new_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/Drift_new_16.png
new file mode 100644
index 0000000..e3e4f97
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/Drift_new_16.png differ
12 years, 9 months
[rhq] Branch 'drift' - modules/enterprise
by John Sanda
modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
New commits:
commit 5a81800b803be0d83ebc18a91f763ad43d364b70
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Aug 1 15:23:33 2011 -0400
temporarily disabling test until mongodb server is available with hudson builds
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
index cfdc802..ac20ac4 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
@@ -45,7 +45,7 @@ public class MongoDBChangeSetTest {
ds.delete(deleteAll);
}
- @Test
+ @Test(enabled = false)
public void saveAndLoadEmptyChangeSet() throws Exception {
MongoDBChangeSet expected = new MongoDBChangeSet();
expected.setCategory(COVERAGE);
@@ -59,7 +59,7 @@ public class MongoDBChangeSetTest {
assertPropertiesMatch("Failed to save change set", expected, actual);
}
- @Test
+ @Test(enabled = false)
public void saveAndLoadChangeSetWithOneEntry() throws Exception {
MongoDBChangeSet expected = new MongoDBChangeSet();
expected.setResourceId(10001);
@@ -75,7 +75,7 @@ public class MongoDBChangeSetTest {
"changeSet");
}
- @Test
+ @Test(enabled = false)
public void saveAndFindChangeSetById() throws Exception {
MongoDBChangeSet expected = new MongoDBChangeSet();
expected.setCategory(COVERAGE);
12 years, 9 months
[rhq] Branch 'drift' - modules/core modules/enterprise
by John Sanda
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java | 12 ++++
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java | 4 +
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java | 11 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java | 25 ++++++++--
modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java | 1
5 files changed, 48 insertions(+), 5 deletions(-)
New commits:
commit 26bfa2034a6306ed941d6a1fd5f26840e32eef84
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Aug 1 15:17:18 2011 -0400
Add config id to drift change set criteria
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java
index 2debece..ba46bc2 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java
@@ -22,6 +22,8 @@ public class BasicDriftChangeSetCriteria implements DriftChangeSetCriteria {
private Integer filterResourceId;
+ private Integer filterDriftConfigId;
+
private DriftChangeSetCategory filterCategory;
private boolean fetchDrifts;
@@ -101,6 +103,16 @@ public class BasicDriftChangeSetCriteria implements DriftChangeSetCriteria {
}
@Override
+ public void addFilterDriftConfigurationId(Integer filterDriftConfigId) {
+ this.filterDriftConfigId = filterDriftConfigId;
+ }
+
+ @Override
+ public Integer getFilterDriftConfigurationId() {
+ return filterDriftConfigId;
+ }
+
+ @Override
public void addFilterCategory(DriftChangeSetCategory filterCategory) {
this.filterCategory = filterCategory;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
index b5f71b2..273db4b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
@@ -35,6 +35,10 @@ public interface DriftChangeSetCriteria extends BaseCriteria, Serializable {
Integer getFilterResourceId();
+ void addFilterDriftConfigurationId(Integer filterDriftConfigId);
+
+ Integer getFilterDriftConfigurationId();
+
void addFilterCategory(DriftChangeSetCategory filterCategory);
DriftChangeSetCategory getFilterCategory();
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
index 7a7f78f..0ca1d36 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
@@ -39,6 +39,7 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
private Integer filterId;
private Integer filterInitial; // needs override
private Integer filterResourceId; // needs override
+ private Integer filterDriftConfigurationId;
private Integer filterVersion;
private Integer filterStartVersion;
private Integer filterEndVersion;
@@ -138,6 +139,16 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
return filterResourceId;
}
+ @Override
+ public void addFilterDriftConfigurationId(Integer filterDriftConfigId) {
+ this.filterDriftConfigurationId = filterDriftConfigId;
+ }
+
+ @Override
+ public Integer getFilterDriftConfigurationId() {
+ return filterDriftConfigurationId;
+ }
+
public void addFilterCategory(DriftChangeSetCategory filterCategory) {
this.filterCategory = filterCategory;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 8e4d1f7..0479c4a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -147,11 +147,6 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
try {
- DriftChangeSetJPACriteria c = new DriftChangeSetJPACriteria();
- c.addFilterResourceId(resourceId);
- List<RhqDriftChangeSet> changeSets = findDriftChangeSetsByCriteria(subjectManager.getOverlord(), c);
- final int version = changeSets.size();
-
ZipUtil.walkZipFile(changeSetZip, new ChangeSetFileVisitor() {
@Override
@@ -165,6 +160,8 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
// store the new change set info (not the actual blob)
DriftConfiguration config = findDriftConfiguration(resource, reader.getHeaders());
+ int version = getChangeSetVersion(resource, config);
+
if (config == null) {
log.error("Unable to locate " + config.getClass().getSimpleName() + "[id: " +
config.getId() + ", name: " + config.getName() + "]. Change set cannot be saved.");
@@ -240,6 +237,24 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
}
+ /**
+ * This method only exists temporarily until the version header is added to the change
+ * set meta data file. This method determines the version by looking at the number of
+ * change sets in the database.
+ *
+ * @param r The resource
+ * @param c The drift configuration
+ * @return The next change set version number
+ */
+ int getChangeSetVersion(Resource r, DriftConfiguration c) {
+ DriftChangeSetJPACriteria criteria = new DriftChangeSetJPACriteria();
+ criteria.addFilterResourceId(r.getId());
+ criteria.addFilterDriftConfigurationId(c.getId());
+ List<RhqDriftChangeSet> changeSets = findDriftChangeSetsByCriteria(subjectManager.getOverlord(), criteria);
+
+ return changeSets.size();
+ }
+
DriftConfiguration findDriftConfiguration(Resource resource, Headers headers) {
for (Configuration config : resource.getDriftConfigurations()) {
DriftConfiguration driftConfig = new DriftConfiguration(config);
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index 1755d3e..c2520d5 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -111,6 +111,7 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
DriftChangeSetJPACriteria jpaCriteria = new DriftChangeSetJPACriteria();
jpaCriteria.addFilterId(criteria.getFilterId());
jpaCriteria.addFilterResourceId(criteria.getFilterResourceId());
+ jpaCriteria.addFilterDriftConfigurationId(criteria.getFilterDriftConfigurationId());
jpaCriteria.addFilterCategory(criteria.getFilterCategory());
jpaCriteria.addFilterCreatedAfter(criteria.getFilterCreatedAfter());
jpaCriteria.addFilterCreatedBefore(criteria.getFilterCreatedBefore());
12 years, 9 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java | 65 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 50 -------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java | 55 +++++++-
3 files changed, 88 insertions(+), 82 deletions(-)
New commits:
commit d47438f7a5a56de5539f8635a44aed53833837dc
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Aug 1 14:09:29 2011 -0400
[BZ 720456] fix so all child types are shown in manual-add dropdown on Inventory>Child Resources view (https://bugzilla.redhat.com/show_bug.cgi?id=720456)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java
index f333ddf..de0dba6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java
@@ -122,47 +122,54 @@ public class ResourceCompositeSearchView extends ResourceSearchView {
});
if (this.parentResourceComposite.getResourcePermission().isCreateChildResources()) {
- ResourceType parentType = parentResourceComposite.getResource().getResourceType();
-
- // manual import type menu
- LinkedHashMap<String, ResourceType> importTypeValueMap = new LinkedHashMap<String, ResourceType>();
+ addImportButton();
+ }
- for (ResourceType childType : parentType.getChildResourceTypes()) {
- if (childType.isSupportsManualAdd()) {
- importTypeValueMap.put(childType.getName(), childType);
- }
- }
- addTableAction(extendLocatorId("Import"), MSG.common_button_import(), null, importTypeValueMap,
- new AbstractTableAction(TableActionEnablement.ALWAYS) {
+ super.configureTable();
+ }
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ResourceFactoryImportWizard.showImportWizard(parentResourceComposite.getResource(),
- (ResourceType) actionValue);
- }
- });
+ private void addImportButton() {
+ ResourceType parentType = parentResourceComposite.getResource().getResourceType();
- // creatable child type menu
- LinkedHashMap<String, ResourceType> createTypeValueMap = new LinkedHashMap<String, ResourceType>();
+ // manual import type menu
+ // TODO: Use TreeMap instead, so the types will be sorted by name.
+ LinkedHashMap<String, ResourceType> importTypeValueMap = new LinkedHashMap<String, ResourceType>();
- for (ResourceType childType : parentType.getChildResourceTypes()) {
- if (childType.isCreatable()) {
- createTypeValueMap.put(childType.getName(), childType);
- }
+ for (ResourceType childType : parentType.getChildResourceTypes()) {
+ if (childType.isSupportsManualAdd()) {
+ importTypeValueMap.put(childType.getName(), childType);
}
- if (!createTypeValueMap.isEmpty()) {
- addTableAction(extendLocatorId("CreateChild"), MSG.common_button_create_child(), null,
- createTypeValueMap, new AbstractTableAction(TableActionEnablement.ALWAYS) {
+ }
+ if (!importTypeValueMap.isEmpty()) {
+ addTableAction(extendLocatorId("Import"), MSG.common_button_import(), null, importTypeValueMap,
+ new AbstractTableAction(TableActionEnablement.ALWAYS) {
public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ResourceFactoryCreateWizard.showCreateWizard(parentResourceComposite.getResource(),
- (ResourceType) actionValue);
+ ResourceFactoryImportWizard.showImportWizard(parentResourceComposite.getResource(),
+ (ResourceType) actionValue);
}
});
- }
+ }
+
+ // creatable child type menu
+ // TODO: Use TreeMap instead, so the types will be sorted by name.
+ LinkedHashMap<String, ResourceType> createTypeValueMap = new LinkedHashMap<String, ResourceType>();
+ for (ResourceType childType : parentType.getChildResourceTypes()) {
+ if (childType.isCreatable()) {
+ createTypeValueMap.put(childType.getName(), childType);
+ }
}
+ if (!createTypeValueMap.isEmpty()) {
+ addTableAction(extendLocatorId("CreateChild"), MSG.common_button_create_child(), null,
+ createTypeValueMap, new AbstractTableAction(TableActionEnablement.ALWAYS) {
- super.configureTable();
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ ResourceFactoryCreateWizard.showCreateWizard(parentResourceComposite.getResource(),
+ (ResourceType) actionValue);
+ }
+ });
+ }
}
public ResourceComposite getParentResourceComposite() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 7149726..68ef419 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -60,7 +60,6 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.criteria.DashboardCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
-import org.rhq.core.domain.criteria.ResourceTypeCriteria;
import org.rhq.core.domain.dashboard.Dashboard;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.measurement.DataType;
@@ -68,7 +67,6 @@ import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.operation.OperationDefinition;
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.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.composite.ResourceLineageComposite;
@@ -83,7 +81,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resour
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.InventoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupContextMenu;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupDetailView;
@@ -539,9 +536,6 @@ public class ResourceTreeView extends LocatableVLayout {
importChildSubMenu.addItem(importItem);
}
}
- if (resourceType.getCategory() == ResourceCategory.PLATFORM) {
- loadManuallyAddServersToPlatforms(importChildSubMenu, resource);
- }
importChildMenu.setSubmenu(importChildSubMenu);
manualImportEnabled = importChildSubMenu.getItems().length > 0;
@@ -550,48 +544,6 @@ public class ResourceTreeView extends LocatableVLayout {
resourceContextMenu.addItem(importChildMenu);
}
- private void loadManuallyAddServersToPlatforms(final Menu manuallyAddMenu, final Resource resource) {
- ResourceTypeGWTServiceAsync rts = GWTServiceLookup.getResourceTypeGWTService();
-
- ResourceTypeCriteria criteria = new ResourceTypeCriteria();
- criteria.addFilterSupportsManualAdd(true);
- criteria.fetchParentResourceTypes(true);
- rts.findResourceTypesByCriteria(criteria, new AsyncCallback<PageList<ResourceType>>() {
-
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_loadFailed_manualAddChildren(),
- caught);
- }
-
- public void onSuccess(PageList<ResourceType> result) {
- //sort the display items alphabetically
- TreeSet<String> ordered = new TreeSet<String>();
- Map<String, ResourceType> displayTypes = new HashMap<String, ResourceType>();
- for (ResourceType type : result) {
- displayTypes.put(type.getName(), type);
- ordered.add(type.getName());
- }
-
- int idx = 0;
- for (String displayType : ordered) {
- final ResourceType type = displayTypes.get(displayType);
- if (type.getParentResourceTypes() == null || type.getParentResourceTypes().isEmpty()) {
- MenuItem item = new MenuItem(type.getName());
-
- item.addClickHandler(new ClickHandler() {
-
- public void onClick(MenuItemClickEvent event) {
- ResourceFactoryImportWizard.showImportWizard(resource, type);
- }
- });
-
- manuallyAddMenu.addItem(item, idx++);
- }
- }
- }
- });
- }
-
private MenuItem buildMetricsMenu(final ResourceType type, final Resource resource) {
MenuItem measurements = new MenuItem(MSG.view_tree_common_contextMenu_measurements());
final Menu measurementsSubMenu = new Menu();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
index d1dce1f..c4630dd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -32,6 +32,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
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.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageControl;
@@ -51,6 +52,7 @@ public class ResourceTypeRepository {
private Map<Integer, ResourceType> typeCache = new HashMap<Integer, ResourceType>();
private Map<Integer, EnumSet<MetadataType>> typeCacheLevel = new HashMap<Integer, EnumSet<MetadataType>>();
+ private Set<ResourceType> topLevelServerAndServiceTypes;
private static ResourceTypeGWTServiceAsync resourceTypeService = GWTServiceLookup.getResourceTypeGWTService();
@@ -252,9 +254,46 @@ public class ResourceTypeRepository {
criteria.setPageControl(PageControl.getUnlimitedInstance());
- com.allen_sauer.gwt.log.client.Log.info("Loading " + typesNeeded.size()
+ Log.info("Loading " + typesNeeded.size()
+ ((metadataTypes != null) ? (" types: " + metadataTypes) : ""));
+ if ((topLevelServerAndServiceTypes == null) && (metadataTypes != null) &&
+ metadataTypes.contains(MetadataType.children)) {
+ // Perform a one-time load of server and service types with no parent types. These types are implicitly
+ // children of all platform types, even though they are not included in the platform types'
+ // childResourceTypes field.
+ loadTopLevelServerAndServiceTypes(callback, metadataTypes, criteria, cachedTypes);
+ } else {
+ loadRequestedTypes(callback, metadataTypes, criteria, cachedTypes);
+ }
+ }
+
+ private void loadTopLevelServerAndServiceTypes(final TypesLoadedCallback callback,
+ final EnumSet<MetadataType> metadataTypes,
+ final ResourceTypeCriteria criteria, final Map<Integer,
+ ResourceType> cachedTypes) {
+ ResourceTypeCriteria topLevelCriteria = new ResourceTypeCriteria();
+ topLevelCriteria.fetchParentResourceTypes(true);
+ resourceTypeService.findResourceTypesByCriteria(topLevelCriteria, new AsyncCallback<PageList<ResourceType>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.widget_typeCache_loadFail(), caught);
+ loadRequestedTypes(callback, metadataTypes, criteria, cachedTypes);
+ }
+
+ public void onSuccess(PageList<ResourceType> types) {
+ topLevelServerAndServiceTypes = new HashSet<ResourceType>();
+ for (ResourceType type : types) {
+ if ((type.getCategory() != ResourceCategory.PLATFORM) &&
+ (type.getParentResourceTypes() == null || type.getParentResourceTypes().isEmpty())) {
+ topLevelServerAndServiceTypes.add(type);
+ }
+ }
+ loadRequestedTypes(callback, metadataTypes, criteria, cachedTypes);
+ }
+ });
+ }
+
+ private void loadRequestedTypes(final TypesLoadedCallback callback, final EnumSet<MetadataType> metadataTypes, ResourceTypeCriteria criteria, final Map<Integer, ResourceType> cachedTypes) {
resourceTypeService.findResourceTypesByCriteria(criteria, new AsyncCallback<PageList<ResourceType>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.widget_typeCache_loadFail(), caught);
@@ -268,7 +307,15 @@ public class ResourceTypeRepository {
for (MetadataType metadataType : metadataTypes) {
switch (metadataType) {
case children:
- cachedType.setChildResourceTypes(type.getChildResourceTypes());
+ Set<ResourceType> childTypes = type.getChildResourceTypes();
+ if (type.getCategory() == ResourceCategory.PLATFORM &&
+ topLevelServerAndServiceTypes != null) {
+ // Add server and service types with no parent types to the list of child types.
+ // These types are implicitly children of all platform types, even though they
+ // are not included in the platform types' childResourceTypes field.
+ childTypes.addAll(topLevelServerAndServiceTypes);
+ }
+ cachedType.setChildResourceTypes(childTypes);
break;
case content:
cachedType.setPackageTypes(type.getPackageTypes());
@@ -304,7 +351,7 @@ public class ResourceTypeRepository {
break;
default:
Log.error("ERROR: metadataType " + metadataType.name()
- + " not merged into cached ResourceType.");
+ + " not merged into cached ResourceType.");
}
}
}
12 years, 9 months
[rhq] modules/enterprise
by ips
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/util/ConfigurationMaskingUtility.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
New commits:
commit 1307c8ddd76d5567fe7914c5b359dc8ad354cb67
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Aug 1 11:39:38 2011 -0400
[BZ 717921] fix potential IndexOutOfBoundsException in unmaskProperty() (https://bugzilla.redhat.com/show_bug.cgi?id=717921)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/util/ConfigurationMaskingUtility.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/util/ConfigurationMaskingUtility.java
index 2059064..0884fbb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/util/ConfigurationMaskingUtility.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/util/ConfigurationMaskingUtility.java
@@ -157,10 +157,11 @@ public class ConfigurationMaskingUtility {
// properties.
if (!memberProperties.isEmpty() && memberProperties.get(0) instanceof PropertyMap) {
PropertyList unmaskedPropertyList = unmaskedParentPropertyMap.getList(propertyList.getName());
- if (unmaskedPropertyList!=null) {
- for (int i = 0; i < propertyList.getList().size(); i++) {
+ if (unmaskedPropertyList != null) {
+ List<Property> unmaskedMemberProperties = unmaskedPropertyList.getList();
+ for (int i = 0; (i < memberProperties.size()) && (i < unmaskedMemberProperties.size()); i++) {
PropertyMap propertyMap = (PropertyMap) memberProperties.get(i);
- PropertyMap unmaskedPropertyMap = (PropertyMap) unmaskedPropertyList.getList().get(i);
+ PropertyMap unmaskedPropertyMap = (PropertyMap) unmaskedMemberProperties.get(i);
unmaskPropertyMap(propertyMap, unmaskedPropertyMap);
}
}
12 years, 9 months
[rhq] 77 commits - modules/common modules/core modules/enterprise modules/helpers modules/plugins modules/test-utils
by lkrejci
modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/BackupAndReplaceFileActionHandler.java | 8
modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/CompareDigestActionHandler.java | 16
modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/HandlerUtils.java | 9
modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/SetProcessStatusActionHandler.java | 6
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/i18n/PropertiesGenerator.java | 53 +-
modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/ExtensionModelTest.java | 5
modules/core/client-api/src/test/java/org/rhq/core/clientapi/descriptor/PluginTransformerTest.java | 2
modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/DBUpgrader.java | 24
modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/RetrieveContentBitsRunner.java | 13
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryFile.java | 10
modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginClassLoader.java | 12
modules/core/util/src/main/java/org/rhq/core/util/file/JarContentFileInfo.java | 1
modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java | 16
modules/core/util/src/test/java/org/rhq/core/util/ZipUtilTest.java | 4
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfiguration.java | 8
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/Version.java | 6
modules/enterprise/agentupdate/src/main/java/org/rhq/enterprise/agent/update/AgentUpdate.java | 10
modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/util/DumpBytes.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java | 31 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleFileUploadServlet.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PackageVersionFileUploadServlet.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java | 14
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/Version.java | 6
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java | 42 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java | 63 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java | 63 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java | 14
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 13
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java | 76 +-
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java | 4
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/ResourceCategory.java | 2
modules/plugins/byteman/src/main/java/org/rhq/plugins/byteman/BytemanRuleComponent.java | 2
modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java | 16
modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java | 6
modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java | 4
modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java | 4
modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java | 4
modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java | 6
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java | 46 -
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDiscoveryComponent.java | 3
modules/plugins/netservices/src/main/java/org/rhq/plugins/netservices/HTTPNetServiceComponent.java | 4
modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java | 7
modules/plugins/perftest/src/main/java/org/rhq/plugins/perftest/PerfTestDiscoveryComponent.java | 4
modules/plugins/perftest/src/main/java/org/rhq/plugins/perftest/ScenarioManager.java | 1
modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/yum/YumServer.java | 21
modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixServerDiscoveryComponent.java | 48 -
modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java | 3
modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentSnapshotReport.java | 9
modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerDiscoveryComponent.java | 49 +
modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java | 8
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatDiscoveryComponent.java | 9
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatGroupComponent.java | 3
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserComponent.java | 3
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java | 3
modules/plugins/virt/src/main/java/org/rhq/plugins/virt/LibVirtConnection.java | 264 ++++++----
modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationDomainComponent.java | 5
modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java | 16
61 files changed, 723 insertions(+), 412 deletions(-)
New commits:
commit ec88d4be0152d195ef769de97f43cdd289d77aeb
Merge: b38642e c4a82bc
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Aug 1 08:41:55 2011 +0200
Merge branch 'code-smell' into master
commit b38642e2f6dc7ea6ada5781440c7580336b38af6
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 23:47:32 2011 -0400
[coverity] fix NPE
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
index 60d6b0f..a57c686 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
@@ -20,7 +20,6 @@ package org.rhq.enterprise.server.alert;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -307,24 +306,26 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
public boolean finalizeNotifications(Subject subject, List<AlertNotification> notifications) {
boolean hasErrors = false;
-
+
AlertSenderPluginManager pluginManager = alertManager.getAlertPluginManager();
-
- for(AlertNotification notification : notifications) {
+
+ for (AlertNotification notification : notifications) {
AlertSender<?> sender = pluginManager.getAlertSenderForNotification(notification);
-
- AlertSenderValidationResults validation = sender.validateAndFinalizeConfiguration(subject);
-
- notification.setConfiguration(validation.getAlertParameters());
- notification.setExtraConfiguration(validation.getExtraParameters());
-
- hasErrors = hasErrors || hasErrors(validation.getAlertParameters()) ||
- hasErrors(validation.getExtraParameters());
- }
-
+
+ if (sender != null) {
+ AlertSenderValidationResults validation = sender.validateAndFinalizeConfiguration(subject);
+
+ notification.setConfiguration(validation.getAlertParameters());
+ notification.setExtraConfiguration(validation.getExtraParameters());
+
+ hasErrors = hasErrors || hasErrors(validation.getAlertParameters())
+ || hasErrors(validation.getExtraParameters());
+ }
+ }
+
return !hasErrors;
}
-
+
public int cleanseAlertNotificationBySubject(int subjectId) {
return cleanseParameterValueForAlertSender("System Users", "subjectId", String.valueOf(subjectId));
}
@@ -335,17 +336,17 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
public void massReconfigure(List<Integer> alertNotificationIds, Map<String, String> newConfigurationValues) {
Query query = entityManager.createNamedQuery(AlertNotification.QUERY_UPDATE_PARAMETER_FOR_NOTIFICATIONS);
-
+
query.setParameter("alertNotificationIds", alertNotificationIds);
-
- for(Map.Entry<String, String> entry : newConfigurationValues.entrySet()) {
+
+ for (Map.Entry<String, String> entry : newConfigurationValues.entrySet()) {
query.setParameter("propertyName", entry.getKey());
query.setParameter("propertyValue", entry.getValue());
-
+
query.executeUpdate();
}
}
-
+
private int cleanseParameterValueForAlertSender(String senderName, String propertyName, String valueToCleanse) {
Query query = entityManager.createNamedQuery(AlertNotification.QUERY_CLEANSE_PARAMETER_VALUE_FOR_ALERT_SENDER);
query.setParameter("senderName", senderName);
@@ -357,43 +358,43 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
private boolean hasErrors(AbstractPropertyMap configuration) {
if (configuration instanceof PropertyMap) {
- if (((PropertyMap)configuration).getErrorMessage() != null) {
+ if (((PropertyMap) configuration).getErrorMessage() != null) {
return true;
}
}
-
- for(Map.Entry<String, Property> entry : configuration.getMap().entrySet()) {
+
+ for (Map.Entry<String, Property> entry : configuration.getMap().entrySet()) {
if (hasErrors(entry.getValue())) {
return true;
}
}
-
+
return false;
}
-
+
private boolean hasErrors(PropertyList list) {
if (list.getErrorMessage() != null) {
return true;
}
-
- for(Property p : list.getList()) {
+
+ for (Property p : list.getList()) {
if (hasErrors(p)) {
return true;
}
}
-
+
return false;
}
-
+
private boolean hasErrors(Property property) {
if (property instanceof PropertySimple) {
return property.getErrorMessage() != null;
} else if (property instanceof PropertyList) {
return hasErrors((PropertyList) property);
} else if (property instanceof PropertyMap) {
- return hasErrors((AbstractPropertyMap)property);
+ return hasErrors((AbstractPropertyMap) property);
} else {
return false;
}
- }
+ }
}
commit 9537fe73100bcef9054098b2fa0f41f43b108e9d
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 23:44:09 2011 -0400
[coverity] fix NPE
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfiguration.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfiguration.java
index 3db9170..3f07f8b 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfiguration.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfiguration.java
@@ -661,6 +661,13 @@ public class AgentConfiguration {
long[] ret_params = isClientSenderCommandSpoolFileParamsValueValid(value);
+ // If the config was invalid, immediately fall back to our default just so we don't bomb out with a NPE later.
+ // We are guaranteed not to get a null returned if we pass in the hardcoded default params.
+ // The above method will have already logged a warning for us.
+ if (ret_params == null) {
+ ret_params = isClientSenderCommandSpoolFileParamsValueValid(AgentConfigurationConstants.DEFAULT_CLIENT_SENDER_COMMAND_SPOOL_FILE_PARAMS);
+ }
+
return ret_params;
}
@@ -1229,7 +1236,6 @@ public class AgentConfiguration {
return config;
}
-
/**
* This returns the agent's security token that it needs to send with its commands to the server. If <code>
* null</code>, it means the agent has not yet been registered with the server.
commit 7fd8a41c6bf1f3327e968611c5fb0452e6f455a4
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 23:29:58 2011 -0400
[coverity] fix NPE
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index 85f5e92..5860fb6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -53,8 +53,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceT
import org.rhq.enterprise.gui.coregui.client.menu.MenuBarView;
import org.rhq.enterprise.gui.coregui.client.report.ReportTopView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
-import org.rhq.enterprise.gui.coregui.client.test.TestRemoteServiceStatisticsView;
import org.rhq.enterprise.gui.coregui.client.test.TestDataSourceResponseStatisticsView;
+import org.rhq.enterprise.gui.coregui.client.test.TestRemoteServiceStatisticsView;
import org.rhq.enterprise.gui.coregui.client.test.TestTopView;
import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -524,10 +524,12 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String>, Event.Na
}
}.run(); // fire the timer immediately
} else {
- if (this.currentCanvas instanceof BookmarkableView) {
- ((BookmarkableView) this.currentCanvas).renderView(viewPath.next());
- } else {
- this.currentCanvas.markForRedraw();
+ if (this.currentCanvas != null) {
+ if (this.currentCanvas instanceof BookmarkableView) {
+ ((BookmarkableView) this.currentCanvas).renderView(viewPath.next());
+ } else {
+ this.currentCanvas.markForRedraw();
+ }
}
}
}
commit 47dad6a1bae981765565df5f6b25e0e2aacbc7a3
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 23:06:00 2011 -0400
[coverity] close initial contexts
diff --git a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
index b385473..cff3343 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
@@ -24,8 +24,13 @@ public class JPAUtils {
public static EntityManager lookupEntityManager() {
try {
- return ((EntityManagerFactory) getInitialContext().lookup("java:/RHQEntityManagerFactory"))
- .createEntityManager();
+ InitialContext initialContext = getInitialContext();
+ try {
+ return ((EntityManagerFactory) initialContext.lookup("java:/RHQEntityManagerFactory"))
+ .createEntityManager();
+ } finally {
+ initialContext.close();
+ }
} catch (NamingException e) {
throw new RuntimeException("Failed to load entity manager", e);
}
@@ -33,7 +38,12 @@ public class JPAUtils {
public static TransactionManager lookupTransactionManager() {
try {
- return (TransactionManager) getInitialContext().lookup("java:/TransactionManager");
+ InitialContext initialContext = getInitialContext();
+ try {
+ return (TransactionManager) initialContext.lookup("java:/TransactionManager");
+ } finally {
+ initialContext.close();
+ }
} catch (NamingException e) {
throw new RuntimeException("Failed to load transaction manager", e);
}
commit a0dcfe490b595b9c950eff69a1d4efa9410482d9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 23:04:17 2011 -0400
[coverity] fix NPE
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
index 38d0fa5..2321fd3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
@@ -591,8 +591,8 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
public void renderView(ViewPath viewPath) {
currentViewId = viewPath.getCurrent();
- String currentViewIdPath = currentViewId.getPath();
if (this.currentViewId != null) {
+ String currentViewIdPath = currentViewId.getPath();
if ("AutoCluster".equals(currentViewIdPath)) {
// Move the currentViewId to the ID portion to play better with other code
currentViewId = viewPath.getNext();
commit 5cd3024ccd2ef2712864f1331a7500d5b7abe1d8
Merge: ed7aad1 da99d5b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 22:55:15 2011 -0400
Merge commit 'origin/master' into code-smell
Conflicts:
modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
commit ed7aad1f40f87b6d484897d72eb2075836f7ae29
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 16:43:23 2011 -0400
[coverity] close initial contexts
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index e9ff990..5cd937b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -233,6 +233,7 @@ public final class LookupUtil {
try {
InitialContext context = new InitialContext();
DataSource ds = (DataSource) context.lookup(RHQConstants.DATASOURCE_JNDI_NAME);
+ context.close();
return ds;
} catch (Exception e) {
throw new RuntimeException("Failed to get the data source", e);
@@ -249,6 +250,7 @@ public final class LookupUtil {
try {
InitialContext context = new InitialContext();
TransactionManager tm = (TransactionManager) context.lookup(RHQConstants.TRANSACTION_MANAGER_JNDI_NAME);
+ context.close();
return tm;
} catch (Exception e) {
throw new RuntimeException("Failed to get the transaction manager", e);
@@ -678,7 +680,12 @@ public final class LookupUtil {
* @throws NamingException when resource not found
*/
private static Object lookup(String name) throws NamingException {
- return new InitialContext().lookup(name);
+ InitialContext initialContext = new InitialContext();
+ try {
+ return initialContext.lookup(name);
+ } finally {
+ initialContext.close();
+ }
}
public static DataAccessManagerLocal getDataAccessManager() {
commit 199940ca403f4123a2a6a753b196a12f975e207a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 16:24:39 2011 -0400
[coverity] close jar file
diff --git a/modules/enterprise/agentupdate/src/main/java/org/rhq/enterprise/agent/update/AgentUpdate.java b/modules/enterprise/agentupdate/src/main/java/org/rhq/enterprise/agent/update/AgentUpdate.java
index fc43008..704b48d 100644
--- a/modules/enterprise/agentupdate/src/main/java/org/rhq/enterprise/agent/update/AgentUpdate.java
+++ b/modules/enterprise/agentupdate/src/main/java/org/rhq/enterprise/agent/update/AgentUpdate.java
@@ -272,9 +272,13 @@ public class AgentUpdate {
private byte[] getJarFileContent(String filename) throws Exception {
JarFile jarFile = new JarFile(getJarFilename()); // use the jar file because user might have used --jar
- JarEntry jarFileEntry = jarFile.getJarEntry(filename);
- InputStream jarFileEntryStream = jarFile.getInputStream(jarFileEntry);
- return slurp(jarFileEntryStream);
+ try {
+ JarEntry jarFileEntry = jarFile.getJarEntry(filename);
+ InputStream jarFileEntryStream = jarFile.getInputStream(jarFileEntry);
+ return slurp(jarFileEntryStream);
+ } finally {
+ jarFile.close();
+ }
}
private void printSyntax() {
commit 9cabd191fd42b89a86d1fa6bd2290bc5ea7a16c3
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 16:22:35 2011 -0400
[coverity] close reader
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
index 693885f..9a071b7 100644
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
@@ -58,7 +58,7 @@ public class ScriptCommand implements ClientCommand {
private ScriptEngine jsEngine;
private StandardBindings bindings;
-
+
private final Log log = LogFactory.getLog(ScriptCommand.class);
private StringBuilder script = new StringBuilder();
@@ -85,7 +85,15 @@ public class ScriptCommand implements ClientCommand {
bindScriptArgs(scriptCmdLine);
executeUtilScripts();
- return executeScriptFile(new FileReader(scriptCmdLine.getScriptFileName()), client);
+ FileReader reader = new FileReader(scriptCmdLine.getScriptFileName());
+ try {
+ return executeScriptFile(reader, client);
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException ignore) {
+ }
+ }
} catch (FileNotFoundException e) {
client.getPrintWriter().println(e.getMessage());
if (log.isDebugEnabled()) {
@@ -97,8 +105,7 @@ public class ScriptCommand implements ClientCommand {
if (log.isDebugEnabled()) {
log.debug("A parse error occurred.", e);
}
- }
- else {
+ } else {
throw new CLIScriptException(e);
}
}
@@ -143,8 +150,8 @@ public class ScriptCommand implements ClientCommand {
} catch (ScriptException e) {
String message = e.getCause() != null ? e.getCause().getMessage() : e.getMessage();
- message = message.replace("sun.org.mozilla.javascript.internal.EcmaError: ","");
- message = message.replace("(<Unknown source>#1) in <Unknown source> at line number 1","");
+ message = message.replace("sun.org.mozilla.javascript.internal.EcmaError: ", "");
+ message = message.replace("(<Unknown source>#1) in <Unknown source> at line number 1", "");
client.getPrintWriter().println(message);
client.getPrintWriter().println(script);
@@ -162,9 +169,10 @@ public class ScriptCommand implements ClientCommand {
public void initBindings(ClientMain client) {
if (jsEngine == null) {
bindings = new StandardBindings(client.getPrintWriter(), client.getRemoteClient());
-
+
try {
- jsEngine = ScriptEngineFactory.getScriptEngine("JavaScript", new PackageFinder(Arrays.asList(getLibDir())), bindings);
+ jsEngine = ScriptEngineFactory.getScriptEngine("JavaScript", new PackageFinder(Arrays
+ .asList(getLibDir())), bindings);
jsEngine.eval("1+1");
} catch (ScriptException e) {
e.printStackTrace();
@@ -172,19 +180,20 @@ public class ScriptCommand implements ClientCommand {
e.printStackTrace();
}
}
-
+
bindings.getSubject().setValue(client.getSubject());
bindings.getPretty().getValue().setWidth(client.getConsoleWidth());
bindings.getProxyFactory().setValue(new EditableResourceClientFactory(client));
-
+
//non-standard bindings
bindings.put("configurationEditor", new ConfigurationEditor(client));
bindings.put("rhq", new Controller(client));
ScriptEngineFactory.injectStandardBindings(jsEngine, bindings, false);
-
- ScriptEngineFactory.bindIndirectionMethods(jsEngine, "configurationEditor", bindings.get("configurationEditor"));
- ScriptEngineFactory.bindIndirectionMethods(jsEngine, "rhq", bindings.get("rhq"));
+
+ ScriptEngineFactory
+ .bindIndirectionMethods(jsEngine, "configurationEditor", bindings.get("configurationEditor"));
+ ScriptEngineFactory.bindIndirectionMethods(jsEngine, "rhq", bindings.get("rhq"));
}
private void executeUtilScripts() {
@@ -253,8 +262,7 @@ public class ScriptCommand implements ClientCommand {
if (client.isInteractiveMode()) {
client.getPrintWriter().println(e.getMessage());
client.getPrintWriter().println("^");
- }
- else {
+ } else {
throw new CLIScriptException(e);
}
}
@@ -270,8 +278,8 @@ public class ScriptCommand implements ClientCommand {
}
public String getDetailedHelp() {
- return "Execute a statement or a script. The following services managers are available: " +
- RhqManagers.values();
+ return "Execute a statement or a script. The following services managers are available: "
+ + RhqManagers.values();
}
public ScriptContext getContext() {
commit 19c89919315d3a13f2894f9da829f1384e710053
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 16:20:31 2011 -0400
close streams (didn't see a coverity alert on this - I just came across it)
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/Version.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/Version.java
index 89280d9..e7f63a4 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/Version.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/Version.java
@@ -184,7 +184,11 @@ public class Version {
Properties newProps = new Properties();
try {
- newProps.load(stream);
+ try {
+ newProps.load(stream);
+ } finally {
+ stream.close();
+ }
} catch (Exception e) {
throw new RuntimeException(e);
}
commit b7a146b5eae72b2545ceead0a45c79420355be7a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 16:18:49 2011 -0400
[coverity] close stream
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/Version.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/Version.java
index 84e9ec0..0150a9c 100644
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/Version.java
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/Version.java
@@ -190,7 +190,11 @@ public class Version {
try {
URL jarUrl = Version.class.getProtectionDomain().getCodeSource().getLocation();
JarFile jarFile = new JarFile(new File(jarUrl.toURI()));
- manifest = jarFile.getManifest();
+ try {
+ manifest = jarFile.getManifest();
+ } finally {
+ jarFile.close();
+ }
} catch (Exception e) {
return new Properties();
}
commit 2a8e27ee809f2d812b72b15fcbb5ee8a0485c653
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 16:15:31 2011 -0400
[converity] close stream
diff --git a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/util/DumpBytes.java b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/util/DumpBytes.java
index 8bb9865..4d5848f 100644
--- a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/util/DumpBytes.java
+++ b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/util/DumpBytes.java
@@ -167,9 +167,13 @@ public class DumpBytes {
int num_bytes;
try {
- fis = new FileInputStream(file);
file_contents = new byte[(int) file.length()];
- num_bytes = fis.read(file_contents);
+ fis = new FileInputStream(file);
+ try {
+ num_bytes = fis.read(file_contents);
+ } finally {
+ fis.close();
+ }
if (num_bytes != file_contents.length) {
throw new IllegalStateException(num_bytes + "!=" + file_contents.length);
commit 0fac1e88882631275804d98d47c910b005f1050e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 16:11:15 2011 -0400
[coverity] close input streams
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
index 052bf11..db04c59 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
@@ -92,7 +92,12 @@ public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements Syst
File file = agentManager.getAgentUpdateVersionFile();
Properties props = new Properties();
- props.load(new FileInputStream(file));
+ FileInputStream inStream = new FileInputStream(file);
+ try {
+ props.load(inStream);
+ } finally {
+ inStream.close();
+ }
return convertFromProperties(props);
} catch (Throwable t) {
@@ -143,7 +148,12 @@ public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements Syst
File versionFile = new File(getClientDownloadDir(), "rhq-client-version.properties");
try {
Properties p = new Properties();
- p.load(new FileInputStream(versionFile));
+ FileInputStream inStream = new FileInputStream(versionFile);
+ try {
+ p.load(inStream);
+ } finally {
+ inStream.close();
+ }
return convertFromProperties(p);
} catch (Throwable t) {
throw getExceptionToThrowToClient(t, "Unable to retrieve client version info.");
commit 2e3d2af81ea989a9dad7d9ccc5c6e551a085d879
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 15:53:19 2011 -0400
[coverity] close input streams
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/RetrieveContentBitsRunner.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/RetrieveContentBitsRunner.java
index 3bdafda..b339190 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/RetrieveContentBitsRunner.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/RetrieveContentBitsRunner.java
@@ -86,7 +86,12 @@ public class RetrieveContentBitsRunner implements Runnable {
InputStream is;
try {
is = contentManager.performGetPackageBits(request.getResourceId(), request.getPackageDetails());
- pkgDetails.setSHA256(new MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(is));
+ try {
+ pkgDetails.setSHA256(new MessageDigestGenerator(MessageDigestGenerator.SHA_256)
+ .calcDigestString(is));
+ } finally {
+ is.close();
+ }
} catch (Exception e) {
e.printStackTrace();
}
@@ -95,7 +100,11 @@ public class RetrieveContentBitsRunner implements Runnable {
InputStream is;
try {
is = contentManager.performGetPackageBits(request.getResourceId(), request.getPackageDetails());
- pkgDetails.setMD5((new MessageDigestGenerator(MessageDigestGenerator.MD5).calcDigestString(is)));
+ try {
+ pkgDetails.setMD5((new MessageDigestGenerator(MessageDigestGenerator.MD5).calcDigestString(is)));
+ } finally {
+ is.close();
+ }
} catch (Exception e) {
e.printStackTrace();
}
commit 302b7ee7c388f0db5f7cf926308034b5041de7ad
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 15:44:49 2011 -0400
[coverity] be nice and close the context. don't worry about doing it
in a try-finally - if the lookup fails, we have more important things
to worry about then not closing the context - such as we don't
have a hibernate entity manager available!
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index b399741..e9ff990 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -266,6 +266,7 @@ public final class LookupUtil {
try {
InitialContext context = new InitialContext();
EntityManagerFactory factory = (EntityManagerFactory) context.lookup(RHQConstants.ENTITY_MANAGER_JNDI_NAME);
+ context.close();
return factory.createEntityManager();
} catch (Exception e) {
throw new RuntimeException("Failed to create an entity manager", e);
@@ -653,7 +654,8 @@ public final class LookupUtil {
localJNDIName = getLocalJNDIName(type);
return (T) lookup(localJNDIName);
} catch (NamingException e) {
- throw new RuntimeException("Failed to lookup local interface to EJB " + type + ", localJNDI=[" + localJNDIName + "]", e);
+ throw new RuntimeException("Failed to lookup local interface to EJB " + type + ", localJNDI=["
+ + localJNDIName + "]", e);
}
}
commit 796ac12453e260f24228add540934d9a128804bf
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 15:40:00 2011 -0400
[coverity] close the initial context
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
index 85fb5b8..a2bdaa9 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
@@ -109,12 +109,20 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
}
public EntityManager getEntityManager() {
+ InitialContext initialContext = null;
try {
- return ((EntityManagerFactory) getInitialContext().lookup("java:/RHQEntityManagerFactory"))
+ initialContext = getInitialContext();
+ return ((EntityManagerFactory) initialContext.lookup("java:/RHQEntityManagerFactory"))
.createEntityManager();
} catch (NamingException e) {
e.printStackTrace();
throw new RuntimeException("Failed to load entity manager", e);
+ } finally {
+ try {
+ initialContext.close();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to close the initial context - why did this happen?", e);
+ }
}
}
commit a07dc82e8347ce2f1e7e42f9520fb3d4d5f7f3b6
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 15:33:05 2011 -0400
[coverity] closing the initial context explicitly
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
index 57ec318..85fb5b8 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
@@ -35,15 +35,13 @@ import javax.transaction.TransactionManager;
import org.testng.AssertJUnit;
import org.testng.annotations.AfterGroups;
-import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeGroups;
-import org.testng.annotations.BeforeSuite;
import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
import org.jboss.ejb3.embedded.EJB3StandaloneDeployer;
public abstract class AbstractEJB3Test extends AssertJUnit {
-// @BeforeSuite(groups = "integration.ejb3")
+ // @BeforeSuite(groups = "integration.ejb3")
@BeforeGroups(groups = "integration.ejb3")
public static void startupEmbeddedJboss() {
System.out.println("Starting ejb3...");
@@ -84,7 +82,7 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
}
}
-// @AfterSuite
+ // @AfterSuite
@AfterGroups(groups = "integration.ejb3")
public static void shutdownEmbeddedJboss() {
EJB3StandaloneBootstrap.shutdown();
@@ -93,12 +91,20 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
private TransactionManager tm;
public TransactionManager getTransactionManager() {
+ InitialContext initialContext = null;
try {
- tm = (TransactionManager) getInitialContext().lookup("java:/TransactionManager");
+ initialContext = getInitialContext();
+ tm = (TransactionManager) initialContext.lookup("java:/TransactionManager");
return tm;
} catch (NamingException e) {
e.printStackTrace();
throw new RuntimeException("Failed to load transaction manager", e);
+ } finally {
+ try {
+ initialContext.close();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to close the initial context - why did this happen?", e);
+ }
}
}
commit e0bb9de07efb271a80e98f53a4c09e75c9b1d73e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 15:23:01 2011 -0400
[coverity] close the jar file for the test
diff --git a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/descriptor/PluginTransformerTest.java b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/descriptor/PluginTransformerTest.java
index 2e3374f..714d9b5 100644
--- a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/descriptor/PluginTransformerTest.java
+++ b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/descriptor/PluginTransformerTest.java
@@ -311,7 +311,7 @@ public class PluginTransformerTest {
JarFile jarFile = new JarFile(pluginJarFile);
Manifest manifest = jarFile.getManifest();
Attributes attributes = manifest.getMainAttributes();
-
+ jarFile.close();
return attributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
}
commit 59a739e6a77f05d48ede89e5dc416ea670ad478c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 15:13:36 2011 -0400
[coverity] this isn't used anywhere, but we may revive it later. close the input stream properly.
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/i18n/PropertiesGenerator.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/i18n/PropertiesGenerator.java
index 93a9c56..3c9d64f 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/i18n/PropertiesGenerator.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/i18n/PropertiesGenerator.java
@@ -1,25 +1,25 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
package org.rhq.core.clientapi.agent.metadata.i18n;
import java.io.File;
@@ -34,9 +34,11 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -106,7 +108,12 @@ public class PropertiesGenerator {
if (update) {
// First load into properties we can check for existence
previousProperties = new Properties();
- previousProperties.load(new FileInputStream(propertiesFile));
+ FileInputStream is = new FileInputStream(propertiesFile);
+ try {
+ previousProperties.load(is);
+ } finally {
+ is.close();
+ }
this.contentWriter.println("\n\n# Contents added " + new Date() + "\n\n");
}
commit 2300051a18838bb45b6f33ca4a15ffba8f076c2a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 15:08:43 2011 -0400
[coverity] make sure we close the jar file
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/file/JarContentFileInfo.java b/modules/core/util/src/main/java/org/rhq/core/util/file/JarContentFileInfo.java
index c24fb54..529f317 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/file/JarContentFileInfo.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/file/JarContentFileInfo.java
@@ -168,6 +168,7 @@ public class JarContentFileInfo extends ContentFileInfo {
JarFile jarFile = new JarFile(file);
if (null != jarFile) {
manifest = jarFile.getManifest();
+ jarFile.close();
}
} else {
File manifestFile = new File(file, "/META-INF/MANIFEST.MF");
commit f816103dfd72e5108772459d4673eb6226cf0a19
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 14:56:55 2011 -0400
[coverity] close the pid file
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java
index e4d7575..325ed20 100644
--- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java
@@ -18,18 +18,6 @@
*/
package org.rhq.plugins.mysql;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.DataType;
-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.InvalidPluginConfigurationException;
-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.util.jdbc.JDBCUtil;
-import org.rhq.plugins.database.DatabaseComponent;
-
import java.io.File;
import java.io.FileReader;
import java.sql.Connection;
@@ -43,8 +31,19 @@ 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.DataType;
+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.InvalidPluginConfigurationException;
+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.system.AggregateProcessInfo;
import org.rhq.core.system.ProcessInfo;
+import org.rhq.plugins.database.DatabaseComponent;
import org.rhq.plugins.database.DatabaseQueryUtility;
/**
@@ -129,7 +128,7 @@ public class MySqlComponent implements DatabaseComponent, ResourceComponent, Mea
} else if ("Process.aggregateMemory.size".equals(requestName)) {
long value = aggregateProcessInfo.getAggregateMemory().getSize();
report.addData(new MeasurementDataNumeric(request, new Double((double) value)));
- }else if ("Process.aggregateMemory.pageFaults".equals(requestName)) {
+ } else if ("Process.aggregateMemory.pageFaults".equals(requestName)) {
long value = aggregateProcessInfo.getAggregateMemory().getPageFaults();
report.addData(new MeasurementDataNumeric(request, new Double((double) value)));
} else if ("Process.aggregateCpu.user".equals(requestName)) {
@@ -141,12 +140,12 @@ public class MySqlComponent implements DatabaseComponent, ResourceComponent, Mea
} else if ("Process.aggregateCpu.percent".equals(requestName)) {
double value = aggregateProcessInfo.getAggregateCpu().getPercent();
report.addData(new MeasurementDataNumeric(request, new Double(value)));
- } else if ("Process.aggregateCpu.total".equals(requestName)) {
+ } else if ("Process.aggregateCpu.total".equals(requestName)) {
long value = aggregateProcessInfo.getAggregateCpu().getTotal();
- report.addData(new MeasurementDataNumeric(request, new Double((double)value)));
- }else if ("Process.aggregateFileDescriptor.total".equals(requestName)) {
+ report.addData(new MeasurementDataNumeric(request, new Double((double) value)));
+ } else if ("Process.aggregateFileDescriptor.total".equals(requestName)) {
long value = aggregateProcessInfo.getAggregateFileDescriptor().getTotal();
- report.addData(new MeasurementDataNumeric(request, new Double((double)value)));
+ report.addData(new MeasurementDataNumeric(request, new Double((double) value)));
}
} else {
if (request.getDataType() == DataType.MEASUREMENT) {
@@ -202,11 +201,15 @@ public class MySqlComponent implements DatabaseComponent, ResourceComponent, Mea
if (file.canRead()) {
try {
FileReader pidFileReader = new FileReader(file);
- char pidData[] = new char[(int)file.length()];
- pidFileReader.read(pidData);
- String pidString = new String(pidData);
- pidString = pidString.trim();
- result = Long.valueOf(pidString);
+ try {
+ char pidData[] = new char[(int) file.length()];
+ pidFileReader.read(pidData);
+ String pidString = new String(pidData);
+ pidString = pidString.trim();
+ result = Long.valueOf(pidString);
+ } finally {
+ pidFileReader.close();
+ }
} catch (Exception ex) {
log.warn("Unable to read MySQL pid file " + pidFile);
}
commit bd2129db2d7f4e76efc938986674d24beebd1b4f
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 14:28:47 2011 -0400
[coverity] not really necessary I don't think - seems like Bundle Manager Bean closes the stream for us. but just in case...
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleFileUploadServlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleFileUploadServlet.java
index 71ff5f4..3081883 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleFileUploadServlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleFileUploadServlet.java
@@ -58,11 +58,14 @@ public class BundleFileUploadServlet extends FileUploadServlet {
String version = getFormField(formFields, "version", Integer.toString(bundleVersionId));
Architecture architecture = new Architecture(getFormField(formFields, "arch", "noarch"));
InputStream fileStream = new FileInputStream(file);
-
- BundleManagerLocal bundleManager = LookupUtil.getBundleManager();
- BundleFile bundleFile = bundleManager.addBundleFile(subject, bundleVersionId, name, version, architecture,
- fileStream);
- successMsg = "success [" + bundleFile.getId() + "]";
+ try {
+ BundleManagerLocal bundleManager = LookupUtil.getBundleManager();
+ BundleFile bundleFile = bundleManager.addBundleFile(subject, bundleVersionId, name, version,
+ architecture, fileStream);
+ successMsg = "success [" + bundleFile.getId() + "]";
+ } finally {
+ fileStream.close(); // I don't think this is necessary (seems BundleManager closes it for us) but do it anyway just in case
+ }
} catch (Exception e) {
writeExceptionResponse(response, "Failed to upload bundle file", e); // clients will look for this string!
return;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PackageVersionFileUploadServlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PackageVersionFileUploadServlet.java
index 9aed016..0795914 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PackageVersionFileUploadServlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PackageVersionFileUploadServlet.java
@@ -32,7 +32,6 @@ import javax.servlet.http.HttpServletResponse;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.PackageVersion;
import org.rhq.enterprise.server.content.ContentManagerLocal;
-import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -73,8 +72,6 @@ public class PackageVersionFileUploadServlet extends FileUploadServlet {
if (repoIdS != null) {
repoId = Integer.parseInt(repoIdS);
}
-
- InputStream fileStream = new FileInputStream(file);
//use getUploadedPackageVersion instead of createPackageVersion here
//because createPackageVersion successfully returns an already existing
@@ -84,10 +81,15 @@ public class PackageVersionFileUploadServlet extends FileUploadServlet {
Map<String, String> metaData = new HashMap<String, String>();
metaData.put(ContentManagerLocal.UPLOAD_FILE_INSTALL_DATE, Long.toString(file.lastModified()));
metaData.put(ContentManagerLocal.UPLOAD_FILE_NAME, packageName);
- PackageVersion packageVersion = contentManager.getUploadedPackageVersion(subject, packageName,
- packageTypeId, version, architectureId, fileStream, metaData, repoId);
-
- successMsg = "success [packageVersionId=" + packageVersion.getId() + ",packageId=" + packageVersion.getGeneralPackage().getId() + "]";
+ InputStream fileStream = new FileInputStream(file);
+ try {
+ PackageVersion packageVersion = contentManager.getUploadedPackageVersion(subject, packageName,
+ packageTypeId, version, architectureId, fileStream, metaData, repoId);
+ successMsg = "success [packageVersionId=" + packageVersion.getId() + ",packageId="
+ + packageVersion.getGeneralPackage().getId() + "]";
+ } finally {
+ fileStream.close();
+ }
} catch (Exception e) {
writeExceptionResponse(response, "Failed to upload file", e); // clients will look for this string!
return;
commit c59a821e4bc8ee18d19262f4c5887af6545eb5de
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 14:19:06 2011 -0400
[coverity] make sure we close the input stream
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/DBUpgrader.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/DBUpgrader.java
index d4c055f..9a0c91b 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/DBUpgrader.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/ant/dbupgrade/DBUpgrader.java
@@ -20,6 +20,7 @@ package org.rhq.core.db.ant.dbupgrade;
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -28,9 +29,12 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+
import mazz.i18n.Msg;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
+
import org.rhq.core.db.DatabaseType;
import org.rhq.core.db.DatabaseTypeFactory;
import org.rhq.core.db.DbUtil;
@@ -70,16 +74,16 @@ public class DBUpgrader extends Task {
private Connection connection;
private boolean doCloseConnection;
-
+
public DBUpgrader() {
doCloseConnection = true;
}
-
+
public DBUpgrader(Connection connection) {
this.connection = connection;
doCloseConnection = false;
}
-
+
/**
* The URL to the database that is to be upgraded.
*
@@ -339,12 +343,20 @@ public class DBUpgrader extends Task {
if (typeMapFile == null) {
typeMaps = TypeMap.loadKnownTypeMaps();
} else {
+ FileInputStream fis = null;
try {
- FileInputStream fis = new FileInputStream(typeMapFile);
+ fis = new FileInputStream(typeMapFile);
typeMaps = TypeMap.loadTypeMapsFromStream(fis);
} catch (Exception e) {
throw new BuildException(MSG.getMsg(DbAntI18NResourceKeys.DBUPGRADE_TYPE_MAP_FILE_ERROR, typeMapFile
.getAbsolutePath(), e), e);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ }
+ }
}
}
@@ -461,7 +473,7 @@ public class DBUpgrader extends Task {
if (connection == null) {
connection = DbUtil.getConnection(jdbcUrl, jdbcUser, jdbcPassword);
}
- return connection;
+ return connection;
}
/**
@@ -474,7 +486,7 @@ public class DBUpgrader extends Task {
this.connection = connection;
doCloseConnection = connection == null;
}
-
+
/**
* Returns the type of database that is being upgraded.
*
commit fb8f4905912ba0bbc63d1aabc8dae84e10619b32
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 14:12:13 2011 -0400
[coverity] just a test class, but it should still close the stream to be a good citizen
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/ZipUtilTest.java b/modules/core/util/src/test/java/org/rhq/core/util/ZipUtilTest.java
index 4bada6d..8ddcf1e 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/ZipUtilTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/ZipUtilTest.java
@@ -74,7 +74,9 @@ public class ZipUtilTest {
destFile.mkdirs();
} else {
destFile.getParentFile().mkdirs();
- StreamUtil.copy(stream, new FileOutputStream(destFile), false);
+ FileOutputStream fos = new FileOutputStream(destFile);
+ StreamUtil.copy(stream, fos, false);
+ fos.close();
}
return true;
}
commit 7db43fdbd624ec1227a1d7745b67b59f39a9fe1e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 14:07:38 2011 -0400
[coverity] paranoia - just make sure we always close the file stream, avoiding the possibility that Buffered stream constructor bombs would leave the file stream open
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginClassLoader.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginClassLoader.java
index 25be7de..a9b07f2 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginClassLoader.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginClassLoader.java
@@ -205,21 +205,24 @@ public class PluginClassLoader extends URLClassLoader {
}
}
- BufferedOutputStream outputStream;
+ FileOutputStream fileOutputStream;
try {
- outputStream = new BufferedOutputStream(new FileOutputStream(file));
+ fileOutputStream = new FileOutputStream(file);
} catch (FileNotFoundException ex) {
if (file.exists() && (file.length() > 0)) {
// e.g. on win32, agent running w/ dll loaded PluginDumper cannot overwrite file inuse.
continue;
}
-
throw ex;
}
+ BufferedOutputStream outputStream = new BufferedOutputStream(fileOutputStream);
try {
file.deleteOnExit();
+ // do NOT close this inputStream since it is buffering the ZipInputStream
+ // and we are going to still process that input stream later. We close
+ // this ZipInputStream down below in the outer most try-finally block.
BufferedInputStream inputStream = new BufferedInputStream(zis);
int count;
@@ -229,13 +232,12 @@ public class PluginClassLoader extends URLClassLoader {
}
} finally {
outputStream.flush();
- outputStream.close();
+ outputStream.close(); // this also closes the fileOutputStream
}
} catch (IOException ioe) {
if (file != null) {
file.delete();
}
-
throw ioe;
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
index fa26970..90e2117 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginClassLoader.java
@@ -133,37 +133,39 @@ public class ServerPluginClassLoader extends URLClassLoader {
}
}
- BufferedOutputStream outputStream;
+ FileOutputStream fileOutputStream;
try {
- outputStream = new BufferedOutputStream(new FileOutputStream(file));
+ fileOutputStream = new FileOutputStream(file);
} catch (FileNotFoundException ex) {
if (file.exists() && (file.length() > 0)) {
// e.g. on win32, agent running w/ dll loaded PluginDumper cannot overwrite file inuse.
continue;
}
-
throw ex;
}
+ BufferedOutputStream outputStream = new BufferedOutputStream(fileOutputStream);
try {
file.deleteOnExit();
+ // do NOT close this inputStream since it is buffering the ZipInputStream
+ // and we are going to still process that input stream later. We close
+ // this ZipInputStream down below in the outer most try-finally block.
BufferedInputStream inputStream = new BufferedInputStream(zis);
- int count = 0;
+ int count;
byte[] b = new byte[8192];
while ((count = inputStream.read(b)) > -1) {
outputStream.write(b, 0, count);
}
} finally {
outputStream.flush();
- outputStream.close();
+ outputStream.close(); // this also closes the fileOutputStream
}
} catch (IOException ioe) {
if (file != null) {
file.delete();
}
-
throw ioe;
}
}
commit 2f53d69eccc94ffa068ed1483ca3d7d6db9d776e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 13:00:09 2011 -0400
opps, fix comment
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java
index e2fc414..5697374 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java
@@ -939,7 +939,7 @@ public class ServerCommunicationsService implements ServerCommunicationsServiceM
return server_configuration;
} finally {
- // we know this isn't non-null; if it was, we would have thrown the IOException earlier.
+ // we know this is not null; if it was, we would have thrown the IOException earlier.
config_file_input_stream.close();
}
}
commit b09ab768bc1d84ab27476536237f28e09506387f
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 12:58:59 2011 -0400
[coverity] close the config file input stream
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java
index 29116d8..e2fc414 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java
@@ -439,12 +439,12 @@ public class ServerCommunicationsService implements ServerCommunicationsServiceM
try {
ClientCommandSenderConfiguration sender_config = getSenderConfiguration(agent);
if (sender_config.commandSpoolFileName != null) {
- spool_file = new File(sender_config.dataDirectory, sender_config.commandSpoolFileName);
- if (spool_file.exists()) {
- // first truncate it, in case Windows is locking it; then try to delete
- new FileOutputStream(spool_file, false).close();
- spool_file.delete();
- }
+ spool_file = new File(sender_config.dataDirectory, sender_config.commandSpoolFileName);
+ if (spool_file.exists()) {
+ // first truncate it, in case Windows is locking it; then try to delete
+ new FileOutputStream(spool_file, false).close();
+ spool_file.delete();
+ }
}
} catch (Exception e) {
LOG.warn("Failed to truncate/delete spool for deleted agent [" + agent + "]"
@@ -907,36 +907,41 @@ public class ServerCommunicationsService implements ServerCommunicationsServiceM
// But first we need to backup these original preferences in case the config file fails to load -
// we'll restore the original values in that case.
- Preferences preferences_node = getPreferencesNode();
- ByteArrayOutputStream backup = new ByteArrayOutputStream();
- preferences_node.exportSubtree(backup);
- preferences_node.clear();
-
- // now load in the preferences
try {
- Preferences.importPreferences(config_file_input_stream);
+ Preferences preferences_node = getPreferencesNode();
+ ByteArrayOutputStream backup = new ByteArrayOutputStream();
+ preferences_node.exportSubtree(backup);
+ preferences_node.clear();
- if (new ServerConfiguration(preferences_node).getServerConfigurationVersion() == 0) {
- throw new IllegalArgumentException(LOG.getMsgString(
- ServerI18NResourceKeys.BAD_NODE_NAME_IN_CONFIG_FILE, file_name, preferences_node_name));
- }
- } catch (Exception e) {
- // a problem occurred importing the config file; let's restore our original values
+ // now load in the preferences
try {
- Preferences.importPreferences(new ByteArrayInputStream(backup.toByteArray()));
- } catch (Exception e1) {
- // its conceivable the same problem occurred here as with the original exception (backing store problem?)
- // let's throw the original exception, not this one
- }
+ Preferences.importPreferences(config_file_input_stream);
- throw e;
- }
+ if (new ServerConfiguration(preferences_node).getServerConfigurationVersion() == 0) {
+ throw new IllegalArgumentException(LOG.getMsgString(
+ ServerI18NResourceKeys.BAD_NODE_NAME_IN_CONFIG_FILE, file_name, preferences_node_name));
+ }
+ } catch (Exception e) {
+ // a problem occurred importing the config file; let's restore our original values
+ try {
+ Preferences.importPreferences(new ByteArrayInputStream(backup.toByteArray()));
+ } catch (Exception e1) {
+ // its conceivable the same problem occurred here as with the original exception (backing store problem?)
+ // let's throw the original exception, not this one
+ }
- ServerConfiguration server_configuration = new ServerConfiguration(preferences_node);
+ throw e;
+ }
- LOG.debug(ServerI18NResourceKeys.LOADED_CONFIG_FILE, file_name);
+ ServerConfiguration server_configuration = new ServerConfiguration(preferences_node);
- return server_configuration;
+ LOG.debug(ServerI18NResourceKeys.LOADED_CONFIG_FILE, file_name);
+
+ return server_configuration;
+ } finally {
+ // we know this isn't non-null; if it was, we would have thrown the IOException earlier.
+ config_file_input_stream.close();
+ }
}
/**
commit 4b3e3a6e01e2f599af8a21a14c37debc92060cc1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 12:37:04 2011 -0400
[coverity] close the context - no need to keep it open since we just create it to see that no exceptions occurred.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
index be7a0ab..a4124ca 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
@@ -209,7 +209,7 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
}
log.debug("Validating LDAP with environment=" + env);
- new InitialLdapContext(env, null);
+ new InitialLdapContext(env, null).close();
return;
}
commit 0329aa66eaea0e3a53b4c7682e9e49d3a28d0750
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 12:17:21 2011 -0400
[coverity] make sure to close the file
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryFile.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryFile.java
index 7a8e1e5..ea5e7fd 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryFile.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryFile.java
@@ -103,8 +103,9 @@ public class InventoryFile {
* inventory
*/
public void loadInventory() throws PluginContainerException {
+ FileInputStream fis = null;
try {
- FileInputStream fis = new FileInputStream(inventoryFile);
+ fis = new FileInputStream(inventoryFile);
ObjectInputStream ois = new ObjectInputStream(fis);
// this list will contain UUIDs of resources that we should ignore usually due to disabled plugins
@@ -126,6 +127,13 @@ public class InventoryFile {
return;
} catch (Exception e) {
throw new PluginContainerException("Cannot load inventory file: " + inventoryFile, e);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (Exception e) {
+ }
+ }
}
}
commit 203bb4b9b7d4107d7332754709b6bc9ec5851771
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 12:12:05 2011 -0400
[coverity] make sure we close the printwriter in finally block
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/yum/YumServer.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/yum/YumServer.java
index dc92a61..3524b9b 100644
--- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/yum/YumServer.java
+++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/yum/YumServer.java
@@ -178,15 +178,18 @@ public class YumServer {
File file = new File(yumconf);
try {
PrintWriter writer = new PrintWriter(file);
- writer.println("[rhq]");
- writer.println("name=RHQ");
- writer.printf("baseurl=%s\n", context.baseurl());
- writer.printf("metadata_expire=%d\n", context.getMetadataCacheTimeout());
- writer.println("enabled=1");
- writer.println("gpgcheck=0");
- writer.println("keepalive=0");
- writer.println("timeout=90");
- writer.close();
+ try {
+ writer.println("[rhq]");
+ writer.println("name=RHQ");
+ writer.printf("baseurl=%s\n", context.baseurl());
+ writer.printf("metadata_expire=%d\n", context.getMetadataCacheTimeout());
+ writer.println("enabled=1");
+ writer.println("gpgcheck=0");
+ writer.println("keepalive=0");
+ writer.println("timeout=90");
+ } finally {
+ writer.close();
+ }
} catch (Exception e) {
String msg = "The yum repo configuration file '" + file + "' could not be created/updated!";
log.error(msg, e);
commit 3a558fe5559b55707cb861e72a3d307a6a24b2a6
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 11:42:07 2011 -0400
[coverity] this should have been an assert - and if it was, this unit test would have failed only because the casting was incorrect.
the code it was testing actually worked. I'm fixing the test so this actually asserts the correct thing.
diff --git a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/ExtensionModelTest.java b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/ExtensionModelTest.java
index 3d9fb10..06fc087 100644
--- a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/ExtensionModelTest.java
+++ b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/ExtensionModelTest.java
@@ -37,6 +37,7 @@ import org.rhq.core.clientapi.agent.metadata.PluginMetadataManager;
import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
import org.rhq.core.clientapi.descriptor.DescriptorPackages;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
@@ -130,7 +131,9 @@ public class ExtensionModelTest {
assert !def1.isRequired();
assert def1 instanceof PropertyDefinitionSimple;
assert ((PropertyDefinitionSimple) def1).getType().equals(PropertySimpleType.BOOLEAN);
- def1.getConfigurationDefinition().getDefaultTemplate().getConfiguration().get("force").equals("false");
+ PropertySimple prop = (PropertySimple) def1.getConfigurationDefinition().getDefaultTemplate()
+ .getConfiguration().get("force");
+ assert prop.getBooleanValue().booleanValue() == false;
assert stopOp.getResultsConfigurationDefinition() != null;
ConfigurationDefinition results = stopOp.getResultsConfigurationDefinition();
commit d85516841d7bead784f587535c1364d47185b7a9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 11:23:34 2011 -0400
[coverity] the if-stmt looks bad, but anyway, this handler doesn't do anything anyway, the main code inside it was commented out.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java
index cce560c..007f908 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java
@@ -38,9 +38,6 @@ import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.Event.NativePreviewHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
@@ -129,17 +126,23 @@ public class SearchBar extends AbstractSearchBar {
String searchButtonId = searchBarElement.getAttribute("searchButtonId");
searchButton = DOM.getElementById(searchButtonId);
- Event.addNativePreviewHandler(new NativePreviewHandler() {
- public void onPreviewNativeEvent(NativePreviewEvent event) {
- if (event.getNativeEvent() != null && event.getNativeEvent().getEventTarget() != null) {
-
- if (event.getNativeEvent().getEventTarget().equals(searchButton)
- && event.getTypeInt() == Event.ONMOUSEDOWN) {
- //prepareSearchExecution();
- }
- }
- }
- });
+ // Don't know what this originally was going to be used for, but if you notice,
+ // after all the if-stmts are evaluated true, the only piece of code to be invoked
+ // (prepareSearchExecution()) has been commented out. So this is a no-op. In addition
+ // the second if-stmt (getEventTarget().equals(searchButton) doesn't look correct and
+ // may not ever evaluate to true anyway. Commenting this out, in case something like this
+ // is needed in the future, but we'll havee to probably fix that if-stmt first.
+
+ // Event.addNativePreviewHandler(new NativePreviewHandler() {
+ // public void onPreviewNativeEvent(NativePreviewEvent event) {
+ // if (event.getNativeEvent() != null && event.getNativeEvent().getEventTarget() != null) {
+ // if (event.getNativeEvent().getEventTarget().equals(searchButton)
+ // && event.getTypeInt() == Event.ONMOUSEDOWN) {
+ // //prepareSearchExecution();
+ // }
+ // }
+ // }
+ // });
String searchSubsystem = searchBarElement.getAttribute("searchSubsystem");
setSearchSubsystem(SearchSubsystem.valueOf(searchSubsystem.toUpperCase()));
commit e7bcd08184a293f0fa745e4fe8a1167dd552bb68
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 28 11:15:21 2011 -0400
[coverity] fix NPE
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
index 71f5ec5..047f5af 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
@@ -296,7 +296,8 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo
SubTab subTab = tab.getDefaultSubTab();
if (subTab == null || tab.getLayout().isSubTabDisabled(subTab)) {
- CoreGUI.getErrorHandler().handleError(MSG.view_tabs_invalidSubTab(subTab.getName()));
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_tabs_invalidSubTab((subTab != null ? subTab.getName() : "null")));
subTab = tab.getLayout().getDefaultSubTab();
}
commit 4120c6b83a25a6b52c44e8e5a6fa528989f8c4a5
Merge: 447cd29 c8dc1d8
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Jul 14 11:46:34 2011 +0200
Merge branch 'master' into code-smell
diff --cc modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java
index e84d7d4,be0446b..d21ab62
--- a/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java
@@@ -23,9 -23,10 +23,11 @@@
package org.rhq.core.util.stream;
import java.io.BufferedInputStream;
+ import java.io.BufferedReader;
+ import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
commit 447cd29b3c4d39c80fabc990096807353544d258
Merge: f7aa5f5 32b8223
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Dec 2 10:54:48 2010 +0100
Merge branch 'master' into code-smell
diff --cc modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java
index 3eb1c6b,b57c65b..e4d7575
--- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java
@@@ -30,16 -27,16 +27,17 @@@ import org.rhq.core.pluginapi.inventory
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.util.jdbc.JDBCUtil;
import org.rhq.plugins.database.DatabaseComponent;
+ import java.io.File;
+ import java.io.FileReader;
import java.sql.Connection;
- import java.sql.DatabaseMetaData;
- import java.sql.DriverManager;
import java.sql.ResultSet;
- import java.sql.ResultSetMetaData;
import java.sql.SQLException;
+ import java.sql.Statement;
import java.util.HashMap;
+ import java.util.List;
import java.util.Map;
import java.util.Set;
diff --cc modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDiscoveryComponent.java
index 2ada67b,30b65f2..c4ada90
--- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDiscoveryComponent.java
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDiscoveryComponent.java
@@@ -28,10 -28,8 +28,9 @@@ import org.rhq.core.pluginapi.inventory
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.core.pluginapi.inventory.ManualAddFacet;
import org.rhq.core.system.ProcessInfo;
+import org.rhq.core.util.jdbc.JDBCUtil;
import java.sql.Connection;
- import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.LinkedHashSet;
import java.util.List;
@@@ -82,59 -79,53 +80,53 @@@ public class MySqlDiscoveryComponent im
}
protected static DiscoveredResourceDetails createResourceDetails(ResourceDiscoveryContext discoveryContext,
- Configuration pluginConfiguration, ProcessInfo processInfo) {
-
- String key = buildUrl(pluginConfiguration);
- String db = pluginConfiguration.getSimple(DB_CONFIGURATION_PROPERTY).getStringValue();
- String name = "MySql [" + db + "]";
- try {
- String version = getVersion(pluginConfiguration);
- return new DiscoveredResourceDetails(discoveryContext.getResourceType(), key, name, version,
- DEFAULT_RESOURCE_DESCRIPTION, pluginConfiguration, processInfo);
- } catch (Exception e) {
- log.warn("Getting details failed: " + e.getMessage());
- if (e.getCause()!=null) {
- log.warn(" caused by: " + e.getCause().getMessage());
- }
- }
- return null;
- }
+ Configuration pluginConfiguration,
+ ProcessInfo processInfo) throws InvalidPluginConfigurationException {
- protected static String buildUrl(Configuration config) {
- String host = config.getSimple(HOST_CONFIGURATION_PROPERTY).getStringValue();
- String port = config.getSimple(PORT_CONFIGURATION_PROPERTY).getStringValue();
- String user = config.getSimple(PRINCIPAL_CONFIGURATION_PROPERTY).getStringValue();
- String pass = config.getSimple(CREDENTIALS_CONFIGURATION_PROPERTY).getStringValue();
- String url = "jdbc:mysql://" + host + "?user=" + user + "&password=" + pass;
- return url;
- }
-
- protected static String getVersion(Configuration config) {
- String version = null;
- Connection conn = null;
+ MySqlConnectionInfo ci = buildConnectionInfo(pluginConfiguration);
+ Connection conn;
+ String version = "";
try {
- conn = buildConnection(config);
+ conn = MySqlConnectionManager.getConnectionManager().getConnection(ci);
version = conn.getMetaData().getDatabaseProductVersion();
- } catch (SQLException e) {
- // TODO GH: How to put this back to the server while inventorying this resource in an unconfigured state
- log.info("Exception detecting mysql instance version" + e.getMessage());
- } finally {
- JDBCUtil.safeClose(conn);
+ } catch (SQLException ex) {
+ // ignore so we can still add to the inventory even though we can't currently connect
}
- return version;
- }
+ String key = new StringBuilder().append("MySql:")
+ .append(ci.getDb())
+ .append(":")
+ .append(ci.getHost())
+ .append(":")
+ .append(ci.getPort())
+ .append("-")
+ .append(ci.getUser()).toString();
+ String name = new StringBuilder().append("MySql [")
+ .append(ci.getDb())
+ .append("]").toString();
+
+ DiscoveredResourceDetails result = new DiscoveredResourceDetails(
+ discoveryContext.getResourceType(),
+ key,
+ name,
+ version,
+ "MySql Server",
+ pluginConfiguration,
+ processInfo);
- public static Connection buildConnection(Configuration configuration) throws SQLException {
- String driverClass = configuration.getSimple(DRIVER_CONFIGURATION_PROPERTY).getStringValue();
- try {
- Class.forName(driverClass);
- } catch (ClassNotFoundException e) {
- throw new InvalidPluginConfigurationException("Specified JDBC driver class (" + driverClass
- + ") not found.");
+ if (log.isDebugEnabled()) {
+ log.debug("Discovered Database Server for MySQL Database " + ci.buildURL());
}
+ return result;
- String url = buildUrl(configuration);
-
- return DriverManager.getConnection(url);
}
+
+ static MySqlConnectionInfo buildConnectionInfo(Configuration configuration) {
+ // build the Discovered Resource from the configuration
+ String host = configuration.getSimple(HOST_CONFIGURATION_PROPERTY).getStringValue();
+ String port = configuration.getSimple(PORT_CONFIGURATION_PROPERTY).getStringValue();
+ String user = configuration.getSimple(PRINCIPAL_CONFIGURATION_PROPERTY).getStringValue();
+ String pass = configuration.getSimple(CREDENTIALS_CONFIGURATION_PROPERTY).getStringValue();
+ String db = configuration.getSimple(DB_CONFIGURATION_PROPERTY).getStringValue();
+ return new MySqlConnectionInfo(host, port, db, user, pass);
+ }
-}
+}
commit f7aa5f57e02fb94389c33ac5b22bcef222488bc7
Merge: 077dd3d 08566cc
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 11:16:45 2010 +0200
Merge branch 'master' into code-smell
diff --cc modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
index 4034184,bc1fc64..484d591
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
@@@ -87,10 -87,12 +87,12 @@@ public class Props
private Set<Template> templates = new HashSet<Template>();
- private Set<MetricProps> metrics = new LinkedHashSet<MetricProps>();;
+ private Set<MetricProps> metrics = new LinkedHashSet<MetricProps>();
- private Set<OperationProps> operations = new LinkedHashSet<OperationProps>();;
+ private Set<OperationProps> operations = new LinkedHashSet<OperationProps>();
+ private Set<TypeKey> runsInsides = new LinkedHashSet<TypeKey>();;
+
private String pluginName;
private String pluginDescription;
commit 077dd3d75a5782dd4c775b47a64e80b0cfd38311
Merge: 8970684 e5fac0a
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Sep 14 18:08:59 2010 +0200
Merge branch 'master' into code-smell
commit 89706849030f5d35d65189b7cc6e8fd75da403d2
Merge: 271474d fb4f6c2
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Sep 3 11:02:19 2010 +0200
Merge branch 'master' into code-smell
commit 271474dd691b04cc01106d83baee292cfd6689a2
Merge: 4d5b070 66234db
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 24 18:10:33 2010 +0200
Merge branch 'master' into code-smell
diff --cc modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDiscoveryComponent.java
index ba0ea81,4f1045e..2ada67b
--- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDiscoveryComponent.java
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDiscoveryComponent.java
@@@ -106,9 -115,7 +117,9 @@@ public class MySqlDiscoveryComponent im
version = conn.getMetaData().getDatabaseProductVersion();
} catch (SQLException e) {
// TODO GH: How to put this back to the server while inventorying this resource in an unconfigured state
- log.info("Exception detecting mysql instance version", e);
+ log.info("Exception detecting mysql instance version" + e.getMessage());
+ } finally {
+ JDBCUtil.safeClose(conn);
}
return version;
}
@@@ -126,4 -133,4 +137,4 @@@
return DriverManager.getConnection(url);
}
--}
++}
commit 4d5b070e7e77d53f32d93ee9788e52e1ff5b509f
Merge: 88faac6 462e15f
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Aug 20 12:46:56 2010 +0200
Merge branch 'master' into code-smell
commit 88faac6a30c0282e08d2b0d7d19d6d019a0504c3
Merge: 2c7c7fc 1c5c441
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Aug 16 12:19:04 2010 +0200
Merge branch 'master' into code-smell
commit 2c7c7fc3aa949bbfebdefaaa4a0688a95bbeede8
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Aug 13 15:21:25 2010 +0200
Be defensive about the existence of HTTP Date header.
diff --git a/modules/plugins/netservices/src/main/java/org/rhq/plugins/netservices/HTTPNetServiceComponent.java b/modules/plugins/netservices/src/main/java/org/rhq/plugins/netservices/HTTPNetServiceComponent.java
index 85b19ad..54d9256 100644
--- a/modules/plugins/netservices/src/main/java/org/rhq/plugins/netservices/HTTPNetServiceComponent.java
+++ b/modules/plugins/netservices/src/main/java/org/rhq/plugins/netservices/HTTPNetServiceComponent.java
@@ -24,6 +24,7 @@ import java.util.Date;
import java.util.Locale;
import java.util.Set;
+import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.logging.Log;
@@ -114,7 +115,8 @@ public class HTTPNetServiceComponent implements ResourceComponent, MeasurementFa
// TODO: may need to allow plugin to configure the locale, but for this fixed string, make sure we
// ignore default locale, this works for english.
SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss zzz", Locale.ENGLISH);
- Date contentDate = sdf.parse(method.getResponseHeader("Date").getValue());
+ Header dateHeader = method.getResponseHeader("Date");
+ Date contentDate = dateHeader == null ? new Date(System.currentTimeMillis()) : sdf.parse(dateHeader.getValue());
// System.out.println("Success: " + success);
// System.out.println("Response: " + responseCode);
commit c033ec0a86a394f0caeda7081ed9c3fbd77ac524
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Aug 13 15:16:53 2010 +0200
Fail gracefully if we cannot determine the deployment descriptor file of the mbean during the resource configuration update.
diff --git a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java
index 34c3ffc..daa7cdb 100644
--- a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java
+++ b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java
@@ -281,6 +281,12 @@ public class JBossCacheComponent implements ResourceComponent<JMXComponent>, Mea
String mbeanName = context.getResourceKey();
File file = DeploymentUtility.getDescriptorFile(parentServer.getEmsConnection(), mbeanName);
+ if (file == null) {
+ report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ report.setErrorMessage("Failed to determine the deployment descriptor file for mbean '" + mbeanName + "'.");
+ return;
+ }
+
CacheConfigurationHelper helper = new CacheConfigurationHelper();
try {
helper.writeConfig(file, newOne, mbeanName, true);
commit 6334d8b4fbb3e77b3ce607cd3191406ad85cc348
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Aug 13 15:06:07 2010 +0200
Paranoidly prevent NPE if a set of rules changed between avail checks of the parent BytemanScriptComponent.
diff --git a/modules/plugins/byteman/src/main/java/org/rhq/plugins/byteman/BytemanRuleComponent.java b/modules/plugins/byteman/src/main/java/org/rhq/plugins/byteman/BytemanRuleComponent.java
index 09f7213..189eb47 100644
--- a/modules/plugins/byteman/src/main/java/org/rhq/plugins/byteman/BytemanRuleComponent.java
+++ b/modules/plugins/byteman/src/main/java/org/rhq/plugins/byteman/BytemanRuleComponent.java
@@ -36,7 +36,7 @@ public class BytemanRuleComponent implements ResourceComponent<BytemanScriptComp
List<String> rules = this.resourceContext.getParentResourceComponent().getRules();
for (String rule : rules) {
String ruleName = client.determineRuleName(rule);
- if (ruleName.equals(ourKey)) {
+ if (ourKey.equals(ruleName)) {
return AvailabilityType.UP;
}
}
commit ac1418991c901faed1397c7a9016d226316855a0
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Aug 13 15:00:54 2010 +0200
Make sure to close the stream (this will paranoidly close the buffered output stream instead just the file output stream that is wrapped by it).
diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentSnapshotReport.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentSnapshotReport.java
index f2fb4b3..cd92575 100644
--- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentSnapshotReport.java
+++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentSnapshotReport.java
@@ -21,6 +21,7 @@ package org.rhq.plugins.agent;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.OutputStream;
import java.util.Properties;
import org.apache.commons.logging.Log;
@@ -29,6 +30,7 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.util.SnapshotReport;
+import org.rhq.core.util.stream.StreamUtil;
/**
* Performs some slight customizations of the snapshot report utility such as taking a snapshot of the live
@@ -82,11 +84,12 @@ public class AgentSnapshotReport extends SnapshotReport {
try {
File configDir = new File(this.agentInstallDir, "conf");
File liveConfigFile = new File(configDir, "live-agent-configuration.properties");
- FileOutputStream fos = new FileOutputStream(liveConfigFile);
+ OutputStream fos = null;
try {
- this.agentConfiguration.store(new BufferedOutputStream(fos), null);
+ fos = new BufferedOutputStream(new FileOutputStream(liveConfigFile));
+ this.agentConfiguration.store(fos, null);
} finally {
- fos.close();
+ StreamUtil.safeClose(fos);
}
return liveConfigFile;
} catch (Exception e) {
commit 8869c018b39935049b924b1d7273fcb15663b7b9
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Aug 13 14:54:40 2010 +0200
Prevent an NPE if all aliases would be removed from a tomcat vhost.
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
index e8d6e8b..2746c5b 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
@@ -159,11 +159,10 @@ public class TomcatVHostComponent extends MBeanResourceComponent<TomcatServerCom
String currentValsLongString = currentVals.getStringValue();
String newValsLongString = newVals.getStringValue();
StringTokenizer tokenizer = null;
- Configuration opConfig = null;
+ Configuration opConfig = new Configuration();
if (null != newValsLongString) {
tokenizer = new StringTokenizer(newValsLongString, "\n");
- opConfig = new Configuration();
while (tokenizer.hasMoreTokens()) {
String newVal = tokenizer.nextToken().trim();
if ((null == currentValsLongString) || !currentValsLongString.contains(newVal)) {
commit f270fe5702392360cc2ab6710f2e4f528f6ab4b3
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Aug 13 14:53:00 2010 +0200
Prevent an NPE when the user was removed from all groups or roles during resource configuration update.
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserComponent.java
index 52efaac..24936cd 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserComponent.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserComponent.java
@@ -162,11 +162,10 @@ public class TomcatUserComponent extends MBeanResourceComponent<TomcatUserDataba
String currentValsLongString = currentVals.getStringValue();
String newValsLongString = newVals.getStringValue();
StringTokenizer tokenizer = null;
- Configuration opConfig = null;
+ Configuration opConfig = new Configuration();
if (null != newValsLongString) {
tokenizer = new StringTokenizer(newValsLongString, "\n");
- opConfig = new Configuration();
while (tokenizer.hasMoreTokens()) {
String newVal = tokenizer.nextToken().trim();
if ((null == currentValsLongString) || !currentValsLongString.contains(newVal)) {
commit d6a394514a81cab7a2912d5f0d183b7b958d84ea
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Aug 13 14:50:40 2010 +0200
Prevent an NPE in case all the roles were removed from the tomcat group.
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatGroupComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatGroupComponent.java
index 89b2ce2..1d667a7 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatGroupComponent.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatGroupComponent.java
@@ -141,11 +141,10 @@ public class TomcatGroupComponent extends MBeanResourceComponent<TomcatUserDatab
String currentValsLongString = currentVals.getStringValue();
String newValsLongString = newVals.getStringValue();
StringTokenizer tokenizer = null;
- Configuration opConfig = null;
+ Configuration opConfig = new Configuration();
if (null != newValsLongString) {
tokenizer = new StringTokenizer(newValsLongString, "\n");
- opConfig = new Configuration();
while (tokenizer.hasMoreTokens()) {
String newVal = tokenizer.nextToken().trim();
if ((null == currentValsLongString) || !currentValsLongString.contains(newVal)) {
commit 48f7788fa29d437b791f28625c233e87c5e2b811
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Aug 13 14:48:16 2010 +0200
Be paranoid about File.getParentFile()
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatDiscoveryComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatDiscoveryComponent.java
index 3007520..fc0e681 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatDiscoveryComponent.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatDiscoveryComponent.java
@@ -341,8 +341,17 @@ public class TomcatDiscoveryComponent implements ResourceDiscoveryComponent, Man
private String determineCatalinaHomeOnWindows(ProcessInfo processInfo) {
File exePath = new File(processInfo.getName());
+
File parentDir = exePath.getParentFile();
+ if (parentDir == null) { //paranoia
+ return null;
+ }
+
File ewsDir = parentDir.getParentFile();
+ if (ewsDir == null) { //paranoia
+ return null;
+ }
+
File tomcatDir = new File(ewsDir, "share/apache-tomcat-6.0.24");
if (tomcatDir.exists()) {
commit dd633d1e56712671a496952dd6f04fae21bada07
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Aug 13 14:36:32 2010 +0200
Throw a specific exception if failed to parse virt domain xml.
diff --git a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationDomainComponent.java b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationDomainComponent.java
index a67d5c3..adc75a6 100644
--- a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationDomainComponent.java
+++ b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationDomainComponent.java
@@ -159,6 +159,11 @@ public class VirtualizationDomainComponent implements ResourceComponent<Virtuali
String xml = virt.getDomainXML(this.domainName);
Configuration oldConfig = loadResourceConfiguration();
+
+ if (oldConfig == null) {
+ throw new IllegalStateException("Failed to parse the XML specification for domain '" + domainName + "'.");
+ }
+
Configuration newConfig = report.getConfiguration();
String newXml = XMLEditor.updateDomainXML(report.getConfiguration(), xml);
commit 8ad726302d19649136d25783b23555431de16db2
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Aug 13 14:07:50 2010 +0200
Be paranoid about free()ing the libvirt objects, throw IllegalArgumentException if domain/network of some name cannot be found instead of just blindly throwing an NPE later in the workflow.
diff --git a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/LibVirtConnection.java b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/LibVirtConnection.java
index 6b16328..b1f578e 100644
--- a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/LibVirtConnection.java
+++ b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/LibVirtConnection.java
@@ -114,15 +114,17 @@ public class LibVirtConnection {
public DomainInfo getDomainInfo(String domainName) throws LibvirtException {
try {
- Domain domain = connection.domainLookupByName(domainName);
-
- DomainInfo info = new DomainInfo();
- info.domainInfo = domain.getInfo();
- info.name = domainName;
- info.uuid = domain.getUUIDString();
- domain.free();
-
- return info;
+ Domain domain = getDomain(domainName);
+ try {
+ DomainInfo info = new DomainInfo();
+ info.domainInfo = domain.getInfo();
+ info.name = domainName;
+ info.uuid = domain.getUUIDString();
+
+ return info;
+ } finally {
+ domain.free();
+ }
} catch (LibvirtException e) {
log.error("Error looking up domain with name " + domainName, e);
throw e;
@@ -132,14 +134,19 @@ public class LibVirtConnection {
public DomainInfo getDomainInfo(int id) throws LibvirtException {
try {
Domain domain = connection.domainLookupByID(id);
-
- DomainInfo info = new DomainInfo();
- info.domainInfo = domain.getInfo();
- info.name = domain.getName();
- info.uuid = domain.getUUIDString();
- domain.free();
-
- return info;
+ if (domain == null) {
+ throw new IllegalArgumentException("No domain found with ID: " + id);
+ }
+ try {
+ DomainInfo info = new DomainInfo();
+ info.domainInfo = domain.getInfo();
+ info.name = domain.getName();
+ info.uuid = domain.getUUIDString();
+
+ return info;
+ } finally {
+ domain.free();
+ }
} catch (LibvirtException e) {
log.error("Error looking up domain with id " + id, e);
throw e;
@@ -147,18 +154,22 @@ public class LibVirtConnection {
}
public String getDomainXML(String domainName) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- String returnValue = domain.getXMLDesc(0);
- domain.free();
-
- return returnValue;
+ Domain domain = getDomain(domainName);
+ try {
+ return domain.getXMLDesc(0);
+ } finally {
+ domain.free();
+ }
}
public int domainReboot(String domainName) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- domain.reboot(0);
- domain.free();
- return SUCCESS;
+ Domain domain = getDomain(domainName);
+ try {
+ domain.reboot(0);
+ return SUCCESS;
+ } finally {
+ domain.free();
+ }
}
public int domainRestore(String toPath) throws LibvirtException {
@@ -167,57 +178,79 @@ public class LibVirtConnection {
}
public int domainDestroy(String domainName) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- domain.destroy();
- domain.free();
- return SUCCESS;
+ Domain domain = getDomain(domainName);
+ try {
+ domain.destroy();
+ return SUCCESS;
+ } finally {
+ domain.free();
+ }
}
public int domainDelete(String domainName) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- DomainState state = domain.getInfo().state;
-
- if ((state != DomainState.VIR_DOMAIN_SHUTDOWN) && (state != DomainState.VIR_DOMAIN_SHUTOFF)) {
- domain.destroy();
+ Domain domain = getDomain(domainName);
+ try {
+ DomainState state = domain.getInfo().state;
+
+ if ((state != DomainState.VIR_DOMAIN_SHUTDOWN) && (state != DomainState.VIR_DOMAIN_SHUTOFF)) {
+ domain.destroy();
+ }
+ domain.undefine();
+
+ return SUCCESS;
+ } finally {
+ domain.free();
}
- domain.undefine();
- domain.free();
- return SUCCESS;
}
public int domainSave(String domainName, String toPath) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- domain.save(toPath);
- domain.free();
- return SUCCESS;
+ Domain domain = getDomain(domainName);
+ try {
+ domain.save(toPath);
+ return SUCCESS;
+ } finally {
+ domain.free();
+ }
}
public int domainResume(String domainName) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- domain.resume();
- domain.free();
- return SUCCESS;
+ Domain domain = getDomain(domainName);
+ try {
+ domain.resume();
+ return SUCCESS;
+ } finally {
+ domain.free();
+ }
}
public int domainShutdown(String domainName) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- domain.shutdown();
- domain.free();
- return SUCCESS;
+ Domain domain = getDomain(domainName);
+ try {
+ domain.shutdown();
+ return SUCCESS;
+ } finally {
+ domain.free();
+ }
}
public int domainSuspend(String domainName) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- domain.suspend();
- domain.free();
- return SUCCESS;
+ Domain domain = getDomain(domainName);
+ try {
+ domain.suspend();
+ return SUCCESS;
+ } finally {
+ domain.free();
+ }
}
public int domainCreate(String domainName) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- domain.create();
- domain.free();
- return SUCCESS;
+ Domain domain = getDomain(domainName);
+ try {
+ domain.create();
+ return SUCCESS;
+ } finally {
+ domain.free();
+ }
}
public boolean defineDomain(String xml) throws LibvirtException {
@@ -230,35 +263,48 @@ public class LibVirtConnection {
}
public void setMaxMemory(String domainName, long size) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- domain.setMaxMemory(size);
- domain.free();
+ Domain domain = getDomain(domainName);
+ try {
+ domain.setMaxMemory(size);
+ } finally {
+ domain.free();
+ }
}
public void setMemory(String domainName, long size) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- domain.setMemory(size);
- domain.free();
+ Domain domain = getDomain(domainName);
+ try {
+ domain.setMemory(size);
+ } finally {
+ domain.free();
+ }
}
public void setVcpus(String domainName, int count) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- domain.setVcpus(count);
- domain.free();
+ Domain domain = getDomain(domainName);
+ try {
+ domain.setVcpus(count);
+ } finally {
+ domain.free();
+ }
}
public DomainInterfaceStats getDomainInterfaceStats(String domainName, String path) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- DomainInterfaceStats returnValue = domain.interfaceStats(path);
- domain.free();
- return returnValue;
+ Domain domain = getDomain(domainName);
+ try {
+ return domain.interfaceStats(path);
+ } finally {
+ domain.free();
+ }
}
public DomainBlockStats getDomainBlockStats(String domainName, String path) throws LibvirtException {
- Domain domain = connection.domainLookupByName(domainName);
- DomainBlockStats returnValue = domain.blockStats(path);
- domain.free();
- return returnValue;
+ Domain domain = getDomain(domainName);
+ try {
+ return domain.blockStats(path);
+ } finally {
+ domain.free();
+ }
}
public int close() throws LibvirtException {
@@ -275,7 +321,10 @@ public class LibVirtConnection {
double usedMemory = 0;
for (int id : connection.listDomains()) {
Domain domain = connection.domainLookupByID(id);
- usedMemory += domain.getInfo().memory;
+ if (domain != null) {
+ usedMemory += domain.getInfo().memory;
+ domain.free();
+ }
}
return usedMemory / memory;
}
@@ -284,8 +333,10 @@ public class LibVirtConnection {
long cpuTime = 0;
for (int id : connection.listDomains()) {
Domain domain = connection.domainLookupByID(id);
- cpuTime += domain.getInfo().cpuTime;
- domain.free();
+ if (domain != null) {
+ cpuTime += domain.getInfo().cpuTime;
+ domain.free();
+ }
}
return cpuTime;
}
@@ -321,28 +372,37 @@ public class LibVirtConnection {
return getNetworks().contains(name);
}
- //TODO NEED TO ADD A NETWORK OBJECT AND FREE THE LIBVIRT ONE
public NetworkInfo getNetwork(String name) throws LibvirtException {
- NetworkInfo info = new NetworkInfo();
- Network net = connection.networkLookupByName(name);
- info.name = net.getName();
- info.autostart = net.getAutostart();
- info.bridgeName = net.getBridgeName();
- return info;
+ Network net = getLibVirtNetwork(name);
+
+ try {
+ NetworkInfo info = new NetworkInfo();
+ info.name = net.getName();
+ info.autostart = net.getAutostart();
+ info.bridgeName = net.getBridgeName();
+ return info;
+ } finally {
+ net.free();
+ }
}
public String getNetworkXML(String name) throws LibvirtException {
- Network network = connection.networkLookupByName(name);
- String returnValue = network.getXMLDesc(0);
- network.free();
- return returnValue;
+ Network network = getLibVirtNetwork(name);
+ try {
+ return network.getXMLDesc(0);
+ } finally {
+ network.free();
+ }
}
public void updateNetwork(String name, String xml, boolean autostart) throws LibvirtException {
connection.networkDefineXML(xml);
- Network network = connection.networkLookupByName(name);
- network.setAutostart(autostart);
- network.free();
+ Network network = getLibVirtNetwork(name);
+ try {
+ network.setAutostart(autostart);
+ } finally {
+ network.free();
+ }
}
public static class DomainInfo {
@@ -385,10 +445,26 @@ public class LibVirtConnection {
System.out.println(conn.connection.domainLookupByName(foo).getXMLDesc(0));
}
}
+
+ private Domain getDomain(String domainName) throws LibvirtException, IllegalArgumentException {
+ Domain ret = connection.domainLookupByName(domainName);
+ if (ret == null) {
+ throw new IllegalArgumentException("Could not find a domain called '" + domainName + "'.");
+ }
+
+ return ret;
+ }
+
+ private Network getLibVirtNetwork(String networkName) throws LibvirtException, IllegalArgumentException {
+ Network ret = connection.networkLookupByName(networkName);
+ if (ret == null) {
+ throw new IllegalArgumentException("Could not find a netword called '" + networkName + "'.");
+ }
+
+ return ret;
+ }
}
-//TODO Put the callbacks in
-/* Comment this out untilt he callbacks get in*/
class Logger extends org.libvirt.ErrorCallback {
// Make this static so the callback will always have an object
commit 1a666b2c5cd1e942d8f568c041ac2f678421050b
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Aug 13 12:20:05 2010 +0200
Removed needless null check.
diff --git a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
index 475195a..38f1b02 100644
--- a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
+++ b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
@@ -336,12 +336,8 @@ public class ScriptServerComponent implements ResourceComponent, MeasurementFace
ProcessExecutionResults results = executeExecutable(sysInfo, pluginConfig, args, wait, captureOutput);
if (log.isDebugEnabled()) {
- if (results != null) {
- logDebug("CLI results: exitcode=[" + results.getExitCode() + "]; error=[" + results.getError()
- + "]; output=" + truncateString(results.getCapturedOutput()));
- } else {
- logDebug("CLI has null results");
- }
+ logDebug("CLI results: exitcode=[" + results.getExitCode() + "]; error=[" + results.getError()
+ + "]; output=" + truncateString(results.getCapturedOutput()));
}
return results;
commit b9f07c09436a548434acfd6855662d54d33bf866
Merge: c8fb8b3 910702a
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Aug 12 15:30:40 2010 +0200
Merge branch 'master' into code-smell
commit c8fb8b3652d6b32e880b52913dd2280ab157eb57
Merge: 2638f27 f1365e5
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Aug 12 15:18:05 2010 +0200
Merge branch 'code-smell' of ssh://git.fedorahosted.org/git/rhq/rhq into code-smell
commit f1365e541a2ba19357abfa063333dc9901f6d786
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Aug 12 12:24:08 2010 +0200
12644 prevent NPE
diff --git a/modules/plugins/perftest/src/main/java/org/rhq/plugins/perftest/PerfTestDiscoveryComponent.java b/modules/plugins/perftest/src/main/java/org/rhq/plugins/perftest/PerfTestDiscoveryComponent.java
index 6830f5f..16d6c89 100644
--- a/modules/plugins/perftest/src/main/java/org/rhq/plugins/perftest/PerfTestDiscoveryComponent.java
+++ b/modules/plugins/perftest/src/main/java/org/rhq/plugins/perftest/PerfTestDiscoveryComponent.java
@@ -18,6 +18,7 @@
*/
package org.rhq.plugins.perftest;
+import java.util.Collections;
import java.util.Set;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.resource.ResourceType;
@@ -44,6 +45,9 @@ public class PerfTestDiscoveryComponent implements ResourceDiscoveryComponent {
Set<DiscoveredResourceDetails> resourceDetails = null;
if (manager.isEnabled()) {
ResourceFactory resourceFactory = manager.getResourceFactory(resourceType.getName());
+ if (resourceFactory==null)
+ return Collections.emptySet();
+
resourceDetails = resourceFactory.discoverResources(context);
// If there is a plugin configuration factory defined, run it on each resource
diff --git a/modules/plugins/perftest/src/main/java/org/rhq/plugins/perftest/ScenarioManager.java b/modules/plugins/perftest/src/main/java/org/rhq/plugins/perftest/ScenarioManager.java
index d9aabf9..1eb831d 100644
--- a/modules/plugins/perftest/src/main/java/org/rhq/plugins/perftest/ScenarioManager.java
+++ b/modules/plugins/perftest/src/main/java/org/rhq/plugins/perftest/ScenarioManager.java
@@ -310,6 +310,7 @@ public class ScenarioManager {
return new SimpleResourceFactory((SimpleResourceGenerator) generator);
}
+ log.warn("No factory for generator " + generator.toString() + " specified");
return null;
}
commit 391f9be4637842049cc01e90d7bce1b4ce54e86f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Aug 12 12:02:58 2010 +0200
Fix some potential NPE and resource leakage
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
index 69587d0..17a6818 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
@@ -61,37 +61,49 @@ public class PluginGen {
public void run() throws Exception {
+ Props props = null;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+ try {
- Props props = askQuestions(br, new Props());
- if (props == null) {
- // abort by user
- return;
- }
+ props = askQuestions(br, new Props());
+ if (props == null) {
+ // abort by user
+ return;
+ }
+
+ boolean done = false;
+ do {
- boolean done = false;
- do {
-
- System.out.println();
- System.out.print("Do you want to add a child to " + props.getName() + "? (y/N) ");
- String answer = br.readLine();
- answer = answer.toLowerCase(Locale.getDefault());
- if (answer.startsWith("n") || answer.length() == 0)
- done = true;
- else {
- Props child = askQuestions(br, props);
- if (child == null) {
- // abort by user
- return;
+ System.out.println();
+ System.out.print("Do you want to add a child to " + props.getName() + "? (y/N) ");
+ String answer = br.readLine();
+ if (answer==null) {
+ break;
+ }
+ answer = answer.toLowerCase(Locale.getDefault());
+ if (answer.startsWith("n") || answer.length() == 0)
+ done = true;
+ else {
+ Props child = askQuestions(br, props);
+ if (child == null) {
+ // abort by user
+ return;
+ }
+ props.getChildren().add(child);
}
- props.getChildren().add(child);
- }
- } while (!done);
+ } while (!done);
+ } catch (IOException ioe) {
+ System.err.println("Internal error happended: " + ioe.getMessage());
+ } finally {
+ br.close();
+ }
- log.info("\nYou have choosen:\n" + props.toString());
- postprocess(props);
- generate(props);
+ if (props!=null) {
+ log.info("\nYou have chosen:\n" + props.toString());
+ postprocess(props);
+ generate(props);
+ }
System.out.println("Don't forget to ");
System.out.println(" - add your plugin to the parent pom.xml if needed");
@@ -345,11 +357,15 @@ public class PluginGen {
Template templ = config.getTemplate(template + ".ftl");
Writer out = new BufferedWriter(new FileWriter(new File(directory, fileName)));
- Map<String, Props> root = new HashMap<String, Props>();
- root.put("props", props);
- templ.process(root, out);
- out.flush();
- out.close();
+ try {
+ Map<String, Props> root = new HashMap<String, Props>();
+ root.put("props", props);
+ templ.process(root, out);
+ }
+ finally {
+ out.flush();
+ out.close();
+ }
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (TemplateException te) {
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
index a657f42..4034184 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
@@ -87,9 +87,9 @@ public class Props {
private Set<Template> templates = new HashSet<Template>();
- private Set<MetricProps> metrics = new LinkedHashSet<MetricProps>();;
+ private Set<MetricProps> metrics = new LinkedHashSet<MetricProps>();
- private Set<OperationProps> operations = new LinkedHashSet<OperationProps>();;
+ private Set<OperationProps> operations = new LinkedHashSet<OperationProps>();
private String pluginName;
private String pluginDescription;
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/ResourceCategory.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/ResourceCategory.java
index 566af60..911ed41 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/ResourceCategory.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/ResourceCategory.java
@@ -77,7 +77,7 @@ public enum ResourceCategory {
public static ResourceCategory getByAbbrv(char abbrev) {
EnumSet<ResourceCategory> set = EnumSet.allOf(ResourceCategory.class);
for (ResourceCategory cat : set) {
- if (cat.getAbbrev()==abbrev)
+ if (cat.abbrevLetter ==abbrev)
return cat;
}
return null;
commit 2638f279d22aebb3e5ebcad5f7bd17c3d873b33b
Merge: aef5cf2 a13c17d
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Aug 11 15:02:32 2010 +0200
Merge branch 'master' into code-smell
commit aef5cf286fc08b16273a54022ecb0f48f19d9b44
Merge: ac90dbd a5187a8
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 18:11:10 2010 +0200
Merge branch 'master' into code-smell
commit ac90dbd66d849db6dc7d4d82e595cf44cf58b5c0
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 18:02:45 2010 +0200
Trivial - code formatting.
diff --git a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerDiscoveryComponent.java b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerDiscoveryComponent.java
index 1821eed..b805ea9 100644
--- a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerDiscoveryComponent.java
+++ b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerDiscoveryComponent.java
@@ -37,27 +37,29 @@ import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent;
public class SambaServerDiscoveryComponent extends AugeasConfigurationDiscoveryComponent {
- private static final Pattern netBiosNamePattern = Pattern.compile("[\\s]*netbios[\\s]*name[\\s]*=[\\s]*(.*)[\\s]*");
-
- public Set discoverResources(ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception {
+ private static final Pattern NET_BIOS_NAME_PATTERN = Pattern
+ .compile("[\\s]*netbios[\\s]*name[\\s]*=[\\s]*(.*)[\\s]*");
+
+ public Set discoverResources(ResourceDiscoveryContext resourceDiscoveryContext)
+ throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> resources = super.discoverResources(resourceDiscoveryContext);
- for (DiscoveredResourceDetails detail : resources){
+ for (DiscoveredResourceDetails detail : resources) {
Configuration config = detail.getPluginConfiguration();
PropertySimple property = (PropertySimple) config.get(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP);
String configFilePath = property.getStringValue();
String resourceName;
-
+
try {
- resourceName = findNetBiosName(configFilePath);
- }catch(Exception e){
- resourceName = resourceDiscoveryContext.getSystemInformation().getHostname();
+ resourceName = findNetBiosName(configFilePath);
+ } catch (Exception e) {
+ resourceName = resourceDiscoveryContext.getSystemInformation().getHostname();
}
detail.setResourceName(resourceName);
}
return resources;
}
-
- private String findNetBiosName(String includeFile) throws Exception{
+
+ private String findNetBiosName(String includeFile) throws Exception {
try {
File file = new File(includeFile);
if (file.exists()) {
@@ -66,21 +68,20 @@ public class SambaServerDiscoveryComponent extends AugeasConfigurationDiscoveryC
try {
String strLine;
while ((strLine = br.readLine()) != null) {
- Matcher m = netBiosNamePattern.matcher(strLine);
+ Matcher m = NET_BIOS_NAME_PATTERN.matcher(strLine);
if (m.matches()) {
String glob = m.group(1);
-
- return glob;
- }
+
+ return glob;
+ }
}
} finally {
StreamUtil.safeClose(br);
}
}
- }
- catch (Exception e) {
- throw new Exception("NetBios name was not found in configuration file "+ includeFile + " cause:",e);
+ } catch (Exception e) {
+ throw new Exception("NetBios name was not found in configuration file " + includeFile + " cause:", e);
}
- throw new Exception("NetBios name was not found in configuration file "+ includeFile);
+ throw new Exception("NetBios name was not found in configuration file " + includeFile);
}
}
commit 892927807a251621668c91bbf18e07e05c8037bd
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 18:00:39 2010 +0200
Close the stream.
diff --git a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerDiscoveryComponent.java b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerDiscoveryComponent.java
index b53c006..1821eed 100644
--- a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerDiscoveryComponent.java
+++ b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerDiscoveryComponent.java
@@ -31,6 +31,7 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.util.stream.StreamUtil;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent;
@@ -62,16 +63,19 @@ public class SambaServerDiscoveryComponent extends AugeasConfigurationDiscoveryC
if (file.exists()) {
FileInputStream fstream = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
- String strLine;
- while ((strLine = br.readLine()) != null) {
- Matcher m = netBiosNamePattern.matcher(strLine);
- if (m.matches()) {
- String glob = m.group(1);
-
- return glob;
- }
+ try {
+ String strLine;
+ while ((strLine = br.readLine()) != null) {
+ Matcher m = netBiosNamePattern.matcher(strLine);
+ if (m.matches()) {
+ String glob = m.group(1);
+
+ return glob;
+ }
+ }
+ } finally {
+ StreamUtil.safeClose(br);
}
- br.close();
}
}
catch (Exception e) {
commit e6e41cf77ad3cd48cb50abb74b56952c289fa49c
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 17:57:09 2010 +0200
Unnecessarily getting a value twice.
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java
index af3280a..6312c4d 100644
--- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java
+++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java
@@ -151,7 +151,8 @@ public class PostgresUserComponent implements DatabaseComponent<PostgresServerCo
+ " ";
if (type != UpdateType.DROP) {
- if (config.getSimpleValue("password",null) != null && config.getSimpleValue("password",null).length() != 0) {
+ String password = config.getSimpleValue("password",null);
+ if (password != null && password.length() != 0) {
sql += " WITH PASSWORD '" + config.getSimpleValue("password",null) + "' ";
}
commit 75e16e1459f6e2d7f1725189be63f2439a91ec3a
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 17:56:14 2010 +0200
Make sure to close the JDBC connection.
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java
index b02d764..b03327d 100644
--- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java
+++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDiscoveryComponent.java
@@ -298,7 +298,12 @@ public class PostgresDiscoveryComponent implements ResourceDiscoveryComponent, M
}
public static List<String> getDatabases(Configuration pluginConfiguration) {
- return getDatabaseNames(pluginConfiguration, getConnection(pluginConfiguration));
+ Connection conn = getConnection(pluginConfiguration);
+ try {
+ return getDatabaseNames(pluginConfiguration, conn);
+ } finally {
+ JDBCUtil.safeClose(conn);
+ }
}
private static List<String> getDatabaseNames(Configuration config, Connection conn) {
commit dfa063dcb426f7ba05cfd3923c603b9d33e4dbf4
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 17:46:45 2010 +0200
Trivial - code formatting.
diff --git a/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixServerDiscoveryComponent.java b/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixServerDiscoveryComponent.java
index 49172bd..91490c0 100644
--- a/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixServerDiscoveryComponent.java
+++ b/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixServerDiscoveryComponent.java
@@ -37,27 +37,28 @@ import java.util.regex.Pattern;
public class PostfixServerDiscoveryComponent extends AugeasConfigurationDiscoveryComponent {
- private static final Pattern hostNamePattern = Pattern.compile("[\\s]*myhostname[\\s]*=[\\s]*([^$].*)[\\s]*");
-
- public Set discoverResources(ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception {
+ private static final Pattern HOSTNAME_PATTERN = Pattern.compile("[\\s]*myhostname[\\s]*=[\\s]*([^$].*)[\\s]*");
+
+ public Set discoverResources(ResourceDiscoveryContext resourceDiscoveryContext)
+ throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> resources = super.discoverResources(resourceDiscoveryContext);
- for (DiscoveredResourceDetails detail : resources){
+ for (DiscoveredResourceDetails detail : resources) {
Configuration config = detail.getPluginConfiguration();
PropertySimple property = (PropertySimple) config.get(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP);
String configFilePath = property.getStringValue();
String resourceName;
-
+
try {
- resourceName = findHostName(configFilePath);
- }catch(Exception e){
- resourceName = resourceDiscoveryContext.getSystemInformation().getHostname();
+ resourceName = findHostName(configFilePath);
+ } catch (Exception e) {
+ resourceName = resourceDiscoveryContext.getSystemInformation().getHostname();
}
detail.setResourceName(resourceName);
}
return resources;
}
-
- private String findHostName(String includeFile) throws Exception{
+
+ private String findHostName(String includeFile) throws Exception {
try {
File file = new File(includeFile);
if (file.exists()) {
@@ -66,21 +67,20 @@ public class PostfixServerDiscoveryComponent extends AugeasConfigurationDiscover
try {
String strLine;
while ((strLine = br.readLine()) != null) {
- Matcher m = hostNamePattern.matcher(strLine);
+ Matcher m = HOSTNAME_PATTERN.matcher(strLine);
if (m.matches()) {
String glob = m.group(1);
-
- return glob;
- }
+
+ return glob;
+ }
}
} finally {
StreamUtil.safeClose(br);
}
}
- }
- catch (Exception e) {
- throw new Exception("NetBios name was not found in configuration file "+ includeFile + " cause:",e);
+ } catch (Exception e) {
+ throw new Exception("NetBios name was not found in configuration file " + includeFile + " cause:", e);
}
- throw new Exception("NetBios name was not found in configuration file "+ includeFile);
+ throw new Exception("NetBios name was not found in configuration file " + includeFile);
}
}
commit e13bce0c0d7a0d84a6afbfc5c7c04586f306329a
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 17:37:40 2010 +0200
Close the stream.
diff --git a/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixServerDiscoveryComponent.java b/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixServerDiscoveryComponent.java
index 8f26ee0..49172bd 100644
--- a/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixServerDiscoveryComponent.java
+++ b/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixServerDiscoveryComponent.java
@@ -23,6 +23,7 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.util.stream.StreamUtil;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent;
@@ -62,16 +63,19 @@ public class PostfixServerDiscoveryComponent extends AugeasConfigurationDiscover
if (file.exists()) {
FileInputStream fstream = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
- String strLine;
- while ((strLine = br.readLine()) != null) {
- Matcher m = hostNamePattern.matcher(strLine);
- if (m.matches()) {
- String glob = m.group(1);
-
- return glob;
- }
+ try {
+ String strLine;
+ while ((strLine = br.readLine()) != null) {
+ Matcher m = hostNamePattern.matcher(strLine);
+ if (m.matches()) {
+ String glob = m.group(1);
+
+ return glob;
+ }
+ }
+ } finally {
+ StreamUtil.safeClose(br);
}
- br.close();
}
}
catch (Exception e) {
commit 86b070e80ddf96df954e976613464d7af120a977
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 16:42:19 2010 +0200
Make sure to not fail when close() method of a stream throws an exception.
diff --git a/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/CompareDigestActionHandler.java b/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/CompareDigestActionHandler.java
index 08303c8..6bee4b2 100644
--- a/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/CompareDigestActionHandler.java
+++ b/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/CompareDigestActionHandler.java
@@ -26,6 +26,7 @@ import java.io.FileInputStream;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import org.jbpm.graph.exe.ExecutionContext;
+import org.rhq.core.util.stream.StreamUtil;
/**
* @author Jason Dobies
@@ -115,9 +116,7 @@ public class CompareDigestActionHandler extends BaseHandler {
while (in.read(buffer) != -1) {
}
} finally {
- if (in != null) {
- in.close();
- }
+ StreamUtil.safeClose(in);
}
String digest = HandlerUtils.encode(messageDigest.digest());
commit 41a3463a600a4014ed650d96c9fbd604dd4e8ba5
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 16:38:49 2010 +0200
Adding a utility method for safely closing streams.
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java b/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java
index e970b83..e84d7d4 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java
@@ -25,6 +25,7 @@ package org.rhq.core.util.stream;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
@@ -245,4 +246,19 @@ public class StreamUtil {
return retObject;
}
+
+ /**
+ * Can be used to safely close a stream. No-op if the stream is null.
+ *
+ * @param stream the stream to close or null
+ */
+ public static void safeClose(Closeable stream) {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ LOG.error("Failed to close a stream.", e);
+ }
+ }
+ }
}
\ No newline at end of file
commit fe93c191577091c0f45b11e80d5aba28084f7fb5
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 16:27:43 2010 +0200
Added missing import (how come I missed this?)
diff --git a/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/SetProcessStatusActionHandler.java b/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/SetProcessStatusActionHandler.java
index 7f6dbae..a3f1963 100644
--- a/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/SetProcessStatusActionHandler.java
+++ b/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/SetProcessStatusActionHandler.java
@@ -22,6 +22,7 @@
*/
package com.jboss.jbossnetwork.product.jbpm.handlers;
+import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
commit 0597c8e2ddafd88f7c0c9d2c25f81f1f461739f4
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 15:34:10 2010 +0200
Close the connections in the test code and in the discovery.
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java
index e3da0aa..f89344a 100644
--- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java
@@ -28,6 +28,7 @@ import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
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.util.jdbc.JDBCUtil;
import org.rhq.plugins.database.DatabaseComponent;
import java.sql.Connection;
@@ -116,10 +117,11 @@ public class MySqlComponent implements DatabaseComponent, ResourceComponent, Mea
public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+ Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
- Connection conn =
+ conn =
DriverManager.getConnection("jdbc:mysql://192.168.1.5?user=rhqadmin&password=rhqadmin");
DatabaseMetaData dmd = conn.getMetaData();
@@ -149,6 +151,8 @@ public class MySqlComponent implements DatabaseComponent, ResourceComponent, Mea
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
+ } finally {
+ JDBCUtil.safeClose(conn);
}
}
}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDiscoveryComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDiscoveryComponent.java
index f50fbc0..ba0ea81 100644
--- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDiscoveryComponent.java
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDiscoveryComponent.java
@@ -28,6 +28,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.core.pluginapi.inventory.ManualAddFacet;
import org.rhq.core.system.ProcessInfo;
+import org.rhq.core.util.jdbc.JDBCUtil;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -99,12 +100,15 @@ public class MySqlDiscoveryComponent implements ResourceDiscoveryComponent, Manu
protected static String getVersion(Configuration config) {
String version = null;
+ Connection conn = null;
try {
- Connection conn = buildConnection(config);
+ conn = buildConnection(config);
version = conn.getMetaData().getDatabaseProductVersion();
} catch (SQLException e) {
// TODO GH: How to put this back to the server while inventorying this resource in an unconfigured state
log.info("Exception detecting mysql instance version", e);
+ } finally {
+ JDBCUtil.safeClose(conn);
}
return version;
}
commit 20460165a99b1f2e92cc6033e7fb3dc158984ef4
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 15:27:11 2010 +0200
Close the connection when done with it during the discovery.
diff --git a/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java b/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java
index 2340f0b..79d67fd 100644
--- a/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java
+++ b/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleDiscoveryComponent.java
@@ -35,6 +35,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.core.pluginapi.inventory.ManualAddFacet;
import org.rhq.core.system.ProcessInfo;
+import org.rhq.core.util.jdbc.JDBCUtil;
/**
@@ -75,8 +76,10 @@ public class OracleDiscoveryComponent implements ResourceDiscoveryComponent, Man
public DiscoveredResourceDetails discoverResource(Configuration pluginConfig,
ResourceDiscoveryContext resourceDiscoveryContext)
throws InvalidPluginConfigurationException {
+
+ Connection connection = null;
try {
- Connection connection = OracleServerComponent.buildConnection(pluginConfig);
+ connection = OracleServerComponent.buildConnection(pluginConfig);
DatabaseMetaData dbmd = connection.getMetaData();
String version = dbmd.getDatabaseMajorVersion() + "." + dbmd.getDatabaseMinorVersion();
DiscoveredResourceDetails details = createResourceDetails(resourceDiscoveryContext, pluginConfig,
@@ -85,6 +88,8 @@ public class OracleDiscoveryComponent implements ResourceDiscoveryComponent, Man
} catch (Exception e) {
log.warn("Could not connect to oracle with supplied configuration", e);
throw new InvalidPluginConfigurationException("Unable to connect to Oracle",e);
+ } finally {
+ JDBCUtil.safeClose(connection);
}
}
commit cb19eacae48d2e2c0d47b761191dd11ef103c2cd
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 14:52:23 2010 +0200
Removing unused obsolete testing code.
diff --git a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java
index f4cbceb..4e276a3 100644
--- a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java
+++ b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerDiscoveryComponent.java
@@ -83,8 +83,4 @@ public class IISServerDiscoveryComponent implements ResourceDiscoveryComponent {
return Collections.singleton(details);
}
-
- public static void main(String[] args) throws Exception {
- new IISServerDiscoveryComponent().discoverResources(null);
- }
}
diff --git a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java
index a6fc8a1..0cd5cd8 100644
--- a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java
+++ b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java
@@ -93,8 +93,4 @@ public class IISVHostDiscoveryComponent implements ResourceDiscoveryComponent<II
return hostDetails;
}
-
- public static void main(String[] args) throws Exception {
- new IISVHostDiscoveryComponent().discoverResources(null);
- }
}
commit be16929be8cdd15b30d9e2ac98ee6efa2a68cbe0
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 14:51:52 2010 +0200
Preventing NPE in case of invalid plugin configuration.
diff --git a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java
index 692dbb8..9d264b9 100644
--- a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java
+++ b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java
@@ -56,6 +56,10 @@ public class IISVHostComponent implements ResourceComponent<IISServerComponent>,
String logFormat = getResponseTimeLogFormat();
ResponseTimeConfiguration responseTimeConfiguration = getResponseTimeConfiguration();
+ if (logFormat == null) {
+ throw new InvalidPluginConfigurationException("The 'responseTimeLogFormat' property must be specified.");
+ }
+
responseTimeDelegate = new IISResponseTimeDelegate(logDirectory, logFormat, responseTimeConfiguration
/*,collectionTZ.equals("true")*/);
}
commit 4ea9b298ddf1e5bf36567265e040c894d074fa92
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 14:05:31 2010 +0200
Avoid an NPE when the component is not properly configured.
diff --git a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java
index 0c7a5a5..f8ddcd8 100644
--- a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java
+++ b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java
@@ -23,10 +23,14 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.Map;
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.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
@@ -40,6 +44,8 @@ import org.rhq.core.util.jdbc.JDBCUtil;
public class CustomTableComponent implements DatabaseComponent<DatabaseComponent>, MeasurementFacet {
private ResourceContext<DatabaseComponent> context;
+ private static final Log log = LogFactory.getLog(CustomTableComponent.class);
+
public void start(ResourceContext<DatabaseComponent> resourceContext) throws InvalidPluginConfigurationException,
Exception {
this.context = resourceContext;
@@ -67,7 +73,15 @@ public class CustomTableComponent implements DatabaseComponent<DatabaseComponent
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
String query = this.context.getPluginConfiguration().getSimpleValue("metricQuery", null);
-
+
+ if (query == null) {
+ ResourceType type = this.context.getResourceType();
+ String resourceKey = this.context.getResourceKey();
+ log.info("Resource " + resourceKey + " (" + type.getName() + ", plugin " + type.getPlugin()
+ + "): The plugin configuration doesn't specify 'metricQuery' property. Ignoring the measurement request.");
+ return;
+ }
+
query = CustomTableRowDiscoveryComponent.formatMessage(query, this.context.getPluginConfiguration().getSimpleValue("key",null));
Map<String, Double> values = DatabaseQueryUtility.getNumericQueryValues(this, query);
commit 029f0c7abe2743f33460a4be96e1fc1814cce917
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 12:35:22 2010 +0200
Making sure resource name is specified in the plugin config and that null description doesn't blow up the discovery.
diff --git a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java
index aaf2e67..4b40d86 100644
--- a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java
+++ b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java
@@ -53,8 +53,12 @@ public class CustomTableRowDiscoveryComponent implements ResourceDiscoveryCompon
String table = config.getSimpleValue("table", null);
String keyColumn = config.getSimpleValue("keyColumn", null);
String resourceName = config.getSimpleValue("name", null);
- String resourceDescription = config.getSimpleValue("description", null);
+ String resourceDescription = config.getSimpleValue("description", "");
+ if (resourceName == null) {
+ throw new InvalidPluginConfigurationException("The 'name' connection property has to be specified.");
+ }
+
statement = conn.createStatement();
resultSet = statement.executeQuery("SELECT * FROM " + table);
commit cc86e651f9c850356dbfa82a42ee821948440ab8
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 11:54:25 2010 +0200
Make sure to close the stream.
diff --git a/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/CompareDigestActionHandler.java b/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/CompareDigestActionHandler.java
index 1f6d9c5..08303c8 100644
--- a/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/CompareDigestActionHandler.java
+++ b/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/CompareDigestActionHandler.java
@@ -107,12 +107,19 @@ public class CompareDigestActionHandler extends BaseHandler {
private String calculateDigest() throws Exception {
MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
- DigestInputStream in = new DigestInputStream(new FileInputStream(fileToBeCheckedLocation), messageDigest);
-
- byte[] buffer = new byte[4096];
- while (in.read(buffer) != -1) {
+ DigestInputStream in = null;
+
+ try {
+ in = new DigestInputStream(new FileInputStream(fileToBeCheckedLocation), messageDigest);
+ byte[] buffer = new byte[4096];
+ while (in.read(buffer) != -1) {
+ }
+ } finally {
+ if (in != null) {
+ in.close();
+ }
}
-
+
String digest = HandlerUtils.encode(messageDigest.digest());
return digest;
}
commit 8a9fd618e4f6a47a97da77a23e30437093861610
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 11:40:31 2010 +0200
Fix possible null dereference.
diff --git a/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/SetProcessStatusActionHandler.java b/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/SetProcessStatusActionHandler.java
index 48a2674..7f6dbae 100644
--- a/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/SetProcessStatusActionHandler.java
+++ b/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/SetProcessStatusActionHandler.java
@@ -37,7 +37,10 @@ public class SetProcessStatusActionHandler implements ActionHandler {
private Boolean status;
public void execute(ExecutionContext executionContext) {
- executionContext.getContextInstance().setVariable("processStatus", status);
+ ContextInstance instance = executionContext.getContextInstance();
+ if (instance != null) {
+ instance.setVariable("processStatus", status);
+ }
}
public Boolean getStatus() {
commit bff8c9db80f86d9696f8ddc57756ee9782d2a8e2
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Aug 10 11:09:49 2010 +0200
Fixing possible null parent path dereference.
diff --git a/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/BackupAndReplaceFileActionHandler.java b/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/BackupAndReplaceFileActionHandler.java
index 00d6a65..da5b5b2 100644
--- a/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/BackupAndReplaceFileActionHandler.java
+++ b/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/BackupAndReplaceFileActionHandler.java
@@ -155,9 +155,11 @@ public class BackupAndReplaceFileActionHandler extends BaseHandler {
if (!replacementFilename.equalsIgnoreCase(originalFilename)) {
// This file name can't be relative since we need its parent in the next step
HandlerUtils.checkFilenameIsAbsolute(originalFileLocation);
-
- File destinationFile = new File(originalFile.getParentFile().getPath() + File.separator
- + replacementFilename);
+
+ //check that there is a parent
+ File parent = HandlerUtils.checkAndReturnParent(originalFileLocation);
+
+ File destinationFile = new File(parent, replacementFilename);
setDestinationFileLocation(destinationFile.getPath());
// Make sure the newly generated file name isn't going to clash with an existing file
diff --git a/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/HandlerUtils.java b/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/HandlerUtils.java
index ae5293b..50d802c 100644
--- a/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/HandlerUtils.java
+++ b/modules/common/jboss-as/src/main/java/com/jboss/jbossnetwork/product/jbpm/handlers/HandlerUtils.java
@@ -142,6 +142,15 @@ public class HandlerUtils {
}
}
+ public static File checkAndReturnParent(String filename) throws ActionHandlerException {
+ File parent = getFile(filename).getParentFile();
+ if (parent == null) {
+ throw new ActionHandlerException("Cannot access parent directory of [" + formatPath(filename) + "].");
+ }
+
+ return parent;
+ }
+
private static File getFile(String filename) throws ActionHandlerException {
return new File(filename);
}
12 years, 9 months
[rhq] Branch 'code-smell' - 8 commits - modules/enterprise modules/plugins
by lkrejci
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 26 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java | 11 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java | 58 -----
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/ManagedComponentDeployer.java | 105 +++++-----
modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 2
5 files changed, 87 insertions(+), 115 deletions(-)
New commits:
commit 78ce51980e1fbb6ece062825c813722b46e4952c
Merge: fbc31a7 ec88d4b
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Aug 1 08:42:38 2011 +0200
Merge branch 'master' into code-smell
commit ec88d4be0152d195ef769de97f43cdd289d77aeb
Merge: b38642e c4a82bc
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Aug 1 08:41:55 2011 +0200
Merge branch 'code-smell' into master
commit fbc31a7aae1ffc7949789473bfe7a72c5777d862
Merge: b38642e c4a82bc
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Aug 1 08:38:51 2011 +0200
Merge branch 'master' into code-smell
commit c4a82bca1620900e3bb2c7353ca5425a1ee4b354
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jul 29 17:20:11 2011 -0400
[BZ-726508 - Can't create alert condition on certain metrics]
Since metric def names may not be unique, they are duplicated
for the 'Per Minute' version of certain metrics, don't use them
for the value map keys in alert def drop downs.
- Also, some of these metric name lists are long, sort the
menu entries.
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 2fd9400..44875d8 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,9 +24,11 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
+import java.util.TreeSet;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -572,7 +574,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
LinkedHashMap<String, String> traitsMap = new LinkedHashMap<String, String>();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
if (def.getDataType() == DataType.TRAIT) {
- traitsMap.put(def.getName(), def.getDisplayName());
+ traitsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
@@ -703,10 +705,21 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem buildMetricDropDownMenu(String itemName, boolean dynamicOnly, FormItemIfFunction ifFunc) {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
- for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ TreeSet<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());
+
+ for (MeasurementDefinition def : sortedDefs) {
if (def.getDataType() == DataType.MEASUREMENT) {
if (!dynamicOnly || def.getNumericType() == NumericType.DYNAMIC) {
- metricsMap.put(def.getName(), def.getDisplayName());
+ // use id as opposed to name for key, the name is not unique when per-minute metric is also used
+ metricsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
}
@@ -726,7 +739,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
if (def.getDataType() == DataType.CALLTIME) {
- metricsMap.put(def.getName(), def.getDisplayName());
+ metricsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
@@ -790,9 +803,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
return help;
}
- private MeasurementDefinition getMeasurementDefinition(String metricName) {
+ private MeasurementDefinition getMeasurementDefinition(String metricId) {
+ int id = Integer.valueOf(metricId).intValue();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
- if (metricName.equals(def.getName())) {
+ if (id == def.getId()) {
return def;
}
}
commit e431028f07369d98a0ffc72c883a8be1c4ab39f6
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Jul 29 15:03:54 2011 -0400
[BZ 710230] improve description of testConnection operation on datasources/connFactories (https://bugzilla.redhat.com/show_bug.cgi?id=710230)
diff --git a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
index 21161fe..bbe70ea 100644
--- a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
@@ -37,7 +37,7 @@
</results>
</operation>
- <operation name="testConnection" displayName="Test Connection" description="Test if a connection can be obtained">
+ <operation name="testConnection" displayName="Test Connection" description="Test if a connection can be obtained - returns true if a connection was obtained, or false if not; NOTE: this operation will always return a status of Successful - the results of the operation must be inspected to see whether or not a connection was obtained">
<results>
<c:notes>Test if a connection can be obtained</c:notes>
<c:simple-property type="boolean" name="result" description="Was a connection obtained?"/>
commit e4e340d418889e7a8972c421fe002a84ff2aa187
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jul 29 13:28:33 2011 -0400
[BZ-726714 - Metric template creation generates NPE (null pointer exception)]
Fix a problem when trying to apply a metric template to a resource in a
"hidden" state like UNINVENTORIED.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
index 98110ac..03cd4bb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
@@ -498,6 +498,17 @@ public class MeasurementScheduleManagerBean implements MeasurementScheduleManage
for (Integer resourceId : reqMap.keySet()) {
Agent agent = agentManager.getAgentByResourceId(subjectManager.getOverlord(), resourceId);
+ // Ignore resources that are not actually associated with an agent. For example,
+ // those with an UNINVENTORIED status.
+ if (null == agent) {
+ if (log.isDebugEnabled()) {
+ log.debug("Ignoring measurement schedule change for non-agent-related resource ["
+ + resourceId + "]. It is probably waiting to be uninventoried.");
+ }
+
+ continue;
+ }
+
Set<ResourceMeasurementScheduleRequest> agentUpdate = agentUpdates.get(agent);
if (agentUpdate == null) {
agentUpdate = new HashSet<ResourceMeasurementScheduleRequest>();
commit 397cb79ad080285aadb93a9257318d4c1ee2c9b6
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Jul 29 12:51:50 2011 -0400
some general cleanup/refactoring + improved error handling
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/ManagedComponentDeployer.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/ManagedComponentDeployer.java
index 6314d3a..4315155 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/ManagedComponentDeployer.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/ManagedComponentDeployer.java
@@ -16,7 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
package org.rhq.plugins.jbossas5.deploy;
import java.io.File;
@@ -60,14 +59,10 @@ public class ManagedComponentDeployer implements Deployer {
private static final ProfileKey FARM_PROFILE_KEY = new ProfileKey("farm");
private static final ProfileKey APPLICATIONS_PROFILE_KEY = new ProfileKey("applications");
- public static final String DEPLOYMENT_NAME_PROPERTY = "deploymentName";
private PackageDownloader downloader;
private ProfileServiceConnection profileServiceConnection;
- /**
- * @param downloader
- */
public ManagedComponentDeployer(ProfileServiceConnection profileServiceConnection, PackageDownloader downloader) {
this.downloader = downloader;
this.profileServiceConnection = profileServiceConnection;
@@ -120,9 +115,9 @@ public class ManagedComponentDeployer implements Deployer {
deploymentManager.loadProfile(FARM_PROFILE_KEY);
}
- String[] deployedArchives;
+ String[] deploymentNames;
try {
- deployedArchives = DeploymentUtils.deployArchive(deploymentManager, archiveFile, deployExploded);
+ deploymentNames = DeploymentUtils.deployArchive(deploymentManager, archiveFile, deployExploded);
} finally {
// Make sure to switch back to the 'applications' profile if we switched to the 'farm' profile above.
if (deployFarmed) {
@@ -130,62 +125,72 @@ public class ManagedComponentDeployer implements Deployer {
}
}
- //if deployed exploded, we need to store the sha of source package for correct versioning
+ if (deploymentNames == null || deploymentNames.length != 1) {
+ throw new RuntimeException("deploy operation returned invalid result: " + deploymentNames);
+ }
+
+ // e.g.: vfszip:/C:/opt/jboss-6.0.0.Final/server/default/deploy/foo.war
+ String deploymentName = deploymentNames[0];
+
+ // If deployed exploded, we need to store the SHA of source package in META-INF/MANIFEST.MF for correct
+ // versioning.
if (deployExploded) {
- for (String archive : deployedArchives) {
-
- String shaString = new MessageDigestGenerator(MessageDigestGenerator.SHA_256)
- .getDigestString(archiveFile);
-
- URI deployePackageURI = URI.create(archive);
- // e.g.: foo.war
- String path = deployePackageURI.getPath();
- File location = new File(path);
- //We've located the deployed
- if ((location != null) && (location.isDirectory())) {
- File manifestFile = new File(location, "META-INF/MANIFEST.MF");
- Manifest manifest;
- if (manifestFile.exists()) {
- FileInputStream inputStream = new FileInputStream(manifestFile);
- manifest = new Manifest(inputStream);
- inputStream.close();
- } else {
- File metaInf = new File(location, "META-INF");
- if (!metaInf.exists())
- if (!metaInf.mkdir())
- throw new Exception("Could not create directory " + location + "META-INF.");
-
- manifestFile = new File(metaInf, "MANIFEST.MF");
- manifest = new Manifest();
- }
- Attributes attribs = manifest.getMainAttributes();
- attribs.putValue("RHQ-Sha256", shaString);
- FileOutputStream outputStream = new FileOutputStream(manifestFile);
- manifest.write(outputStream);
- outputStream.close();
+ MessageDigestGenerator sha256Generator = new MessageDigestGenerator(MessageDigestGenerator.SHA_256);
+ String shaString = sha256Generator.calcDigestString(archiveFile);
+ URI deploymentURI = URI.create(deploymentName);
+ // e.g.: /C:/opt/jboss-6.0.0.Final/server/default/deploy/foo.war
+ String deploymentPath = deploymentURI.getPath();
+ File deploymentFile = new File(deploymentPath);
+ if (deploymentFile.isDirectory()) {
+ File manifestFile = new File(deploymentFile, "META-INF/MANIFEST.MF");
+ Manifest manifest;
+ if (manifestFile.exists()) {
+ FileInputStream inputStream = new FileInputStream(manifestFile);
+ manifest = new Manifest(inputStream);
+ inputStream.close();
+ } else {
+ File metaInf = new File(deploymentFile, "META-INF");
+ if (!metaInf.exists())
+ if (!metaInf.mkdir())
+ throw new Exception("Could not create directory " + deploymentFile + "META-INF.");
+
+ manifestFile = new File(metaInf, "MANIFEST.MF");
+ manifest = new Manifest();
}
+ Attributes attribs = manifest.getMainAttributes();
+ attribs.putValue("RHQ-Sha256", shaString);
+ FileOutputStream outputStream = new FileOutputStream(manifestFile);
+ manifest.write(outputStream);
+ outputStream.close();
+ } else {
+ LOG.error("Exploded deployment '" + deploymentFile
+ + "' does not exist or is not a directory - unable to add RHQ versioning metadata to META-INF/MANIFEST.MF.");
}
}
+ // Reload the management view to pickup the ManagedDeployment for the app we just deployed.
ManagementView managementView = this.profileServiceConnection.getManagementView();
managementView.load();
- for (String deployedArchive : deployedArchives) {
- ManagedDeployment managedDeployment;
- try {
- managedDeployment = managementView.getDeployment(deployedArchive);
- } catch (NoSuchDeploymentException e) {
- LOG.error("Failed to find managed deployment '" + deployedArchive + "' after deploying '"
- + archiveName + "'.");
- continue;
- }
+
+ ManagedDeployment managedDeployment = null;
+ try {
+ managedDeployment = managementView.getDeployment(deploymentName);
+ } catch (NoSuchDeploymentException e) {
+ LOG.error("Failed to find managed deployment '" + deploymentName + "' after deploying '"
+ + archiveName + "', so cannot start the application.");
+ createResourceReport.setStatus(CreateResourceStatus.INVALID_ARTIFACT);
+ createResourceReport.setErrorMessage("Unable to start application '" + deploymentName
+ + "' after deploying it, since lookup of the associated ManagedDeployment failed.");
+ }
+ if (managedDeployment != null) {
DeploymentState state = managedDeployment.getDeploymentState();
if (state != DeploymentState.STARTED) {
// The app failed to start - do not consider this a FAILURE, since it was at least deployed
// successfully. However, set the status to INVALID_ARTIFACT and set an error message, so
// the user is informed of the condition.
createResourceReport.setStatus(CreateResourceStatus.INVALID_ARTIFACT);
- createResourceReport.setErrorMessage("Failed to start application '" + deployedArchive + "' after deploying it.");
- break;
+ createResourceReport.setErrorMessage("Failed to start application '" + deploymentName
+ + "' after deploying it.");
}
}
commit ff1fc54e0d3c744c5a66172d375eb44dca31e631
Author: Simeon Pinder <simeonpinder(a)gmail.com>
Date: Fri Jul 29 09:03:56 2011 -0400
BZ:726502,717526: removing deprecated content from the remote interface as duplicate but deprecated names causes non-unique message signatures which creates invalid wsdl.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
index 0883859..d92883f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
@@ -47,64 +47,6 @@ import org.rhq.enterprise.server.system.ServerVersion;
public interface ResourceFactoryManagerRemote {
/**
- * @Deprecated
- *
- * Use new signature with timeout parameter:
- * @{link {@link #createPackageBackedResource(Subject, int, int, String, Configuration, String, String, Integer, Configuration, byte[], Integer)}
- */
- @WebMethod
- CreateResourceHistory createResource( //
- @WebParam(name = "subject") Subject subject, //
- @WebParam(name = "parentResourceId") int parentResourceId, //
- @WebParam(name = "resourceTypeId") int resourceTypeId, //
- @WebParam(name = "resourceName") String resourceName, //
- @WebParam(name = "pluginConfiguration") Configuration pluginConfiguration, //
- @WebParam(name = "resourceConfiguration") Configuration resourceConfiguration);
-
- /**
- * @Deprecated
- *
- * Use new signature with timeout parameter:
- * @{link {@link #createPackageBackedResource(Subject, int, int, String, Configuration, String, String, Integer, Configuration, byte[], Integer)}
- */
- @WebMethod
- CreateResourceHistory createPackageBackedResource(//
- @WebParam(name = "subject") Subject subject, //
- @WebParam(name = "parentResourceId") int parentResourceId, //
- @WebParam(name = "newResourceTypeId") int newResourceTypeId, //
- @WebParam(name = "newResourceName") String newResourceName, //
- @WebParam(name = "pluginConfiguration")//
- @XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
- Configuration pluginConfiguration, //
- @WebParam(name = "packageName") String packageName, //
- @WebParam(name = "packageVersion") String packageVersion, //
- @WebParam(name = "architectureId") Integer architectureId, //
- @WebParam(name = "deploymentTimeConfiguration")//
- @XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
- Configuration deploymentTimeConfiguration, //
- @WebParam(name = "packageBits") byte[] packageBits);
-
- /**
- * @Deprecated
- *
- * Use new signature with timeout parameter:
- * @{link {@link #createPackageBackedResourceViaPackageVersion(Subject, int, int, String, Configuration, Configuration, int, Integer)
- */
- @WebMethod
- public CreateResourceHistory createPackageBackedResourceViaPackageVersion(//
- @WebParam(name = "subject") Subject subject, //
- @WebParam(name = "parentResourceId") int parentResourceId, //
- @WebParam(name = "newResourceTypeId") int newResourceTypeId, //
- @WebParam(name = "newResourceName") String newResourceName, //
- @WebParam(name = "pluginConfiguration")//
- @XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
- Configuration pluginConfiguration, //
- @WebParam(name = "deploymentTimeConfiguration")//
- @XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
- Configuration deploymentTimeConfiguration, //
- @WebParam(name = "packageVersionId") int packageVersionId);
-
- /**
* Creates a new physical resource. The resource will be created as a child of the specified parent. In other words,
* the resource component of the indicated parent will be used to create the new resource. This call should only be
* made for resource types that are defined with a create/delete policy of {@link CreateDeletePolicy#BOTH} or
12 years, 9 months