[rhq] Branch 'perftest' - 14 commits - modules/core modules/enterprise modules/plugins
by Heiko W. Rupp
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java | 15
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java | 12
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 3
modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java | 24
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java | 147 ++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java | 28 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java | 52 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java | 75 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java | 30 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java | 23
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java | 27 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java | 94 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 30 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java | 37 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java | 32 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java | 23
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GroupAlertDefinitionGWTService.java | 45 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java | 35 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java | 80 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java | 26 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java | 129 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java | 32 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 45 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java | 52 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java | 76 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java | 58 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java | 121 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java | 48 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java | 30 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java | 62 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 23
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java | 90 +++
modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml | 17
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 7
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java | 123 ++++
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 56 +-
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java | 260 ++++++----
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java | 12
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java | 90 ++-
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java | 206 +++++--
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionInfo.java | 92 +++
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionManager.java | 124 ++++
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseComponent.java | 167 ++++++
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java | 65 +-
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDiscoveryComponent.java | 99 +--
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlPluginLifecycleListener.java | 28 -
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableComponent.java | 129 ++++
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableDiscoveryComponent.java | 85 +++
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserComponent.java | 128 ++++
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserDiscoveryComponent.java | 76 ++
modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml | 112 +---
74 files changed, 2736 insertions(+), 1046 deletions(-)
New commits:
commit a07d67fc4f26d8a59c3ed01341e81830b0706fc6
Merge: 58c4c2c... a6d0d0b...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Oct 18 12:05:37 2010 +0200
Merge branch 'master' into perftest
commit a6d0d0b482e537e103bd117429227780e2e08522
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Oct 18 11:20:09 2010 +0200
Smallish import cleanup.
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 f38b944..b57c65b 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,13 +18,6 @@
*/
package org.rhq.plugins.mysql;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
@@ -36,6 +29,8 @@ import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.plugins.database.DatabaseComponent;
+import java.io.File;
+import java.io.FileReader;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -44,9 +39,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.pluginapi.event.EventPoller;
import org.rhq.core.system.AggregateProcessInfo;
import org.rhq.core.system.ProcessInfo;
import org.rhq.plugins.database.DatabaseQueryUtility;
commit 28ae734397d49586094f973c0db81f06fc394791
Author: Steve Millidge <smillidge(a)c2b2.co.uk>
Date: Mon Oct 18 11:13:29 2010 +0200
Huge Improvement of the MySQL plugin.
This included autodiscovery of MySQL, databases and users.
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 737634b..f38b944 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
@@ -16,11 +16,15 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
package org.rhq.plugins.mysql;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
@@ -33,129 +37,184 @@ import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.plugins.database.DatabaseComponent;
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;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.pluginapi.event.EventPoller;
+import org.rhq.core.system.AggregateProcessInfo;
+import org.rhq.core.system.ProcessInfo;
+import org.rhq.plugins.database.DatabaseQueryUtility;
/**
* @author Greg Hinkle
+ * @author Steve Millidge
*/
public class MySqlComponent implements DatabaseComponent, ResourceComponent, MeasurementFacet {
private ResourceContext resourceContext;
- private Connection connection;
- private static final Log log = LogFactory.getLog(MySqlComponent.class);
+ private AggregateProcessInfo aggregateProcessInfo;
+ private MySqlConnectionInfo info;
+ private Log log = LogFactory.getLog(this.getClass());
+ private Map<String, String> globalStatusValues = new HashMap<String, String>();
+ private Map<String, String> globalVariables = new HashMap<String, String>();
public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception {
this.resourceContext = resourceContext;
- getConnection();
+ info = MySqlDiscoveryComponent.buildConnectionInfo(resourceContext.getPluginConfiguration());
+ ProcessInfo processInfo = resourceContext.getNativeProcess();
+ if (processInfo != null) {
+ aggregateProcessInfo = processInfo.getAggregateProcessTree();
+ } else {
+ //findProcessInfo();
+ //log.debug("Unable to locate native process information. Process level statistics will be unavailable.");
+ }
}
public void stop() {
- try {
- this.connection.close();
- } catch (SQLException e) {
- log.warn(e);
- }
+ MySqlConnectionManager.getConnectionManager().closeConnection(info);
}
public AvailabilityType getAvailability() {
+ if (log.isDebugEnabled()) {
+ log.debug("Doing an availability check on " + info.buildURL());
+ }
- try {
- getConnection().createStatement().executeQuery("select 1");
- return AvailabilityType.UP;
- } catch (SQLException e) {
- if (log.isDebugEnabled()) {
- log.debug("getAvail failed: " + e.getMessage());
- }
- return AvailabilityType.DOWN;
+ Connection conn = getConnection();
+ AvailabilityType result = AvailabilityType.DOWN;
+ if (conn != null) {
+ // the connection must be OK as the validity check will have worked
+ result = AvailabilityType.UP;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Availability check on " + info.buildURL() + " gives " + result);
}
+ return result;
+
}
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
+ Connection conn = getConnection();
+ if (conn != null) {
+ ResultSet rs = null;
+ Statement stmt = null;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("SHOW GLOBAL STATUS");
+ while (rs.next()) {
+ globalStatusValues.put(rs.getString(1), rs.getString(2));
+ }
- ResultSet rs = getConnection().createStatement().executeQuery("SHOW /*!50002 GLOBAL */ STATUS");
-
- Map<String, String> values = new HashMap<String, String>();
- while (rs.next()) {
- values.put(rs.getString(1), rs.getString(2));
+ rs.close();
+ rs = stmt.executeQuery("select * from information_schema.global_variables");
+ while (rs.next()) {
+ globalVariables.put(rs.getString(1), rs.getString(2));
+ }
+ } catch (SQLException sqle) {
+ } finally {
+ DatabaseQueryUtility.close(stmt, rs);
+ }
}
-
+ // get process information
+ aggregateProcessInfo = findProcessInfo();
for (MeasurementScheduleRequest request : metrics) {
- if (!request.getName().startsWith("Process")) {
-
+ String requestName = request.getName();
+ if (requestName.startsWith("Process") && aggregateProcessInfo != null) {
+ aggregateProcessInfo.refresh();
+ if ("Process.aggregateMemory.resident".equals(requestName)) {
+ long mem = aggregateProcessInfo.getAggregateMemory().getResident();
+ report.addData(new MeasurementDataNumeric(request, new Double((double) mem)));
+ } 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)) {
+ long value = aggregateProcessInfo.getAggregateMemory().getPageFaults();
+ report.addData(new MeasurementDataNumeric(request, new Double((double) value)));
+ } else if ("Process.aggregateCpu.user".equals(requestName)) {
+ long value = aggregateProcessInfo.getAggregateCpu().getUser();
+ report.addData(new MeasurementDataNumeric(request, new Double((double) value)));
+ } else if ("Process.aggregateCpu.sys".equals(requestName)) {
+ long value = aggregateProcessInfo.getAggregateCpu().getSys();
+ report.addData(new MeasurementDataNumeric(request, new Double((double) value)));
+ } 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)) {
+ long value = aggregateProcessInfo.getAggregateCpu().getTotal();
+ 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)));
+ }
+ } else {
if (request.getDataType() == DataType.MEASUREMENT) {
try {
- String strVal = values.get(request.getName());
+ String strVal = globalStatusValues.get(request.getName());
double val = Double.parseDouble(strVal);
report.addData(new MeasurementDataNumeric(request, val));
- } catch (Exception e) { }
+ } catch (Exception e) {
+ }
}
}
}
}
-
-
-
-
public Connection getConnection() {
try {
- this.connection = MySqlDiscoveryComponent.buildConnection(resourceContext.getPluginConfiguration());
-
- } catch (SQLException e) {
- if (log.isDebugEnabled()) {
- log.debug("getAvail failed: " + e.getMessage());
- }
+ return MySqlConnectionManager.getConnectionManager().getConnection(info);
+ } catch (SQLException ex) {
+ log.warn("Unable to obtain database connection ", ex);
+ return null;
}
- return connection;
}
+ @Override
public void removeConnection() {
- this.connection = null;
+ MySqlConnectionManager.getConnectionManager().closeConnection(info);
}
- public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
-
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
-
- Connection conn =
- DriverManager.getConnection("jdbc:mysql://192.168.1.5?user=rhqadmin&password=rhqadmin");
-
- DatabaseMetaData dmd = conn.getMetaData();
- System.out.println("Version: " + dmd.getDatabaseProductVersion());
- System.out.println("Product: " + dmd.getDatabaseProductName());
-
-
-
- // The default changed in 5.0.2... the following gets globabl data for all versions
-// ResultSet rs = conn.createStatement().executeQuery("SHOW /*!50002 GLOBAL *//* STATUS");
- ResultSet rs = conn.createStatement().executeQuery("SHOW TABLE STATUS FROM mysql");
-// ResultSet rs = dmd.getTables(null, null, null, null);//Catalogs();//Schemas();
- ResultSetMetaData md = rs.getMetaData();
- for (int i = 1; i <= md.getColumnCount();i++) {
- System.out.print(md.getColumnName(i) + " ");
+ private AggregateProcessInfo findProcessInfo() {
+ AggregateProcessInfo result = null;
+ // is still running reuse
+ if (aggregateProcessInfo != null && aggregateProcessInfo.isRunning()) {
+ result = aggregateProcessInfo;
+ } else {
+ long pid = findPID();
+ if (pid != -1) {
+ List<ProcessInfo> processes = resourceContext.getSystemInformation().getAllProcesses();
+ for (ProcessInfo pi : processes) {
+ if (pid == pi.getPid()) {
+ result = pi.getAggregateProcessTree();
+ break;
+ }
+ }
}
- System.out.println("");
- while (rs.next()) {
+ }
+ return result;
+ }
- for (int i = 1; i <= md.getColumnCount();i++) {
- System.out.print(rs.getObject(i) + " ");
- }
- System.out.println("");
+ private long findPID() {
+ long result = -1;
+ String pidFile = globalVariables.get("PID_FILE");
+ File file = new File(pidFile);
+ 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);
+ } catch (Exception ex) {
+ log.warn("Unable to read MySQL pid file " + pidFile);
}
- } catch (SQLException ex) {
- // handle any errors
- log.info("SQLException: " + ex.getMessage());
- log.info("SQLState: " + ex.getSQLState());
- log.info("VendorError: " + ex.getErrorCode());
}
+ return result;
}
}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionInfo.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionInfo.java
new file mode 100644
index 0000000..4fa0a4f
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionInfo.java
@@ -0,0 +1,92 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.mysql;
+
+/**
+ * A class to act as a key to a specific MySQL connection
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+class MySqlConnectionInfo {
+
+ private String host;
+ private String port;
+ private String db;
+ private String user;
+ private String password;
+ private int hashCode;
+
+ MySqlConnectionInfo(String host, String port, String db, String user, String password ) {
+ this.host = host;
+ this.port = port;
+ this.db = db;
+ this.user = user;
+ this.password = password;
+ this.hashCode = new StringBuilder().append(host).
+ append(port).
+ append(db).
+ append(user).
+ append(password).toString().hashCode();
+
+ }
+
+ public String getDb() {
+ return db;
+ }
+
+ @Override
+ public int hashCode() {
+ return hashCode;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public String buildURL() {
+ return new StringBuilder().append("jdbc:mysql://")
+ .append(host)
+ .append(":")
+ .append(port)
+ .append("/")
+ .append(db).toString();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ boolean result = false;
+ if ((other instanceof MySqlConnectionInfo) && (other.hashCode() == this.hashCode())) {
+ result = true;
+ }
+ return result;
+ }
+
+}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionManager.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionManager.java
new file mode 100644
index 0000000..9dd60ee
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionManager.java
@@ -0,0 +1,124 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.mysql;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.HashMap;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A class to manage the connections to MySQL
+ * This class keeps a cache of connections to MySQL and reuses them on demand
+ * We assume single threaded access to the Connection in the agent
+ * this will need to be reworked if that assumption is not correct
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+class MySqlConnectionManager {
+
+ private HashMap<MySqlConnectionInfo, Connection> connections;
+ private static MySqlConnectionManager singleton;
+ private Log logger = LogFactory.getLog(MySqlConnectionManager.class);
+
+ private MySqlConnectionManager() {
+ connections = new HashMap<MySqlConnectionInfo,Connection>();
+ try {
+ Class.forName("com.mysql.jdbc.Driver").newInstance();
+ } catch (Exception ex) {
+ logger.error("Unable to find com.mysql.jdbc.Driver");
+ }
+ }
+
+ static MySqlConnectionManager getConnectionManager() {
+ if (singleton == null) {
+ singleton = new MySqlConnectionManager();
+ }
+ return singleton;
+ }
+
+ public void shutdown() {
+ Driver driver = null;
+ for (Connection conn : connections.values()) {
+ try {
+ if (driver == null) {
+ String driverName = conn.getMetaData().getDriverName();
+ driver = DriverManager.getDriver(driverName);
+ }
+ conn.close();
+ }catch(SQLException e) { logger.info("Problem closing connection on Shutdown ignoring...");}
+ }
+ // deregister driver as well
+ if (driver != null) {
+ try {
+ DriverManager.deregisterDriver(driver);
+ } catch (SQLException ex) {
+ logger.warn("Unable to deregister MySQL Driver on shutdown");
+ }
+ }
+ }
+
+ void closeConnection(MySqlConnectionInfo info) {
+ Connection conn = connections.get(info);
+ if (conn != null) {
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Closing Connection to " + info.buildURL());
+ }
+ conn.close();
+ } catch (SQLException e) {
+ logger.warn("Problem closing connection to " + info.buildURL() + " on close");
+ }
+ }
+ connections.remove(info);
+ }
+
+ Connection getConnection (MySqlConnectionInfo info) throws SQLException {
+ Connection conn = connections.get(info);
+ String url = info.buildURL();
+ if (conn == null) {
+ if (logger.isInfoEnabled()) {
+ logger.info("Attemping connection to " + url);
+ }
+ conn = DriverManager.getConnection(url,info.getUser(), info.getPassword());
+ if (logger.isInfoEnabled()) {
+ logger.info("Successfully connected to " + url);
+ }
+ connections.put(info, conn);
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Reusing existing connection to " + url);
+ }
+ }
+
+ // check the validity of the connection
+ if (!conn.isValid(0)) {
+ // attempt a single reconnect here and now
+ conn.close();
+ conn = DriverManager.getConnection(url,info.getUser(), info.getPassword());
+ connections.put(info, conn);
+ logger.info("Refreshed a connection to " + url);
+ }
+ return conn;
+ }
+
+}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseComponent.java
new file mode 100644
index 0000000..43747bc
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseComponent.java
@@ -0,0 +1,167 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.mysql;
+
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.availability.AvailabilityFacet;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.database.DatabaseComponent;
+import org.rhq.plugins.database.DatabaseQueryUtility;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.measurement.AvailabilityType;
+
+/**
+ *
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+public class MySqlDatabaseComponent implements DatabaseComponent, AvailabilityFacet, OperationFacet {
+
+ private ResourceContext resourceContext;
+ private MySqlComponent parent;
+ private String databaseName;
+ private static Log log = LogFactory.getLog(MySqlDatabaseComponent.class);
+
+ @Override
+ public Connection getConnection() {
+ return parent.getConnection();
+ }
+
+ @Override
+ public void removeConnection() {
+ parent.removeConnection();
+ }
+
+ @Override
+ public void start(ResourceContext rc) throws InvalidPluginConfigurationException, Exception {
+ resourceContext = rc;
+ databaseName = rc.getResourceKey();
+ parent = (MySqlComponent)resourceContext.getParentResourceComponent();
+ }
+
+ public String getName() { return databaseName; }
+
+ @Override
+ public void stop() {
+ }
+
+ @Override
+ public AvailabilityType getAvailability() {
+ AvailabilityType result = AvailabilityType.DOWN;
+
+ if (log.isDebugEnabled()) {
+ log.debug("Availability check for " + databaseName);
+ }
+ Connection conn = getConnection();
+ if (conn != null) {
+ Statement statement = null;
+ ResultSet resultSet = null;
+ try {
+ statement = conn.createStatement();
+ resultSet = statement.executeQuery("SHOW DATABASES LIKE '" + databaseName + "'");
+ if (resultSet.next()) {
+ if (resultSet.getString(1).equalsIgnoreCase(databaseName)) {
+ result = AvailabilityType.UP;
+ }
+ }
+ }catch(SQLException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Got Exception when determining database availability",e);
+ }
+ } finally {
+ DatabaseQueryUtility.close(statement, resultSet);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public OperationResult invokeOperation(String name, Configuration parameters)
+ throws InterruptedException, Exception {
+
+ if ("invokeSql".equals(name)) {
+ Statement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = getConnection().createStatement();
+ String sql = parameters.getSimple("sql").getStringValue();
+ OperationResult result = new OperationResult();
+
+ if (parameters.getSimple("type").getStringValue().equals("update")) {
+ int updateCount = stmt.executeUpdate(sql);
+ result.getComplexResults().put(new PropertySimple("result", "Query updated " + updateCount + " rows"));
+
+ } else {
+ rs = stmt.executeQuery(parameters.getSimple("sql").getStringValue());
+
+ ResultSetMetaData md = rs.getMetaData();
+ StringBuilder buf = new StringBuilder();
+ int rowCount = 0;
+
+ buf.append("<table>");
+ buf.append("<th>");
+ for (int i = 1; i <= md.getColumnCount(); i++) {
+ buf.append("<td>");
+ buf.append(md.getColumnName(i) + " (" + md.getColumnTypeName(i) + ")");
+ buf.append("</td>");
+ }
+ buf.append("</th>");
+
+
+ while (rs.next()) {
+ rowCount++;
+ buf.append("<tr>");
+ for (int i = 1; i <= md.getColumnCount(); i++) {
+ buf.append("<td>");
+ buf.append(rs.getString(i));
+ buf.append("</td>");
+ }
+ buf.append("</tr>");
+ }
+
+ buf.append("</table>");
+ result.getComplexResults().put(new PropertySimple("result", "Query returned " + rowCount + " rows"));
+ result.getComplexResults().put(new PropertySimple("contents", buf.toString()));
+ }
+ return result;
+ } finally {
+ if (rs != null) {
+ rs.close();
+ }
+
+ if (stmt != null) {
+ stmt.close();
+ }
+ }
+ } else {
+ throw new UnsupportedOperationException("Operation [" + name + "] is not supported yet.");
+ }
+ }
+}
+
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java
index e34f021..c8f8673 100644
--- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java
@@ -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.mysql;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
@@ -30,46 +29,62 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.LinkedHashSet;
import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
/**
* @author Greg Hinkle
+ * @author Steve Millidge
*/
public class MySqlDatabaseDiscoveryComponent implements ResourceDiscoveryComponent<MySqlComponent> {
+ private Log logger = LogFactory.getLog(this.getClass());
-
+ @Override
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MySqlComponent> context) {
- Set<DiscoveredResourceDetails> tables = new LinkedHashSet<DiscoveredResourceDetails>();
-
+ if (logger.isDebugEnabled()) {
+ logger.debug("Database discovery started");
+ }
+ Set<DiscoveredResourceDetails> databases = new LinkedHashSet<DiscoveredResourceDetails>();
Connection connection = context.getParentResourceComponent().getConnection();
Statement statement = null;
ResultSet resultSet = null;
- try {
- statement = connection.createStatement();
- resultSet = statement.executeQuery("SHOW DATABASES");
+ if (connection != null) {
+ try {
+ statement = connection.createStatement();
+ resultSet = statement.executeQuery("SHOW DATABASES");
- while (resultSet.next()) {
- String databaseName = resultSet.getString(1);
- DiscoveredResourceDetails details =
- new DiscoveredResourceDetails(
- context.getResourceType(),
- databaseName,
- databaseName + " Database",
- null,
- "A MySql Database",
- null,
- null);
- tables.add(details);
- }
+ while (resultSet.next()) {
+ String databaseName = resultSet.getString(1);
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("databaseName",databaseName));
+ DiscoveredResourceDetails details =
+ new DiscoveredResourceDetails(
+ context.getResourceType(),
+ databaseName,
+ databaseName + " Database",
+ null,
+ "A MySql Database",
+ config,
+ null);
+ databases.add(details);
+ }
- } catch (SQLException e) {
- DatabaseQueryUtility.close(statement, resultSet);
+ } catch (SQLException e) {
+ } finally {
+ DatabaseQueryUtility.close(statement, resultSet);
+ }
+ } else {
+ if (logger.isInfoEnabled()) {
+ logger.info("No connection to MySQL obtained from connection manager");
+ }
}
- return tables;
+ return databases;
}
-
-}
\ No newline at end of file
+}
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 4f1045e..30b65f2 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
@@ -30,7 +30,6 @@ import org.rhq.core.pluginapi.inventory.ManualAddFacet;
import org.rhq.core.system.ProcessInfo;
import java.sql.Connection;
-import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.LinkedHashSet;
import java.util.List;
@@ -39,20 +38,22 @@ import java.util.Set;
/**
* @author Greg Hinkle
* @author Ian Springer
+ * @author Steve Millidge
*/
public class MySqlDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
private static final Log log = LogFactory.getLog(MySqlDiscoveryComponent.class);
- public static final String DRIVER_CONFIGURATION_PROPERTY = "driverClass";
public static final String HOST_CONFIGURATION_PROPERTY = "host";
public static final String PORT_CONFIGURATION_PROPERTY = "port";
public static final String DB_CONFIGURATION_PROPERTY = "db";
public static final String PRINCIPAL_CONFIGURATION_PROPERTY = "principal";
public static final String CREDENTIALS_CONFIGURATION_PROPERTY = "credentials";
- private static final String DEFAULT_RESOURCE_DESCRIPTION = "Mysql relational database server";
-
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Resource Discovery Started");
+ }
Set<DiscoveredResourceDetails> servers = new LinkedHashSet<DiscoveredResourceDetails>();
// Process any auto-discovered resources.
@@ -62,10 +63,7 @@ public class MySqlDiscoveryComponent implements ResourceDiscoveryComponent, Manu
ProcessInfo procInfo = result.getProcessInfo();
- DiscoveredResourceDetails resourceDetails = createResourceDetails(context, context.getDefaultPluginConfiguration(), procInfo);
- if (resourceDetails!=null) {
- servers.add(resourceDetails);
- }
+ servers.add(createResourceDetails(context,context.getDefaultPluginConfiguration(),procInfo));
}
return servers;
@@ -81,56 +79,53 @@ public class MySqlDiscoveryComponent implements ResourceDiscoveryComponent, Manu
}
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;
+ MySqlConnectionInfo ci = buildConnectionInfo(pluginConfiguration);
+ Connection conn;
+ String version = "";
try {
- Connection 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());
+ } 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);
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlPluginLifecycleListener.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlPluginLifecycleListener.java
index 181a113..a731aed 100644
--- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlPluginLifecycleListener.java
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlPluginLifecycleListener.java
@@ -18,39 +18,29 @@
*/
package org.rhq.plugins.mysql;
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.util.Enumeration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.pluginapi.plugin.PluginContext;
import org.rhq.core.pluginapi.plugin.PluginLifecycleListener;
-import org.rhq.core.util.exception.ThrowableUtil;
+/**
+ *
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
public class MySqlPluginLifecycleListener implements PluginLifecycleListener {
private final Log log = LogFactory.getLog(MySqlPluginLifecycleListener.class);
+ private String pluginName;
public void initialize(PluginContext context) throws Exception {
- // no-op
+ pluginName = context.getPluginName();
}
public void shutdown() {
- // so we do not cause our classloader to leak perm gen, we need to de-register
- // any and all JDBC drivers this plugin registered
- Enumeration<Driver> drivers = DriverManager.getDrivers();
- while (drivers.hasMoreElements()) {
- try {
- Driver driver = drivers.nextElement();
- DriverManager.deregisterDriver(driver);
- log.debug("Deregistered JDBC driver: " + driver.getClass());
- } catch (Exception e) {
- log.warn("Failed to deregister JDBC drivers - memory might leak" + ThrowableUtil.getAllMessages(e));
- }
+ if (log.isDebugEnabled()) {
+ log.debug(new StringBuilder().append(pluginName).append(" Plugin Shutdown").toString());
}
-
- log.debug(this.getClass().getSimpleName() + " completed shutdown.");
- return;
+ MySqlConnectionManager.getConnectionManager().shutdown();
}
}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableComponent.java
new file mode 100644
index 0000000..73354f9
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableComponent.java
@@ -0,0 +1,129 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.mysql;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.plugins.database.DatabaseComponent;
+import org.rhq.plugins.database.DatabaseQueryUtility;
+
+/**
+ *
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+public class MySqlTableComponent implements DatabaseComponent, MeasurementFacet {
+
+ private String tableName;
+ private MySqlDatabaseComponent parent;
+ private String databaseName;
+ private Log log = LogFactory.getLog(this.getClass());
+
+ @Override
+ public Connection getConnection() {
+ return parent.getConnection();
+ }
+
+ @Override
+ public void removeConnection() {
+ parent.removeConnection();
+ }
+
+ @Override
+ public void start(ResourceContext rc) throws InvalidPluginConfigurationException, Exception {
+ tableName = rc.getResourceKey();
+ parent = (MySqlDatabaseComponent)rc.getParentResourceComponent();
+ databaseName = parent.getName();
+ }
+
+ @Override
+ public void stop() {
+ }
+
+ @Override
+ public AvailabilityType getAvailability() {
+ AvailabilityType result = AvailabilityType.DOWN;
+ Connection conn = parent.getConnection();
+ if (conn != null) {
+ Statement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("show tables from " + databaseName + " like '" + tableName + "'");
+ if (rs.first()) {
+ result = AvailabilityType.UP;
+ }
+ }catch (SQLException se) {
+ // ignore as unablailable if we can't execute the query
+ }finally {
+ DatabaseQueryUtility.close(stmt, rs);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public void getValues(MeasurementReport mr, Set<MeasurementScheduleRequest> set) throws Exception {
+ Connection conn = parent.getConnection();
+ if (conn != null ) {
+ Statement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("show table status from " + databaseName+ " like '" + tableName + "'");
+ if (rs.next()) {
+ for (MeasurementScheduleRequest request : set) {
+ String value = rs.getString(request.getName());
+ if (value == null) {value = "0";}
+ switch (request.getDataType()) {
+ case MEASUREMENT: {
+ mr.addData(new MeasurementDataNumeric(request, Double.valueOf(value)));
+ break;
+ } case TRAIT: {
+ mr.addData(new MeasurementDataTrait(request, value));
+ break;
+ } default: {
+ break;
+ }
+ }
+ }
+ }
+ } catch(Exception se) {
+ if (log.isInfoEnabled()) {
+ log.info("Unable to measure table statistics", se);
+ }
+ }finally {
+ DatabaseQueryUtility.close(stmt, rs);
+ }
+ }
+ }
+
+}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableDiscoveryComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableDiscoveryComponent.java
new file mode 100644
index 0000000..5b62118
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableDiscoveryComponent.java
@@ -0,0 +1,85 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.mysql;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.database.DatabaseQueryUtility;
+
+/**
+ *
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+public class MySqlTableDiscoveryComponent implements ResourceDiscoveryComponent {
+
+ private Log log = LogFactory.getLog(this.getClass());
+
+ @Override
+ public Set discoverResources(ResourceDiscoveryContext rdc) throws InvalidPluginConfigurationException, Exception {
+
+ HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+ MySqlDatabaseComponent parent = (MySqlDatabaseComponent)rdc.getParentResourceComponent();
+ Connection conn = parent.getConnection();
+
+ if (conn != null) {
+ Statement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("show tables from " + parent.getName());
+ while (rs.next()) {
+ String tableName = rs.getString(1);
+ if (log.isDebugEnabled()) {
+ log.debug("Discovered Table "+ tableName);
+ }
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("tableName",tableName));
+ DiscoveredResourceDetails details = new DiscoveredResourceDetails(
+ rdc.getResourceType(),
+ tableName,
+ tableName + " Table",
+ null,
+ tableName + " MySql Table", config, null);
+ set.add(details);
+ }
+ } catch(SQLException se) {
+ if (log.isDebugEnabled()) {
+ log.debug("Unable to Discover Tables",se);
+ }
+
+ }finally {
+ DatabaseQueryUtility.close(stmt, rs);
+ }
+ }
+ return set;
+ }
+
+}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserComponent.java
new file mode 100644
index 0000000..32525c2
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserComponent.java
@@ -0,0 +1,128 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.mysql;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+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.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.plugins.database.DatabaseComponent;
+import org.rhq.plugins.database.DatabaseQueryUtility;
+
+/**
+ *
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+public class MySqlUserComponent implements MeasurementFacet, DatabaseComponent {
+
+ private String userName;
+ private String host;
+ private MySqlComponent parent;
+ private Log log = LogFactory.getLog(this.getClass());
+ private ResourceContext context;
+
+ @Override
+ public Connection getConnection() {
+ return parent.getConnection();
+ }
+
+ @Override
+ public void removeConnection() {
+ parent.removeConnection();
+ }
+
+ @Override
+ public void start(ResourceContext rc) throws InvalidPluginConfigurationException, Exception {
+ parent = (MySqlComponent)rc.getParentResourceComponent();
+ context = rc;
+ userName = context.getPluginConfiguration().getSimple("userName").getStringValue();
+ host = context.getPluginConfiguration().getSimple("host").getStringValue();
+ }
+
+ @Override
+ public void stop() {
+ }
+
+
+ public void getValues(MeasurementReport mr, Set<MeasurementScheduleRequest> requests) throws Exception {
+ Connection conn = getConnection();
+ ResultSet rs = null;
+ Statement stmt = null;
+ int activeConnections = 0;
+ int totalConnections = 0;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("select User,Host,State from information_schema.processlist where User='"+userName+"'");
+ while(rs.next()) {
+ String hostVal = rs.getString(2);
+ String state = rs.getString(3);
+ if (hostVal.startsWith(host)) {
+ if (state.length() > 1) {
+ activeConnections ++;
+ }
+ totalConnections++;
+ }
+ }
+ }catch(SQLException sqle) {
+
+ } finally {
+ DatabaseQueryUtility.close(stmt, rs);
+ }
+
+ for (MeasurementScheduleRequest request : requests) {
+ if (request.getName().equals("TotalConnections")) {
+ mr.addData(new MeasurementDataNumeric(request, new Double((double)totalConnections)));
+ } else if (request.getName().equals("ActiveConnections")) {
+ mr.addData(new MeasurementDataNumeric(request, new Double((double)activeConnections)));
+ }
+ }
+ }
+
+ public AvailabilityType getAvailability() {
+ AvailabilityType result = AvailabilityType.DOWN;
+ Connection conn = getConnection();
+ ResultSet rs = null;
+ Statement stmt = null;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("select User from mysql.user where User='"+userName+"' and Host='" + host +"'");
+ if (rs.first()) {
+ result = AvailabilityType.UP;
+ }
+ }catch(SQLException sqle) {
+
+ } finally {
+ DatabaseQueryUtility.close(stmt, rs);
+ }
+ return result;
+ }
+
+}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserDiscoveryComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserDiscoveryComponent.java
new file mode 100644
index 0000000..d05682a
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserDiscoveryComponent.java
@@ -0,0 +1,76 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.mysql;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.HashSet;
+import java.util.Set;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.database.DatabaseQueryUtility;
+
+/**
+ *
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+public class MySqlUserDiscoveryComponent implements ResourceDiscoveryComponent {
+
+ public Set discoverResources(ResourceDiscoveryContext rdc) throws InvalidPluginConfigurationException, Exception {
+ HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+ MySqlComponent parent = (MySqlComponent) rdc.getParentResourceComponent();
+ Connection conn = parent.getConnection();
+ if (conn != null) {
+ Statement statement = null;
+ ResultSet resultSet = null;
+ try {
+ statement = conn.createStatement();
+ resultSet = statement.executeQuery("select User,Host from mysql.user");
+ while (resultSet.next()) {
+ String user = resultSet.getString(1);
+ String host = resultSet.getString(2);
+ String userName = user + "@" + host;
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("userName",user));
+ config.put(new PropertySimple("host",host));
+ DiscoveredResourceDetails discoveredUser =
+ new DiscoveredResourceDetails(
+ rdc.getResourceType(),
+ userName,
+ userName,
+ null,
+ "A MySql User",
+ config,
+ null);
+ set.add(discoveredUser);
+ }
+ } catch (Exception e) {
+ } finally {
+ DatabaseQueryUtility.close(statement, resultSet);
+ }
+ }
+ return set;
+ }
+}
diff --git a/modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml
index d94a60f..6a96c19 100644
--- a/modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml
@@ -15,8 +15,6 @@
description="MySql Server"
supportsManualAdd="true">
- <version match="8.0"/>
-
<!-- Properties are connection/lookup configurations. They are values that the
plugin components need to connect and interact with the resource. -->
<plugin-configuration>
@@ -31,45 +29,31 @@
<c:integer-constraint minimum="1" maximum="65535"/>
</c:constraint>
</c:simple-property>
- <c:simple-property name="db" default="MySql" displayName="database name" description="the name of the database to connect to"/>
-
- <c:simple-property name="driverClass" default="com.mysql.jdbc.Driver" displayName="JDBC driver class"
- description="the fully-qualified classname of the JDBC driver class" required="false"/>
- <c:simple-property name="principal" default="MySql" displayName="role name" description="the database role to connect as"/>
- <c:simple-property name="credentials" default="MySql" type="password" displayName="role password"
+ <c:simple-property name="db" default="mysql" displayName="database name" description="the name of the database to connect to"/>
+ <c:simple-property name="principal" default="root" displayName="role name" description="the database role to connect as"/>
+ <c:simple-property name="credentials" default="root" type="password" displayName="role password"
description="the password for the database role being used to connect"/>
</plugin-configuration>
<process-scan name="windows" query="process|basename|match=^(?i)mysqld\.exe$,process|basename|nomatch|parent=^(?i)mysqld\.exe$" />
<process-scan name="unix" query="process|basename|match=^mysqld$,process|basename|nomatch|parent=^mysqld$" />
- <operation name="listProcessStatistics" description="List statistics about the currently executing MySql backends">
- <results>
- <c:list-property name="processList">
- <c:map-property name="process">
- <c:simple-property name="Id" type="integer"/>
- <c:simple-property name="User"/>
- <c:simple-property name="Host"/>
- <c:simple-property name="db"/>
- <c:simple-property name="Command"/>
- <c:simple-property name="Time"/>
- <c:simple-property name="State"/>
- <c:simple-property name="Info"/>
- </c:map-property>
- </c:list-property>
- </results>
- </operation>
-
-
-
- <metric displayName="User Time" property="Process.aggregateCpu.user" measurementType="trendsup" units="milliseconds" displayType="summary"/>
- <metric displayName="Kernel Time" property="Process.aggregateCpu.sys" measurementType="trendsup" units="milliseconds" displayType="summary"/>
- <metric displayName="CPU Percentage" property="Process.aggregateCpu.percent" measurementType="dynamic" units="percentage" displayType="summary"/>
- <metric displayName="Physical Memory" property="Process.aggregateMemory.resident" measurementType="dynamic" units="bytes" displayType="summary"/>
- <metric displayName="Virtual Memory" property="Process.aggregateMemory.size" measurementType="dynamic" units="bytes" displayType="summary"/>
- <metric displayName="Open File Descriptors" property="Process.aggregateFileDescriptor.total" measurementType="dynamic" displayType="summary"/>
-
-
+ <metric displayName="Physical Memory" property="Process.aggregateMemory.resident" measurementType="dynamic" units="bytes" displayType="summary"
+ description="The aggregate amount of resident memory used by all mysql processes"/>
+ <metric displayName="Virtual Memory" property="Process.aggregateMemory.size" measurementType="dynamic" units="bytes" displayType="summary"
+ description="The aggregate amount of virtual memory used by all mysql processes"/>
+ <metric displayName="Page Faults" property="Process.aggregateMemory.pageFaults" measurementType="trendsup" displayType="summary"
+ description="The Number of memory page faults by all mysql processes"/>
+ <metric displayName="User Time" property="Process.aggregateCpu.user" measurementType="trendsup" units="milliseconds" displayType="summary"
+ description="The aggregate amount of CPU user time spent by all mysql processes"/>
+ <metric displayName="Kernel Time" property="Process.aggregateCpu.sys" measurementType="trendsup" units="milliseconds" displayType="summary"
+ description="The aggregate amount of CPU kernel time spent by all mysql processes"/>
+ <metric displayName="CPU Percentage" property="Process.aggregateCpu.percent" measurementType="dynamic" units="percentage" displayType="summary"
+ description="The percentage of CPU currently being used by all mysql processes"/>
+ <metric displayName="Total CPU Time" property="Process.aggregateCpu.total" measurementType="trendsup" units="milliseconds" displayType="summary"
+ description="The aggregate amount of CPU time spent by all mysql processes"/>
+ <metric displayName="Open File Descriptors" property="Process.aggregateFileDescriptor.total" measurementType="dynamic" displayType="summary"
+ description="The aggregate number of file descriptors open by all mysql processes"/>
<metric property="Aborted_clients" measurementType="trendsup" description="Connections that aborted because the client did not close the connection"/>
@@ -353,10 +337,10 @@
<c:simple-property name="databaseName" displayName="Database Name" readOnly="true" />
</plugin-configuration>
- <operation name="resetStatistics" displayName="Reset Statistics" description="Resets the statistics in this database"/>
<operation name="invokeSql" description="Execute arbitrary SQL">
<parameters>
- <c:simple-property name="type" default="query">
+ <c:simple-property name="sql"/>
+ <c:simple-property name="type" default="query">
<c:property-options>
<c:option value="query" name="query"/>
<c:option value="update" name="update"/>
@@ -370,39 +354,39 @@
</results>
</operation>
-
- <metric displayName="Backends" property="numbackends" displayType="summary"/>
- <metric displayName="Transactions Committed" property="xact_commit" measurementType="trendsup" displayType="summary"/>
- <metric displayName="Transactions Rolled Back" property="xact_rollback" measurementType="trendsup" displayType="summary"/>
- <metric displayName="Blocks Read" property="blks_read" measurementType="trendsup"/>
- <metric displayName="Blocks Hit" property="blks_hit" measurementType="trendsup"/>
- <metric displayName="Size" property="size" description="Size of the database" units="bytes" displayType="summary"/>
-
-
-
- <service name="Table" class="MySqlTableComponent" discovery="MySqlTableDiscoveryComponent"
- description="Database table" createDeletePolicy="both" creationDataType="configuration">
+ <service name="Table" class="MySqlTableComponent" discovery="MySqlTableDiscoveryComponent"
+ description="Database table">
<plugin-configuration>
<c:simple-property name="tableName" readOnly="true" />
</plugin-configuration>
-
-
-
+ <!-- Summary Traits -->
+ <metric property="Engine" displayType="summary" dataType="trait" description="Database Engine that created the Table" defaultOn="true"/>
+ <metric property="Version" displayType="summary" dataType="trait" description="Version of the Table" defaultOn="true"/>
+ <metric property="Row_format" displayType="summary" dataType="trait" description="Row Format" defaultOn="true"/>
+ <metric property="Collation" displayType="summary" dataType="trait" description="Collation Character Set" defaultOn="true"/>
+ <metric property="Comment" displayType="summary" dataType="trait" description="Table Creation Comment" defaultOn="true"/>
+ <metric property="Create_options" displayType="summary" dataType="trait" description="Table Creation Options" defaultOn="true"/>
+ <metric property="Create_time" displayType="summary" dataType="trait" description="Table Creation Time" defaultOn="true"/>
+
+ <!-- Dynamic Metrics -->
+ <metric property="Rows" displayType="summary" measurementType="dynamic" description="Number of Rows in the Table" defaultOn="true"/>
+ <metric property="Avg_row_length" displayType="summary" measurementType="dynamic" units="bytes" description="Average Row Length(bytes)" defaultOn="true"/>
+ <metric property="Data_length" displayType="summary" measurementType="dynamic" units="bytes" description="Table Data Size(bytes)" defaultOn="true"/>
+ <metric property="Max_data_length" displayType="summary" measurementType="dynamic" units="bytes" description="Max Table Data Size(bytes)" defaultOn="true"/>
+ <metric property="Index_length" displayType="summary" measurementType="dynamic" units="bytes" description="Table Index Size(bytes)" defaultOn="true"/>
+ <metric property="Data_free" displayType="summary" measurementType="dynamic" units="bytes" description="Table Free Space(bytes)" defaultOn="true"/>
</service>
-
- </service>
-
- <service name="User" discovery="MySqlUserDiscoveryComponent" class="MySqlUserComponent"
- createDeletePolicy="both" creationDataType="configuration"
- description="A User in the MySql System">
- <plugin-configuration>
- <c:simple-property name="userName" required="true"/>
- </plugin-configuration>
-
-
-
</service>
+ <service name="User" class="MySqlUserComponent" discovery="MySqlUserDiscoveryComponent"
+ description="A MySQL User">
+ <plugin-configuration>
+ <c:simple-property name="userName" readOnly="true" />
+ <c:simple-property name="host" readOnly="true" />
+ </plugin-configuration>
+ <metric property="TotalConnections" displayType="summary" description="Total number of connections to the server"/>
+ <metric property="ActiveConnections" displayType="summary" description="Active Connections to the server"/>
+ </service>
</server>
</plugin>
\ No newline at end of file
commit cec52a70ca813ed0138ab1b2f59efc364953b393
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Sat Oct 16 01:15:18 2010 +0200
Removing the code dealing with the legacy resource keys and implement a ResourceUpgradeFacet for virtual hosts so that we can finally move away from the insufficient legacy resource keys.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index a0f2120..9b5c975 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -345,79 +345,46 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
String[] addrs = resourceKey.substring(pipeIdx + 1).split(" ");
List<AugeasNode> nodes = tree.matchRelative(tree.getRootNode(), "<VirtualHost");
List<AugeasNode> virtualHosts = new ArrayList<AugeasNode>();
- boolean updated = false;
-
-//BZ 612189 - uncomment this algo once the resource upgrade is in place
-// for (AugeasNode node : nodes) {
-// updated = false;
-// List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
-// String tempServerName = null;
-//
-// if (!(serverNameNodes.isEmpty())) {
-// tempServerName = serverNameNodes.get(0).getValue();
-// }
-// if (tempServerName == null & serverName == null)
-// updated = true;
-// if (tempServerName != null & serverName != null)
-// if (tempServerName.equals(serverName)){
-// updated = true;
-// }
-//
-//
-// if (updated){
-// updated = false;
-// List<AugeasNode> params = node.getChildByLabel("param");
-// for (AugeasNode nd : params) {
-// updated = false;
-// for (String adr : addrs) {
-// if (adr.equals(nd.getValue()))
-// updated = true;
-// }
-// if (!updated)
-// break;
-// }
-//
-// if (updated)
-// virtualHosts.add(node);
-// }
-// }
-
- //BZ 612189 - remove this once resource upgrade is in place
- HttpdAddressUtility.Address resourceKeyAddress = HttpdAddressUtility.Address.parse(resourceKey);
- for(AugeasNode node : nodes) {
+ boolean matching = false;
+
+ for (AugeasNode node : nodes) {
+ matching = false;
List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
- List<AugeasNode> vhostAddressNodes = node.getChildByLabel("param");
+ String tempServerName = null;
+
+ if (!(serverNameNodes.isEmpty())) {
+ tempServerName = serverNameNodes.get(0).getValue();
+ }
+ if (tempServerName == null & serverName == null) {
+ matching = true;
+ }
- String vhostServerName = serverNameNodes.isEmpty() ? null : serverNameNodes.get(0).getValue();
- String vhostAddressDef = vhostAddressNodes.isEmpty() ? null : vhostAddressNodes.get(0).getValue();
+ if (tempServerName != null & serverName != null) {
+ if (tempServerName.equals(serverName)) {
+ matching = true;
+ }
+ }
- if (vhostAddressDef != null) {
- HttpdAddressUtility.Address vhostAddress = HttpdAddressUtility.Address.parse(vhostAddressDef);
- if (vhostServerName != null) {
- HttpdAddressUtility.Address vhostServerAddress = HttpdAddressUtility.Address.parse(vhostServerName);
- vhostAddress.host = vhostServerAddress.host;
+ if (matching) {
+ List<AugeasNode> params = node.getChildByLabel("param");
+ for (AugeasNode nd : params) {
+ matching = false;
+ for (String adr : addrs) {
+ if (adr.equals(nd.getValue())) {
+ matching = true;
+ }
+ }
+ if (!matching) {
+ break;
+ }
}
-
- if (resourceKeyAddress.equals(vhostAddress)) {
+
+ if (matching) {
virtualHosts.add(node);
}
}
}
-
- //BZ 612189 - remove this once we have resource upgrade
- //ok, one final attempt... the legacy resource key format for the MainServer is just a host:port as with the rest of the vhosts, let's try that
- try {
- String serverUrl = resourceContext.getParentResourceComponent().getServerUrl();
- URI serverUri = new URI(serverUrl);
- String expectedResourceKey = serverUri.getHost() + ":" + serverUri.getPort();
-
- if (expectedResourceKey.equals(resourceKey)) {
- return tree.getRootNode();
- }
- } catch (URISyntaxException e) {
- log.warn("Failed to parse the server URL when trying to match the vhost with the main server.", e);
- }
-
+
if (virtualHosts.size() == 0) {
throw new IllegalStateException("Could not find virtual host configuration in augeas for virtual host: "
+ resourceKey);
@@ -544,14 +511,6 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
vhostServerName, true);
if (vhostAddr != null) {
vhostAddresses.add(vhostAddr);
- } else {
- //this is not to choke on the old style resource keys for the main server. without this, we'd never be able
- //to match the main server with its snmp index below.
- HttpdAddressUtility.Address addr = HttpdAddressUtility.Address.parse(vhostAddressStrings[i]);
- vhostAddr = parent.getAddressUtility().getMainServerSampleAddress(tree, addr.host, addr.port);
- if (vhostAddr != null) {
- vhostAddresses.add(vhostAddr);
- }
}
}
}
@@ -618,7 +577,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
return snmpWwwServiceIndex;
}
- private static int matchRate(List<HttpdAddressUtility.Address> addresses, HttpdAddressUtility.Address addressToCheck) {
+ public static int matchRate(List<HttpdAddressUtility.Address> addresses, HttpdAddressUtility.Address addressToCheck) {
for(HttpdAddressUtility.Address a : addresses) {
if (HttpdAddressUtility.isAddressConforming(addressToCheck, a.host, a.port, true)) {
return 3;
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index 8251658..6f24ca7 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -21,23 +21,25 @@ package org.rhq.plugins.apache;
import java.io.File;
import java.net.InetAddress;
import java.net.URI;
-import java.net.URISyntaxException;
import java.net.UnknownHostException;
-import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.augeas.node.AugeasNode;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.ResourceUpgradeReport;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext;
+import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet;
import org.rhq.plugins.apache.parser.ApacheDirective;
import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
import org.rhq.plugins.apache.util.HttpdAddressUtility;
@@ -54,7 +56,7 @@ import org.rhq.plugins.www.snmp.SNMPValue;
* @author Ian Springer
* @author Lukas Krejci
*/
-public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDiscoveryComponent<ApacheServerComponent> {
+public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDiscoveryComponent<ApacheServerComponent>, ResourceUpgradeFacet<ApacheServerComponent> {
private static final String COULD_NOT_DETERMINE_THE_VIRTUAL_HOST_ADDRESS = "*** Could not determine the virtual host address ***";
@@ -69,37 +71,25 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
- //BZ 612189 - prepare for the legacy overrides. We need to revert to the old-style resource keys until
- //resource upgrade functionality is ready.
- SnmpWwwServiceIndexes snmpDiscoveries = getSnmpDiscoveries(context);
-
ApacheServerComponent serverComponent = context.getParentResourceComponent();
ApacheDirectiveTree tree = serverComponent.loadParser();
//first define the root server as one virtual host
- discoverMainServer(context, discoveredResources, snmpDiscoveries);
+ discoverMainServer(context, discoveredResources);
ResourceType resourceType = context.getResourceType();
File configPath = serverComponent.getServerRoot();
File logsDir = new File(configPath, LOGS_DIRECTORY_NAME);
- List<ApacheDirective> virtualHosts = tree.search("/<VirtualHost");
-
- for (ApacheDirective node : virtualHosts) {
- List<String> hosts = node.getValues();
- String firstAddress = hosts.get(0);
-
- List<ApacheDirective> serverNames = node.getChildByName("ServerName");
- String serverName = null;
- if (serverNames.size() > 0) {
- serverName = serverNames.get(0).getValuesAsString();
- }
+ for(VHostSpec vhost : VHostSpec.detect(tree)) {
+
+ String firstAddress = vhost.hosts.get(0);
- String resourceKey = createResourceKey(serverName, hosts);
+ String resourceKey = createResourceKey(vhost.serverName, vhost.hosts);
Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
- Address address = serverComponent.getAddressUtility().getVirtualHostSampleAddress(tree, firstAddress, serverName, false);
+ Address address = serverComponent.getAddressUtility().getVirtualHostSampleAddress(tree, firstAddress, vhost.serverName, false);
if (address != null) {
String scheme = address.scheme;
String hostToPing = address.host;
@@ -143,17 +133,11 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
}
String resourceName;
- if (serverName != null) {
+ if (address != null) {
resourceName = address.host + ":" + address.port;
} else {
resourceName = resourceKey;
}
-
- //BZ 612189 - remove this once we have resource upgrade
- if (snmpDiscoveries != null) {
- String legacyResourceKey = getLegacyResourceKey(context, resourceKey, snmpDiscoveries);
- resourceKey = legacyResourceKey != null ? legacyResourceKey : resourceKey;
- }
discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
pluginConfiguration, null));
@@ -162,9 +146,56 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
return discoveredResources;
}
+ public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ApacheServerComponent> inventoriedResource) {
+ String resourceKey = inventoriedResource.getResourceKey();
+
+ if (ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY.equals(resourceKey) ||
+ resourceKey.contains("|")) {
+ //a new style resource key. we're done.
+ return null;
+ }
+
+ String newResourceKey = null;
+
+ ApacheServerComponent serverComponent = inventoriedResource.getParentResourceComponent();
+
+ ApacheDirectiveTree tree = serverComponent.loadParser();
+
+ List<VHostSpec> vhosts = VHostSpec.detect(tree);
+ SnmpWwwServiceIndexes snmpIndexes = getSnmpDiscoveries(serverComponent, inventoriedResource.getParentResourceContext().getResourceKey());
+
+ for (VHostSpec vhost : vhosts) {
+ String legacyResourceKey = createLegacyResourceKey(serverComponent, vhost.serverName, vhost.hosts, snmpIndexes);
+ if (resourceKey.equals(legacyResourceKey)) {
+ newResourceKey = createResourceKey(vhost.serverName, vhost.hosts);
+ break;
+ }
+ }
+
+ if (newResourceKey == null) {
+ //the last thing to check is whether the inventoried vhost isn't in fact the main server
+ String serverUrl = serverComponent.getServerUrl();
+ HttpdAddressUtility.Address serverAddress = HttpdAddressUtility.Address.parse(serverUrl);
+ HttpdAddressUtility.Address vhostAddress = HttpdAddressUtility.Address.parse(resourceKey);
+
+ if (ApacheVirtualHostServiceComponent.matchRate(Collections.singletonList(serverAddress), vhostAddress) > 0) {
+ newResourceKey = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ }
+ }
+
+ if (newResourceKey != null) {
+ ResourceUpgradeReport report = new ResourceUpgradeReport();
+ report.setNewResourceKey(newResourceKey);
+
+ return report;
+ } else {
+ return null;
+ }
+ }
+
private void discoverMainServer(ResourceDiscoveryContext<ApacheServerComponent> context,
- Set<DiscoveredResourceDetails> discoveredResources, SnmpWwwServiceIndexes snmpDiscoveries) throws Exception {
+ Set<DiscoveredResourceDetails> discoveredResources) throws Exception {
ResourceType resourceType = context.getResourceType();
Configuration mainServerPluginConfig = context.getDefaultPluginConfiguration();
@@ -175,8 +206,6 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
String mainServerUrl = context.getParentResourceContext().getPluginConfiguration().getSimple(
ApacheServerComponent.PLUGIN_CONFIG_PROP_URL).getStringValue();
- String key = null;
-
if (mainServerUrl != null && !"null".equals(mainServerUrl)) {
PropertySimple mainServerUrlProp = new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP,
mainServerUrl);
@@ -195,21 +224,9 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
PropertySimple rtLogProp = new PropertySimple(
ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
mainServerPluginConfig.put(rtLogProp);
-
- //BZ 612189 - remove this once we have resource upgrade
- key = host + ":" + port;
}
- //BZ 612189 - this can simply the MAIN_SERVER_RESOURCE_KEY only once we have resource upgrade
- if (key == null) {
- key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
- }
-
- //BZ 612189 - remove this once we have resource upgrade
- if (snmpDiscoveries != null) {
- String legacyKey = getLegacyResourceKey(context, key, snmpDiscoveries);
- key = legacyKey != null ? legacyKey : key;
- }
+ String key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
DiscoveredResourceDetails mainServer = new DiscoveredResourceDetails(resourceType,
key, "Main", null, null,
@@ -217,45 +234,43 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
discoveredResources.add(mainServer);
}
- /**
- * @deprecated remove this once we have resource upgrade
- * @param discoveryContext
- * @param newStyleResourceKey
- * @param snmpDiscoveries
- * @return
- */
- @Deprecated
- private String getLegacyResourceKey(ResourceDiscoveryContext<ApacheServerComponent> discoveryContext, String newStyleResourceKey, SnmpWwwServiceIndexes snmpDiscoveries) {
- int snmpWwwServiceIndex = ApacheVirtualHostServiceComponent.getMatchingWwwServiceIndex(discoveryContext.getParentResourceComponent(), newStyleResourceKey, snmpDiscoveries.names, snmpDiscoveries.ports);
-
- if (snmpWwwServiceIndex < 1) {
- return null;
- } else {
- String host = snmpDiscoveries.names.get(snmpWwwServiceIndex - 1).toString();
- String fullPort = snmpDiscoveries.ports.get(snmpWwwServiceIndex - 1).toString();
-
- // The port value will be in the form "1.3.6.1.2.1.6.XXXXX",
- // where "1.3.6.1.2.1.6" represents the TCP protocol ID,
- // and XXXXX is the actual port number
- String port = fullPort.substring(fullPort.lastIndexOf(".") + 1);
- return host + ":" + port;
+ public static String createResourceKey(String serverName, List<String> hosts) {
+ StringBuilder keyBuilder = new StringBuilder();
+ if (serverName != null) {
+ keyBuilder.append(serverName);
+ }
+ keyBuilder.append("|"); //always do this so that we have a clear distinction between old and new style resource keys
+ keyBuilder.append(hosts.get(0));
+
+ for (int i = 1; i < hosts.size(); ++i){
+ keyBuilder.append(" ").append(hosts.get(i));
}
+
+ return keyBuilder.toString();
}
- public static String createResourceKey(String serverName, List<String> hosts) {
-//BZ 612189 - swap the impls once resource upgrade is in place
-// StringBuilder keyBuilder = new StringBuilder();
-// if (serverName != null) {
-// keyBuilder.append(serverName).append("|");
-// }
-// keyBuilder.append(hosts.get(0));
-//
-//
-// for (int i = 1; i < hosts.size(); ++i){
-// keyBuilder.append(" ").append(hosts.get(i));
-// }
-//
-// return keyBuilder.toString();
+ private static String createLegacyResourceKey(ApacheServerComponent serverComponent, String serverName, List<String> hosts, SnmpWwwServiceIndexes snmpIndexes) {
+ if (snmpIndexes != null) {
+ String newStyleResourceKey = createResourceKey(serverName, hosts);
+ String legacyResourceKey = null;
+
+ int snmpWwwServiceIndex = ApacheVirtualHostServiceComponent.getMatchingWwwServiceIndex(serverComponent, newStyleResourceKey, snmpIndexes.names, snmpIndexes.ports);
+
+ if (snmpWwwServiceIndex > 0) {
+ String host = snmpIndexes.names.get(snmpWwwServiceIndex - 1).toString();
+ String fullPort = snmpIndexes.ports.get(snmpWwwServiceIndex - 1).toString();
+
+ // The port value will be in the form "1.3.6.1.2.1.6.XXXXX",
+ // where "1.3.6.1.2.1.6" represents the TCP protocol ID,
+ // and XXXXX is the actual port number
+ String port = fullPort.substring(fullPort.lastIndexOf(".") + 1);
+ legacyResourceKey = host + ":" + port;
+ }
+
+ if (legacyResourceKey != null) {
+ return legacyResourceKey;
+ }
+ }
//try to derive the same resource key as the SNMP would have... this is to prevent the duplication of
//vhost resources after the SNMP was configured - how I wish resource upgrade made it to 3.0 to prevent this
@@ -279,18 +294,15 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
}
/**
- * @deprecated remove this once we have resource upgrade
* @param discoveryContext
* @return
*/
- @Deprecated
- private SnmpWwwServiceIndexes getSnmpDiscoveries(ResourceDiscoveryContext<ApacheServerComponent> discoveryContext) {
+ private static SnmpWwwServiceIndexes getSnmpDiscoveries(ApacheServerComponent serverComponent, String serverResourceKey) {
try {
- SNMPSession snmpSession = discoveryContext.getParentResourceComponent().getSNMPSession();
+ SNMPSession snmpSession = serverComponent.getSNMPSession();
List<SNMPValue> nameValues;
List<SNMPValue> portValues;
- SNMPValue descValue;
-
+
try {
nameValues = snmpSession.getColumn(SNMPConstants.COLUMN_VHOST_NAME);
} catch (SNMPException e) {
@@ -305,35 +317,46 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
"Error getting SNMP column: " + SNMPConstants.COLUMN_VHOST_PORT + ": " + e.getMessage(), e);
}
- try {
- // Just get the first one - they are all the same.
- descValue = snmpSession.getNextValue(SNMPConstants.COLUMN_VHOST_DESC);
- } catch (SNMPException e) {
- throw new Exception("Error getting SNMP value: " + SNMPConstants.COLUMN_VHOST_DESC + ": " + e.getMessage(),
- e);
- }
-
SnmpWwwServiceIndexes ret = new SnmpWwwServiceIndexes();
ret.names = nameValues;
ret.ports = portValues;
- ret.desc = descValue;
return ret;
} catch (Exception e) {
- log.warn("Error while trying to contact SNMP of the apache server " + discoveryContext.getParentResourceContext().getResourceKey(), e);
+ log.warn("Error while trying to contact SNMP of the apache server " + serverResourceKey, e);
return null;
}
}
- /**
- * @deprecated remove this once we have resource upgrade
- *
- * @author Lukas Krejci
- */
- @Deprecated
private static class SnmpWwwServiceIndexes {
public List<SNMPValue> names;
public List<SNMPValue> ports;
- public SNMPValue desc;
+ }
+
+ private static class VHostSpec {
+ public String serverName;
+ public List<String> hosts;
+
+ public static List<VHostSpec> detect(ApacheDirectiveTree config) {
+ List<ApacheDirective> virtualHosts = config.search("/<VirtualHost");
+
+ List<VHostSpec> ret = new ArrayList<VHostSpec>(virtualHosts.size());
+
+ for(ApacheDirective dir : virtualHosts) {
+ ret.add(new VHostSpec(dir));
+ }
+
+ return ret;
+ }
+
+ public VHostSpec(ApacheDirective vhostDirective) {
+ hosts = vhostDirective.getValues();
+
+ List<ApacheDirective> serverNames = vhostDirective.getChildByName("ServerName");
+ serverName = null;
+ if (serverNames.size() > 0) {
+ serverName = serverNames.get(0).getValuesAsString();
+ }
+ }
}
}
\ No newline at end of file
commit dd1e15c2f1b564b0f547508fbc472a0f97ec8cc6
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Sat Oct 16 01:13:17 2010 +0200
Adding the ResourceContext of the parent resource to the ResourceUpgradeContext so that upgrade() methods of the discovery components can use that information.
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java
index 35f5029..c56d280 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java
@@ -44,17 +44,18 @@ import org.rhq.core.system.SystemInfo;
*
* @author Lukas Krejci
*/
-@SuppressWarnings("unchecked")
+@SuppressWarnings("rawtypes")
public class ResourceUpgradeContext<T extends ResourceComponent> extends ResourceContext<T> {
private final Configuration resourceConfiguration;
private final String name;
private final String description;
+ private ResourceContext<?> parentResourceContext;
/**
* @see ResourceContext#ResourceContext(Resource, ResourceComponent, ResourceDiscoveryComponent, SystemInfo, File, File, String, EventContext, OperationContext, ContentContext, Executor, PluginContainerDeployment)
*/
- public ResourceUpgradeContext(Resource resource, T parentResourceComponent,
+ public ResourceUpgradeContext(Resource resource, ResourceContext<?> parentResourceContext, T parentResourceComponent,
ResourceDiscoveryComponent resourceDiscoveryComponent, SystemInfo systemInfo, File temporaryDirectory,
File dataDirectory, String pluginContainerName, EventContext eventContext, OperationContext operationContext,
ContentContext contentContext, Executor availCollectorThreadPool,
@@ -64,15 +65,14 @@ public class ResourceUpgradeContext<T extends ResourceComponent> extends Resourc
pluginContainerName, eventContext, operationContext, contentContext, availCollectorThreadPool,
pluginContainerDeployment);
+ this.parentResourceContext = parentResourceContext;
this.resourceConfiguration = resource.getResourceConfiguration();
this.name = resource.getName();
this.description = resource.getDescription();
}
- public ResourceUpgradeContext(Resource resource, ResourceDiscoveryComponent discoveryComponent, ResourceContext<T> context, Executor availCollectorThreadPool) {
- this(resource, context.getParentResourceComponent(), discoveryComponent, context.getSystemInformation(), context.getTemporaryDirectory(),
- context.getDataDirectory(), context.getPluginContainerName(), context.getEventContext(), context.getOperationContext(),
- context.getContentContext(), availCollectorThreadPool, context.getPluginContainerDeployment());
+ public ResourceContext<?> getParentResourceContext() {
+ return parentResourceContext;
}
public Configuration getResourceConfiguration() {
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index 0259c69..2e15f8e 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -1568,10 +1568,11 @@ public class InventoryManager extends AgentService implements ContainerService,
}
public <T extends ResourceComponent> ResourceUpgradeContext<T> createResourceUpgradeContext(Resource resource,
- T parentComponent, ResourceDiscoveryComponent<T> discoveryComponent) {
+ ResourceContext<?> parentResourceContext, T parentComponent, ResourceDiscoveryComponent<T> discoveryComponent) {
File pluginDataDir = new File(this.configuration.getDataDirectory(), resource.getResourceType().getPlugin());
return new ResourceUpgradeContext<T>(resource, // the resource itself
+ parentResourceContext, //the context of its parent resource
parentComponent, // its parent component
discoveryComponent, // the discovery component (this is actually the proxy to it)
SystemInfoFactory.createSystemInfo(), // for native access
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
index 06d2cd0..b3b8716 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
@@ -36,6 +36,7 @@ import org.rhq.core.pc.PluginContainer;
import org.rhq.core.pc.inventory.InventoryManager;
import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext;
import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet;
@@ -158,12 +159,14 @@ public class ResourceUpgradeDelegate {
ResourceComponent<T> parentResourceComponent = resourceContainer.getResourceContext()
.getParentResourceComponent();
-
+
Resource parentResource = resourceContainer.getResource().getParentResource();
ResourceContainer parentResourceContainer = (parentResource != null) ? inventoryManager
.getResourceContainer(resourceContainer.getResource().getParentResource()) : null;
+ ResourceContext<?> parentResourceContext = parentResourceContainer == null ? null : parentResourceContainer.getResourceContext();
+
Resource resource = resourceContainer.getResource();
ResourceDiscoveryComponent<ResourceComponent<T>> discoveryComponent = PluginContainer.getInstance()
@@ -175,7 +178,7 @@ public class ResourceUpgradeDelegate {
}
ResourceUpgradeContext<ResourceComponent<T>> upgradeContext = inventoryManager.createResourceUpgradeContext(
- resource, parentResourceComponent, discoveryComponent);
+ resource, parentResourceContext, parentResourceComponent, discoveryComponent);
ResourceUpgradeRequest request = new ResourceUpgradeRequest(resource.getId());
commit 9bf39010bcf60ad0cd52876be3f1255329cf656e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:37:36 2010 +0100
BZ 535786 - Adding the SNMP host and port detection during the apache server discovery.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index a1b08a7..a5e19e5 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -18,12 +18,19 @@
*/
package org.rhq.plugins.apache;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.URI;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -162,6 +169,16 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
serverConfigFile.getParent() + File.separator + "*"));
}
+ List<InetSocketAddress> snmpAddresses = findSNMPAddresses(serverConfig, new File(serverRoot));
+ if (snmpAddresses != null && snmpAddresses.size() > 0) {
+ InetSocketAddress addr = snmpAddresses.get(0);
+ int port = addr.getPort();
+ InetAddress host = addr.getAddress() == null ? InetAddress.getLocalHost() : addr.getAddress();
+
+ pluginConfig.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST, host.getHostAddress()));
+ pluginConfig.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT, port));
+ }
+
discoveredResources.add(createResourceDetails(discoveryContext, pluginConfig, process.getProcessInfo(),
binaryInfo));
}
@@ -445,4 +462,106 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
return serverRoot + "||" + httpdConf;
}
+
+ private static List<InetSocketAddress> findSNMPAddresses(ApacheDirectiveTree tree, File serverRoot) {
+ List<InetSocketAddress> ret = new ArrayList<InetSocketAddress>();
+
+ List<ApacheDirective> confs = tree.search("/SNMPConf");
+
+ if (confs.size() == 0) {
+ log.info("SNMPConf directive not found. Skipping SNMP configuration.");
+ return ret;
+ }
+
+ String confDirName = confs.get(0).getValuesAsString();
+ if (confDirName == null || confDirName.isEmpty()) {
+ log.warn("The SNMPConf directive seems to not have a value. Skipping SNMP configuration.");
+ return ret;
+ }
+
+
+ File confDir = new File(confDirName);
+
+ if (!confDir.isAbsolute()) {
+ confDir = new File(serverRoot, confDirName);
+ }
+
+ File snmpdConf = new File(confDir, "snmpd.conf");
+
+ if (!snmpdConf.exists()) {
+ log.warn("Could not find a snmpd.conf file under the configured directory '" + confDirName
+ + "'. Skipping SNMP configuration.");
+ return ret;
+ }
+
+ try {
+ String agentAddressLine = findSNMPAgentAddressConfigLine(snmpdConf);
+
+ if (agentAddressLine == null) {
+ log.warn("Could not find the 'agentaddress' property in the snmpd.conf. Skipping SNMP configuration.");
+ return ret;
+ }
+
+ int specStartIdx = agentAddressLine.indexOf("agentaddress") + "agentaddress".length() + 1;
+
+ while (Character.isWhitespace(agentAddressLine.charAt(specStartIdx)))
+ specStartIdx++;
+
+ String spec = agentAddressLine.substring(specStartIdx);
+
+ String[] addrs = spec.split(",");
+
+ try {
+ for (String addr : addrs) {
+ if (addr.startsWith("udp") || addr.startsWith("tcp")) {
+ //this contains the transport spec - either "udp:" or "tcp:"
+ addr = addr.substring(4);
+ }
+
+ int atIdx = addr.indexOf('@');
+ String port = addr;
+ String host = null;
+ if (atIdx > 0) {
+ host = addr.substring(atIdx + 1);
+ port = addr.substring(0, atIdx);
+ }
+
+ InetSocketAddress address = null;
+ if (host != null) {
+ address = new InetSocketAddress(host, Integer.parseInt(port));
+ } else {
+ address = new InetSocketAddress(Integer.parseInt(port));
+ }
+
+ ret.add(address);
+ }
+ } catch (Exception e) {
+ log.warn("Failed to parse the SNMP 'agentaddress' configuration property: "
+ + agentAddressLine, e);
+ }
+ } catch (IOException e) {
+ log.warn("Failed to read in the configured snmpd.conf file: " + snmpdConf.getAbsolutePath(), e);
+ }
+
+ return ret;
+ }
+
+ private static String findSNMPAgentAddressConfigLine(File snmpdConf) throws IOException {
+ BufferedReader rdr = new BufferedReader(new FileReader(snmpdConf));
+
+ try {
+ Pattern search = Pattern.compile("^\\s*agentaddress.*");
+ String line;
+
+ while ((line = rdr.readLine()) != null) {
+ if (search.matcher(line).matches()) {
+ return line;
+ }
+ }
+
+ return null;
+ } finally {
+ rdr.close();
+ }
+ }
}
commit b7e3bccde3c4c36be6e9aab7299ff2d060e0475f
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:41:07 2010 +0100
BZ 642622 - Adding the ability to extract the scheme and port from the ServerName so that proper ping URLs can be discovered.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index bea7c23..a1b08a7 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -262,7 +262,7 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
*/
private static String getUrl(ApacheDirectiveTree serverConfig, String version) throws Exception {
Address addr = HttpdAddressUtility.get(version).getMainServerSampleAddress(serverConfig, null, 0);
- return addr == null ? null : "http://" + addr.host + ":" + addr.port + "/";
+ return addr == null ? null : addr.toString();
}
@Nullable
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index b2f76bc..8251658 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -124,7 +124,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
String url;
if (hostToPing != null && portToPing != Address.PORT_WILDCARD_VALUE && portToPing != Address.NO_PORT_SPECIFIED_VALUE) {
- url = "http://" + hostToPing + ":" + portToPing + "/";
+ url = scheme + "://" + hostToPing + ":" + portToPing + "/";
} else {
url = COULD_NOT_DETERMINE_THE_VIRTUAL_HOST_ADDRESS;
}
@@ -133,16 +133,18 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
pluginConfiguration.put(urlProp);
}
-
- File rtLogFile = new File(logsDir, address.host + address.port + RT_LOG_FILE_NAME_SUFFIX);
-
- PropertySimple rtLogProp = new PropertySimple(
- ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
- pluginConfiguration.put(rtLogProp);
-
+
+ if (address != null) {
+ File rtLogFile = new File(logsDir, address.host + address.port + RT_LOG_FILE_NAME_SUFFIX);
+
+ PropertySimple rtLogProp = new PropertySimple(
+ ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
+ pluginConfiguration.put(rtLogProp);
+ }
+
String resourceName;
if (serverName != null) {
- resourceName = address.toString();
+ resourceName = address.host + ":" + address.port;
} else {
resourceName = resourceKey;
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
index c5589fd..b5cdedf 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
@@ -82,7 +82,7 @@ public enum HttpdAddressUtility {
address = getLocalhost(address.port);
}
- updateWithServerName(address, ag);
+ updateWithServerName(address, ag, false);
return address;
}
@@ -90,7 +90,7 @@ public enum HttpdAddressUtility {
return null;
} catch (Exception e) {
- log.info("Failed to obtain main server address. Is augeas installed and correct lens in use?");
+ log.warn("Failed to obtain main server address.", e);
return null;
}
@@ -106,7 +106,7 @@ public enum HttpdAddressUtility {
addr = getLocalhost(addr.port);
}
- updateWithServerName(addr, ag);
+ updateWithServerName(addr, ag, false);
return addr;
}
@@ -115,7 +115,7 @@ public enum HttpdAddressUtility {
//there has to be at least one Listen directive
throw new IllegalStateException("Could find a listen address on port " + limitToPort);
} catch (Exception e) {
- log.info("Failed to obtain main server address. Is augeas installed and correct lens in use?");
+ log.warn("Failed to obtain main server address.", e);
return null;
}
@@ -131,6 +131,7 @@ public enum HttpdAddressUtility {
public static class Address {
public String host;
public int port = -1;
+ public String scheme = "http";
public static final String WILDCARD = "*";
public static final String DEFAULT_HOST = "_default_";
@@ -142,6 +143,10 @@ public enum HttpdAddressUtility {
this.port = port;
}
+ public Address(String scheme, String host, int port) {
+ this(host, port);
+ this.scheme = scheme;
+ }
/**
* A simple parser of the provided address into host and port
* sections.
@@ -150,6 +155,13 @@ public enum HttpdAddressUtility {
* @return an instance of Address with host and port set accordingly
*/
public static Address parse(String address) {
+ String scheme = "http";
+ int schemeSpecIdx = address.indexOf("://");
+ if (schemeSpecIdx >= 0) {
+ scheme = address.substring(0, schemeSpecIdx);
+ address = address.substring(schemeSpecIdx + "://".length());
+ }
+
int lastColonIdx = address.lastIndexOf(':');
if (lastColonIdx == NO_PORT_SPECIFIED_VALUE) {
return new Address(address, -1);
@@ -166,10 +178,10 @@ public enum HttpdAddressUtility {
port = Integer.parseInt(portSpec);
}
- return new Address(host, port);
+ return new Address(scheme, host, port);
} else {
//this is an IP6 address without a port spec
- return new Address(address, NO_PORT_SPECIFIED_VALUE);
+ return new Address(scheme, address, NO_PORT_SPECIFIED_VALUE);
}
}
}
@@ -214,11 +226,11 @@ public enum HttpdAddressUtility {
@Override
public String toString() {
- if (port == NO_PORT_SPECIFIED_VALUE) return host;
+ if (port == NO_PORT_SPECIFIED_VALUE) return scheme + "://" + host;
else {
String portSpec = port == PORT_WILDCARD_VALUE ? WILDCARD : String.valueOf(port);
- return host + ":" + portSpec;
+ return scheme + "://" + host + ":" + portSpec;
}
}
}
@@ -245,30 +257,29 @@ public enum HttpdAddressUtility {
* @return the address on which the virtual host can be accessed or null on error
*/
public Address getVirtualHostSampleAddress(ApacheDirectiveTree ag, String virtualHost, String serverName, boolean snmpModuleCompatibleMode) {
- Address addr = Address.parse(virtualHost);
- if (addr.isHostDefault() || addr.isHostWildcard()) {
- Address serverAddr = null;
- if (snmpModuleCompatibleMode) {
- serverAddr = getLocalhost(addr.port);
- } else {
- serverAddr = getMainServerSampleAddress(ag, null, addr.port);
+ try {
+ Address addr = Address.parse(virtualHost);
+ if (addr.isHostDefault() || addr.isHostWildcard()) {
+ Address serverAddr = null;
+ if (snmpModuleCompatibleMode) {
+ serverAddr = getLocalhost(addr.port);
+ } else {
+ serverAddr = getMainServerSampleAddress(ag, null, addr.port);
+ }
+ if (serverAddr == null)
+ return null;
+ addr.host = serverAddr.host;
}
- if (serverAddr == null)
- return null;
- addr.host = serverAddr.host;
- }
- if (serverName != null) {
- int colonIdx = serverName.indexOf(':');
- if (colonIdx >= 0) {
- addr.host = serverName.substring(0, colonIdx);
- addr.port = Integer.parseInt(serverName.substring(colonIdx + 1));
- } else {
- addr.host = serverName;
+ if (serverName != null) {
+ updateWithServerName(addr, serverName, true);
}
- }
- return addr;
+ return addr;
+ } catch (Exception e) {
+ log.warn("Failed to obtain virtual host address.", e);
+ return null;
+ }
}
private static Address parseListen(String listenValue) {
@@ -335,12 +346,12 @@ public enum HttpdAddressUtility {
try {
return new Address(InetAddress.getLocalHost().getHostAddress(), port);
} catch (UnknownHostException e) {
- //well, this is bad, we can get address of the localhost. let's use the force...
+ //well, this is bad, we can't get address of the localhost. let's use the force...
return new Address("127.0.0.1", port);
}
}
- private static void updateWithServerName(Address address, ApacheDirectiveTree config) throws UnknownHostException {
+ private static void updateWithServerName(Address address, ApacheDirectiveTree config, boolean updatePort) throws UnknownHostException {
//check if there is a ServerName directive
List<ApacheDirective> serverNameNodes = config.search("/ServerName");
@@ -349,11 +360,20 @@ public enum HttpdAddressUtility {
//be the case if the server listens on more than one interfaces.
if (serverNameNodes.size() > 0) {
String serverName = serverNameNodes.get(0).getValuesAsString();
- InetAddress addrFromServerName = InetAddress.getByName(serverName);
- InetAddress addrFromAddress = InetAddress.getByName(address.host);
-
- if (addrFromAddress.equals(addrFromServerName)) {
- address.host = serverName;
+ updateWithServerName(address, serverName, updatePort);
+ }
+ }
+
+ private static void updateWithServerName(Address address, String serverName, boolean updatePort) throws UnknownHostException {
+ Address serverAddr = Address.parse(serverName);
+ InetAddress addrFromServerName = InetAddress.getByName(serverAddr.host);
+ InetAddress addrFromAddress = InetAddress.getByName(address.host);
+
+ if (addrFromAddress.equals(addrFromServerName)) {
+ address.scheme = serverAddr.scheme;
+ address.host = serverAddr.host;
+ if (updatePort) {
+ address.port = serverAddr.port;
}
}
}
commit eb45a242496d529a1ac3ee63807d8ea67237708e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:43:42 2010 +0200
BZ 642610 - directives found in included files aren't duplicated anymore
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
index 2e0f2a2..6cb168e 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
@@ -121,18 +121,6 @@ public class ApacheAugeasNode extends AugeasNodeLazy implements AugeasNode {
childNodes.add(node);
}
- public List<AugeasNode> getChildByLabel(String labelName) {
- List<AugeasNode> nodes = super.getChildByLabel(labelName);
-
- if (includedNodes != null) {
- for (AugeasNode node : includedNodes) {
- if (node.getLabel().equals(labelName))
- nodes.add(node);
- }
- }
- return nodes;
- }
-
public void setPath(String path) throws AugeasTreeException {
this.path = path;
commit a3455824e924722ee018b6fca916da31a2c5e859
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:42:17 2010 +0200
BZ 642591 - make sure we always have the same resource keys as in old plugin version.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
index c1f6323..4c61682 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
@@ -590,6 +590,13 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
/**
+ * @return The url the server is pinged for availability or null if the url is not set.
+ */
+ public @Nullable String getServerUrl() {
+ return resourceContext.getPluginConfiguration().getSimpleValue(PLUGIN_CONFIG_PROP_URL, null);
+ }
+
+ /**
* Returns the httpd.conf file
* @return A File object that represents the httpd.conf file or null in case of error
*/
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index d97d9fc..a0f2120 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -21,6 +21,8 @@ package org.rhq.plugins.apache;
import java.io.File;
import java.net.InetAddress;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -345,40 +347,77 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
List<AugeasNode> virtualHosts = new ArrayList<AugeasNode>();
boolean updated = false;
- for (AugeasNode node : nodes) {
- updated = false;
+//BZ 612189 - uncomment this algo once the resource upgrade is in place
+// for (AugeasNode node : nodes) {
+// updated = false;
+// List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
+// String tempServerName = null;
+//
+// if (!(serverNameNodes.isEmpty())) {
+// tempServerName = serverNameNodes.get(0).getValue();
+// }
+// if (tempServerName == null & serverName == null)
+// updated = true;
+// if (tempServerName != null & serverName != null)
+// if (tempServerName.equals(serverName)){
+// updated = true;
+// }
+//
+//
+// if (updated){
+// updated = false;
+// List<AugeasNode> params = node.getChildByLabel("param");
+// for (AugeasNode nd : params) {
+// updated = false;
+// for (String adr : addrs) {
+// if (adr.equals(nd.getValue()))
+// updated = true;
+// }
+// if (!updated)
+// break;
+// }
+//
+// if (updated)
+// virtualHosts.add(node);
+// }
+// }
+
+ //BZ 612189 - remove this once resource upgrade is in place
+ HttpdAddressUtility.Address resourceKeyAddress = HttpdAddressUtility.Address.parse(resourceKey);
+ for(AugeasNode node : nodes) {
List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
- String tempServerName = null;
-
- if (!(serverNameNodes.isEmpty())) {
- tempServerName = serverNameNodes.get(0).getValue();
- }
- if (tempServerName == null & serverName == null)
- updated = true;
- if (tempServerName != null & serverName != null)
- if (tempServerName.equals(serverName)){
- updated = true;
- }
+ List<AugeasNode> vhostAddressNodes = node.getChildByLabel("param");
+
+ String vhostServerName = serverNameNodes.isEmpty() ? null : serverNameNodes.get(0).getValue();
+ String vhostAddressDef = vhostAddressNodes.isEmpty() ? null : vhostAddressNodes.get(0).getValue();
+
+ if (vhostAddressDef != null) {
+ HttpdAddressUtility.Address vhostAddress = HttpdAddressUtility.Address.parse(vhostAddressDef);
+ if (vhostServerName != null) {
+ HttpdAddressUtility.Address vhostServerAddress = HttpdAddressUtility.Address.parse(vhostServerName);
+ vhostAddress.host = vhostServerAddress.host;
+ }
-
- if (updated){
- updated = false;
- List<AugeasNode> params = node.getChildByLabel("param");
- for (AugeasNode nd : params) {
- updated = false;
- for (String adr : addrs) {
- if (adr.equals(nd.getValue()))
- updated = true;
- }
- if (!updated)
- break;
- }
-
- if (updated)
- virtualHosts.add(node);
+ if (resourceKeyAddress.equals(vhostAddress)) {
+ virtualHosts.add(node);
}
- }
-
+ }
+ }
+
+ //BZ 612189 - remove this once we have resource upgrade
+ //ok, one final attempt... the legacy resource key format for the MainServer is just a host:port as with the rest of the vhosts, let's try that
+ try {
+ String serverUrl = resourceContext.getParentResourceComponent().getServerUrl();
+ URI serverUri = new URI(serverUrl);
+ String expectedResourceKey = serverUri.getHost() + ":" + serverUri.getPort();
+
+ if (expectedResourceKey.equals(resourceKey)) {
+ return tree.getRootNode();
+ }
+ } catch (URISyntaxException e) {
+ log.warn("Failed to parse the server URL when trying to match the vhost with the main server.", e);
+ }
+
if (virtualHosts.size() == 0) {
throw new IllegalStateException("Could not find virtual host configuration in augeas for virtual host: "
+ resourceKey);
@@ -505,6 +544,14 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
vhostServerName, true);
if (vhostAddr != null) {
vhostAddresses.add(vhostAddr);
+ } else {
+ //this is not to choke on the old style resource keys for the main server. without this, we'd never be able
+ //to match the main server with its snmp index below.
+ HttpdAddressUtility.Address addr = HttpdAddressUtility.Address.parse(vhostAddressStrings[i]);
+ vhostAddr = parent.getAddressUtility().getMainServerSampleAddress(tree, addr.host, addr.port);
+ if (vhostAddr != null) {
+ vhostAddresses.add(vhostAddr);
+ }
}
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index 4a32e27..b2f76bc 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -19,7 +19,10 @@
package org.rhq.plugins.apache;
import java.io.File;
+import java.net.InetAddress;
import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -37,6 +40,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.apache.parser.ApacheDirective;
import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
+import org.rhq.plugins.apache.util.HttpdAddressUtility;
import org.rhq.plugins.apache.util.HttpdAddressUtility.Address;
import org.rhq.plugins.www.snmp.SNMPException;
import org.rhq.plugins.www.snmp.SNMPSession;
@@ -91,23 +95,13 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
serverName = serverNames.get(0).getValuesAsString();
}
- StringBuilder keyBuilder = new StringBuilder();
- if (serverName != null) {
- keyBuilder.append(serverName).append("|");
- }
- keyBuilder.append(firstAddress);
-
-
- for (int i=1;i<hosts.size();i++){
- keyBuilder.append(" ").append(hosts.get(i));
- }
-
- String resourceKey = keyBuilder.toString();
+ String resourceKey = createResourceKey(serverName, hosts);
Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
Address address = serverComponent.getAddressUtility().getVirtualHostSampleAddress(tree, firstAddress, serverName, false);
if (address != null) {
+ String scheme = address.scheme;
String hostToPing = address.host;
int portToPing = address.port;
if (address.isPortWildcard()) {
@@ -178,6 +172,9 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
String mainServerUrl = context.getParentResourceContext().getPluginConfiguration().getSimple(
ApacheServerComponent.PLUGIN_CONFIG_PROP_URL).getStringValue();
+
+ String key = null;
+
if (mainServerUrl != null && !"null".equals(mainServerUrl)) {
PropertySimple mainServerUrlProp = new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP,
mainServerUrl);
@@ -196,9 +193,15 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
PropertySimple rtLogProp = new PropertySimple(
ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
mainServerPluginConfig.put(rtLogProp);
+
+ //BZ 612189 - remove this once we have resource upgrade
+ key = host + ":" + port;
}
- String key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ //BZ 612189 - this can simply the MAIN_SERVER_RESOURCE_KEY only once we have resource upgrade
+ if (key == null) {
+ key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ }
//BZ 612189 - remove this once we have resource upgrade
if (snmpDiscoveries != null) {
@@ -237,6 +240,42 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
}
}
+ public static String createResourceKey(String serverName, List<String> hosts) {
+//BZ 612189 - swap the impls once resource upgrade is in place
+// StringBuilder keyBuilder = new StringBuilder();
+// if (serverName != null) {
+// keyBuilder.append(serverName).append("|");
+// }
+// keyBuilder.append(hosts.get(0));
+//
+//
+// for (int i = 1; i < hosts.size(); ++i){
+// keyBuilder.append(" ").append(hosts.get(i));
+// }
+//
+// return keyBuilder.toString();
+
+ //try to derive the same resource key as the SNMP would have... this is to prevent the duplication of
+ //vhost resources after the SNMP was configured - how I wish resource upgrade made it to 3.0 to prevent this
+ //kind of guessing being necessary.
+ String host = hosts.get(0);
+ HttpdAddressUtility.Address hostAddr = HttpdAddressUtility.Address.parse(host);
+ if (serverName != null) {
+ HttpdAddressUtility.Address serverAddr = HttpdAddressUtility.Address.parse(serverName);
+ hostAddr.host = serverAddr.host;
+ }
+
+ //the SNMP module seems to resolve the IPs to hostnames.
+ try {
+ InetAddress hostName = InetAddress.getByName(hostAddr.host);
+ hostAddr.host = hostName.getHostName();
+ } catch (UnknownHostException e) {
+ log.debug("Host " + hostAddr.host + " is not resolvable.", e);
+ }
+
+ return hostAddr.host + ":" + hostAddr.port;
+ }
+
/**
* @deprecated remove this once we have resource upgrade
* @param discoveryContext
@@ -279,7 +318,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
return ret;
} catch (Exception e) {
- log.warn("Error while trying to contact SNMP of the apache server " + discoveryContext.getParentResourceContext().getResourceKey());
+ log.warn("Error while trying to contact SNMP of the apache server " + discoveryContext.getParentResourceContext().getResourceKey(), e);
return null;
}
}
commit 15a2bbe9f0a9ba43cccb2065ced149a8abb92710
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 14:33:57 2010 +0100
BZ 642588 - config is reloaded if ServerRoot is redefined in config
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index ca8f972..bea7c23 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -141,6 +141,8 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
if (!serverRoots.isEmpty()) {
serverRoot = AugeasNodeValueUtil.unescape(serverRoots.get(0).getValuesAsString());
serverRootProp.setValue(serverRoot);
+ //reparse the configuration with the new ServerRoot
+ serverConfig = loadParser(serverConfigFile.getAbsolutePath(), serverRoot);
}
serverUrl = getUrl(serverConfig, binaryInfo.getVersion());
commit 0235aed4bd3737768f96acc66f5868838235686d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Oct 15 17:40:49 2010 -0400
DataSource Work:
Resulting from the fact that we couldn't render a list view without
including the ID colum. In short it seems there is (currently) only one
way to get control of column widths in one of our dataSource-backed
ListGrid based views. That is to override the ds fields with its own
ListGrid fields (see ResourceSearchView for a working example).
Perhaps at some point the listGrid.resizeField() method will work as
maybe it should, but until then this is the way to go. By calling
setFields(ListGridField[]) you will override the ds fields. For datasources
used explicitly to back ListGrid views the ds doesn't really have to
declare fields. With one exception, it may need to declare a primary key
field, typically "id".
Anyway, this checkin does a few things:
- Apply the same pattern to all of our datasources for defining ds fields.
This pattern lets subclasses easily add to the superclass's fields.
- Add CoreGUI.isDebugEnabled()
- Add Table.setListGridFields(fields). This will handle any "id" field
defined in the underlying datasource. It will be shown in debug and
omitted otherwise.
- Update ResourceSearchView and ResourceDataSource to work in the new
fashion and serve (hopefully) as a decent example moving forward. Look
here if you want to fix issues in column widths.
- Misc: some null protection added, some selenium ID protection added
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 3544941..5bce6ba 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
@@ -88,6 +88,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
private static Messages messages;
+ private static boolean debugMode = true;
+
public void onModuleLoad() {
String hostPageBaseURL = GWT.getHostPageBaseURL();
if (hostPageBaseURL.indexOf("/coregui/") == -1) {
@@ -102,7 +104,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
coreGUI = this;
- if (!GWT.isScript()) {
+ debugMode = !GWT.isScript();
+ if (debugMode) {
KeyIdentifier debugKey = new KeyIdentifier();
debugKey.setCtrlKey(true);
debugKey.setKeyName("D");
@@ -331,4 +334,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
}
+ public static boolean isDebugMode() {
+ return debugMode;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
index 9af7064..a12bec5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.admin.roles;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -62,13 +63,24 @@ public class RolesDataSource extends RPCDataSource<Role> {
}
public RolesDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceField idDataField = new DataSourceIntegerField("id", "ID");
idDataField.setPrimaryKey(true);
idDataField.setCanEdit(false);
+ fields.add(idDataField);
DataSourceTextField nameField = new DataSourceTextField("name", "Name", 100, true);
+ fields.add(nameField);
- setFields(idDataField, nameField);
+ return fields;
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
index af9acd6..33b94a0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.admin.users;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -63,16 +64,28 @@ public class UsersDataSource extends RPCDataSource<Subject> {
}
public UsersDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idDataField = new DataSourceIntegerField("id", "ID");
idDataField.setPrimaryKey(true);
idDataField.setCanEdit(false);
+ fields.add(idDataField);
DataSourceTextField usernameField = new DataSourceTextField("name", "User Name", 100, true);
+ fields.add(usernameField);
DataSourceTextField firstName = new DataSourceTextField("firstName", "First Name", 100, true);
+ fields.add(firstName);
DataSourceTextField lastName = new DataSourceTextField("lastName", "Last Name", 100, true);
+ fields.add(lastName);
DataSourceTextField password = new DataSourceTextField("password", "Password", 100, false);
password.setType(FieldType.PASSWORD);
@@ -89,18 +102,22 @@ public class UsersDataSource extends RPCDataSource<Subject> {
passwordsEqualValidator.setOtherField("password");
passwordsEqualValidator.setErrorMessage("Passwords do not match");
passwordVerify.setValidators(passwordsEqualValidator);
+ fields.add(password);
DataSourceTextField emailAddress = new DataSourceTextField("emailAddress", "Email Address", 100, true);
+ fields.add(emailAddress);
DataSourceTextField phone = new DataSourceTextField("phoneNumber", "Phone", 15, false);
+ fields.add(phone);
DataSourceTextField department = new DataSourceTextField("department", "Department", 100, false);
+ fields.add(department);
DataSourceTextField enabled = new DataSourceTextField("factive", "Enabled");
enabled.setType(FieldType.BOOLEAN);
+ fields.add(enabled);
- setFields(idDataField, usernameField, firstName, lastName, password, passwordVerify, phone, emailAddress,
- department, enabled);
+ return fields;
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index a950c34..aaee63f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -18,7 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.alert;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -65,12 +64,13 @@ public class AlertDataSource extends RPCDataSource<Alert> {
setCanMultiSort(true);
- List<DataSourceField> fields = createFields();
+ List<DataSourceField> fields = addDataSourceFields();
addFields(fields);
}
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = new ArrayList<DataSourceField>();
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idField = new DataSourceIntegerField("id", "Id");
idField.setPrimaryKey(true);
@@ -284,7 +284,8 @@ public class AlertDataSource extends RPCDataSource<Alert> {
CoreGUI.getMessageCenter().notify(
new Message("Acknowledged [" + alertIds.length + "] alerts", Message.Severity.Info));
- com.allen_sauer.gwt.log.client.Log.info("Acknowledged Alerts with id's: " + Arrays.toString(alertIds) + ".");
+ com.allen_sauer.gwt.log.client.Log.info("Acknowledged Alerts with id's: " + Arrays.toString(alertIds)
+ + ".");
alertsView.refresh();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
index 7a53dbe..b7c9db8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
@@ -19,10 +19,12 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceImageField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.FieldType;
@@ -52,7 +54,9 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
protected static final String FIELD_OBJECT = "_object"; // the actual AlertDefinition object
public AbstractAlertDefinitionsDataSource() {
- setupFields();
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
}
@Override
@@ -94,27 +98,31 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
* free to call this method and then add more, or add their own custom set and not
* call this method at all (if they don't want some of these basic fields or want to reorder them).
*/
- protected void setupFields() {
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField nameField = new DataSourceTextField(FIELD_NAME, "Name");
- addField(nameField);
+ fields.add(nameField);
DataSourceTextField descriptionField = new DataSourceTextField(FIELD_DESCRIPTION, "Description");
- addField(descriptionField);
+ fields.add(descriptionField);
DataSourceTextField ctimeField = new DataSourceTextField(FIELD_CTIME, "Created Time");
ctimeField.setType(FieldType.DATETIME);
- addField(ctimeField);
+ fields.add(ctimeField);
DataSourceTextField mtimeField = new DataSourceTextField(FIELD_MTIME, "Modified Time");
mtimeField.setType(FieldType.DATETIME);
- addField(mtimeField);
+ fields.add(mtimeField);
DataSourceTextField enabledField = new DataSourceTextField(FIELD_ENABLED, "Enabled");
enabledField.setType(FieldType.BOOLEAN);
- addField(enabledField);
+ fields.add(enabledField);
DataSourceImageField priorityField = new DataSourceImageField(FIELD_PRIORITY, "Priority");
- addField(priorityField);
+ fields.add(priorityField);
+
+ return fields;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 2d4e85a..2d8463d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -24,10 +24,12 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Window;
@@ -148,8 +150,19 @@ public class ConditionsEditor extends LocatableVLayout {
private static final String FIELD_CONDITION = "condition";
public ConditionDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField conditionField = new DataSourceTextField(FIELD_CONDITION, "Condition");
- addField(conditionField);
+ fields.add(conditionField);
+
+ return fields;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
index f707dc1..f783b4c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -29,6 +29,7 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Window;
@@ -170,11 +171,26 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
private class NotificationDataSource extends RPCDataSource<AlertNotification> {
public NotificationDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField senderField = new DataSourceTextField(FIELD_SENDER, "Sender");
- addField(senderField);
+ fields.add(senderField);
DataSourceTextField configField = new DataSourceTextField(FIELD_CONFIGURATION, "Configuration");
- addField(configField);
+ fields.add(configField);
+
+ return fields;
+ }
+
+ @Override
+ public void useDatasourceDefinedFields() {
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
index f53710f..b9c4dca 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
@@ -23,10 +23,12 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.List;
import java.util.Map;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceLinkField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -81,15 +83,17 @@ public class ResourceAlertDefinitionsDataSource extends AbstractAlertDefinitions
}
@Override
- protected void setupFields() {
- super.setupFields();
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
// add two more columns
DataSourceLinkField parentIdField = new DataSourceLinkField(FIELD_PARENT, "Parent");
- addField(parentIdField);
+ fields.add(parentIdField);
DataSourceTextField readOnlyField = new DataSourceTextField(FIELD_READONLY, "Read Only");
- addField(readOnlyField);
+ fields.add(readOnlyField);
+
+ return fields;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
index a6e4da7..1f3ced4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
@@ -23,10 +23,12 @@
package org.rhq.enterprise.gui.coregui.client.bundle.deployment;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -48,25 +50,35 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundleDeploymentDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField id = new DataSourceIntegerField("id", "ID");
id.setPrimaryKey(true);
- addField(id);
+ fields.add(id);
DataSourceTextField name = new DataSourceTextField("name", "Deployment Name");
- addField(name);
+ fields.add(name);
DataSourceTextField bundleVersion = new DataSourceTextField("bundleVersionVersion", "Bundle Version");
- addField(bundleVersion);
+ fields.add(bundleVersion);
DataSourceTextField description = new DataSourceTextField("description", "Description");
- addField(description);
+ fields.add(description);
DataSourceTextField status = new DataSourceTextField("status", "Status");
- addField(status);
+ fields.add(status);
DataSourceDateTimeField created = new DataSourceDateTimeField("deploymentTime", "Deployment Time");
- addField(created);
+ fields.add(created);
+
+ return fields;
}
@Override
@@ -83,7 +95,8 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
}
if (request.getCriteria().getValues().containsKey("bundleDestinationId")) {
- criteria.addFilterDestinationId(Integer.parseInt(request.getCriteria().getAttribute("bundleDestinationId")));
+ criteria
+ .addFilterDestinationId(Integer.parseInt(request.getCriteria().getAttribute("bundleDestinationId")));
}
if (request.getCriteria().getValues().get("tagNamespace") != null) {
@@ -130,7 +143,6 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
record.setAttribute("status", from.getStatus().name());
record.setAttribute("deployer", from.getSubjectName());
-
if (from.getBundleVersion() != null) {
record.setAttribute("bundleVersionVersion", from.getBundleVersion().getVersion());
record.setAttribute("bundleVersionId", from.getBundleVersion().getId());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
index a2fa68e..1c23d51 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
@@ -22,15 +22,17 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.deployment.resource;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
-import org.rhq.core.domain.criteria.BundleDeploymentCriteria;
import org.rhq.core.domain.criteria.BundleResourceDeploymentCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
@@ -44,19 +46,27 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleResourceDeployment> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
-
public BundleResourceDeploymentDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
- DataSourceIntegerField id = new DataSourceIntegerField("id","ID");
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceIntegerField id = new DataSourceIntegerField("id", "ID");
id.setPrimaryKey(true);
- addField(id);
+ fields.add(id);
DataSourceTextField resourceName = new DataSourceTextField("resourceName", "Resource");
- addField(resourceName);
+ fields.add(resourceName);
DataSourceTextField status = new DataSourceTextField("status", "Status");
- addField(status);
+ fields.add(status);
+ return fields;
}
@Override
@@ -68,26 +78,27 @@ public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleReso
criteria.fetchHistories(true);
if (request.getCriteria().getValues().containsKey("bundleDeploymentId")) {
- criteria.addFilterBundleDeploymentId(Integer.parseInt(request.getCriteria().getAttribute("bundleDeploymentId")));
+ criteria.addFilterBundleDeploymentId(Integer.parseInt(request.getCriteria().getAttribute(
+ "bundleDeploymentId")));
}
- bundleService.findBundleResourceDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleResourceDeployment>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle resource deployments",caught);
- }
-
- public void onSuccess(PageList<BundleResourceDeployment> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ bundleService.findBundleResourceDeploymentsByCriteria(criteria,
+ new AsyncCallback<PageList<BundleResourceDeployment>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load bundle resource deployments", caught);
+ }
+ public void onSuccess(PageList<BundleResourceDeployment> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
@Override
public BundleResourceDeployment copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
@@ -97,10 +108,9 @@ public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleReso
record.setAttribute("resourceName", from.getResource().getName());
record.setAttribute("resourceId", from.getResource().getId());
- record.setAttribute("status",from.getStatus().name());
-
- record.setAttribute("histories",from.getBundleResourceDeploymentHistories());
+ record.setAttribute("status", from.getStatus().name());
+ record.setAttribute("histories", from.getBundleResourceDeploymentHistories());
from.getBundleResourceDeploymentHistories();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
index a375981..3985c78 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
@@ -23,10 +23,12 @@
package org.rhq.enterprise.gui.coregui.client.bundle.destination;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -34,7 +36,6 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDestination;
import org.rhq.core.domain.bundle.BundleVersion;
-import org.rhq.core.domain.criteria.BundleDeploymentCriteria;
import org.rhq.core.domain.criteria.BundleDestinationCriteria;
import org.rhq.core.domain.criteria.BundleVersionCriteria;
import org.rhq.core.domain.util.PageList;
@@ -48,38 +49,49 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
public class BundleDestinationDataSource extends RPCDataSource<BundleDestination> {
public BundleDestinationDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id", "Id");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField name = new DataSourceTextField("name", "Name");
- addField(name);
+ fields.add(name);
DataSourceTextField description = new DataSourceTextField("description", "Description");
- addField(description);
+ fields.add(description);
DataSourceTextField bundle = new DataSourceTextField("bundleName", "Bundle");
- addField(bundle);
+ fields.add(bundle);
DataSourceTextField group = new DataSourceTextField("groupName", "Group");
- addField(group);
+ fields.add(group);
DataSourceTextField deployDir = new DataSourceTextField("deployDir", "Deploy Directory");
- addField(deployDir);
+ fields.add(deployDir);
- DataSourceTextField latestDeploymentVersion = new DataSourceTextField("latestDeploymentVersion", "Last Deployed Version");
- addField(latestDeploymentVersion);
+ DataSourceTextField latestDeploymentVersion = new DataSourceTextField("latestDeploymentVersion",
+ "Last Deployed Version");
+ fields.add(latestDeploymentVersion);
- DataSourceTextField latestDeploymentDate = new DataSourceTextField("latestDeploymentDate", "Last Deployment Date");
- addField(latestDeploymentDate);
+ DataSourceTextField latestDeploymentDate = new DataSourceTextField("latestDeploymentDate",
+ "Last Deployment Date");
+ fields.add(latestDeploymentDate);
- DataSourceTextField latestDeploymentStatus = new DataSourceTextField("latestDeploymentStatus", "Last Deployment Status");
- addField(latestDeploymentStatus);
+ DataSourceTextField latestDeploymentStatus = new DataSourceTextField("latestDeploymentStatus",
+ "Last Deployment Status");
+ fields.add(latestDeploymentStatus);
+ return fields;
}
-
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
BundleDestinationCriteria criteria = new BundleDestinationCriteria();
@@ -88,7 +100,7 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
criteria.addFilterBundleId(Integer.parseInt(request.getCriteria().getAttributeAsString("bundleId")));
}
- if (request.getCriteria().getValues().get("tagNamespace") != null) {
+ if (request.getCriteria().getValues().get("tagNamespace") != null) {
criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
}
@@ -100,28 +112,29 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
}
-
criteria.fetchBundle(true);
criteria.fetchDeployments(true);
criteria.fetchGroup(true);
criteria.fetchTags(true);
-
GWTServiceLookup.getBundleService().findBundleDestinationsByCriteria(criteria,
- new AsyncCallback<PageList<BundleDestination>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle destinations",caught);
- }
+ new AsyncCallback<PageList<BundleDestination>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load bundle destinations", caught);
+ }
- public void onSuccess(final PageList<BundleDestination> result) {
+ public void onSuccess(final PageList<BundleDestination> result) {
- BundleVersionCriteria versionCriteria = new BundleVersionCriteria();
- if (request.getCriteria().getValues().containsKey("bundleId")) {
- versionCriteria.addFilterBundleId(Integer.parseInt(request.getCriteria().getAttributeAsString("bundleId")));
- }
- GWTServiceLookup.getBundleService().findBundleVersionsByCriteria(versionCriteria, new AsyncCallback<PageList<BundleVersion>>() {
+ BundleVersionCriteria versionCriteria = new BundleVersionCriteria();
+ if (request.getCriteria().getValues().containsKey("bundleId")) {
+ versionCriteria.addFilterBundleId(Integer.parseInt(request.getCriteria().getAttributeAsString(
+ "bundleId")));
+ }
+ GWTServiceLookup.getBundleService().findBundleVersionsByCriteria(versionCriteria,
+ new AsyncCallback<PageList<BundleVersion>>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle destination deployed version info",caught);
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to load bundle destination deployed version info", caught);
}
public void onSuccess(PageList<BundleVersion> versions) {
@@ -143,8 +156,8 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
}
});
- }
- });
+ }
+ });
}
@Override
@@ -168,7 +181,6 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
record.setAttribute("deployDir", from.getDeployDir());
record.setAttribute("entity", from);
-
long last = 0;
for (BundleDeployment dep : from.getDeployments()) {
if (last < dep.getCtime()) {
@@ -182,7 +194,6 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
}
}
-
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
index 6b08c63..b5b0444 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
@@ -18,9 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.list;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -39,26 +42,34 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
public class BundleVersionDataSource extends RPCDataSource<BundleVersion> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
- private int bundleId;
public BundleVersionDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceIntegerField idField = new DataSourceIntegerField("id", "ID");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField latestVersionField = new DataSourceTextField("version", "Version");
- addField(latestVersionField);
+ fields.add(latestVersionField);
DataSourceTextField nameField = new DataSourceTextField("name", "Name");
- addField(nameField);
+ fields.add(nameField);
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
- addField(descriptionField);
-
-
+ fields.add(descriptionField);
DataSourceIntegerField deploymentCountField = new DataSourceIntegerField("fileCount", "File Count");
- addField(deploymentCountField);
+ fields.add(deploymentCountField);
+
+ return fields;
}
@Override
@@ -70,7 +81,8 @@ public class BundleVersionDataSource extends RPCDataSource<BundleVersion> {
criteria.setPageControl(getPageControl(request));
if (request.getCriteria().getValues().get("bundleId") != null) {
- criteria.addFilterBundleId(Integer.parseInt(String.valueOf(request.getCriteria().getValues().get("bundleId"))));
+ criteria.addFilterBundleId(Integer.parseInt(String.valueOf(request.getCriteria().getValues()
+ .get("bundleId"))));
}
if (request.getCriteria().getValues().get("tagNamespace") != null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
index 7c8aa02..32cf81a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
@@ -18,9 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.list;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -41,19 +44,29 @@ public class BundlesDataSource extends RPCDataSource<Bundle> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundlesDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id", "ID");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField("name", "Name");
- addField(nameField);
+ fields.add(nameField);
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
- addField(descriptionField);
+ fields.add(descriptionField);
DataSourceTextField bundleTypeDataField = new DataSourceTextField("bundleType", "Bundle Type");
- addField(bundleTypeDataField);
+ fields.add(bundleTypeDataField);
+
+ return fields;
}
@Override
@@ -62,7 +75,6 @@ public class BundlesDataSource extends RPCDataSource<Bundle> {
BundleCriteria criteria = new BundleCriteria();
criteria.setPageControl(getPageControl(request));
-
if (request.getCriteria().getValues().get("tagNamespace") != null) {
criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
}
@@ -75,7 +87,6 @@ public class BundlesDataSource extends RPCDataSource<Bundle> {
criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
}
-
bundleService.findBundlesByCriteria(criteria, new AsyncCallback<PageList<Bundle>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Failed to load bundle data", caught);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
index e3b54ac..76340e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
@@ -18,9 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.list;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceLinkField;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -42,23 +45,32 @@ public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWith
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundlesWithLatestVersionDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id", "ID");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceLinkField linkField = new DataSourceLinkField("link", "Name");
- addField(linkField);
-
+ fields.add(linkField);
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
- addField(descriptionField);
+ fields.add(descriptionField);
DataSourceTextField latestVersionField = new DataSourceTextField("latestVersion", "Latest Version");
- addField(latestVersionField);
+ fields.add(latestVersionField);
DataSourceIntegerField deploymentCountField = new DataSourceIntegerField("versionsCount", "Versions Count");
- addField(deploymentCountField);
+ fields.add(deploymentCountField);
+
+ return fields;
}
@Override
@@ -78,7 +90,6 @@ public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWith
criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
}
-
bundleService.findBundlesWithLatestVersionCompositesByCriteria(criteria,
new AsyncCallback<PageList<BundleWithLatestVersionComposite>>() {
public void onFailure(Throwable caught) {
@@ -115,11 +126,9 @@ public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWith
record.setAttribute("id", from.getBundleId());
record.setAttribute("name", from.getBundleName());
-
record.setAttribute("link", "#Bundles/Bundle/" + from.getBundleId());
record.setLinkText(from.getBundleName());
-
record.setAttribute("description", from.getBundleDescription());
record.setAttribute("latestVersion", from.getLatestVersion());
record.setAttribute("versionsCount", Integer.valueOf(from.getVersionsCount().intValue())); // want int, not long
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
index f1661c8..16e5e67 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
@@ -24,6 +24,7 @@ package org.rhq.enterprise.gui.coregui.client.bundle.tree;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
@@ -50,25 +51,34 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
+@SuppressWarnings("unchecked")
public class BundleTreeDataSource extends RPCDataSource {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundleTreeDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceField idDataField = new DataSourceTextField("id", "ID");
idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
DataSourceTextField nameDataField = new DataSourceTextField("name", "Name");
nameDataField.setCanEdit(false);
-
- DataSourceTextField descriptionDataField = new DataSourceTextField("description", "Description");
- descriptionDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField parentIdField = new DataSourceTextField("parentId", "Parent ID");
parentIdField.setForeignKey("id");
+ fields.add(parentIdField);
-
- setFields(idDataField, nameDataField, parentIdField);
+ return fields;
}
@Override
@@ -97,8 +107,8 @@ public class BundleTreeDataSource extends RPCDataSource {
}
});
} else {
- if (p.endsWith(":versions")) {
- int bundleId = Integer.parseInt(p.substring(0, p.indexOf(":")));
+ if (p.endsWith("_versions")) {
+ int bundleId = Integer.parseInt(p.substring(0, p.indexOf("_")));
BundleVersionCriteria criteria = new BundleVersionCriteria();
criteria.addFilterBundleId(bundleId);
bundleService.findBundleVersionsByCriteria(criteria, new AsyncCallback<PageList<BundleVersion>>() {
@@ -114,46 +124,47 @@ public class BundleTreeDataSource extends RPCDataSource {
processResponse(request.getRequestId(), response);
}
});
- } else if (p.endsWith(":deployments")) {
- int bundleId = Integer.parseInt(p.substring(0, p.indexOf(":")));
+ } else if (p.endsWith("_deployments")) {
+ int bundleId = Integer.parseInt(p.substring(0, p.indexOf("_")));
BundleDeploymentCriteria criteria = new BundleDeploymentCriteria();
criteria.fetchBundleVersion(true);
criteria.addFilterBundleId(bundleId);
- bundleService.findBundleDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleDeployment>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle", caught);
- }
-
- public void onSuccess(PageList<BundleDeployment> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
- } else if (p.endsWith(":destinations")) {
- int bundleId = Integer.parseInt(p.substring(0, p.indexOf(":")));
+ bundleService.findBundleDeploymentsByCriteria(criteria,
+ new AsyncCallback<PageList<BundleDeployment>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load bundle", caught);
+ }
+
+ public void onSuccess(PageList<BundleDeployment> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ } else if (p.endsWith("_destinations")) {
+ int bundleId = Integer.parseInt(p.substring(0, p.indexOf("_")));
BundleDestinationCriteria criteria = new BundleDestinationCriteria();
criteria.addFilterBundleId(bundleId);
- bundleService.findBundleDestinationsByCriteria(criteria, new AsyncCallback<PageList<BundleDestination>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle destinations", caught);
- }
-
- public void onSuccess(PageList<BundleDestination> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ bundleService.findBundleDestinationsByCriteria(criteria,
+ new AsyncCallback<PageList<BundleDestination>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load bundle destinations", caught);
+ }
+
+ public void onSuccess(PageList<BundleDestination> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
}
-
}
@Override
public Object copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
@@ -171,14 +182,14 @@ public class BundleTreeDataSource extends RPCDataSource {
Bundle bundle = (Bundle) item;
TreeNode versionNode = new TreeNode("Versions");
- versionNode.setID(bundle.getId() + ":versions");
+ versionNode.setID(bundle.getId() + "_versions");
versionNode.setParentID(String.valueOf(bundle.getId()));
versionNode.setName("Versions");
versionNode.setAttribute("name", "Versions");
records.add(versionNode);
TreeNode deploymentsNode = new TreeNode("Destinations");
- deploymentsNode.setID(bundle.getId() + ":destinations");
+ deploymentsNode.setID(bundle.getId() + "_destinations");
deploymentsNode.setParentID(String.valueOf(bundle.getId()));
deploymentsNode.setName("Destinations");
records.add(deploymentsNode);
@@ -187,7 +198,6 @@ public class BundleTreeDataSource extends RPCDataSource {
return records.toArray(new ListGridRecord[records.size()]);
}
-
@Override
public ListGridRecord copyValues(Object from) {
TreeNode node = new TreeNode();
@@ -200,23 +210,23 @@ public class BundleTreeDataSource extends RPCDataSource {
} else if (from instanceof BundleVersion) {
BundleVersion version = (BundleVersion) from;
node.setName(version.getVersion());
- node.setID(version.getBundle().getId() + ":versions:" + version.getId());
- node.setParentID(version.getBundle().getId() + ":versions");
+ node.setID(version.getBundle().getId() + "_versions_" + version.getId());
+ node.setParentID(version.getBundle().getId() + "_versions");
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleVersion_16.png");
} else if (from instanceof BundleDeployment) {
BundleDeployment deployment = (BundleDeployment) from;
node.setName(deployment.getName() + " (" + deployment.getBundleVersion().getVersion() + ")");
- node.setID(deployment.getBundleVersion().getBundle().getId() + ":deployments:" + deployment.getId());
- node.setParentID(deployment.getBundleVersion().getBundle().getId() + ":deployments");
+ node.setID(deployment.getBundleVersion().getBundle().getId() + "_deployments_" + deployment.getId());
+ node.setParentID(deployment.getBundleVersion().getBundle().getId() + "_deployments");
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleDeployment_16.png");
} else if (from instanceof BundleDestination) {
BundleDestination destination = (BundleDestination) from;
node.setName(destination.getName());
- node.setID(destination.getBundle().getId() + ":destinations:" +destination.getId());
- node.setParentID(destination.getBundle().getId() + ":destinations");
+ node.setID(destination.getBundle().getId() + "_destinations_" + destination.getId());
+ node.setParentID(destination.getBundle().getId() + "_destinations");
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleDestination_16.png");
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index b4aff2b..7e2604e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -23,7 +23,9 @@ import java.util.List;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Autofit;
+import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.types.VerticalAlignment;
@@ -47,6 +49,7 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
@@ -484,6 +487,33 @@ public class Table extends LocatableHLayout implements RefreshableView {
return listGrid;
}
+ /**
+ * Wraps ListGrid.setFields(...) but takes care of "id" field display handling
+ * @param fields
+ */
+ public void setListGridFields(ListGridField... fields) {
+ if (null == this.dataSource.getField("id")) {
+ return;
+ }
+
+ if (CoreGUI.isDebugMode()) {
+ ListGridField idField = new ListGridField("id", "Id", 55);
+ idField.setType(ListGridFieldType.INTEGER);
+ idField.setCanEdit(false);
+ idField.setAlign(Alignment.LEFT);
+
+ ListGridField[] newFields = new ListGridField[fields.length + 1];
+ newFields[0] = idField;
+ for (int i = 0; i < fields.length; ++i) {
+ newFields[i + 1] = fields[i];
+ }
+ this.listGrid.setFields(newFields);
+ } else {
+ getListGrid().hideField("id");
+ this.listGrid.setFields(fields);
+ }
+ }
+
public void setTitleComponent(Canvas canvas) {
this.titleComponent = canvas;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
index 1d3f08d..a971a97 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
@@ -47,38 +47,37 @@ public class TaggingDataSource extends RPCDataSource<Tag> {
String search = (String) request.getCriteria().getValues().get("tag");
if (search != null) {
// todo
-// criteria.addFilter
+ // criteria.addFilter
}
- GWTServiceLookup.getTagService().findTagsByCriteria(new TagCriteria(),
- new AsyncCallback<PageList<Tag>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load tags",caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
+ GWTServiceLookup.getTagService().findTagsByCriteria(new TagCriteria(), new AsyncCallback<PageList<Tag>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load tags", caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
- public void onSuccess(PageList<Tag> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ public void onSuccess(PageList<Tag> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
@Override
public Tag copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
public ListGridRecord copyValues(Tag from) {
ListGridRecord record = new ListGridRecord();
- record.setAttribute("id",from.getId());
- record.setAttribute("namespace",from.getNamespace());
- record.setAttribute("semantic",from.getSemantic());
- record.setAttribute("name",from.getName());
- record.setAttribute("tag",from.toString());
+ record.setAttribute("id", from.getId());
+ record.setAttribute("namespace", from.getNamespace());
+ record.setAttribute("semantic", from.getSemantic());
+ record.setAttribute("name", from.getName());
+ record.setAttribute("tag", from.toString());
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
index f4b69ae..a2b8b37 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -28,11 +28,9 @@ import org.rhq.core.domain.util.StringUtils;
public class EnhancedTreeNode extends TreeNode {
public EnhancedTreeNode() {
super();
- // this(null);
}
public EnhancedTreeNode(String name) {
- //this(name, new TreeNode[0]);
super(name);
if (name != null) {
setTitle(StringUtils.deCamelCase(name));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
index 9b54565..9490647 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
@@ -22,6 +22,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.content.repository.tree;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -30,52 +32,54 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.tree.TreeNode;
-import org.rhq.core.domain.criteria.Criteria;
+import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.RepoGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import org.rhq.core.domain.content.Repo;
/**
* @author Greg Hinkle
*/
-public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
+public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
private RepoGWTServiceAsync repoService = GWTServiceLookup.getRepoService();
-
-
public ContentRepositoryTreeDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idDataField = new DataSourceTextField("id", "ID");
idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
DataSourceTextField nameDataField = new DataSourceTextField("name", "Name");
nameDataField.setCanEdit(false);
-
- DataSourceTextField descriptionDataField = new DataSourceTextField("description", "Description");
- descriptionDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField parentIdField = new DataSourceTextField("parentId", "Parent ID");
parentIdField.setForeignKey("id");
+ fields.add(parentIdField);
- setFields(idDataField, nameDataField, parentIdField);
+ return fields;
}
-
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
-
RepoCriteria criteria = new RepoCriteria();
-
repoService.findReposByCriteria(criteria, new AsyncCallback<PageList<Repo>>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load repositories",caught);
+ CoreGUI.getErrorHandler().handleError("Failed to load repositories", caught);
}
public void onSuccess(PageList<Repo> result) {
@@ -88,7 +92,7 @@ public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
@Override
public Repo copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
index 7f9d8fd..b0f94c3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
@@ -18,9 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform;
+import java.util.List;
+
import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.fields.DataSourceImageField;
-import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -38,15 +38,24 @@ public class PlatformMetricDataSource extends ResourceDatasource {
super();
this.view = view;
- DataSourceTextField cpuField = new DataSourceTextField("cpu","CPU");
- addField(cpuField);
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceTextField cpuField = new DataSourceTextField("cpu", "CPU");
+ fields.add(cpuField);
DataSourceTextField memoryField = new DataSourceTextField("memory", "Memory");
- addField(memoryField);
+ fields.add(memoryField);
+
DataSourceTextField swapField = new DataSourceTextField("swap", "Swap");
// todo swap
- }
-
+ return fields;
+ }
@Override
public ListGridRecord copyValues(Resource from) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
index b30714f..874d92d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
@@ -18,14 +18,19 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common;
+import java.util.List;
+import java.util.Map;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.fields.*;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
+import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.util.PageList;
@@ -34,10 +39,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
/**
* A server-side SmartGWT DataSource for reading {@link MeasurementDataTrait trait data}.
*
@@ -48,12 +49,13 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
protected AbstractMeasurementDataTraitDataSource() {
setCanMultiSort(true);
- List<DataSourceField> fields = createFields();
+ List<DataSourceField> fields = addDataSourceFields();
addFields(fields);
}
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = new ArrayList<DataSourceField>();
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceTextField primaryKeyField = new DataSourceTextField("primaryKey", "Primary Key");
primaryKeyField.setPrimaryKey(true);
@@ -65,17 +67,16 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME,
- "Trait");
+ "Trait");
fields.add(nameField);
// TODO: Include description from metric def?
- DataSourceTextField valueField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_VALUE,
- "Value");
+ DataSourceTextField valueField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_VALUE, "Value");
fields.add(valueField);
- DataSourceIntegerField timestampField = new DataSourceIntegerField(MeasurementDataTraitCriteria.SORT_FIELD_TIMESTAMP,
- "Last Changed");
+ DataSourceIntegerField timestampField = new DataSourceIntegerField(
+ MeasurementDataTraitCriteria.SORT_FIELD_TIMESTAMP, "Last Changed");
fields.add(timestampField);
return fields;
@@ -88,8 +89,7 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
this.measurementService.findTraitsByCriteria(criteria, new AsyncCallback<PageList<MeasurementDataTrait>>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to fetch traits for criteria " + criteria,
- caught);
+ CoreGUI.getErrorHandler().handleError("Failed to fetch traits for criteria " + criteria, caught);
response.setStatus(RPCResponse.STATUS_FAILURE);
processResponse(request.getRequestId(), response);
}
@@ -145,9 +145,10 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
record.setAttribute("primaryKey", from.getScheduleId() + ":" + from.getTimestamp());
record.setAttribute("id", from.getSchedule().getDefinition().getId()); // used for detail view
record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_TIMESTAMP, from.getTimestamp());
- record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME, from.getSchedule().getDefinition().getDisplayName());
+ record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME, from.getSchedule().getDefinition()
+ .getDisplayName());
record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_VALUE, from.getValue());
-
+
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
index 7782c87..1f7da77 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
@@ -49,7 +49,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*
* @author Ian Springer
*/
-public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPCDataSource<MeasurementScheduleComposite> {
+public abstract class AbstractMeasurementScheduleCompositeDataSource extends
+ RPCDataSource<MeasurementScheduleComposite> {
private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService();
protected AbstractMeasurementScheduleCompositeDataSource() {
@@ -57,37 +58,38 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
setCanMultiSort(true);
- List<DataSourceField> fields = createFields();
+ List<DataSourceField> fields = addDataSourceFields();
addFields(fields);
}
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = new ArrayList<DataSourceField>();
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceIntegerField idField = new DataSourceIntegerField(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID,
- "Id");
+ DataSourceIntegerField idField = new DataSourceIntegerField(
+ MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID, "Id");
idField.setPrimaryKey(true);
idField.setHidden(true);
fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME,
- "Metric");
+ "Metric");
fields.add(nameField);
- DataSourceTextField descriptionField = new DataSourceTextField(MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION,
- "Description");
+ DataSourceTextField descriptionField = new DataSourceTextField(
+ MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION, "Description");
fields.add(descriptionField);
DataSourceTextField typeField = new DataSourceTextField(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE,
- "Type");
+ "Type");
fields.add(typeField);
- DataSourceBooleanField enabledField = new DataSourceBooleanField(MeasurementScheduleCriteria.SORT_FIELD_ENABLED,
- "Enabled?");
+ DataSourceBooleanField enabledField = new DataSourceBooleanField(
+ MeasurementScheduleCriteria.SORT_FIELD_ENABLED, "Enabled?");
fields.add(enabledField);
- DataSourceIntegerField intervalField = new DataSourceIntegerField(MeasurementScheduleCriteria.SORT_FIELD_INTERVAL,
- "Collection Interval");
+ DataSourceIntegerField intervalField = new DataSourceIntegerField(
+ MeasurementScheduleCriteria.SORT_FIELD_INTERVAL, "Collection Interval");
fields.add(intervalField);
return fields;
@@ -96,21 +98,22 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
protected void executeFetch(final DSRequest request, final DSResponse response) {
final EntityContext entityContext = getEntityContext(request);
- this.measurementService.getMeasurementScheduleCompositesByContext(entityContext, new AsyncCallback<PageList<MeasurementScheduleComposite>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to fetch measurement schedules for context " + entityContext,
- caught);
- response.setStatus(RPCResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
+ this.measurementService.getMeasurementScheduleCompositesByContext(entityContext,
+ new AsyncCallback<PageList<MeasurementScheduleComposite>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to fetch measurement schedules for context " + entityContext, caught);
+ response.setStatus(RPCResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
- public void onSuccess(PageList<MeasurementScheduleComposite> result) {
- response.setData(buildRecords(result));
- // For paging to work, we have to specify size of full result set.
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
+ public void onSuccess(PageList<MeasurementScheduleComposite> result) {
+ response.setData(buildRecords(result));
+ // For paging to work, we have to specify size of full result set.
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
protected EntityContext getEntityContext(DSRequest request) {
@@ -150,15 +153,16 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
MeasurementDefinition measurementDefinition = from.getMeasurementDefinition();
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID, measurementDefinition.getId());
- record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME, measurementDefinition.getDisplayName());
+ record
+ .setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME, measurementDefinition.getDisplayName());
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION, measurementDefinition.getDescription());
- record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE,
- measurementDefinition.getDataType().name().toLowerCase());
+ record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE, measurementDefinition.getDataType()
+ .name().toLowerCase());
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_ENABLED, from.getCollectionEnabled());
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_INTERVAL, from.getCollectionInterval());
// TODO: resourceId and resourceGroupId (in subclasses)
-
+
return record;
}
@@ -170,7 +174,7 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
}
protected abstract void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames);
+ int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames);
public void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView) {
int[] ids = getMeasurementDefinitionIds(measurementScheduleListView);
@@ -180,7 +184,7 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
}
protected abstract void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames);
+ int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames);
public void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, long interval) {
int[] ids = getMeasurementDefinitionIds(measurementScheduleListView);
@@ -196,13 +200,15 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
int[] measurementDefinitionIds = new int[records.length];
for (int i = 0, selectionLength = records.length; i < selectionLength; i++) {
ListGridRecord record = records[i];
- Integer measurementDefinitionId = record.getAttributeAsInt(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID);
+ Integer measurementDefinitionId = record
+ .getAttributeAsInt(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID);
measurementDefinitionIds[i] = measurementDefinitionId;
}
return measurementDefinitionIds;
}
- private List<String> getMeasurementDefinitionDisplayNames(AbstractMeasurementScheduleListView measurementScheduleListView) {
+ private List<String> getMeasurementDefinitionDisplayNames(
+ AbstractMeasurementScheduleListView measurementScheduleListView) {
ListGrid listGrid = measurementScheduleListView.getListGrid();
ListGridRecord[] records = listGrid.getSelection();
List<String> displayNames = new ArrayList<String>(records.length);
@@ -214,5 +220,5 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
}
protected abstract void updateSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
- final int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames, final long interval);
+ final int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames, final long interval);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
index 40dc105..03d6575 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
@@ -22,11 +22,14 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.event;
+import java.util.List;
import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.types.FieldType;
@@ -54,23 +57,32 @@ public class EventCompositeDatasource extends RPCDataSource<EventComposite> {
public EventCompositeDatasource(EntityContext context) {
super();
this.entityContext = context;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- // DataSourceField id = new DataSourceIntegerField("id", "Id");
- // id.setPrimaryKey(true);
- // addField(id);
+ DataSourceField id = new DataSourceIntegerField("id", "Id");
+ id.setPrimaryKey(true);
+ fields.add(id);
DataSourceTextField timestamp = new DataSourceTextField("timestamp", "Timestamp");
timestamp.setType(FieldType.DATETIME);
- addField(timestamp);
+ fields.add(timestamp);
DataSourceTextField severity = new DataSourceTextField("severity", "Severity");
- addField(severity);
+ fields.add(severity);
DataSourceTextField details = new HighlightingDatasourceTextField("details", "Details");
- addField(details);
+ fields.add(details);
DataSourceTextField sourceLocation = new DataSourceTextField("source", "Source Location");
- addField(sourceLocation);
+ fields.add(sourceLocation);
+
+ return fields;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index 4bdfdd4..4ddfa54 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -120,7 +120,7 @@ public class EventCompositeHistoryView extends TableSection {
}
});
- grid.setFields(timestampField, severityField, detailsField, sourceField);
+ setListGridFields(timestampField, severityField, detailsField, sourceField);
/*
grid.getField("timestamp").setWidth(125);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
index 0da1963..6fd1d01 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
@@ -21,9 +21,12 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups;
import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.CATEGORY;
import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.NAME;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -57,18 +60,32 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
public ResourceGroupCompositeDataSource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceTextField nameDataField = new DataSourceTextField("name", "Name", 200);
nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField descriptionDataField = new DataSourceTextField("description", "Description");
descriptionDataField.setCanEdit(false);
+ fields.add(descriptionDataField);
DataSourceTextField typeNameDataField = new DataSourceTextField("typeName", "Type");
+ fields.add(typeNameDataField);
+
DataSourceTextField pluginNameDataField = new DataSourceTextField("pluginName", "Plugin");
+ fields.add(pluginNameDataField);
+
DataSourceTextField categoryDataField = new DataSourceTextField("category", "Category");
+ fields.add(categoryDataField);
- setFields(nameDataField, descriptionDataField, typeNameDataField, pluginNameDataField, categoryDataField);
+ return fields;
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
index 2a02c99..190baf7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
@@ -21,6 +21,8 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups;
import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.CATEGORY;
import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.NAME;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -58,22 +60,36 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
public ResourceGroupsDataSource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 20);
idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
DataSourceTextField nameDataField = new DataSourceTextField("name", "Name", 200);
nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField descriptionDataField = new DataSourceTextField("description", "Description");
descriptionDataField.setCanEdit(false);
+ fields.add(descriptionDataField);
DataSourceTextField typeNameDataField = new DataSourceTextField("typeName", "Type");
+ fields.add(typeNameDataField);
+
DataSourceTextField pluginNameDataField = new DataSourceTextField("pluginName", "Plugin");
+ fields.add(pluginNameDataField);
+
DataSourceTextField categoryDataField = new DataSourceTextField("category", "Category");
+ fields.add(categoryDataField);
- setFields(idDataField, nameDataField, descriptionDataField, typeNameDataField, pluginNameDataField,
- categoryDataField);
+ return fields;
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
index f4da478..e9824e9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import com.google.gwt.core.client.JavaScriptObject;
@@ -59,31 +60,39 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
private GroupDefinitionDataSource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idField = new DataSourceIntegerField("id", "ID");
idField.setPrimaryKey(true);
idField.setCanEdit(false);
+ fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField("name", "Name");
nameField.setRequired(true);
+ fields.add(nameField);
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
+ fields.add(descriptionField);
DataSourceTextField expressionField = new DataSourceTextField("expression", "Expression Set");
expressionField.setRequired(true);
+ fields.add(expressionField);
DataSourceIntegerField lastCalculationTimeIntervalField = new DataSourceIntegerField("lastCalculationTime",
"Recalculation Interval");
+ fields.add(lastCalculationTimeIntervalField);
DataSourceIntegerField nextCalculationTimeField = new DataSourceIntegerField("nextCalculationTime",
"Next Calculation Time");
+ fields.add(nextCalculationTimeField);
- addField(idField);
- addField(nameField);
- addField(descriptionField);
- addField(expressionField);
- addField(lastCalculationTimeIntervalField);
- addField(nextCalculationTimeField);
+ return fields;
}
@Override
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 481354b..fc08133 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
@@ -59,8 +59,8 @@ import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
-import org.rhq.enterprise.gui.coregui.client.util.TreeUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
@@ -270,7 +270,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
ClusterKey rootKey = new ClusterKey(root.getGroupId());
loadTree(rootNode, root, rootKey);
-
+
Tree tree = new Tree();
tree.setRoot(fakeRoot);
@@ -347,26 +347,27 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
}
if (lastSubcategoryNode != null) {
- List<TreeNode> currentSubcategoryChildren = subCategoryChildrenByName.get(currentSubcategoryNode.getName());
+ List<TreeNode> currentSubcategoryChildren = subCategoryChildrenByName
+ .get(currentSubcategoryNode.getName());
currentSubcategoryChildren.add(lastSubcategoryNode);
}
lastSubcategoryNode = currentSubcategoryNode;
- } while (currentSubcategoryNodeCreated &&
- (currentSubCategory = currentSubCategory.getParentSubCategory()) != null);
+ } while (currentSubcategoryNodeCreated
+ && (currentSubCategory = currentSubCategory.getParentSubCategory()) != null);
List<TreeNode> subcategoryChildren = subCategoryChildrenByName.get(subcategory.getName());
subcategoryChildren.addAll(nodesByType);
- } else {
+ } else {
childNodes.addAll(nodesByType);
}
}
-
+
for (String subcategoryName : subCategoryNodesByName.keySet()) {
TreeNode subcategoryNode = subCategoryNodesByName.get(subcategoryName);
List<TreeNode> subcategoryChildren = subCategoryChildrenByName.get(subcategoryName);
subcategoryNode.setChildren(subcategoryChildren.toArray(new TreeNode[subcategoryChildren.size()]));
}
-
+
parentNode.setChildren(childNodes.toArray(new TreeNode[childNodes.size()]));
}
}
@@ -377,7 +378,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
ClusterKeyFlyweight keyFlyweight = child.getClusterKey();
ClusterKey key = new ClusterKey(parentKey, keyFlyweight.getResourceTypeId(), keyFlyweight.getResourceKey());
String id = key.getKey();
- node.setID(id);
+ node.setID(SeleniumUtility.getSafeId(id));
node.setAttribute("key", key);
node.setAttribute("resourceType", type);
node.setIsFolder(!child.getChildren().isEmpty());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
index 158448b..79a9b2a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
@@ -36,8 +38,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasuremen
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import java.util.List;
-
/**
* A DataSource for reading and updating the metric schedules for the current group.
*
@@ -52,12 +52,14 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
}
@Override
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = super.createFields();
- DataSourceField resourceGroupIdField = new DataSourceIntegerField(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID,
- "Resource Group Id");
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceField resourceGroupIdField = new DataSourceIntegerField(
+ MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID, "Resource Group Id");
resourceGroupIdField.setHidden(true);
fields.add(resourceGroupIdField);
+
return fields;
}
@@ -83,73 +85,76 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
@Override
protected void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
this.measurementService.enableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to enable collection of metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Enabled collection of selected metric" + s + ".",
- "Enabled collection of metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId +
- "].", Message.Severity.Info));
-
- }
- });
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to enable collection of metric" + s + " " + measurementDefinitionDisplayNames
+ + " for Resource group with id [" + resourceGroupId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Enabled collection of selected metric" + s + ".", "Enabled collection of metric"
+ + s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
+ + resourceGroupId + "].", Message.Severity.Info));
+
+ }
+ });
}
@Override
- protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
this.measurementService.disableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to disable collection of metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Disabled collection of selected metric" + s + ".",
- "Disabled collection of metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId +
- "].", Message.Severity.Info));
-
- }
- });
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to disable collection of metric" + s + " " + measurementDefinitionDisplayNames
+ + " for Resource group with id [" + resourceGroupId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Disabled collection of selected metric" + s + ".", "Disabled collection of metric"
+ + s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
+ + resourceGroupId + "].", Message.Severity.Info));
+
+ }
+ });
}
@Override
protected void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames, final long collectionInterval) {
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames,
+ final long collectionInterval) {
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
- this.measurementService.updateSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds, collectionInterval,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to set collection interval to " + (collectionInterval / 1000)
- + " seconds for metric" + s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
- + resourceGroupId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Updated collection intervals of selected metric" + s + ".",
- "Collection interval for metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId +
- "] set to " + (collectionInterval / 1000) + " seconds.", Message.Severity.Info));
-
- }
- });
+ this.measurementService.updateSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
+ collectionInterval, new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to set collection interval to " + (collectionInterval / 1000) + " seconds for metric"
+ + s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
+ + resourceGroupId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Updated collection intervals of selected metric" + s + ".",
+ "Collection interval for metric" + s + " " + measurementDefinitionDisplayNames
+ + " for Resource group with id [" + resourceGroupId + "] set to "
+ + (collectionInterval / 1000) + " seconds.", Message.Severity.Info));
+
+ }
+ });
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
index 4be1f22..3321237 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
@@ -18,16 +18,17 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits;
+import java.util.List;
+
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitDataSource;
-import java.util.List;
-
/**
* A DataSource for reading traits for the current group.
*
@@ -41,16 +42,16 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
}
@Override
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = super.createFields();
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceIntegerField groupIdField =
- new DataSourceIntegerField(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, "Group Id");
+ DataSourceIntegerField groupIdField = new DataSourceIntegerField(
+ MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, "Group Id");
groupIdField.setHidden(true);
fields.add(0, groupIdField);
- DataSourceTextField resourceNameField =
- new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, "Member Resource");
+ DataSourceTextField resourceNameField = new DataSourceTextField(
+ MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, "Member Resource");
fields.add(0, resourceNameField);
return fields;
@@ -62,8 +63,8 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, this.groupId);
- record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME,
- from.getSchedule().getResource().getName());
+ record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, from.getSchedule().getResource()
+ .getName());
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
index 766df27..2b3a4c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
@@ -25,6 +25,8 @@ import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceD
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -54,31 +56,53 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
public ResourceDatasource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 20);
+ DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 50);
idDataField.setPrimaryKey(true);
+ idDataField.setCanEdit(false);
+ fields.add(idDataField);
DataSourceImageField iconField = new DataSourceImageField("icon", "");
iconField.setImageURLPrefix("types/");
+ fields.add(iconField);
DataSourceTextField nameDataField = new DataSourceTextField(NAME.propertyName(), NAME.title(), 200);
nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField descriptionDataField = new DataSourceTextField(DESCRIPTION.propertyName(), DESCRIPTION
.title());
descriptionDataField.setCanEdit(false);
+ fields.add(descriptionDataField);
DataSourceTextField typeNameDataField = new DataSourceTextField(TYPE.propertyName(), TYPE.title());
+ fields.add(typeNameDataField);
+
DataSourceTextField pluginNameDataField = new DataSourceTextField(PLUGIN.propertyName(), PLUGIN.title());
+ fields.add(pluginNameDataField);
+
DataSourceTextField categoryDataField = new DataSourceTextField(CATEGORY.propertyName(), CATEGORY.title());
+ fields.add(categoryDataField);
DataSourceImageField availabilityDataField = new DataSourceImageField(AVAILABILITY.propertyName(), AVAILABILITY
.title(), 20);
-
availabilityDataField.setCanEdit(false);
+ fields.add(availabilityDataField);
+
+ return fields;
+ }
+
+ @Override
+ public void useDatasourceDefinedFields() {
+ // TODO Auto-generated method stub
- setFields(idDataField, iconField, nameDataField, descriptionDataField, typeNameDataField, pluginNameDataField,
- categoryDataField, availabilityDataField);
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 15bf220..82595af 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -18,13 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
-
import java.util.ArrayList;
import java.util.List;
@@ -96,18 +89,18 @@ public class ResourceSearchView extends Table {
// searchPanel.setFields(searchBox);
final ResourceDatasource datasource = new ResourceDatasource();
- // setTitleComponent(searchPanel);
setDataSource(datasource);
-
}
@Override
protected void configureTable() {
- ListGridField idField = new ListGridField("id", "Id", 55);
- idField.setType(ListGridFieldType.INTEGER);
- //idField.setHidden(true);
- ListGridField iconField = new ListGridField("icon", "", 40);
- ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
+
+ ListGridField iconField = new ListGridField("icon", "Icon", 40);
+ iconField.setType(ListGridFieldType.IMAGE);
+ iconField.setImageURLPrefix("types/");
+
+ ListGridField nameField = new ListGridField(ResourceDataSourceField.NAME.propertyName(),
+ ResourceDataSourceField.NAME.title(), 250);
nameField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
return "<a href=\"" + LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("id")) + "\">" + o
@@ -115,15 +108,25 @@ public class ResourceSearchView extends Table {
}
});
- ListGridField descriptionField = new ListGridField(DESCRIPTION.propertyName(), DESCRIPTION.title());
- ListGridField typeNameField = new ListGridField(TYPE.propertyName(), TYPE.title(), 130);
- ListGridField pluginNameField = new ListGridField(PLUGIN.propertyName(), PLUGIN.title(), 100);
- ListGridField categoryField = new ListGridField(CATEGORY.propertyName(), CATEGORY.title(), 60);
+ ListGridField descriptionField = new ListGridField(ResourceDataSourceField.DESCRIPTION.propertyName(),
+ ResourceDataSourceField.DESCRIPTION.title());
- ListGridField availabilityField = new ListGridField(AVAILABILITY.propertyName(), AVAILABILITY.title(), 55);
+ ListGridField typeNameField = new ListGridField(ResourceDataSourceField.TYPE.propertyName(),
+ ResourceDataSourceField.TYPE.title(), 130);
+
+ ListGridField pluginNameField = new ListGridField(ResourceDataSourceField.PLUGIN.propertyName(),
+ ResourceDataSourceField.PLUGIN.title(), 100);
+
+ ListGridField categoryField = new ListGridField(ResourceDataSourceField.CATEGORY.propertyName(),
+ ResourceDataSourceField.CATEGORY.title(), 60);
+
+ ListGridField availabilityField = new ListGridField(ResourceDataSourceField.AVAILABILITY.propertyName(),
+ ResourceDataSourceField.AVAILABILITY.title(), 55);
+ availabilityField.setType(ListGridFieldType.IMAGE);
availabilityField.setAlign(Alignment.CENTER);
- getListGrid().setFields(idField, iconField, nameField, descriptionField, typeNameField, pluginNameField,
- categoryField, availabilityField);
+
+ setListGridFields(iconField, nameField, descriptionField, typeNameField, pluginNameField, categoryField,
+ availabilityField);
addTableAction(extendLocatorId("Uninventory"), "Uninventory", Table.SelectionEnablement.ANY,
"Are you sure you want to uninventory # resources?", new TableAction() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
index f8387c9..e777bc9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
@@ -19,10 +19,12 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.FieldType;
@@ -45,25 +47,32 @@ public class ConfigurationHistoryDataSource extends RPCDataSource<ResourceConfig
public ConfigurationHistoryDataSource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField resourceField = new DataSourceTextField("resource", "Resource");
- addField(resourceField);
+ fields.add(resourceField);
DataSourceTextField submittedField = new DataSourceTextField("createdTime", "Created");
submittedField.setType(FieldType.DATETIME);
- addField(submittedField);
+ fields.add(submittedField);
DataSourceTextField statusField = new DataSourceTextField("status", "Status");
- addField(statusField);
+ fields.add(statusField);
DataSourceTextField subjectField = new DataSourceTextField("subject", "Subject");
- addField(subjectField);
-
+ fields.add(subjectField);
+ return fields;
}
@Override
@@ -75,31 +84,30 @@ public class ConfigurationHistoryDataSource extends RPCDataSource<ResourceConfig
criteria.setPageControl(getPageControl(request));
- Integer resourceId = (Integer)request.getCriteria().getValues().get("resourceId");
+ Integer resourceId = (Integer) request.getCriteria().getValues().get("resourceId");
if (resourceId != null) {
criteria.addFilterResourceIds(resourceId);
}
configurationService.findResourceConfigurationUpdatesByCriteria(criteria,
- new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Unable to load configuration history", caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
+ new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Unable to load configuration history", caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
-
@Override
public ResourceConfigurationUpdate copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
index f412d7b..0361f65 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
@@ -22,12 +22,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring;
-import java.util.Collection;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -40,7 +40,6 @@ import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
@@ -48,54 +47,58 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*/
public class ResourceScheduledMetricDatasource extends RPCDataSource<MeasurementDefinition> {
-
public ResourceScheduledMetricDatasource() {
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField id = new DataSourceIntegerField("id");
id.setPrimaryKey(true);
- addField(id);
+ fields.add(id);
DataSourceTextField name = new DataSourceTextField("name");
- addField(name);
+ fields.add(name);
DataSourceTextField displayName = new DataSourceTextField("displayName");
- addField(displayName);
+ fields.add(displayName);
DataSourceTextField description = new DataSourceTextField("description");
- addField(description);
+ fields.add(description);
DataSourceTextField units = new DataSourceTextField("units");
- addField(units);
+ fields.add(units);
DataSourceTextField numericType = new DataSourceTextField("numericType");
- addField(numericType);
+ fields.add(numericType);
DataSourceTextField category = new DataSourceTextField("category");
- addField(category);
+ fields.add(category);
+
+ return fields;
}
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
-
-
-
if (request.getCriteria().getValues().containsKey("id")) {
MeasurementDefinitionCriteria criteria = new MeasurementDefinitionCriteria();
criteria.addFilterId(request.getCriteria().getAttributeAsInt("id"));
GWTServiceLookup.getMeasurementDataService().findMeasurementDefinitionsByCriteria(criteria,
- new AsyncCallback<PageList<MeasurementDefinition>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load metric definitions",caught);
- }
-
- public void onSuccess(PageList<MeasurementDefinition> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ new AsyncCallback<PageList<MeasurementDefinition>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load metric definitions", caught);
+ }
+ public void onSuccess(PageList<MeasurementDefinition> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
} else if (request.getCriteria().getValues().containsKey("resourceId")) {
MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
@@ -103,17 +106,17 @@ public class ResourceScheduledMetricDatasource extends RPCDataSource<Measurement
criteria.addFilterResourceId(request.getCriteria().getAttributeAsInt("resourceId"));
-
- GWTServiceLookup.getMeasurementDataService().findMeasurementSchedulesByCriteria(criteria, new AsyncCallback<PageList<MeasurementSchedule>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load metric schedules", caught);
- }
-
- public void onSuccess(PageList<MeasurementSchedule> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ GWTServiceLookup.getMeasurementDataService().findMeasurementSchedulesByCriteria(criteria,
+ new AsyncCallback<PageList<MeasurementSchedule>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load metric schedules", caught);
+ }
+
+ public void onSuccess(PageList<MeasurementSchedule> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
} else {
processResponse(request.getRequestId(), response);
}
@@ -131,10 +134,9 @@ public class ResourceScheduledMetricDatasource extends RPCDataSource<Measurement
return buildRecords(definitions);
}
-
@Override
public MeasurementDefinition copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
index 5efbcca..843e2af 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
@@ -18,9 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.calltime;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.HTMLFlow;
@@ -41,20 +44,28 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
private double maxMaximum;
public CallTimeDataSource() {
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceTextField callDestination = new DataSourceTextField("callDestination", "Call Destination");
- addField(callDestination);
+ fields.add(callDestination);
DataSourceIntegerField count = new DataSourceIntegerField("count");
- addField(count);
+ fields.add(count);
DataSourceIntegerField minimum = new DataSourceIntegerField("minimum");
- addField(minimum);
+ fields.add(minimum);
DataSourceIntegerField average = new DataSourceIntegerField("average");
- addField(average);
+ fields.add(average);
DataSourceIntegerField maximum = new DataSourceIntegerField("maximum");
- addField(maximum);
+ fields.add(maximum);
DataSourceIntegerField total = new DataSourceIntegerField("total");
- addField(total);
+ fields.add(total);
+ return fields;
}
@Override
@@ -66,21 +77,20 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
PageControl pc = getPageControl(request);
- GWTServiceLookup.getMeasurementDataService().findCallTimeDataForResource(
- scheduleId, eightHoursAgo, now, pc, new AsyncCallback<PageList<CallTimeDataComposite>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Could not load call time data", caught);
- }
+ GWTServiceLookup.getMeasurementDataService().findCallTimeDataForResource(scheduleId, eightHoursAgo, now, pc,
+ new AsyncCallback<PageList<CallTimeDataComposite>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Could not load call time data", caught);
+ }
- public void onSuccess(PageList<CallTimeDataComposite> result) {
- ListGridRecord[] data = buildRecords(result);
- setGraphs(data);
- response.setData(data);
+ public void onSuccess(PageList<CallTimeDataComposite> result) {
+ ListGridRecord[] data = buildRecords(result);
+ setGraphs(data);
+ response.setData(data);
- processResponse(request.getRequestId(), response);
- }
+ processResponse(request.getRequestId(), response);
}
- );
+ });
}
@Override
@@ -100,13 +110,10 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
int avgWidth = (int) ((record.getAttributeAsInt("average") / maxMaximum) * 100d);
int maxWidth = (int) ((record.getAttributeAsInt("maximum") / maxMaximum) * 100d);
-
-
- record.setBackgroundComponent(
- new HTMLFlow(
- "<div style=\"width: " + minWidth + "%; height: 33%; background-color: #A5B391;\"> </div>" +
- "<div style=\"width: " + avgWidth + "%; height: 33%; background-color: #A5B391;\"> </div>" +
- "<div style=\"width: " + maxWidth + "%; height: 33%; background-color: #A5B391;\"> </div>"));
+ record.setBackgroundComponent(new HTMLFlow("<div style=\"width: " + minWidth
+ + "%; height: 33%; background-color: #A5B391;\"> </div>" + "<div style=\"width: " + avgWidth
+ + "%; height: 33%; background-color: #A5B391;\"> </div>" + "<div style=\"width: " + maxWidth
+ + "%; height: 33%; background-color: #A5B391;\"> </div>"));
}
@@ -124,7 +131,6 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
record.setAttribute("maximum", from.getMaximum());
record.setAttribute("total", from.getTotal());
-
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java
index 21fe764..ac7c8dd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
@@ -35,8 +37,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasuremen
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import java.util.List;
-
/**
* A DataSource for reading and updating the metric schedules for the current Resource.
*
@@ -51,12 +51,14 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
}
@Override
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = super.createFields();
- DataSourceField resourceIdField = new DataSourceIntegerField(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_ID,
- "Resource Id");
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceField resourceIdField = new DataSourceIntegerField(
+ MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_ID, "Resource Id");
resourceIdField.setHidden(true);
fields.add(resourceIdField);
+
return fields;
}
@@ -76,67 +78,70 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
@Override
protected void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
- this.measurementService.enableSchedulesForResource(this.resourceId, measurementDefinitionIds,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to enable collection of metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Enabled collection of metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId +
- "].", Message.Severity.Info));
-
- }
- });
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ this.measurementService.enableSchedulesForResource(this.resourceId, measurementDefinitionIds,
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to enable collection of metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Enabled collection of metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "].", Message.Severity.Info));
+
+ }
+ });
}
@Override
- protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
- this.measurementService.disableSchedulesForResource(this.resourceId, measurementDefinitionIds,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to disable collection of metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Disabled collection of metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId +
- "].", Message.Severity.Info));
-
- }
- });
+ protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ this.measurementService.disableSchedulesForResource(this.resourceId, measurementDefinitionIds,
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to disable collection of metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Disabled collection of metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "].", Message.Severity.Info));
+
+ }
+ });
}
@Override
protected void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames, final long collectionInterval) {
- this.measurementService.updateSchedulesForResource(this.resourceId, measurementDefinitionIds, collectionInterval,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to set collection interval to " + (collectionInterval / 1000)
- + " seconds for metrics " + measurementDefinitionDisplayNames + " for Resource with id ["
- + resourceId + "].",
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames,
+ final long collectionInterval) {
+ this.measurementService.updateSchedulesForResource(this.resourceId, measurementDefinitionIds,
+ collectionInterval, new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to set collection interval to " + (collectionInterval / 1000) + " seconds for metrics "
+ + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId + "].",
throwable);
- }
+ }
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Collection interval for metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId +
- "] set to " + (collectionInterval / 1000) + " seconds.", Message.Severity.Info));
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Collection interval for metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "] set to " + (collectionInterval / 1000)
+ + " seconds.", Message.Severity.Info));
- }
- });
+ }
+ });
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java
index c569260..67a330a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java
@@ -18,28 +18,29 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.traits;
-import com.smartgwt.client.data.DSRequest;
+import java.util.List;
+
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitDataSource;
-import java.util.List;
-
/**
* A DataSource for reading traits for the current Resource.
*
* @author Ian Springer
*/
public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
+
@Override
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = super.createFields();
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceIntegerField resourceIdField =
- new DataSourceIntegerField(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, "Resource Id");
+ DataSourceIntegerField resourceIdField = new DataSourceIntegerField(
+ MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, "Resource Id");
resourceIdField.setHidden(true);
fields.add(0, resourceIdField);
@@ -50,7 +51,8 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
public ListGridRecord copyValues(MeasurementDataTrait from) {
ListGridRecord record = super.copyValues(from);
- record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, from.getSchedule().getResource().getId());
+ record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, from.getSchedule().getResource()
+ .getId());
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
index c353fdb..9af5c3b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
@@ -19,10 +19,12 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.FieldType;
@@ -43,51 +45,57 @@ public class OperationHistoryDataSource extends RPCDataSource<ResourceOperationH
private OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
-
public OperationHistoryDataSource() {
- super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField("operationName");
- addField(nameField);
+ fields.add(nameField);
DataSourceTextField resourceField = new DataSourceTextField("resource");
- addField(resourceField);
+ fields.add(resourceField);
DataSourceTextField statusField = new DataSourceTextField("status");
- addField(statusField);
+ fields.add(statusField);
DataSourceTextField startedField = new DataSourceTextField("startedTime");
startedField.setType(FieldType.DATETIME);
- addField(startedField);
+ fields.add(startedField);
+
+ return fields;
}
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
-
if (request.getCriteria().getValues().containsKey("resourceId")) {
- criteria.addFilterResourceIds(Integer.parseInt((String) request.getCriteria().getValues().get("resourceId")));
+ criteria.addFilterResourceIds(Integer
+ .parseInt((String) request.getCriteria().getValues().get("resourceId")));
}
criteria.setPageControl(getPageControl(request));
- operationService.findResourceOperationHistoriesByCriteria(
- criteria, new AsyncCallback<PageList<ResourceOperationHistory>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failure loading operation histories", caught);
- }
+ operationService.findResourceOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceOperationHistory>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failure loading operation histories", caught);
+ }
- public void onSuccess(PageList<ResourceOperationHistory> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
+ public void onSuccess(PageList<ResourceOperationHistory> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
}
- );
+ });
}
@Override
@@ -110,7 +118,7 @@ public class OperationHistoryDataSource extends RPCDataSource<ResourceOperationH
record.setAttribute("status", from.getStatus().name());
record.setAttribute("parameters", from.getParameters());
- record.setAttribute("entity",from);
+ record.setAttribute("entity", from);
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
index 1843f2b..39e99af 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
@@ -22,22 +22,22 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
import java.util.Date;
import java.util.List;
-import org.rhq.core.domain.resource.ResourceError;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-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.util.RPCDataSource;
-
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.fields.DataSourceDateField;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceEnumField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.resource.ResourceError;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+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.util.RPCDataSource;
+
/**
*
* @author Lukas Krejci
@@ -55,10 +55,20 @@ public class ResourceErrorsDataSource extends RPCDataSource<ResourceError> {
public ResourceErrorsDataSource(int resourceId) {
resourceService = GWTServiceLookup.getResourceService();
this.resourceId = resourceId;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ fields.add(new DataSourceTextField(SUMMARY_ID, "Summary"));
+ fields.add(new DataSourceTextField(DETAIL_ID, "Detailed Message"));
+ fields.add(new DataSourceEnumField(ERROR_TYPE_ID, "Error Type"));
+ fields.add(new DataSourceDateTimeField(TIME_OCCURED_ID, "Time"));
- addFields(new DataSourceTextField(SUMMARY_ID, "Summary"),
- new DataSourceTextField(DETAIL_ID, "Detailed Message"),
- new DataSourceEnumField(ERROR_TYPE_ID, "Error Type"), new DataSourceDateTimeField(TIME_OCCURED_ID, "Time"));
+ return fields;
}
/* (non-Javadoc)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
index 5e6d943..9546d66 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
@@ -194,7 +194,8 @@ public class SearchBarPane extends LocatableHLayout {
comboBox.setShowIfCondition(new FormItemIfFunction() {
public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return dynamicForm.getValueAsString("searchType").equals(searchType.getDisplayName());
+ String value = dynamicForm.getValueAsString("searchType");
+ return (null != value && value.equals(searchType.getDisplayName()));
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
index 863afe2..24ada45 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
@@ -24,6 +24,7 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -69,18 +70,31 @@ public class RecentOperationsDataSource extends
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField resourceField = new DataSourceTextField(resource, "Resource");
resourceField.setPrimaryKey(true);
+ fields.add(resourceField);
DataSourceTextField locationField = new DataSourceTextField(location, "Location", 200);
+ fields.add(locationField);
DataSourceTextField operationField = new DataSourceTextField(operation, "Operation");
+ fields.add(operationField);
DataSourceDateTimeField timeField = new DataSourceDateTimeField(time, "Date/Time");
+ fields.add(timeField);
DataSourceTextField statusField = new DataSourceTextField(status, "Status");
+ fields.add(statusField);
- setFields(resourceField, locationField, operationField, timeField, statusField);
+ return fields;
}
/* Intercept DSRequest object to pipe into custom fetch request.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index ebb1185..ab28a8e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -24,7 +24,9 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
@@ -63,16 +65,28 @@ public class ScheduledOperationsDataSource extends
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField resourceField = new DataSourceTextField(resource, "Resource");
resourceField.setPrimaryKey(true);
+ fields.add(resourceField);
- DataSourceTextField locationField = new DataSourceTextField(location, "Location");
+ DataSourceTextField locationField = new DataSourceTextField(location, "Location", 200);
+ fields.add(locationField);
DataSourceTextField operationField = new DataSourceTextField(operation, "Operation");
+ fields.add(operationField);
- DataSourceTextField timeField = new DataSourceTextField(time, "Date/Time");
+ DataSourceDateTimeField timeField = new DataSourceDateTimeField(time, "Date/Time");
+ fields.add(timeField);
- setFields(resourceField, locationField, operationField, timeField);
+ return fields;
}
/* Intercept DSRequest object to pipe into custom fetch request.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
index 6a31020..d513e70 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
@@ -23,10 +23,12 @@
package org.rhq.enterprise.gui.coregui.client.report.measurement;
import java.util.Collection;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -47,48 +49,53 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
private int maximumFactor = 0;
public MeasurementOOBDataSource() {
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceTextField metricField = new DataSourceTextField("scheduleName","Metric");
- addField(metricField);
+ DataSourceTextField metricField = new DataSourceTextField("scheduleName", "Metric");
+ fields.add(metricField);
DataSourceTextField resourceField = new DataSourceTextField("resourceName", "Resource");
- addField(resourceField);
+ fields.add(resourceField);
DataSourceTextField parentField = new DataSourceTextField("parentName", "Parent");
- addField(parentField);
+ fields.add(parentField);
DataSourceTextField bandField = new DataSourceTextField("formattedBaseband", "Band");
- addField(bandField);
+ fields.add(bandField);
DataSourceTextField outlierField = new DataSourceTextField("formattedOutlier", "Outlier");
- addField(outlierField);
+ fields.add(outlierField);
DataSourceTextField factorField = new DataSourceTextField("factor", "Out of range factor (%)");
- addField(factorField);
+ fields.add(factorField);
- }
+ return fields;
+ }
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
PageControl pc = getPageControl(request);
- GWTServiceLookup.getMeasurementDataService().getSchedulesWithOOBs(
- null, null, null, pc,
- new AsyncCallback<PageList<MeasurementOOBComposite>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load measurement OOB information",caught);
- }
-
- public void onSuccess(PageList<MeasurementOOBComposite> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
+ GWTServiceLookup.getMeasurementDataService().getSchedulesWithOOBs(null, null, null, pc,
+ new AsyncCallback<PageList<MeasurementOOBComposite>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load measurement OOB information", caught);
}
- );
+
+ public void onSuccess(PageList<MeasurementOOBComposite> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
@@ -97,7 +104,6 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
throw new UnsupportedOperationException("OOBs Read only");
}
-
@Override
public ListGridRecord[] buildRecords(Collection<MeasurementOOBComposite> list) {
for (MeasurementOOBComposite oob : list) {
@@ -128,20 +134,18 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
record.setAttribute("parentId", from.getParentId());
record.setAttribute("parentName", from.getParentName());
- int factorRankingWidth = (int) (((double)from.getFactor())/ (double)maximumFactor * 100d);
+ int factorRankingWidth = (int) (((double) from.getFactor()) / (double) maximumFactor * 100d);
- record.setBackgroundComponent(
- new HTMLFlow(
- "<div style=\"width: " + factorRankingWidth + "%; height: 100%; background-color: #A5B391;\"> </div>"));
+ record.setBackgroundComponent(new HTMLFlow("<div style=\"width: " + factorRankingWidth
+ + "%; height: 100%; background-color: #A5B391;\"> </div>"));
return record;
}
-
private void applyFormatting(MeasurementOOBComposite oob) {
- oob.setFormattedOutlier(MeasurementConverterClient.format(oob.getOutlier(), oob.getUnits(), true));
- formatBaseband(oob);
+ oob.setFormattedOutlier(MeasurementConverterClient.format(oob.getOutlier(), oob.getUnits(), true));
+ formatBaseband(oob);
}
private void formatBaseband(MeasurementOOBComposite oob) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index 38c316b..e7c8050 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -24,6 +24,7 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.fields.DataSourceImageField;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -66,16 +67,28 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField resourceField = new DataSourceTextField(resource, "Resource");
resourceField.setPrimaryKey(true);
+ fields.add(resourceField);
DataSourceTextField locationField = new DataSourceTextField(location, "Location");
+ fields.add(locationField);
DataSourceTextField alertsField = new DataSourceTextField(alerts, "Alerts");
+ fields.add(alertsField);
- DataSourceImageField availablilityField = new DataSourceImageField(available, "Current Availability");
+ DataSourceImageField availabilityField = new DataSourceImageField(available, "Current Availability");
+ fields.add(availabilityField);
- setFields(resourceField, locationField, alertsField, availablilityField);
+ return fields;
}
/* Intercept DSRequest object to pipe into custom fetch request.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index 86ab57e..38a9386 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -18,8 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.util;
-import java.util.Arrays;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -40,6 +40,7 @@ import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.effects.ColoringUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* Base GWT-RPC oriented DataSource class.
@@ -58,7 +59,7 @@ public abstract class RPCDataSource<T> extends DataSource {
public RPCDataSource(String name) {
if (name != null) {
com.allen_sauer.gwt.log.client.Log.info("Trying to build DS: " + name);
- setID(name);
+ setID(SeleniumUtility.getSafeId(name));
}
// TODO until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed always go to the server for data
setClientOnly(false);
@@ -68,6 +69,22 @@ public abstract class RPCDataSource<T> extends DataSource {
setDataFormat(DSDataFormat.CUSTOM);
}
+ /**
+ * Override in each subclass to set the default ds fields for the ds. The datasource should not
+ * define and set ds fields in the constructor in case a user of the ds wants to set their own. For example,
+ * those that want to use list grid fields (like our list views).
+ */
+ public void useDatasourceDefinedFields() {
+ }
+
+ /**
+ * A pattern that can be used for Datasource subclassing. Each subclass can add it's own fields prior to
+ * all of the fields being added to the datasource.
+ */
+ protected List<DataSourceField> addDataSourceFields() {
+ return new ArrayList<DataSourceField>();
+ }
+
@Override
protected Object transformRequest(DSRequest request) {
try {
@@ -229,7 +246,7 @@ public abstract class RPCDataSource<T> extends DataSource {
addField(field);
}
}
-
+
public void addFields(DataSourceField... fields) {
addFields(Arrays.asList(fields));
}
commit f767f233ffb2cea9cb3f2a69a20af0a4b9cd4960
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Oct 15 14:23:14 2010 -0400
bad things happen when gwt attempts to serialize alert defs return values via RPC calls.
this checks for null values getting passed into setters and avoids NPEs.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index 31be645..a288cad 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -519,7 +519,9 @@ public class AlertDefinition implements Serializable {
public void setResource(Resource resource) {
this.resource = resource;
- this.resource.getAlertDefinitions().add(this);
+ if (this.resource != null) {
+ this.resource.getAlertDefinitions().add(this);
+ }
}
public ResourceGroup getResourceGroup() {
@@ -652,9 +654,11 @@ public class AlertDefinition implements Serializable {
}
public void setConditions(Set<AlertCondition> conditions) {
- this.conditions.clear();
- for (AlertCondition condition : conditions) {
- addCondition(condition);
+ removeAllConditions();
+ if (conditions != null) {
+ for (AlertCondition condition : conditions) {
+ addCondition(condition);
+ }
}
}
@@ -684,6 +688,9 @@ public class AlertDefinition implements Serializable {
}
public void setAlertNotifications(List<AlertNotification> alertNotifications) {
+ if (alertNotifications == null) {
+ alertNotifications = new ArrayList<AlertNotification>();
+ }
this.alertNotifications = alertNotifications;
}
commit e486ae34722cff4146a22d446a99f4a2d95d4659
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Oct 14 23:55:21 2010 -0400
A temporary fix for getting around the ResourceSearchView not rendering
issue. This is a precursor to a more comprehensive change that aims to
solve issues regarding grid field vs ds field use.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 7c6aaf9..15bf220 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -105,7 +105,7 @@ public class ResourceSearchView extends Table {
protected void configureTable() {
ListGridField idField = new ListGridField("id", "Id", 55);
idField.setType(ListGridFieldType.INTEGER);
- idField.setHidden(true);
+ //idField.setHidden(true);
ListGridField iconField = new ListGridField("icon", "", 40);
ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
nameField.setCellFormatter(new CellFormatter() {
commit 2dfe611b1651f7312816b114b684fb90ec5f6854
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Oct 14 17:09:28 2010 -0400
group alert definition editor. there are still things broken in here. more stuff needs to be fixed/tested
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
index 8096fcf..f0916e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
@@ -86,6 +86,7 @@
<servlet path="/ContentGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.ContentGWTServiceImpl"/>
<servlet path="/DashboardGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.DashboardGWTServiceImpl"/>
<servlet path="/EventGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.EventGWTServiceImpl"/>
+ <servlet path="/GroupAlertDefinitionGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.GroupAlertDefinitionGWTServiceImpl"/>
<servlet path="/MeasurementDataGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.MeasurementDataGWTServiceImpl"/>
<servlet path="/OperationGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.OperationGWTServiceImpl"/>
<servlet path="/RemoteInstallGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.RemoteInstallGWTServiceImpl"/>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
index 183faec..e632915 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -26,15 +26,21 @@ package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
import java.util.EnumSet;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.MetadataType;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/**
* @author John Mazzitelli
@@ -44,10 +50,12 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
public static final String CRITERIA_GROUP_ID = "groupId";
private ResourceGroup group;
+ private ResourcePermission permissions;
- public GroupAlertDefinitionsView(String locatorId, ResourceGroup group) {
+ public GroupAlertDefinitionsView(String locatorId, ResourceGroupComposite groupComposite) {
super(locatorId, "Group Alert Definitions");
- this.group = group;
+ this.group = groupComposite.getResourceGroup();
+ this.permissions = groupComposite.getResourcePermission();
// make sure we loaded all the type info we'll need. if one of these is null, either the type
// doesn't have it or we haven't loaded it yet. since we can't know for sure if it was loaded, we have to ask.
@@ -86,55 +94,140 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
+ public SingleAlertDefinitionView getDetailsView(int id) {
+ SingleAlertDefinitionView view = super.getDetailsView(id);
+ if (id == 0) {
+ // when creating a new alert def, make sure to set this in the new alert def
+ view.getAlertDefinition().setResourceGroup(group);
+ }
+ return view;
+ }
+
+ @Override
protected boolean isAllowedToModifyAlertDefinitions() {
- // TODO: see if user can modify group alerts on this group
- return true;
+ return this.permissions.isAlert();
}
@Override
protected void newButtonPressed(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
- String str = "this is not implemented yet but you selected";
- for (ListGridRecord record : selection) {
- str += ": " + record.getAttribute("name");
- }
- SC.say(str);
+ newDetails();
}
@Override
protected void enableButtonPressed(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
- String str = "this is not implemented yet but you selected";
+ if (selection.length == 0) {
+ return;
+ }
+
+ Integer[] alertDefIds = new Integer[selection.length];
+ int i = 0;
for (ListGridRecord record : selection) {
- str += ": " + record.getAttribute("name");
+ Integer id = record.getAttributeAsInt(AbstractAlertDefinitionsDataSource.FIELD_ID);
+ alertDefIds[i++] = id;
}
- SC.say(str);
+
+ GWTServiceLookup.getGroupAlertDefinitionService().enableGroupAlertDefinitions(alertDefIds,
+ new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("[" + result + "] group alert definitions enabled.", Severity.Info));
+ GroupAlertDefinitionsView.this.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to enable group alert definitions", caught);
+ }
+ });
}
@Override
protected void disableButtonPressed(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
- String str = "this is not implemented yet but you selected";
+ if (selection.length == 0) {
+ return;
+ }
+
+ Integer[] alertDefIds = new Integer[selection.length];
+ int i = 0;
for (ListGridRecord record : selection) {
- str += ": " + record.getAttribute("name");
+ Integer id = record.getAttributeAsInt(AbstractAlertDefinitionsDataSource.FIELD_ID);
+ alertDefIds[i++] = id;
}
- SC.say(str);
+ GWTServiceLookup.getGroupAlertDefinitionService().disableGroupAlertDefinitions(alertDefIds,
+ new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("[" + result + "] group alert definitions disabled.", Severity.Info));
+ GroupAlertDefinitionsView.this.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to disable group alert definitions.", caught);
+ }
+ });
}
@Override
protected void deleteButtonPressed(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
- String str = "this is not implemented yet but you selected";
+ if (selection.length == 0) {
+ return;
+ }
+
+ Integer[] alertDefIds = new Integer[selection.length];
+ int i = 0;
for (ListGridRecord record : selection) {
- str += ": " + record.getAttribute("name");
+ Integer id = record.getAttributeAsInt(AbstractAlertDefinitionsDataSource.FIELD_ID);
+ alertDefIds[i++] = id;
}
- SC.say(str);
+ GWTServiceLookup.getGroupAlertDefinitionService().removeGroupAlertDefinitions(alertDefIds,
+ new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("[" + result + "] group alert definitions deleted.", Severity.Info));
+ GroupAlertDefinitionsView.this.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to delete group alert definitions.", caught);
+ }
+ });
}
@Override
- protected void commitAlertDefinition(AlertDefinition alertDefinition) {
- // TODO call into server SLSB to store alert def
- // GroupAlertDefinitionManagerLocal groupAlertDefinitionManager = LookupUtil.getGroupAlertDefinitionManager();
- // groupAlertDefinitionManager.updateGroupAlertDefinitions(subject, alertDef, true);
+ protected void commitAlertDefinition(final AlertDefinition alertDefinition) {
+ if (alertDefinition.getId() == 0) {
+ GWTServiceLookup.getGroupAlertDefinitionService().createGroupAlertDefinitions(alertDefinition,
+ Integer.valueOf(this.group.getId()), new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(new Message("Alert definition is created", Severity.Info));
+ alertDefinition.setId(result.intValue());
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to create alert definition.", caught);
+ }
+ });
+ } else {
+ GWTServiceLookup.getGroupAlertDefinitionService().updateGroupAlertDefinitions(alertDefinition, true,
+ new AsyncCallback<AlertDefinition>() {
+ @Override
+ public void onSuccess(AlertDefinition result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Group alert definition is updated.", Severity.Info));
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to update group alert definition.", caught);
+ }
+ });
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
index 3bc7a3f..f53710f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
@@ -70,9 +70,8 @@ public class ResourceAlertDefinitionsDataSource extends AbstractAlertDefinitions
+ this.resource.getResourceType().getId() + "&from=" + from.getId() + "&ad=" + parentId);
record.setLinkText("View Template");
} else {
- record.setAttribute(FIELD_PARENT, "/alerts/Config.do?mode=viewRoles&groupId="
- + groupAlertDefinition.getResourceGroup().getId() + "&from=" + from.getId() + "&ad="
- + groupAlertDefinition.getId());
+ record.setAttribute(FIELD_PARENT, "#ResourceGroup/" + groupAlertDefinition.getResourceGroup().getId()
+ + "/Alerts/Definitions/" + groupAlertDefinition.getId());
record.setLinkText("View Group Definition");
}
record.setAttribute(FIELD_READONLY, readOnly);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
index ebd0ab5..adc839d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
@@ -39,6 +39,10 @@ public class GWTServiceLookup {
return secure(AlertDefinitionGWTServiceAsync.Util.getInstance());
}
+ public static GroupAlertDefinitionGWTServiceAsync getGroupAlertDefinitionService() {
+ return secure(GroupAlertDefinitionGWTServiceAsync.Util.getInstance());
+ }
+
public static ConfigurationGWTServiceAsync getConfigurationService() {
return secure(ConfigurationGWTServiceAsync.Util.getInstance());
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GroupAlertDefinitionGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GroupAlertDefinitionGWTService.java
new file mode 100644
index 0000000..ff4299e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GroupAlertDefinitionGWTService.java
@@ -0,0 +1,45 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License 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.gwt;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+
+public interface GroupAlertDefinitionGWTService extends RemoteService {
+
+ int createGroupAlertDefinitions(AlertDefinition groupAlertDefinition, Integer resourceGroupId) throws Exception;
+
+ /**
+ * Updates a group alert definition.
+ *
+ * @param groupAlertDefinition
+ * @param purgeInternals must be true if you are updating conditions or dampening settings, can be false otherwise
+ * @return the updated definition
+ * @throws Exception
+ */
+ AlertDefinition updateGroupAlertDefinitions(AlertDefinition groupAlertDefinition, boolean purgeInternals)
+ throws Exception;
+
+ int enableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception;
+
+ int disableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception;
+
+ int removeGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception;
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 4f71441..225de69 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -40,6 +40,7 @@ import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.alert.definitions.GroupAlertDefinitionsView;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
@@ -265,6 +266,11 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
.extendLocatorId("CompositeHistView"), groupComposite), true, true);
}
+ // alerts tab is always visible
+ // TODO what about history subtab?
+ updateSubTab(this.alertsTab, this.alertDef, new GroupAlertDefinitionsView(alertsTab
+ .extendLocatorId("AlertDefView"), this.groupComposite), true, true);
+
this.show();
markForRedraw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java
new file mode 100644
index 0000000..7b65ee2
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java
@@ -0,0 +1,90 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License 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.server.gwt;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.enterprise.gui.coregui.client.gwt.GroupAlertDefinitionGWTService;
+import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
+import org.rhq.enterprise.server.alert.GroupAlertDefinitionManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+public class GroupAlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implements
+ GroupAlertDefinitionGWTService {
+ private static final long serialVersionUID = 1L;
+
+ private GroupAlertDefinitionManagerLocal groupAlertDefManager = LookupUtil.getGroupAlertDefinitionManager();
+
+ @Override
+ public int createGroupAlertDefinitions(AlertDefinition groupAlertDefinition, Integer resourceGroupId)
+ throws Exception {
+ try {
+ int results = groupAlertDefManager.createGroupAlertDefinitions(getSessionSubject(), groupAlertDefinition,
+ resourceGroupId);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public AlertDefinition updateGroupAlertDefinitions(AlertDefinition groupAlertDefinition, boolean purgeInternals)
+ throws Exception {
+ try {
+ AlertDefinition results = groupAlertDefManager.updateGroupAlertDefinitions(getSessionSubject(),
+ groupAlertDefinition, purgeInternals);
+ return SerialUtility.prepare(results, "updateGroupAlertDefinitions");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public int enableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception {
+ try {
+ int results = groupAlertDefManager
+ .enableGroupAlertDefinitions(getSessionSubject(), groupAlertDefinitionIds);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public int disableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception {
+ try {
+ int results = groupAlertDefManager.disableGroupAlertDefinitions(getSessionSubject(),
+ groupAlertDefinitionIds);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public int removeGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception {
+ try {
+ int results = groupAlertDefManager
+ .removeGroupAlertDefinitions(getSessionSubject(), groupAlertDefinitionIds);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
index 377ae0d..40e7f16 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
@@ -42,18 +42,19 @@
</servlet>
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AlertGWTService</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AlertGWTServiceImpl
- </servlet-class>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AlertGWTServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AlertDefinitionGWTService</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AlertDefinitionGWTServiceImpl
- </servlet-class>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AlertDefinitionGWTServiceImpl</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI GroupAlertDefinitionGWTService</servlet-name>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.GroupAlertDefinitionGWTServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI OperationGWTService</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.OperationGWTServiceImpl
- </servlet-class>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.OperationGWTServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI BundleGWTService</servlet-name>
@@ -158,6 +159,10 @@
<url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/AlertDefinitionGWTService</url-pattern>
</servlet-mapping>
<servlet-mapping>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI GroupAlertDefinitionGWTService</servlet-name>
+ <url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/GroupAlertDefinitionGWTService</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI OperationGWTService</servlet-name>
<url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/OperationGWTService</url-pattern>
</servlet-mapping>
13 years, 8 months
[rhq] modules/plugins
by Heiko W. Rupp
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java | 211 ++++++----
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionInfo.java | 92 ++++
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionManager.java | 124 +++++
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseComponent.java | 167 +++++++
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java | 65 +--
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDiscoveryComponent.java | 99 ++--
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlPluginLifecycleListener.java | 28 -
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableComponent.java | 129 ++++++
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableDiscoveryComponent.java | 85 ++++
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserComponent.java | 128 ++++++
modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserDiscoveryComponent.java | 76 +++
modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml | 112 ++---
12 files changed, 1080 insertions(+), 236 deletions(-)
New commits:
commit 28ae734397d49586094f973c0db81f06fc394791
Author: Steve Millidge <smillidge(a)c2b2.co.uk>
Date: Mon Oct 18 11:13:29 2010 +0200
Huge Improvement of the MySQL plugin.
This included autodiscovery of MySQL, databases and users.
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 737634b..f38b944 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
@@ -16,11 +16,15 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
package org.rhq.plugins.mysql;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
@@ -33,129 +37,184 @@ import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.plugins.database.DatabaseComponent;
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;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.pluginapi.event.EventPoller;
+import org.rhq.core.system.AggregateProcessInfo;
+import org.rhq.core.system.ProcessInfo;
+import org.rhq.plugins.database.DatabaseQueryUtility;
/**
* @author Greg Hinkle
+ * @author Steve Millidge
*/
public class MySqlComponent implements DatabaseComponent, ResourceComponent, MeasurementFacet {
private ResourceContext resourceContext;
- private Connection connection;
- private static final Log log = LogFactory.getLog(MySqlComponent.class);
+ private AggregateProcessInfo aggregateProcessInfo;
+ private MySqlConnectionInfo info;
+ private Log log = LogFactory.getLog(this.getClass());
+ private Map<String, String> globalStatusValues = new HashMap<String, String>();
+ private Map<String, String> globalVariables = new HashMap<String, String>();
public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception {
this.resourceContext = resourceContext;
- getConnection();
+ info = MySqlDiscoveryComponent.buildConnectionInfo(resourceContext.getPluginConfiguration());
+ ProcessInfo processInfo = resourceContext.getNativeProcess();
+ if (processInfo != null) {
+ aggregateProcessInfo = processInfo.getAggregateProcessTree();
+ } else {
+ //findProcessInfo();
+ //log.debug("Unable to locate native process information. Process level statistics will be unavailable.");
+ }
}
public void stop() {
- try {
- this.connection.close();
- } catch (SQLException e) {
- log.warn(e);
- }
+ MySqlConnectionManager.getConnectionManager().closeConnection(info);
}
public AvailabilityType getAvailability() {
+ if (log.isDebugEnabled()) {
+ log.debug("Doing an availability check on " + info.buildURL());
+ }
- try {
- getConnection().createStatement().executeQuery("select 1");
- return AvailabilityType.UP;
- } catch (SQLException e) {
- if (log.isDebugEnabled()) {
- log.debug("getAvail failed: " + e.getMessage());
- }
- return AvailabilityType.DOWN;
+ Connection conn = getConnection();
+ AvailabilityType result = AvailabilityType.DOWN;
+ if (conn != null) {
+ // the connection must be OK as the validity check will have worked
+ result = AvailabilityType.UP;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Availability check on " + info.buildURL() + " gives " + result);
}
+ return result;
+
}
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
+ Connection conn = getConnection();
+ if (conn != null) {
+ ResultSet rs = null;
+ Statement stmt = null;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("SHOW GLOBAL STATUS");
+ while (rs.next()) {
+ globalStatusValues.put(rs.getString(1), rs.getString(2));
+ }
- ResultSet rs = getConnection().createStatement().executeQuery("SHOW /*!50002 GLOBAL */ STATUS");
-
- Map<String, String> values = new HashMap<String, String>();
- while (rs.next()) {
- values.put(rs.getString(1), rs.getString(2));
+ rs.close();
+ rs = stmt.executeQuery("select * from information_schema.global_variables");
+ while (rs.next()) {
+ globalVariables.put(rs.getString(1), rs.getString(2));
+ }
+ } catch (SQLException sqle) {
+ } finally {
+ DatabaseQueryUtility.close(stmt, rs);
+ }
}
-
+ // get process information
+ aggregateProcessInfo = findProcessInfo();
for (MeasurementScheduleRequest request : metrics) {
- if (!request.getName().startsWith("Process")) {
-
+ String requestName = request.getName();
+ if (requestName.startsWith("Process") && aggregateProcessInfo != null) {
+ aggregateProcessInfo.refresh();
+ if ("Process.aggregateMemory.resident".equals(requestName)) {
+ long mem = aggregateProcessInfo.getAggregateMemory().getResident();
+ report.addData(new MeasurementDataNumeric(request, new Double((double) mem)));
+ } 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)) {
+ long value = aggregateProcessInfo.getAggregateMemory().getPageFaults();
+ report.addData(new MeasurementDataNumeric(request, new Double((double) value)));
+ } else if ("Process.aggregateCpu.user".equals(requestName)) {
+ long value = aggregateProcessInfo.getAggregateCpu().getUser();
+ report.addData(new MeasurementDataNumeric(request, new Double((double) value)));
+ } else if ("Process.aggregateCpu.sys".equals(requestName)) {
+ long value = aggregateProcessInfo.getAggregateCpu().getSys();
+ report.addData(new MeasurementDataNumeric(request, new Double((double) value)));
+ } 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)) {
+ long value = aggregateProcessInfo.getAggregateCpu().getTotal();
+ 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)));
+ }
+ } else {
if (request.getDataType() == DataType.MEASUREMENT) {
try {
- String strVal = values.get(request.getName());
+ String strVal = globalStatusValues.get(request.getName());
double val = Double.parseDouble(strVal);
report.addData(new MeasurementDataNumeric(request, val));
- } catch (Exception e) { }
+ } catch (Exception e) {
+ }
}
}
}
}
-
-
-
-
public Connection getConnection() {
try {
- this.connection = MySqlDiscoveryComponent.buildConnection(resourceContext.getPluginConfiguration());
-
- } catch (SQLException e) {
- if (log.isDebugEnabled()) {
- log.debug("getAvail failed: " + e.getMessage());
- }
+ return MySqlConnectionManager.getConnectionManager().getConnection(info);
+ } catch (SQLException ex) {
+ log.warn("Unable to obtain database connection ", ex);
+ return null;
}
- return connection;
}
+ @Override
public void removeConnection() {
- this.connection = null;
+ MySqlConnectionManager.getConnectionManager().closeConnection(info);
}
- public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
-
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
-
- Connection conn =
- DriverManager.getConnection("jdbc:mysql://192.168.1.5?user=rhqadmin&password=rhqadmin");
-
- DatabaseMetaData dmd = conn.getMetaData();
- System.out.println("Version: " + dmd.getDatabaseProductVersion());
- System.out.println("Product: " + dmd.getDatabaseProductName());
-
-
-
- // The default changed in 5.0.2... the following gets globabl data for all versions
-// ResultSet rs = conn.createStatement().executeQuery("SHOW /*!50002 GLOBAL *//* STATUS");
- ResultSet rs = conn.createStatement().executeQuery("SHOW TABLE STATUS FROM mysql");
-// ResultSet rs = dmd.getTables(null, null, null, null);//Catalogs();//Schemas();
- ResultSetMetaData md = rs.getMetaData();
- for (int i = 1; i <= md.getColumnCount();i++) {
- System.out.print(md.getColumnName(i) + " ");
+ private AggregateProcessInfo findProcessInfo() {
+ AggregateProcessInfo result = null;
+ // is still running reuse
+ if (aggregateProcessInfo != null && aggregateProcessInfo.isRunning()) {
+ result = aggregateProcessInfo;
+ } else {
+ long pid = findPID();
+ if (pid != -1) {
+ List<ProcessInfo> processes = resourceContext.getSystemInformation().getAllProcesses();
+ for (ProcessInfo pi : processes) {
+ if (pid == pi.getPid()) {
+ result = pi.getAggregateProcessTree();
+ break;
+ }
+ }
}
- System.out.println("");
- while (rs.next()) {
+ }
+ return result;
+ }
- for (int i = 1; i <= md.getColumnCount();i++) {
- System.out.print(rs.getObject(i) + " ");
- }
- System.out.println("");
+ private long findPID() {
+ long result = -1;
+ String pidFile = globalVariables.get("PID_FILE");
+ File file = new File(pidFile);
+ 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);
+ } catch (Exception ex) {
+ log.warn("Unable to read MySQL pid file " + pidFile);
}
- } catch (SQLException ex) {
- // handle any errors
- log.info("SQLException: " + ex.getMessage());
- log.info("SQLState: " + ex.getSQLState());
- log.info("VendorError: " + ex.getErrorCode());
}
+ return result;
}
}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionInfo.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionInfo.java
new file mode 100644
index 0000000..4fa0a4f
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionInfo.java
@@ -0,0 +1,92 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.mysql;
+
+/**
+ * A class to act as a key to a specific MySQL connection
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+class MySqlConnectionInfo {
+
+ private String host;
+ private String port;
+ private String db;
+ private String user;
+ private String password;
+ private int hashCode;
+
+ MySqlConnectionInfo(String host, String port, String db, String user, String password ) {
+ this.host = host;
+ this.port = port;
+ this.db = db;
+ this.user = user;
+ this.password = password;
+ this.hashCode = new StringBuilder().append(host).
+ append(port).
+ append(db).
+ append(user).
+ append(password).toString().hashCode();
+
+ }
+
+ public String getDb() {
+ return db;
+ }
+
+ @Override
+ public int hashCode() {
+ return hashCode;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public String buildURL() {
+ return new StringBuilder().append("jdbc:mysql://")
+ .append(host)
+ .append(":")
+ .append(port)
+ .append("/")
+ .append(db).toString();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ boolean result = false;
+ if ((other instanceof MySqlConnectionInfo) && (other.hashCode() == this.hashCode())) {
+ result = true;
+ }
+ return result;
+ }
+
+}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionManager.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionManager.java
new file mode 100644
index 0000000..9dd60ee
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionManager.java
@@ -0,0 +1,124 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.mysql;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.HashMap;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A class to manage the connections to MySQL
+ * This class keeps a cache of connections to MySQL and reuses them on demand
+ * We assume single threaded access to the Connection in the agent
+ * this will need to be reworked if that assumption is not correct
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+class MySqlConnectionManager {
+
+ private HashMap<MySqlConnectionInfo, Connection> connections;
+ private static MySqlConnectionManager singleton;
+ private Log logger = LogFactory.getLog(MySqlConnectionManager.class);
+
+ private MySqlConnectionManager() {
+ connections = new HashMap<MySqlConnectionInfo,Connection>();
+ try {
+ Class.forName("com.mysql.jdbc.Driver").newInstance();
+ } catch (Exception ex) {
+ logger.error("Unable to find com.mysql.jdbc.Driver");
+ }
+ }
+
+ static MySqlConnectionManager getConnectionManager() {
+ if (singleton == null) {
+ singleton = new MySqlConnectionManager();
+ }
+ return singleton;
+ }
+
+ public void shutdown() {
+ Driver driver = null;
+ for (Connection conn : connections.values()) {
+ try {
+ if (driver == null) {
+ String driverName = conn.getMetaData().getDriverName();
+ driver = DriverManager.getDriver(driverName);
+ }
+ conn.close();
+ }catch(SQLException e) { logger.info("Problem closing connection on Shutdown ignoring...");}
+ }
+ // deregister driver as well
+ if (driver != null) {
+ try {
+ DriverManager.deregisterDriver(driver);
+ } catch (SQLException ex) {
+ logger.warn("Unable to deregister MySQL Driver on shutdown");
+ }
+ }
+ }
+
+ void closeConnection(MySqlConnectionInfo info) {
+ Connection conn = connections.get(info);
+ if (conn != null) {
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Closing Connection to " + info.buildURL());
+ }
+ conn.close();
+ } catch (SQLException e) {
+ logger.warn("Problem closing connection to " + info.buildURL() + " on close");
+ }
+ }
+ connections.remove(info);
+ }
+
+ Connection getConnection (MySqlConnectionInfo info) throws SQLException {
+ Connection conn = connections.get(info);
+ String url = info.buildURL();
+ if (conn == null) {
+ if (logger.isInfoEnabled()) {
+ logger.info("Attemping connection to " + url);
+ }
+ conn = DriverManager.getConnection(url,info.getUser(), info.getPassword());
+ if (logger.isInfoEnabled()) {
+ logger.info("Successfully connected to " + url);
+ }
+ connections.put(info, conn);
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Reusing existing connection to " + url);
+ }
+ }
+
+ // check the validity of the connection
+ if (!conn.isValid(0)) {
+ // attempt a single reconnect here and now
+ conn.close();
+ conn = DriverManager.getConnection(url,info.getUser(), info.getPassword());
+ connections.put(info, conn);
+ logger.info("Refreshed a connection to " + url);
+ }
+ return conn;
+ }
+
+}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseComponent.java
new file mode 100644
index 0000000..43747bc
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseComponent.java
@@ -0,0 +1,167 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.mysql;
+
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.availability.AvailabilityFacet;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.database.DatabaseComponent;
+import org.rhq.plugins.database.DatabaseQueryUtility;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.measurement.AvailabilityType;
+
+/**
+ *
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+public class MySqlDatabaseComponent implements DatabaseComponent, AvailabilityFacet, OperationFacet {
+
+ private ResourceContext resourceContext;
+ private MySqlComponent parent;
+ private String databaseName;
+ private static Log log = LogFactory.getLog(MySqlDatabaseComponent.class);
+
+ @Override
+ public Connection getConnection() {
+ return parent.getConnection();
+ }
+
+ @Override
+ public void removeConnection() {
+ parent.removeConnection();
+ }
+
+ @Override
+ public void start(ResourceContext rc) throws InvalidPluginConfigurationException, Exception {
+ resourceContext = rc;
+ databaseName = rc.getResourceKey();
+ parent = (MySqlComponent)resourceContext.getParentResourceComponent();
+ }
+
+ public String getName() { return databaseName; }
+
+ @Override
+ public void stop() {
+ }
+
+ @Override
+ public AvailabilityType getAvailability() {
+ AvailabilityType result = AvailabilityType.DOWN;
+
+ if (log.isDebugEnabled()) {
+ log.debug("Availability check for " + databaseName);
+ }
+ Connection conn = getConnection();
+ if (conn != null) {
+ Statement statement = null;
+ ResultSet resultSet = null;
+ try {
+ statement = conn.createStatement();
+ resultSet = statement.executeQuery("SHOW DATABASES LIKE '" + databaseName + "'");
+ if (resultSet.next()) {
+ if (resultSet.getString(1).equalsIgnoreCase(databaseName)) {
+ result = AvailabilityType.UP;
+ }
+ }
+ }catch(SQLException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Got Exception when determining database availability",e);
+ }
+ } finally {
+ DatabaseQueryUtility.close(statement, resultSet);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public OperationResult invokeOperation(String name, Configuration parameters)
+ throws InterruptedException, Exception {
+
+ if ("invokeSql".equals(name)) {
+ Statement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = getConnection().createStatement();
+ String sql = parameters.getSimple("sql").getStringValue();
+ OperationResult result = new OperationResult();
+
+ if (parameters.getSimple("type").getStringValue().equals("update")) {
+ int updateCount = stmt.executeUpdate(sql);
+ result.getComplexResults().put(new PropertySimple("result", "Query updated " + updateCount + " rows"));
+
+ } else {
+ rs = stmt.executeQuery(parameters.getSimple("sql").getStringValue());
+
+ ResultSetMetaData md = rs.getMetaData();
+ StringBuilder buf = new StringBuilder();
+ int rowCount = 0;
+
+ buf.append("<table>");
+ buf.append("<th>");
+ for (int i = 1; i <= md.getColumnCount(); i++) {
+ buf.append("<td>");
+ buf.append(md.getColumnName(i) + " (" + md.getColumnTypeName(i) + ")");
+ buf.append("</td>");
+ }
+ buf.append("</th>");
+
+
+ while (rs.next()) {
+ rowCount++;
+ buf.append("<tr>");
+ for (int i = 1; i <= md.getColumnCount(); i++) {
+ buf.append("<td>");
+ buf.append(rs.getString(i));
+ buf.append("</td>");
+ }
+ buf.append("</tr>");
+ }
+
+ buf.append("</table>");
+ result.getComplexResults().put(new PropertySimple("result", "Query returned " + rowCount + " rows"));
+ result.getComplexResults().put(new PropertySimple("contents", buf.toString()));
+ }
+ return result;
+ } finally {
+ if (rs != null) {
+ rs.close();
+ }
+
+ if (stmt != null) {
+ stmt.close();
+ }
+ }
+ } else {
+ throw new UnsupportedOperationException("Operation [" + name + "] is not supported yet.");
+ }
+ }
+}
+
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java
index e34f021..c8f8673 100644
--- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlDatabaseDiscoveryComponent.java
@@ -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.mysql;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
@@ -30,46 +29,62 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.LinkedHashSet;
import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
/**
* @author Greg Hinkle
+ * @author Steve Millidge
*/
public class MySqlDatabaseDiscoveryComponent implements ResourceDiscoveryComponent<MySqlComponent> {
+ private Log logger = LogFactory.getLog(this.getClass());
-
+ @Override
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MySqlComponent> context) {
- Set<DiscoveredResourceDetails> tables = new LinkedHashSet<DiscoveredResourceDetails>();
-
+ if (logger.isDebugEnabled()) {
+ logger.debug("Database discovery started");
+ }
+ Set<DiscoveredResourceDetails> databases = new LinkedHashSet<DiscoveredResourceDetails>();
Connection connection = context.getParentResourceComponent().getConnection();
Statement statement = null;
ResultSet resultSet = null;
- try {
- statement = connection.createStatement();
- resultSet = statement.executeQuery("SHOW DATABASES");
+ if (connection != null) {
+ try {
+ statement = connection.createStatement();
+ resultSet = statement.executeQuery("SHOW DATABASES");
- while (resultSet.next()) {
- String databaseName = resultSet.getString(1);
- DiscoveredResourceDetails details =
- new DiscoveredResourceDetails(
- context.getResourceType(),
- databaseName,
- databaseName + " Database",
- null,
- "A MySql Database",
- null,
- null);
- tables.add(details);
- }
+ while (resultSet.next()) {
+ String databaseName = resultSet.getString(1);
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("databaseName",databaseName));
+ DiscoveredResourceDetails details =
+ new DiscoveredResourceDetails(
+ context.getResourceType(),
+ databaseName,
+ databaseName + " Database",
+ null,
+ "A MySql Database",
+ config,
+ null);
+ databases.add(details);
+ }
- } catch (SQLException e) {
- DatabaseQueryUtility.close(statement, resultSet);
+ } catch (SQLException e) {
+ } finally {
+ DatabaseQueryUtility.close(statement, resultSet);
+ }
+ } else {
+ if (logger.isInfoEnabled()) {
+ logger.info("No connection to MySQL obtained from connection manager");
+ }
}
- return tables;
+ return databases;
}
-
-}
\ No newline at end of file
+}
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 4f1045e..30b65f2 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
@@ -30,7 +30,6 @@ import org.rhq.core.pluginapi.inventory.ManualAddFacet;
import org.rhq.core.system.ProcessInfo;
import java.sql.Connection;
-import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.LinkedHashSet;
import java.util.List;
@@ -39,20 +38,22 @@ import java.util.Set;
/**
* @author Greg Hinkle
* @author Ian Springer
+ * @author Steve Millidge
*/
public class MySqlDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
private static final Log log = LogFactory.getLog(MySqlDiscoveryComponent.class);
- public static final String DRIVER_CONFIGURATION_PROPERTY = "driverClass";
public static final String HOST_CONFIGURATION_PROPERTY = "host";
public static final String PORT_CONFIGURATION_PROPERTY = "port";
public static final String DB_CONFIGURATION_PROPERTY = "db";
public static final String PRINCIPAL_CONFIGURATION_PROPERTY = "principal";
public static final String CREDENTIALS_CONFIGURATION_PROPERTY = "credentials";
- private static final String DEFAULT_RESOURCE_DESCRIPTION = "Mysql relational database server";
-
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Resource Discovery Started");
+ }
Set<DiscoveredResourceDetails> servers = new LinkedHashSet<DiscoveredResourceDetails>();
// Process any auto-discovered resources.
@@ -62,10 +63,7 @@ public class MySqlDiscoveryComponent implements ResourceDiscoveryComponent, Manu
ProcessInfo procInfo = result.getProcessInfo();
- DiscoveredResourceDetails resourceDetails = createResourceDetails(context, context.getDefaultPluginConfiguration(), procInfo);
- if (resourceDetails!=null) {
- servers.add(resourceDetails);
- }
+ servers.add(createResourceDetails(context,context.getDefaultPluginConfiguration(),procInfo));
}
return servers;
@@ -81,56 +79,53 @@ public class MySqlDiscoveryComponent implements ResourceDiscoveryComponent, Manu
}
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;
+ MySqlConnectionInfo ci = buildConnectionInfo(pluginConfiguration);
+ Connection conn;
+ String version = "";
try {
- Connection 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());
+ } 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);
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlPluginLifecycleListener.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlPluginLifecycleListener.java
index 181a113..a731aed 100644
--- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlPluginLifecycleListener.java
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlPluginLifecycleListener.java
@@ -18,39 +18,29 @@
*/
package org.rhq.plugins.mysql;
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.util.Enumeration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.pluginapi.plugin.PluginContext;
import org.rhq.core.pluginapi.plugin.PluginLifecycleListener;
-import org.rhq.core.util.exception.ThrowableUtil;
+/**
+ *
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
public class MySqlPluginLifecycleListener implements PluginLifecycleListener {
private final Log log = LogFactory.getLog(MySqlPluginLifecycleListener.class);
+ private String pluginName;
public void initialize(PluginContext context) throws Exception {
- // no-op
+ pluginName = context.getPluginName();
}
public void shutdown() {
- // so we do not cause our classloader to leak perm gen, we need to de-register
- // any and all JDBC drivers this plugin registered
- Enumeration<Driver> drivers = DriverManager.getDrivers();
- while (drivers.hasMoreElements()) {
- try {
- Driver driver = drivers.nextElement();
- DriverManager.deregisterDriver(driver);
- log.debug("Deregistered JDBC driver: " + driver.getClass());
- } catch (Exception e) {
- log.warn("Failed to deregister JDBC drivers - memory might leak" + ThrowableUtil.getAllMessages(e));
- }
+ if (log.isDebugEnabled()) {
+ log.debug(new StringBuilder().append(pluginName).append(" Plugin Shutdown").toString());
}
-
- log.debug(this.getClass().getSimpleName() + " completed shutdown.");
- return;
+ MySqlConnectionManager.getConnectionManager().shutdown();
}
}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableComponent.java
new file mode 100644
index 0000000..73354f9
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableComponent.java
@@ -0,0 +1,129 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.mysql;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.plugins.database.DatabaseComponent;
+import org.rhq.plugins.database.DatabaseQueryUtility;
+
+/**
+ *
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+public class MySqlTableComponent implements DatabaseComponent, MeasurementFacet {
+
+ private String tableName;
+ private MySqlDatabaseComponent parent;
+ private String databaseName;
+ private Log log = LogFactory.getLog(this.getClass());
+
+ @Override
+ public Connection getConnection() {
+ return parent.getConnection();
+ }
+
+ @Override
+ public void removeConnection() {
+ parent.removeConnection();
+ }
+
+ @Override
+ public void start(ResourceContext rc) throws InvalidPluginConfigurationException, Exception {
+ tableName = rc.getResourceKey();
+ parent = (MySqlDatabaseComponent)rc.getParentResourceComponent();
+ databaseName = parent.getName();
+ }
+
+ @Override
+ public void stop() {
+ }
+
+ @Override
+ public AvailabilityType getAvailability() {
+ AvailabilityType result = AvailabilityType.DOWN;
+ Connection conn = parent.getConnection();
+ if (conn != null) {
+ Statement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("show tables from " + databaseName + " like '" + tableName + "'");
+ if (rs.first()) {
+ result = AvailabilityType.UP;
+ }
+ }catch (SQLException se) {
+ // ignore as unablailable if we can't execute the query
+ }finally {
+ DatabaseQueryUtility.close(stmt, rs);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public void getValues(MeasurementReport mr, Set<MeasurementScheduleRequest> set) throws Exception {
+ Connection conn = parent.getConnection();
+ if (conn != null ) {
+ Statement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("show table status from " + databaseName+ " like '" + tableName + "'");
+ if (rs.next()) {
+ for (MeasurementScheduleRequest request : set) {
+ String value = rs.getString(request.getName());
+ if (value == null) {value = "0";}
+ switch (request.getDataType()) {
+ case MEASUREMENT: {
+ mr.addData(new MeasurementDataNumeric(request, Double.valueOf(value)));
+ break;
+ } case TRAIT: {
+ mr.addData(new MeasurementDataTrait(request, value));
+ break;
+ } default: {
+ break;
+ }
+ }
+ }
+ }
+ } catch(Exception se) {
+ if (log.isInfoEnabled()) {
+ log.info("Unable to measure table statistics", se);
+ }
+ }finally {
+ DatabaseQueryUtility.close(stmt, rs);
+ }
+ }
+ }
+
+}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableDiscoveryComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableDiscoveryComponent.java
new file mode 100644
index 0000000..5b62118
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlTableDiscoveryComponent.java
@@ -0,0 +1,85 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.mysql;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.database.DatabaseQueryUtility;
+
+/**
+ *
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+public class MySqlTableDiscoveryComponent implements ResourceDiscoveryComponent {
+
+ private Log log = LogFactory.getLog(this.getClass());
+
+ @Override
+ public Set discoverResources(ResourceDiscoveryContext rdc) throws InvalidPluginConfigurationException, Exception {
+
+ HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+ MySqlDatabaseComponent parent = (MySqlDatabaseComponent)rdc.getParentResourceComponent();
+ Connection conn = parent.getConnection();
+
+ if (conn != null) {
+ Statement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("show tables from " + parent.getName());
+ while (rs.next()) {
+ String tableName = rs.getString(1);
+ if (log.isDebugEnabled()) {
+ log.debug("Discovered Table "+ tableName);
+ }
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("tableName",tableName));
+ DiscoveredResourceDetails details = new DiscoveredResourceDetails(
+ rdc.getResourceType(),
+ tableName,
+ tableName + " Table",
+ null,
+ tableName + " MySql Table", config, null);
+ set.add(details);
+ }
+ } catch(SQLException se) {
+ if (log.isDebugEnabled()) {
+ log.debug("Unable to Discover Tables",se);
+ }
+
+ }finally {
+ DatabaseQueryUtility.close(stmt, rs);
+ }
+ }
+ return set;
+ }
+
+}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserComponent.java
new file mode 100644
index 0000000..32525c2
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserComponent.java
@@ -0,0 +1,128 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.mysql;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+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.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.plugins.database.DatabaseComponent;
+import org.rhq.plugins.database.DatabaseQueryUtility;
+
+/**
+ *
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+public class MySqlUserComponent implements MeasurementFacet, DatabaseComponent {
+
+ private String userName;
+ private String host;
+ private MySqlComponent parent;
+ private Log log = LogFactory.getLog(this.getClass());
+ private ResourceContext context;
+
+ @Override
+ public Connection getConnection() {
+ return parent.getConnection();
+ }
+
+ @Override
+ public void removeConnection() {
+ parent.removeConnection();
+ }
+
+ @Override
+ public void start(ResourceContext rc) throws InvalidPluginConfigurationException, Exception {
+ parent = (MySqlComponent)rc.getParentResourceComponent();
+ context = rc;
+ userName = context.getPluginConfiguration().getSimple("userName").getStringValue();
+ host = context.getPluginConfiguration().getSimple("host").getStringValue();
+ }
+
+ @Override
+ public void stop() {
+ }
+
+
+ public void getValues(MeasurementReport mr, Set<MeasurementScheduleRequest> requests) throws Exception {
+ Connection conn = getConnection();
+ ResultSet rs = null;
+ Statement stmt = null;
+ int activeConnections = 0;
+ int totalConnections = 0;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("select User,Host,State from information_schema.processlist where User='"+userName+"'");
+ while(rs.next()) {
+ String hostVal = rs.getString(2);
+ String state = rs.getString(3);
+ if (hostVal.startsWith(host)) {
+ if (state.length() > 1) {
+ activeConnections ++;
+ }
+ totalConnections++;
+ }
+ }
+ }catch(SQLException sqle) {
+
+ } finally {
+ DatabaseQueryUtility.close(stmt, rs);
+ }
+
+ for (MeasurementScheduleRequest request : requests) {
+ if (request.getName().equals("TotalConnections")) {
+ mr.addData(new MeasurementDataNumeric(request, new Double((double)totalConnections)));
+ } else if (request.getName().equals("ActiveConnections")) {
+ mr.addData(new MeasurementDataNumeric(request, new Double((double)activeConnections)));
+ }
+ }
+ }
+
+ public AvailabilityType getAvailability() {
+ AvailabilityType result = AvailabilityType.DOWN;
+ Connection conn = getConnection();
+ ResultSet rs = null;
+ Statement stmt = null;
+ try {
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("select User from mysql.user where User='"+userName+"' and Host='" + host +"'");
+ if (rs.first()) {
+ result = AvailabilityType.UP;
+ }
+ }catch(SQLException sqle) {
+
+ } finally {
+ DatabaseQueryUtility.close(stmt, rs);
+ }
+ return result;
+ }
+
+}
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserDiscoveryComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserDiscoveryComponent.java
new file mode 100644
index 0000000..d05682a
--- /dev/null
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlUserDiscoveryComponent.java
@@ -0,0 +1,76 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.mysql;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.HashSet;
+import java.util.Set;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.database.DatabaseQueryUtility;
+
+/**
+ *
+ * @author Steve Millidge (C2B2 Consulting Limited)
+ */
+public class MySqlUserDiscoveryComponent implements ResourceDiscoveryComponent {
+
+ public Set discoverResources(ResourceDiscoveryContext rdc) throws InvalidPluginConfigurationException, Exception {
+ HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+ MySqlComponent parent = (MySqlComponent) rdc.getParentResourceComponent();
+ Connection conn = parent.getConnection();
+ if (conn != null) {
+ Statement statement = null;
+ ResultSet resultSet = null;
+ try {
+ statement = conn.createStatement();
+ resultSet = statement.executeQuery("select User,Host from mysql.user");
+ while (resultSet.next()) {
+ String user = resultSet.getString(1);
+ String host = resultSet.getString(2);
+ String userName = user + "@" + host;
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("userName",user));
+ config.put(new PropertySimple("host",host));
+ DiscoveredResourceDetails discoveredUser =
+ new DiscoveredResourceDetails(
+ rdc.getResourceType(),
+ userName,
+ userName,
+ null,
+ "A MySql User",
+ config,
+ null);
+ set.add(discoveredUser);
+ }
+ } catch (Exception e) {
+ } finally {
+ DatabaseQueryUtility.close(statement, resultSet);
+ }
+ }
+ return set;
+ }
+}
diff --git a/modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml
index d94a60f..6a96c19 100644
--- a/modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mysql/src/main/resources/META-INF/rhq-plugin.xml
@@ -15,8 +15,6 @@
description="MySql Server"
supportsManualAdd="true">
- <version match="8.0"/>
-
<!-- Properties are connection/lookup configurations. They are values that the
plugin components need to connect and interact with the resource. -->
<plugin-configuration>
@@ -31,45 +29,31 @@
<c:integer-constraint minimum="1" maximum="65535"/>
</c:constraint>
</c:simple-property>
- <c:simple-property name="db" default="MySql" displayName="database name" description="the name of the database to connect to"/>
-
- <c:simple-property name="driverClass" default="com.mysql.jdbc.Driver" displayName="JDBC driver class"
- description="the fully-qualified classname of the JDBC driver class" required="false"/>
- <c:simple-property name="principal" default="MySql" displayName="role name" description="the database role to connect as"/>
- <c:simple-property name="credentials" default="MySql" type="password" displayName="role password"
+ <c:simple-property name="db" default="mysql" displayName="database name" description="the name of the database to connect to"/>
+ <c:simple-property name="principal" default="root" displayName="role name" description="the database role to connect as"/>
+ <c:simple-property name="credentials" default="root" type="password" displayName="role password"
description="the password for the database role being used to connect"/>
</plugin-configuration>
<process-scan name="windows" query="process|basename|match=^(?i)mysqld\.exe$,process|basename|nomatch|parent=^(?i)mysqld\.exe$" />
<process-scan name="unix" query="process|basename|match=^mysqld$,process|basename|nomatch|parent=^mysqld$" />
- <operation name="listProcessStatistics" description="List statistics about the currently executing MySql backends">
- <results>
- <c:list-property name="processList">
- <c:map-property name="process">
- <c:simple-property name="Id" type="integer"/>
- <c:simple-property name="User"/>
- <c:simple-property name="Host"/>
- <c:simple-property name="db"/>
- <c:simple-property name="Command"/>
- <c:simple-property name="Time"/>
- <c:simple-property name="State"/>
- <c:simple-property name="Info"/>
- </c:map-property>
- </c:list-property>
- </results>
- </operation>
-
-
-
- <metric displayName="User Time" property="Process.aggregateCpu.user" measurementType="trendsup" units="milliseconds" displayType="summary"/>
- <metric displayName="Kernel Time" property="Process.aggregateCpu.sys" measurementType="trendsup" units="milliseconds" displayType="summary"/>
- <metric displayName="CPU Percentage" property="Process.aggregateCpu.percent" measurementType="dynamic" units="percentage" displayType="summary"/>
- <metric displayName="Physical Memory" property="Process.aggregateMemory.resident" measurementType="dynamic" units="bytes" displayType="summary"/>
- <metric displayName="Virtual Memory" property="Process.aggregateMemory.size" measurementType="dynamic" units="bytes" displayType="summary"/>
- <metric displayName="Open File Descriptors" property="Process.aggregateFileDescriptor.total" measurementType="dynamic" displayType="summary"/>
-
-
+ <metric displayName="Physical Memory" property="Process.aggregateMemory.resident" measurementType="dynamic" units="bytes" displayType="summary"
+ description="The aggregate amount of resident memory used by all mysql processes"/>
+ <metric displayName="Virtual Memory" property="Process.aggregateMemory.size" measurementType="dynamic" units="bytes" displayType="summary"
+ description="The aggregate amount of virtual memory used by all mysql processes"/>
+ <metric displayName="Page Faults" property="Process.aggregateMemory.pageFaults" measurementType="trendsup" displayType="summary"
+ description="The Number of memory page faults by all mysql processes"/>
+ <metric displayName="User Time" property="Process.aggregateCpu.user" measurementType="trendsup" units="milliseconds" displayType="summary"
+ description="The aggregate amount of CPU user time spent by all mysql processes"/>
+ <metric displayName="Kernel Time" property="Process.aggregateCpu.sys" measurementType="trendsup" units="milliseconds" displayType="summary"
+ description="The aggregate amount of CPU kernel time spent by all mysql processes"/>
+ <metric displayName="CPU Percentage" property="Process.aggregateCpu.percent" measurementType="dynamic" units="percentage" displayType="summary"
+ description="The percentage of CPU currently being used by all mysql processes"/>
+ <metric displayName="Total CPU Time" property="Process.aggregateCpu.total" measurementType="trendsup" units="milliseconds" displayType="summary"
+ description="The aggregate amount of CPU time spent by all mysql processes"/>
+ <metric displayName="Open File Descriptors" property="Process.aggregateFileDescriptor.total" measurementType="dynamic" displayType="summary"
+ description="The aggregate number of file descriptors open by all mysql processes"/>
<metric property="Aborted_clients" measurementType="trendsup" description="Connections that aborted because the client did not close the connection"/>
@@ -353,10 +337,10 @@
<c:simple-property name="databaseName" displayName="Database Name" readOnly="true" />
</plugin-configuration>
- <operation name="resetStatistics" displayName="Reset Statistics" description="Resets the statistics in this database"/>
<operation name="invokeSql" description="Execute arbitrary SQL">
<parameters>
- <c:simple-property name="type" default="query">
+ <c:simple-property name="sql"/>
+ <c:simple-property name="type" default="query">
<c:property-options>
<c:option value="query" name="query"/>
<c:option value="update" name="update"/>
@@ -370,39 +354,39 @@
</results>
</operation>
-
- <metric displayName="Backends" property="numbackends" displayType="summary"/>
- <metric displayName="Transactions Committed" property="xact_commit" measurementType="trendsup" displayType="summary"/>
- <metric displayName="Transactions Rolled Back" property="xact_rollback" measurementType="trendsup" displayType="summary"/>
- <metric displayName="Blocks Read" property="blks_read" measurementType="trendsup"/>
- <metric displayName="Blocks Hit" property="blks_hit" measurementType="trendsup"/>
- <metric displayName="Size" property="size" description="Size of the database" units="bytes" displayType="summary"/>
-
-
-
- <service name="Table" class="MySqlTableComponent" discovery="MySqlTableDiscoveryComponent"
- description="Database table" createDeletePolicy="both" creationDataType="configuration">
+ <service name="Table" class="MySqlTableComponent" discovery="MySqlTableDiscoveryComponent"
+ description="Database table">
<plugin-configuration>
<c:simple-property name="tableName" readOnly="true" />
</plugin-configuration>
-
-
-
+ <!-- Summary Traits -->
+ <metric property="Engine" displayType="summary" dataType="trait" description="Database Engine that created the Table" defaultOn="true"/>
+ <metric property="Version" displayType="summary" dataType="trait" description="Version of the Table" defaultOn="true"/>
+ <metric property="Row_format" displayType="summary" dataType="trait" description="Row Format" defaultOn="true"/>
+ <metric property="Collation" displayType="summary" dataType="trait" description="Collation Character Set" defaultOn="true"/>
+ <metric property="Comment" displayType="summary" dataType="trait" description="Table Creation Comment" defaultOn="true"/>
+ <metric property="Create_options" displayType="summary" dataType="trait" description="Table Creation Options" defaultOn="true"/>
+ <metric property="Create_time" displayType="summary" dataType="trait" description="Table Creation Time" defaultOn="true"/>
+
+ <!-- Dynamic Metrics -->
+ <metric property="Rows" displayType="summary" measurementType="dynamic" description="Number of Rows in the Table" defaultOn="true"/>
+ <metric property="Avg_row_length" displayType="summary" measurementType="dynamic" units="bytes" description="Average Row Length(bytes)" defaultOn="true"/>
+ <metric property="Data_length" displayType="summary" measurementType="dynamic" units="bytes" description="Table Data Size(bytes)" defaultOn="true"/>
+ <metric property="Max_data_length" displayType="summary" measurementType="dynamic" units="bytes" description="Max Table Data Size(bytes)" defaultOn="true"/>
+ <metric property="Index_length" displayType="summary" measurementType="dynamic" units="bytes" description="Table Index Size(bytes)" defaultOn="true"/>
+ <metric property="Data_free" displayType="summary" measurementType="dynamic" units="bytes" description="Table Free Space(bytes)" defaultOn="true"/>
</service>
-
- </service>
-
- <service name="User" discovery="MySqlUserDiscoveryComponent" class="MySqlUserComponent"
- createDeletePolicy="both" creationDataType="configuration"
- description="A User in the MySql System">
- <plugin-configuration>
- <c:simple-property name="userName" required="true"/>
- </plugin-configuration>
-
-
-
</service>
+ <service name="User" class="MySqlUserComponent" discovery="MySqlUserDiscoveryComponent"
+ description="A MySQL User">
+ <plugin-configuration>
+ <c:simple-property name="userName" readOnly="true" />
+ <c:simple-property name="host" readOnly="true" />
+ </plugin-configuration>
+ <metric property="TotalConnections" displayType="summary" description="Total number of connections to the server"/>
+ <metric property="ActiveConnections" displayType="summary" description="Active Connections to the server"/>
+ </service>
</server>
</plugin>
\ No newline at end of file
13 years, 8 months
[rhq] Branch 'gwt-ldap' - 17 commits - modules/core modules/enterprise modules/plugins
by Simeon Pinder
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java | 15
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java | 12
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 3
modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java | 24
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java | 147 ++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java | 37 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java | 28 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java | 52 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java | 75 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java | 30 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java | 23
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java | 27 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java | 94 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 30 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java | 37 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java | 32 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java | 23
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GroupAlertDefinitionGWTService.java | 45 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java | 35 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java | 80 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java | 26 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java | 129 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java | 32 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 44 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java | 52 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java | 76 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java | 58 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java | 121 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java | 48 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java | 30 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java | 62 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java | 90 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java | 45 -
modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml | 17
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java | 30 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java | 25
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/TemporarySessionPasswordGenerator.java | 259 ---------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java | 14
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/TempSessionLoginModule.java | 100 ---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java | 14
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 7
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java | 123 ++++
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 56 +-
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java | 260 ++++++----
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java | 12
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java | 90 ++-
71 files changed, 1724 insertions(+), 1277 deletions(-)
New commits:
commit 079be6eeb1d8b3141f884375895e38a59af4120e
Merge: 018b306... cec52a7...
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Oct 15 19:41:17 2010 -0400
Merge branch 'master' into gwt-ldap2
diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index f0c2135,38a9386..2a88a26
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@@ -39,8 -39,8 +39,9 @@@ import com.smartgwt.client.widgets.grid
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.util.effects.ColoringUtility;
+ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* Base GWT-RPC oriented DataSource class.
commit 018b306f018c85e7a8472dfebbdd3e1d00e63b4e
Merge: 34f9d85... f767f23...
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Oct 15 19:38:56 2010 -0400
i)fixed ldap role-user regression
ii)lowered log levels.
iii)Merge branch 'master' into gwt-ldap2
Conflicts:
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
index c96f73a,f0916e2..a5f67c1
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
@@@ -86,7 -86,7 +86,8 @@@
<servlet path="/ContentGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.ContentGWTServiceImpl"/>
<servlet path="/DashboardGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.DashboardGWTServiceImpl"/>
<servlet path="/EventGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.EventGWTServiceImpl"/>
+ <servlet path="/GroupAlertDefinitionGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.GroupAlertDefinitionGWTServiceImpl"/>
+ <servlet path="/LdapGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.LdapGWTServiceImpl"/>
<servlet path="/MeasurementDataGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.MeasurementDataGWTServiceImpl"/>
<servlet path="/OperationGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.OperationGWTServiceImpl"/>
<servlet path="/RemoteInstallGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.RemoteInstallGWTServiceImpl"/>
diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index 66c37c6,3d79afd..03e46e1
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@@ -86,22 -67,6 +86,22 @@@ public class LoginView extends Canvas
public LoginView() {
}
+ //registration fields
+ private TextItem first;
+ private TextItem last;
+ private TextItem email;
+ private TextItem phone;
+ private TextItem department;
+ private ArrayList<DynamicForm> forms;
+ private static final String FIRST = "first";
+ private static final String LAST = "last";
- private static final String USERNAME = "username";
++ private static final String USERNAME = "ldap.username";
+ private static final String EMAIL = "email";
+ private static final String PHONE = "phone";
+ private static final String DEPARTMENT = "department";
- private static final String SESSIONID = "sessionid";
- private static final String PASSWORD = "password";
++ private static final String SESSIONID = "ldap.sessionid";
++ private static final String PASSWORD = "ldap.password";
+
public void showLoginDialog() {
if (!loginShowing) {
loginShowing = true;
diff --cc modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java
index fe68250,0000000..7b27fb6
mode 100644,000000..100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java
@@@ -1,311 -1,0 +1,304 @@@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License 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.server.gwt;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
++import com.allen_sauer.gwt.log.client.Log;
++
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SubjectCriteria;
+import org.rhq.core.domain.resource.group.LdapGroup;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.enterprise.gui.coregui.client.gwt.LdapGWTService;
+import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
+import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
+import org.rhq.enterprise.server.system.SystemManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * @author Simeon Pinder
+ */
+public class LdapGWTServiceImpl extends AbstractGWTServiceImpl implements LdapGWTService {
+
+ private static final long serialVersionUID = 1L;
+
+ private LdapGroupManagerLocal ldapManager = LookupUtil.getLdapGroupManager();
+ private SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
+ private SystemManagerLocal systemManager = LookupUtil.getSystemManager();
+
+ @Override
+ public Set<Map<String, String>> findAvailableGroups() {
+
+ try {
+ Set<Map<String, String>> results = ldapManager.findAvailableGroups();
+ return SerialUtility.prepare(results, "findAvailableGroups");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public void addLdapGroupsToRole(int roleId, List<String> groupIds) {
+ try {
+ ldapManager.addLdapGroupsToRole(subjectManager.getOverlord(), roleId, groupIds);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+
+ }
+
+ public void setLdapGroupsForRole(int roleId, List<String> groupIds) {
+ try {
+ //clean out existing roles as this defines the new list of roles
+ PageList<LdapGroup> existing = ldapManager.findLdapGroupsByRole(roleId, PageControl.getUnlimitedInstance());
- com.allen_sauer.gwt.log.client.Log.debug("Removing " + existing.getTotalSize() + " groups from role '"
- + roleId + "'.");
++ Log.trace("Removing " + existing.getTotalSize() + " groups from role '" + roleId + "'.");
+ int[] groupIndices = new int[existing.size()];
+ int indx = 0;
+ for (LdapGroup lg : existing) {
+ groupIndices[indx++] = lg.getId();
+ }
- com.allen_sauer.gwt.log.client.Log
- .debug("Removing " + groupIndices.length + " LDAP Groups." + groupIndices);
++ Log.trace("Removing " + groupIndices.length + " LDAP Groups." + groupIndices);
+ ldapManager.removeLdapGroupsFromRole(subjectManager.getOverlord(), roleId, groupIndices);
+ PageList<LdapGroup> nowGroups = ldapManager
+ .findLdapGroupsByRole(roleId, PageControl.getUnlimitedInstance());
+
+ //from among all available groups, if group name matches then add it to the list.
+ ArrayList<String> validGroupIds = new ArrayList<String>();
+ Set<Map<String, String>> allAvailableLdapGroups = ldapManager.findAvailableGroups();
+ for (String group : groupIds) {
+ for (Map<String, String> map : allAvailableLdapGroups) {
+ if (map.get("name").equals(group)) {
+ validGroupIds.add(group);
+ }
+ }
+ }
- com.allen_sauer.gwt.log.client.Log.debug("Adding " + validGroupIds.size() + " ldap groups to role["
- + roleId + "].");
++ Log.trace("Adding " + validGroupIds.size() + " ldap groups to role[" + roleId + "].");
+ ldapManager.addLdapGroupsToRole(subjectManager.getOverlord(), roleId, groupIds);
+ nowGroups = ldapManager.findLdapGroupsByRole(roleId, PageControl.getUnlimitedInstance());
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ public void updateLdapGroupAssignmentsForSubject(Subject subject) {
-
+ try {
+ //BZ-580127: only do group authz check if one or both of group filter fields is set
+ // Properties options = systemManager.getSystemConfiguration();
+ String groupFilter = LookupUtil.getSystemManager().getSystemConfiguration().getProperty(
+ RHQConstants.LDAPGroupFilter, "");
+ String groupMember = LookupUtil.getSystemManager().getSystemConfiguration().getProperty(
+ RHQConstants.LDAPGroupMember, "");
- // String groupFilter = (String) options.getProperty(RHQConstants.LDAPGroupFilter, "");
- // String groupMember = (String) options.getProperty(RHQConstants.LDAPGroupMember, "");
+ if ((groupFilter.trim().length() > 0) || (groupMember.trim().length() > 0)) {
- // try { //defend against ldap communication runtime difficulties.
+ String provider = LookupUtil.getSystemManager().getSystemConfiguration().getProperty(
+ RHQConstants.JAASProvider);
+ if (RHQConstants.LDAPJAASProvider.equals(provider)) {
- List<String> groupNames = new ArrayList(ldapManager.findAvailableGroupsFor(subject.getName()));
++ List<String> groupNames = new ArrayList<String>(ldapManager.findAvailableGroupsFor(subject
++ .getName()));
+ ldapManager.assignRolesToLdapSubject(subject.getId(), groupNames);
+ }
+ }
++ // try { //defend against ldap communication runtime difficulties.
+ // } catch (EJBException ejx) {
+ // //this is the exception type thrown now that we use SLSB.Local methods
+ // // mine out other exceptions
+ // Exception cause = ejx.getCausedByException();
+ // if (cause == null) {
+ // ActionMessages actionMessages = new ActionMessages();
+ // actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.cam.general"));
+ // saveErrors(request, actionMessages);
+ // } else {
+ // if (cause instanceof LdapFilterException) {
+ // ActionMessages actionMessages = new ActionMessages();
+ // actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
+ // "admin.role.LdapGroupFilterMessage"));
+ // saveErrors(request, actionMessages);
+ // } else if (cause instanceof LdapCommunicationException) {
+ // ActionMessages actionMessages = new ActionMessages();
+ // SystemManagerLocal manager = LookupUtil.getSystemManager();
+ // options = manager.getSystemConfiguration();
+ // String providerUrl = options.getProperty(RHQConstants.LDAPUrl, "(unavailable)");
+ // actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
+ // "admin.role.LdapCommunicationMessage", providerUrl));
+ // saveErrors(request, actionMessages);
+ // }
+ // }
+ // } catch (LdapFilterException lce) {
+ // ActionMessages actionMessages = new ActionMessages();
+ // actionMessages.add(ActionMessages.GLOBAL_MESSAGE,
+ // new ActionMessage("admin.role.LdapGroupFilterMessage"));
+ // saveErrors(request, actionMessages);
+ // } catch (LdapCommunicationException lce) {
+ // ActionMessages actionMessages = new ActionMessages();
+ // String providerUrl = options.getProperty(RHQConstants.LDAPUrl, "(unavailable)");
+ // actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
+ // "admin.role.LdapCommunicationMessage", providerUrl));
+ // saveErrors(request, actionMessages);
+ // }
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public Set<Map<String, String>> findLdapGroupsAssignedToRole(int roleId) {
+ try {
+ PageList<LdapGroup> allAssignedLdapGroups = ldapManager.findLdapGroupsByRole(roleId, PageControl
+ .getUnlimitedInstance());
+ Set<Map<String, String>> ldapGroups = new HashSet<Map<String, String>>();
+
+ for (LdapGroup group : allAssignedLdapGroups) {
+ HashMap<String, String> map = new HashMap<String, String>();
+ map.put("name", group.getName());
+ map.put("id", group.getName());
+ map.put("description", group.getDescription());
+ ldapGroups.add(map);
+ }
+
+ return SerialUtility.prepare(ldapGroups, "findLdapGroupsAssignedToRole");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ /** Does a series of LDAP checks and for case insensitive ldap matching accounts will return new Subject with session id.
+ * i) needs registration(user exists in ldap but not yet in RHQ)
+ * ii) if LDAP authentication is enabled. All authentication is piped through this method.
+ *
+ *
+ */
+ @Override
+ public Subject checkSubjectForLdapAuth(Subject currentSubject, String user, String password) {
+ try {
+ Subject newSubject = null;
- com.allen_sauer.gwt.log.client.Log.debug("Subject being checked for ldapAuthentication is :"
- + currentSubject);
++ Log.trace("Subject being checked for ldapAuthentication is :" + currentSubject);
+
+ boolean needsRegistrationOrCaseIncorrectOnAccountName = false;
+
+ //null checks.
+ if ((currentSubject != null) && (user != null) && (password != null)) {
+ if (currentSubject.getId() == 0) {
+ // Subject with a ID of 0 means the subject wasn't in the database but the login succeeded.
+ // This means the login method detected the LDAP authenticated user and gave us a dummy subject.
+ // Set the needs-registration flag so we can eventually steer the user to the LDAP registration workflow.
+ needsRegistrationOrCaseIncorrectOnAccountName = true;
+ }
+
- com.allen_sauer.gwt.log.client.Log.debug("Subject has id of :" + currentSubject.getId()
- + "and requires Registration:" + needsRegistrationOrCaseIncorrectOnAccountName);
++ Log.trace("Subject has id of :" + currentSubject.getId() + "and requires Registration:"
++ + needsRegistrationOrCaseIncorrectOnAccountName);
+
+ // figure out if the user has a principal
+ String provider = LookupUtil.getSystemManager().getSystemConfiguration().getProperty(
+ RHQConstants.JAASProvider);
+ boolean ldapEnabled = ((provider != null) && provider.equals(RHQConstants.LDAPJAASProvider));
+
- com.allen_sauer.gwt.log.client.Log.debug("LDAP Authentication has been enabled :" + ldapEnabled);
++ Log.trace("LDAP Authentication has been enabled :" + ldapEnabled);
+ boolean hasPrincipal = false;
+
+ if (ldapEnabled) {
+ // when we allow for LDAP authentication, we may still have users logging in with JDBC.
+ // The only way we can distinguish these users is by checking to see if they have an
+ // entry in the principals table. If they do, then we know we use JDBC authentication
+ // for that user. If they do not, then we must be using LDAP to authenticate that user.
+ // hasPrincipal = subjectManager.isUserWithPrincipal(currentSubject.getName());
+ hasPrincipal = subjectManager.isUserWithPrincipal(user);
- com.allen_sauer.gwt.log.client.Log.debug("Subject '" + user + "' hasPrincipal :" + hasPrincipal);
- // System.out.println("Subject hasPrincipal :" + hasPrincipal);
++ Log.trace("Subject '" + user + "' hasPrincipal :" + hasPrincipal);
+
+ if (!hasPrincipal && needsRegistrationOrCaseIncorrectOnAccountName) {
+ //for the case when they're already registered but entering a case sensitive different name
+ //BZ-586435: insert case insensitivity for usernames with ldap auth
+ // locate first matching subject and attach.
+ SubjectCriteria subjectCriteria = new SubjectCriteria();
+ subjectCriteria.setCaseSensitive(false);
+ subjectCriteria.setStrict(true);
+ subjectCriteria.addFilterName(user);
+ subjectCriteria.fetchRoles(true);
+ subjectCriteria.fetchConfiguration(true);
+ PageList<Subject> subjectsLocated = LookupUtil.getSubjectManager().findSubjectsByCriteria(
+ LookupUtil.getSubjectManager().getOverlord(), subjectCriteria);
- com.allen_sauer.gwt.log.client.Log.debug("Subjects located with name '" + user + "' and found:"
- + subjectsLocated.size());
++ Log.trace("Subjects located with name '" + user + "' and found:" + subjectsLocated.size());
+
+ //if subject variants located then take the first one with a principal otherwise do nothing
+ //To defend against the case where they create an account with the same name but not
+ //case as an rhq sysadmin or higher perms, then make them relogin with same creds entered.
+ if (!subjectsLocated.isEmpty()) {//then case insensitive username matches found. Try to use instead.
+ Subject ldapSubject = subjectsLocated.get(0);
+ String msg = "Located existing ldap account with different case for ["
+ + ldapSubject.getName() + "]. "
+ + "Attempting to authenticate with that account instead.";
- com.allen_sauer.gwt.log.client.Log.info(msg);
- com.allen_sauer.gwt.log.client.Log
- .debug("Attempting to log back in with credentials passed in.");
++ Log.info(msg);
++ Log.trace("Attempting to log back in with credentials passed in.");
+ newSubject = subjectManager.login(user, password);
- com.allen_sauer.gwt.log.client.Log.debug("Logged in as [" + ldapSubject.getName()
- + "] with session id [" + newSubject.getSessionId() + "]");
++ Log.trace("Logged in as [" + ldapSubject.getName() + "] with session id ["
++ + newSubject.getSessionId() + "]");
+ needsRegistrationOrCaseIncorrectOnAccountName = false;
+ }
+ }
+
+ } else {
+ // with regular JDBC authentication, we are guaranteed to have a principal
+ hasPrincipal = true;
+ }
+ } else {
- com.allen_sauer.gwt.log.client.Log.debug("The Subject and user/password cannot be null to proceed.");
++ Log.debug("The Subject and user/password cannot be null to proceed.");
+ }
+ return SerialUtility.prepare(newSubject, "checkSubjectForLdapAuth");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ /**Light call to determine ldap configuration status.
+ *
+ */
+ @Override
+ public Boolean checkLdapConfiguredStatus() {
+ Boolean ldapEnabled = false;
+ try {
+ String provider = systemManager.getSystemConfiguration().getProperty(RHQConstants.JAASProvider);
+ ldapEnabled = ((provider != null) && provider.equals(RHQConstants.LDAPJAASProvider));
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ return ldapEnabled;
+ }
+
+ /**Returns all LDAP details for a given user, using the configured ldap details of server.
+ *
+ */
+ @Override
+ public Map<String, String> getLdapDetailsFor(String user) {
+ Map<String, String> ldapDetails = new HashMap<String, String>();
+ try {
+ ldapDetails = ldapManager.findLdapUserDetails(user);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ return ldapDetails;
+ }
+}
diff --cc modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
index 2cff69b,409d64e..81aebe8
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
@@@ -103,7 -104,7 +103,10 @@@ public class LdapGroupManagerBean imple
filter = String.format("(&(%s)(%s=%s))", groupFilter, groupMember, userDN);
Set<Map<String, String>> matched = buildGroup(options, filter);
++ log.trace("Located '" + matched.size() + "' LDAP groups for user '" + userName
++ + "' using following ldap filter '" + filter + "'.");
++ //iterate to extract just the group names.
Set<String> ldapSet = new HashSet<String>();
for (Map<String, String> match : matched) {
ldapSet.add(match.get("id"));
@@@ -205,20 -206,12 +208,26 @@@
Query query = PersistenceUtility.createQueryWithOrderBy(entityManager, queryName, pc);
long count = (Long) queryCount.getSingleResult();
-- // List<Role> roles = query.getResultList();
List<LdapGroup> groups = query.getResultList();
return new PageList<LdapGroup>(groups, (int) count, pc);
}
++ /**Build/retrieve the user DN. Not usually a property.
++ *
++ * @param options
++ * @param userName
++ * @return
++ */
private String getUserDN(Properties options, String userName) {
+ Map<String, String> details = findLdapUserDetails(userName);
+ String userDN = details.get("dn");
++
+ return userDN;
+ }
+
+ public Map<String, String> findLdapUserDetails(String userName) {
+ Properties options = systemManager.getSystemConfiguration();
+ HashMap<String, String> userDetails = new HashMap<String, String>();
// Load our LDAP specific properties
Properties env = getProperties(options);
@@@ -271,19 -265,14 +280,22 @@@
// We use the first match
SearchResult si = (SearchResult) answer.next();
++ //generate the DN
++ String userDN = si.getName() + "," + baseDNs[x];
++ userDetails.put("dn", userDN);
// Construct the UserDN
- String userDN = si.getName() + "," + baseDNs[x];
- return userDN;
+ NamingEnumeration<String> keys = si.getAttributes().getIDs();
+ while (keys.hasMore()) {
+ String key = keys.next();
+ Attribute value = si.getAttributes().get(key);
+ if (value != null) {
+ userDetails.put(key, value.get() + "");
+ }
+ }
+ return userDetails;
}
-
- // If we try all the BaseDN's and have not found a match, return false
- return "";
+ return userDetails;
} catch (NamingException e) {
throw new RuntimeException(e);
}
commit cec52a70ca813ed0138ab1b2f59efc364953b393
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Sat Oct 16 01:15:18 2010 +0200
Removing the code dealing with the legacy resource keys and implement a ResourceUpgradeFacet for virtual hosts so that we can finally move away from the insufficient legacy resource keys.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index a0f2120..9b5c975 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -345,79 +345,46 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
String[] addrs = resourceKey.substring(pipeIdx + 1).split(" ");
List<AugeasNode> nodes = tree.matchRelative(tree.getRootNode(), "<VirtualHost");
List<AugeasNode> virtualHosts = new ArrayList<AugeasNode>();
- boolean updated = false;
-
-//BZ 612189 - uncomment this algo once the resource upgrade is in place
-// for (AugeasNode node : nodes) {
-// updated = false;
-// List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
-// String tempServerName = null;
-//
-// if (!(serverNameNodes.isEmpty())) {
-// tempServerName = serverNameNodes.get(0).getValue();
-// }
-// if (tempServerName == null & serverName == null)
-// updated = true;
-// if (tempServerName != null & serverName != null)
-// if (tempServerName.equals(serverName)){
-// updated = true;
-// }
-//
-//
-// if (updated){
-// updated = false;
-// List<AugeasNode> params = node.getChildByLabel("param");
-// for (AugeasNode nd : params) {
-// updated = false;
-// for (String adr : addrs) {
-// if (adr.equals(nd.getValue()))
-// updated = true;
-// }
-// if (!updated)
-// break;
-// }
-//
-// if (updated)
-// virtualHosts.add(node);
-// }
-// }
-
- //BZ 612189 - remove this once resource upgrade is in place
- HttpdAddressUtility.Address resourceKeyAddress = HttpdAddressUtility.Address.parse(resourceKey);
- for(AugeasNode node : nodes) {
+ boolean matching = false;
+
+ for (AugeasNode node : nodes) {
+ matching = false;
List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
- List<AugeasNode> vhostAddressNodes = node.getChildByLabel("param");
+ String tempServerName = null;
+
+ if (!(serverNameNodes.isEmpty())) {
+ tempServerName = serverNameNodes.get(0).getValue();
+ }
+ if (tempServerName == null & serverName == null) {
+ matching = true;
+ }
- String vhostServerName = serverNameNodes.isEmpty() ? null : serverNameNodes.get(0).getValue();
- String vhostAddressDef = vhostAddressNodes.isEmpty() ? null : vhostAddressNodes.get(0).getValue();
+ if (tempServerName != null & serverName != null) {
+ if (tempServerName.equals(serverName)) {
+ matching = true;
+ }
+ }
- if (vhostAddressDef != null) {
- HttpdAddressUtility.Address vhostAddress = HttpdAddressUtility.Address.parse(vhostAddressDef);
- if (vhostServerName != null) {
- HttpdAddressUtility.Address vhostServerAddress = HttpdAddressUtility.Address.parse(vhostServerName);
- vhostAddress.host = vhostServerAddress.host;
+ if (matching) {
+ List<AugeasNode> params = node.getChildByLabel("param");
+ for (AugeasNode nd : params) {
+ matching = false;
+ for (String adr : addrs) {
+ if (adr.equals(nd.getValue())) {
+ matching = true;
+ }
+ }
+ if (!matching) {
+ break;
+ }
}
-
- if (resourceKeyAddress.equals(vhostAddress)) {
+
+ if (matching) {
virtualHosts.add(node);
}
}
}
-
- //BZ 612189 - remove this once we have resource upgrade
- //ok, one final attempt... the legacy resource key format for the MainServer is just a host:port as with the rest of the vhosts, let's try that
- try {
- String serverUrl = resourceContext.getParentResourceComponent().getServerUrl();
- URI serverUri = new URI(serverUrl);
- String expectedResourceKey = serverUri.getHost() + ":" + serverUri.getPort();
-
- if (expectedResourceKey.equals(resourceKey)) {
- return tree.getRootNode();
- }
- } catch (URISyntaxException e) {
- log.warn("Failed to parse the server URL when trying to match the vhost with the main server.", e);
- }
-
+
if (virtualHosts.size() == 0) {
throw new IllegalStateException("Could not find virtual host configuration in augeas for virtual host: "
+ resourceKey);
@@ -544,14 +511,6 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
vhostServerName, true);
if (vhostAddr != null) {
vhostAddresses.add(vhostAddr);
- } else {
- //this is not to choke on the old style resource keys for the main server. without this, we'd never be able
- //to match the main server with its snmp index below.
- HttpdAddressUtility.Address addr = HttpdAddressUtility.Address.parse(vhostAddressStrings[i]);
- vhostAddr = parent.getAddressUtility().getMainServerSampleAddress(tree, addr.host, addr.port);
- if (vhostAddr != null) {
- vhostAddresses.add(vhostAddr);
- }
}
}
}
@@ -618,7 +577,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
return snmpWwwServiceIndex;
}
- private static int matchRate(List<HttpdAddressUtility.Address> addresses, HttpdAddressUtility.Address addressToCheck) {
+ public static int matchRate(List<HttpdAddressUtility.Address> addresses, HttpdAddressUtility.Address addressToCheck) {
for(HttpdAddressUtility.Address a : addresses) {
if (HttpdAddressUtility.isAddressConforming(addressToCheck, a.host, a.port, true)) {
return 3;
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index 8251658..6f24ca7 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -21,23 +21,25 @@ package org.rhq.plugins.apache;
import java.io.File;
import java.net.InetAddress;
import java.net.URI;
-import java.net.URISyntaxException;
import java.net.UnknownHostException;
-import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.augeas.node.AugeasNode;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.ResourceUpgradeReport;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext;
+import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet;
import org.rhq.plugins.apache.parser.ApacheDirective;
import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
import org.rhq.plugins.apache.util.HttpdAddressUtility;
@@ -54,7 +56,7 @@ import org.rhq.plugins.www.snmp.SNMPValue;
* @author Ian Springer
* @author Lukas Krejci
*/
-public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDiscoveryComponent<ApacheServerComponent> {
+public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDiscoveryComponent<ApacheServerComponent>, ResourceUpgradeFacet<ApacheServerComponent> {
private static final String COULD_NOT_DETERMINE_THE_VIRTUAL_HOST_ADDRESS = "*** Could not determine the virtual host address ***";
@@ -69,37 +71,25 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
- //BZ 612189 - prepare for the legacy overrides. We need to revert to the old-style resource keys until
- //resource upgrade functionality is ready.
- SnmpWwwServiceIndexes snmpDiscoveries = getSnmpDiscoveries(context);
-
ApacheServerComponent serverComponent = context.getParentResourceComponent();
ApacheDirectiveTree tree = serverComponent.loadParser();
//first define the root server as one virtual host
- discoverMainServer(context, discoveredResources, snmpDiscoveries);
+ discoverMainServer(context, discoveredResources);
ResourceType resourceType = context.getResourceType();
File configPath = serverComponent.getServerRoot();
File logsDir = new File(configPath, LOGS_DIRECTORY_NAME);
- List<ApacheDirective> virtualHosts = tree.search("/<VirtualHost");
-
- for (ApacheDirective node : virtualHosts) {
- List<String> hosts = node.getValues();
- String firstAddress = hosts.get(0);
-
- List<ApacheDirective> serverNames = node.getChildByName("ServerName");
- String serverName = null;
- if (serverNames.size() > 0) {
- serverName = serverNames.get(0).getValuesAsString();
- }
+ for(VHostSpec vhost : VHostSpec.detect(tree)) {
+
+ String firstAddress = vhost.hosts.get(0);
- String resourceKey = createResourceKey(serverName, hosts);
+ String resourceKey = createResourceKey(vhost.serverName, vhost.hosts);
Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
- Address address = serverComponent.getAddressUtility().getVirtualHostSampleAddress(tree, firstAddress, serverName, false);
+ Address address = serverComponent.getAddressUtility().getVirtualHostSampleAddress(tree, firstAddress, vhost.serverName, false);
if (address != null) {
String scheme = address.scheme;
String hostToPing = address.host;
@@ -143,17 +133,11 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
}
String resourceName;
- if (serverName != null) {
+ if (address != null) {
resourceName = address.host + ":" + address.port;
} else {
resourceName = resourceKey;
}
-
- //BZ 612189 - remove this once we have resource upgrade
- if (snmpDiscoveries != null) {
- String legacyResourceKey = getLegacyResourceKey(context, resourceKey, snmpDiscoveries);
- resourceKey = legacyResourceKey != null ? legacyResourceKey : resourceKey;
- }
discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
pluginConfiguration, null));
@@ -162,9 +146,56 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
return discoveredResources;
}
+ public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ApacheServerComponent> inventoriedResource) {
+ String resourceKey = inventoriedResource.getResourceKey();
+
+ if (ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY.equals(resourceKey) ||
+ resourceKey.contains("|")) {
+ //a new style resource key. we're done.
+ return null;
+ }
+
+ String newResourceKey = null;
+
+ ApacheServerComponent serverComponent = inventoriedResource.getParentResourceComponent();
+
+ ApacheDirectiveTree tree = serverComponent.loadParser();
+
+ List<VHostSpec> vhosts = VHostSpec.detect(tree);
+ SnmpWwwServiceIndexes snmpIndexes = getSnmpDiscoveries(serverComponent, inventoriedResource.getParentResourceContext().getResourceKey());
+
+ for (VHostSpec vhost : vhosts) {
+ String legacyResourceKey = createLegacyResourceKey(serverComponent, vhost.serverName, vhost.hosts, snmpIndexes);
+ if (resourceKey.equals(legacyResourceKey)) {
+ newResourceKey = createResourceKey(vhost.serverName, vhost.hosts);
+ break;
+ }
+ }
+
+ if (newResourceKey == null) {
+ //the last thing to check is whether the inventoried vhost isn't in fact the main server
+ String serverUrl = serverComponent.getServerUrl();
+ HttpdAddressUtility.Address serverAddress = HttpdAddressUtility.Address.parse(serverUrl);
+ HttpdAddressUtility.Address vhostAddress = HttpdAddressUtility.Address.parse(resourceKey);
+
+ if (ApacheVirtualHostServiceComponent.matchRate(Collections.singletonList(serverAddress), vhostAddress) > 0) {
+ newResourceKey = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ }
+ }
+
+ if (newResourceKey != null) {
+ ResourceUpgradeReport report = new ResourceUpgradeReport();
+ report.setNewResourceKey(newResourceKey);
+
+ return report;
+ } else {
+ return null;
+ }
+ }
+
private void discoverMainServer(ResourceDiscoveryContext<ApacheServerComponent> context,
- Set<DiscoveredResourceDetails> discoveredResources, SnmpWwwServiceIndexes snmpDiscoveries) throws Exception {
+ Set<DiscoveredResourceDetails> discoveredResources) throws Exception {
ResourceType resourceType = context.getResourceType();
Configuration mainServerPluginConfig = context.getDefaultPluginConfiguration();
@@ -175,8 +206,6 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
String mainServerUrl = context.getParentResourceContext().getPluginConfiguration().getSimple(
ApacheServerComponent.PLUGIN_CONFIG_PROP_URL).getStringValue();
- String key = null;
-
if (mainServerUrl != null && !"null".equals(mainServerUrl)) {
PropertySimple mainServerUrlProp = new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP,
mainServerUrl);
@@ -195,21 +224,9 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
PropertySimple rtLogProp = new PropertySimple(
ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
mainServerPluginConfig.put(rtLogProp);
-
- //BZ 612189 - remove this once we have resource upgrade
- key = host + ":" + port;
}
- //BZ 612189 - this can simply the MAIN_SERVER_RESOURCE_KEY only once we have resource upgrade
- if (key == null) {
- key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
- }
-
- //BZ 612189 - remove this once we have resource upgrade
- if (snmpDiscoveries != null) {
- String legacyKey = getLegacyResourceKey(context, key, snmpDiscoveries);
- key = legacyKey != null ? legacyKey : key;
- }
+ String key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
DiscoveredResourceDetails mainServer = new DiscoveredResourceDetails(resourceType,
key, "Main", null, null,
@@ -217,45 +234,43 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
discoveredResources.add(mainServer);
}
- /**
- * @deprecated remove this once we have resource upgrade
- * @param discoveryContext
- * @param newStyleResourceKey
- * @param snmpDiscoveries
- * @return
- */
- @Deprecated
- private String getLegacyResourceKey(ResourceDiscoveryContext<ApacheServerComponent> discoveryContext, String newStyleResourceKey, SnmpWwwServiceIndexes snmpDiscoveries) {
- int snmpWwwServiceIndex = ApacheVirtualHostServiceComponent.getMatchingWwwServiceIndex(discoveryContext.getParentResourceComponent(), newStyleResourceKey, snmpDiscoveries.names, snmpDiscoveries.ports);
-
- if (snmpWwwServiceIndex < 1) {
- return null;
- } else {
- String host = snmpDiscoveries.names.get(snmpWwwServiceIndex - 1).toString();
- String fullPort = snmpDiscoveries.ports.get(snmpWwwServiceIndex - 1).toString();
-
- // The port value will be in the form "1.3.6.1.2.1.6.XXXXX",
- // where "1.3.6.1.2.1.6" represents the TCP protocol ID,
- // and XXXXX is the actual port number
- String port = fullPort.substring(fullPort.lastIndexOf(".") + 1);
- return host + ":" + port;
+ public static String createResourceKey(String serverName, List<String> hosts) {
+ StringBuilder keyBuilder = new StringBuilder();
+ if (serverName != null) {
+ keyBuilder.append(serverName);
+ }
+ keyBuilder.append("|"); //always do this so that we have a clear distinction between old and new style resource keys
+ keyBuilder.append(hosts.get(0));
+
+ for (int i = 1; i < hosts.size(); ++i){
+ keyBuilder.append(" ").append(hosts.get(i));
}
+
+ return keyBuilder.toString();
}
- public static String createResourceKey(String serverName, List<String> hosts) {
-//BZ 612189 - swap the impls once resource upgrade is in place
-// StringBuilder keyBuilder = new StringBuilder();
-// if (serverName != null) {
-// keyBuilder.append(serverName).append("|");
-// }
-// keyBuilder.append(hosts.get(0));
-//
-//
-// for (int i = 1; i < hosts.size(); ++i){
-// keyBuilder.append(" ").append(hosts.get(i));
-// }
-//
-// return keyBuilder.toString();
+ private static String createLegacyResourceKey(ApacheServerComponent serverComponent, String serverName, List<String> hosts, SnmpWwwServiceIndexes snmpIndexes) {
+ if (snmpIndexes != null) {
+ String newStyleResourceKey = createResourceKey(serverName, hosts);
+ String legacyResourceKey = null;
+
+ int snmpWwwServiceIndex = ApacheVirtualHostServiceComponent.getMatchingWwwServiceIndex(serverComponent, newStyleResourceKey, snmpIndexes.names, snmpIndexes.ports);
+
+ if (snmpWwwServiceIndex > 0) {
+ String host = snmpIndexes.names.get(snmpWwwServiceIndex - 1).toString();
+ String fullPort = snmpIndexes.ports.get(snmpWwwServiceIndex - 1).toString();
+
+ // The port value will be in the form "1.3.6.1.2.1.6.XXXXX",
+ // where "1.3.6.1.2.1.6" represents the TCP protocol ID,
+ // and XXXXX is the actual port number
+ String port = fullPort.substring(fullPort.lastIndexOf(".") + 1);
+ legacyResourceKey = host + ":" + port;
+ }
+
+ if (legacyResourceKey != null) {
+ return legacyResourceKey;
+ }
+ }
//try to derive the same resource key as the SNMP would have... this is to prevent the duplication of
//vhost resources after the SNMP was configured - how I wish resource upgrade made it to 3.0 to prevent this
@@ -279,18 +294,15 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
}
/**
- * @deprecated remove this once we have resource upgrade
* @param discoveryContext
* @return
*/
- @Deprecated
- private SnmpWwwServiceIndexes getSnmpDiscoveries(ResourceDiscoveryContext<ApacheServerComponent> discoveryContext) {
+ private static SnmpWwwServiceIndexes getSnmpDiscoveries(ApacheServerComponent serverComponent, String serverResourceKey) {
try {
- SNMPSession snmpSession = discoveryContext.getParentResourceComponent().getSNMPSession();
+ SNMPSession snmpSession = serverComponent.getSNMPSession();
List<SNMPValue> nameValues;
List<SNMPValue> portValues;
- SNMPValue descValue;
-
+
try {
nameValues = snmpSession.getColumn(SNMPConstants.COLUMN_VHOST_NAME);
} catch (SNMPException e) {
@@ -305,35 +317,46 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
"Error getting SNMP column: " + SNMPConstants.COLUMN_VHOST_PORT + ": " + e.getMessage(), e);
}
- try {
- // Just get the first one - they are all the same.
- descValue = snmpSession.getNextValue(SNMPConstants.COLUMN_VHOST_DESC);
- } catch (SNMPException e) {
- throw new Exception("Error getting SNMP value: " + SNMPConstants.COLUMN_VHOST_DESC + ": " + e.getMessage(),
- e);
- }
-
SnmpWwwServiceIndexes ret = new SnmpWwwServiceIndexes();
ret.names = nameValues;
ret.ports = portValues;
- ret.desc = descValue;
return ret;
} catch (Exception e) {
- log.warn("Error while trying to contact SNMP of the apache server " + discoveryContext.getParentResourceContext().getResourceKey(), e);
+ log.warn("Error while trying to contact SNMP of the apache server " + serverResourceKey, e);
return null;
}
}
- /**
- * @deprecated remove this once we have resource upgrade
- *
- * @author Lukas Krejci
- */
- @Deprecated
private static class SnmpWwwServiceIndexes {
public List<SNMPValue> names;
public List<SNMPValue> ports;
- public SNMPValue desc;
+ }
+
+ private static class VHostSpec {
+ public String serverName;
+ public List<String> hosts;
+
+ public static List<VHostSpec> detect(ApacheDirectiveTree config) {
+ List<ApacheDirective> virtualHosts = config.search("/<VirtualHost");
+
+ List<VHostSpec> ret = new ArrayList<VHostSpec>(virtualHosts.size());
+
+ for(ApacheDirective dir : virtualHosts) {
+ ret.add(new VHostSpec(dir));
+ }
+
+ return ret;
+ }
+
+ public VHostSpec(ApacheDirective vhostDirective) {
+ hosts = vhostDirective.getValues();
+
+ List<ApacheDirective> serverNames = vhostDirective.getChildByName("ServerName");
+ serverName = null;
+ if (serverNames.size() > 0) {
+ serverName = serverNames.get(0).getValuesAsString();
+ }
+ }
}
}
\ No newline at end of file
commit dd1e15c2f1b564b0f547508fbc472a0f97ec8cc6
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Sat Oct 16 01:13:17 2010 +0200
Adding the ResourceContext of the parent resource to the ResourceUpgradeContext so that upgrade() methods of the discovery components can use that information.
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java
index 35f5029..c56d280 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java
@@ -44,17 +44,18 @@ import org.rhq.core.system.SystemInfo;
*
* @author Lukas Krejci
*/
-@SuppressWarnings("unchecked")
+@SuppressWarnings("rawtypes")
public class ResourceUpgradeContext<T extends ResourceComponent> extends ResourceContext<T> {
private final Configuration resourceConfiguration;
private final String name;
private final String description;
+ private ResourceContext<?> parentResourceContext;
/**
* @see ResourceContext#ResourceContext(Resource, ResourceComponent, ResourceDiscoveryComponent, SystemInfo, File, File, String, EventContext, OperationContext, ContentContext, Executor, PluginContainerDeployment)
*/
- public ResourceUpgradeContext(Resource resource, T parentResourceComponent,
+ public ResourceUpgradeContext(Resource resource, ResourceContext<?> parentResourceContext, T parentResourceComponent,
ResourceDiscoveryComponent resourceDiscoveryComponent, SystemInfo systemInfo, File temporaryDirectory,
File dataDirectory, String pluginContainerName, EventContext eventContext, OperationContext operationContext,
ContentContext contentContext, Executor availCollectorThreadPool,
@@ -64,15 +65,14 @@ public class ResourceUpgradeContext<T extends ResourceComponent> extends Resourc
pluginContainerName, eventContext, operationContext, contentContext, availCollectorThreadPool,
pluginContainerDeployment);
+ this.parentResourceContext = parentResourceContext;
this.resourceConfiguration = resource.getResourceConfiguration();
this.name = resource.getName();
this.description = resource.getDescription();
}
- public ResourceUpgradeContext(Resource resource, ResourceDiscoveryComponent discoveryComponent, ResourceContext<T> context, Executor availCollectorThreadPool) {
- this(resource, context.getParentResourceComponent(), discoveryComponent, context.getSystemInformation(), context.getTemporaryDirectory(),
- context.getDataDirectory(), context.getPluginContainerName(), context.getEventContext(), context.getOperationContext(),
- context.getContentContext(), availCollectorThreadPool, context.getPluginContainerDeployment());
+ public ResourceContext<?> getParentResourceContext() {
+ return parentResourceContext;
}
public Configuration getResourceConfiguration() {
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index 0259c69..2e15f8e 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -1568,10 +1568,11 @@ public class InventoryManager extends AgentService implements ContainerService,
}
public <T extends ResourceComponent> ResourceUpgradeContext<T> createResourceUpgradeContext(Resource resource,
- T parentComponent, ResourceDiscoveryComponent<T> discoveryComponent) {
+ ResourceContext<?> parentResourceContext, T parentComponent, ResourceDiscoveryComponent<T> discoveryComponent) {
File pluginDataDir = new File(this.configuration.getDataDirectory(), resource.getResourceType().getPlugin());
return new ResourceUpgradeContext<T>(resource, // the resource itself
+ parentResourceContext, //the context of its parent resource
parentComponent, // its parent component
discoveryComponent, // the discovery component (this is actually the proxy to it)
SystemInfoFactory.createSystemInfo(), // for native access
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
index 06d2cd0..b3b8716 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
@@ -36,6 +36,7 @@ import org.rhq.core.pc.PluginContainer;
import org.rhq.core.pc.inventory.InventoryManager;
import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext;
import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet;
@@ -158,12 +159,14 @@ public class ResourceUpgradeDelegate {
ResourceComponent<T> parentResourceComponent = resourceContainer.getResourceContext()
.getParentResourceComponent();
-
+
Resource parentResource = resourceContainer.getResource().getParentResource();
ResourceContainer parentResourceContainer = (parentResource != null) ? inventoryManager
.getResourceContainer(resourceContainer.getResource().getParentResource()) : null;
+ ResourceContext<?> parentResourceContext = parentResourceContainer == null ? null : parentResourceContainer.getResourceContext();
+
Resource resource = resourceContainer.getResource();
ResourceDiscoveryComponent<ResourceComponent<T>> discoveryComponent = PluginContainer.getInstance()
@@ -175,7 +178,7 @@ public class ResourceUpgradeDelegate {
}
ResourceUpgradeContext<ResourceComponent<T>> upgradeContext = inventoryManager.createResourceUpgradeContext(
- resource, parentResourceComponent, discoveryComponent);
+ resource, parentResourceContext, parentResourceComponent, discoveryComponent);
ResourceUpgradeRequest request = new ResourceUpgradeRequest(resource.getId());
commit 9bf39010bcf60ad0cd52876be3f1255329cf656e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:37:36 2010 +0100
BZ 535786 - Adding the SNMP host and port detection during the apache server discovery.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index a1b08a7..a5e19e5 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -18,12 +18,19 @@
*/
package org.rhq.plugins.apache;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.URI;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -162,6 +169,16 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
serverConfigFile.getParent() + File.separator + "*"));
}
+ List<InetSocketAddress> snmpAddresses = findSNMPAddresses(serverConfig, new File(serverRoot));
+ if (snmpAddresses != null && snmpAddresses.size() > 0) {
+ InetSocketAddress addr = snmpAddresses.get(0);
+ int port = addr.getPort();
+ InetAddress host = addr.getAddress() == null ? InetAddress.getLocalHost() : addr.getAddress();
+
+ pluginConfig.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST, host.getHostAddress()));
+ pluginConfig.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT, port));
+ }
+
discoveredResources.add(createResourceDetails(discoveryContext, pluginConfig, process.getProcessInfo(),
binaryInfo));
}
@@ -445,4 +462,106 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
return serverRoot + "||" + httpdConf;
}
+
+ private static List<InetSocketAddress> findSNMPAddresses(ApacheDirectiveTree tree, File serverRoot) {
+ List<InetSocketAddress> ret = new ArrayList<InetSocketAddress>();
+
+ List<ApacheDirective> confs = tree.search("/SNMPConf");
+
+ if (confs.size() == 0) {
+ log.info("SNMPConf directive not found. Skipping SNMP configuration.");
+ return ret;
+ }
+
+ String confDirName = confs.get(0).getValuesAsString();
+ if (confDirName == null || confDirName.isEmpty()) {
+ log.warn("The SNMPConf directive seems to not have a value. Skipping SNMP configuration.");
+ return ret;
+ }
+
+
+ File confDir = new File(confDirName);
+
+ if (!confDir.isAbsolute()) {
+ confDir = new File(serverRoot, confDirName);
+ }
+
+ File snmpdConf = new File(confDir, "snmpd.conf");
+
+ if (!snmpdConf.exists()) {
+ log.warn("Could not find a snmpd.conf file under the configured directory '" + confDirName
+ + "'. Skipping SNMP configuration.");
+ return ret;
+ }
+
+ try {
+ String agentAddressLine = findSNMPAgentAddressConfigLine(snmpdConf);
+
+ if (agentAddressLine == null) {
+ log.warn("Could not find the 'agentaddress' property in the snmpd.conf. Skipping SNMP configuration.");
+ return ret;
+ }
+
+ int specStartIdx = agentAddressLine.indexOf("agentaddress") + "agentaddress".length() + 1;
+
+ while (Character.isWhitespace(agentAddressLine.charAt(specStartIdx)))
+ specStartIdx++;
+
+ String spec = agentAddressLine.substring(specStartIdx);
+
+ String[] addrs = spec.split(",");
+
+ try {
+ for (String addr : addrs) {
+ if (addr.startsWith("udp") || addr.startsWith("tcp")) {
+ //this contains the transport spec - either "udp:" or "tcp:"
+ addr = addr.substring(4);
+ }
+
+ int atIdx = addr.indexOf('@');
+ String port = addr;
+ String host = null;
+ if (atIdx > 0) {
+ host = addr.substring(atIdx + 1);
+ port = addr.substring(0, atIdx);
+ }
+
+ InetSocketAddress address = null;
+ if (host != null) {
+ address = new InetSocketAddress(host, Integer.parseInt(port));
+ } else {
+ address = new InetSocketAddress(Integer.parseInt(port));
+ }
+
+ ret.add(address);
+ }
+ } catch (Exception e) {
+ log.warn("Failed to parse the SNMP 'agentaddress' configuration property: "
+ + agentAddressLine, e);
+ }
+ } catch (IOException e) {
+ log.warn("Failed to read in the configured snmpd.conf file: " + snmpdConf.getAbsolutePath(), e);
+ }
+
+ return ret;
+ }
+
+ private static String findSNMPAgentAddressConfigLine(File snmpdConf) throws IOException {
+ BufferedReader rdr = new BufferedReader(new FileReader(snmpdConf));
+
+ try {
+ Pattern search = Pattern.compile("^\\s*agentaddress.*");
+ String line;
+
+ while ((line = rdr.readLine()) != null) {
+ if (search.matcher(line).matches()) {
+ return line;
+ }
+ }
+
+ return null;
+ } finally {
+ rdr.close();
+ }
+ }
}
commit b7e3bccde3c4c36be6e9aab7299ff2d060e0475f
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:41:07 2010 +0100
BZ 642622 - Adding the ability to extract the scheme and port from the ServerName so that proper ping URLs can be discovered.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index bea7c23..a1b08a7 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -262,7 +262,7 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
*/
private static String getUrl(ApacheDirectiveTree serverConfig, String version) throws Exception {
Address addr = HttpdAddressUtility.get(version).getMainServerSampleAddress(serverConfig, null, 0);
- return addr == null ? null : "http://" + addr.host + ":" + addr.port + "/";
+ return addr == null ? null : addr.toString();
}
@Nullable
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index b2f76bc..8251658 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -124,7 +124,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
String url;
if (hostToPing != null && portToPing != Address.PORT_WILDCARD_VALUE && portToPing != Address.NO_PORT_SPECIFIED_VALUE) {
- url = "http://" + hostToPing + ":" + portToPing + "/";
+ url = scheme + "://" + hostToPing + ":" + portToPing + "/";
} else {
url = COULD_NOT_DETERMINE_THE_VIRTUAL_HOST_ADDRESS;
}
@@ -133,16 +133,18 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
pluginConfiguration.put(urlProp);
}
-
- File rtLogFile = new File(logsDir, address.host + address.port + RT_LOG_FILE_NAME_SUFFIX);
-
- PropertySimple rtLogProp = new PropertySimple(
- ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
- pluginConfiguration.put(rtLogProp);
-
+
+ if (address != null) {
+ File rtLogFile = new File(logsDir, address.host + address.port + RT_LOG_FILE_NAME_SUFFIX);
+
+ PropertySimple rtLogProp = new PropertySimple(
+ ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
+ pluginConfiguration.put(rtLogProp);
+ }
+
String resourceName;
if (serverName != null) {
- resourceName = address.toString();
+ resourceName = address.host + ":" + address.port;
} else {
resourceName = resourceKey;
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
index c5589fd..b5cdedf 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
@@ -82,7 +82,7 @@ public enum HttpdAddressUtility {
address = getLocalhost(address.port);
}
- updateWithServerName(address, ag);
+ updateWithServerName(address, ag, false);
return address;
}
@@ -90,7 +90,7 @@ public enum HttpdAddressUtility {
return null;
} catch (Exception e) {
- log.info("Failed to obtain main server address. Is augeas installed and correct lens in use?");
+ log.warn("Failed to obtain main server address.", e);
return null;
}
@@ -106,7 +106,7 @@ public enum HttpdAddressUtility {
addr = getLocalhost(addr.port);
}
- updateWithServerName(addr, ag);
+ updateWithServerName(addr, ag, false);
return addr;
}
@@ -115,7 +115,7 @@ public enum HttpdAddressUtility {
//there has to be at least one Listen directive
throw new IllegalStateException("Could find a listen address on port " + limitToPort);
} catch (Exception e) {
- log.info("Failed to obtain main server address. Is augeas installed and correct lens in use?");
+ log.warn("Failed to obtain main server address.", e);
return null;
}
@@ -131,6 +131,7 @@ public enum HttpdAddressUtility {
public static class Address {
public String host;
public int port = -1;
+ public String scheme = "http";
public static final String WILDCARD = "*";
public static final String DEFAULT_HOST = "_default_";
@@ -142,6 +143,10 @@ public enum HttpdAddressUtility {
this.port = port;
}
+ public Address(String scheme, String host, int port) {
+ this(host, port);
+ this.scheme = scheme;
+ }
/**
* A simple parser of the provided address into host and port
* sections.
@@ -150,6 +155,13 @@ public enum HttpdAddressUtility {
* @return an instance of Address with host and port set accordingly
*/
public static Address parse(String address) {
+ String scheme = "http";
+ int schemeSpecIdx = address.indexOf("://");
+ if (schemeSpecIdx >= 0) {
+ scheme = address.substring(0, schemeSpecIdx);
+ address = address.substring(schemeSpecIdx + "://".length());
+ }
+
int lastColonIdx = address.lastIndexOf(':');
if (lastColonIdx == NO_PORT_SPECIFIED_VALUE) {
return new Address(address, -1);
@@ -166,10 +178,10 @@ public enum HttpdAddressUtility {
port = Integer.parseInt(portSpec);
}
- return new Address(host, port);
+ return new Address(scheme, host, port);
} else {
//this is an IP6 address without a port spec
- return new Address(address, NO_PORT_SPECIFIED_VALUE);
+ return new Address(scheme, address, NO_PORT_SPECIFIED_VALUE);
}
}
}
@@ -214,11 +226,11 @@ public enum HttpdAddressUtility {
@Override
public String toString() {
- if (port == NO_PORT_SPECIFIED_VALUE) return host;
+ if (port == NO_PORT_SPECIFIED_VALUE) return scheme + "://" + host;
else {
String portSpec = port == PORT_WILDCARD_VALUE ? WILDCARD : String.valueOf(port);
- return host + ":" + portSpec;
+ return scheme + "://" + host + ":" + portSpec;
}
}
}
@@ -245,30 +257,29 @@ public enum HttpdAddressUtility {
* @return the address on which the virtual host can be accessed or null on error
*/
public Address getVirtualHostSampleAddress(ApacheDirectiveTree ag, String virtualHost, String serverName, boolean snmpModuleCompatibleMode) {
- Address addr = Address.parse(virtualHost);
- if (addr.isHostDefault() || addr.isHostWildcard()) {
- Address serverAddr = null;
- if (snmpModuleCompatibleMode) {
- serverAddr = getLocalhost(addr.port);
- } else {
- serverAddr = getMainServerSampleAddress(ag, null, addr.port);
+ try {
+ Address addr = Address.parse(virtualHost);
+ if (addr.isHostDefault() || addr.isHostWildcard()) {
+ Address serverAddr = null;
+ if (snmpModuleCompatibleMode) {
+ serverAddr = getLocalhost(addr.port);
+ } else {
+ serverAddr = getMainServerSampleAddress(ag, null, addr.port);
+ }
+ if (serverAddr == null)
+ return null;
+ addr.host = serverAddr.host;
}
- if (serverAddr == null)
- return null;
- addr.host = serverAddr.host;
- }
- if (serverName != null) {
- int colonIdx = serverName.indexOf(':');
- if (colonIdx >= 0) {
- addr.host = serverName.substring(0, colonIdx);
- addr.port = Integer.parseInt(serverName.substring(colonIdx + 1));
- } else {
- addr.host = serverName;
+ if (serverName != null) {
+ updateWithServerName(addr, serverName, true);
}
- }
- return addr;
+ return addr;
+ } catch (Exception e) {
+ log.warn("Failed to obtain virtual host address.", e);
+ return null;
+ }
}
private static Address parseListen(String listenValue) {
@@ -335,12 +346,12 @@ public enum HttpdAddressUtility {
try {
return new Address(InetAddress.getLocalHost().getHostAddress(), port);
} catch (UnknownHostException e) {
- //well, this is bad, we can get address of the localhost. let's use the force...
+ //well, this is bad, we can't get address of the localhost. let's use the force...
return new Address("127.0.0.1", port);
}
}
- private static void updateWithServerName(Address address, ApacheDirectiveTree config) throws UnknownHostException {
+ private static void updateWithServerName(Address address, ApacheDirectiveTree config, boolean updatePort) throws UnknownHostException {
//check if there is a ServerName directive
List<ApacheDirective> serverNameNodes = config.search("/ServerName");
@@ -349,11 +360,20 @@ public enum HttpdAddressUtility {
//be the case if the server listens on more than one interfaces.
if (serverNameNodes.size() > 0) {
String serverName = serverNameNodes.get(0).getValuesAsString();
- InetAddress addrFromServerName = InetAddress.getByName(serverName);
- InetAddress addrFromAddress = InetAddress.getByName(address.host);
-
- if (addrFromAddress.equals(addrFromServerName)) {
- address.host = serverName;
+ updateWithServerName(address, serverName, updatePort);
+ }
+ }
+
+ private static void updateWithServerName(Address address, String serverName, boolean updatePort) throws UnknownHostException {
+ Address serverAddr = Address.parse(serverName);
+ InetAddress addrFromServerName = InetAddress.getByName(serverAddr.host);
+ InetAddress addrFromAddress = InetAddress.getByName(address.host);
+
+ if (addrFromAddress.equals(addrFromServerName)) {
+ address.scheme = serverAddr.scheme;
+ address.host = serverAddr.host;
+ if (updatePort) {
+ address.port = serverAddr.port;
}
}
}
commit eb45a242496d529a1ac3ee63807d8ea67237708e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:43:42 2010 +0200
BZ 642610 - directives found in included files aren't duplicated anymore
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
index 2e0f2a2..6cb168e 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
@@ -121,18 +121,6 @@ public class ApacheAugeasNode extends AugeasNodeLazy implements AugeasNode {
childNodes.add(node);
}
- public List<AugeasNode> getChildByLabel(String labelName) {
- List<AugeasNode> nodes = super.getChildByLabel(labelName);
-
- if (includedNodes != null) {
- for (AugeasNode node : includedNodes) {
- if (node.getLabel().equals(labelName))
- nodes.add(node);
- }
- }
- return nodes;
- }
-
public void setPath(String path) throws AugeasTreeException {
this.path = path;
commit a3455824e924722ee018b6fca916da31a2c5e859
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:42:17 2010 +0200
BZ 642591 - make sure we always have the same resource keys as in old plugin version.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
index c1f6323..4c61682 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
@@ -590,6 +590,13 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
/**
+ * @return The url the server is pinged for availability or null if the url is not set.
+ */
+ public @Nullable String getServerUrl() {
+ return resourceContext.getPluginConfiguration().getSimpleValue(PLUGIN_CONFIG_PROP_URL, null);
+ }
+
+ /**
* Returns the httpd.conf file
* @return A File object that represents the httpd.conf file or null in case of error
*/
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index d97d9fc..a0f2120 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -21,6 +21,8 @@ package org.rhq.plugins.apache;
import java.io.File;
import java.net.InetAddress;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -345,40 +347,77 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
List<AugeasNode> virtualHosts = new ArrayList<AugeasNode>();
boolean updated = false;
- for (AugeasNode node : nodes) {
- updated = false;
+//BZ 612189 - uncomment this algo once the resource upgrade is in place
+// for (AugeasNode node : nodes) {
+// updated = false;
+// List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
+// String tempServerName = null;
+//
+// if (!(serverNameNodes.isEmpty())) {
+// tempServerName = serverNameNodes.get(0).getValue();
+// }
+// if (tempServerName == null & serverName == null)
+// updated = true;
+// if (tempServerName != null & serverName != null)
+// if (tempServerName.equals(serverName)){
+// updated = true;
+// }
+//
+//
+// if (updated){
+// updated = false;
+// List<AugeasNode> params = node.getChildByLabel("param");
+// for (AugeasNode nd : params) {
+// updated = false;
+// for (String adr : addrs) {
+// if (adr.equals(nd.getValue()))
+// updated = true;
+// }
+// if (!updated)
+// break;
+// }
+//
+// if (updated)
+// virtualHosts.add(node);
+// }
+// }
+
+ //BZ 612189 - remove this once resource upgrade is in place
+ HttpdAddressUtility.Address resourceKeyAddress = HttpdAddressUtility.Address.parse(resourceKey);
+ for(AugeasNode node : nodes) {
List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
- String tempServerName = null;
-
- if (!(serverNameNodes.isEmpty())) {
- tempServerName = serverNameNodes.get(0).getValue();
- }
- if (tempServerName == null & serverName == null)
- updated = true;
- if (tempServerName != null & serverName != null)
- if (tempServerName.equals(serverName)){
- updated = true;
- }
+ List<AugeasNode> vhostAddressNodes = node.getChildByLabel("param");
+
+ String vhostServerName = serverNameNodes.isEmpty() ? null : serverNameNodes.get(0).getValue();
+ String vhostAddressDef = vhostAddressNodes.isEmpty() ? null : vhostAddressNodes.get(0).getValue();
+
+ if (vhostAddressDef != null) {
+ HttpdAddressUtility.Address vhostAddress = HttpdAddressUtility.Address.parse(vhostAddressDef);
+ if (vhostServerName != null) {
+ HttpdAddressUtility.Address vhostServerAddress = HttpdAddressUtility.Address.parse(vhostServerName);
+ vhostAddress.host = vhostServerAddress.host;
+ }
-
- if (updated){
- updated = false;
- List<AugeasNode> params = node.getChildByLabel("param");
- for (AugeasNode nd : params) {
- updated = false;
- for (String adr : addrs) {
- if (adr.equals(nd.getValue()))
- updated = true;
- }
- if (!updated)
- break;
- }
-
- if (updated)
- virtualHosts.add(node);
+ if (resourceKeyAddress.equals(vhostAddress)) {
+ virtualHosts.add(node);
}
- }
-
+ }
+ }
+
+ //BZ 612189 - remove this once we have resource upgrade
+ //ok, one final attempt... the legacy resource key format for the MainServer is just a host:port as with the rest of the vhosts, let's try that
+ try {
+ String serverUrl = resourceContext.getParentResourceComponent().getServerUrl();
+ URI serverUri = new URI(serverUrl);
+ String expectedResourceKey = serverUri.getHost() + ":" + serverUri.getPort();
+
+ if (expectedResourceKey.equals(resourceKey)) {
+ return tree.getRootNode();
+ }
+ } catch (URISyntaxException e) {
+ log.warn("Failed to parse the server URL when trying to match the vhost with the main server.", e);
+ }
+
if (virtualHosts.size() == 0) {
throw new IllegalStateException("Could not find virtual host configuration in augeas for virtual host: "
+ resourceKey);
@@ -505,6 +544,14 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
vhostServerName, true);
if (vhostAddr != null) {
vhostAddresses.add(vhostAddr);
+ } else {
+ //this is not to choke on the old style resource keys for the main server. without this, we'd never be able
+ //to match the main server with its snmp index below.
+ HttpdAddressUtility.Address addr = HttpdAddressUtility.Address.parse(vhostAddressStrings[i]);
+ vhostAddr = parent.getAddressUtility().getMainServerSampleAddress(tree, addr.host, addr.port);
+ if (vhostAddr != null) {
+ vhostAddresses.add(vhostAddr);
+ }
}
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index 4a32e27..b2f76bc 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -19,7 +19,10 @@
package org.rhq.plugins.apache;
import java.io.File;
+import java.net.InetAddress;
import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -37,6 +40,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.apache.parser.ApacheDirective;
import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
+import org.rhq.plugins.apache.util.HttpdAddressUtility;
import org.rhq.plugins.apache.util.HttpdAddressUtility.Address;
import org.rhq.plugins.www.snmp.SNMPException;
import org.rhq.plugins.www.snmp.SNMPSession;
@@ -91,23 +95,13 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
serverName = serverNames.get(0).getValuesAsString();
}
- StringBuilder keyBuilder = new StringBuilder();
- if (serverName != null) {
- keyBuilder.append(serverName).append("|");
- }
- keyBuilder.append(firstAddress);
-
-
- for (int i=1;i<hosts.size();i++){
- keyBuilder.append(" ").append(hosts.get(i));
- }
-
- String resourceKey = keyBuilder.toString();
+ String resourceKey = createResourceKey(serverName, hosts);
Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
Address address = serverComponent.getAddressUtility().getVirtualHostSampleAddress(tree, firstAddress, serverName, false);
if (address != null) {
+ String scheme = address.scheme;
String hostToPing = address.host;
int portToPing = address.port;
if (address.isPortWildcard()) {
@@ -178,6 +172,9 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
String mainServerUrl = context.getParentResourceContext().getPluginConfiguration().getSimple(
ApacheServerComponent.PLUGIN_CONFIG_PROP_URL).getStringValue();
+
+ String key = null;
+
if (mainServerUrl != null && !"null".equals(mainServerUrl)) {
PropertySimple mainServerUrlProp = new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP,
mainServerUrl);
@@ -196,9 +193,15 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
PropertySimple rtLogProp = new PropertySimple(
ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
mainServerPluginConfig.put(rtLogProp);
+
+ //BZ 612189 - remove this once we have resource upgrade
+ key = host + ":" + port;
}
- String key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ //BZ 612189 - this can simply the MAIN_SERVER_RESOURCE_KEY only once we have resource upgrade
+ if (key == null) {
+ key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ }
//BZ 612189 - remove this once we have resource upgrade
if (snmpDiscoveries != null) {
@@ -237,6 +240,42 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
}
}
+ public static String createResourceKey(String serverName, List<String> hosts) {
+//BZ 612189 - swap the impls once resource upgrade is in place
+// StringBuilder keyBuilder = new StringBuilder();
+// if (serverName != null) {
+// keyBuilder.append(serverName).append("|");
+// }
+// keyBuilder.append(hosts.get(0));
+//
+//
+// for (int i = 1; i < hosts.size(); ++i){
+// keyBuilder.append(" ").append(hosts.get(i));
+// }
+//
+// return keyBuilder.toString();
+
+ //try to derive the same resource key as the SNMP would have... this is to prevent the duplication of
+ //vhost resources after the SNMP was configured - how I wish resource upgrade made it to 3.0 to prevent this
+ //kind of guessing being necessary.
+ String host = hosts.get(0);
+ HttpdAddressUtility.Address hostAddr = HttpdAddressUtility.Address.parse(host);
+ if (serverName != null) {
+ HttpdAddressUtility.Address serverAddr = HttpdAddressUtility.Address.parse(serverName);
+ hostAddr.host = serverAddr.host;
+ }
+
+ //the SNMP module seems to resolve the IPs to hostnames.
+ try {
+ InetAddress hostName = InetAddress.getByName(hostAddr.host);
+ hostAddr.host = hostName.getHostName();
+ } catch (UnknownHostException e) {
+ log.debug("Host " + hostAddr.host + " is not resolvable.", e);
+ }
+
+ return hostAddr.host + ":" + hostAddr.port;
+ }
+
/**
* @deprecated remove this once we have resource upgrade
* @param discoveryContext
@@ -279,7 +318,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
return ret;
} catch (Exception e) {
- log.warn("Error while trying to contact SNMP of the apache server " + discoveryContext.getParentResourceContext().getResourceKey());
+ log.warn("Error while trying to contact SNMP of the apache server " + discoveryContext.getParentResourceContext().getResourceKey(), e);
return null;
}
}
commit 15a2bbe9f0a9ba43cccb2065ced149a8abb92710
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 14:33:57 2010 +0100
BZ 642588 - config is reloaded if ServerRoot is redefined in config
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index ca8f972..bea7c23 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -141,6 +141,8 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
if (!serverRoots.isEmpty()) {
serverRoot = AugeasNodeValueUtil.unescape(serverRoots.get(0).getValuesAsString());
serverRootProp.setValue(serverRoot);
+ //reparse the configuration with the new ServerRoot
+ serverConfig = loadParser(serverConfigFile.getAbsolutePath(), serverRoot);
}
serverUrl = getUrl(serverConfig, binaryInfo.getVersion());
commit 0235aed4bd3737768f96acc66f5868838235686d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Oct 15 17:40:49 2010 -0400
DataSource Work:
Resulting from the fact that we couldn't render a list view without
including the ID colum. In short it seems there is (currently) only one
way to get control of column widths in one of our dataSource-backed
ListGrid based views. That is to override the ds fields with its own
ListGrid fields (see ResourceSearchView for a working example).
Perhaps at some point the listGrid.resizeField() method will work as
maybe it should, but until then this is the way to go. By calling
setFields(ListGridField[]) you will override the ds fields. For datasources
used explicitly to back ListGrid views the ds doesn't really have to
declare fields. With one exception, it may need to declare a primary key
field, typically "id".
Anyway, this checkin does a few things:
- Apply the same pattern to all of our datasources for defining ds fields.
This pattern lets subclasses easily add to the superclass's fields.
- Add CoreGUI.isDebugEnabled()
- Add Table.setListGridFields(fields). This will handle any "id" field
defined in the underlying datasource. It will be shown in debug and
omitted otherwise.
- Update ResourceSearchView and ResourceDataSource to work in the new
fashion and serve (hopefully) as a decent example moving forward. Look
here if you want to fix issues in column widths.
- Misc: some null protection added, some selenium ID protection added
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 3544941..5bce6ba 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
@@ -88,6 +88,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
private static Messages messages;
+ private static boolean debugMode = true;
+
public void onModuleLoad() {
String hostPageBaseURL = GWT.getHostPageBaseURL();
if (hostPageBaseURL.indexOf("/coregui/") == -1) {
@@ -102,7 +104,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
coreGUI = this;
- if (!GWT.isScript()) {
+ debugMode = !GWT.isScript();
+ if (debugMode) {
KeyIdentifier debugKey = new KeyIdentifier();
debugKey.setCtrlKey(true);
debugKey.setKeyName("D");
@@ -331,4 +334,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
}
+ public static boolean isDebugMode() {
+ return debugMode;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
index 9af7064..a12bec5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.admin.roles;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -62,13 +63,24 @@ public class RolesDataSource extends RPCDataSource<Role> {
}
public RolesDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceField idDataField = new DataSourceIntegerField("id", "ID");
idDataField.setPrimaryKey(true);
idDataField.setCanEdit(false);
+ fields.add(idDataField);
DataSourceTextField nameField = new DataSourceTextField("name", "Name", 100, true);
+ fields.add(nameField);
- setFields(idDataField, nameField);
+ return fields;
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
index af9acd6..33b94a0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.admin.users;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -63,16 +64,28 @@ public class UsersDataSource extends RPCDataSource<Subject> {
}
public UsersDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idDataField = new DataSourceIntegerField("id", "ID");
idDataField.setPrimaryKey(true);
idDataField.setCanEdit(false);
+ fields.add(idDataField);
DataSourceTextField usernameField = new DataSourceTextField("name", "User Name", 100, true);
+ fields.add(usernameField);
DataSourceTextField firstName = new DataSourceTextField("firstName", "First Name", 100, true);
+ fields.add(firstName);
DataSourceTextField lastName = new DataSourceTextField("lastName", "Last Name", 100, true);
+ fields.add(lastName);
DataSourceTextField password = new DataSourceTextField("password", "Password", 100, false);
password.setType(FieldType.PASSWORD);
@@ -89,18 +102,22 @@ public class UsersDataSource extends RPCDataSource<Subject> {
passwordsEqualValidator.setOtherField("password");
passwordsEqualValidator.setErrorMessage("Passwords do not match");
passwordVerify.setValidators(passwordsEqualValidator);
+ fields.add(password);
DataSourceTextField emailAddress = new DataSourceTextField("emailAddress", "Email Address", 100, true);
+ fields.add(emailAddress);
DataSourceTextField phone = new DataSourceTextField("phoneNumber", "Phone", 15, false);
+ fields.add(phone);
DataSourceTextField department = new DataSourceTextField("department", "Department", 100, false);
+ fields.add(department);
DataSourceTextField enabled = new DataSourceTextField("factive", "Enabled");
enabled.setType(FieldType.BOOLEAN);
+ fields.add(enabled);
- setFields(idDataField, usernameField, firstName, lastName, password, passwordVerify, phone, emailAddress,
- department, enabled);
+ return fields;
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index a950c34..aaee63f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -18,7 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.alert;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -65,12 +64,13 @@ public class AlertDataSource extends RPCDataSource<Alert> {
setCanMultiSort(true);
- List<DataSourceField> fields = createFields();
+ List<DataSourceField> fields = addDataSourceFields();
addFields(fields);
}
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = new ArrayList<DataSourceField>();
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idField = new DataSourceIntegerField("id", "Id");
idField.setPrimaryKey(true);
@@ -284,7 +284,8 @@ public class AlertDataSource extends RPCDataSource<Alert> {
CoreGUI.getMessageCenter().notify(
new Message("Acknowledged [" + alertIds.length + "] alerts", Message.Severity.Info));
- com.allen_sauer.gwt.log.client.Log.info("Acknowledged Alerts with id's: " + Arrays.toString(alertIds) + ".");
+ com.allen_sauer.gwt.log.client.Log.info("Acknowledged Alerts with id's: " + Arrays.toString(alertIds)
+ + ".");
alertsView.refresh();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
index 7a53dbe..b7c9db8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
@@ -19,10 +19,12 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceImageField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.FieldType;
@@ -52,7 +54,9 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
protected static final String FIELD_OBJECT = "_object"; // the actual AlertDefinition object
public AbstractAlertDefinitionsDataSource() {
- setupFields();
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
}
@Override
@@ -94,27 +98,31 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
* free to call this method and then add more, or add their own custom set and not
* call this method at all (if they don't want some of these basic fields or want to reorder them).
*/
- protected void setupFields() {
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField nameField = new DataSourceTextField(FIELD_NAME, "Name");
- addField(nameField);
+ fields.add(nameField);
DataSourceTextField descriptionField = new DataSourceTextField(FIELD_DESCRIPTION, "Description");
- addField(descriptionField);
+ fields.add(descriptionField);
DataSourceTextField ctimeField = new DataSourceTextField(FIELD_CTIME, "Created Time");
ctimeField.setType(FieldType.DATETIME);
- addField(ctimeField);
+ fields.add(ctimeField);
DataSourceTextField mtimeField = new DataSourceTextField(FIELD_MTIME, "Modified Time");
mtimeField.setType(FieldType.DATETIME);
- addField(mtimeField);
+ fields.add(mtimeField);
DataSourceTextField enabledField = new DataSourceTextField(FIELD_ENABLED, "Enabled");
enabledField.setType(FieldType.BOOLEAN);
- addField(enabledField);
+ fields.add(enabledField);
DataSourceImageField priorityField = new DataSourceImageField(FIELD_PRIORITY, "Priority");
- addField(priorityField);
+ fields.add(priorityField);
+
+ return fields;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 2d4e85a..2d8463d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -24,10 +24,12 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Window;
@@ -148,8 +150,19 @@ public class ConditionsEditor extends LocatableVLayout {
private static final String FIELD_CONDITION = "condition";
public ConditionDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField conditionField = new DataSourceTextField(FIELD_CONDITION, "Condition");
- addField(conditionField);
+ fields.add(conditionField);
+
+ return fields;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
index f707dc1..f783b4c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -29,6 +29,7 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Window;
@@ -170,11 +171,26 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
private class NotificationDataSource extends RPCDataSource<AlertNotification> {
public NotificationDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField senderField = new DataSourceTextField(FIELD_SENDER, "Sender");
- addField(senderField);
+ fields.add(senderField);
DataSourceTextField configField = new DataSourceTextField(FIELD_CONFIGURATION, "Configuration");
- addField(configField);
+ fields.add(configField);
+
+ return fields;
+ }
+
+ @Override
+ public void useDatasourceDefinedFields() {
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
index f53710f..b9c4dca 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
@@ -23,10 +23,12 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.List;
import java.util.Map;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceLinkField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -81,15 +83,17 @@ public class ResourceAlertDefinitionsDataSource extends AbstractAlertDefinitions
}
@Override
- protected void setupFields() {
- super.setupFields();
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
// add two more columns
DataSourceLinkField parentIdField = new DataSourceLinkField(FIELD_PARENT, "Parent");
- addField(parentIdField);
+ fields.add(parentIdField);
DataSourceTextField readOnlyField = new DataSourceTextField(FIELD_READONLY, "Read Only");
- addField(readOnlyField);
+ fields.add(readOnlyField);
+
+ return fields;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
index a6e4da7..1f3ced4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
@@ -23,10 +23,12 @@
package org.rhq.enterprise.gui.coregui.client.bundle.deployment;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -48,25 +50,35 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundleDeploymentDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField id = new DataSourceIntegerField("id", "ID");
id.setPrimaryKey(true);
- addField(id);
+ fields.add(id);
DataSourceTextField name = new DataSourceTextField("name", "Deployment Name");
- addField(name);
+ fields.add(name);
DataSourceTextField bundleVersion = new DataSourceTextField("bundleVersionVersion", "Bundle Version");
- addField(bundleVersion);
+ fields.add(bundleVersion);
DataSourceTextField description = new DataSourceTextField("description", "Description");
- addField(description);
+ fields.add(description);
DataSourceTextField status = new DataSourceTextField("status", "Status");
- addField(status);
+ fields.add(status);
DataSourceDateTimeField created = new DataSourceDateTimeField("deploymentTime", "Deployment Time");
- addField(created);
+ fields.add(created);
+
+ return fields;
}
@Override
@@ -83,7 +95,8 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
}
if (request.getCriteria().getValues().containsKey("bundleDestinationId")) {
- criteria.addFilterDestinationId(Integer.parseInt(request.getCriteria().getAttribute("bundleDestinationId")));
+ criteria
+ .addFilterDestinationId(Integer.parseInt(request.getCriteria().getAttribute("bundleDestinationId")));
}
if (request.getCriteria().getValues().get("tagNamespace") != null) {
@@ -130,7 +143,6 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
record.setAttribute("status", from.getStatus().name());
record.setAttribute("deployer", from.getSubjectName());
-
if (from.getBundleVersion() != null) {
record.setAttribute("bundleVersionVersion", from.getBundleVersion().getVersion());
record.setAttribute("bundleVersionId", from.getBundleVersion().getId());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
index a2fa68e..1c23d51 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
@@ -22,15 +22,17 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.deployment.resource;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
-import org.rhq.core.domain.criteria.BundleDeploymentCriteria;
import org.rhq.core.domain.criteria.BundleResourceDeploymentCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
@@ -44,19 +46,27 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleResourceDeployment> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
-
public BundleResourceDeploymentDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
- DataSourceIntegerField id = new DataSourceIntegerField("id","ID");
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceIntegerField id = new DataSourceIntegerField("id", "ID");
id.setPrimaryKey(true);
- addField(id);
+ fields.add(id);
DataSourceTextField resourceName = new DataSourceTextField("resourceName", "Resource");
- addField(resourceName);
+ fields.add(resourceName);
DataSourceTextField status = new DataSourceTextField("status", "Status");
- addField(status);
+ fields.add(status);
+ return fields;
}
@Override
@@ -68,26 +78,27 @@ public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleReso
criteria.fetchHistories(true);
if (request.getCriteria().getValues().containsKey("bundleDeploymentId")) {
- criteria.addFilterBundleDeploymentId(Integer.parseInt(request.getCriteria().getAttribute("bundleDeploymentId")));
+ criteria.addFilterBundleDeploymentId(Integer.parseInt(request.getCriteria().getAttribute(
+ "bundleDeploymentId")));
}
- bundleService.findBundleResourceDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleResourceDeployment>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle resource deployments",caught);
- }
-
- public void onSuccess(PageList<BundleResourceDeployment> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ bundleService.findBundleResourceDeploymentsByCriteria(criteria,
+ new AsyncCallback<PageList<BundleResourceDeployment>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load bundle resource deployments", caught);
+ }
+ public void onSuccess(PageList<BundleResourceDeployment> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
@Override
public BundleResourceDeployment copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
@@ -97,10 +108,9 @@ public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleReso
record.setAttribute("resourceName", from.getResource().getName());
record.setAttribute("resourceId", from.getResource().getId());
- record.setAttribute("status",from.getStatus().name());
-
- record.setAttribute("histories",from.getBundleResourceDeploymentHistories());
+ record.setAttribute("status", from.getStatus().name());
+ record.setAttribute("histories", from.getBundleResourceDeploymentHistories());
from.getBundleResourceDeploymentHistories();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
index a375981..3985c78 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
@@ -23,10 +23,12 @@
package org.rhq.enterprise.gui.coregui.client.bundle.destination;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -34,7 +36,6 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDestination;
import org.rhq.core.domain.bundle.BundleVersion;
-import org.rhq.core.domain.criteria.BundleDeploymentCriteria;
import org.rhq.core.domain.criteria.BundleDestinationCriteria;
import org.rhq.core.domain.criteria.BundleVersionCriteria;
import org.rhq.core.domain.util.PageList;
@@ -48,38 +49,49 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
public class BundleDestinationDataSource extends RPCDataSource<BundleDestination> {
public BundleDestinationDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id", "Id");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField name = new DataSourceTextField("name", "Name");
- addField(name);
+ fields.add(name);
DataSourceTextField description = new DataSourceTextField("description", "Description");
- addField(description);
+ fields.add(description);
DataSourceTextField bundle = new DataSourceTextField("bundleName", "Bundle");
- addField(bundle);
+ fields.add(bundle);
DataSourceTextField group = new DataSourceTextField("groupName", "Group");
- addField(group);
+ fields.add(group);
DataSourceTextField deployDir = new DataSourceTextField("deployDir", "Deploy Directory");
- addField(deployDir);
+ fields.add(deployDir);
- DataSourceTextField latestDeploymentVersion = new DataSourceTextField("latestDeploymentVersion", "Last Deployed Version");
- addField(latestDeploymentVersion);
+ DataSourceTextField latestDeploymentVersion = new DataSourceTextField("latestDeploymentVersion",
+ "Last Deployed Version");
+ fields.add(latestDeploymentVersion);
- DataSourceTextField latestDeploymentDate = new DataSourceTextField("latestDeploymentDate", "Last Deployment Date");
- addField(latestDeploymentDate);
+ DataSourceTextField latestDeploymentDate = new DataSourceTextField("latestDeploymentDate",
+ "Last Deployment Date");
+ fields.add(latestDeploymentDate);
- DataSourceTextField latestDeploymentStatus = new DataSourceTextField("latestDeploymentStatus", "Last Deployment Status");
- addField(latestDeploymentStatus);
+ DataSourceTextField latestDeploymentStatus = new DataSourceTextField("latestDeploymentStatus",
+ "Last Deployment Status");
+ fields.add(latestDeploymentStatus);
+ return fields;
}
-
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
BundleDestinationCriteria criteria = new BundleDestinationCriteria();
@@ -88,7 +100,7 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
criteria.addFilterBundleId(Integer.parseInt(request.getCriteria().getAttributeAsString("bundleId")));
}
- if (request.getCriteria().getValues().get("tagNamespace") != null) {
+ if (request.getCriteria().getValues().get("tagNamespace") != null) {
criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
}
@@ -100,28 +112,29 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
}
-
criteria.fetchBundle(true);
criteria.fetchDeployments(true);
criteria.fetchGroup(true);
criteria.fetchTags(true);
-
GWTServiceLookup.getBundleService().findBundleDestinationsByCriteria(criteria,
- new AsyncCallback<PageList<BundleDestination>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle destinations",caught);
- }
+ new AsyncCallback<PageList<BundleDestination>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load bundle destinations", caught);
+ }
- public void onSuccess(final PageList<BundleDestination> result) {
+ public void onSuccess(final PageList<BundleDestination> result) {
- BundleVersionCriteria versionCriteria = new BundleVersionCriteria();
- if (request.getCriteria().getValues().containsKey("bundleId")) {
- versionCriteria.addFilterBundleId(Integer.parseInt(request.getCriteria().getAttributeAsString("bundleId")));
- }
- GWTServiceLookup.getBundleService().findBundleVersionsByCriteria(versionCriteria, new AsyncCallback<PageList<BundleVersion>>() {
+ BundleVersionCriteria versionCriteria = new BundleVersionCriteria();
+ if (request.getCriteria().getValues().containsKey("bundleId")) {
+ versionCriteria.addFilterBundleId(Integer.parseInt(request.getCriteria().getAttributeAsString(
+ "bundleId")));
+ }
+ GWTServiceLookup.getBundleService().findBundleVersionsByCriteria(versionCriteria,
+ new AsyncCallback<PageList<BundleVersion>>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle destination deployed version info",caught);
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to load bundle destination deployed version info", caught);
}
public void onSuccess(PageList<BundleVersion> versions) {
@@ -143,8 +156,8 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
}
});
- }
- });
+ }
+ });
}
@Override
@@ -168,7 +181,6 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
record.setAttribute("deployDir", from.getDeployDir());
record.setAttribute("entity", from);
-
long last = 0;
for (BundleDeployment dep : from.getDeployments()) {
if (last < dep.getCtime()) {
@@ -182,7 +194,6 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
}
}
-
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
index 6b08c63..b5b0444 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
@@ -18,9 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.list;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -39,26 +42,34 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
public class BundleVersionDataSource extends RPCDataSource<BundleVersion> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
- private int bundleId;
public BundleVersionDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceIntegerField idField = new DataSourceIntegerField("id", "ID");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField latestVersionField = new DataSourceTextField("version", "Version");
- addField(latestVersionField);
+ fields.add(latestVersionField);
DataSourceTextField nameField = new DataSourceTextField("name", "Name");
- addField(nameField);
+ fields.add(nameField);
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
- addField(descriptionField);
-
-
+ fields.add(descriptionField);
DataSourceIntegerField deploymentCountField = new DataSourceIntegerField("fileCount", "File Count");
- addField(deploymentCountField);
+ fields.add(deploymentCountField);
+
+ return fields;
}
@Override
@@ -70,7 +81,8 @@ public class BundleVersionDataSource extends RPCDataSource<BundleVersion> {
criteria.setPageControl(getPageControl(request));
if (request.getCriteria().getValues().get("bundleId") != null) {
- criteria.addFilterBundleId(Integer.parseInt(String.valueOf(request.getCriteria().getValues().get("bundleId"))));
+ criteria.addFilterBundleId(Integer.parseInt(String.valueOf(request.getCriteria().getValues()
+ .get("bundleId"))));
}
if (request.getCriteria().getValues().get("tagNamespace") != null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
index 7c8aa02..32cf81a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
@@ -18,9 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.list;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -41,19 +44,29 @@ public class BundlesDataSource extends RPCDataSource<Bundle> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundlesDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id", "ID");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField("name", "Name");
- addField(nameField);
+ fields.add(nameField);
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
- addField(descriptionField);
+ fields.add(descriptionField);
DataSourceTextField bundleTypeDataField = new DataSourceTextField("bundleType", "Bundle Type");
- addField(bundleTypeDataField);
+ fields.add(bundleTypeDataField);
+
+ return fields;
}
@Override
@@ -62,7 +75,6 @@ public class BundlesDataSource extends RPCDataSource<Bundle> {
BundleCriteria criteria = new BundleCriteria();
criteria.setPageControl(getPageControl(request));
-
if (request.getCriteria().getValues().get("tagNamespace") != null) {
criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
}
@@ -75,7 +87,6 @@ public class BundlesDataSource extends RPCDataSource<Bundle> {
criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
}
-
bundleService.findBundlesByCriteria(criteria, new AsyncCallback<PageList<Bundle>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Failed to load bundle data", caught);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
index e3b54ac..76340e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
@@ -18,9 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.list;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceLinkField;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -42,23 +45,32 @@ public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWith
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundlesWithLatestVersionDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id", "ID");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceLinkField linkField = new DataSourceLinkField("link", "Name");
- addField(linkField);
-
+ fields.add(linkField);
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
- addField(descriptionField);
+ fields.add(descriptionField);
DataSourceTextField latestVersionField = new DataSourceTextField("latestVersion", "Latest Version");
- addField(latestVersionField);
+ fields.add(latestVersionField);
DataSourceIntegerField deploymentCountField = new DataSourceIntegerField("versionsCount", "Versions Count");
- addField(deploymentCountField);
+ fields.add(deploymentCountField);
+
+ return fields;
}
@Override
@@ -78,7 +90,6 @@ public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWith
criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
}
-
bundleService.findBundlesWithLatestVersionCompositesByCriteria(criteria,
new AsyncCallback<PageList<BundleWithLatestVersionComposite>>() {
public void onFailure(Throwable caught) {
@@ -115,11 +126,9 @@ public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWith
record.setAttribute("id", from.getBundleId());
record.setAttribute("name", from.getBundleName());
-
record.setAttribute("link", "#Bundles/Bundle/" + from.getBundleId());
record.setLinkText(from.getBundleName());
-
record.setAttribute("description", from.getBundleDescription());
record.setAttribute("latestVersion", from.getLatestVersion());
record.setAttribute("versionsCount", Integer.valueOf(from.getVersionsCount().intValue())); // want int, not long
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
index f1661c8..16e5e67 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
@@ -24,6 +24,7 @@ package org.rhq.enterprise.gui.coregui.client.bundle.tree;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
@@ -50,25 +51,34 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
+@SuppressWarnings("unchecked")
public class BundleTreeDataSource extends RPCDataSource {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundleTreeDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceField idDataField = new DataSourceTextField("id", "ID");
idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
DataSourceTextField nameDataField = new DataSourceTextField("name", "Name");
nameDataField.setCanEdit(false);
-
- DataSourceTextField descriptionDataField = new DataSourceTextField("description", "Description");
- descriptionDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField parentIdField = new DataSourceTextField("parentId", "Parent ID");
parentIdField.setForeignKey("id");
+ fields.add(parentIdField);
-
- setFields(idDataField, nameDataField, parentIdField);
+ return fields;
}
@Override
@@ -97,8 +107,8 @@ public class BundleTreeDataSource extends RPCDataSource {
}
});
} else {
- if (p.endsWith(":versions")) {
- int bundleId = Integer.parseInt(p.substring(0, p.indexOf(":")));
+ if (p.endsWith("_versions")) {
+ int bundleId = Integer.parseInt(p.substring(0, p.indexOf("_")));
BundleVersionCriteria criteria = new BundleVersionCriteria();
criteria.addFilterBundleId(bundleId);
bundleService.findBundleVersionsByCriteria(criteria, new AsyncCallback<PageList<BundleVersion>>() {
@@ -114,46 +124,47 @@ public class BundleTreeDataSource extends RPCDataSource {
processResponse(request.getRequestId(), response);
}
});
- } else if (p.endsWith(":deployments")) {
- int bundleId = Integer.parseInt(p.substring(0, p.indexOf(":")));
+ } else if (p.endsWith("_deployments")) {
+ int bundleId = Integer.parseInt(p.substring(0, p.indexOf("_")));
BundleDeploymentCriteria criteria = new BundleDeploymentCriteria();
criteria.fetchBundleVersion(true);
criteria.addFilterBundleId(bundleId);
- bundleService.findBundleDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleDeployment>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle", caught);
- }
-
- public void onSuccess(PageList<BundleDeployment> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
- } else if (p.endsWith(":destinations")) {
- int bundleId = Integer.parseInt(p.substring(0, p.indexOf(":")));
+ bundleService.findBundleDeploymentsByCriteria(criteria,
+ new AsyncCallback<PageList<BundleDeployment>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load bundle", caught);
+ }
+
+ public void onSuccess(PageList<BundleDeployment> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ } else if (p.endsWith("_destinations")) {
+ int bundleId = Integer.parseInt(p.substring(0, p.indexOf("_")));
BundleDestinationCriteria criteria = new BundleDestinationCriteria();
criteria.addFilterBundleId(bundleId);
- bundleService.findBundleDestinationsByCriteria(criteria, new AsyncCallback<PageList<BundleDestination>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle destinations", caught);
- }
-
- public void onSuccess(PageList<BundleDestination> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ bundleService.findBundleDestinationsByCriteria(criteria,
+ new AsyncCallback<PageList<BundleDestination>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load bundle destinations", caught);
+ }
+
+ public void onSuccess(PageList<BundleDestination> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
}
-
}
@Override
public Object copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
@@ -171,14 +182,14 @@ public class BundleTreeDataSource extends RPCDataSource {
Bundle bundle = (Bundle) item;
TreeNode versionNode = new TreeNode("Versions");
- versionNode.setID(bundle.getId() + ":versions");
+ versionNode.setID(bundle.getId() + "_versions");
versionNode.setParentID(String.valueOf(bundle.getId()));
versionNode.setName("Versions");
versionNode.setAttribute("name", "Versions");
records.add(versionNode);
TreeNode deploymentsNode = new TreeNode("Destinations");
- deploymentsNode.setID(bundle.getId() + ":destinations");
+ deploymentsNode.setID(bundle.getId() + "_destinations");
deploymentsNode.setParentID(String.valueOf(bundle.getId()));
deploymentsNode.setName("Destinations");
records.add(deploymentsNode);
@@ -187,7 +198,6 @@ public class BundleTreeDataSource extends RPCDataSource {
return records.toArray(new ListGridRecord[records.size()]);
}
-
@Override
public ListGridRecord copyValues(Object from) {
TreeNode node = new TreeNode();
@@ -200,23 +210,23 @@ public class BundleTreeDataSource extends RPCDataSource {
} else if (from instanceof BundleVersion) {
BundleVersion version = (BundleVersion) from;
node.setName(version.getVersion());
- node.setID(version.getBundle().getId() + ":versions:" + version.getId());
- node.setParentID(version.getBundle().getId() + ":versions");
+ node.setID(version.getBundle().getId() + "_versions_" + version.getId());
+ node.setParentID(version.getBundle().getId() + "_versions");
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleVersion_16.png");
} else if (from instanceof BundleDeployment) {
BundleDeployment deployment = (BundleDeployment) from;
node.setName(deployment.getName() + " (" + deployment.getBundleVersion().getVersion() + ")");
- node.setID(deployment.getBundleVersion().getBundle().getId() + ":deployments:" + deployment.getId());
- node.setParentID(deployment.getBundleVersion().getBundle().getId() + ":deployments");
+ node.setID(deployment.getBundleVersion().getBundle().getId() + "_deployments_" + deployment.getId());
+ node.setParentID(deployment.getBundleVersion().getBundle().getId() + "_deployments");
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleDeployment_16.png");
} else if (from instanceof BundleDestination) {
BundleDestination destination = (BundleDestination) from;
node.setName(destination.getName());
- node.setID(destination.getBundle().getId() + ":destinations:" +destination.getId());
- node.setParentID(destination.getBundle().getId() + ":destinations");
+ node.setID(destination.getBundle().getId() + "_destinations_" + destination.getId());
+ node.setParentID(destination.getBundle().getId() + "_destinations");
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleDestination_16.png");
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index b4aff2b..7e2604e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -23,7 +23,9 @@ import java.util.List;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Autofit;
+import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.types.VerticalAlignment;
@@ -47,6 +49,7 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
@@ -484,6 +487,33 @@ public class Table extends LocatableHLayout implements RefreshableView {
return listGrid;
}
+ /**
+ * Wraps ListGrid.setFields(...) but takes care of "id" field display handling
+ * @param fields
+ */
+ public void setListGridFields(ListGridField... fields) {
+ if (null == this.dataSource.getField("id")) {
+ return;
+ }
+
+ if (CoreGUI.isDebugMode()) {
+ ListGridField idField = new ListGridField("id", "Id", 55);
+ idField.setType(ListGridFieldType.INTEGER);
+ idField.setCanEdit(false);
+ idField.setAlign(Alignment.LEFT);
+
+ ListGridField[] newFields = new ListGridField[fields.length + 1];
+ newFields[0] = idField;
+ for (int i = 0; i < fields.length; ++i) {
+ newFields[i + 1] = fields[i];
+ }
+ this.listGrid.setFields(newFields);
+ } else {
+ getListGrid().hideField("id");
+ this.listGrid.setFields(fields);
+ }
+ }
+
public void setTitleComponent(Canvas canvas) {
this.titleComponent = canvas;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
index 1d3f08d..a971a97 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
@@ -47,38 +47,37 @@ public class TaggingDataSource extends RPCDataSource<Tag> {
String search = (String) request.getCriteria().getValues().get("tag");
if (search != null) {
// todo
-// criteria.addFilter
+ // criteria.addFilter
}
- GWTServiceLookup.getTagService().findTagsByCriteria(new TagCriteria(),
- new AsyncCallback<PageList<Tag>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load tags",caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
+ GWTServiceLookup.getTagService().findTagsByCriteria(new TagCriteria(), new AsyncCallback<PageList<Tag>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load tags", caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
- public void onSuccess(PageList<Tag> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ public void onSuccess(PageList<Tag> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
@Override
public Tag copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
public ListGridRecord copyValues(Tag from) {
ListGridRecord record = new ListGridRecord();
- record.setAttribute("id",from.getId());
- record.setAttribute("namespace",from.getNamespace());
- record.setAttribute("semantic",from.getSemantic());
- record.setAttribute("name",from.getName());
- record.setAttribute("tag",from.toString());
+ record.setAttribute("id", from.getId());
+ record.setAttribute("namespace", from.getNamespace());
+ record.setAttribute("semantic", from.getSemantic());
+ record.setAttribute("name", from.getName());
+ record.setAttribute("tag", from.toString());
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
index f4b69ae..a2b8b37 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -28,11 +28,9 @@ import org.rhq.core.domain.util.StringUtils;
public class EnhancedTreeNode extends TreeNode {
public EnhancedTreeNode() {
super();
- // this(null);
}
public EnhancedTreeNode(String name) {
- //this(name, new TreeNode[0]);
super(name);
if (name != null) {
setTitle(StringUtils.deCamelCase(name));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
index 9b54565..9490647 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
@@ -22,6 +22,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.content.repository.tree;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -30,52 +32,54 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.tree.TreeNode;
-import org.rhq.core.domain.criteria.Criteria;
+import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.RepoGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import org.rhq.core.domain.content.Repo;
/**
* @author Greg Hinkle
*/
-public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
+public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
private RepoGWTServiceAsync repoService = GWTServiceLookup.getRepoService();
-
-
public ContentRepositoryTreeDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idDataField = new DataSourceTextField("id", "ID");
idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
DataSourceTextField nameDataField = new DataSourceTextField("name", "Name");
nameDataField.setCanEdit(false);
-
- DataSourceTextField descriptionDataField = new DataSourceTextField("description", "Description");
- descriptionDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField parentIdField = new DataSourceTextField("parentId", "Parent ID");
parentIdField.setForeignKey("id");
+ fields.add(parentIdField);
- setFields(idDataField, nameDataField, parentIdField);
+ return fields;
}
-
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
-
RepoCriteria criteria = new RepoCriteria();
-
repoService.findReposByCriteria(criteria, new AsyncCallback<PageList<Repo>>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load repositories",caught);
+ CoreGUI.getErrorHandler().handleError("Failed to load repositories", caught);
}
public void onSuccess(PageList<Repo> result) {
@@ -88,7 +92,7 @@ public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
@Override
public Repo copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
index 7f9d8fd..b0f94c3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
@@ -18,9 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform;
+import java.util.List;
+
import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.fields.DataSourceImageField;
-import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -38,15 +38,24 @@ public class PlatformMetricDataSource extends ResourceDatasource {
super();
this.view = view;
- DataSourceTextField cpuField = new DataSourceTextField("cpu","CPU");
- addField(cpuField);
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceTextField cpuField = new DataSourceTextField("cpu", "CPU");
+ fields.add(cpuField);
DataSourceTextField memoryField = new DataSourceTextField("memory", "Memory");
- addField(memoryField);
+ fields.add(memoryField);
+
DataSourceTextField swapField = new DataSourceTextField("swap", "Swap");
// todo swap
- }
-
+ return fields;
+ }
@Override
public ListGridRecord copyValues(Resource from) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
index b30714f..874d92d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
@@ -18,14 +18,19 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common;
+import java.util.List;
+import java.util.Map;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.fields.*;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
+import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.util.PageList;
@@ -34,10 +39,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
/**
* A server-side SmartGWT DataSource for reading {@link MeasurementDataTrait trait data}.
*
@@ -48,12 +49,13 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
protected AbstractMeasurementDataTraitDataSource() {
setCanMultiSort(true);
- List<DataSourceField> fields = createFields();
+ List<DataSourceField> fields = addDataSourceFields();
addFields(fields);
}
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = new ArrayList<DataSourceField>();
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceTextField primaryKeyField = new DataSourceTextField("primaryKey", "Primary Key");
primaryKeyField.setPrimaryKey(true);
@@ -65,17 +67,16 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME,
- "Trait");
+ "Trait");
fields.add(nameField);
// TODO: Include description from metric def?
- DataSourceTextField valueField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_VALUE,
- "Value");
+ DataSourceTextField valueField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_VALUE, "Value");
fields.add(valueField);
- DataSourceIntegerField timestampField = new DataSourceIntegerField(MeasurementDataTraitCriteria.SORT_FIELD_TIMESTAMP,
- "Last Changed");
+ DataSourceIntegerField timestampField = new DataSourceIntegerField(
+ MeasurementDataTraitCriteria.SORT_FIELD_TIMESTAMP, "Last Changed");
fields.add(timestampField);
return fields;
@@ -88,8 +89,7 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
this.measurementService.findTraitsByCriteria(criteria, new AsyncCallback<PageList<MeasurementDataTrait>>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to fetch traits for criteria " + criteria,
- caught);
+ CoreGUI.getErrorHandler().handleError("Failed to fetch traits for criteria " + criteria, caught);
response.setStatus(RPCResponse.STATUS_FAILURE);
processResponse(request.getRequestId(), response);
}
@@ -145,9 +145,10 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
record.setAttribute("primaryKey", from.getScheduleId() + ":" + from.getTimestamp());
record.setAttribute("id", from.getSchedule().getDefinition().getId()); // used for detail view
record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_TIMESTAMP, from.getTimestamp());
- record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME, from.getSchedule().getDefinition().getDisplayName());
+ record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME, from.getSchedule().getDefinition()
+ .getDisplayName());
record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_VALUE, from.getValue());
-
+
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
index 7782c87..1f7da77 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
@@ -49,7 +49,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*
* @author Ian Springer
*/
-public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPCDataSource<MeasurementScheduleComposite> {
+public abstract class AbstractMeasurementScheduleCompositeDataSource extends
+ RPCDataSource<MeasurementScheduleComposite> {
private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService();
protected AbstractMeasurementScheduleCompositeDataSource() {
@@ -57,37 +58,38 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
setCanMultiSort(true);
- List<DataSourceField> fields = createFields();
+ List<DataSourceField> fields = addDataSourceFields();
addFields(fields);
}
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = new ArrayList<DataSourceField>();
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceIntegerField idField = new DataSourceIntegerField(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID,
- "Id");
+ DataSourceIntegerField idField = new DataSourceIntegerField(
+ MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID, "Id");
idField.setPrimaryKey(true);
idField.setHidden(true);
fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME,
- "Metric");
+ "Metric");
fields.add(nameField);
- DataSourceTextField descriptionField = new DataSourceTextField(MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION,
- "Description");
+ DataSourceTextField descriptionField = new DataSourceTextField(
+ MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION, "Description");
fields.add(descriptionField);
DataSourceTextField typeField = new DataSourceTextField(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE,
- "Type");
+ "Type");
fields.add(typeField);
- DataSourceBooleanField enabledField = new DataSourceBooleanField(MeasurementScheduleCriteria.SORT_FIELD_ENABLED,
- "Enabled?");
+ DataSourceBooleanField enabledField = new DataSourceBooleanField(
+ MeasurementScheduleCriteria.SORT_FIELD_ENABLED, "Enabled?");
fields.add(enabledField);
- DataSourceIntegerField intervalField = new DataSourceIntegerField(MeasurementScheduleCriteria.SORT_FIELD_INTERVAL,
- "Collection Interval");
+ DataSourceIntegerField intervalField = new DataSourceIntegerField(
+ MeasurementScheduleCriteria.SORT_FIELD_INTERVAL, "Collection Interval");
fields.add(intervalField);
return fields;
@@ -96,21 +98,22 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
protected void executeFetch(final DSRequest request, final DSResponse response) {
final EntityContext entityContext = getEntityContext(request);
- this.measurementService.getMeasurementScheduleCompositesByContext(entityContext, new AsyncCallback<PageList<MeasurementScheduleComposite>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to fetch measurement schedules for context " + entityContext,
- caught);
- response.setStatus(RPCResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
+ this.measurementService.getMeasurementScheduleCompositesByContext(entityContext,
+ new AsyncCallback<PageList<MeasurementScheduleComposite>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to fetch measurement schedules for context " + entityContext, caught);
+ response.setStatus(RPCResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
- public void onSuccess(PageList<MeasurementScheduleComposite> result) {
- response.setData(buildRecords(result));
- // For paging to work, we have to specify size of full result set.
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
+ public void onSuccess(PageList<MeasurementScheduleComposite> result) {
+ response.setData(buildRecords(result));
+ // For paging to work, we have to specify size of full result set.
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
protected EntityContext getEntityContext(DSRequest request) {
@@ -150,15 +153,16 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
MeasurementDefinition measurementDefinition = from.getMeasurementDefinition();
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID, measurementDefinition.getId());
- record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME, measurementDefinition.getDisplayName());
+ record
+ .setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME, measurementDefinition.getDisplayName());
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION, measurementDefinition.getDescription());
- record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE,
- measurementDefinition.getDataType().name().toLowerCase());
+ record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE, measurementDefinition.getDataType()
+ .name().toLowerCase());
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_ENABLED, from.getCollectionEnabled());
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_INTERVAL, from.getCollectionInterval());
// TODO: resourceId and resourceGroupId (in subclasses)
-
+
return record;
}
@@ -170,7 +174,7 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
}
protected abstract void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames);
+ int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames);
public void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView) {
int[] ids = getMeasurementDefinitionIds(measurementScheduleListView);
@@ -180,7 +184,7 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
}
protected abstract void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames);
+ int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames);
public void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, long interval) {
int[] ids = getMeasurementDefinitionIds(measurementScheduleListView);
@@ -196,13 +200,15 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
int[] measurementDefinitionIds = new int[records.length];
for (int i = 0, selectionLength = records.length; i < selectionLength; i++) {
ListGridRecord record = records[i];
- Integer measurementDefinitionId = record.getAttributeAsInt(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID);
+ Integer measurementDefinitionId = record
+ .getAttributeAsInt(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID);
measurementDefinitionIds[i] = measurementDefinitionId;
}
return measurementDefinitionIds;
}
- private List<String> getMeasurementDefinitionDisplayNames(AbstractMeasurementScheduleListView measurementScheduleListView) {
+ private List<String> getMeasurementDefinitionDisplayNames(
+ AbstractMeasurementScheduleListView measurementScheduleListView) {
ListGrid listGrid = measurementScheduleListView.getListGrid();
ListGridRecord[] records = listGrid.getSelection();
List<String> displayNames = new ArrayList<String>(records.length);
@@ -214,5 +220,5 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
}
protected abstract void updateSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
- final int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames, final long interval);
+ final int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames, final long interval);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
index 40dc105..03d6575 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
@@ -22,11 +22,14 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.event;
+import java.util.List;
import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.types.FieldType;
@@ -54,23 +57,32 @@ public class EventCompositeDatasource extends RPCDataSource<EventComposite> {
public EventCompositeDatasource(EntityContext context) {
super();
this.entityContext = context;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- // DataSourceField id = new DataSourceIntegerField("id", "Id");
- // id.setPrimaryKey(true);
- // addField(id);
+ DataSourceField id = new DataSourceIntegerField("id", "Id");
+ id.setPrimaryKey(true);
+ fields.add(id);
DataSourceTextField timestamp = new DataSourceTextField("timestamp", "Timestamp");
timestamp.setType(FieldType.DATETIME);
- addField(timestamp);
+ fields.add(timestamp);
DataSourceTextField severity = new DataSourceTextField("severity", "Severity");
- addField(severity);
+ fields.add(severity);
DataSourceTextField details = new HighlightingDatasourceTextField("details", "Details");
- addField(details);
+ fields.add(details);
DataSourceTextField sourceLocation = new DataSourceTextField("source", "Source Location");
- addField(sourceLocation);
+ fields.add(sourceLocation);
+
+ return fields;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index 4bdfdd4..4ddfa54 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -120,7 +120,7 @@ public class EventCompositeHistoryView extends TableSection {
}
});
- grid.setFields(timestampField, severityField, detailsField, sourceField);
+ setListGridFields(timestampField, severityField, detailsField, sourceField);
/*
grid.getField("timestamp").setWidth(125);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
index 0da1963..6fd1d01 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
@@ -21,9 +21,12 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups;
import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.CATEGORY;
import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.NAME;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -57,18 +60,32 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
public ResourceGroupCompositeDataSource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceTextField nameDataField = new DataSourceTextField("name", "Name", 200);
nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField descriptionDataField = new DataSourceTextField("description", "Description");
descriptionDataField.setCanEdit(false);
+ fields.add(descriptionDataField);
DataSourceTextField typeNameDataField = new DataSourceTextField("typeName", "Type");
+ fields.add(typeNameDataField);
+
DataSourceTextField pluginNameDataField = new DataSourceTextField("pluginName", "Plugin");
+ fields.add(pluginNameDataField);
+
DataSourceTextField categoryDataField = new DataSourceTextField("category", "Category");
+ fields.add(categoryDataField);
- setFields(nameDataField, descriptionDataField, typeNameDataField, pluginNameDataField, categoryDataField);
+ return fields;
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
index 2a02c99..190baf7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
@@ -21,6 +21,8 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups;
import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.CATEGORY;
import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.NAME;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -58,22 +60,36 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
public ResourceGroupsDataSource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 20);
idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
DataSourceTextField nameDataField = new DataSourceTextField("name", "Name", 200);
nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField descriptionDataField = new DataSourceTextField("description", "Description");
descriptionDataField.setCanEdit(false);
+ fields.add(descriptionDataField);
DataSourceTextField typeNameDataField = new DataSourceTextField("typeName", "Type");
+ fields.add(typeNameDataField);
+
DataSourceTextField pluginNameDataField = new DataSourceTextField("pluginName", "Plugin");
+ fields.add(pluginNameDataField);
+
DataSourceTextField categoryDataField = new DataSourceTextField("category", "Category");
+ fields.add(categoryDataField);
- setFields(idDataField, nameDataField, descriptionDataField, typeNameDataField, pluginNameDataField,
- categoryDataField);
+ return fields;
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
index f4da478..e9824e9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import com.google.gwt.core.client.JavaScriptObject;
@@ -59,31 +60,39 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
private GroupDefinitionDataSource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idField = new DataSourceIntegerField("id", "ID");
idField.setPrimaryKey(true);
idField.setCanEdit(false);
+ fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField("name", "Name");
nameField.setRequired(true);
+ fields.add(nameField);
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
+ fields.add(descriptionField);
DataSourceTextField expressionField = new DataSourceTextField("expression", "Expression Set");
expressionField.setRequired(true);
+ fields.add(expressionField);
DataSourceIntegerField lastCalculationTimeIntervalField = new DataSourceIntegerField("lastCalculationTime",
"Recalculation Interval");
+ fields.add(lastCalculationTimeIntervalField);
DataSourceIntegerField nextCalculationTimeField = new DataSourceIntegerField("nextCalculationTime",
"Next Calculation Time");
+ fields.add(nextCalculationTimeField);
- addField(idField);
- addField(nameField);
- addField(descriptionField);
- addField(expressionField);
- addField(lastCalculationTimeIntervalField);
- addField(nextCalculationTimeField);
+ return fields;
}
@Override
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 481354b..fc08133 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
@@ -59,8 +59,8 @@ import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
-import org.rhq.enterprise.gui.coregui.client.util.TreeUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
@@ -270,7 +270,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
ClusterKey rootKey = new ClusterKey(root.getGroupId());
loadTree(rootNode, root, rootKey);
-
+
Tree tree = new Tree();
tree.setRoot(fakeRoot);
@@ -347,26 +347,27 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
}
if (lastSubcategoryNode != null) {
- List<TreeNode> currentSubcategoryChildren = subCategoryChildrenByName.get(currentSubcategoryNode.getName());
+ List<TreeNode> currentSubcategoryChildren = subCategoryChildrenByName
+ .get(currentSubcategoryNode.getName());
currentSubcategoryChildren.add(lastSubcategoryNode);
}
lastSubcategoryNode = currentSubcategoryNode;
- } while (currentSubcategoryNodeCreated &&
- (currentSubCategory = currentSubCategory.getParentSubCategory()) != null);
+ } while (currentSubcategoryNodeCreated
+ && (currentSubCategory = currentSubCategory.getParentSubCategory()) != null);
List<TreeNode> subcategoryChildren = subCategoryChildrenByName.get(subcategory.getName());
subcategoryChildren.addAll(nodesByType);
- } else {
+ } else {
childNodes.addAll(nodesByType);
}
}
-
+
for (String subcategoryName : subCategoryNodesByName.keySet()) {
TreeNode subcategoryNode = subCategoryNodesByName.get(subcategoryName);
List<TreeNode> subcategoryChildren = subCategoryChildrenByName.get(subcategoryName);
subcategoryNode.setChildren(subcategoryChildren.toArray(new TreeNode[subcategoryChildren.size()]));
}
-
+
parentNode.setChildren(childNodes.toArray(new TreeNode[childNodes.size()]));
}
}
@@ -377,7 +378,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
ClusterKeyFlyweight keyFlyweight = child.getClusterKey();
ClusterKey key = new ClusterKey(parentKey, keyFlyweight.getResourceTypeId(), keyFlyweight.getResourceKey());
String id = key.getKey();
- node.setID(id);
+ node.setID(SeleniumUtility.getSafeId(id));
node.setAttribute("key", key);
node.setAttribute("resourceType", type);
node.setIsFolder(!child.getChildren().isEmpty());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
index 158448b..79a9b2a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
@@ -36,8 +38,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasuremen
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import java.util.List;
-
/**
* A DataSource for reading and updating the metric schedules for the current group.
*
@@ -52,12 +52,14 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
}
@Override
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = super.createFields();
- DataSourceField resourceGroupIdField = new DataSourceIntegerField(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID,
- "Resource Group Id");
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceField resourceGroupIdField = new DataSourceIntegerField(
+ MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID, "Resource Group Id");
resourceGroupIdField.setHidden(true);
fields.add(resourceGroupIdField);
+
return fields;
}
@@ -83,73 +85,76 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
@Override
protected void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
this.measurementService.enableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to enable collection of metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Enabled collection of selected metric" + s + ".",
- "Enabled collection of metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId +
- "].", Message.Severity.Info));
-
- }
- });
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to enable collection of metric" + s + " " + measurementDefinitionDisplayNames
+ + " for Resource group with id [" + resourceGroupId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Enabled collection of selected metric" + s + ".", "Enabled collection of metric"
+ + s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
+ + resourceGroupId + "].", Message.Severity.Info));
+
+ }
+ });
}
@Override
- protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
this.measurementService.disableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to disable collection of metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Disabled collection of selected metric" + s + ".",
- "Disabled collection of metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId +
- "].", Message.Severity.Info));
-
- }
- });
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to disable collection of metric" + s + " " + measurementDefinitionDisplayNames
+ + " for Resource group with id [" + resourceGroupId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Disabled collection of selected metric" + s + ".", "Disabled collection of metric"
+ + s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
+ + resourceGroupId + "].", Message.Severity.Info));
+
+ }
+ });
}
@Override
protected void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames, final long collectionInterval) {
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames,
+ final long collectionInterval) {
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
- this.measurementService.updateSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds, collectionInterval,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to set collection interval to " + (collectionInterval / 1000)
- + " seconds for metric" + s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
- + resourceGroupId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Updated collection intervals of selected metric" + s + ".",
- "Collection interval for metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId +
- "] set to " + (collectionInterval / 1000) + " seconds.", Message.Severity.Info));
-
- }
- });
+ this.measurementService.updateSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
+ collectionInterval, new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to set collection interval to " + (collectionInterval / 1000) + " seconds for metric"
+ + s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
+ + resourceGroupId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Updated collection intervals of selected metric" + s + ".",
+ "Collection interval for metric" + s + " " + measurementDefinitionDisplayNames
+ + " for Resource group with id [" + resourceGroupId + "] set to "
+ + (collectionInterval / 1000) + " seconds.", Message.Severity.Info));
+
+ }
+ });
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
index 4be1f22..3321237 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
@@ -18,16 +18,17 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits;
+import java.util.List;
+
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitDataSource;
-import java.util.List;
-
/**
* A DataSource for reading traits for the current group.
*
@@ -41,16 +42,16 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
}
@Override
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = super.createFields();
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceIntegerField groupIdField =
- new DataSourceIntegerField(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, "Group Id");
+ DataSourceIntegerField groupIdField = new DataSourceIntegerField(
+ MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, "Group Id");
groupIdField.setHidden(true);
fields.add(0, groupIdField);
- DataSourceTextField resourceNameField =
- new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, "Member Resource");
+ DataSourceTextField resourceNameField = new DataSourceTextField(
+ MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, "Member Resource");
fields.add(0, resourceNameField);
return fields;
@@ -62,8 +63,8 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, this.groupId);
- record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME,
- from.getSchedule().getResource().getName());
+ record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, from.getSchedule().getResource()
+ .getName());
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
index 766df27..2b3a4c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
@@ -25,6 +25,8 @@ import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceD
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -54,31 +56,53 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
public ResourceDatasource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 20);
+ DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 50);
idDataField.setPrimaryKey(true);
+ idDataField.setCanEdit(false);
+ fields.add(idDataField);
DataSourceImageField iconField = new DataSourceImageField("icon", "");
iconField.setImageURLPrefix("types/");
+ fields.add(iconField);
DataSourceTextField nameDataField = new DataSourceTextField(NAME.propertyName(), NAME.title(), 200);
nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField descriptionDataField = new DataSourceTextField(DESCRIPTION.propertyName(), DESCRIPTION
.title());
descriptionDataField.setCanEdit(false);
+ fields.add(descriptionDataField);
DataSourceTextField typeNameDataField = new DataSourceTextField(TYPE.propertyName(), TYPE.title());
+ fields.add(typeNameDataField);
+
DataSourceTextField pluginNameDataField = new DataSourceTextField(PLUGIN.propertyName(), PLUGIN.title());
+ fields.add(pluginNameDataField);
+
DataSourceTextField categoryDataField = new DataSourceTextField(CATEGORY.propertyName(), CATEGORY.title());
+ fields.add(categoryDataField);
DataSourceImageField availabilityDataField = new DataSourceImageField(AVAILABILITY.propertyName(), AVAILABILITY
.title(), 20);
-
availabilityDataField.setCanEdit(false);
+ fields.add(availabilityDataField);
+
+ return fields;
+ }
+
+ @Override
+ public void useDatasourceDefinedFields() {
+ // TODO Auto-generated method stub
- setFields(idDataField, iconField, nameDataField, descriptionDataField, typeNameDataField, pluginNameDataField,
- categoryDataField, availabilityDataField);
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 15bf220..82595af 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -18,13 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
-
import java.util.ArrayList;
import java.util.List;
@@ -96,18 +89,18 @@ public class ResourceSearchView extends Table {
// searchPanel.setFields(searchBox);
final ResourceDatasource datasource = new ResourceDatasource();
- // setTitleComponent(searchPanel);
setDataSource(datasource);
-
}
@Override
protected void configureTable() {
- ListGridField idField = new ListGridField("id", "Id", 55);
- idField.setType(ListGridFieldType.INTEGER);
- //idField.setHidden(true);
- ListGridField iconField = new ListGridField("icon", "", 40);
- ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
+
+ ListGridField iconField = new ListGridField("icon", "Icon", 40);
+ iconField.setType(ListGridFieldType.IMAGE);
+ iconField.setImageURLPrefix("types/");
+
+ ListGridField nameField = new ListGridField(ResourceDataSourceField.NAME.propertyName(),
+ ResourceDataSourceField.NAME.title(), 250);
nameField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
return "<a href=\"" + LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("id")) + "\">" + o
@@ -115,15 +108,25 @@ public class ResourceSearchView extends Table {
}
});
- ListGridField descriptionField = new ListGridField(DESCRIPTION.propertyName(), DESCRIPTION.title());
- ListGridField typeNameField = new ListGridField(TYPE.propertyName(), TYPE.title(), 130);
- ListGridField pluginNameField = new ListGridField(PLUGIN.propertyName(), PLUGIN.title(), 100);
- ListGridField categoryField = new ListGridField(CATEGORY.propertyName(), CATEGORY.title(), 60);
+ ListGridField descriptionField = new ListGridField(ResourceDataSourceField.DESCRIPTION.propertyName(),
+ ResourceDataSourceField.DESCRIPTION.title());
- ListGridField availabilityField = new ListGridField(AVAILABILITY.propertyName(), AVAILABILITY.title(), 55);
+ ListGridField typeNameField = new ListGridField(ResourceDataSourceField.TYPE.propertyName(),
+ ResourceDataSourceField.TYPE.title(), 130);
+
+ ListGridField pluginNameField = new ListGridField(ResourceDataSourceField.PLUGIN.propertyName(),
+ ResourceDataSourceField.PLUGIN.title(), 100);
+
+ ListGridField categoryField = new ListGridField(ResourceDataSourceField.CATEGORY.propertyName(),
+ ResourceDataSourceField.CATEGORY.title(), 60);
+
+ ListGridField availabilityField = new ListGridField(ResourceDataSourceField.AVAILABILITY.propertyName(),
+ ResourceDataSourceField.AVAILABILITY.title(), 55);
+ availabilityField.setType(ListGridFieldType.IMAGE);
availabilityField.setAlign(Alignment.CENTER);
- getListGrid().setFields(idField, iconField, nameField, descriptionField, typeNameField, pluginNameField,
- categoryField, availabilityField);
+
+ setListGridFields(iconField, nameField, descriptionField, typeNameField, pluginNameField, categoryField,
+ availabilityField);
addTableAction(extendLocatorId("Uninventory"), "Uninventory", Table.SelectionEnablement.ANY,
"Are you sure you want to uninventory # resources?", new TableAction() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
index f8387c9..e777bc9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
@@ -19,10 +19,12 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.FieldType;
@@ -45,25 +47,32 @@ public class ConfigurationHistoryDataSource extends RPCDataSource<ResourceConfig
public ConfigurationHistoryDataSource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField resourceField = new DataSourceTextField("resource", "Resource");
- addField(resourceField);
+ fields.add(resourceField);
DataSourceTextField submittedField = new DataSourceTextField("createdTime", "Created");
submittedField.setType(FieldType.DATETIME);
- addField(submittedField);
+ fields.add(submittedField);
DataSourceTextField statusField = new DataSourceTextField("status", "Status");
- addField(statusField);
+ fields.add(statusField);
DataSourceTextField subjectField = new DataSourceTextField("subject", "Subject");
- addField(subjectField);
-
+ fields.add(subjectField);
+ return fields;
}
@Override
@@ -75,31 +84,30 @@ public class ConfigurationHistoryDataSource extends RPCDataSource<ResourceConfig
criteria.setPageControl(getPageControl(request));
- Integer resourceId = (Integer)request.getCriteria().getValues().get("resourceId");
+ Integer resourceId = (Integer) request.getCriteria().getValues().get("resourceId");
if (resourceId != null) {
criteria.addFilterResourceIds(resourceId);
}
configurationService.findResourceConfigurationUpdatesByCriteria(criteria,
- new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Unable to load configuration history", caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
+ new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Unable to load configuration history", caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
-
@Override
public ResourceConfigurationUpdate copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
index f412d7b..0361f65 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
@@ -22,12 +22,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring;
-import java.util.Collection;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -40,7 +40,6 @@ import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
@@ -48,54 +47,58 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*/
public class ResourceScheduledMetricDatasource extends RPCDataSource<MeasurementDefinition> {
-
public ResourceScheduledMetricDatasource() {
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField id = new DataSourceIntegerField("id");
id.setPrimaryKey(true);
- addField(id);
+ fields.add(id);
DataSourceTextField name = new DataSourceTextField("name");
- addField(name);
+ fields.add(name);
DataSourceTextField displayName = new DataSourceTextField("displayName");
- addField(displayName);
+ fields.add(displayName);
DataSourceTextField description = new DataSourceTextField("description");
- addField(description);
+ fields.add(description);
DataSourceTextField units = new DataSourceTextField("units");
- addField(units);
+ fields.add(units);
DataSourceTextField numericType = new DataSourceTextField("numericType");
- addField(numericType);
+ fields.add(numericType);
DataSourceTextField category = new DataSourceTextField("category");
- addField(category);
+ fields.add(category);
+
+ return fields;
}
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
-
-
-
if (request.getCriteria().getValues().containsKey("id")) {
MeasurementDefinitionCriteria criteria = new MeasurementDefinitionCriteria();
criteria.addFilterId(request.getCriteria().getAttributeAsInt("id"));
GWTServiceLookup.getMeasurementDataService().findMeasurementDefinitionsByCriteria(criteria,
- new AsyncCallback<PageList<MeasurementDefinition>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load metric definitions",caught);
- }
-
- public void onSuccess(PageList<MeasurementDefinition> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ new AsyncCallback<PageList<MeasurementDefinition>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load metric definitions", caught);
+ }
+ public void onSuccess(PageList<MeasurementDefinition> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
} else if (request.getCriteria().getValues().containsKey("resourceId")) {
MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
@@ -103,17 +106,17 @@ public class ResourceScheduledMetricDatasource extends RPCDataSource<Measurement
criteria.addFilterResourceId(request.getCriteria().getAttributeAsInt("resourceId"));
-
- GWTServiceLookup.getMeasurementDataService().findMeasurementSchedulesByCriteria(criteria, new AsyncCallback<PageList<MeasurementSchedule>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load metric schedules", caught);
- }
-
- public void onSuccess(PageList<MeasurementSchedule> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ GWTServiceLookup.getMeasurementDataService().findMeasurementSchedulesByCriteria(criteria,
+ new AsyncCallback<PageList<MeasurementSchedule>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load metric schedules", caught);
+ }
+
+ public void onSuccess(PageList<MeasurementSchedule> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
} else {
processResponse(request.getRequestId(), response);
}
@@ -131,10 +134,9 @@ public class ResourceScheduledMetricDatasource extends RPCDataSource<Measurement
return buildRecords(definitions);
}
-
@Override
public MeasurementDefinition copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
index 5efbcca..843e2af 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
@@ -18,9 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.calltime;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.HTMLFlow;
@@ -41,20 +44,28 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
private double maxMaximum;
public CallTimeDataSource() {
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceTextField callDestination = new DataSourceTextField("callDestination", "Call Destination");
- addField(callDestination);
+ fields.add(callDestination);
DataSourceIntegerField count = new DataSourceIntegerField("count");
- addField(count);
+ fields.add(count);
DataSourceIntegerField minimum = new DataSourceIntegerField("minimum");
- addField(minimum);
+ fields.add(minimum);
DataSourceIntegerField average = new DataSourceIntegerField("average");
- addField(average);
+ fields.add(average);
DataSourceIntegerField maximum = new DataSourceIntegerField("maximum");
- addField(maximum);
+ fields.add(maximum);
DataSourceIntegerField total = new DataSourceIntegerField("total");
- addField(total);
+ fields.add(total);
+ return fields;
}
@Override
@@ -66,21 +77,20 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
PageControl pc = getPageControl(request);
- GWTServiceLookup.getMeasurementDataService().findCallTimeDataForResource(
- scheduleId, eightHoursAgo, now, pc, new AsyncCallback<PageList<CallTimeDataComposite>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Could not load call time data", caught);
- }
+ GWTServiceLookup.getMeasurementDataService().findCallTimeDataForResource(scheduleId, eightHoursAgo, now, pc,
+ new AsyncCallback<PageList<CallTimeDataComposite>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Could not load call time data", caught);
+ }
- public void onSuccess(PageList<CallTimeDataComposite> result) {
- ListGridRecord[] data = buildRecords(result);
- setGraphs(data);
- response.setData(data);
+ public void onSuccess(PageList<CallTimeDataComposite> result) {
+ ListGridRecord[] data = buildRecords(result);
+ setGraphs(data);
+ response.setData(data);
- processResponse(request.getRequestId(), response);
- }
+ processResponse(request.getRequestId(), response);
}
- );
+ });
}
@Override
@@ -100,13 +110,10 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
int avgWidth = (int) ((record.getAttributeAsInt("average") / maxMaximum) * 100d);
int maxWidth = (int) ((record.getAttributeAsInt("maximum") / maxMaximum) * 100d);
-
-
- record.setBackgroundComponent(
- new HTMLFlow(
- "<div style=\"width: " + minWidth + "%; height: 33%; background-color: #A5B391;\"> </div>" +
- "<div style=\"width: " + avgWidth + "%; height: 33%; background-color: #A5B391;\"> </div>" +
- "<div style=\"width: " + maxWidth + "%; height: 33%; background-color: #A5B391;\"> </div>"));
+ record.setBackgroundComponent(new HTMLFlow("<div style=\"width: " + minWidth
+ + "%; height: 33%; background-color: #A5B391;\"> </div>" + "<div style=\"width: " + avgWidth
+ + "%; height: 33%; background-color: #A5B391;\"> </div>" + "<div style=\"width: " + maxWidth
+ + "%; height: 33%; background-color: #A5B391;\"> </div>"));
}
@@ -124,7 +131,6 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
record.setAttribute("maximum", from.getMaximum());
record.setAttribute("total", from.getTotal());
-
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java
index 21fe764..ac7c8dd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
@@ -35,8 +37,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasuremen
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import java.util.List;
-
/**
* A DataSource for reading and updating the metric schedules for the current Resource.
*
@@ -51,12 +51,14 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
}
@Override
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = super.createFields();
- DataSourceField resourceIdField = new DataSourceIntegerField(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_ID,
- "Resource Id");
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceField resourceIdField = new DataSourceIntegerField(
+ MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_ID, "Resource Id");
resourceIdField.setHidden(true);
fields.add(resourceIdField);
+
return fields;
}
@@ -76,67 +78,70 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
@Override
protected void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
- this.measurementService.enableSchedulesForResource(this.resourceId, measurementDefinitionIds,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to enable collection of metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Enabled collection of metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId +
- "].", Message.Severity.Info));
-
- }
- });
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ this.measurementService.enableSchedulesForResource(this.resourceId, measurementDefinitionIds,
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to enable collection of metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Enabled collection of metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "].", Message.Severity.Info));
+
+ }
+ });
}
@Override
- protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
- this.measurementService.disableSchedulesForResource(this.resourceId, measurementDefinitionIds,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to disable collection of metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Disabled collection of metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId +
- "].", Message.Severity.Info));
-
- }
- });
+ protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ this.measurementService.disableSchedulesForResource(this.resourceId, measurementDefinitionIds,
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to disable collection of metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Disabled collection of metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "].", Message.Severity.Info));
+
+ }
+ });
}
@Override
protected void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames, final long collectionInterval) {
- this.measurementService.updateSchedulesForResource(this.resourceId, measurementDefinitionIds, collectionInterval,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to set collection interval to " + (collectionInterval / 1000)
- + " seconds for metrics " + measurementDefinitionDisplayNames + " for Resource with id ["
- + resourceId + "].",
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames,
+ final long collectionInterval) {
+ this.measurementService.updateSchedulesForResource(this.resourceId, measurementDefinitionIds,
+ collectionInterval, new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to set collection interval to " + (collectionInterval / 1000) + " seconds for metrics "
+ + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId + "].",
throwable);
- }
+ }
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Collection interval for metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId +
- "] set to " + (collectionInterval / 1000) + " seconds.", Message.Severity.Info));
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Collection interval for metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "] set to " + (collectionInterval / 1000)
+ + " seconds.", Message.Severity.Info));
- }
- });
+ }
+ });
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java
index c569260..67a330a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java
@@ -18,28 +18,29 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.traits;
-import com.smartgwt.client.data.DSRequest;
+import java.util.List;
+
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitDataSource;
-import java.util.List;
-
/**
* A DataSource for reading traits for the current Resource.
*
* @author Ian Springer
*/
public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
+
@Override
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = super.createFields();
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceIntegerField resourceIdField =
- new DataSourceIntegerField(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, "Resource Id");
+ DataSourceIntegerField resourceIdField = new DataSourceIntegerField(
+ MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, "Resource Id");
resourceIdField.setHidden(true);
fields.add(0, resourceIdField);
@@ -50,7 +51,8 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
public ListGridRecord copyValues(MeasurementDataTrait from) {
ListGridRecord record = super.copyValues(from);
- record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, from.getSchedule().getResource().getId());
+ record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, from.getSchedule().getResource()
+ .getId());
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
index c353fdb..9af5c3b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
@@ -19,10 +19,12 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.FieldType;
@@ -43,51 +45,57 @@ public class OperationHistoryDataSource extends RPCDataSource<ResourceOperationH
private OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
-
public OperationHistoryDataSource() {
- super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField("operationName");
- addField(nameField);
+ fields.add(nameField);
DataSourceTextField resourceField = new DataSourceTextField("resource");
- addField(resourceField);
+ fields.add(resourceField);
DataSourceTextField statusField = new DataSourceTextField("status");
- addField(statusField);
+ fields.add(statusField);
DataSourceTextField startedField = new DataSourceTextField("startedTime");
startedField.setType(FieldType.DATETIME);
- addField(startedField);
+ fields.add(startedField);
+
+ return fields;
}
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
-
if (request.getCriteria().getValues().containsKey("resourceId")) {
- criteria.addFilterResourceIds(Integer.parseInt((String) request.getCriteria().getValues().get("resourceId")));
+ criteria.addFilterResourceIds(Integer
+ .parseInt((String) request.getCriteria().getValues().get("resourceId")));
}
criteria.setPageControl(getPageControl(request));
- operationService.findResourceOperationHistoriesByCriteria(
- criteria, new AsyncCallback<PageList<ResourceOperationHistory>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failure loading operation histories", caught);
- }
+ operationService.findResourceOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceOperationHistory>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failure loading operation histories", caught);
+ }
- public void onSuccess(PageList<ResourceOperationHistory> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
+ public void onSuccess(PageList<ResourceOperationHistory> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
}
- );
+ });
}
@Override
@@ -110,7 +118,7 @@ public class OperationHistoryDataSource extends RPCDataSource<ResourceOperationH
record.setAttribute("status", from.getStatus().name());
record.setAttribute("parameters", from.getParameters());
- record.setAttribute("entity",from);
+ record.setAttribute("entity", from);
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
index 1843f2b..39e99af 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
@@ -22,22 +22,22 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
import java.util.Date;
import java.util.List;
-import org.rhq.core.domain.resource.ResourceError;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-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.util.RPCDataSource;
-
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.fields.DataSourceDateField;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceEnumField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.resource.ResourceError;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+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.util.RPCDataSource;
+
/**
*
* @author Lukas Krejci
@@ -55,10 +55,20 @@ public class ResourceErrorsDataSource extends RPCDataSource<ResourceError> {
public ResourceErrorsDataSource(int resourceId) {
resourceService = GWTServiceLookup.getResourceService();
this.resourceId = resourceId;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ fields.add(new DataSourceTextField(SUMMARY_ID, "Summary"));
+ fields.add(new DataSourceTextField(DETAIL_ID, "Detailed Message"));
+ fields.add(new DataSourceEnumField(ERROR_TYPE_ID, "Error Type"));
+ fields.add(new DataSourceDateTimeField(TIME_OCCURED_ID, "Time"));
- addFields(new DataSourceTextField(SUMMARY_ID, "Summary"),
- new DataSourceTextField(DETAIL_ID, "Detailed Message"),
- new DataSourceEnumField(ERROR_TYPE_ID, "Error Type"), new DataSourceDateTimeField(TIME_OCCURED_ID, "Time"));
+ return fields;
}
/* (non-Javadoc)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
index 5e6d943..9546d66 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
@@ -194,7 +194,8 @@ public class SearchBarPane extends LocatableHLayout {
comboBox.setShowIfCondition(new FormItemIfFunction() {
public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return dynamicForm.getValueAsString("searchType").equals(searchType.getDisplayName());
+ String value = dynamicForm.getValueAsString("searchType");
+ return (null != value && value.equals(searchType.getDisplayName()));
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
index 863afe2..24ada45 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
@@ -24,6 +24,7 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -69,18 +70,31 @@ public class RecentOperationsDataSource extends
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField resourceField = new DataSourceTextField(resource, "Resource");
resourceField.setPrimaryKey(true);
+ fields.add(resourceField);
DataSourceTextField locationField = new DataSourceTextField(location, "Location", 200);
+ fields.add(locationField);
DataSourceTextField operationField = new DataSourceTextField(operation, "Operation");
+ fields.add(operationField);
DataSourceDateTimeField timeField = new DataSourceDateTimeField(time, "Date/Time");
+ fields.add(timeField);
DataSourceTextField statusField = new DataSourceTextField(status, "Status");
+ fields.add(statusField);
- setFields(resourceField, locationField, operationField, timeField, statusField);
+ return fields;
}
/* Intercept DSRequest object to pipe into custom fetch request.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index ebb1185..ab28a8e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -24,7 +24,9 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
@@ -63,16 +65,28 @@ public class ScheduledOperationsDataSource extends
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField resourceField = new DataSourceTextField(resource, "Resource");
resourceField.setPrimaryKey(true);
+ fields.add(resourceField);
- DataSourceTextField locationField = new DataSourceTextField(location, "Location");
+ DataSourceTextField locationField = new DataSourceTextField(location, "Location", 200);
+ fields.add(locationField);
DataSourceTextField operationField = new DataSourceTextField(operation, "Operation");
+ fields.add(operationField);
- DataSourceTextField timeField = new DataSourceTextField(time, "Date/Time");
+ DataSourceDateTimeField timeField = new DataSourceDateTimeField(time, "Date/Time");
+ fields.add(timeField);
- setFields(resourceField, locationField, operationField, timeField);
+ return fields;
}
/* Intercept DSRequest object to pipe into custom fetch request.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
index 6a31020..d513e70 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
@@ -23,10 +23,12 @@
package org.rhq.enterprise.gui.coregui.client.report.measurement;
import java.util.Collection;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -47,48 +49,53 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
private int maximumFactor = 0;
public MeasurementOOBDataSource() {
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceTextField metricField = new DataSourceTextField("scheduleName","Metric");
- addField(metricField);
+ DataSourceTextField metricField = new DataSourceTextField("scheduleName", "Metric");
+ fields.add(metricField);
DataSourceTextField resourceField = new DataSourceTextField("resourceName", "Resource");
- addField(resourceField);
+ fields.add(resourceField);
DataSourceTextField parentField = new DataSourceTextField("parentName", "Parent");
- addField(parentField);
+ fields.add(parentField);
DataSourceTextField bandField = new DataSourceTextField("formattedBaseband", "Band");
- addField(bandField);
+ fields.add(bandField);
DataSourceTextField outlierField = new DataSourceTextField("formattedOutlier", "Outlier");
- addField(outlierField);
+ fields.add(outlierField);
DataSourceTextField factorField = new DataSourceTextField("factor", "Out of range factor (%)");
- addField(factorField);
+ fields.add(factorField);
- }
+ return fields;
+ }
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
PageControl pc = getPageControl(request);
- GWTServiceLookup.getMeasurementDataService().getSchedulesWithOOBs(
- null, null, null, pc,
- new AsyncCallback<PageList<MeasurementOOBComposite>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load measurement OOB information",caught);
- }
-
- public void onSuccess(PageList<MeasurementOOBComposite> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
+ GWTServiceLookup.getMeasurementDataService().getSchedulesWithOOBs(null, null, null, pc,
+ new AsyncCallback<PageList<MeasurementOOBComposite>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load measurement OOB information", caught);
}
- );
+
+ public void onSuccess(PageList<MeasurementOOBComposite> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
@@ -97,7 +104,6 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
throw new UnsupportedOperationException("OOBs Read only");
}
-
@Override
public ListGridRecord[] buildRecords(Collection<MeasurementOOBComposite> list) {
for (MeasurementOOBComposite oob : list) {
@@ -128,20 +134,18 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
record.setAttribute("parentId", from.getParentId());
record.setAttribute("parentName", from.getParentName());
- int factorRankingWidth = (int) (((double)from.getFactor())/ (double)maximumFactor * 100d);
+ int factorRankingWidth = (int) (((double) from.getFactor()) / (double) maximumFactor * 100d);
- record.setBackgroundComponent(
- new HTMLFlow(
- "<div style=\"width: " + factorRankingWidth + "%; height: 100%; background-color: #A5B391;\"> </div>"));
+ record.setBackgroundComponent(new HTMLFlow("<div style=\"width: " + factorRankingWidth
+ + "%; height: 100%; background-color: #A5B391;\"> </div>"));
return record;
}
-
private void applyFormatting(MeasurementOOBComposite oob) {
- oob.setFormattedOutlier(MeasurementConverterClient.format(oob.getOutlier(), oob.getUnits(), true));
- formatBaseband(oob);
+ oob.setFormattedOutlier(MeasurementConverterClient.format(oob.getOutlier(), oob.getUnits(), true));
+ formatBaseband(oob);
}
private void formatBaseband(MeasurementOOBComposite oob) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index 38c316b..e7c8050 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -24,6 +24,7 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.fields.DataSourceImageField;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -66,16 +67,28 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField resourceField = new DataSourceTextField(resource, "Resource");
resourceField.setPrimaryKey(true);
+ fields.add(resourceField);
DataSourceTextField locationField = new DataSourceTextField(location, "Location");
+ fields.add(locationField);
DataSourceTextField alertsField = new DataSourceTextField(alerts, "Alerts");
+ fields.add(alertsField);
- DataSourceImageField availablilityField = new DataSourceImageField(available, "Current Availability");
+ DataSourceImageField availabilityField = new DataSourceImageField(available, "Current Availability");
+ fields.add(availabilityField);
- setFields(resourceField, locationField, alertsField, availablilityField);
+ return fields;
}
/* Intercept DSRequest object to pipe into custom fetch request.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index 86ab57e..38a9386 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -18,8 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.util;
-import java.util.Arrays;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -40,6 +40,7 @@ import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.effects.ColoringUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* Base GWT-RPC oriented DataSource class.
@@ -58,7 +59,7 @@ public abstract class RPCDataSource<T> extends DataSource {
public RPCDataSource(String name) {
if (name != null) {
com.allen_sauer.gwt.log.client.Log.info("Trying to build DS: " + name);
- setID(name);
+ setID(SeleniumUtility.getSafeId(name));
}
// TODO until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed always go to the server for data
setClientOnly(false);
@@ -68,6 +69,22 @@ public abstract class RPCDataSource<T> extends DataSource {
setDataFormat(DSDataFormat.CUSTOM);
}
+ /**
+ * Override in each subclass to set the default ds fields for the ds. The datasource should not
+ * define and set ds fields in the constructor in case a user of the ds wants to set their own. For example,
+ * those that want to use list grid fields (like our list views).
+ */
+ public void useDatasourceDefinedFields() {
+ }
+
+ /**
+ * A pattern that can be used for Datasource subclassing. Each subclass can add it's own fields prior to
+ * all of the fields being added to the datasource.
+ */
+ protected List<DataSourceField> addDataSourceFields() {
+ return new ArrayList<DataSourceField>();
+ }
+
@Override
protected Object transformRequest(DSRequest request) {
try {
@@ -229,7 +246,7 @@ public abstract class RPCDataSource<T> extends DataSource {
addField(field);
}
}
-
+
public void addFields(DataSourceField... fields) {
addFields(Arrays.asList(fields));
}
commit f767f233ffb2cea9cb3f2a69a20af0a4b9cd4960
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Oct 15 14:23:14 2010 -0400
bad things happen when gwt attempts to serialize alert defs return values via RPC calls.
this checks for null values getting passed into setters and avoids NPEs.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index 31be645..a288cad 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -519,7 +519,9 @@ public class AlertDefinition implements Serializable {
public void setResource(Resource resource) {
this.resource = resource;
- this.resource.getAlertDefinitions().add(this);
+ if (this.resource != null) {
+ this.resource.getAlertDefinitions().add(this);
+ }
}
public ResourceGroup getResourceGroup() {
@@ -652,9 +654,11 @@ public class AlertDefinition implements Serializable {
}
public void setConditions(Set<AlertCondition> conditions) {
- this.conditions.clear();
- for (AlertCondition condition : conditions) {
- addCondition(condition);
+ removeAllConditions();
+ if (conditions != null) {
+ for (AlertCondition condition : conditions) {
+ addCondition(condition);
+ }
}
}
@@ -684,6 +688,9 @@ public class AlertDefinition implements Serializable {
}
public void setAlertNotifications(List<AlertNotification> alertNotifications) {
+ if (alertNotifications == null) {
+ alertNotifications = new ArrayList<AlertNotification>();
+ }
this.alertNotifications = alertNotifications;
}
commit e486ae34722cff4146a22d446a99f4a2d95d4659
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Oct 14 23:55:21 2010 -0400
A temporary fix for getting around the ResourceSearchView not rendering
issue. This is a precursor to a more comprehensive change that aims to
solve issues regarding grid field vs ds field use.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 7c6aaf9..15bf220 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -105,7 +105,7 @@ public class ResourceSearchView extends Table {
protected void configureTable() {
ListGridField idField = new ListGridField("id", "Id", 55);
idField.setType(ListGridFieldType.INTEGER);
- idField.setHidden(true);
+ //idField.setHidden(true);
ListGridField iconField = new ListGridField("icon", "", 40);
ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
nameField.setCellFormatter(new CellFormatter() {
commit 2dfe611b1651f7312816b114b684fb90ec5f6854
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Oct 14 17:09:28 2010 -0400
group alert definition editor. there are still things broken in here. more stuff needs to be fixed/tested
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
index 8096fcf..f0916e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
@@ -86,6 +86,7 @@
<servlet path="/ContentGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.ContentGWTServiceImpl"/>
<servlet path="/DashboardGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.DashboardGWTServiceImpl"/>
<servlet path="/EventGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.EventGWTServiceImpl"/>
+ <servlet path="/GroupAlertDefinitionGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.GroupAlertDefinitionGWTServiceImpl"/>
<servlet path="/MeasurementDataGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.MeasurementDataGWTServiceImpl"/>
<servlet path="/OperationGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.OperationGWTServiceImpl"/>
<servlet path="/RemoteInstallGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.RemoteInstallGWTServiceImpl"/>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
index 183faec..e632915 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -26,15 +26,21 @@ package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
import java.util.EnumSet;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.MetadataType;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/**
* @author John Mazzitelli
@@ -44,10 +50,12 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
public static final String CRITERIA_GROUP_ID = "groupId";
private ResourceGroup group;
+ private ResourcePermission permissions;
- public GroupAlertDefinitionsView(String locatorId, ResourceGroup group) {
+ public GroupAlertDefinitionsView(String locatorId, ResourceGroupComposite groupComposite) {
super(locatorId, "Group Alert Definitions");
- this.group = group;
+ this.group = groupComposite.getResourceGroup();
+ this.permissions = groupComposite.getResourcePermission();
// make sure we loaded all the type info we'll need. if one of these is null, either the type
// doesn't have it or we haven't loaded it yet. since we can't know for sure if it was loaded, we have to ask.
@@ -86,55 +94,140 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
+ public SingleAlertDefinitionView getDetailsView(int id) {
+ SingleAlertDefinitionView view = super.getDetailsView(id);
+ if (id == 0) {
+ // when creating a new alert def, make sure to set this in the new alert def
+ view.getAlertDefinition().setResourceGroup(group);
+ }
+ return view;
+ }
+
+ @Override
protected boolean isAllowedToModifyAlertDefinitions() {
- // TODO: see if user can modify group alerts on this group
- return true;
+ return this.permissions.isAlert();
}
@Override
protected void newButtonPressed(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
- String str = "this is not implemented yet but you selected";
- for (ListGridRecord record : selection) {
- str += ": " + record.getAttribute("name");
- }
- SC.say(str);
+ newDetails();
}
@Override
protected void enableButtonPressed(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
- String str = "this is not implemented yet but you selected";
+ if (selection.length == 0) {
+ return;
+ }
+
+ Integer[] alertDefIds = new Integer[selection.length];
+ int i = 0;
for (ListGridRecord record : selection) {
- str += ": " + record.getAttribute("name");
+ Integer id = record.getAttributeAsInt(AbstractAlertDefinitionsDataSource.FIELD_ID);
+ alertDefIds[i++] = id;
}
- SC.say(str);
+
+ GWTServiceLookup.getGroupAlertDefinitionService().enableGroupAlertDefinitions(alertDefIds,
+ new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("[" + result + "] group alert definitions enabled.", Severity.Info));
+ GroupAlertDefinitionsView.this.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to enable group alert definitions", caught);
+ }
+ });
}
@Override
protected void disableButtonPressed(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
- String str = "this is not implemented yet but you selected";
+ if (selection.length == 0) {
+ return;
+ }
+
+ Integer[] alertDefIds = new Integer[selection.length];
+ int i = 0;
for (ListGridRecord record : selection) {
- str += ": " + record.getAttribute("name");
+ Integer id = record.getAttributeAsInt(AbstractAlertDefinitionsDataSource.FIELD_ID);
+ alertDefIds[i++] = id;
}
- SC.say(str);
+ GWTServiceLookup.getGroupAlertDefinitionService().disableGroupAlertDefinitions(alertDefIds,
+ new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("[" + result + "] group alert definitions disabled.", Severity.Info));
+ GroupAlertDefinitionsView.this.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to disable group alert definitions.", caught);
+ }
+ });
}
@Override
protected void deleteButtonPressed(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
- String str = "this is not implemented yet but you selected";
+ if (selection.length == 0) {
+ return;
+ }
+
+ Integer[] alertDefIds = new Integer[selection.length];
+ int i = 0;
for (ListGridRecord record : selection) {
- str += ": " + record.getAttribute("name");
+ Integer id = record.getAttributeAsInt(AbstractAlertDefinitionsDataSource.FIELD_ID);
+ alertDefIds[i++] = id;
}
- SC.say(str);
+ GWTServiceLookup.getGroupAlertDefinitionService().removeGroupAlertDefinitions(alertDefIds,
+ new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("[" + result + "] group alert definitions deleted.", Severity.Info));
+ GroupAlertDefinitionsView.this.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to delete group alert definitions.", caught);
+ }
+ });
}
@Override
- protected void commitAlertDefinition(AlertDefinition alertDefinition) {
- // TODO call into server SLSB to store alert def
- // GroupAlertDefinitionManagerLocal groupAlertDefinitionManager = LookupUtil.getGroupAlertDefinitionManager();
- // groupAlertDefinitionManager.updateGroupAlertDefinitions(subject, alertDef, true);
+ protected void commitAlertDefinition(final AlertDefinition alertDefinition) {
+ if (alertDefinition.getId() == 0) {
+ GWTServiceLookup.getGroupAlertDefinitionService().createGroupAlertDefinitions(alertDefinition,
+ Integer.valueOf(this.group.getId()), new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(new Message("Alert definition is created", Severity.Info));
+ alertDefinition.setId(result.intValue());
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to create alert definition.", caught);
+ }
+ });
+ } else {
+ GWTServiceLookup.getGroupAlertDefinitionService().updateGroupAlertDefinitions(alertDefinition, true,
+ new AsyncCallback<AlertDefinition>() {
+ @Override
+ public void onSuccess(AlertDefinition result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Group alert definition is updated.", Severity.Info));
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to update group alert definition.", caught);
+ }
+ });
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
index 3bc7a3f..f53710f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
@@ -70,9 +70,8 @@ public class ResourceAlertDefinitionsDataSource extends AbstractAlertDefinitions
+ this.resource.getResourceType().getId() + "&from=" + from.getId() + "&ad=" + parentId);
record.setLinkText("View Template");
} else {
- record.setAttribute(FIELD_PARENT, "/alerts/Config.do?mode=viewRoles&groupId="
- + groupAlertDefinition.getResourceGroup().getId() + "&from=" + from.getId() + "&ad="
- + groupAlertDefinition.getId());
+ record.setAttribute(FIELD_PARENT, "#ResourceGroup/" + groupAlertDefinition.getResourceGroup().getId()
+ + "/Alerts/Definitions/" + groupAlertDefinition.getId());
record.setLinkText("View Group Definition");
}
record.setAttribute(FIELD_READONLY, readOnly);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
index ebd0ab5..adc839d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
@@ -39,6 +39,10 @@ public class GWTServiceLookup {
return secure(AlertDefinitionGWTServiceAsync.Util.getInstance());
}
+ public static GroupAlertDefinitionGWTServiceAsync getGroupAlertDefinitionService() {
+ return secure(GroupAlertDefinitionGWTServiceAsync.Util.getInstance());
+ }
+
public static ConfigurationGWTServiceAsync getConfigurationService() {
return secure(ConfigurationGWTServiceAsync.Util.getInstance());
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GroupAlertDefinitionGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GroupAlertDefinitionGWTService.java
new file mode 100644
index 0000000..ff4299e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GroupAlertDefinitionGWTService.java
@@ -0,0 +1,45 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License 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.gwt;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+
+public interface GroupAlertDefinitionGWTService extends RemoteService {
+
+ int createGroupAlertDefinitions(AlertDefinition groupAlertDefinition, Integer resourceGroupId) throws Exception;
+
+ /**
+ * Updates a group alert definition.
+ *
+ * @param groupAlertDefinition
+ * @param purgeInternals must be true if you are updating conditions or dampening settings, can be false otherwise
+ * @return the updated definition
+ * @throws Exception
+ */
+ AlertDefinition updateGroupAlertDefinitions(AlertDefinition groupAlertDefinition, boolean purgeInternals)
+ throws Exception;
+
+ int enableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception;
+
+ int disableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception;
+
+ int removeGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception;
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 4f71441..225de69 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -40,6 +40,7 @@ import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.alert.definitions.GroupAlertDefinitionsView;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
@@ -265,6 +266,11 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
.extendLocatorId("CompositeHistView"), groupComposite), true, true);
}
+ // alerts tab is always visible
+ // TODO what about history subtab?
+ updateSubTab(this.alertsTab, this.alertDef, new GroupAlertDefinitionsView(alertsTab
+ .extendLocatorId("AlertDefView"), this.groupComposite), true, true);
+
this.show();
markForRedraw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java
new file mode 100644
index 0000000..7b65ee2
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java
@@ -0,0 +1,90 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License 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.server.gwt;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.enterprise.gui.coregui.client.gwt.GroupAlertDefinitionGWTService;
+import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
+import org.rhq.enterprise.server.alert.GroupAlertDefinitionManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+public class GroupAlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implements
+ GroupAlertDefinitionGWTService {
+ private static final long serialVersionUID = 1L;
+
+ private GroupAlertDefinitionManagerLocal groupAlertDefManager = LookupUtil.getGroupAlertDefinitionManager();
+
+ @Override
+ public int createGroupAlertDefinitions(AlertDefinition groupAlertDefinition, Integer resourceGroupId)
+ throws Exception {
+ try {
+ int results = groupAlertDefManager.createGroupAlertDefinitions(getSessionSubject(), groupAlertDefinition,
+ resourceGroupId);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public AlertDefinition updateGroupAlertDefinitions(AlertDefinition groupAlertDefinition, boolean purgeInternals)
+ throws Exception {
+ try {
+ AlertDefinition results = groupAlertDefManager.updateGroupAlertDefinitions(getSessionSubject(),
+ groupAlertDefinition, purgeInternals);
+ return SerialUtility.prepare(results, "updateGroupAlertDefinitions");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public int enableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception {
+ try {
+ int results = groupAlertDefManager
+ .enableGroupAlertDefinitions(getSessionSubject(), groupAlertDefinitionIds);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public int disableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception {
+ try {
+ int results = groupAlertDefManager.disableGroupAlertDefinitions(getSessionSubject(),
+ groupAlertDefinitionIds);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public int removeGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception {
+ try {
+ int results = groupAlertDefManager
+ .removeGroupAlertDefinitions(getSessionSubject(), groupAlertDefinitionIds);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
index 377ae0d..40e7f16 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
@@ -42,18 +42,19 @@
</servlet>
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AlertGWTService</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AlertGWTServiceImpl
- </servlet-class>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AlertGWTServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AlertDefinitionGWTService</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AlertDefinitionGWTServiceImpl
- </servlet-class>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AlertDefinitionGWTServiceImpl</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI GroupAlertDefinitionGWTService</servlet-name>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.GroupAlertDefinitionGWTServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI OperationGWTService</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.OperationGWTServiceImpl
- </servlet-class>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.OperationGWTServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI BundleGWTService</servlet-name>
@@ -158,6 +159,10 @@
<url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/AlertDefinitionGWTService</url-pattern>
</servlet-mapping>
<servlet-mapping>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI GroupAlertDefinitionGWTService</servlet-name>
+ <url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/GroupAlertDefinitionGWTService</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI OperationGWTService</servlet-name>
<url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/OperationGWTService</url-pattern>
</servlet-mapping>
commit 74c6ac20bd7ff5f12842f6a2c5962f8a3b179fee
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Oct 13 15:15:08 2010 -0400
need to populate the operations drop down when changing the descendant selection
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
index b2e9c05..e1bad9b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
@@ -172,7 +172,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
ancestorTypeSelectItem.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
- populateRelativeDescendantsDropDownMenu(null);
+ populateRelativeDescendantsDropDownMenu(null, null, null);
}
});
@@ -186,6 +186,12 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
descendantTypeSelectItem
.setTooltip("The resource type to search for under the root type defined in the Start Search From selection.");
descendantTypeSelectItem.setShowIfCondition(new ShowIfModeFunction(ResourceSelectionMode.RELATIVE));
+ descendantTypeSelectItem.addChangedHandler(new ChangedHandler() {
+ @Override
+ public void onChanged(ChangedEvent event) {
+ setOperationDropDownMenuValues(Integer.valueOf(event.getItem().getValue().toString()), null, null);
+ }
+ });
descendantNameTextItem = new TextItem("descendantNameTextItem");
descendantNameTextItem.setStartRow(false);
@@ -229,7 +235,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
descendantTypeSelectItem.clearValue();
descendantNameTextItem.clearValue();
hideOperationDropDownMenu();
- populateRelativeDropDownMenus(null, null);
+ populateRelativeDropDownMenus(null, null, null, null);
break;
}
}
@@ -260,7 +266,8 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
break;
}
case RELATIVE: {
- populateRelativeDropDownMenus(notifInfo.getAncestorTypeId(), notifInfo.getDescendantTypeId());
+ populateRelativeDropDownMenus(notifInfo.getAncestorTypeId(), notifInfo.getDescendantTypeId(), notifInfo
+ .getOperationId(), notifInfo.getOperationArguments());
if (notifInfo.getDescendantName() != null) {
descendantNameTextItem.setValue(notifInfo.getDescendantName());
}
@@ -274,7 +281,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
}
private void populateRelativeDropDownMenus(final Integer selectedResourceTypeId,
- final Integer descendantResourceTypeId) {
+ final Integer descendantResourceTypeId, final Integer selectedOpId, final Configuration opArgs) {
if (ancestorTypeSelectItem.getValue() == null) {
AsyncCallback<ArrayList<ResourceType>> callback = new AsyncCallback<ArrayList<ResourceType>>() {
@@ -290,7 +297,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
} else {
ancestorTypeSelectItem.setValue(String.valueOf(results.get(0).getId()));
}
- populateRelativeDescendantsDropDownMenu(descendantResourceTypeId);
+ populateRelativeDescendantsDropDownMenu(descendantResourceTypeId, selectedOpId, opArgs);
}
@Override
@@ -306,10 +313,13 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
GWTServiceLookup.getResourceTypeGWTService().getAllResourceTypeAncestors(this.resourceType.getId(),
callback);
}
+ } else {
+ populateRelativeDescendantsDropDownMenu(descendantResourceTypeId, selectedOpId, opArgs);
}
}
- private void populateRelativeDescendantsDropDownMenu(final Integer selectedDescendantResourceTypeId) {
+ private void populateRelativeDescendantsDropDownMenu(final Integer selectedDescendantResourceTypeId,
+ final Integer selectedOpId, final Configuration opArgs) {
Object rootResourceTypeIdObj = ancestorTypeSelectItem.getValue();
final int rootResourceTypeId;
@@ -331,9 +341,13 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
descendantTypeSelectItem.setValueMap(map);
if (selectedDescendantResourceTypeId != null) {
descendantTypeSelectItem.setValue(selectedDescendantResourceTypeId.toString());
+ setOperationDropDownMenuValues(selectedDescendantResourceTypeId.intValue(), selectedOpId,
+ opArgs);
} else {
descendantTypeSelectItem.setValue(String.valueOf(rootResourceTypeId));
+ setOperationDropDownMenuValues(rootResourceTypeId, selectedOpId, opArgs);
}
+
}
@Override
@@ -394,10 +408,10 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
* If args is non-null (and if opId is non-null), this will pre-populate the argument config editor.
*
* @param resourceTypeId the type whose operation definitions are to be shown in the operation drop down menu
- * @param opId if not-null, the selected operation
+ * @param selectedOpId if not-null, the selected operation
* @param args if not-null (and opId is not null), this will prepopulate the argument config
*/
- private void setOperationDropDownMenuValues(int resourceTypeId, final Integer opId, final Configuration args) {
+ private void setOperationDropDownMenuValues(int resourceTypeId, final Integer selectedOpId, final Configuration args) {
ResourceTypeCriteria criteria = new ResourceTypeCriteria();
criteria.addFilterId(resourceTypeId);
criteria.fetchOperationDefinitions(true);
@@ -423,9 +437,10 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
}
operationSelectItem.setAttribute(OPERATION_DEFS_ATTRIBUTE, (Object) opDefs);
operationSelectItem.setValueMap(valueMap);
- if (opId != null && opId > 0 && opDefs.containsKey(opId)) {
- operationSelectItem.setValue(String.valueOf(opId));
- showOperationArguments(opDefs.get(opId).getParametersConfigurationDefinition(), args);
+ if (selectedOpId != null && selectedOpId > 0 && opDefs.containsKey(selectedOpId)) {
+ operationSelectItem.setValue(String.valueOf(selectedOpId));
+ showOperationArguments(opDefs.get(selectedOpId).getParametersConfigurationDefinition(),
+ args);
} else {
operationSelectItem.clearValue(); // sets it to the default
hideOperationArguments();
commit 3b9b30f9582b0255ba2425b91dfa60735e8184b1
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Oct 13 14:18:04 2010 -0400
Changes to let selenium locators properly identify the nodes. I'm not
sure why we were passing the "new TreeNode[0]" as a child in the
constructors, it doesn't seem right, does not seem to adversely affect
our tree creation (perhaps it will help?) and removal seems to solve the
selenium issue.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
index 41e70c6..f4b69ae 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -27,11 +27,16 @@ import org.rhq.core.domain.util.StringUtils;
*/
public class EnhancedTreeNode extends TreeNode {
public EnhancedTreeNode() {
- this(null);
+ super();
+ // this(null);
}
public EnhancedTreeNode(String name) {
- this(name, new TreeNode[0]);
+ //this(name, new TreeNode[0]);
+ super(name);
+ if (name != null) {
+ setTitle(StringUtils.deCamelCase(name));
+ }
}
public EnhancedTreeNode(String name, TreeNode... children) {
@@ -65,8 +70,7 @@ public class EnhancedTreeNode extends TreeNode {
String className = this.getClass().getName();
String simpleClassName = className.substring(className.lastIndexOf(".") + 1);
innerClassName = simpleClassName.substring(simpleClassName.lastIndexOf("$") + 1);
- }
- catch (RuntimeException e) {
+ } catch (RuntimeException e) {
innerClassName = "EnhancedTreeNode";
}
commit 3e90719a317d577fc6fc90c0efae8b840aa8cc99
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Oct 13 11:45:13 2010 -0400
remove legacy TempSessionLoginModule and all related classes
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
index 6359a23..3b125e1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
@@ -93,11 +93,6 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
private SessionManager sessionManager = SessionManager.getInstance();
/**
- * This is used to generate temporary session passwords and to validate those passwords.
- */
- private TemporarySessionPasswordGenerator m_sessionPasswordGenerator = new TemporarySessionPasswordGenerator();
-
- /**
* @see org.rhq.enterprise.server.auth.SubjectManagerLocal#loadUserConfiguration(Integer)
*/
public Subject loadUserConfiguration(Integer subjectId) {
@@ -253,31 +248,6 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
}
/**
- * @see org.rhq.enterprise.server.auth.SubjectManagerLocal#generateTemporarySessionPassword(int)
- */
- public String generateTemporarySessionPassword(int sessionId) {
- return m_sessionPasswordGenerator.generateSessionPassword(sessionId);
- }
-
- /**
- * @see org.rhq.enterprise.server.auth.SubjectManagerLocal#authenticateTemporarySessionPassword(java.lang.String)
- */
- public boolean authenticateTemporarySessionPassword(String password) throws Exception {
- Integer sessionId = m_sessionPasswordGenerator.authenticateSessionPassword(password);
- boolean validPassword = false;
-
- if (sessionId != null) {
- // If the password was valid, sessionId will be the ID to its associated session. We now have to make
- // sure that session is still valid - this just makes sure the session hasn't timed out or was invalidated
- if (sessionManager.getSubject(sessionId.intValue()) != null) {
- validPassword = true;
- }
- }
-
- return validPassword;
- }
-
- /**
* @see org.rhq.enterprise.server.auth.SubjectManagerLocal#login(String, String)
*/
public Subject login(String username, String password) throws LoginException {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java
index b4b7d55..d62096b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java
@@ -72,31 +72,6 @@ public interface SubjectManagerLocal {
PageList<Subject> findAllSubjects(PageControl pageControl);
/**
- * Generates a one-time temporary session password for the given session. This can be used to authenticate the user
- * of that session for one time and one time only (i.e. to login as the user this temporary password can be used as
- * opposed to the user's real password).
- *
- * <p>Note that this method should only be available on this EJB's local interface.</p>
- *
- * @param sessionId the session to assign a temporary password to
- *
- * @return a temporary password that can be used once to login as the user
- */
- String generateTemporarySessionPassword(int sessionId);
-
- /**
- * Tests the validity of the given session password. Returns <code>true</code> if the password is valid and the
- * session is still valid.
- *
- * @param password a temporary session password that was created by {@link #generateTemporarySessionPassword(int)}.
- *
- * @return <code>true</code> if the given <code>password</code> is valid and its associated session is still valid
- *
- * @throws Exception if the password was valid but its associated session has either timed out or was invalidated
- */
- boolean authenticateTemporarySessionPassword(String password) throws Exception;
-
- /**
* Logs in a user without performing any authentication. This method should be used with care and not available to
* remote clients. Because of the unauthenticated nature of this login, the new login session will have a session
* timeout of only a few seconds. However, if you pass in <code>true</code> for the "reattach", this method will
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/TemporarySessionPasswordGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/TemporarySessionPasswordGenerator.java
deleted file mode 100644
index fc82ce2..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/TemporarySessionPasswordGenerator.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.server.auth;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import org.jboss.security.Util;
-
-/**
- * Provides a random password generator and a storage area that helps temporarily authenticate users even though their
- * true passwords are not known. This is necessary when a scheduled action is triggered and we want to run as the user,
- * but we don't know the user's true password. In other words, these temporary passwords should only be used if we have
- * previously validated the user for a given session ID. Session passwords generated by this object can only be used
- * once, and they must be validated fairly quickly after being generated.
- *
- * <p>This object is thread-safe.</p>
- *
- * @author John Mazzitelli
- */
-public class TemporarySessionPasswordGenerator {
- /**
- * This is a separator character that will appear between the session ID and a random set of characters in a
- * generated session password. This character must NOT be in {@link #SESSION_PASSWORD_PREFIX}.
- */
- private static final char SESSION_PASSWORD_SEPARATOR = '$';
-
- /**
- * A prefix to all generated session passwords; this makes it possible to quickly identify a possible session
- * password. While this doesn't exclusively identify only session passwords, it helps eliminate most passwords from
- * being recognized as a session password. None of the characters in this string will be the same as
- * {@link #SESSION_PASSWORD_SEPARATOR}.
- */
- private static final String SESSION_PASSWORD_PREFIX = "_x|=~";
-
- /**
- * Map keyed on session Integers whose values are Longs indicating when the session's password was created.
- */
- private final Map<Integer, Long> m_sessionPasswordCreationDates;
-
- /**
- * Map keyed on session Integers whose values are the MD5 strings of the generated passwords.
- */
- private final Map<Integer, String> m_sessionPasswordMD5Strings;
-
- /**
- * The amount of milliseconds that a temporary password is guaranteed to remain valid (a password may actually live
- * longer than this, but it is not guaranteed to do so)
- */
- private final int m_timeoutMillis;
-
- /**
- * Constructor for {@link TemporarySessionPasswordGenerator}.
- */
- public TemporarySessionPasswordGenerator() {
- this(60 * 60 * 1000); // be default, give a copious 60 minutes - this is easily enough for what we need to use this class for
- }
-
- /**
- * Constructor for {@link TemporarySessionPasswordGenerator}.
- *
- * @param timeoutMillis the amount of milliseconds that a temporary password is guaranteed to remain valid (a
- * password may actually live longer than this, but it is not guaranteed to do so)
- */
- public TemporarySessionPasswordGenerator(int timeoutMillis) {
- m_sessionPasswordCreationDates = new HashMap<Integer, Long>();
- m_sessionPasswordMD5Strings = new HashMap<Integer, String>();
- m_timeoutMillis = timeoutMillis;
-
- return;
- }
-
- /**
- * Given a session identifier, this will generate a temporary password that can be used to identify the user whose
- * session that is. Use {@link #authenticateSessionPassword(String)} to later check for this password's
- * authenticity. This session password can only be authenticated once.
- *
- * @param sessionId the session of a user who needs a temporary password assigned
- *
- * @return a password that can be used to associate a session with a user
- *
- * @see #authenticateSessionPassword(String)
- */
- public String generateSessionPassword(int sessionId) {
- StringBuffer pwBuf = new StringBuffer(SESSION_PASSWORD_PREFIX);
-
- pwBuf.append(sessionId);
- pwBuf.append(SESSION_PASSWORD_SEPARATOR);
- pwBuf.append(generateRandomPassword());
-
- String pw = pwBuf.toString();
-
- storeSessionPassword(new Integer(sessionId), pw);
-
- return pw;
- }
-
- /**
- * Returns the session's ID if the given session's password was one that was generated by this object. Returns
- * <code>null</code> if the password was invalid and thus the user attempting to log in should be denied access.
- * Once authenticated, the password will no longer be valid and can not be used to validate the session again.
- *
- * @param password the password to test
- *
- * @return session's ID if the session's <code>password</code> was one that was generated by this object; <code>
- * null</code> otherwise
- *
- * @throws IllegalStateException if the password was in a valid format but the password's MD5 does not match; this
- * exception will only be thrown when it looks like someone is trying to hack a
- * session password
- *
- * @see #generateSessionPassword(int)
- */
- public Integer authenticateSessionPassword(String password) throws IllegalStateException {
- int separator = (password != null) ? password.indexOf(SESSION_PASSWORD_SEPARATOR) : -1;
-
- // let's quickly eliminate most passwords
- if ((separator == -1) || !password.startsWith(SESSION_PASSWORD_PREFIX)) {
- return null;
- }
-
- String sessionStr = password.substring(SESSION_PASSWORD_PREFIX.length(), separator);
- Integer sessionId;
-
- try {
- sessionId = new Integer(sessionStr);
- } catch (NumberFormatException e) {
- // kinda looked like our password, but it can't be since this should have been a valid session ID number
- return null;
- }
-
- String passwordMD5 = generateMD5(password);
- String sessionMD5;
-
- synchronized (this) {
- purgeOldSessionPasswords(); // let's do this cleanup now; must do this inside the sychronized block
-
- // we only allow a session password to be authenticated once, so remove all traces of it while retrieving it
- sessionMD5 = m_sessionPasswordMD5Strings.remove(sessionId);
- m_sessionPasswordCreationDates.remove(sessionId);
- }
-
- // the session password was either already authenticated or was removed because it was too old
- if (sessionMD5 == null) {
- return null;
- }
-
- // the password was wrong, if we got this far and the password was wrong, someone is trying to hack
- if (!sessionMD5.equals(passwordMD5)) {
- throw new IllegalStateException(
- "WARNING! A session was attempted to be reattached but the login password was invalid");
- }
-
- return sessionId;
- }
-
- /**
- * Stores the generated session password in our internal data structures so we can authenticate the session using
- * the password.
- *
- * @param sessionId the session identifier
- * @param pw the password to store
- */
- private void storeSessionPassword(Integer sessionId, String pw) {
- synchronized (this) {
- purgeOldSessionPasswords(); // let's do this cleanup now; must do this inside the sychronized block
-
- m_sessionPasswordCreationDates.put(sessionId, new Long(System.currentTimeMillis()));
- m_sessionPasswordMD5Strings.put(sessionId, generateMD5(pw));
- }
-
- return;
- }
-
- /**
- * Looks at the current set of session passwords and removes those that are old. Not sure why these passwords would
- * be hanging around, since usually generated session passwords are authenticated fairly quickly thereafter. But
- * just in case something went wrong between the time the password was generated and the time it was to be
- * authenticated, this method is used to clean up.
- *
- * <p>To avoid having to enter another synchronized block and again attempt to aquire a lock, make sure you call
- * this method from within a sychronized block - this method requires "this" object's lock.</p>
- */
- private void purgeOldSessionPasswords() {
- long earliestAllowed = System.currentTimeMillis() - m_timeoutMillis;
- List<Integer> doomedSessions = new ArrayList<Integer>();
-
- for (Map.Entry<Integer, Long> entry : m_sessionPasswordCreationDates.entrySet()) {
- Long creationTime = entry.getValue();
-
- if (creationTime.longValue() < earliestAllowed) {
- doomedSessions.add(entry.getKey());
- }
- }
-
- for (Integer doomedSession : doomedSessions) {
- m_sessionPasswordCreationDates.remove(doomedSession);
- m_sessionPasswordMD5Strings.remove(doomedSession);
- }
-
- return;
- }
-
- /**
- * Generates a random password that will be used as part of the session password.
- *
- * @return a random password
- */
- private String generateRandomPassword() {
- // generate a random password - this will usually be used as part of a Basic Authentication to our WebDAV server
- // make sure these can be encoded in a URL (no + signs - don't ask - see UrlUtil.encodeMore)
- // make sure SESSION_PASSWORD_SEPARATOR character is NOT in the chars variable!
- StringBuffer password = new StringBuffer();
- String chars = "0a3X1bWd-2VeU*fTgH7sGtF6YS^KpJqI4rh7RiQj_5P.kOZlNm|0Mn~Lou!9EvD4wACxB8yz";
- Random random = new Random(System.currentTimeMillis());
- int passwordLength = 0;
-
- while (passwordLength < 64) {
- passwordLength = random.nextInt(129);
- }
-
- random = new Random(System.currentTimeMillis() + passwordLength);
-
- for (int i = 0; i < passwordLength; i++) {
- password.append(chars.charAt(random.nextInt(chars.length())));
- }
-
- return password.toString();
- }
-
- /**
- * Given a password string, this will return its MD5.
- *
- * @param password the string whose MD5 is to be calculated
- *
- * @return the MD5 string
- */
- private String generateMD5(String password) {
- return Util.createPasswordHash("MD5", "base64", null, null, password);
- }
-}
\ No newline at end of file
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 caec439..7787dba 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
@@ -113,20 +113,6 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
this.log.info("Enabling RHQ JDBC JAAS Provider");
configEntries.add(ace);
- /*
- * NOT USED ANYMORE
- // to support the need for authenticating temporary session passwords, add a login module that can do that
- // we set an empty set of config options, but if we need to, we can store the config items
- // in the RHQ_config_props table, which would allow the GUI to modify them (just in case we want to add that capability)
- // the "conf" Properties value has all RHQ_config_props values, so we have that now
- // for now, there are no config properties we need in this login module, so just create an empty map
- ace = new AppConfigurationEntry(TempSessionLoginModule.class.getName(),
- AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT, new HashMap<String, String>());
- this.log.info("Enabled the temporary session login module");
- configEntries.add(ace);
- *
- */
-
String provider = conf.getProperty(RHQConstants.JAASProvider);
if ((provider != null) && provider.equals(RHQConstants.LDAPJAASProvider)) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/TempSessionLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/TempSessionLoginModule.java
deleted file mode 100644
index a58f275..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/TempSessionLoginModule.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.server.core.jaas;
-
-import java.security.acl.Group;
-import java.util.Map;
-import javax.security.auth.Subject;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.login.LoginException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.security.SimpleGroup;
-import org.jboss.security.auth.spi.UsernamePasswordLoginModule;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-/**
- * A "special" JAAS login module that checks to see if the password is a valid temporary session password. If it is, the
- * user is authenticated; if not, the user is denied access.
- *
- * <p>This is used mainly to support the use-case where a server component needs to submit a request that needs to again
- * be authenticated. In this case, the server doesn't know the user's true password; instead a temporary session
- * password was created for the user.
- *
- * @author John Mazzitelli
- */
-public class TempSessionLoginModule extends UsernamePasswordLoginModule {
- /**
- * Logger
- */
- private static final Log LOG = LogFactory.getLog(TempSessionLoginModule.class);
-
- /**
- * A place where this login module can initialize itself.
- *
- * @param theSubject
- * @param theHandler
- * @param theSharedState
- * @param theOptions
- */
- public void initialize(Subject theSubject, CallbackHandler theHandler, Map theSharedState, Map theOptions) {
- super.initialize(theSubject, theHandler, theSharedState, theOptions);
- }
-
- /**
- * We don't know the user's true password, so we don't know the expected password; therefore, this returns an empty
- * string. This class overrides {@link #validatePassword(String, String)} so it can validate on the input password
- * that was entered by the client, since it is all we need to check validity.
- *
- * @return empty string
- */
- protected String getUsersPassword() {
- return "";
- }
-
- /**
- * Authenticates the user by seeing if the <code>inputPassword</code> is a valid temporary session password. <code>
- * expectedPassword</code> is ignored.
- *
- * @see UsernamePasswordLoginModule#validatePassword(String, String)
- */
- protected boolean validatePassword(String inputPassword, String expectedPassword) {
- boolean validPassword = false;
-
- // call into the JON authentication subsystem to see if the input password was valid.
- try {
- validPassword = LookupUtil.getSubjectManager().authenticateTemporarySessionPassword(inputPassword);
- } catch (Exception e) {
- LOG.error("Failed to authenticate a session password for user [" + getUsername() + "]", e);
- }
-
- return validPassword;
- }
-
- /**
- * @see org.jboss.security.auth.spi.AbstractServerLoginModule#getRoleSets()
- */
- protected Group[] getRoleSets() throws LoginException {
- SimpleGroup roles = new SimpleGroup("Roles");
-
- //roles.addMember( new SimplePrincipal( "some role" ) );
-
- return new Group[] { roles };
- }
-}
\ No newline at end of file
commit fa51b77cce5f9e3d5af5d72099d93fa7c9efc0c2
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Oct 13 10:31:09 2010 -0400
don't show id fields in grids
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index eb7175b..7c6aaf9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -105,6 +105,7 @@ public class ResourceSearchView extends Table {
protected void configureTable() {
ListGridField idField = new ListGridField("id", "Id", 55);
idField.setType(ListGridFieldType.INTEGER);
+ idField.setHidden(true);
ListGridField iconField = new ListGridField("icon", "", 40);
ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
nameField.setCellFormatter(new CellFormatter() {
13 years, 8 months
[rhq] 7 commits - modules/core modules/plugins
by lkrejci
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java | 12
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 3
modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java | 7
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 7
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java | 123 ++++
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 56 +-
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java | 260 ++++++----
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java | 12
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java | 90 ++-
9 files changed, 390 insertions(+), 180 deletions(-)
New commits:
commit cec52a70ca813ed0138ab1b2f59efc364953b393
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Sat Oct 16 01:15:18 2010 +0200
Removing the code dealing with the legacy resource keys and implement a ResourceUpgradeFacet for virtual hosts so that we can finally move away from the insufficient legacy resource keys.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index a0f2120..9b5c975 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -345,79 +345,46 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
String[] addrs = resourceKey.substring(pipeIdx + 1).split(" ");
List<AugeasNode> nodes = tree.matchRelative(tree.getRootNode(), "<VirtualHost");
List<AugeasNode> virtualHosts = new ArrayList<AugeasNode>();
- boolean updated = false;
-
-//BZ 612189 - uncomment this algo once the resource upgrade is in place
-// for (AugeasNode node : nodes) {
-// updated = false;
-// List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
-// String tempServerName = null;
-//
-// if (!(serverNameNodes.isEmpty())) {
-// tempServerName = serverNameNodes.get(0).getValue();
-// }
-// if (tempServerName == null & serverName == null)
-// updated = true;
-// if (tempServerName != null & serverName != null)
-// if (tempServerName.equals(serverName)){
-// updated = true;
-// }
-//
-//
-// if (updated){
-// updated = false;
-// List<AugeasNode> params = node.getChildByLabel("param");
-// for (AugeasNode nd : params) {
-// updated = false;
-// for (String adr : addrs) {
-// if (adr.equals(nd.getValue()))
-// updated = true;
-// }
-// if (!updated)
-// break;
-// }
-//
-// if (updated)
-// virtualHosts.add(node);
-// }
-// }
-
- //BZ 612189 - remove this once resource upgrade is in place
- HttpdAddressUtility.Address resourceKeyAddress = HttpdAddressUtility.Address.parse(resourceKey);
- for(AugeasNode node : nodes) {
+ boolean matching = false;
+
+ for (AugeasNode node : nodes) {
+ matching = false;
List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
- List<AugeasNode> vhostAddressNodes = node.getChildByLabel("param");
+ String tempServerName = null;
+
+ if (!(serverNameNodes.isEmpty())) {
+ tempServerName = serverNameNodes.get(0).getValue();
+ }
+ if (tempServerName == null & serverName == null) {
+ matching = true;
+ }
- String vhostServerName = serverNameNodes.isEmpty() ? null : serverNameNodes.get(0).getValue();
- String vhostAddressDef = vhostAddressNodes.isEmpty() ? null : vhostAddressNodes.get(0).getValue();
+ if (tempServerName != null & serverName != null) {
+ if (tempServerName.equals(serverName)) {
+ matching = true;
+ }
+ }
- if (vhostAddressDef != null) {
- HttpdAddressUtility.Address vhostAddress = HttpdAddressUtility.Address.parse(vhostAddressDef);
- if (vhostServerName != null) {
- HttpdAddressUtility.Address vhostServerAddress = HttpdAddressUtility.Address.parse(vhostServerName);
- vhostAddress.host = vhostServerAddress.host;
+ if (matching) {
+ List<AugeasNode> params = node.getChildByLabel("param");
+ for (AugeasNode nd : params) {
+ matching = false;
+ for (String adr : addrs) {
+ if (adr.equals(nd.getValue())) {
+ matching = true;
+ }
+ }
+ if (!matching) {
+ break;
+ }
}
-
- if (resourceKeyAddress.equals(vhostAddress)) {
+
+ if (matching) {
virtualHosts.add(node);
}
}
}
-
- //BZ 612189 - remove this once we have resource upgrade
- //ok, one final attempt... the legacy resource key format for the MainServer is just a host:port as with the rest of the vhosts, let's try that
- try {
- String serverUrl = resourceContext.getParentResourceComponent().getServerUrl();
- URI serverUri = new URI(serverUrl);
- String expectedResourceKey = serverUri.getHost() + ":" + serverUri.getPort();
-
- if (expectedResourceKey.equals(resourceKey)) {
- return tree.getRootNode();
- }
- } catch (URISyntaxException e) {
- log.warn("Failed to parse the server URL when trying to match the vhost with the main server.", e);
- }
-
+
if (virtualHosts.size() == 0) {
throw new IllegalStateException("Could not find virtual host configuration in augeas for virtual host: "
+ resourceKey);
@@ -544,14 +511,6 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
vhostServerName, true);
if (vhostAddr != null) {
vhostAddresses.add(vhostAddr);
- } else {
- //this is not to choke on the old style resource keys for the main server. without this, we'd never be able
- //to match the main server with its snmp index below.
- HttpdAddressUtility.Address addr = HttpdAddressUtility.Address.parse(vhostAddressStrings[i]);
- vhostAddr = parent.getAddressUtility().getMainServerSampleAddress(tree, addr.host, addr.port);
- if (vhostAddr != null) {
- vhostAddresses.add(vhostAddr);
- }
}
}
}
@@ -618,7 +577,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
return snmpWwwServiceIndex;
}
- private static int matchRate(List<HttpdAddressUtility.Address> addresses, HttpdAddressUtility.Address addressToCheck) {
+ public static int matchRate(List<HttpdAddressUtility.Address> addresses, HttpdAddressUtility.Address addressToCheck) {
for(HttpdAddressUtility.Address a : addresses) {
if (HttpdAddressUtility.isAddressConforming(addressToCheck, a.host, a.port, true)) {
return 3;
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index 8251658..6f24ca7 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -21,23 +21,25 @@ package org.rhq.plugins.apache;
import java.io.File;
import java.net.InetAddress;
import java.net.URI;
-import java.net.URISyntaxException;
import java.net.UnknownHostException;
-import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.augeas.node.AugeasNode;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.ResourceUpgradeReport;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext;
+import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet;
import org.rhq.plugins.apache.parser.ApacheDirective;
import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
import org.rhq.plugins.apache.util.HttpdAddressUtility;
@@ -54,7 +56,7 @@ import org.rhq.plugins.www.snmp.SNMPValue;
* @author Ian Springer
* @author Lukas Krejci
*/
-public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDiscoveryComponent<ApacheServerComponent> {
+public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDiscoveryComponent<ApacheServerComponent>, ResourceUpgradeFacet<ApacheServerComponent> {
private static final String COULD_NOT_DETERMINE_THE_VIRTUAL_HOST_ADDRESS = "*** Could not determine the virtual host address ***";
@@ -69,37 +71,25 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
- //BZ 612189 - prepare for the legacy overrides. We need to revert to the old-style resource keys until
- //resource upgrade functionality is ready.
- SnmpWwwServiceIndexes snmpDiscoveries = getSnmpDiscoveries(context);
-
ApacheServerComponent serverComponent = context.getParentResourceComponent();
ApacheDirectiveTree tree = serverComponent.loadParser();
//first define the root server as one virtual host
- discoverMainServer(context, discoveredResources, snmpDiscoveries);
+ discoverMainServer(context, discoveredResources);
ResourceType resourceType = context.getResourceType();
File configPath = serverComponent.getServerRoot();
File logsDir = new File(configPath, LOGS_DIRECTORY_NAME);
- List<ApacheDirective> virtualHosts = tree.search("/<VirtualHost");
-
- for (ApacheDirective node : virtualHosts) {
- List<String> hosts = node.getValues();
- String firstAddress = hosts.get(0);
-
- List<ApacheDirective> serverNames = node.getChildByName("ServerName");
- String serverName = null;
- if (serverNames.size() > 0) {
- serverName = serverNames.get(0).getValuesAsString();
- }
+ for(VHostSpec vhost : VHostSpec.detect(tree)) {
+
+ String firstAddress = vhost.hosts.get(0);
- String resourceKey = createResourceKey(serverName, hosts);
+ String resourceKey = createResourceKey(vhost.serverName, vhost.hosts);
Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
- Address address = serverComponent.getAddressUtility().getVirtualHostSampleAddress(tree, firstAddress, serverName, false);
+ Address address = serverComponent.getAddressUtility().getVirtualHostSampleAddress(tree, firstAddress, vhost.serverName, false);
if (address != null) {
String scheme = address.scheme;
String hostToPing = address.host;
@@ -143,17 +133,11 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
}
String resourceName;
- if (serverName != null) {
+ if (address != null) {
resourceName = address.host + ":" + address.port;
} else {
resourceName = resourceKey;
}
-
- //BZ 612189 - remove this once we have resource upgrade
- if (snmpDiscoveries != null) {
- String legacyResourceKey = getLegacyResourceKey(context, resourceKey, snmpDiscoveries);
- resourceKey = legacyResourceKey != null ? legacyResourceKey : resourceKey;
- }
discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
pluginConfiguration, null));
@@ -162,9 +146,56 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
return discoveredResources;
}
+ public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ApacheServerComponent> inventoriedResource) {
+ String resourceKey = inventoriedResource.getResourceKey();
+
+ if (ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY.equals(resourceKey) ||
+ resourceKey.contains("|")) {
+ //a new style resource key. we're done.
+ return null;
+ }
+
+ String newResourceKey = null;
+
+ ApacheServerComponent serverComponent = inventoriedResource.getParentResourceComponent();
+
+ ApacheDirectiveTree tree = serverComponent.loadParser();
+
+ List<VHostSpec> vhosts = VHostSpec.detect(tree);
+ SnmpWwwServiceIndexes snmpIndexes = getSnmpDiscoveries(serverComponent, inventoriedResource.getParentResourceContext().getResourceKey());
+
+ for (VHostSpec vhost : vhosts) {
+ String legacyResourceKey = createLegacyResourceKey(serverComponent, vhost.serverName, vhost.hosts, snmpIndexes);
+ if (resourceKey.equals(legacyResourceKey)) {
+ newResourceKey = createResourceKey(vhost.serverName, vhost.hosts);
+ break;
+ }
+ }
+
+ if (newResourceKey == null) {
+ //the last thing to check is whether the inventoried vhost isn't in fact the main server
+ String serverUrl = serverComponent.getServerUrl();
+ HttpdAddressUtility.Address serverAddress = HttpdAddressUtility.Address.parse(serverUrl);
+ HttpdAddressUtility.Address vhostAddress = HttpdAddressUtility.Address.parse(resourceKey);
+
+ if (ApacheVirtualHostServiceComponent.matchRate(Collections.singletonList(serverAddress), vhostAddress) > 0) {
+ newResourceKey = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ }
+ }
+
+ if (newResourceKey != null) {
+ ResourceUpgradeReport report = new ResourceUpgradeReport();
+ report.setNewResourceKey(newResourceKey);
+
+ return report;
+ } else {
+ return null;
+ }
+ }
+
private void discoverMainServer(ResourceDiscoveryContext<ApacheServerComponent> context,
- Set<DiscoveredResourceDetails> discoveredResources, SnmpWwwServiceIndexes snmpDiscoveries) throws Exception {
+ Set<DiscoveredResourceDetails> discoveredResources) throws Exception {
ResourceType resourceType = context.getResourceType();
Configuration mainServerPluginConfig = context.getDefaultPluginConfiguration();
@@ -175,8 +206,6 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
String mainServerUrl = context.getParentResourceContext().getPluginConfiguration().getSimple(
ApacheServerComponent.PLUGIN_CONFIG_PROP_URL).getStringValue();
- String key = null;
-
if (mainServerUrl != null && !"null".equals(mainServerUrl)) {
PropertySimple mainServerUrlProp = new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP,
mainServerUrl);
@@ -195,21 +224,9 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
PropertySimple rtLogProp = new PropertySimple(
ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
mainServerPluginConfig.put(rtLogProp);
-
- //BZ 612189 - remove this once we have resource upgrade
- key = host + ":" + port;
}
- //BZ 612189 - this can simply the MAIN_SERVER_RESOURCE_KEY only once we have resource upgrade
- if (key == null) {
- key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
- }
-
- //BZ 612189 - remove this once we have resource upgrade
- if (snmpDiscoveries != null) {
- String legacyKey = getLegacyResourceKey(context, key, snmpDiscoveries);
- key = legacyKey != null ? legacyKey : key;
- }
+ String key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
DiscoveredResourceDetails mainServer = new DiscoveredResourceDetails(resourceType,
key, "Main", null, null,
@@ -217,45 +234,43 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
discoveredResources.add(mainServer);
}
- /**
- * @deprecated remove this once we have resource upgrade
- * @param discoveryContext
- * @param newStyleResourceKey
- * @param snmpDiscoveries
- * @return
- */
- @Deprecated
- private String getLegacyResourceKey(ResourceDiscoveryContext<ApacheServerComponent> discoveryContext, String newStyleResourceKey, SnmpWwwServiceIndexes snmpDiscoveries) {
- int snmpWwwServiceIndex = ApacheVirtualHostServiceComponent.getMatchingWwwServiceIndex(discoveryContext.getParentResourceComponent(), newStyleResourceKey, snmpDiscoveries.names, snmpDiscoveries.ports);
-
- if (snmpWwwServiceIndex < 1) {
- return null;
- } else {
- String host = snmpDiscoveries.names.get(snmpWwwServiceIndex - 1).toString();
- String fullPort = snmpDiscoveries.ports.get(snmpWwwServiceIndex - 1).toString();
-
- // The port value will be in the form "1.3.6.1.2.1.6.XXXXX",
- // where "1.3.6.1.2.1.6" represents the TCP protocol ID,
- // and XXXXX is the actual port number
- String port = fullPort.substring(fullPort.lastIndexOf(".") + 1);
- return host + ":" + port;
+ public static String createResourceKey(String serverName, List<String> hosts) {
+ StringBuilder keyBuilder = new StringBuilder();
+ if (serverName != null) {
+ keyBuilder.append(serverName);
+ }
+ keyBuilder.append("|"); //always do this so that we have a clear distinction between old and new style resource keys
+ keyBuilder.append(hosts.get(0));
+
+ for (int i = 1; i < hosts.size(); ++i){
+ keyBuilder.append(" ").append(hosts.get(i));
}
+
+ return keyBuilder.toString();
}
- public static String createResourceKey(String serverName, List<String> hosts) {
-//BZ 612189 - swap the impls once resource upgrade is in place
-// StringBuilder keyBuilder = new StringBuilder();
-// if (serverName != null) {
-// keyBuilder.append(serverName).append("|");
-// }
-// keyBuilder.append(hosts.get(0));
-//
-//
-// for (int i = 1; i < hosts.size(); ++i){
-// keyBuilder.append(" ").append(hosts.get(i));
-// }
-//
-// return keyBuilder.toString();
+ private static String createLegacyResourceKey(ApacheServerComponent serverComponent, String serverName, List<String> hosts, SnmpWwwServiceIndexes snmpIndexes) {
+ if (snmpIndexes != null) {
+ String newStyleResourceKey = createResourceKey(serverName, hosts);
+ String legacyResourceKey = null;
+
+ int snmpWwwServiceIndex = ApacheVirtualHostServiceComponent.getMatchingWwwServiceIndex(serverComponent, newStyleResourceKey, snmpIndexes.names, snmpIndexes.ports);
+
+ if (snmpWwwServiceIndex > 0) {
+ String host = snmpIndexes.names.get(snmpWwwServiceIndex - 1).toString();
+ String fullPort = snmpIndexes.ports.get(snmpWwwServiceIndex - 1).toString();
+
+ // The port value will be in the form "1.3.6.1.2.1.6.XXXXX",
+ // where "1.3.6.1.2.1.6" represents the TCP protocol ID,
+ // and XXXXX is the actual port number
+ String port = fullPort.substring(fullPort.lastIndexOf(".") + 1);
+ legacyResourceKey = host + ":" + port;
+ }
+
+ if (legacyResourceKey != null) {
+ return legacyResourceKey;
+ }
+ }
//try to derive the same resource key as the SNMP would have... this is to prevent the duplication of
//vhost resources after the SNMP was configured - how I wish resource upgrade made it to 3.0 to prevent this
@@ -279,18 +294,15 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
}
/**
- * @deprecated remove this once we have resource upgrade
* @param discoveryContext
* @return
*/
- @Deprecated
- private SnmpWwwServiceIndexes getSnmpDiscoveries(ResourceDiscoveryContext<ApacheServerComponent> discoveryContext) {
+ private static SnmpWwwServiceIndexes getSnmpDiscoveries(ApacheServerComponent serverComponent, String serverResourceKey) {
try {
- SNMPSession snmpSession = discoveryContext.getParentResourceComponent().getSNMPSession();
+ SNMPSession snmpSession = serverComponent.getSNMPSession();
List<SNMPValue> nameValues;
List<SNMPValue> portValues;
- SNMPValue descValue;
-
+
try {
nameValues = snmpSession.getColumn(SNMPConstants.COLUMN_VHOST_NAME);
} catch (SNMPException e) {
@@ -305,35 +317,46 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
"Error getting SNMP column: " + SNMPConstants.COLUMN_VHOST_PORT + ": " + e.getMessage(), e);
}
- try {
- // Just get the first one - they are all the same.
- descValue = snmpSession.getNextValue(SNMPConstants.COLUMN_VHOST_DESC);
- } catch (SNMPException e) {
- throw new Exception("Error getting SNMP value: " + SNMPConstants.COLUMN_VHOST_DESC + ": " + e.getMessage(),
- e);
- }
-
SnmpWwwServiceIndexes ret = new SnmpWwwServiceIndexes();
ret.names = nameValues;
ret.ports = portValues;
- ret.desc = descValue;
return ret;
} catch (Exception e) {
- log.warn("Error while trying to contact SNMP of the apache server " + discoveryContext.getParentResourceContext().getResourceKey(), e);
+ log.warn("Error while trying to contact SNMP of the apache server " + serverResourceKey, e);
return null;
}
}
- /**
- * @deprecated remove this once we have resource upgrade
- *
- * @author Lukas Krejci
- */
- @Deprecated
private static class SnmpWwwServiceIndexes {
public List<SNMPValue> names;
public List<SNMPValue> ports;
- public SNMPValue desc;
+ }
+
+ private static class VHostSpec {
+ public String serverName;
+ public List<String> hosts;
+
+ public static List<VHostSpec> detect(ApacheDirectiveTree config) {
+ List<ApacheDirective> virtualHosts = config.search("/<VirtualHost");
+
+ List<VHostSpec> ret = new ArrayList<VHostSpec>(virtualHosts.size());
+
+ for(ApacheDirective dir : virtualHosts) {
+ ret.add(new VHostSpec(dir));
+ }
+
+ return ret;
+ }
+
+ public VHostSpec(ApacheDirective vhostDirective) {
+ hosts = vhostDirective.getValues();
+
+ List<ApacheDirective> serverNames = vhostDirective.getChildByName("ServerName");
+ serverName = null;
+ if (serverNames.size() > 0) {
+ serverName = serverNames.get(0).getValuesAsString();
+ }
+ }
}
}
\ No newline at end of file
commit dd1e15c2f1b564b0f547508fbc472a0f97ec8cc6
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Sat Oct 16 01:13:17 2010 +0200
Adding the ResourceContext of the parent resource to the ResourceUpgradeContext so that upgrade() methods of the discovery components can use that information.
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java
index 35f5029..c56d280 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java
@@ -44,17 +44,18 @@ import org.rhq.core.system.SystemInfo;
*
* @author Lukas Krejci
*/
-@SuppressWarnings("unchecked")
+@SuppressWarnings("rawtypes")
public class ResourceUpgradeContext<T extends ResourceComponent> extends ResourceContext<T> {
private final Configuration resourceConfiguration;
private final String name;
private final String description;
+ private ResourceContext<?> parentResourceContext;
/**
* @see ResourceContext#ResourceContext(Resource, ResourceComponent, ResourceDiscoveryComponent, SystemInfo, File, File, String, EventContext, OperationContext, ContentContext, Executor, PluginContainerDeployment)
*/
- public ResourceUpgradeContext(Resource resource, T parentResourceComponent,
+ public ResourceUpgradeContext(Resource resource, ResourceContext<?> parentResourceContext, T parentResourceComponent,
ResourceDiscoveryComponent resourceDiscoveryComponent, SystemInfo systemInfo, File temporaryDirectory,
File dataDirectory, String pluginContainerName, EventContext eventContext, OperationContext operationContext,
ContentContext contentContext, Executor availCollectorThreadPool,
@@ -64,15 +65,14 @@ public class ResourceUpgradeContext<T extends ResourceComponent> extends Resourc
pluginContainerName, eventContext, operationContext, contentContext, availCollectorThreadPool,
pluginContainerDeployment);
+ this.parentResourceContext = parentResourceContext;
this.resourceConfiguration = resource.getResourceConfiguration();
this.name = resource.getName();
this.description = resource.getDescription();
}
- public ResourceUpgradeContext(Resource resource, ResourceDiscoveryComponent discoveryComponent, ResourceContext<T> context, Executor availCollectorThreadPool) {
- this(resource, context.getParentResourceComponent(), discoveryComponent, context.getSystemInformation(), context.getTemporaryDirectory(),
- context.getDataDirectory(), context.getPluginContainerName(), context.getEventContext(), context.getOperationContext(),
- context.getContentContext(), availCollectorThreadPool, context.getPluginContainerDeployment());
+ public ResourceContext<?> getParentResourceContext() {
+ return parentResourceContext;
}
public Configuration getResourceConfiguration() {
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index 0259c69..2e15f8e 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -1568,10 +1568,11 @@ public class InventoryManager extends AgentService implements ContainerService,
}
public <T extends ResourceComponent> ResourceUpgradeContext<T> createResourceUpgradeContext(Resource resource,
- T parentComponent, ResourceDiscoveryComponent<T> discoveryComponent) {
+ ResourceContext<?> parentResourceContext, T parentComponent, ResourceDiscoveryComponent<T> discoveryComponent) {
File pluginDataDir = new File(this.configuration.getDataDirectory(), resource.getResourceType().getPlugin());
return new ResourceUpgradeContext<T>(resource, // the resource itself
+ parentResourceContext, //the context of its parent resource
parentComponent, // its parent component
discoveryComponent, // the discovery component (this is actually the proxy to it)
SystemInfoFactory.createSystemInfo(), // for native access
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
index 06d2cd0..b3b8716 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
@@ -36,6 +36,7 @@ import org.rhq.core.pc.PluginContainer;
import org.rhq.core.pc.inventory.InventoryManager;
import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext;
import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet;
@@ -158,12 +159,14 @@ public class ResourceUpgradeDelegate {
ResourceComponent<T> parentResourceComponent = resourceContainer.getResourceContext()
.getParentResourceComponent();
-
+
Resource parentResource = resourceContainer.getResource().getParentResource();
ResourceContainer parentResourceContainer = (parentResource != null) ? inventoryManager
.getResourceContainer(resourceContainer.getResource().getParentResource()) : null;
+ ResourceContext<?> parentResourceContext = parentResourceContainer == null ? null : parentResourceContainer.getResourceContext();
+
Resource resource = resourceContainer.getResource();
ResourceDiscoveryComponent<ResourceComponent<T>> discoveryComponent = PluginContainer.getInstance()
@@ -175,7 +178,7 @@ public class ResourceUpgradeDelegate {
}
ResourceUpgradeContext<ResourceComponent<T>> upgradeContext = inventoryManager.createResourceUpgradeContext(
- resource, parentResourceComponent, discoveryComponent);
+ resource, parentResourceContext, parentResourceComponent, discoveryComponent);
ResourceUpgradeRequest request = new ResourceUpgradeRequest(resource.getId());
commit 9bf39010bcf60ad0cd52876be3f1255329cf656e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:37:36 2010 +0100
BZ 535786 - Adding the SNMP host and port detection during the apache server discovery.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index a1b08a7..a5e19e5 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -18,12 +18,19 @@
*/
package org.rhq.plugins.apache;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.URI;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -162,6 +169,16 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
serverConfigFile.getParent() + File.separator + "*"));
}
+ List<InetSocketAddress> snmpAddresses = findSNMPAddresses(serverConfig, new File(serverRoot));
+ if (snmpAddresses != null && snmpAddresses.size() > 0) {
+ InetSocketAddress addr = snmpAddresses.get(0);
+ int port = addr.getPort();
+ InetAddress host = addr.getAddress() == null ? InetAddress.getLocalHost() : addr.getAddress();
+
+ pluginConfig.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST, host.getHostAddress()));
+ pluginConfig.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT, port));
+ }
+
discoveredResources.add(createResourceDetails(discoveryContext, pluginConfig, process.getProcessInfo(),
binaryInfo));
}
@@ -445,4 +462,106 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
return serverRoot + "||" + httpdConf;
}
+
+ private static List<InetSocketAddress> findSNMPAddresses(ApacheDirectiveTree tree, File serverRoot) {
+ List<InetSocketAddress> ret = new ArrayList<InetSocketAddress>();
+
+ List<ApacheDirective> confs = tree.search("/SNMPConf");
+
+ if (confs.size() == 0) {
+ log.info("SNMPConf directive not found. Skipping SNMP configuration.");
+ return ret;
+ }
+
+ String confDirName = confs.get(0).getValuesAsString();
+ if (confDirName == null || confDirName.isEmpty()) {
+ log.warn("The SNMPConf directive seems to not have a value. Skipping SNMP configuration.");
+ return ret;
+ }
+
+
+ File confDir = new File(confDirName);
+
+ if (!confDir.isAbsolute()) {
+ confDir = new File(serverRoot, confDirName);
+ }
+
+ File snmpdConf = new File(confDir, "snmpd.conf");
+
+ if (!snmpdConf.exists()) {
+ log.warn("Could not find a snmpd.conf file under the configured directory '" + confDirName
+ + "'. Skipping SNMP configuration.");
+ return ret;
+ }
+
+ try {
+ String agentAddressLine = findSNMPAgentAddressConfigLine(snmpdConf);
+
+ if (agentAddressLine == null) {
+ log.warn("Could not find the 'agentaddress' property in the snmpd.conf. Skipping SNMP configuration.");
+ return ret;
+ }
+
+ int specStartIdx = agentAddressLine.indexOf("agentaddress") + "agentaddress".length() + 1;
+
+ while (Character.isWhitespace(agentAddressLine.charAt(specStartIdx)))
+ specStartIdx++;
+
+ String spec = agentAddressLine.substring(specStartIdx);
+
+ String[] addrs = spec.split(",");
+
+ try {
+ for (String addr : addrs) {
+ if (addr.startsWith("udp") || addr.startsWith("tcp")) {
+ //this contains the transport spec - either "udp:" or "tcp:"
+ addr = addr.substring(4);
+ }
+
+ int atIdx = addr.indexOf('@');
+ String port = addr;
+ String host = null;
+ if (atIdx > 0) {
+ host = addr.substring(atIdx + 1);
+ port = addr.substring(0, atIdx);
+ }
+
+ InetSocketAddress address = null;
+ if (host != null) {
+ address = new InetSocketAddress(host, Integer.parseInt(port));
+ } else {
+ address = new InetSocketAddress(Integer.parseInt(port));
+ }
+
+ ret.add(address);
+ }
+ } catch (Exception e) {
+ log.warn("Failed to parse the SNMP 'agentaddress' configuration property: "
+ + agentAddressLine, e);
+ }
+ } catch (IOException e) {
+ log.warn("Failed to read in the configured snmpd.conf file: " + snmpdConf.getAbsolutePath(), e);
+ }
+
+ return ret;
+ }
+
+ private static String findSNMPAgentAddressConfigLine(File snmpdConf) throws IOException {
+ BufferedReader rdr = new BufferedReader(new FileReader(snmpdConf));
+
+ try {
+ Pattern search = Pattern.compile("^\\s*agentaddress.*");
+ String line;
+
+ while ((line = rdr.readLine()) != null) {
+ if (search.matcher(line).matches()) {
+ return line;
+ }
+ }
+
+ return null;
+ } finally {
+ rdr.close();
+ }
+ }
}
commit b7e3bccde3c4c36be6e9aab7299ff2d060e0475f
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:41:07 2010 +0100
BZ 642622 - Adding the ability to extract the scheme and port from the ServerName so that proper ping URLs can be discovered.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index bea7c23..a1b08a7 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -262,7 +262,7 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
*/
private static String getUrl(ApacheDirectiveTree serverConfig, String version) throws Exception {
Address addr = HttpdAddressUtility.get(version).getMainServerSampleAddress(serverConfig, null, 0);
- return addr == null ? null : "http://" + addr.host + ":" + addr.port + "/";
+ return addr == null ? null : addr.toString();
}
@Nullable
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index b2f76bc..8251658 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -124,7 +124,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
String url;
if (hostToPing != null && portToPing != Address.PORT_WILDCARD_VALUE && portToPing != Address.NO_PORT_SPECIFIED_VALUE) {
- url = "http://" + hostToPing + ":" + portToPing + "/";
+ url = scheme + "://" + hostToPing + ":" + portToPing + "/";
} else {
url = COULD_NOT_DETERMINE_THE_VIRTUAL_HOST_ADDRESS;
}
@@ -133,16 +133,18 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
pluginConfiguration.put(urlProp);
}
-
- File rtLogFile = new File(logsDir, address.host + address.port + RT_LOG_FILE_NAME_SUFFIX);
-
- PropertySimple rtLogProp = new PropertySimple(
- ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
- pluginConfiguration.put(rtLogProp);
-
+
+ if (address != null) {
+ File rtLogFile = new File(logsDir, address.host + address.port + RT_LOG_FILE_NAME_SUFFIX);
+
+ PropertySimple rtLogProp = new PropertySimple(
+ ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
+ pluginConfiguration.put(rtLogProp);
+ }
+
String resourceName;
if (serverName != null) {
- resourceName = address.toString();
+ resourceName = address.host + ":" + address.port;
} else {
resourceName = resourceKey;
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
index c5589fd..b5cdedf 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
@@ -82,7 +82,7 @@ public enum HttpdAddressUtility {
address = getLocalhost(address.port);
}
- updateWithServerName(address, ag);
+ updateWithServerName(address, ag, false);
return address;
}
@@ -90,7 +90,7 @@ public enum HttpdAddressUtility {
return null;
} catch (Exception e) {
- log.info("Failed to obtain main server address. Is augeas installed and correct lens in use?");
+ log.warn("Failed to obtain main server address.", e);
return null;
}
@@ -106,7 +106,7 @@ public enum HttpdAddressUtility {
addr = getLocalhost(addr.port);
}
- updateWithServerName(addr, ag);
+ updateWithServerName(addr, ag, false);
return addr;
}
@@ -115,7 +115,7 @@ public enum HttpdAddressUtility {
//there has to be at least one Listen directive
throw new IllegalStateException("Could find a listen address on port " + limitToPort);
} catch (Exception e) {
- log.info("Failed to obtain main server address. Is augeas installed and correct lens in use?");
+ log.warn("Failed to obtain main server address.", e);
return null;
}
@@ -131,6 +131,7 @@ public enum HttpdAddressUtility {
public static class Address {
public String host;
public int port = -1;
+ public String scheme = "http";
public static final String WILDCARD = "*";
public static final String DEFAULT_HOST = "_default_";
@@ -142,6 +143,10 @@ public enum HttpdAddressUtility {
this.port = port;
}
+ public Address(String scheme, String host, int port) {
+ this(host, port);
+ this.scheme = scheme;
+ }
/**
* A simple parser of the provided address into host and port
* sections.
@@ -150,6 +155,13 @@ public enum HttpdAddressUtility {
* @return an instance of Address with host and port set accordingly
*/
public static Address parse(String address) {
+ String scheme = "http";
+ int schemeSpecIdx = address.indexOf("://");
+ if (schemeSpecIdx >= 0) {
+ scheme = address.substring(0, schemeSpecIdx);
+ address = address.substring(schemeSpecIdx + "://".length());
+ }
+
int lastColonIdx = address.lastIndexOf(':');
if (lastColonIdx == NO_PORT_SPECIFIED_VALUE) {
return new Address(address, -1);
@@ -166,10 +178,10 @@ public enum HttpdAddressUtility {
port = Integer.parseInt(portSpec);
}
- return new Address(host, port);
+ return new Address(scheme, host, port);
} else {
//this is an IP6 address without a port spec
- return new Address(address, NO_PORT_SPECIFIED_VALUE);
+ return new Address(scheme, address, NO_PORT_SPECIFIED_VALUE);
}
}
}
@@ -214,11 +226,11 @@ public enum HttpdAddressUtility {
@Override
public String toString() {
- if (port == NO_PORT_SPECIFIED_VALUE) return host;
+ if (port == NO_PORT_SPECIFIED_VALUE) return scheme + "://" + host;
else {
String portSpec = port == PORT_WILDCARD_VALUE ? WILDCARD : String.valueOf(port);
- return host + ":" + portSpec;
+ return scheme + "://" + host + ":" + portSpec;
}
}
}
@@ -245,30 +257,29 @@ public enum HttpdAddressUtility {
* @return the address on which the virtual host can be accessed or null on error
*/
public Address getVirtualHostSampleAddress(ApacheDirectiveTree ag, String virtualHost, String serverName, boolean snmpModuleCompatibleMode) {
- Address addr = Address.parse(virtualHost);
- if (addr.isHostDefault() || addr.isHostWildcard()) {
- Address serverAddr = null;
- if (snmpModuleCompatibleMode) {
- serverAddr = getLocalhost(addr.port);
- } else {
- serverAddr = getMainServerSampleAddress(ag, null, addr.port);
+ try {
+ Address addr = Address.parse(virtualHost);
+ if (addr.isHostDefault() || addr.isHostWildcard()) {
+ Address serverAddr = null;
+ if (snmpModuleCompatibleMode) {
+ serverAddr = getLocalhost(addr.port);
+ } else {
+ serverAddr = getMainServerSampleAddress(ag, null, addr.port);
+ }
+ if (serverAddr == null)
+ return null;
+ addr.host = serverAddr.host;
}
- if (serverAddr == null)
- return null;
- addr.host = serverAddr.host;
- }
- if (serverName != null) {
- int colonIdx = serverName.indexOf(':');
- if (colonIdx >= 0) {
- addr.host = serverName.substring(0, colonIdx);
- addr.port = Integer.parseInt(serverName.substring(colonIdx + 1));
- } else {
- addr.host = serverName;
+ if (serverName != null) {
+ updateWithServerName(addr, serverName, true);
}
- }
- return addr;
+ return addr;
+ } catch (Exception e) {
+ log.warn("Failed to obtain virtual host address.", e);
+ return null;
+ }
}
private static Address parseListen(String listenValue) {
@@ -335,12 +346,12 @@ public enum HttpdAddressUtility {
try {
return new Address(InetAddress.getLocalHost().getHostAddress(), port);
} catch (UnknownHostException e) {
- //well, this is bad, we can get address of the localhost. let's use the force...
+ //well, this is bad, we can't get address of the localhost. let's use the force...
return new Address("127.0.0.1", port);
}
}
- private static void updateWithServerName(Address address, ApacheDirectiveTree config) throws UnknownHostException {
+ private static void updateWithServerName(Address address, ApacheDirectiveTree config, boolean updatePort) throws UnknownHostException {
//check if there is a ServerName directive
List<ApacheDirective> serverNameNodes = config.search("/ServerName");
@@ -349,11 +360,20 @@ public enum HttpdAddressUtility {
//be the case if the server listens on more than one interfaces.
if (serverNameNodes.size() > 0) {
String serverName = serverNameNodes.get(0).getValuesAsString();
- InetAddress addrFromServerName = InetAddress.getByName(serverName);
- InetAddress addrFromAddress = InetAddress.getByName(address.host);
-
- if (addrFromAddress.equals(addrFromServerName)) {
- address.host = serverName;
+ updateWithServerName(address, serverName, updatePort);
+ }
+ }
+
+ private static void updateWithServerName(Address address, String serverName, boolean updatePort) throws UnknownHostException {
+ Address serverAddr = Address.parse(serverName);
+ InetAddress addrFromServerName = InetAddress.getByName(serverAddr.host);
+ InetAddress addrFromAddress = InetAddress.getByName(address.host);
+
+ if (addrFromAddress.equals(addrFromServerName)) {
+ address.scheme = serverAddr.scheme;
+ address.host = serverAddr.host;
+ if (updatePort) {
+ address.port = serverAddr.port;
}
}
}
commit eb45a242496d529a1ac3ee63807d8ea67237708e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:43:42 2010 +0200
BZ 642610 - directives found in included files aren't duplicated anymore
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
index 2e0f2a2..6cb168e 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
@@ -121,18 +121,6 @@ public class ApacheAugeasNode extends AugeasNodeLazy implements AugeasNode {
childNodes.add(node);
}
- public List<AugeasNode> getChildByLabel(String labelName) {
- List<AugeasNode> nodes = super.getChildByLabel(labelName);
-
- if (includedNodes != null) {
- for (AugeasNode node : includedNodes) {
- if (node.getLabel().equals(labelName))
- nodes.add(node);
- }
- }
- return nodes;
- }
-
public void setPath(String path) throws AugeasTreeException {
this.path = path;
commit a3455824e924722ee018b6fca916da31a2c5e859
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:42:17 2010 +0200
BZ 642591 - make sure we always have the same resource keys as in old plugin version.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
index c1f6323..4c61682 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
@@ -590,6 +590,13 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
/**
+ * @return The url the server is pinged for availability or null if the url is not set.
+ */
+ public @Nullable String getServerUrl() {
+ return resourceContext.getPluginConfiguration().getSimpleValue(PLUGIN_CONFIG_PROP_URL, null);
+ }
+
+ /**
* Returns the httpd.conf file
* @return A File object that represents the httpd.conf file or null in case of error
*/
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index d97d9fc..a0f2120 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -21,6 +21,8 @@ package org.rhq.plugins.apache;
import java.io.File;
import java.net.InetAddress;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -345,40 +347,77 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
List<AugeasNode> virtualHosts = new ArrayList<AugeasNode>();
boolean updated = false;
- for (AugeasNode node : nodes) {
- updated = false;
+//BZ 612189 - uncomment this algo once the resource upgrade is in place
+// for (AugeasNode node : nodes) {
+// updated = false;
+// List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
+// String tempServerName = null;
+//
+// if (!(serverNameNodes.isEmpty())) {
+// tempServerName = serverNameNodes.get(0).getValue();
+// }
+// if (tempServerName == null & serverName == null)
+// updated = true;
+// if (tempServerName != null & serverName != null)
+// if (tempServerName.equals(serverName)){
+// updated = true;
+// }
+//
+//
+// if (updated){
+// updated = false;
+// List<AugeasNode> params = node.getChildByLabel("param");
+// for (AugeasNode nd : params) {
+// updated = false;
+// for (String adr : addrs) {
+// if (adr.equals(nd.getValue()))
+// updated = true;
+// }
+// if (!updated)
+// break;
+// }
+//
+// if (updated)
+// virtualHosts.add(node);
+// }
+// }
+
+ //BZ 612189 - remove this once resource upgrade is in place
+ HttpdAddressUtility.Address resourceKeyAddress = HttpdAddressUtility.Address.parse(resourceKey);
+ for(AugeasNode node : nodes) {
List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
- String tempServerName = null;
-
- if (!(serverNameNodes.isEmpty())) {
- tempServerName = serverNameNodes.get(0).getValue();
- }
- if (tempServerName == null & serverName == null)
- updated = true;
- if (tempServerName != null & serverName != null)
- if (tempServerName.equals(serverName)){
- updated = true;
- }
+ List<AugeasNode> vhostAddressNodes = node.getChildByLabel("param");
+
+ String vhostServerName = serverNameNodes.isEmpty() ? null : serverNameNodes.get(0).getValue();
+ String vhostAddressDef = vhostAddressNodes.isEmpty() ? null : vhostAddressNodes.get(0).getValue();
+
+ if (vhostAddressDef != null) {
+ HttpdAddressUtility.Address vhostAddress = HttpdAddressUtility.Address.parse(vhostAddressDef);
+ if (vhostServerName != null) {
+ HttpdAddressUtility.Address vhostServerAddress = HttpdAddressUtility.Address.parse(vhostServerName);
+ vhostAddress.host = vhostServerAddress.host;
+ }
-
- if (updated){
- updated = false;
- List<AugeasNode> params = node.getChildByLabel("param");
- for (AugeasNode nd : params) {
- updated = false;
- for (String adr : addrs) {
- if (adr.equals(nd.getValue()))
- updated = true;
- }
- if (!updated)
- break;
- }
-
- if (updated)
- virtualHosts.add(node);
+ if (resourceKeyAddress.equals(vhostAddress)) {
+ virtualHosts.add(node);
}
- }
-
+ }
+ }
+
+ //BZ 612189 - remove this once we have resource upgrade
+ //ok, one final attempt... the legacy resource key format for the MainServer is just a host:port as with the rest of the vhosts, let's try that
+ try {
+ String serverUrl = resourceContext.getParentResourceComponent().getServerUrl();
+ URI serverUri = new URI(serverUrl);
+ String expectedResourceKey = serverUri.getHost() + ":" + serverUri.getPort();
+
+ if (expectedResourceKey.equals(resourceKey)) {
+ return tree.getRootNode();
+ }
+ } catch (URISyntaxException e) {
+ log.warn("Failed to parse the server URL when trying to match the vhost with the main server.", e);
+ }
+
if (virtualHosts.size() == 0) {
throw new IllegalStateException("Could not find virtual host configuration in augeas for virtual host: "
+ resourceKey);
@@ -505,6 +544,14 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
vhostServerName, true);
if (vhostAddr != null) {
vhostAddresses.add(vhostAddr);
+ } else {
+ //this is not to choke on the old style resource keys for the main server. without this, we'd never be able
+ //to match the main server with its snmp index below.
+ HttpdAddressUtility.Address addr = HttpdAddressUtility.Address.parse(vhostAddressStrings[i]);
+ vhostAddr = parent.getAddressUtility().getMainServerSampleAddress(tree, addr.host, addr.port);
+ if (vhostAddr != null) {
+ vhostAddresses.add(vhostAddr);
+ }
}
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index 4a32e27..b2f76bc 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -19,7 +19,10 @@
package org.rhq.plugins.apache;
import java.io.File;
+import java.net.InetAddress;
import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -37,6 +40,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.apache.parser.ApacheDirective;
import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
+import org.rhq.plugins.apache.util.HttpdAddressUtility;
import org.rhq.plugins.apache.util.HttpdAddressUtility.Address;
import org.rhq.plugins.www.snmp.SNMPException;
import org.rhq.plugins.www.snmp.SNMPSession;
@@ -91,23 +95,13 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
serverName = serverNames.get(0).getValuesAsString();
}
- StringBuilder keyBuilder = new StringBuilder();
- if (serverName != null) {
- keyBuilder.append(serverName).append("|");
- }
- keyBuilder.append(firstAddress);
-
-
- for (int i=1;i<hosts.size();i++){
- keyBuilder.append(" ").append(hosts.get(i));
- }
-
- String resourceKey = keyBuilder.toString();
+ String resourceKey = createResourceKey(serverName, hosts);
Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
Address address = serverComponent.getAddressUtility().getVirtualHostSampleAddress(tree, firstAddress, serverName, false);
if (address != null) {
+ String scheme = address.scheme;
String hostToPing = address.host;
int portToPing = address.port;
if (address.isPortWildcard()) {
@@ -178,6 +172,9 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
String mainServerUrl = context.getParentResourceContext().getPluginConfiguration().getSimple(
ApacheServerComponent.PLUGIN_CONFIG_PROP_URL).getStringValue();
+
+ String key = null;
+
if (mainServerUrl != null && !"null".equals(mainServerUrl)) {
PropertySimple mainServerUrlProp = new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP,
mainServerUrl);
@@ -196,9 +193,15 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
PropertySimple rtLogProp = new PropertySimple(
ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
mainServerPluginConfig.put(rtLogProp);
+
+ //BZ 612189 - remove this once we have resource upgrade
+ key = host + ":" + port;
}
- String key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ //BZ 612189 - this can simply the MAIN_SERVER_RESOURCE_KEY only once we have resource upgrade
+ if (key == null) {
+ key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ }
//BZ 612189 - remove this once we have resource upgrade
if (snmpDiscoveries != null) {
@@ -237,6 +240,42 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
}
}
+ public static String createResourceKey(String serverName, List<String> hosts) {
+//BZ 612189 - swap the impls once resource upgrade is in place
+// StringBuilder keyBuilder = new StringBuilder();
+// if (serverName != null) {
+// keyBuilder.append(serverName).append("|");
+// }
+// keyBuilder.append(hosts.get(0));
+//
+//
+// for (int i = 1; i < hosts.size(); ++i){
+// keyBuilder.append(" ").append(hosts.get(i));
+// }
+//
+// return keyBuilder.toString();
+
+ //try to derive the same resource key as the SNMP would have... this is to prevent the duplication of
+ //vhost resources after the SNMP was configured - how I wish resource upgrade made it to 3.0 to prevent this
+ //kind of guessing being necessary.
+ String host = hosts.get(0);
+ HttpdAddressUtility.Address hostAddr = HttpdAddressUtility.Address.parse(host);
+ if (serverName != null) {
+ HttpdAddressUtility.Address serverAddr = HttpdAddressUtility.Address.parse(serverName);
+ hostAddr.host = serverAddr.host;
+ }
+
+ //the SNMP module seems to resolve the IPs to hostnames.
+ try {
+ InetAddress hostName = InetAddress.getByName(hostAddr.host);
+ hostAddr.host = hostName.getHostName();
+ } catch (UnknownHostException e) {
+ log.debug("Host " + hostAddr.host + " is not resolvable.", e);
+ }
+
+ return hostAddr.host + ":" + hostAddr.port;
+ }
+
/**
* @deprecated remove this once we have resource upgrade
* @param discoveryContext
@@ -279,7 +318,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
return ret;
} catch (Exception e) {
- log.warn("Error while trying to contact SNMP of the apache server " + discoveryContext.getParentResourceContext().getResourceKey());
+ log.warn("Error while trying to contact SNMP of the apache server " + discoveryContext.getParentResourceContext().getResourceKey(), e);
return null;
}
}
commit 15a2bbe9f0a9ba43cccb2065ced149a8abb92710
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 14:33:57 2010 +0100
BZ 642588 - config is reloaded if ServerRoot is redefined in config
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index ca8f972..bea7c23 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -141,6 +141,8 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
if (!serverRoots.isEmpty()) {
serverRoot = AugeasNodeValueUtil.unescape(serverRoots.get(0).getValuesAsString());
serverRootProp.setValue(serverRoot);
+ //reparse the configuration with the new ServerRoot
+ serverConfig = loadParser(serverConfigFile.getAbsolutePath(), serverRoot);
}
serverUrl = getUrl(serverConfig, binaryInfo.getVersion());
13 years, 8 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java | 14 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java | 21 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java | 24 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 15 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 20 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java | 28 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java | 52 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java | 75 +++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java | 30 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java | 23 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java | 27 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java | 94 ++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 30 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java | 37 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java | 32 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java | 23 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java | 35 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java | 80 +++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java | 26 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java | 19 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java | 20 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java | 21 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java | 19 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java | 129 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java | 21 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java | 32 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 45 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java | 52 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java | 76 +++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java | 58 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java | 121 ++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java | 18 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java | 48 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java | 30 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java | 16 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java | 20 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java | 62 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java | 17 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 23 +
45 files changed, 981 insertions(+), 590 deletions(-)
New commits:
commit 0235aed4bd3737768f96acc66f5868838235686d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Oct 15 17:40:49 2010 -0400
DataSource Work:
Resulting from the fact that we couldn't render a list view without
including the ID colum. In short it seems there is (currently) only one
way to get control of column widths in one of our dataSource-backed
ListGrid based views. That is to override the ds fields with its own
ListGrid fields (see ResourceSearchView for a working example).
Perhaps at some point the listGrid.resizeField() method will work as
maybe it should, but until then this is the way to go. By calling
setFields(ListGridField[]) you will override the ds fields. For datasources
used explicitly to back ListGrid views the ds doesn't really have to
declare fields. With one exception, it may need to declare a primary key
field, typically "id".
Anyway, this checkin does a few things:
- Apply the same pattern to all of our datasources for defining ds fields.
This pattern lets subclasses easily add to the superclass's fields.
- Add CoreGUI.isDebugEnabled()
- Add Table.setListGridFields(fields). This will handle any "id" field
defined in the underlying datasource. It will be shown in debug and
omitted otherwise.
- Update ResourceSearchView and ResourceDataSource to work in the new
fashion and serve (hopefully) as a decent example moving forward. Look
here if you want to fix issues in column widths.
- Misc: some null protection added, some selenium ID protection added
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 3544941..5bce6ba 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
@@ -88,6 +88,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
private static Messages messages;
+ private static boolean debugMode = true;
+
public void onModuleLoad() {
String hostPageBaseURL = GWT.getHostPageBaseURL();
if (hostPageBaseURL.indexOf("/coregui/") == -1) {
@@ -102,7 +104,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
coreGUI = this;
- if (!GWT.isScript()) {
+ debugMode = !GWT.isScript();
+ if (debugMode) {
KeyIdentifier debugKey = new KeyIdentifier();
debugKey.setCtrlKey(true);
debugKey.setKeyName("D");
@@ -331,4 +334,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
}
+ public static boolean isDebugMode() {
+ return debugMode;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
index 9af7064..a12bec5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.admin.roles;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -62,13 +63,24 @@ public class RolesDataSource extends RPCDataSource<Role> {
}
public RolesDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceField idDataField = new DataSourceIntegerField("id", "ID");
idDataField.setPrimaryKey(true);
idDataField.setCanEdit(false);
+ fields.add(idDataField);
DataSourceTextField nameField = new DataSourceTextField("name", "Name", 100, true);
+ fields.add(nameField);
- setFields(idDataField, nameField);
+ return fields;
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
index af9acd6..33b94a0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.admin.users;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -63,16 +64,28 @@ public class UsersDataSource extends RPCDataSource<Subject> {
}
public UsersDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idDataField = new DataSourceIntegerField("id", "ID");
idDataField.setPrimaryKey(true);
idDataField.setCanEdit(false);
+ fields.add(idDataField);
DataSourceTextField usernameField = new DataSourceTextField("name", "User Name", 100, true);
+ fields.add(usernameField);
DataSourceTextField firstName = new DataSourceTextField("firstName", "First Name", 100, true);
+ fields.add(firstName);
DataSourceTextField lastName = new DataSourceTextField("lastName", "Last Name", 100, true);
+ fields.add(lastName);
DataSourceTextField password = new DataSourceTextField("password", "Password", 100, false);
password.setType(FieldType.PASSWORD);
@@ -89,18 +102,22 @@ public class UsersDataSource extends RPCDataSource<Subject> {
passwordsEqualValidator.setOtherField("password");
passwordsEqualValidator.setErrorMessage("Passwords do not match");
passwordVerify.setValidators(passwordsEqualValidator);
+ fields.add(password);
DataSourceTextField emailAddress = new DataSourceTextField("emailAddress", "Email Address", 100, true);
+ fields.add(emailAddress);
DataSourceTextField phone = new DataSourceTextField("phoneNumber", "Phone", 15, false);
+ fields.add(phone);
DataSourceTextField department = new DataSourceTextField("department", "Department", 100, false);
+ fields.add(department);
DataSourceTextField enabled = new DataSourceTextField("factive", "Enabled");
enabled.setType(FieldType.BOOLEAN);
+ fields.add(enabled);
- setFields(idDataField, usernameField, firstName, lastName, password, passwordVerify, phone, emailAddress,
- department, enabled);
+ return fields;
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index a950c34..aaee63f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -18,7 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.alert;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -65,12 +64,13 @@ public class AlertDataSource extends RPCDataSource<Alert> {
setCanMultiSort(true);
- List<DataSourceField> fields = createFields();
+ List<DataSourceField> fields = addDataSourceFields();
addFields(fields);
}
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = new ArrayList<DataSourceField>();
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idField = new DataSourceIntegerField("id", "Id");
idField.setPrimaryKey(true);
@@ -284,7 +284,8 @@ public class AlertDataSource extends RPCDataSource<Alert> {
CoreGUI.getMessageCenter().notify(
new Message("Acknowledged [" + alertIds.length + "] alerts", Message.Severity.Info));
- com.allen_sauer.gwt.log.client.Log.info("Acknowledged Alerts with id's: " + Arrays.toString(alertIds) + ".");
+ com.allen_sauer.gwt.log.client.Log.info("Acknowledged Alerts with id's: " + Arrays.toString(alertIds)
+ + ".");
alertsView.refresh();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
index 7a53dbe..b7c9db8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
@@ -19,10 +19,12 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceImageField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.FieldType;
@@ -52,7 +54,9 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
protected static final String FIELD_OBJECT = "_object"; // the actual AlertDefinition object
public AbstractAlertDefinitionsDataSource() {
- setupFields();
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
}
@Override
@@ -94,27 +98,31 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
* free to call this method and then add more, or add their own custom set and not
* call this method at all (if they don't want some of these basic fields or want to reorder them).
*/
- protected void setupFields() {
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField nameField = new DataSourceTextField(FIELD_NAME, "Name");
- addField(nameField);
+ fields.add(nameField);
DataSourceTextField descriptionField = new DataSourceTextField(FIELD_DESCRIPTION, "Description");
- addField(descriptionField);
+ fields.add(descriptionField);
DataSourceTextField ctimeField = new DataSourceTextField(FIELD_CTIME, "Created Time");
ctimeField.setType(FieldType.DATETIME);
- addField(ctimeField);
+ fields.add(ctimeField);
DataSourceTextField mtimeField = new DataSourceTextField(FIELD_MTIME, "Modified Time");
mtimeField.setType(FieldType.DATETIME);
- addField(mtimeField);
+ fields.add(mtimeField);
DataSourceTextField enabledField = new DataSourceTextField(FIELD_ENABLED, "Enabled");
enabledField.setType(FieldType.BOOLEAN);
- addField(enabledField);
+ fields.add(enabledField);
DataSourceImageField priorityField = new DataSourceImageField(FIELD_PRIORITY, "Priority");
- addField(priorityField);
+ fields.add(priorityField);
+
+ return fields;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 2d4e85a..2d8463d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -24,10 +24,12 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Window;
@@ -148,8 +150,19 @@ public class ConditionsEditor extends LocatableVLayout {
private static final String FIELD_CONDITION = "condition";
public ConditionDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField conditionField = new DataSourceTextField(FIELD_CONDITION, "Condition");
- addField(conditionField);
+ fields.add(conditionField);
+
+ return fields;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
index f707dc1..f783b4c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -29,6 +29,7 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Window;
@@ -170,11 +171,26 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
private class NotificationDataSource extends RPCDataSource<AlertNotification> {
public NotificationDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField senderField = new DataSourceTextField(FIELD_SENDER, "Sender");
- addField(senderField);
+ fields.add(senderField);
DataSourceTextField configField = new DataSourceTextField(FIELD_CONFIGURATION, "Configuration");
- addField(configField);
+ fields.add(configField);
+
+ return fields;
+ }
+
+ @Override
+ public void useDatasourceDefinedFields() {
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
index f53710f..b9c4dca 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
@@ -23,10 +23,12 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.List;
import java.util.Map;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceLinkField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -81,15 +83,17 @@ public class ResourceAlertDefinitionsDataSource extends AbstractAlertDefinitions
}
@Override
- protected void setupFields() {
- super.setupFields();
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
// add two more columns
DataSourceLinkField parentIdField = new DataSourceLinkField(FIELD_PARENT, "Parent");
- addField(parentIdField);
+ fields.add(parentIdField);
DataSourceTextField readOnlyField = new DataSourceTextField(FIELD_READONLY, "Read Only");
- addField(readOnlyField);
+ fields.add(readOnlyField);
+
+ return fields;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
index a6e4da7..1f3ced4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
@@ -23,10 +23,12 @@
package org.rhq.enterprise.gui.coregui.client.bundle.deployment;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -48,25 +50,35 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundleDeploymentDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField id = new DataSourceIntegerField("id", "ID");
id.setPrimaryKey(true);
- addField(id);
+ fields.add(id);
DataSourceTextField name = new DataSourceTextField("name", "Deployment Name");
- addField(name);
+ fields.add(name);
DataSourceTextField bundleVersion = new DataSourceTextField("bundleVersionVersion", "Bundle Version");
- addField(bundleVersion);
+ fields.add(bundleVersion);
DataSourceTextField description = new DataSourceTextField("description", "Description");
- addField(description);
+ fields.add(description);
DataSourceTextField status = new DataSourceTextField("status", "Status");
- addField(status);
+ fields.add(status);
DataSourceDateTimeField created = new DataSourceDateTimeField("deploymentTime", "Deployment Time");
- addField(created);
+ fields.add(created);
+
+ return fields;
}
@Override
@@ -83,7 +95,8 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
}
if (request.getCriteria().getValues().containsKey("bundleDestinationId")) {
- criteria.addFilterDestinationId(Integer.parseInt(request.getCriteria().getAttribute("bundleDestinationId")));
+ criteria
+ .addFilterDestinationId(Integer.parseInt(request.getCriteria().getAttribute("bundleDestinationId")));
}
if (request.getCriteria().getValues().get("tagNamespace") != null) {
@@ -130,7 +143,6 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
record.setAttribute("status", from.getStatus().name());
record.setAttribute("deployer", from.getSubjectName());
-
if (from.getBundleVersion() != null) {
record.setAttribute("bundleVersionVersion", from.getBundleVersion().getVersion());
record.setAttribute("bundleVersionId", from.getBundleVersion().getId());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
index a2fa68e..1c23d51 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
@@ -22,15 +22,17 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.deployment.resource;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
-import org.rhq.core.domain.criteria.BundleDeploymentCriteria;
import org.rhq.core.domain.criteria.BundleResourceDeploymentCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
@@ -44,19 +46,27 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleResourceDeployment> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
-
public BundleResourceDeploymentDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
- DataSourceIntegerField id = new DataSourceIntegerField("id","ID");
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceIntegerField id = new DataSourceIntegerField("id", "ID");
id.setPrimaryKey(true);
- addField(id);
+ fields.add(id);
DataSourceTextField resourceName = new DataSourceTextField("resourceName", "Resource");
- addField(resourceName);
+ fields.add(resourceName);
DataSourceTextField status = new DataSourceTextField("status", "Status");
- addField(status);
+ fields.add(status);
+ return fields;
}
@Override
@@ -68,26 +78,27 @@ public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleReso
criteria.fetchHistories(true);
if (request.getCriteria().getValues().containsKey("bundleDeploymentId")) {
- criteria.addFilterBundleDeploymentId(Integer.parseInt(request.getCriteria().getAttribute("bundleDeploymentId")));
+ criteria.addFilterBundleDeploymentId(Integer.parseInt(request.getCriteria().getAttribute(
+ "bundleDeploymentId")));
}
- bundleService.findBundleResourceDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleResourceDeployment>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle resource deployments",caught);
- }
-
- public void onSuccess(PageList<BundleResourceDeployment> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ bundleService.findBundleResourceDeploymentsByCriteria(criteria,
+ new AsyncCallback<PageList<BundleResourceDeployment>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load bundle resource deployments", caught);
+ }
+ public void onSuccess(PageList<BundleResourceDeployment> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
@Override
public BundleResourceDeployment copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
@@ -97,10 +108,9 @@ public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleReso
record.setAttribute("resourceName", from.getResource().getName());
record.setAttribute("resourceId", from.getResource().getId());
- record.setAttribute("status",from.getStatus().name());
-
- record.setAttribute("histories",from.getBundleResourceDeploymentHistories());
+ record.setAttribute("status", from.getStatus().name());
+ record.setAttribute("histories", from.getBundleResourceDeploymentHistories());
from.getBundleResourceDeploymentHistories();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
index a375981..3985c78 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
@@ -23,10 +23,12 @@
package org.rhq.enterprise.gui.coregui.client.bundle.destination;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -34,7 +36,6 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDestination;
import org.rhq.core.domain.bundle.BundleVersion;
-import org.rhq.core.domain.criteria.BundleDeploymentCriteria;
import org.rhq.core.domain.criteria.BundleDestinationCriteria;
import org.rhq.core.domain.criteria.BundleVersionCriteria;
import org.rhq.core.domain.util.PageList;
@@ -48,38 +49,49 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
public class BundleDestinationDataSource extends RPCDataSource<BundleDestination> {
public BundleDestinationDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id", "Id");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField name = new DataSourceTextField("name", "Name");
- addField(name);
+ fields.add(name);
DataSourceTextField description = new DataSourceTextField("description", "Description");
- addField(description);
+ fields.add(description);
DataSourceTextField bundle = new DataSourceTextField("bundleName", "Bundle");
- addField(bundle);
+ fields.add(bundle);
DataSourceTextField group = new DataSourceTextField("groupName", "Group");
- addField(group);
+ fields.add(group);
DataSourceTextField deployDir = new DataSourceTextField("deployDir", "Deploy Directory");
- addField(deployDir);
+ fields.add(deployDir);
- DataSourceTextField latestDeploymentVersion = new DataSourceTextField("latestDeploymentVersion", "Last Deployed Version");
- addField(latestDeploymentVersion);
+ DataSourceTextField latestDeploymentVersion = new DataSourceTextField("latestDeploymentVersion",
+ "Last Deployed Version");
+ fields.add(latestDeploymentVersion);
- DataSourceTextField latestDeploymentDate = new DataSourceTextField("latestDeploymentDate", "Last Deployment Date");
- addField(latestDeploymentDate);
+ DataSourceTextField latestDeploymentDate = new DataSourceTextField("latestDeploymentDate",
+ "Last Deployment Date");
+ fields.add(latestDeploymentDate);
- DataSourceTextField latestDeploymentStatus = new DataSourceTextField("latestDeploymentStatus", "Last Deployment Status");
- addField(latestDeploymentStatus);
+ DataSourceTextField latestDeploymentStatus = new DataSourceTextField("latestDeploymentStatus",
+ "Last Deployment Status");
+ fields.add(latestDeploymentStatus);
+ return fields;
}
-
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
BundleDestinationCriteria criteria = new BundleDestinationCriteria();
@@ -88,7 +100,7 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
criteria.addFilterBundleId(Integer.parseInt(request.getCriteria().getAttributeAsString("bundleId")));
}
- if (request.getCriteria().getValues().get("tagNamespace") != null) {
+ if (request.getCriteria().getValues().get("tagNamespace") != null) {
criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
}
@@ -100,28 +112,29 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
}
-
criteria.fetchBundle(true);
criteria.fetchDeployments(true);
criteria.fetchGroup(true);
criteria.fetchTags(true);
-
GWTServiceLookup.getBundleService().findBundleDestinationsByCriteria(criteria,
- new AsyncCallback<PageList<BundleDestination>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle destinations",caught);
- }
+ new AsyncCallback<PageList<BundleDestination>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load bundle destinations", caught);
+ }
- public void onSuccess(final PageList<BundleDestination> result) {
+ public void onSuccess(final PageList<BundleDestination> result) {
- BundleVersionCriteria versionCriteria = new BundleVersionCriteria();
- if (request.getCriteria().getValues().containsKey("bundleId")) {
- versionCriteria.addFilterBundleId(Integer.parseInt(request.getCriteria().getAttributeAsString("bundleId")));
- }
- GWTServiceLookup.getBundleService().findBundleVersionsByCriteria(versionCriteria, new AsyncCallback<PageList<BundleVersion>>() {
+ BundleVersionCriteria versionCriteria = new BundleVersionCriteria();
+ if (request.getCriteria().getValues().containsKey("bundleId")) {
+ versionCriteria.addFilterBundleId(Integer.parseInt(request.getCriteria().getAttributeAsString(
+ "bundleId")));
+ }
+ GWTServiceLookup.getBundleService().findBundleVersionsByCriteria(versionCriteria,
+ new AsyncCallback<PageList<BundleVersion>>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle destination deployed version info",caught);
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to load bundle destination deployed version info", caught);
}
public void onSuccess(PageList<BundleVersion> versions) {
@@ -143,8 +156,8 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
}
});
- }
- });
+ }
+ });
}
@Override
@@ -168,7 +181,6 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
record.setAttribute("deployDir", from.getDeployDir());
record.setAttribute("entity", from);
-
long last = 0;
for (BundleDeployment dep : from.getDeployments()) {
if (last < dep.getCtime()) {
@@ -182,7 +194,6 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
}
}
-
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
index 6b08c63..b5b0444 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
@@ -18,9 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.list;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -39,26 +42,34 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
public class BundleVersionDataSource extends RPCDataSource<BundleVersion> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
- private int bundleId;
public BundleVersionDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceIntegerField idField = new DataSourceIntegerField("id", "ID");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField latestVersionField = new DataSourceTextField("version", "Version");
- addField(latestVersionField);
+ fields.add(latestVersionField);
DataSourceTextField nameField = new DataSourceTextField("name", "Name");
- addField(nameField);
+ fields.add(nameField);
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
- addField(descriptionField);
-
-
+ fields.add(descriptionField);
DataSourceIntegerField deploymentCountField = new DataSourceIntegerField("fileCount", "File Count");
- addField(deploymentCountField);
+ fields.add(deploymentCountField);
+
+ return fields;
}
@Override
@@ -70,7 +81,8 @@ public class BundleVersionDataSource extends RPCDataSource<BundleVersion> {
criteria.setPageControl(getPageControl(request));
if (request.getCriteria().getValues().get("bundleId") != null) {
- criteria.addFilterBundleId(Integer.parseInt(String.valueOf(request.getCriteria().getValues().get("bundleId"))));
+ criteria.addFilterBundleId(Integer.parseInt(String.valueOf(request.getCriteria().getValues()
+ .get("bundleId"))));
}
if (request.getCriteria().getValues().get("tagNamespace") != null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
index 7c8aa02..32cf81a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
@@ -18,9 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.list;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -41,19 +44,29 @@ public class BundlesDataSource extends RPCDataSource<Bundle> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundlesDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id", "ID");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField("name", "Name");
- addField(nameField);
+ fields.add(nameField);
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
- addField(descriptionField);
+ fields.add(descriptionField);
DataSourceTextField bundleTypeDataField = new DataSourceTextField("bundleType", "Bundle Type");
- addField(bundleTypeDataField);
+ fields.add(bundleTypeDataField);
+
+ return fields;
}
@Override
@@ -62,7 +75,6 @@ public class BundlesDataSource extends RPCDataSource<Bundle> {
BundleCriteria criteria = new BundleCriteria();
criteria.setPageControl(getPageControl(request));
-
if (request.getCriteria().getValues().get("tagNamespace") != null) {
criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
}
@@ -75,7 +87,6 @@ public class BundlesDataSource extends RPCDataSource<Bundle> {
criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
}
-
bundleService.findBundlesByCriteria(criteria, new AsyncCallback<PageList<Bundle>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Failed to load bundle data", caught);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
index e3b54ac..76340e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
@@ -18,9 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.list;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceLinkField;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -42,23 +45,32 @@ public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWith
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundlesWithLatestVersionDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id", "ID");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceLinkField linkField = new DataSourceLinkField("link", "Name");
- addField(linkField);
-
+ fields.add(linkField);
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
- addField(descriptionField);
+ fields.add(descriptionField);
DataSourceTextField latestVersionField = new DataSourceTextField("latestVersion", "Latest Version");
- addField(latestVersionField);
+ fields.add(latestVersionField);
DataSourceIntegerField deploymentCountField = new DataSourceIntegerField("versionsCount", "Versions Count");
- addField(deploymentCountField);
+ fields.add(deploymentCountField);
+
+ return fields;
}
@Override
@@ -78,7 +90,6 @@ public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWith
criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
}
-
bundleService.findBundlesWithLatestVersionCompositesByCriteria(criteria,
new AsyncCallback<PageList<BundleWithLatestVersionComposite>>() {
public void onFailure(Throwable caught) {
@@ -115,11 +126,9 @@ public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWith
record.setAttribute("id", from.getBundleId());
record.setAttribute("name", from.getBundleName());
-
record.setAttribute("link", "#Bundles/Bundle/" + from.getBundleId());
record.setLinkText(from.getBundleName());
-
record.setAttribute("description", from.getBundleDescription());
record.setAttribute("latestVersion", from.getLatestVersion());
record.setAttribute("versionsCount", Integer.valueOf(from.getVersionsCount().intValue())); // want int, not long
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
index f1661c8..16e5e67 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
@@ -24,6 +24,7 @@ package org.rhq.enterprise.gui.coregui.client.bundle.tree;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
@@ -50,25 +51,34 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
+@SuppressWarnings("unchecked")
public class BundleTreeDataSource extends RPCDataSource {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundleTreeDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceField idDataField = new DataSourceTextField("id", "ID");
idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
DataSourceTextField nameDataField = new DataSourceTextField("name", "Name");
nameDataField.setCanEdit(false);
-
- DataSourceTextField descriptionDataField = new DataSourceTextField("description", "Description");
- descriptionDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField parentIdField = new DataSourceTextField("parentId", "Parent ID");
parentIdField.setForeignKey("id");
+ fields.add(parentIdField);
-
- setFields(idDataField, nameDataField, parentIdField);
+ return fields;
}
@Override
@@ -97,8 +107,8 @@ public class BundleTreeDataSource extends RPCDataSource {
}
});
} else {
- if (p.endsWith(":versions")) {
- int bundleId = Integer.parseInt(p.substring(0, p.indexOf(":")));
+ if (p.endsWith("_versions")) {
+ int bundleId = Integer.parseInt(p.substring(0, p.indexOf("_")));
BundleVersionCriteria criteria = new BundleVersionCriteria();
criteria.addFilterBundleId(bundleId);
bundleService.findBundleVersionsByCriteria(criteria, new AsyncCallback<PageList<BundleVersion>>() {
@@ -114,46 +124,47 @@ public class BundleTreeDataSource extends RPCDataSource {
processResponse(request.getRequestId(), response);
}
});
- } else if (p.endsWith(":deployments")) {
- int bundleId = Integer.parseInt(p.substring(0, p.indexOf(":")));
+ } else if (p.endsWith("_deployments")) {
+ int bundleId = Integer.parseInt(p.substring(0, p.indexOf("_")));
BundleDeploymentCriteria criteria = new BundleDeploymentCriteria();
criteria.fetchBundleVersion(true);
criteria.addFilterBundleId(bundleId);
- bundleService.findBundleDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleDeployment>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle", caught);
- }
-
- public void onSuccess(PageList<BundleDeployment> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
- } else if (p.endsWith(":destinations")) {
- int bundleId = Integer.parseInt(p.substring(0, p.indexOf(":")));
+ bundleService.findBundleDeploymentsByCriteria(criteria,
+ new AsyncCallback<PageList<BundleDeployment>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load bundle", caught);
+ }
+
+ public void onSuccess(PageList<BundleDeployment> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ } else if (p.endsWith("_destinations")) {
+ int bundleId = Integer.parseInt(p.substring(0, p.indexOf("_")));
BundleDestinationCriteria criteria = new BundleDestinationCriteria();
criteria.addFilterBundleId(bundleId);
- bundleService.findBundleDestinationsByCriteria(criteria, new AsyncCallback<PageList<BundleDestination>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load bundle destinations", caught);
- }
-
- public void onSuccess(PageList<BundleDestination> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ bundleService.findBundleDestinationsByCriteria(criteria,
+ new AsyncCallback<PageList<BundleDestination>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load bundle destinations", caught);
+ }
+
+ public void onSuccess(PageList<BundleDestination> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
}
-
}
@Override
public Object copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
@@ -171,14 +182,14 @@ public class BundleTreeDataSource extends RPCDataSource {
Bundle bundle = (Bundle) item;
TreeNode versionNode = new TreeNode("Versions");
- versionNode.setID(bundle.getId() + ":versions");
+ versionNode.setID(bundle.getId() + "_versions");
versionNode.setParentID(String.valueOf(bundle.getId()));
versionNode.setName("Versions");
versionNode.setAttribute("name", "Versions");
records.add(versionNode);
TreeNode deploymentsNode = new TreeNode("Destinations");
- deploymentsNode.setID(bundle.getId() + ":destinations");
+ deploymentsNode.setID(bundle.getId() + "_destinations");
deploymentsNode.setParentID(String.valueOf(bundle.getId()));
deploymentsNode.setName("Destinations");
records.add(deploymentsNode);
@@ -187,7 +198,6 @@ public class BundleTreeDataSource extends RPCDataSource {
return records.toArray(new ListGridRecord[records.size()]);
}
-
@Override
public ListGridRecord copyValues(Object from) {
TreeNode node = new TreeNode();
@@ -200,23 +210,23 @@ public class BundleTreeDataSource extends RPCDataSource {
} else if (from instanceof BundleVersion) {
BundleVersion version = (BundleVersion) from;
node.setName(version.getVersion());
- node.setID(version.getBundle().getId() + ":versions:" + version.getId());
- node.setParentID(version.getBundle().getId() + ":versions");
+ node.setID(version.getBundle().getId() + "_versions_" + version.getId());
+ node.setParentID(version.getBundle().getId() + "_versions");
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleVersion_16.png");
} else if (from instanceof BundleDeployment) {
BundleDeployment deployment = (BundleDeployment) from;
node.setName(deployment.getName() + " (" + deployment.getBundleVersion().getVersion() + ")");
- node.setID(deployment.getBundleVersion().getBundle().getId() + ":deployments:" + deployment.getId());
- node.setParentID(deployment.getBundleVersion().getBundle().getId() + ":deployments");
+ node.setID(deployment.getBundleVersion().getBundle().getId() + "_deployments_" + deployment.getId());
+ node.setParentID(deployment.getBundleVersion().getBundle().getId() + "_deployments");
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleDeployment_16.png");
} else if (from instanceof BundleDestination) {
BundleDestination destination = (BundleDestination) from;
node.setName(destination.getName());
- node.setID(destination.getBundle().getId() + ":destinations:" +destination.getId());
- node.setParentID(destination.getBundle().getId() + ":destinations");
+ node.setID(destination.getBundle().getId() + "_destinations_" + destination.getId());
+ node.setParentID(destination.getBundle().getId() + "_destinations");
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleDestination_16.png");
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index b4aff2b..7e2604e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -23,7 +23,9 @@ import java.util.List;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Autofit;
+import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.types.VerticalAlignment;
@@ -47,6 +49,7 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
@@ -484,6 +487,33 @@ public class Table extends LocatableHLayout implements RefreshableView {
return listGrid;
}
+ /**
+ * Wraps ListGrid.setFields(...) but takes care of "id" field display handling
+ * @param fields
+ */
+ public void setListGridFields(ListGridField... fields) {
+ if (null == this.dataSource.getField("id")) {
+ return;
+ }
+
+ if (CoreGUI.isDebugMode()) {
+ ListGridField idField = new ListGridField("id", "Id", 55);
+ idField.setType(ListGridFieldType.INTEGER);
+ idField.setCanEdit(false);
+ idField.setAlign(Alignment.LEFT);
+
+ ListGridField[] newFields = new ListGridField[fields.length + 1];
+ newFields[0] = idField;
+ for (int i = 0; i < fields.length; ++i) {
+ newFields[i + 1] = fields[i];
+ }
+ this.listGrid.setFields(newFields);
+ } else {
+ getListGrid().hideField("id");
+ this.listGrid.setFields(fields);
+ }
+ }
+
public void setTitleComponent(Canvas canvas) {
this.titleComponent = canvas;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
index 1d3f08d..a971a97 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
@@ -47,38 +47,37 @@ public class TaggingDataSource extends RPCDataSource<Tag> {
String search = (String) request.getCriteria().getValues().get("tag");
if (search != null) {
// todo
-// criteria.addFilter
+ // criteria.addFilter
}
- GWTServiceLookup.getTagService().findTagsByCriteria(new TagCriteria(),
- new AsyncCallback<PageList<Tag>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load tags",caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
+ GWTServiceLookup.getTagService().findTagsByCriteria(new TagCriteria(), new AsyncCallback<PageList<Tag>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load tags", caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
- public void onSuccess(PageList<Tag> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ public void onSuccess(PageList<Tag> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
@Override
public Tag copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
public ListGridRecord copyValues(Tag from) {
ListGridRecord record = new ListGridRecord();
- record.setAttribute("id",from.getId());
- record.setAttribute("namespace",from.getNamespace());
- record.setAttribute("semantic",from.getSemantic());
- record.setAttribute("name",from.getName());
- record.setAttribute("tag",from.toString());
+ record.setAttribute("id", from.getId());
+ record.setAttribute("namespace", from.getNamespace());
+ record.setAttribute("semantic", from.getSemantic());
+ record.setAttribute("name", from.getName());
+ record.setAttribute("tag", from.toString());
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
index f4b69ae..a2b8b37 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -28,11 +28,9 @@ import org.rhq.core.domain.util.StringUtils;
public class EnhancedTreeNode extends TreeNode {
public EnhancedTreeNode() {
super();
- // this(null);
}
public EnhancedTreeNode(String name) {
- //this(name, new TreeNode[0]);
super(name);
if (name != null) {
setTitle(StringUtils.deCamelCase(name));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
index 9b54565..9490647 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
@@ -22,6 +22,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.content.repository.tree;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -30,52 +32,54 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.tree.TreeNode;
-import org.rhq.core.domain.criteria.Criteria;
+import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.RepoGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import org.rhq.core.domain.content.Repo;
/**
* @author Greg Hinkle
*/
-public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
+public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
private RepoGWTServiceAsync repoService = GWTServiceLookup.getRepoService();
-
-
public ContentRepositoryTreeDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idDataField = new DataSourceTextField("id", "ID");
idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
DataSourceTextField nameDataField = new DataSourceTextField("name", "Name");
nameDataField.setCanEdit(false);
-
- DataSourceTextField descriptionDataField = new DataSourceTextField("description", "Description");
- descriptionDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField parentIdField = new DataSourceTextField("parentId", "Parent ID");
parentIdField.setForeignKey("id");
+ fields.add(parentIdField);
- setFields(idDataField, nameDataField, parentIdField);
+ return fields;
}
-
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
-
RepoCriteria criteria = new RepoCriteria();
-
repoService.findReposByCriteria(criteria, new AsyncCallback<PageList<Repo>>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load repositories",caught);
+ CoreGUI.getErrorHandler().handleError("Failed to load repositories", caught);
}
public void onSuccess(PageList<Repo> result) {
@@ -88,7 +92,7 @@ public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
@Override
public Repo copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
index 7f9d8fd..b0f94c3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
@@ -18,9 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform;
+import java.util.List;
+
import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.fields.DataSourceImageField;
-import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -38,15 +38,24 @@ public class PlatformMetricDataSource extends ResourceDatasource {
super();
this.view = view;
- DataSourceTextField cpuField = new DataSourceTextField("cpu","CPU");
- addField(cpuField);
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceTextField cpuField = new DataSourceTextField("cpu", "CPU");
+ fields.add(cpuField);
DataSourceTextField memoryField = new DataSourceTextField("memory", "Memory");
- addField(memoryField);
+ fields.add(memoryField);
+
DataSourceTextField swapField = new DataSourceTextField("swap", "Swap");
// todo swap
- }
-
+ return fields;
+ }
@Override
public ListGridRecord copyValues(Resource from) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
index b30714f..874d92d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
@@ -18,14 +18,19 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common;
+import java.util.List;
+import java.util.Map;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.fields.*;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
+import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.util.PageList;
@@ -34,10 +39,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
/**
* A server-side SmartGWT DataSource for reading {@link MeasurementDataTrait trait data}.
*
@@ -48,12 +49,13 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
protected AbstractMeasurementDataTraitDataSource() {
setCanMultiSort(true);
- List<DataSourceField> fields = createFields();
+ List<DataSourceField> fields = addDataSourceFields();
addFields(fields);
}
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = new ArrayList<DataSourceField>();
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceTextField primaryKeyField = new DataSourceTextField("primaryKey", "Primary Key");
primaryKeyField.setPrimaryKey(true);
@@ -65,17 +67,16 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME,
- "Trait");
+ "Trait");
fields.add(nameField);
// TODO: Include description from metric def?
- DataSourceTextField valueField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_VALUE,
- "Value");
+ DataSourceTextField valueField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_VALUE, "Value");
fields.add(valueField);
- DataSourceIntegerField timestampField = new DataSourceIntegerField(MeasurementDataTraitCriteria.SORT_FIELD_TIMESTAMP,
- "Last Changed");
+ DataSourceIntegerField timestampField = new DataSourceIntegerField(
+ MeasurementDataTraitCriteria.SORT_FIELD_TIMESTAMP, "Last Changed");
fields.add(timestampField);
return fields;
@@ -88,8 +89,7 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
this.measurementService.findTraitsByCriteria(criteria, new AsyncCallback<PageList<MeasurementDataTrait>>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to fetch traits for criteria " + criteria,
- caught);
+ CoreGUI.getErrorHandler().handleError("Failed to fetch traits for criteria " + criteria, caught);
response.setStatus(RPCResponse.STATUS_FAILURE);
processResponse(request.getRequestId(), response);
}
@@ -145,9 +145,10 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
record.setAttribute("primaryKey", from.getScheduleId() + ":" + from.getTimestamp());
record.setAttribute("id", from.getSchedule().getDefinition().getId()); // used for detail view
record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_TIMESTAMP, from.getTimestamp());
- record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME, from.getSchedule().getDefinition().getDisplayName());
+ record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME, from.getSchedule().getDefinition()
+ .getDisplayName());
record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_VALUE, from.getValue());
-
+
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
index 7782c87..1f7da77 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
@@ -49,7 +49,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*
* @author Ian Springer
*/
-public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPCDataSource<MeasurementScheduleComposite> {
+public abstract class AbstractMeasurementScheduleCompositeDataSource extends
+ RPCDataSource<MeasurementScheduleComposite> {
private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService();
protected AbstractMeasurementScheduleCompositeDataSource() {
@@ -57,37 +58,38 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
setCanMultiSort(true);
- List<DataSourceField> fields = createFields();
+ List<DataSourceField> fields = addDataSourceFields();
addFields(fields);
}
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = new ArrayList<DataSourceField>();
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceIntegerField idField = new DataSourceIntegerField(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID,
- "Id");
+ DataSourceIntegerField idField = new DataSourceIntegerField(
+ MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID, "Id");
idField.setPrimaryKey(true);
idField.setHidden(true);
fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME,
- "Metric");
+ "Metric");
fields.add(nameField);
- DataSourceTextField descriptionField = new DataSourceTextField(MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION,
- "Description");
+ DataSourceTextField descriptionField = new DataSourceTextField(
+ MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION, "Description");
fields.add(descriptionField);
DataSourceTextField typeField = new DataSourceTextField(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE,
- "Type");
+ "Type");
fields.add(typeField);
- DataSourceBooleanField enabledField = new DataSourceBooleanField(MeasurementScheduleCriteria.SORT_FIELD_ENABLED,
- "Enabled?");
+ DataSourceBooleanField enabledField = new DataSourceBooleanField(
+ MeasurementScheduleCriteria.SORT_FIELD_ENABLED, "Enabled?");
fields.add(enabledField);
- DataSourceIntegerField intervalField = new DataSourceIntegerField(MeasurementScheduleCriteria.SORT_FIELD_INTERVAL,
- "Collection Interval");
+ DataSourceIntegerField intervalField = new DataSourceIntegerField(
+ MeasurementScheduleCriteria.SORT_FIELD_INTERVAL, "Collection Interval");
fields.add(intervalField);
return fields;
@@ -96,21 +98,22 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
protected void executeFetch(final DSRequest request, final DSResponse response) {
final EntityContext entityContext = getEntityContext(request);
- this.measurementService.getMeasurementScheduleCompositesByContext(entityContext, new AsyncCallback<PageList<MeasurementScheduleComposite>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to fetch measurement schedules for context " + entityContext,
- caught);
- response.setStatus(RPCResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
+ this.measurementService.getMeasurementScheduleCompositesByContext(entityContext,
+ new AsyncCallback<PageList<MeasurementScheduleComposite>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to fetch measurement schedules for context " + entityContext, caught);
+ response.setStatus(RPCResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
- public void onSuccess(PageList<MeasurementScheduleComposite> result) {
- response.setData(buildRecords(result));
- // For paging to work, we have to specify size of full result set.
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
+ public void onSuccess(PageList<MeasurementScheduleComposite> result) {
+ response.setData(buildRecords(result));
+ // For paging to work, we have to specify size of full result set.
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
protected EntityContext getEntityContext(DSRequest request) {
@@ -150,15 +153,16 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
MeasurementDefinition measurementDefinition = from.getMeasurementDefinition();
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID, measurementDefinition.getId());
- record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME, measurementDefinition.getDisplayName());
+ record
+ .setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME, measurementDefinition.getDisplayName());
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION, measurementDefinition.getDescription());
- record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE,
- measurementDefinition.getDataType().name().toLowerCase());
+ record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE, measurementDefinition.getDataType()
+ .name().toLowerCase());
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_ENABLED, from.getCollectionEnabled());
record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_INTERVAL, from.getCollectionInterval());
// TODO: resourceId and resourceGroupId (in subclasses)
-
+
return record;
}
@@ -170,7 +174,7 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
}
protected abstract void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames);
+ int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames);
public void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView) {
int[] ids = getMeasurementDefinitionIds(measurementScheduleListView);
@@ -180,7 +184,7 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
}
protected abstract void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames);
+ int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames);
public void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, long interval) {
int[] ids = getMeasurementDefinitionIds(measurementScheduleListView);
@@ -196,13 +200,15 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
int[] measurementDefinitionIds = new int[records.length];
for (int i = 0, selectionLength = records.length; i < selectionLength; i++) {
ListGridRecord record = records[i];
- Integer measurementDefinitionId = record.getAttributeAsInt(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID);
+ Integer measurementDefinitionId = record
+ .getAttributeAsInt(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID);
measurementDefinitionIds[i] = measurementDefinitionId;
}
return measurementDefinitionIds;
}
- private List<String> getMeasurementDefinitionDisplayNames(AbstractMeasurementScheduleListView measurementScheduleListView) {
+ private List<String> getMeasurementDefinitionDisplayNames(
+ AbstractMeasurementScheduleListView measurementScheduleListView) {
ListGrid listGrid = measurementScheduleListView.getListGrid();
ListGridRecord[] records = listGrid.getSelection();
List<String> displayNames = new ArrayList<String>(records.length);
@@ -214,5 +220,5 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends RPC
}
protected abstract void updateSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
- final int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames, final long interval);
+ final int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames, final long interval);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
index 40dc105..03d6575 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
@@ -22,11 +22,14 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.event;
+import java.util.List;
import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.types.FieldType;
@@ -54,23 +57,32 @@ public class EventCompositeDatasource extends RPCDataSource<EventComposite> {
public EventCompositeDatasource(EntityContext context) {
super();
this.entityContext = context;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- // DataSourceField id = new DataSourceIntegerField("id", "Id");
- // id.setPrimaryKey(true);
- // addField(id);
+ DataSourceField id = new DataSourceIntegerField("id", "Id");
+ id.setPrimaryKey(true);
+ fields.add(id);
DataSourceTextField timestamp = new DataSourceTextField("timestamp", "Timestamp");
timestamp.setType(FieldType.DATETIME);
- addField(timestamp);
+ fields.add(timestamp);
DataSourceTextField severity = new DataSourceTextField("severity", "Severity");
- addField(severity);
+ fields.add(severity);
DataSourceTextField details = new HighlightingDatasourceTextField("details", "Details");
- addField(details);
+ fields.add(details);
DataSourceTextField sourceLocation = new DataSourceTextField("source", "Source Location");
- addField(sourceLocation);
+ fields.add(sourceLocation);
+
+ return fields;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index 4bdfdd4..4ddfa54 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -120,7 +120,7 @@ public class EventCompositeHistoryView extends TableSection {
}
});
- grid.setFields(timestampField, severityField, detailsField, sourceField);
+ setListGridFields(timestampField, severityField, detailsField, sourceField);
/*
grid.getField("timestamp").setWidth(125);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
index 0da1963..6fd1d01 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
@@ -21,9 +21,12 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups;
import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.CATEGORY;
import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.NAME;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -57,18 +60,32 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
public ResourceGroupCompositeDataSource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceTextField nameDataField = new DataSourceTextField("name", "Name", 200);
nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField descriptionDataField = new DataSourceTextField("description", "Description");
descriptionDataField.setCanEdit(false);
+ fields.add(descriptionDataField);
DataSourceTextField typeNameDataField = new DataSourceTextField("typeName", "Type");
+ fields.add(typeNameDataField);
+
DataSourceTextField pluginNameDataField = new DataSourceTextField("pluginName", "Plugin");
+ fields.add(pluginNameDataField);
+
DataSourceTextField categoryDataField = new DataSourceTextField("category", "Category");
+ fields.add(categoryDataField);
- setFields(nameDataField, descriptionDataField, typeNameDataField, pluginNameDataField, categoryDataField);
+ return fields;
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
index 2a02c99..190baf7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
@@ -21,6 +21,8 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups;
import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.CATEGORY;
import static org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField.NAME;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -58,22 +60,36 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
public ResourceGroupsDataSource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 20);
idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
DataSourceTextField nameDataField = new DataSourceTextField("name", "Name", 200);
nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField descriptionDataField = new DataSourceTextField("description", "Description");
descriptionDataField.setCanEdit(false);
+ fields.add(descriptionDataField);
DataSourceTextField typeNameDataField = new DataSourceTextField("typeName", "Type");
+ fields.add(typeNameDataField);
+
DataSourceTextField pluginNameDataField = new DataSourceTextField("pluginName", "Plugin");
+ fields.add(pluginNameDataField);
+
DataSourceTextField categoryDataField = new DataSourceTextField("category", "Category");
+ fields.add(categoryDataField);
- setFields(idDataField, nameDataField, descriptionDataField, typeNameDataField, pluginNameDataField,
- categoryDataField);
+ return fields;
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
index f4da478..e9824e9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import com.google.gwt.core.client.JavaScriptObject;
@@ -59,31 +60,39 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
private GroupDefinitionDataSource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceField idField = new DataSourceIntegerField("id", "ID");
idField.setPrimaryKey(true);
idField.setCanEdit(false);
+ fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField("name", "Name");
nameField.setRequired(true);
+ fields.add(nameField);
DataSourceTextField descriptionField = new DataSourceTextField("description", "Description");
+ fields.add(descriptionField);
DataSourceTextField expressionField = new DataSourceTextField("expression", "Expression Set");
expressionField.setRequired(true);
+ fields.add(expressionField);
DataSourceIntegerField lastCalculationTimeIntervalField = new DataSourceIntegerField("lastCalculationTime",
"Recalculation Interval");
+ fields.add(lastCalculationTimeIntervalField);
DataSourceIntegerField nextCalculationTimeField = new DataSourceIntegerField("nextCalculationTime",
"Next Calculation Time");
+ fields.add(nextCalculationTimeField);
- addField(idField);
- addField(nameField);
- addField(descriptionField);
- addField(expressionField);
- addField(lastCalculationTimeIntervalField);
- addField(nextCalculationTimeField);
+ return fields;
}
@Override
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 481354b..fc08133 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
@@ -59,8 +59,8 @@ import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
-import org.rhq.enterprise.gui.coregui.client.util.TreeUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
@@ -270,7 +270,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
ClusterKey rootKey = new ClusterKey(root.getGroupId());
loadTree(rootNode, root, rootKey);
-
+
Tree tree = new Tree();
tree.setRoot(fakeRoot);
@@ -347,26 +347,27 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
}
if (lastSubcategoryNode != null) {
- List<TreeNode> currentSubcategoryChildren = subCategoryChildrenByName.get(currentSubcategoryNode.getName());
+ List<TreeNode> currentSubcategoryChildren = subCategoryChildrenByName
+ .get(currentSubcategoryNode.getName());
currentSubcategoryChildren.add(lastSubcategoryNode);
}
lastSubcategoryNode = currentSubcategoryNode;
- } while (currentSubcategoryNodeCreated &&
- (currentSubCategory = currentSubCategory.getParentSubCategory()) != null);
+ } while (currentSubcategoryNodeCreated
+ && (currentSubCategory = currentSubCategory.getParentSubCategory()) != null);
List<TreeNode> subcategoryChildren = subCategoryChildrenByName.get(subcategory.getName());
subcategoryChildren.addAll(nodesByType);
- } else {
+ } else {
childNodes.addAll(nodesByType);
}
}
-
+
for (String subcategoryName : subCategoryNodesByName.keySet()) {
TreeNode subcategoryNode = subCategoryNodesByName.get(subcategoryName);
List<TreeNode> subcategoryChildren = subCategoryChildrenByName.get(subcategoryName);
subcategoryNode.setChildren(subcategoryChildren.toArray(new TreeNode[subcategoryChildren.size()]));
}
-
+
parentNode.setChildren(childNodes.toArray(new TreeNode[childNodes.size()]));
}
}
@@ -377,7 +378,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
ClusterKeyFlyweight keyFlyweight = child.getClusterKey();
ClusterKey key = new ClusterKey(parentKey, keyFlyweight.getResourceTypeId(), keyFlyweight.getResourceKey());
String id = key.getKey();
- node.setID(id);
+ node.setID(SeleniumUtility.getSafeId(id));
node.setAttribute("key", key);
node.setAttribute("resourceType", type);
node.setIsFolder(!child.getChildren().isEmpty());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
index 158448b..79a9b2a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
@@ -36,8 +38,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasuremen
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import java.util.List;
-
/**
* A DataSource for reading and updating the metric schedules for the current group.
*
@@ -52,12 +52,14 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
}
@Override
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = super.createFields();
- DataSourceField resourceGroupIdField = new DataSourceIntegerField(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID,
- "Resource Group Id");
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceField resourceGroupIdField = new DataSourceIntegerField(
+ MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID, "Resource Group Id");
resourceGroupIdField.setHidden(true);
fields.add(resourceGroupIdField);
+
return fields;
}
@@ -83,73 +85,76 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
@Override
protected void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
this.measurementService.enableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to enable collection of metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Enabled collection of selected metric" + s + ".",
- "Enabled collection of metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId +
- "].", Message.Severity.Info));
-
- }
- });
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to enable collection of metric" + s + " " + measurementDefinitionDisplayNames
+ + " for Resource group with id [" + resourceGroupId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Enabled collection of selected metric" + s + ".", "Enabled collection of metric"
+ + s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
+ + resourceGroupId + "].", Message.Severity.Info));
+
+ }
+ });
}
@Override
- protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
this.measurementService.disableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to disable collection of metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Disabled collection of selected metric" + s + ".",
- "Disabled collection of metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId +
- "].", Message.Severity.Info));
-
- }
- });
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to disable collection of metric" + s + " " + measurementDefinitionDisplayNames
+ + " for Resource group with id [" + resourceGroupId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Disabled collection of selected metric" + s + ".", "Disabled collection of metric"
+ + s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
+ + resourceGroupId + "].", Message.Severity.Info));
+
+ }
+ });
}
@Override
protected void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames, final long collectionInterval) {
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames,
+ final long collectionInterval) {
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
- this.measurementService.updateSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds, collectionInterval,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to set collection interval to " + (collectionInterval / 1000)
- + " seconds for metric" + s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
- + resourceGroupId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Updated collection intervals of selected metric" + s + ".",
- "Collection interval for metric" + s + " "
- + measurementDefinitionDisplayNames + " for Resource group with id [" + resourceGroupId +
- "] set to " + (collectionInterval / 1000) + " seconds.", Message.Severity.Info));
-
- }
- });
+ this.measurementService.updateSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds,
+ collectionInterval, new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to set collection interval to " + (collectionInterval / 1000) + " seconds for metric"
+ + s + " " + measurementDefinitionDisplayNames + " for Resource group with id ["
+ + resourceGroupId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Updated collection intervals of selected metric" + s + ".",
+ "Collection interval for metric" + s + " " + measurementDefinitionDisplayNames
+ + " for Resource group with id [" + resourceGroupId + "] set to "
+ + (collectionInterval / 1000) + " seconds.", Message.Severity.Info));
+
+ }
+ });
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
index 4be1f22..3321237 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
@@ -18,16 +18,17 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits;
+import java.util.List;
+
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitDataSource;
-import java.util.List;
-
/**
* A DataSource for reading traits for the current group.
*
@@ -41,16 +42,16 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
}
@Override
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = super.createFields();
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceIntegerField groupIdField =
- new DataSourceIntegerField(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, "Group Id");
+ DataSourceIntegerField groupIdField = new DataSourceIntegerField(
+ MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, "Group Id");
groupIdField.setHidden(true);
fields.add(0, groupIdField);
- DataSourceTextField resourceNameField =
- new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, "Member Resource");
+ DataSourceTextField resourceNameField = new DataSourceTextField(
+ MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, "Member Resource");
fields.add(0, resourceNameField);
return fields;
@@ -62,8 +63,8 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, this.groupId);
- record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME,
- from.getSchedule().getResource().getName());
+ record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, from.getSchedule().getResource()
+ .getName());
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
index 766df27..2b3a4c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
@@ -25,6 +25,8 @@ import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceD
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -54,31 +56,53 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
public ResourceDatasource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 20);
+ DataSourceField idDataField = new DataSourceIntegerField("id", "ID", 50);
idDataField.setPrimaryKey(true);
+ idDataField.setCanEdit(false);
+ fields.add(idDataField);
DataSourceImageField iconField = new DataSourceImageField("icon", "");
iconField.setImageURLPrefix("types/");
+ fields.add(iconField);
DataSourceTextField nameDataField = new DataSourceTextField(NAME.propertyName(), NAME.title(), 200);
nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
DataSourceTextField descriptionDataField = new DataSourceTextField(DESCRIPTION.propertyName(), DESCRIPTION
.title());
descriptionDataField.setCanEdit(false);
+ fields.add(descriptionDataField);
DataSourceTextField typeNameDataField = new DataSourceTextField(TYPE.propertyName(), TYPE.title());
+ fields.add(typeNameDataField);
+
DataSourceTextField pluginNameDataField = new DataSourceTextField(PLUGIN.propertyName(), PLUGIN.title());
+ fields.add(pluginNameDataField);
+
DataSourceTextField categoryDataField = new DataSourceTextField(CATEGORY.propertyName(), CATEGORY.title());
+ fields.add(categoryDataField);
DataSourceImageField availabilityDataField = new DataSourceImageField(AVAILABILITY.propertyName(), AVAILABILITY
.title(), 20);
-
availabilityDataField.setCanEdit(false);
+ fields.add(availabilityDataField);
+
+ return fields;
+ }
+
+ @Override
+ public void useDatasourceDefinedFields() {
+ // TODO Auto-generated method stub
- setFields(idDataField, iconField, nameDataField, descriptionDataField, typeNameDataField, pluginNameDataField,
- categoryDataField, availabilityDataField);
}
public void executeFetch(final DSRequest request, final DSResponse response) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 15bf220..82595af 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -18,13 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
-
import java.util.ArrayList;
import java.util.List;
@@ -96,18 +89,18 @@ public class ResourceSearchView extends Table {
// searchPanel.setFields(searchBox);
final ResourceDatasource datasource = new ResourceDatasource();
- // setTitleComponent(searchPanel);
setDataSource(datasource);
-
}
@Override
protected void configureTable() {
- ListGridField idField = new ListGridField("id", "Id", 55);
- idField.setType(ListGridFieldType.INTEGER);
- //idField.setHidden(true);
- ListGridField iconField = new ListGridField("icon", "", 40);
- ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
+
+ ListGridField iconField = new ListGridField("icon", "Icon", 40);
+ iconField.setType(ListGridFieldType.IMAGE);
+ iconField.setImageURLPrefix("types/");
+
+ ListGridField nameField = new ListGridField(ResourceDataSourceField.NAME.propertyName(),
+ ResourceDataSourceField.NAME.title(), 250);
nameField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
return "<a href=\"" + LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("id")) + "\">" + o
@@ -115,15 +108,25 @@ public class ResourceSearchView extends Table {
}
});
- ListGridField descriptionField = new ListGridField(DESCRIPTION.propertyName(), DESCRIPTION.title());
- ListGridField typeNameField = new ListGridField(TYPE.propertyName(), TYPE.title(), 130);
- ListGridField pluginNameField = new ListGridField(PLUGIN.propertyName(), PLUGIN.title(), 100);
- ListGridField categoryField = new ListGridField(CATEGORY.propertyName(), CATEGORY.title(), 60);
+ ListGridField descriptionField = new ListGridField(ResourceDataSourceField.DESCRIPTION.propertyName(),
+ ResourceDataSourceField.DESCRIPTION.title());
- ListGridField availabilityField = new ListGridField(AVAILABILITY.propertyName(), AVAILABILITY.title(), 55);
+ ListGridField typeNameField = new ListGridField(ResourceDataSourceField.TYPE.propertyName(),
+ ResourceDataSourceField.TYPE.title(), 130);
+
+ ListGridField pluginNameField = new ListGridField(ResourceDataSourceField.PLUGIN.propertyName(),
+ ResourceDataSourceField.PLUGIN.title(), 100);
+
+ ListGridField categoryField = new ListGridField(ResourceDataSourceField.CATEGORY.propertyName(),
+ ResourceDataSourceField.CATEGORY.title(), 60);
+
+ ListGridField availabilityField = new ListGridField(ResourceDataSourceField.AVAILABILITY.propertyName(),
+ ResourceDataSourceField.AVAILABILITY.title(), 55);
+ availabilityField.setType(ListGridFieldType.IMAGE);
availabilityField.setAlign(Alignment.CENTER);
- getListGrid().setFields(idField, iconField, nameField, descriptionField, typeNameField, pluginNameField,
- categoryField, availabilityField);
+
+ setListGridFields(iconField, nameField, descriptionField, typeNameField, pluginNameField, categoryField,
+ availabilityField);
addTableAction(extendLocatorId("Uninventory"), "Uninventory", Table.SelectionEnablement.ANY,
"Are you sure you want to uninventory # resources?", new TableAction() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
index f8387c9..e777bc9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
@@ -19,10 +19,12 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.FieldType;
@@ -45,25 +47,32 @@ public class ConfigurationHistoryDataSource extends RPCDataSource<ResourceConfig
public ConfigurationHistoryDataSource() {
super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField resourceField = new DataSourceTextField("resource", "Resource");
- addField(resourceField);
+ fields.add(resourceField);
DataSourceTextField submittedField = new DataSourceTextField("createdTime", "Created");
submittedField.setType(FieldType.DATETIME);
- addField(submittedField);
+ fields.add(submittedField);
DataSourceTextField statusField = new DataSourceTextField("status", "Status");
- addField(statusField);
+ fields.add(statusField);
DataSourceTextField subjectField = new DataSourceTextField("subject", "Subject");
- addField(subjectField);
-
+ fields.add(subjectField);
+ return fields;
}
@Override
@@ -75,31 +84,30 @@ public class ConfigurationHistoryDataSource extends RPCDataSource<ResourceConfig
criteria.setPageControl(getPageControl(request));
- Integer resourceId = (Integer)request.getCriteria().getValues().get("resourceId");
+ Integer resourceId = (Integer) request.getCriteria().getValues().get("resourceId");
if (resourceId != null) {
criteria.addFilterResourceIds(resourceId);
}
configurationService.findResourceConfigurationUpdatesByCriteria(criteria,
- new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Unable to load configuration history", caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
+ new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Unable to load configuration history", caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
-
@Override
public ResourceConfigurationUpdate copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
index f412d7b..0361f65 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
@@ -22,12 +22,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring;
-import java.util.Collection;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -40,7 +40,6 @@ import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
@@ -48,54 +47,58 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*/
public class ResourceScheduledMetricDatasource extends RPCDataSource<MeasurementDefinition> {
-
public ResourceScheduledMetricDatasource() {
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField id = new DataSourceIntegerField("id");
id.setPrimaryKey(true);
- addField(id);
+ fields.add(id);
DataSourceTextField name = new DataSourceTextField("name");
- addField(name);
+ fields.add(name);
DataSourceTextField displayName = new DataSourceTextField("displayName");
- addField(displayName);
+ fields.add(displayName);
DataSourceTextField description = new DataSourceTextField("description");
- addField(description);
+ fields.add(description);
DataSourceTextField units = new DataSourceTextField("units");
- addField(units);
+ fields.add(units);
DataSourceTextField numericType = new DataSourceTextField("numericType");
- addField(numericType);
+ fields.add(numericType);
DataSourceTextField category = new DataSourceTextField("category");
- addField(category);
+ fields.add(category);
+
+ return fields;
}
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
-
-
-
if (request.getCriteria().getValues().containsKey("id")) {
MeasurementDefinitionCriteria criteria = new MeasurementDefinitionCriteria();
criteria.addFilterId(request.getCriteria().getAttributeAsInt("id"));
GWTServiceLookup.getMeasurementDataService().findMeasurementDefinitionsByCriteria(criteria,
- new AsyncCallback<PageList<MeasurementDefinition>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load metric definitions",caught);
- }
-
- public void onSuccess(PageList<MeasurementDefinition> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ new AsyncCallback<PageList<MeasurementDefinition>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load metric definitions", caught);
+ }
+ public void onSuccess(PageList<MeasurementDefinition> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
} else if (request.getCriteria().getValues().containsKey("resourceId")) {
MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
@@ -103,17 +106,17 @@ public class ResourceScheduledMetricDatasource extends RPCDataSource<Measurement
criteria.addFilterResourceId(request.getCriteria().getAttributeAsInt("resourceId"));
-
- GWTServiceLookup.getMeasurementDataService().findMeasurementSchedulesByCriteria(criteria, new AsyncCallback<PageList<MeasurementSchedule>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load metric schedules", caught);
- }
-
- public void onSuccess(PageList<MeasurementSchedule> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ GWTServiceLookup.getMeasurementDataService().findMeasurementSchedulesByCriteria(criteria,
+ new AsyncCallback<PageList<MeasurementSchedule>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load metric schedules", caught);
+ }
+
+ public void onSuccess(PageList<MeasurementSchedule> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
} else {
processResponse(request.getRequestId(), response);
}
@@ -131,10 +134,9 @@ public class ResourceScheduledMetricDatasource extends RPCDataSource<Measurement
return buildRecords(definitions);
}
-
@Override
public MeasurementDefinition copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
+ return null; // TODO: Implement this method.
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
index 5efbcca..843e2af 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
@@ -18,9 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.calltime;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.HTMLFlow;
@@ -41,20 +44,28 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
private double maxMaximum;
public CallTimeDataSource() {
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceTextField callDestination = new DataSourceTextField("callDestination", "Call Destination");
- addField(callDestination);
+ fields.add(callDestination);
DataSourceIntegerField count = new DataSourceIntegerField("count");
- addField(count);
+ fields.add(count);
DataSourceIntegerField minimum = new DataSourceIntegerField("minimum");
- addField(minimum);
+ fields.add(minimum);
DataSourceIntegerField average = new DataSourceIntegerField("average");
- addField(average);
+ fields.add(average);
DataSourceIntegerField maximum = new DataSourceIntegerField("maximum");
- addField(maximum);
+ fields.add(maximum);
DataSourceIntegerField total = new DataSourceIntegerField("total");
- addField(total);
+ fields.add(total);
+ return fields;
}
@Override
@@ -66,21 +77,20 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
PageControl pc = getPageControl(request);
- GWTServiceLookup.getMeasurementDataService().findCallTimeDataForResource(
- scheduleId, eightHoursAgo, now, pc, new AsyncCallback<PageList<CallTimeDataComposite>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Could not load call time data", caught);
- }
+ GWTServiceLookup.getMeasurementDataService().findCallTimeDataForResource(scheduleId, eightHoursAgo, now, pc,
+ new AsyncCallback<PageList<CallTimeDataComposite>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Could not load call time data", caught);
+ }
- public void onSuccess(PageList<CallTimeDataComposite> result) {
- ListGridRecord[] data = buildRecords(result);
- setGraphs(data);
- response.setData(data);
+ public void onSuccess(PageList<CallTimeDataComposite> result) {
+ ListGridRecord[] data = buildRecords(result);
+ setGraphs(data);
+ response.setData(data);
- processResponse(request.getRequestId(), response);
- }
+ processResponse(request.getRequestId(), response);
}
- );
+ });
}
@Override
@@ -100,13 +110,10 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
int avgWidth = (int) ((record.getAttributeAsInt("average") / maxMaximum) * 100d);
int maxWidth = (int) ((record.getAttributeAsInt("maximum") / maxMaximum) * 100d);
-
-
- record.setBackgroundComponent(
- new HTMLFlow(
- "<div style=\"width: " + minWidth + "%; height: 33%; background-color: #A5B391;\"> </div>" +
- "<div style=\"width: " + avgWidth + "%; height: 33%; background-color: #A5B391;\"> </div>" +
- "<div style=\"width: " + maxWidth + "%; height: 33%; background-color: #A5B391;\"> </div>"));
+ record.setBackgroundComponent(new HTMLFlow("<div style=\"width: " + minWidth
+ + "%; height: 33%; background-color: #A5B391;\"> </div>" + "<div style=\"width: " + avgWidth
+ + "%; height: 33%; background-color: #A5B391;\"> </div>" + "<div style=\"width: " + maxWidth
+ + "%; height: 33%; background-color: #A5B391;\"> </div>"));
}
@@ -124,7 +131,6 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
record.setAttribute("maximum", from.getMaximum());
record.setAttribute("total", from.getTotal());
-
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java
index 21fe764..ac7c8dd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
@@ -35,8 +37,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasuremen
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import java.util.List;
-
/**
* A DataSource for reading and updating the metric schedules for the current Resource.
*
@@ -51,12 +51,14 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
}
@Override
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = super.createFields();
- DataSourceField resourceIdField = new DataSourceIntegerField(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_ID,
- "Resource Id");
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceField resourceIdField = new DataSourceIntegerField(
+ MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_ID, "Resource Id");
resourceIdField.setHidden(true);
fields.add(resourceIdField);
+
return fields;
}
@@ -76,67 +78,70 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
@Override
protected void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
- this.measurementService.enableSchedulesForResource(this.resourceId, measurementDefinitionIds,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to enable collection of metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Enabled collection of metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId +
- "].", Message.Severity.Info));
-
- }
- });
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ this.measurementService.enableSchedulesForResource(this.resourceId, measurementDefinitionIds,
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to enable collection of metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Enabled collection of metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "].", Message.Severity.Info));
+
+ }
+ });
}
@Override
- protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
- this.measurementService.disableSchedulesForResource(this.resourceId, measurementDefinitionIds,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to disable collection of metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId + "].",
- throwable);
- }
-
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Disabled collection of metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId +
- "].", Message.Severity.Info));
-
- }
- });
+ protected void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ this.measurementService.disableSchedulesForResource(this.resourceId, measurementDefinitionIds,
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to disable collection of metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "].", throwable);
+ }
+
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Disabled collection of metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "].", Message.Severity.Info));
+
+ }
+ });
}
@Override
protected void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView,
- int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames, final long collectionInterval) {
- this.measurementService.updateSchedulesForResource(this.resourceId, measurementDefinitionIds, collectionInterval,
- new AsyncCallback<Void>() {
- @Override
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to set collection interval to " + (collectionInterval / 1000)
- + " seconds for metrics " + measurementDefinitionDisplayNames + " for Resource with id ["
- + resourceId + "].",
+ int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames,
+ final long collectionInterval) {
+ this.measurementService.updateSchedulesForResource(this.resourceId, measurementDefinitionIds,
+ collectionInterval, new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to set collection interval to " + (collectionInterval / 1000) + " seconds for metrics "
+ + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId + "].",
throwable);
- }
+ }
- @Override
- public void onSuccess(Void aVoid) {
- CoreGUI.getMessageCenter().notify(new Message("Collection interval for metrics "
- + measurementDefinitionDisplayNames + " for Resource with id [" + resourceId +
- "] set to " + (collectionInterval / 1000) + " seconds.", Message.Severity.Info));
+ @Override
+ public void onSuccess(Void aVoid) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Collection interval for metrics " + measurementDefinitionDisplayNames
+ + " for Resource with id [" + resourceId + "] set to " + (collectionInterval / 1000)
+ + " seconds.", Message.Severity.Info));
- }
- });
+ }
+ });
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java
index c569260..67a330a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java
@@ -18,28 +18,29 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.traits;
-import com.smartgwt.client.data.DSRequest;
+import java.util.List;
+
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitDataSource;
-import java.util.List;
-
/**
* A DataSource for reading traits for the current Resource.
*
* @author Ian Springer
*/
public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
+
@Override
- protected List<DataSourceField> createFields() {
- List<DataSourceField> fields = super.createFields();
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceIntegerField resourceIdField =
- new DataSourceIntegerField(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, "Resource Id");
+ DataSourceIntegerField resourceIdField = new DataSourceIntegerField(
+ MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, "Resource Id");
resourceIdField.setHidden(true);
fields.add(0, resourceIdField);
@@ -50,7 +51,8 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
public ListGridRecord copyValues(MeasurementDataTrait from) {
ListGridRecord record = super.copyValues(from);
- record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, from.getSchedule().getResource().getId());
+ record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, from.getSchedule().getResource()
+ .getId());
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
index c353fdb..9af5c3b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
@@ -19,10 +19,12 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation;
import java.util.Date;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.FieldType;
@@ -43,51 +45,57 @@ public class OperationHistoryDataSource extends RPCDataSource<ResourceOperationH
private OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
-
public OperationHistoryDataSource() {
- super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
DataSourceIntegerField idField = new DataSourceIntegerField("id");
idField.setPrimaryKey(true);
- addField(idField);
+ fields.add(idField);
DataSourceTextField nameField = new DataSourceTextField("operationName");
- addField(nameField);
+ fields.add(nameField);
DataSourceTextField resourceField = new DataSourceTextField("resource");
- addField(resourceField);
+ fields.add(resourceField);
DataSourceTextField statusField = new DataSourceTextField("status");
- addField(statusField);
+ fields.add(statusField);
DataSourceTextField startedField = new DataSourceTextField("startedTime");
startedField.setType(FieldType.DATETIME);
- addField(startedField);
+ fields.add(startedField);
+
+ return fields;
}
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
-
if (request.getCriteria().getValues().containsKey("resourceId")) {
- criteria.addFilterResourceIds(Integer.parseInt((String) request.getCriteria().getValues().get("resourceId")));
+ criteria.addFilterResourceIds(Integer
+ .parseInt((String) request.getCriteria().getValues().get("resourceId")));
}
criteria.setPageControl(getPageControl(request));
- operationService.findResourceOperationHistoriesByCriteria(
- criteria, new AsyncCallback<PageList<ResourceOperationHistory>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failure loading operation histories", caught);
- }
+ operationService.findResourceOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceOperationHistory>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failure loading operation histories", caught);
+ }
- public void onSuccess(PageList<ResourceOperationHistory> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
+ public void onSuccess(PageList<ResourceOperationHistory> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
}
- );
+ });
}
@Override
@@ -110,7 +118,7 @@ public class OperationHistoryDataSource extends RPCDataSource<ResourceOperationH
record.setAttribute("status", from.getStatus().name());
record.setAttribute("parameters", from.getParameters());
- record.setAttribute("entity",from);
+ record.setAttribute("entity", from);
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
index 1843f2b..39e99af 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
@@ -22,22 +22,22 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
import java.util.Date;
import java.util.List;
-import org.rhq.core.domain.resource.ResourceError;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-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.util.RPCDataSource;
-
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.fields.DataSourceDateField;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceEnumField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.resource.ResourceError;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+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.util.RPCDataSource;
+
/**
*
* @author Lukas Krejci
@@ -55,10 +55,20 @@ public class ResourceErrorsDataSource extends RPCDataSource<ResourceError> {
public ResourceErrorsDataSource(int resourceId) {
resourceService = GWTServiceLookup.getResourceService();
this.resourceId = resourceId;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ fields.add(new DataSourceTextField(SUMMARY_ID, "Summary"));
+ fields.add(new DataSourceTextField(DETAIL_ID, "Detailed Message"));
+ fields.add(new DataSourceEnumField(ERROR_TYPE_ID, "Error Type"));
+ fields.add(new DataSourceDateTimeField(TIME_OCCURED_ID, "Time"));
- addFields(new DataSourceTextField(SUMMARY_ID, "Summary"),
- new DataSourceTextField(DETAIL_ID, "Detailed Message"),
- new DataSourceEnumField(ERROR_TYPE_ID, "Error Type"), new DataSourceDateTimeField(TIME_OCCURED_ID, "Time"));
+ return fields;
}
/* (non-Javadoc)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
index 5e6d943..9546d66 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
@@ -194,7 +194,8 @@ public class SearchBarPane extends LocatableHLayout {
comboBox.setShowIfCondition(new FormItemIfFunction() {
public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return dynamicForm.getValueAsString("searchType").equals(searchType.getDisplayName());
+ String value = dynamicForm.getValueAsString("searchType");
+ return (null != value && value.equals(searchType.getDisplayName()));
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
index 863afe2..24ada45 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
@@ -24,6 +24,7 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -69,18 +70,31 @@ public class RecentOperationsDataSource extends
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField resourceField = new DataSourceTextField(resource, "Resource");
resourceField.setPrimaryKey(true);
+ fields.add(resourceField);
DataSourceTextField locationField = new DataSourceTextField(location, "Location", 200);
+ fields.add(locationField);
DataSourceTextField operationField = new DataSourceTextField(operation, "Operation");
+ fields.add(operationField);
DataSourceDateTimeField timeField = new DataSourceDateTimeField(time, "Date/Time");
+ fields.add(timeField);
DataSourceTextField statusField = new DataSourceTextField(status, "Status");
+ fields.add(statusField);
- setFields(resourceField, locationField, operationField, timeField, statusField);
+ return fields;
}
/* Intercept DSRequest object to pipe into custom fetch request.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index ebb1185..ab28a8e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -24,7 +24,9 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
@@ -63,16 +65,28 @@ public class ScheduledOperationsDataSource extends
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField resourceField = new DataSourceTextField(resource, "Resource");
resourceField.setPrimaryKey(true);
+ fields.add(resourceField);
- DataSourceTextField locationField = new DataSourceTextField(location, "Location");
+ DataSourceTextField locationField = new DataSourceTextField(location, "Location", 200);
+ fields.add(locationField);
DataSourceTextField operationField = new DataSourceTextField(operation, "Operation");
+ fields.add(operationField);
- DataSourceTextField timeField = new DataSourceTextField(time, "Date/Time");
+ DataSourceDateTimeField timeField = new DataSourceDateTimeField(time, "Date/Time");
+ fields.add(timeField);
- setFields(resourceField, locationField, operationField, timeField);
+ return fields;
}
/* Intercept DSRequest object to pipe into custom fetch request.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
index 6a31020..d513e70 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
@@ -23,10 +23,12 @@
package org.rhq.enterprise.gui.coregui.client.report.measurement;
import java.util.Collection;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -47,48 +49,53 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
private int maximumFactor = 0;
public MeasurementOOBDataSource() {
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceTextField metricField = new DataSourceTextField("scheduleName","Metric");
- addField(metricField);
+ DataSourceTextField metricField = new DataSourceTextField("scheduleName", "Metric");
+ fields.add(metricField);
DataSourceTextField resourceField = new DataSourceTextField("resourceName", "Resource");
- addField(resourceField);
+ fields.add(resourceField);
DataSourceTextField parentField = new DataSourceTextField("parentName", "Parent");
- addField(parentField);
+ fields.add(parentField);
DataSourceTextField bandField = new DataSourceTextField("formattedBaseband", "Band");
- addField(bandField);
+ fields.add(bandField);
DataSourceTextField outlierField = new DataSourceTextField("formattedOutlier", "Outlier");
- addField(outlierField);
+ fields.add(outlierField);
DataSourceTextField factorField = new DataSourceTextField("factor", "Out of range factor (%)");
- addField(factorField);
+ fields.add(factorField);
- }
+ return fields;
+ }
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
PageControl pc = getPageControl(request);
- GWTServiceLookup.getMeasurementDataService().getSchedulesWithOOBs(
- null, null, null, pc,
- new AsyncCallback<PageList<MeasurementOOBComposite>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load measurement OOB information",caught);
- }
-
- public void onSuccess(PageList<MeasurementOOBComposite> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
+ GWTServiceLookup.getMeasurementDataService().getSchedulesWithOOBs(null, null, null, pc,
+ new AsyncCallback<PageList<MeasurementOOBComposite>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load measurement OOB information", caught);
}
- );
+
+ public void onSuccess(PageList<MeasurementOOBComposite> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
@@ -97,7 +104,6 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
throw new UnsupportedOperationException("OOBs Read only");
}
-
@Override
public ListGridRecord[] buildRecords(Collection<MeasurementOOBComposite> list) {
for (MeasurementOOBComposite oob : list) {
@@ -128,20 +134,18 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
record.setAttribute("parentId", from.getParentId());
record.setAttribute("parentName", from.getParentName());
- int factorRankingWidth = (int) (((double)from.getFactor())/ (double)maximumFactor * 100d);
+ int factorRankingWidth = (int) (((double) from.getFactor()) / (double) maximumFactor * 100d);
- record.setBackgroundComponent(
- new HTMLFlow(
- "<div style=\"width: " + factorRankingWidth + "%; height: 100%; background-color: #A5B391;\"> </div>"));
+ record.setBackgroundComponent(new HTMLFlow("<div style=\"width: " + factorRankingWidth
+ + "%; height: 100%; background-color: #A5B391;\"> </div>"));
return record;
}
-
private void applyFormatting(MeasurementOOBComposite oob) {
- oob.setFormattedOutlier(MeasurementConverterClient.format(oob.getOutlier(), oob.getUnits(), true));
- formatBaseband(oob);
+ oob.setFormattedOutlier(MeasurementConverterClient.format(oob.getOutlier(), oob.getUnits(), true));
+ formatBaseband(oob);
}
private void formatBaseband(MeasurementOOBComposite oob) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index 38c316b..e7c8050 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -24,6 +24,7 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.fields.DataSourceImageField;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -66,16 +67,28 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
DataSourceTextField resourceField = new DataSourceTextField(resource, "Resource");
resourceField.setPrimaryKey(true);
+ fields.add(resourceField);
DataSourceTextField locationField = new DataSourceTextField(location, "Location");
+ fields.add(locationField);
DataSourceTextField alertsField = new DataSourceTextField(alerts, "Alerts");
+ fields.add(alertsField);
- DataSourceImageField availablilityField = new DataSourceImageField(available, "Current Availability");
+ DataSourceImageField availabilityField = new DataSourceImageField(available, "Current Availability");
+ fields.add(availabilityField);
- setFields(resourceField, locationField, alertsField, availablilityField);
+ return fields;
}
/* Intercept DSRequest object to pipe into custom fetch request.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index 86ab57e..38a9386 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -18,8 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.util;
-import java.util.Arrays;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -40,6 +40,7 @@ import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.effects.ColoringUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* Base GWT-RPC oriented DataSource class.
@@ -58,7 +59,7 @@ public abstract class RPCDataSource<T> extends DataSource {
public RPCDataSource(String name) {
if (name != null) {
com.allen_sauer.gwt.log.client.Log.info("Trying to build DS: " + name);
- setID(name);
+ setID(SeleniumUtility.getSafeId(name));
}
// TODO until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed always go to the server for data
setClientOnly(false);
@@ -68,6 +69,22 @@ public abstract class RPCDataSource<T> extends DataSource {
setDataFormat(DSDataFormat.CUSTOM);
}
+ /**
+ * Override in each subclass to set the default ds fields for the ds. The datasource should not
+ * define and set ds fields in the constructor in case a user of the ds wants to set their own. For example,
+ * those that want to use list grid fields (like our list views).
+ */
+ public void useDatasourceDefinedFields() {
+ }
+
+ /**
+ * A pattern that can be used for Datasource subclassing. Each subclass can add it's own fields prior to
+ * all of the fields being added to the datasource.
+ */
+ protected List<DataSourceField> addDataSourceFields() {
+ return new ArrayList<DataSourceField>();
+ }
+
@Override
protected Object transformRequest(DSRequest request) {
try {
@@ -229,7 +246,7 @@ public abstract class RPCDataSource<T> extends DataSource {
addField(field);
}
}
-
+
public void addFields(DataSourceField... fields) {
addFields(Arrays.asList(fields));
}
13 years, 8 months
[rhq] modules/core
by mazz
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java | 15 +++++++---
1 file changed, 11 insertions(+), 4 deletions(-)
New commits:
commit f767f233ffb2cea9cb3f2a69a20af0a4b9cd4960
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Oct 15 14:23:14 2010 -0400
bad things happen when gwt attempts to serialize alert defs return values via RPC calls.
this checks for null values getting passed into setters and avoids NPEs.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index 31be645..a288cad 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -519,7 +519,9 @@ public class AlertDefinition implements Serializable {
public void setResource(Resource resource) {
this.resource = resource;
- this.resource.getAlertDefinitions().add(this);
+ if (this.resource != null) {
+ this.resource.getAlertDefinitions().add(this);
+ }
}
public ResourceGroup getResourceGroup() {
@@ -652,9 +654,11 @@ public class AlertDefinition implements Serializable {
}
public void setConditions(Set<AlertCondition> conditions) {
- this.conditions.clear();
- for (AlertCondition condition : conditions) {
- addCondition(condition);
+ removeAllConditions();
+ if (conditions != null) {
+ for (AlertCondition condition : conditions) {
+ addCondition(condition);
+ }
}
}
@@ -684,6 +688,9 @@ public class AlertDefinition implements Serializable {
}
public void setAlertNotifications(List<AlertNotification> alertNotifications) {
+ if (alertNotifications == null) {
+ alertNotifications = new ArrayList<AlertNotification>();
+ }
this.alertNotifications = alertNotifications;
}
13 years, 8 months
[rhq] Branch 'release-3.0.0' - modules/enterprise
by John Sanda
modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js | 118 ----------
1 file changed, 118 deletions(-)
New commits:
commit 707023b7391c9835db5a299b1447a8977e083dd7
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Oct 15 12:34:58 2010 -0400
[BZ 536549] Removing unused js code
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js
index ca82a55..de830ca 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js
@@ -124,121 +124,3 @@ WindowResizeTracker.addListener(function() {
overlay.refresh();
});
-/*************************************************************************
- This code is from Dynamic Web Coding at http://www.dyn-web.com/
- Copyright 2003 by Sharon Paine
- See Terms of Use at http://www.dyn-web.com/bus/terms.html
- regarding conditions under which you may use this code.
- This notice must be retained in the code as is!
-*************************************************************************/
-
-var viewport = {
- getWinWidth: function () {
- this.width = 0;
- if (window.innerWidth) this.width = window.innerWidth - 18;
- else if (document.documentElement && document.documentElement.clientWidth)
- this.width = document.documentElement.clientWidth;
- else if (document.body && document.body.clientWidth)
- this.width = document.body.clientWidth;
- },
-
- getWinHeight: function () {
- this.height = 0;
- if (window.innerHeight) this.height = window.innerHeight - 18;
- else if (document.documentElement && document.documentElement.clientHeight)
- this.height = document.documentElement.clientHeight;
- else if (document.body && document.body.clientHeight)
- this.height = document.body.clientHeight;
- },
-
- getScrollX: function () {
- this.scrollX = 0;
- if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset
-;
- else if (document.documentElement && document.documentElement.scrollLeft)
- this.scrollX = document.documentElement.scrollLeft;
- else if (document.body && document.body.scrollLeft)
- this.scrollX = document.body.scrollLeft;
- else if (window.scrollX) this.scrollX = window.scrollX;
- },
-
- getScrollY: function () {
- this.scrollY = 0;
- if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset
-;
- else if (document.documentElement && document.documentElement.scrollTop)
- this.scrollY = document.documentElement.scrollTop;
- else if (document.body && document.body.scrollTop)
- this.scrollY = document.body.scrollTop;
- else if (window.scrollY) this.scrollY = window.scrollY;
- },
-
- getAll: function () {
- this.getWinWidth(); this.getWinHeight();
- this.getScrollX(); this.getScrollY();
- }
-
-}
-
-var menuLayers = {
- timer: null,
- activeMenuID: null,
- offX: 3, // horizontal offset
- offY: 5, // vertical offset
-
- show: function(id, e) {
- var mnu = $? $(id): null;
- if (!mnu) return;
- this.activeMenuID = id;
- if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
- if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
- viewport.getAll();
- this.position(mnu, e);
- },
-
- hide: function() {
- this.clearTimer();
- if (this.activeMenuID && $)
- this.timer = setTimeout("$('"+menuLayers.activeMenuID+"').style.visibility = 'hidden'", 200);
- },
-
- position: function(mnu, e) {
- var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
- var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;
-
- if ( x + mnu.offsetWidth + this.offX > viewport.width + viewport.scrollX )
- x = x - mnu.offsetWidth - this.offX;
- else x = x + this.offX;
-
- if ( y + mnu.offsetHeight + this.offY >
- viewport.height + viewport.scrollY )
- y = ( y - mnu.offsetHeight - this.offY > viewport.scrollY )?
- y - mnu.offsetHeight - this.offY :
- viewport.height + viewport.scrollY - mnu.offsetHeight;
- else y = y + this.offY;
-
- this.timer = setTimeout("$('" + menuLayers.activeMenuID + "').style.visibility = 'visible'", 200);
- mnu.style.left = x + "px"; mnu.style.top = y + "px";
- },
-
- mouseoutCheck: function(e) {
- e = e? e: window.event;
- // is element moused into contained by menu? or is it menu (ul or li or a to menu div)?
- var mnu = $(menuLayers.activeMenuID);
- var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
- if ( mnu != toEl && !menuLayers.contained(toEl, mnu) ) menuLayers.hide();
- },
-
- // returns true of oNode is contained by oCont (container)
- contained: function(oNode, oCont) {
- if (!oNode) return; // in case alt-tab away while hovering (prevent error)
- while ( oNode = oNode.parentNode )
- if ( oNode == oCont ) return true;
- return false;
- },
-
- clearTimer: function() {
- if (menuLayers.timer) clearTimeout(menuLayers.timer);
- }
-}
-
13 years, 8 months
[rhq] Branch 'nagios' - modules/core
by Heiko W. Rupp
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java | 39 +++++++---
1 file changed, 29 insertions(+), 10 deletions(-)
New commits:
commit 7b4e5174fff5f92ece4108cbd98b9a52f8bad271
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Oct 15 18:29:20 2010 +0200
Fix discovery of server type(s) introduced by some changes.
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
index f2dc59b..e0c0e25 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
@@ -92,25 +92,44 @@ public class PluginMetadataManager {
PluginMetadataParser parser = this.parsersByPlugin.get(resourceType.getPlugin());
- //TODO: make it more generic without hardcoded comparison
- if (parser.getDescriptor().getName().equals("NagiosMonitor")) {
- return (parser != null) ? parser.getChildTypeDiscoveryComponentClass(resourceType) : null;
- } else {
- return (parser != null) ? parser.getDiscoveryComponentClass(resourceType) : null;
+// if (parser.getDescriptor().getName().equals("NagiosMonitor")) {
+// return (parser != null) ? parser.getChildTypeDiscoveryComponentClass(resourceType) : null;
+// } else {
+// return (parser != null) ? parser.getDiscoveryComponentClass(resourceType) : null;
+// }
+ if (parser==null)
+ return null;
+
+ if (resourceType.getParentResourceTypes()!=null && !resourceType.getParentResourceTypes().isEmpty()) {
+ ResourceType parent = resourceType.getParentResourceTypes().iterator().next();
+ if (parser.getChildTypeDiscoveryComponentClass(parent)!=null)
+ return parser.getChildTypeDiscoveryComponentClass(parent);
}
+ return parser.getDiscoveryComponentClass(resourceType);
+
}
public String getComponentClass(ResourceType resourceType) {
PluginMetadataParser parser = this.parsersByPlugin.get(resourceType.getPlugin());
- //TODO: make it more generic without hardcoded comparison
- if (parser.getDescriptor().getName().equals("NagiosMonitor")) {
- return (parser != null) ? parser.getChildTypeComponentClass(resourceType) : null;
- } else {
- return (parser != null) ? parser.getComponentClass(resourceType) : null;
+// if (parser.getDescriptor().getName().equals("NagiosMonitor")) {
+// return (parser != null) ? parser.getChildTypeComponentClass(resourceType) : null;
+// } else {
+// return (parser != null) ? parser.getComponentClass(resourceType) : null;
+// }
+ if (parser==null)
+ return null;
+
+ if (resourceType.getParentResourceTypes()!=null && !resourceType.getParentResourceTypes().isEmpty()) {
+ ResourceType parent = resourceType.getParentResourceTypes().iterator().next();
+ if (parser.getChildTypeComponentClass(parent)!=null)
+ return parser.getChildTypeComponentClass(parent);
}
+ return parser.getComponentClass(resourceType);
+
+
}
/**
13 years, 8 months
[rhq] Branch 'gwt-ldap' - modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java | 129 ++++++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/LdapGWTService.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java | 14 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java | 23 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerLocal.java | 2
6 files changed, 151 insertions(+), 31 deletions(-)
New commits:
commit 34f9d85692a50c7b5c578591562ee6e623f3e16d
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Oct 15 12:05:27 2010 -0400
i)ldap user registration prepopulation ii)numerous ldap fixes a)F5 refresh username b)last name required c)stale session checks.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index da1ee4c..66c37c6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -32,6 +32,7 @@ import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
+import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.FormErrorOrientation;
@@ -185,6 +186,10 @@ public class LoginView extends Canvas {
public void showRegistrationDialog(String user, final String sessionId, final String password,
final AsyncCallback<Subject> callback) {
if (!loginShowing) {
+ if ((user != null) && (!user.trim().isEmpty())) {
+ Cookies.setCookie(USERNAME, user);
+ Cookies.setCookie(PASSWORD, password);
+ }
loginShowing = true;
forms = new ArrayList<DynamicForm>();
@@ -194,6 +199,7 @@ public class LoginView extends Canvas {
form.setAutoFocus(true);
form.setShowErrorText(true);
form.setErrorOrientation(FormErrorOrientation.BOTTOM);
+ int fieldWidth = 120;
VLayout column = new VLayout();
HeaderItem header = new HeaderItem();
@@ -206,28 +212,29 @@ public class LoginView extends Canvas {
{
first.setRequired(true);
first.setWrapTitle(false);
- first.setWidth(100);
+ first.setWidth(fieldWidth);
}
last = new TextItem(LAST, "Last Name");
{
last.setWrapTitle(false);
- last.setWidth(100);
+ last.setWidth(fieldWidth);
+ last.setRequired(true);
}
final TextItem username = new TextItem(USERNAME, "Username");
{
- username.setRequired(true);
- username.setValue(user);
+ username.setValue(Cookies.getCookie(USERNAME));
+
username.setDisabled(true);
- username.setWidth(100);
+ username.setWidth(fieldWidth);
column.addMember(wrapInDynamicForm(6, first, last, username));
}
email = new TextItem(EMAIL, "Email");
email.setRequired(true);
- email.setWidth(100);
+ email.setWidth(fieldWidth);
phone = new TextItem(PHONE, "Phone");
- phone.setWidth(100);
+ phone.setWidth(fieldWidth);
department = new TextItem(DEPARTMENT, "Department");
- department.setWidth(100);
+ department.setWidth(fieldWidth);
SpacerItem space = new SpacerItem();
space.setColSpan(1);
column.addMember(wrapInDynamicForm(6, email, phone, department));
@@ -242,6 +249,11 @@ public class LoginView extends Canvas {
IButton okButton = new IButton("OK");
okButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
+ //check for session timeout
+ if (isSessionStale()) {
+ resetLogin();
+ }
+
//validation
if (validateForms(forms)) {
Log.trace("Successfully validated all data for user registration.");
@@ -253,31 +265,61 @@ public class LoginView extends Canvas {
form.setValue(PHONE, String.valueOf(phone.getValue()));
form.setValue(DEPARTMENT, String.valueOf(department.getValue()));
form.setValue(SESSIONID, sessionId);
- form.setValue(PASSWORD, password);
+ form.setValue(PASSWORD, Cookies.getCookie(PASSWORD));
registerLdapUser(form, callback);
}
}
- /** Iterates through the dynamic forms populated then calls validate().
- *
- * @param forms
- * @return
- */
- private boolean validateForms(ArrayList<DynamicForm> forms) {
- boolean allValid = true;
- for (DynamicForm form : forms) {
- if (!form.validate()) {
- allValid = false;
+ });
+ row.addMember(okButton);
+ //send request to LDAP server to grab user details for this user. Already sure ldap user exists
+ GWTServiceLookup.getLdapService().getLdapDetailsFor(user, new AsyncCallback<Map<String, String>>() {
+ public void onSuccess(final Map<String, String> ldapUserDetails) {
+ //now prepopulate UI fields if they exist
+ for (String key : ldapUserDetails.keySet()) {
+ String value;
+ if (key.equalsIgnoreCase("givenName")) {//aka first name
+ value = ldapUserDetails.get(key);
+ first.setValue(value);
+ } else if (key.equalsIgnoreCase("sn")) {//aka Surname
+ value = ldapUserDetails.get(key);
+ if ((value != null) && (!value.isEmpty())) {
+ last.setValue(value);
+ }
+ } else if (key.equalsIgnoreCase("telephoneNumber")) {
+ value = ldapUserDetails.get(key);
+ if ((value != null) && (!value.isEmpty())) {
+ phone.setValue(value);
+ }
+ } else if (key.equalsIgnoreCase("mail")) {
+ value = ldapUserDetails.get(key);
+ if ((value != null) && (!value.isEmpty())) {
+ email.setValue(value);
+ }
}
}
- return allValid;
+ }
+
+ public void onFailure(Throwable caught) {
+ Log.debug("Optional LDAP detail retrieval did not succeed. Registration prepopulation will occur.");
}
});
- row.addMember(okButton);
IButton resetButton = new IButton("Reset");
resetButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
+ if (isSessionStale()) {
+ resetLogin();
+ }
+
+ //clear out all validation messages.
+ {
+ String empty = " ";
+ first.setValue(empty);
+ last.setValue(empty);
+ email.setValue("test(a)test.com");
+ validateForms(forms);
+ }
first.clearValue();
last.clearValue();
email.clearValue();
@@ -290,10 +332,7 @@ public class LoginView extends Canvas {
IButton logout = new IButton("Logout");
logout.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
- UserSessionManager.invalidateSession();
- window.destroy();
- loginShowing = false;
- new LoginView().showLoginDialog();
+ resetLogin();
}
});
row.addMember(logout);
@@ -322,6 +361,46 @@ public class LoginView extends Canvas {
}
}
+ /** Iterates through the dynamic forms populated then calls validate().
+ *
+ * @param forms
+ * @return
+ */
+ private boolean validateForms(ArrayList<DynamicForm> forms) {
+ boolean allValid = true;
+ for (DynamicForm form : forms) {
+ if (!form.validate()) {
+ allValid = false;
+ }
+ }
+ return allValid;
+ }
+
+ /** Go through steps of invalidating this login and piping them back to CoreGUI Login.
+ */
+ private void resetLogin() {
+ UserSessionManager.invalidateSession();
+ window.destroy();
+ loginShowing = false;
+ new LoginView().showLoginDialog();
+ }
+
+ /** Check to see whether session has timed out while user has been waiting on this form.
+ * @return
+ */
+ private boolean isSessionStale() {
+ boolean staleSession = false;
+ String lastAccess = UserSessionManager.getLastAccessTime();
+ if ((lastAccess != null) && (!lastAccess.trim().isEmpty())) {
+ long expiryTime = Long.valueOf(lastAccess) + UserSessionManager.SESSION_TIMEOUT;
+ long expiryMillis = expiryTime - System.currentTimeMillis();
+ if (expiryMillis < 0) {
+ staleSession = true;
+ }
+ }
+ return staleSession;
+ }
+
/**Uses the information from the populated form to create the Subject for the new LDAP user.
*
* @param populatedForm - validated data
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
index 2d283a3..71c62b8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
@@ -54,10 +54,12 @@ import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
* @author Joseph Marques
*/
public class UserSessionManager {
- private static int SESSION_TIMEOUT = 29 * 60 * 1000; // 29 mins, just shorter than the 30-min web session timeout
+ public static int SESSION_TIMEOUT = 29 * 60 * 1000; // 29 mins, just shorter than the 30-min web session timeout
private static int LOGOUT_DELAY = 5 * 1000; // wait 5 seconds for in-flight requests to complete before logout
public static final String SESSION_NAME = "RHQ_Sesssion";
+ public static final String SESSION_LAST_ACCESS = SESSION_NAME + ".LAST_ACCESS";
+
private static Subject sessionSubject;
private static UserPreferences userPreferences;
@@ -99,6 +101,7 @@ public class UserSessionManager {
final int subjectId = Integer.parseInt(parts[0]);
final String sessionId = parts[1]; // not null
final long lastAccess = Long.parseLong(parts[2]);
+ Cookies.setCookie(SESSION_LAST_ACCESS, String.valueOf(lastAccess));
Log.info("sessionAccess-subjectId: " + subjectId);
Log.info("sessionAccess-sessionId: " + sessionId);
Log.info("sessionAccess-lastAccess: " + lastAccess);
@@ -363,4 +366,8 @@ public class UserSessionManager {
public static UserPreferences getUserPreferences() {
return userPreferences;
}
+
+ public static String getLastAccessTime() {
+ return Cookies.getCookie(SESSION_LAST_ACCESS);
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/LdapGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/LdapGWTService.java
index 0209e37..7915b80 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/LdapGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/LdapGWTService.java
@@ -41,6 +41,11 @@ public interface LdapGWTService extends RemoteService {
Set<Map<String, String>> findAvailableGroups();
/**
+ * @return Map with LDAP details for user passed.
+ */
+ Map<String, String> getLdapDetailsFor(String user);
+
+ /**
* Updates the role with the ldap groups selected.
*/
void addLdapGroupsToRole(int roleId, List<String> groupIds);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java
index d03c53c..fe68250 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/LdapGWTServiceImpl.java
@@ -294,4 +294,18 @@ public class LdapGWTServiceImpl extends AbstractGWTServiceImpl implements LdapGW
}
return ldapEnabled;
}
+
+ /**Returns all LDAP details for a given user, using the configured ldap details of server.
+ *
+ */
+ @Override
+ public Map<String, String> getLdapDetailsFor(String user) {
+ Map<String, String> ldapDetails = new HashMap<String, String>();
+ try {
+ ldapDetails = ldapManager.findLdapUserDetails(user);
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ return ldapDetails;
+ }
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
index 8c75852..2cff69b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
@@ -211,6 +211,14 @@ public class LdapGroupManagerBean implements LdapGroupManagerLocal {
}
private String getUserDN(Properties options, String userName) {
+ Map<String, String> details = findLdapUserDetails(userName);
+ String userDN = details.get("dn");
+ return userDN;
+ }
+
+ public Map<String, String> findLdapUserDetails(String userName) {
+ Properties options = systemManager.getSystemConfiguration();
+ HashMap<String, String> userDetails = new HashMap<String, String>();
// Load our LDAP specific properties
Properties env = getProperties(options);
@@ -265,12 +273,17 @@ public class LdapGroupManagerBean implements LdapGroupManagerLocal {
SearchResult si = (SearchResult) answer.next();
// Construct the UserDN
- String userDN = si.getName() + "," + baseDNs[x];
- return userDN;
+ NamingEnumeration<String> keys = si.getAttributes().getIDs();
+ while (keys.hasMore()) {
+ String key = keys.next();
+ Attribute value = si.getAttributes().get(key);
+ if (value != null) {
+ userDetails.put(key, value.get() + "");
+ }
+ }
+ return userDetails;
}
-
- // If we try all the BaseDN's and have not found a match, return false
- return "";
+ return userDetails;
} catch (NamingException e) {
throw new RuntimeException(e);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerLocal.java
index 6709b32..17a008a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerLocal.java
@@ -50,4 +50,6 @@ public interface LdapGroupManagerLocal {
Set<Map<String, String>> findAvailableGroups();
Set<String> findAvailableGroupsFor(String userName);
+
+ Map<String, String> findLdapUserDetails(String userName);
}
\ No newline at end of file
13 years, 8 months
[rhq] Branch 'nagios' - 2 commits - modules/enterprise modules/plugins
by Heiko W. Rupp
modules/enterprise/server/ear/pom.xml | 6 ++++++
modules/plugins/nagios/src/main/resources/META-INF/rhq-plugin.xml | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
New commits:
commit bb2ba16e6663383c80fb8205ea203c9f98271cae
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Oct 15 16:56:18 2010 +0200
Follow package renaming for the main plugin classes.
diff --git a/modules/plugins/nagios/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/nagios/src/main/resources/META-INF/rhq-plugin.xml
index 059bc1d..31c8b33 100644
--- a/modules/plugins/nagios/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/nagios/src/main/resources/META-INF/rhq-plugin.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<plugin name="NagiosMonitor"
displayName="NagiosMonitorPlugin"
- package="org.rhq.plugins.nagios"
+ package="org.rhq.plugins.rhqNagiosPlugin"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration"
commit c39ccf067c27c0a731804e5af8eaed0bd0b9b064
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Oct 15 16:55:39 2010 +0200
Add nagios plugin to full application build.
diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml
index 61803e7..5c65509 100644
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@ -247,6 +247,12 @@
<artifactId>rhq-jmx-plugin</artifactId>
<version>${project.version}</version>
</artifactItem>
+
+ <artifactItem>
+ <groupId>org.rhq</groupId>
+ <artifactId>NagiosMonitor-plugin</artifactId>
+ <version>${project.version}</version>
+ </artifactItem>
</artifactItems>
<outputDirectory>${earDirectory}/rhq-downloads/rhq-plugins</outputDirectory>
</configuration>
13 years, 8 months