[rhq] Branch 'nagios' - modules/plugins
by Alexander Kiefer
modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/managementInterface/NagiosManagementInterface.java | 190 ++++------
modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorChildTypeComponent.java | 190 ++++++++++
modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorChildTypeDiscovery.java | 118 ++++++
modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorComponent.java | 124 ++++++
modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorDiscovery.java | 86 ++++
modules/plugins/nagios/src/main/resources/META-INF/rhq-plugin.xml | 2
6 files changed, 612 insertions(+), 98 deletions(-)
New commits:
commit b45824aa3ed097e538081bcc5163f471376cdb4c
Author: Alexander Kiefer <alexander.kiefer(a)dillinger.biz>
Date: Wed Oct 20 23:15:40 2010 +0200
Changed packet structure and implemented discovery/component classes
both for child and parent resource types
diff --git a/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/managementInterface/NagiosManagementInterface.java b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/managementInterface/NagiosManagementInterface.java
index 5e2d5bb..a7c4979 100644
--- a/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/managementInterface/NagiosManagementInterface.java
+++ b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/managementInterface/NagiosManagementInterface.java
@@ -1,4 +1,5 @@
package org.rhq.plugins.nagios.managementInterface;
+
/*
* RHQ Management Platform
* Copyright (C) 2005-2008 Red Hat, Inc.
@@ -40,28 +41,25 @@ import org.rhq.plugins.nagios.request.LqlStatusRequest;
*
* @author Alexander Kiefer
*/
-public class NagiosManagementInterface
-{
- private String livestatusAddress;
- private int livestatusPort;
-
- private NetworkConnection livestatusConnectionInterface;
- private Controller controller;
-
-
- /**
- *
- *
- * @param livestatusAddress - IP address of mk_livestatus socket
- * @param livetstatusPort - Port number of mk_livestatus socket
- */
- public NagiosManagementInterface(String livestatusAddress, int livetstatusPort)
- {
- this.livestatusAddress = livestatusAddress;
- this.livestatusPort = livetstatusPort;
- livestatusConnectionInterface = new NetworkConnection(this.livestatusAddress, this.livestatusPort);
- controller = new Controller();
- }
+public class NagiosManagementInterface {
+ private String livestatusAddress;
+ private int livestatusPort;
+
+ private NetworkConnection livestatusConnectionInterface;
+ private Controller controller;
+
+ /**
+ *
+ *
+ * @param livestatusAddress - IP address of mk_livestatus socket
+ * @param livetstatusPort - Port number of mk_livestatus socket
+ */
+ public NagiosManagementInterface(String livestatusAddress, int livetstatusPort) {
+ this.livestatusAddress = livestatusAddress;
+ this.livestatusPort = livetstatusPort;
+ livestatusConnectionInterface = new NetworkConnection(this.livestatusAddress, this.livestatusPort);
+ controller = new Controller();
+ }
/**
* Ping the nagios server by sending a host request.
@@ -70,84 +68,82 @@ public class NagiosManagementInterface
public boolean pingNagios() {
LqlHostRequest hostRequest = new LqlHostRequest();
LqlReply hostReply = livestatusConnectionInterface.sendAndReceive(hostRequest);
- if (hostReply.getLqlReply().size()>0)
+ if (hostReply.getLqlReply().size() > 0)
return true;
return false;
}
- /**
- * Method does all the necessary steps to get the data about the current nagios hosts
- *
- * @throws InvalidReplyTypeException
- * @throws InvalidMetricRequestException
- * @throws InvalidServiceRequestException
- */
- private HostData getHostInformation() throws InvalidReplyTypeException, InvalidServiceRequestException, InvalidMetricRequestException
- {
- LqlHostRequest hostRequest = new LqlHostRequest();
- LqlReply hostReply= new LqlReply(hostRequest.getRequestType());
-
- //Send host data request and fill reply object
- hostReply = livestatusConnectionInterface.sendAndReceive(hostRequest);
-
- HostData hostData = (HostData) controller.createDataModel(hostReply);
- Collection<Host> collection = hostData.getHostTable().values();
-
- //request service information for all current nagios hosts
- for(Host host : collection)
- {
- //Give hostname to LQLRequest to complete the lql query in LqlServiceRequest instance
- LqlServiceRequest lqlServiceRequest = new LqlServiceRequest(host.getHostName());
-
- //Set request Type for later usage when concrete instances are created in createDataModel
- LqlReply lqlServiceReply = new LqlReply(lqlServiceRequest.getRequestType());
- //Write result of service request to reply object
- lqlServiceReply = livestatusConnectionInterface.sendAndReceive(lqlServiceRequest);
-
- //Fill service data object
- ServiceData serviceData = (ServiceData) controller.createDataModel(lqlServiceReply);
-
- //put service Data object to the specific host it belongs to
- hostData.getHostTable().get(host.getHostName()).setServiceData(serviceData);
- }
-
- return hostData;
- }
-
- /**
- * Method does all the necessary steps to get the status data of Nagios system
- *
- * @throws InvalidReplyTypeException
- */
- private StatusData getStatusInformation() throws InvalidReplyTypeException
- {
- LqlStatusRequest lqlStatusRequest = new LqlStatusRequest();
-
- //Set request Type for later usage when concrete instances are created in createDataModel
- LqlReply lqlStatusReply = new LqlReply(lqlStatusRequest.getRequestType());
- //Write result of status request to reply object
- lqlStatusReply = livestatusConnectionInterface.sendAndReceive(lqlStatusRequest);
-
- //Fill service data object
- StatusData statusData = (StatusData) controller.createDataModel(lqlStatusReply);
-
-// String test = serviceData.getSingleMetricForRessource("host_execution_time", "Current Load", null).getId();
-// String test2 = serviceData.getSingleMetricForRessource("host_execution_time", "Current Load", null).getValue();
-
-// System.out.println(test);
-// System.out.println(test2);
-
- return statusData;
- }
-
- public NagiosSystemData createNagiosSystemData() throws InvalidReplyTypeException, InvalidServiceRequestException, InvalidMetricRequestException
- {
- HostData hostData = getHostInformation();
- StatusData statusData = getStatusInformation();
-
- NagiosSystemData nagiosSystemData = new NagiosSystemData(hostData, statusData);
-
- return nagiosSystemData;
- }
+ /**
+ * Method does all the necessary steps to get the data about the current nagios hosts
+ *
+ * @throws InvalidReplyTypeException
+ * @throws InvalidMetricRequestException
+ * @throws InvalidServiceRequestException
+ */
+ private HostData getHostInformation() throws InvalidReplyTypeException, InvalidServiceRequestException,
+ InvalidMetricRequestException {
+ LqlHostRequest hostRequest = new LqlHostRequest();
+ LqlReply hostReply = new LqlReply(hostRequest.getRequestType());
+
+ //Send host data request and fill reply object
+ hostReply = livestatusConnectionInterface.sendAndReceive(hostRequest);
+
+ HostData hostData = (HostData) controller.createDataModel(hostReply);
+ Collection<Host> collection = hostData.getHostTable().values();
+
+ //request service information for all current nagios hosts
+ for (Host host : collection) {
+ //Give hostname to LQLRequest to complete the lql query in LqlServiceRequest instance
+ LqlServiceRequest lqlServiceRequest = new LqlServiceRequest(host.getHostName());
+
+ //Set request Type for later usage when concrete instances are created in createDataModel
+ LqlReply lqlServiceReply = new LqlReply(lqlServiceRequest.getRequestType());
+ //Write result of service request to reply object
+ lqlServiceReply = livestatusConnectionInterface.sendAndReceive(lqlServiceRequest);
+
+ //Fill service data object
+ ServiceData serviceData = (ServiceData) controller.createDataModel(lqlServiceReply);
+
+ //put service Data object to the specific host it belongs to
+ hostData.getHostTable().get(host.getHostName()).setServiceData(serviceData);
+ }
+
+ return hostData;
+ }
+
+ /**
+ * Method does all the necessary steps to get the status data of Nagios system
+ *
+ * @throws InvalidReplyTypeException
+ */
+ private StatusData getStatusInformation() throws InvalidReplyTypeException {
+ LqlStatusRequest lqlStatusRequest = new LqlStatusRequest();
+
+ //Set request Type for later usage when concrete instances are created in createDataModel
+ LqlReply lqlStatusReply = new LqlReply(lqlStatusRequest.getRequestType());
+ //Write result of status request to reply object
+ lqlStatusReply = livestatusConnectionInterface.sendAndReceive(lqlStatusRequest);
+
+ //Fill service data object
+ StatusData statusData = (StatusData) controller.createDataModel(lqlStatusReply);
+
+ // String test = serviceData.getSingleMetricForRessource("host_execution_time", "Current Load", null).getId();
+ // String test2 = serviceData.getSingleMetricForRessource("host_execution_time", "Current Load", null).getValue();
+
+ // System.out.println(test);
+ // System.out.println(test2);
+
+ return statusData;
+ }
+
+ public NagiosSystemData createNagiosSystemData() throws InvalidReplyTypeException, InvalidServiceRequestException,
+ InvalidMetricRequestException {
+ HostData hostData = getHostInformation();
+ StatusData statusData = getStatusInformation();
+
+ NagiosSystemData nagiosSystemData = new NagiosSystemData(hostData, statusData);
+
+ return nagiosSystemData;
+ }
}
diff --git a/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorChildTypeComponent.java b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorChildTypeComponent.java
new file mode 100755
index 0000000..6ff21a2
--- /dev/null
+++ b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorChildTypeComponent.java
@@ -0,0 +1,190 @@
+package org.rhq.plugins.nagios.rhqNagiosPlugin;
+
+/*
+ * 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.
+ */
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.ChildResourceTypeDiscoveryFacet;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.plugins.nagios.data.NagiosSystemData;
+import org.rhq.plugins.nagios.error.NagiosException;
+import org.rhq.plugins.nagios.managementInterface.NagiosManagementInterface;
+
+/**
+ *
+ * @author Alexander Kiefer
+ *
+ */
+public class NagiosMonitorChildTypeComponent implements ResourceComponent, MeasurementFacet,
+ ChildResourceTypeDiscoveryFacet {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public static final String DEFAULT_NAGIOSIP = "127.0.0.1";
+ public static final String DEFAULT_NAGIOSPORT = "6557";
+
+ private ResourceContext context;
+ private NagiosManagementInterface nagiosManagementInterface;
+ private String nagiosHost;
+ private int nagiosPort;
+
+ @Override
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
+ NagiosSystemData nagiosSystemData = null;
+ String serviceName = this.context.getResourceType().getName();
+ log.info("getValues() of ResourceType: " + serviceName);
+
+ try {
+ //Getting all Nagios system information
+ nagiosSystemData = nagiosManagementInterface.createNagiosSystemData();
+ } catch (Exception e) {
+ log.warn(" Can not get information from Nagios: ", e);
+ return;
+ }
+
+ //iterating over the metrics
+ for (MeasurementScheduleRequest req : metrics) {
+ try { // Don't let one bad egg spoil the cake
+
+ String[] splitter = req.getName().split("\\|");
+ String property = splitter[1];
+ String pattern = splitter[2];
+
+ if (log.isDebugEnabled()) {
+ log.debug("Name of Metric: " + property);
+ log.debug("RegEx: " + pattern);
+ }
+
+ // Get "raw" data from nagios data structures - we need to pick our value below
+ String value = nagiosSystemData.getSingleHostServiceMetric(property, serviceName, "localhost")
+ .getValue(); // TODO use 'real' host
+
+ Pattern p = Pattern.compile(pattern);
+ Matcher m = p.matcher(value);
+ if (m.matches()) {
+ String val = m.group(1); // Our metric is always in the first match group.
+
+ // We have a match, now dispatch by dataType of the request
+ if (req.getDataType() == DataType.MEASUREMENT) {
+ MeasurementDataNumeric res = new MeasurementDataNumeric(req, Double.valueOf(val));
+ report.addData(res);
+ } else if (req.getDataType() == DataType.TRAIT) {
+ MeasurementDataTrait res = new MeasurementDataTrait(req, val);
+ report.addData(res);
+ } else
+ log.error("Unknown DataType for request " + req);
+ } else {
+ log.warn("Pattern >>" + pattern + "<< did not match for input >>" + value + "<< and request: >>"
+ + req.getName());
+ }
+ } catch (NagiosException e) {
+ log.error(e);
+ }
+ }
+
+ }
+
+ @Override
+ public Set<ResourceType> discoverChildResourceTypes() {
+
+ log.info("<nagiosMonitorComponent>discoverChildResourceTypes called");
+
+ ResourceType parentType = this.context.getResourceType();
+ ResourceType resourceType = new ResourceType("FooBar", parentType.getPlugin(), ResourceCategory.SERVICE,
+ parentType);
+
+ //Create measurement definition for new created ResourceType
+ MeasurementDefinition measurementDef = new MeasurementDefinition(resourceType, resourceType.getName()
+ + "Metric");
+
+ //Add new MeasurementDefinition to the resourceType
+ resourceType.addMetricDefinition(measurementDef);
+
+ Set<ResourceType> resourceTypes = new HashSet<ResourceType>();
+ resourceTypes.add(resourceType);
+
+ return resourceTypes;
+ }
+
+ public void start(ResourceContext context) throws InvalidPluginConfigurationException, Exception {
+ //get context of this component instance
+ this.context = context;
+
+ //get config
+ if (context.getParentResourceComponent() instanceof NagiosMonitorComponent) {
+ NagiosMonitorComponent parent = (NagiosMonitorComponent) context.getParentResourceComponent();
+
+ nagiosHost = parent.getNagiosHost();
+ nagiosPort = parent.getNagiosPort();
+ } else {
+ Configuration conf = context.getPluginConfiguration();
+ nagiosHost = conf.getSimpleValue("nagiosHost", DEFAULT_NAGIOSIP);
+ String tmp = conf.getSimpleValue("nagiosPort", DEFAULT_NAGIOSPORT);
+ nagiosPort = Integer.parseInt(tmp);
+ }
+
+ //Interface class to the nagios system
+ nagiosManagementInterface = new NagiosManagementInterface(nagiosHost, nagiosPort);
+
+ //log.info("nagios Plugin started");
+
+ }
+
+ @Override
+ public void stop() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public AvailabilityType getAvailability() {
+ if (context.getParentResourceComponent() instanceof NagiosMonitorComponent) {
+ return AvailabilityType.UP; // TODO get from parent?
+ } else {
+ boolean available = false;
+ if (nagiosManagementInterface != null)
+ available = nagiosManagementInterface.pingNagios();
+
+ if (available)
+ return AvailabilityType.UP;
+ }
+ return AvailabilityType.DOWN;
+ }
+
+}
diff --git a/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorChildTypeDiscovery.java b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorChildTypeDiscovery.java
new file mode 100755
index 0000000..84ec7e3
--- /dev/null
+++ b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorChildTypeDiscovery.java
@@ -0,0 +1,118 @@
+package org.rhq.plugins.nagios.rhqNagiosPlugin;
+
+/*
+ * 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.
+ */
+
+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.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ManualAddFacet;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.nagios.network.NetworkConnection;
+import org.rhq.plugins.nagios.reply.LqlReply;
+import org.rhq.plugins.nagios.request.LqlResourceTypeRequest;
+
+/**
+ *
+ * @author Alexander Kiefer
+ *
+ */
+public class NagiosMonitorChildTypeDiscovery implements ResourceDiscoveryComponent, ManualAddFacet {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ /**
+ * Don run the auto-discovery for the services below the NagiosMonitor server type.
+ */
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext) throws Exception {
+ Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
+
+ ResourceComponent tmpComponent = discoveryContext.getParentResourceComponent();
+
+ NagiosMonitorComponent parentComponent = (NagiosMonitorComponent) tmpComponent;
+ String nagiosHost = parentComponent.getNagiosHost();
+ int nagiosPort = parentComponent.getNagiosPort();
+
+ //Method requests available nagios services an returns the names of them
+ LqlReply resourceTypeReply = getResourceTypeInformation(nagiosHost, nagiosPort);
+
+ // the resource type we are interested in this invocation
+ ResourceType wanted = discoveryContext.getResourceType();
+ //for each available service
+ for (int i = 0; i < resourceTypeReply.getLqlReply().size(); i++) {
+
+ String nagiosType = resourceTypeReply.getLqlReply().get(i);
+ if (!nagiosType.equals(wanted.getName()))
+ continue;
+
+ //create new DiscoveredResourceDetails instance
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ //new ResourceType instance per service
+ wanted, "nagiosKey@" + "Nr:" + i + ":" + resourceTypeReply.getLqlReply().get(i), "Nagios@" + "Nr:" + i
+ + ":" + resourceTypeReply.getLqlReply().get(i), null, "NagiosService: "
+ + resourceTypeReply.getLqlReply().get(i), null, null);
+
+ //add DiscoveredResourceDetails instance to Set
+ discoveredResources.add(detail);
+ log.info("Discovered a nagios service: " + detail);
+ }
+
+ return discoveredResources;
+ }
+
+ /**
+ * Don't run the auto-discovery of this "nagios" server type,
+ * as we probably won't have one on each platform. Rather have the admin
+ * explicitly add it to one platform.
+ */
+ private LqlReply getResourceTypeInformation(String nagiosIp, int nagiosPort) {
+ LqlResourceTypeRequest resourceTypeRequest = new LqlResourceTypeRequest();
+ LqlReply resourceTypeReply;
+
+ NetworkConnection connection = new NetworkConnection(nagiosIp, nagiosPort);
+ resourceTypeReply = connection.sendAndReceive(resourceTypeRequest);
+
+ return null;
+ }
+
+ @Override
+ public DiscoveredResourceDetails discoverResource(Configuration configuration,
+ ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException {
+
+ String nagiosHost = configuration.getSimpleValue("nagiosHost", NagiosMonitorComponent.DEFAULT_NAGIOSIP);
+ String nagiosPort = configuration.getSimpleValue("nagiosPort", NagiosMonitorComponent.DEFAULT_NAGIOSPORT);
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(resourceDiscoveryContext.getResourceType(),
+ "nagios@" + nagiosHost + ":" + nagiosPort, "Nagios@" + nagiosHost + ":" + nagiosPort, null,
+ "Nagios server @ " + nagiosHost + ":" + nagiosPort, configuration, null);
+ log.info("Adding NagiosMonitor " + detail);
+
+ return detail;
+ }
+
+}
diff --git a/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorComponent.java b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorComponent.java
new file mode 100644
index 0000000..3fa121e
--- /dev/null
+++ b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorComponent.java
@@ -0,0 +1,124 @@
+package org.rhq.plugins.nagios.rhqNagiosPlugin;
+
+/*
+ * 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.
+ */
+
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.plugins.nagios.managementInterface.NagiosManagementInterface;
+
+/**
+ * Plugin Component Class
+ * To make it work you have to change the ip adress and port for your purpose
+ * The metric-, service- and hostnames depend on your nagios system, please make
+ * it sure that they exist and change the plugin descriptor too
+ *
+ * @author Alexander Kiefer
+ */
+public class NagiosMonitorComponent implements ResourceComponent, MeasurementFacet {
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public static final String DEFAULT_NAGIOSIP = "127.0.0.1";
+ public static final String DEFAULT_NAGIOSPORT = "6557";
+
+ private ResourceContext context;
+ private NagiosManagementInterface nagiosManagementInterface;
+ private String nagiosHost;
+ private int nagiosPort;
+
+ /**
+ * Return availability of this resource
+ * @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
+ */
+ public AvailabilityType getAvailability() {
+ if (context.getParentResourceComponent() instanceof NagiosMonitorComponent) {
+ return AvailabilityType.UP; // TODO get from parent?
+ } else {
+ boolean available = false;
+ if (nagiosManagementInterface != null)
+ available = nagiosManagementInterface.pingNagios();
+
+ if (available)
+ return AvailabilityType.UP;
+ }
+ return AvailabilityType.DOWN;
+ }
+
+ /**
+ * Start the resource connection
+ * @see org.rhq.core.pluginapi.inventory.ResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)
+ */
+ public void start(ResourceContext context) throws InvalidPluginConfigurationException, Exception {
+
+ //get context of this component instance
+ this.context = context;
+
+ //get config
+ if (context.getParentResourceComponent() instanceof NagiosMonitorComponent) {
+ NagiosMonitorComponent parent = (NagiosMonitorComponent) context.getParentResourceComponent();
+
+ nagiosHost = parent.getNagiosHost();
+ nagiosPort = parent.getNagiosPort();
+ } else {
+ Configuration conf = context.getPluginConfiguration();
+ nagiosHost = conf.getSimpleValue("nagiosHost", DEFAULT_NAGIOSIP);
+ String tmp = conf.getSimpleValue("nagiosPort", DEFAULT_NAGIOSPORT);
+ nagiosPort = Integer.parseInt(tmp);
+ }
+
+ //Interface class to the nagios system
+ nagiosManagementInterface = new NagiosManagementInterface(nagiosHost, nagiosPort);
+ }
+
+ /**
+ * Tear down the rescource connection
+ * @see org.rhq.core.pluginapi.inventory.ResourceComponent#stop()
+ */
+ public void stop() {
+
+ }
+
+ /**
+ * Gather measurement data
+ * No measurement data for the nagios parent server type needed
+ * everything is done by the NagiosMonitorChildTypeDiscovery/Component classes
+ * @see org.rhq.core.pluginapi.measurement.MeasurementFacet#getValues(org.rhq.core.domain.measurement.MeasurementReport, java.util.Set)
+ */
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) {
+ }
+
+ public String getNagiosHost() {
+ return nagiosHost;
+ }
+
+ public int getNagiosPort() {
+ return nagiosPort;
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorDiscovery.java b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorDiscovery.java
new file mode 100644
index 0000000..e615b19
--- /dev/null
+++ b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/rhqNagiosPlugin/NagiosMonitorDiscovery.java
@@ -0,0 +1,86 @@
+package org.rhq.plugins.nagios.rhqNagiosPlugin;
+
+/*
+ * 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.
+ */
+
+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.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ManualAddFacet;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+/**
+ * Discovery class
+ *
+ *@author Alexander Kiefer
+ */
+public class NagiosMonitorDiscovery implements ResourceDiscoveryComponent, ManualAddFacet {
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ /**
+ * Support manually adding the NagiosMonitor server resource type via Platform's inventory tab
+ * @param configuration Configuration data the user passed in from the UI
+ * @param resourceDiscoveryContext Discovery context from the plugin container
+ * @return Our server type
+ * @throws org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException
+ */
+ public DiscoveredResourceDetails discoverResource(Configuration configuration,
+ ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException {
+
+ DiscoveredResourceDetails detail = createNagiosMonitorServerDetail(configuration, resourceDiscoveryContext);
+ log.info("Adding NagiosMonitor " + detail);
+
+ return detail;
+ }
+
+ /**
+ * Don run the auto-discovery for the services below the NagiosMonitor server type.
+ */
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext) throws Exception {
+ Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
+
+ // If we have no parent, it means the NagiosMonitoring server type is not yet up.
+ ResourceComponent tmpComponent = discoveryContext.getParentResourceComponent();
+
+ // Temporarily allow autodiscovery of NagiosMonitor server type, while RHQ 4 ui work is going on
+ discoveredResources.add(createNagiosMonitorServerDetail(discoveryContext.getDefaultPluginConfiguration(),
+ discoveryContext));
+
+ return discoveredResources;
+ }
+
+ private DiscoveredResourceDetails createNagiosMonitorServerDetail(Configuration configuration,
+ ResourceDiscoveryContext resourceDiscoveryContext) {
+ String nagiosHost = configuration.getSimpleValue("nagiosHost", NagiosMonitorComponent.DEFAULT_NAGIOSIP);
+ String nagiosPort = configuration.getSimpleValue("nagiosPort", NagiosMonitorComponent.DEFAULT_NAGIOSPORT);
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(resourceDiscoveryContext.getResourceType(),
+ "nagios@" + nagiosHost + ":" + nagiosPort, "Nagios@" + nagiosHost + ":" + nagiosPort, null,
+ "Nagios server @ " + nagiosHost + ":" + nagiosPort, configuration, null);
+ return detail;
+ }
+}
\ No newline at end of file
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 31c8b33..932645b 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.rhqNagiosPlugin"
+ package="org.rhq.plugins.nagios.rhqNagiosPlugin"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration"
13 years, 8 months
[rhq] modules/core modules/enterprise
by mazz
modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java | 10
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceTypeTemplateCountComposite.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java | 241 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java | 301 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceTypeGWTService.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java | 13
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Edit_Alert.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Edit_Metric.png |binary
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java | 39 +
10 files changed, 616 insertions(+), 15 deletions(-)
New commits:
commit a0388ba94ee654ee2dbe79a4c47a12ae9941577f
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Oct 20 16:50:20 2010 -0400
the new gwt "templates" admin page. the "edit alert template" and "edit metric template" rollover buttons don't do anything real yet - just pops up a debug window for now
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
index add1a53..e20572f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
@@ -92,16 +92,18 @@ import org.rhq.core.domain.util.Summary;
@NamedQuery(name = ResourceType.FIND_CHILDREN_BY_PARENT, query = "SELECT DISTINCT rt FROM ResourceType AS rt "
+ "JOIN FETCH rt.parentResourceTypes AS pa " + // also fetch parents, as we need them later
"WHERE pa IN (:resourceType)"),
+ // template count composites need the parent types fetched; however, because of a quirk in hibernate,
+ // we can't use the template component constructor in the select, we'll build the composites in our code
@NamedQuery(name = ResourceType.FIND_ALL_TEMPLATE_COUNT_COMPOSITES, query = "" //
- + "SELECT new org.rhq.core.domain.resource.composite.ResourceTypeTemplateCountComposite" //
- + "(" //
+ // + "SELECT new org.rhq.core.domain.resource.composite.ResourceTypeTemplateCountComposite (" //
+ + "SELECT " //
+ " rt," //
+ " (SELECT COUNT(md) FROM MeasurementDefinition AS md WHERE md.resourceType = rt AND md.defaultOn = TRUE), "//
+ " (SELECT COUNT(md) FROM MeasurementDefinition AS md WHERE md.resourceType = rt AND md.defaultOn = FALSE), "//
+ " (SELECT COUNT(ad) FROM AlertDefinition AS ad WHERE ad.resourceType = rt AND ad.deleted = FALSE AND ad.enabled = TRUE), "//
+ " (SELECT COUNT(ad) FROM AlertDefinition AS ad WHERE ad.resourceType = rt AND ad.deleted = FALSE AND ad.enabled = FALSE) "//
- + ")" //
- + "FROM ResourceType AS rt"),
+ // + ")" //
+ + "FROM ResourceType AS rt LEFT JOIN FETCH rt.parentResourceTypes p"),
@NamedQuery(name = ResourceType.QUERY_FIND_BY_CATEGORY, query = "SELECT rt FROM ResourceType AS rt "
+ "WHERE rt.category = :category"),
@NamedQuery(name = ResourceType.QUERY_FIND_UTILIZED_BY_CATEGORY, query = "SELECT DISTINCT res.resourceType "
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceTypeTemplateCountComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceTypeTemplateCountComposite.java
index b2a906f..990acde 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceTypeTemplateCountComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceTypeTemplateCountComposite.java
@@ -31,13 +31,17 @@ public class ResourceTypeTemplateCountComposite implements Serializable, Compara
private static final long serialVersionUID = 1L;
- private final ResourceType type;
- private final long enabledMetricCount;
- private final long disabledMetricCount;
- private final long enabledAlertCount;
- private final long disabledAlertCount;
+ private ResourceType type;
+ private long enabledMetricCount;
+ private long disabledMetricCount;
+ private long enabledAlertCount;
+ private long disabledAlertCount;
private String pluginInfo;
+ // no arg constructor required by gwt
+ protected ResourceTypeTemplateCountComposite() {
+ }
+
public ResourceTypeTemplateCountComposite(ResourceType type, long enabledMetricCount, long disabledMetricCount,
long enabledAlertCount, long disabledAlertCount) {
super();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
index 8c82506..614ac1e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
@@ -39,6 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.admin.agent.install.RemoteAgentInstallView;
import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView;
+import org.rhq.enterprise.gui.coregui.client.admin.templates.ResourceTypeTreeView;
import org.rhq.enterprise.gui.coregui.client.admin.users.UsersView;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
@@ -246,7 +247,7 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable
if (PAGE_SYSTEM_SETTINGS_VIEW_ID.equals(pageName)) {
url = "/admin/config/Config.do?mode=edit";
} else if (PAGE_TEMPLATES_VIEW_ID.equals(pageName)) {
- url = "/admin/config/EditDefaults.do?mode=monitor&viewMode=all";
+ content = new ResourceTypeTreeView(this.extendLocatorId("Templates"));
} else if (PAGE_DOWNLOADS_VIEW_ID.equals(pageName)) {
url = "/rhq/admin/downloads-body.xhtml";
} else if (PAGE_LICENSE_VIEW_ID.equals(pageName)) {
@@ -254,8 +255,10 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable
} else if (PAGE_PLUGINS_VIEW_ID.equals(pageName)) {
url = "/rhq/admin/plugin/plugin-list-plain.xhtml";
}
- url = addQueryStringParam(url, "nomenu=true");
- content = new FullHTMLPane(url);
+ if (url != null) {
+ url = addQueryStringParam(url, "nomenu=true");
+ content = new FullHTMLPane(url);
+ }
} else if (SECTION_TOPOLOGY_VIEW_ID.equals(sectionName)) {
String url = null;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java
new file mode 100644
index 0000000..ec26699
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java
@@ -0,0 +1,241 @@
+/*
+ * 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.admin.templates;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.tree.TreeGrid;
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourceTypeTemplateCountComposite;
+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.ResourceTypeGWTServiceAsync;
+
+/**
+ * @author Greg Hinkle
+ * @author John Mazzitelli
+ */
+public class ResourceTypeTreeNodeBuilder {
+
+ public static final String ATTRIB_ID = "id";
+ public static final String ATTRIB_PARENT_ID = "parentId";
+ public static final String ATTRIB_NAME = "name";
+ public static final String ATTRIB_PLUGIN = "plugin";
+ public static final String ATTRIB_CATEGORY = "category";
+ public static final String ATTRIB_ENABLED_METRIC_TEMPLATES = "enabledMetricTemplates";
+ public static final String ATTRIB_DISABLED_METRIC_TEMPLATES = "disabledMetricTemplates";
+ public static final String ATTRIB_ENABLED_ALERT_TEMPLATES = "enabledAlertTemplates";
+ public static final String ATTRIB_DISABLED_ALERT_TEMPLATES = "disabledAlertTemplates";
+
+ public ResourceTypeTreeNodeBuilder(final ListGrid platformsGrid, final ListGrid platformServicesGrid,
+ final TreeGrid serversGrid) {
+ ResourceTypeGWTServiceAsync resourceTypeService = GWTServiceLookup.getResourceTypeGWTService();
+
+ resourceTypeService
+ .getTemplateCountCompositeMap(new AsyncCallback<Map<Integer, ResourceTypeTemplateCountComposite>>() {
+
+ @Override
+ public void onSuccess(Map<Integer, ResourceTypeTemplateCountComposite> result) {
+ HashSet<ResourceTypeListGridRecord> platformsRecords;
+ HashSet<ResourceTypeListGridRecord> platformServicesRecords;
+ HashSet<ResourceTypeTreeNode> treeNodes;
+
+ platformsRecords = new HashSet<ResourceTypeListGridRecord>();
+ platformServicesRecords = new HashSet<ResourceTypeListGridRecord>();
+ treeNodes = new HashSet<ResourceTypeTreeNode>();
+
+ for (ResourceTypeTemplateCountComposite composite : result.values()) {
+ ResourceType type = composite.getType();
+ Set<ResourceType> parentTypes = type.getParentResourceTypes();
+ if (isEmpty(parentTypes)) {
+ if (type.getCategory() == ResourceCategory.PLATFORM) {
+ // no parents but is a platform - these are our main, top-level platforms
+ platformsRecords.add(new ResourceTypeListGridRecord(composite));
+ } else {
+ // no parents but not a platform - these are our top-level servers
+ treeNodes.add(new ResourceTypeTreeNode(composite, type.getPlugin()));
+ }
+ } else {
+ // has parents; if all the direct parents are top level platforms
+ // and the category is service, consider it a "special" platform service
+ boolean isPlatformService = true; // assume its one, unless one of its parents is not a top level platform
+ if (type.getCategory() == ResourceCategory.SERVICE) {
+ for (ResourceType parentType : parentTypes) {
+ // if one of its parents is not a platform or one of its parent has parents itself,
+ // then this is not a platform service
+ if ((parentType.getCategory() != ResourceCategory.PLATFORM)
+ || !isEmpty(parentType.getParentResourceTypes())) {
+ isPlatformService = false;
+ break;
+ }
+ }
+ } else {
+ isPlatformService = false; // can't be a platform service, its not in the SERVICE category
+ }
+
+ if (isPlatformService) {
+ platformServicesRecords.add(new ResourceTypeListGridRecord(composite));
+ } else {
+ // in some cases, a top level server is limited to which platforms it can run on.
+ // therefore, the parents will not be null/empty (as would be the case if the top level
+ // server can run on ALL platforms), but instead it will have the subset of platforms
+ // the type is valid on. But its the same type - so we only want to show it once. Therefore,
+ // once we see a parent that is a top level platform, we don't add the type again for other
+ // top level platforms. That's what gotPlatform boolean tracks.
+ boolean gotPlatform = false;
+ for (ResourceType parentType : type.getParentResourceTypes()) {
+ boolean isPlatform = (parentType.getCategory() == ResourceCategory.PLATFORM && isEmpty(parentType
+ .getParentResourceTypes()));
+ if (!isPlatform || !gotPlatform) {
+ treeNodes.add(new ResourceTypeTreeNode(composite, String.valueOf(parentType
+ .getId())));
+ }
+ if (isPlatform) {
+ gotPlatform = true;
+ }
+ }
+ }
+ }
+ }
+
+ platformsGrid.setData(platformsRecords.toArray(new ListGridRecord[platformsRecords.size()]));
+ platformServicesGrid.setData(platformServicesRecords
+ .toArray(new ListGridRecord[platformServicesRecords.size()]));
+ serversGrid.getTree().linkNodes(treeNodes.toArray(new TreeNode[treeNodes.size()]));
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load resource types", caught);
+ }
+ });
+ }
+
+ private boolean isEmpty(Set<ResourceType> set) {
+ return set == null || set.isEmpty();
+ }
+
+ public static class ResourceTypeListGridRecord extends ListGridRecord {
+
+ private ResourceType resourceType;
+
+ private ResourceTypeListGridRecord(ResourceTypeTemplateCountComposite composite) {
+ this.resourceType = composite.getType();
+
+ setAttribute(ATTRIB_ID, String.valueOf(resourceType.getId()));
+ setAttribute(ATTRIB_NAME, resourceType.getName());
+ setAttribute(ATTRIB_PLUGIN, resourceType.getPlugin());
+ setAttribute(ATTRIB_CATEGORY, resourceType.getCategory().getDisplayName());
+ setAttribute(ATTRIB_ENABLED_ALERT_TEMPLATES, composite.getEnabledAlertCount());
+ setAttribute(ATTRIB_DISABLED_ALERT_TEMPLATES, composite.getDisabledAlertCount());
+ setAttribute(ATTRIB_ENABLED_METRIC_TEMPLATES, composite.getEnabledMetricCount());
+ setAttribute(ATTRIB_DISABLED_METRIC_TEMPLATES, composite.getDisabledMetricCount());
+ }
+
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof ResourceTypeTreeNode)) {
+ return false;
+ }
+ return (this.resourceType.getId() == ((ResourceTypeTreeNode) o).resourceType.getId());
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * resourceType.getId();
+ }
+ }
+
+ public static class ResourceTypeTreeNode extends TreeNode {
+
+ private ResourceType resourceType;
+ private String id;
+ private String parentId;
+
+ private ResourceTypeTreeNode(ResourceTypeTemplateCountComposite composite, String parentId) {
+ this.resourceType = composite.getType();
+
+ String id = String.valueOf(resourceType.getId());
+ setID(id);
+ this.id = id;
+
+ setParentID(parentId);
+ this.parentId = parentId;
+
+ setAttribute(ATTRIB_ID, id);
+ setAttribute(ATTRIB_PARENT_ID, parentId);
+ setAttribute(ATTRIB_NAME, resourceType.getName());
+ setAttribute(ATTRIB_PLUGIN, resourceType.getPlugin());
+ setAttribute(ATTRIB_CATEGORY, resourceType.getCategory().getDisplayName());
+ setAttribute(ATTRIB_ENABLED_ALERT_TEMPLATES, composite.getEnabledAlertCount());
+ setAttribute(ATTRIB_DISABLED_ALERT_TEMPLATES, composite.getDisabledAlertCount());
+ setAttribute(ATTRIB_DISABLED_METRIC_TEMPLATES, composite.getEnabledMetricCount());
+ setAttribute(ATTRIB_ENABLED_METRIC_TEMPLATES, composite.getDisabledMetricCount());
+
+ setIsFolder(true);
+ }
+
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof ResourceTypeTreeNode)) {
+ return false;
+ }
+
+ ResourceTypeTreeNode that = (ResourceTypeTreeNode) o;
+
+ if (!this.id.equals(that.id)) {
+ return false;
+ }
+ if (this.parentId == null) {
+ return that.parentId == null;
+ }
+ return this.parentId.equals(that.parentId);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 31;
+ result = result * id.hashCode();
+ result = result + (parentId != null ? parentId.hashCode() : 0);
+ return result;
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
new file mode 100644
index 0000000..6e2047d
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
@@ -0,0 +1,301 @@
+/*
+ * 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.admin.templates;
+
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.VisibilityMode;
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.ImgButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.SectionStack;
+import com.smartgwt.client.widgets.layout.SectionStackSection;
+import com.smartgwt.client.widgets.tree.TreeGrid;
+import com.smartgwt.client.widgets.tree.TreeGridField;
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Greg Hinkle
+ * @author John Mazzitelli
+ */
+public class ResourceTypeTreeView extends LocatableVLayout {
+
+ public ResourceTypeTreeView(String locatorId) {
+ super(locatorId);
+
+ setWidth100();
+ setHeight100();
+
+ SectionStack sectionStack = new SectionStack();
+ sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE);
+
+ ListGrid platformsList = new CustomResourceTypeListGrid(extendLocatorId("platformsList"));
+ SectionStackSection platforms = new SectionStackSection("Platforms");
+ platforms.setExpanded(true);
+ platforms.addItem(platformsList);
+
+ ListGrid platformServicesList = new CustomResourceTypeListGrid(extendLocatorId("platformServicesList"));
+ SectionStackSection platformServices = new SectionStackSection("Platform Services");
+ platformServices.setExpanded(true);
+ platformServices.addItem(platformServicesList);
+
+ TreeGrid serversTreeGrid = new CustomResourceTypeTreeGrid(extendLocatorId("serversTree"));
+ SectionStackSection servers = new SectionStackSection("Servers");
+ servers.setExpanded(true);
+ servers.addItem(serversTreeGrid);
+
+ sectionStack.addSection(platforms);
+ sectionStack.addSection(platformServices);
+ sectionStack.addSection(servers);
+
+ addMember(sectionStack);
+
+ new ResourceTypeTreeNodeBuilder(platformsList, platformServicesList, serversTreeGrid);
+ }
+
+ public static class CustomResourceTypeListGrid extends LocatableListGrid {
+ private HLayout rollOverCanvas;
+ private ListGridRecord rollOverRecord;
+
+ public CustomResourceTypeListGrid(String locatorId) {
+ super(locatorId);
+
+ setWrapCells(true);
+ setFixedRecordHeights(false);
+ setShowRollOverCanvas(true);
+ setEmptyMessage("Loading...");
+
+ final ListGridField name = new ListGridField(ResourceTypeTreeNodeBuilder.ATTRIB_NAME, "Name");
+ final ListGridField plugin = new ListGridField(ResourceTypeTreeNodeBuilder.ATTRIB_PLUGIN, "Plugin");
+ final ListGridField category = new ListGridField(ResourceTypeTreeNodeBuilder.ATTRIB_CATEGORY, "Category");
+ final ListGridField enabledAlertTemplates = new ListGridField(
+ ResourceTypeTreeNodeBuilder.ATTRIB_ENABLED_ALERT_TEMPLATES, "Enabled Alert Templates");
+ final ListGridField disabledAlertTemplates = new ListGridField(
+ ResourceTypeTreeNodeBuilder.ATTRIB_DISABLED_ALERT_TEMPLATES, "Disabled Alert Templates");
+ final ListGridField enabledMetricTemplates = new ListGridField(
+ ResourceTypeTreeNodeBuilder.ATTRIB_ENABLED_METRIC_TEMPLATES, "Enabled Metric Templates");
+ final ListGridField disabledMetricTemplates = new ListGridField(
+ ResourceTypeTreeNodeBuilder.ATTRIB_DISABLED_METRIC_TEMPLATES, "Disabled Metric Templates");
+
+ plugin.setHidden(true);
+ category.setHidden(true);
+
+ name.setWidth("40%");
+ plugin.setWidth("10%");
+ category.setWidth("10%");
+ enabledAlertTemplates.setWidth("10%");
+ disabledAlertTemplates.setWidth("10%");
+ enabledMetricTemplates.setWidth("10%");
+ disabledMetricTemplates.setWidth("10%");
+
+ enabledAlertTemplates.setPrompt("Number of alert templates that are enabled on this resource type");
+ disabledAlertTemplates
+ .setPrompt("Number of alert templates that are created but disabled on this resource type");
+ enabledMetricTemplates
+ .setPrompt("Number of metric schedules that are enabled by default on this resource type");
+ disabledMetricTemplates
+ .setPrompt("Number of metric schedules that are disabled by default on this resource type");
+
+ setFields(name, plugin, category, enabledAlertTemplates, disabledAlertTemplates, enabledMetricTemplates,
+ disabledMetricTemplates);
+ }
+
+ @Override
+ protected Canvas getRollOverCanvas(Integer rowNum, Integer colNum) {
+ rollOverRecord = this.getRecord(rowNum);
+
+ if (rollOverCanvas == null) {
+ rollOverCanvas = new HLayout(3);
+ rollOverCanvas.setSnapTo("TR");
+ rollOverCanvas.setWidth(50);
+ rollOverCanvas.setHeight(22);
+
+ ImgButton metricTemplateImg = new ImgButton();
+ metricTemplateImg.setShowDown(false);
+ metricTemplateImg.setShowRollOver(false);
+ metricTemplateImg.setLayoutAlign(Alignment.CENTER);
+ metricTemplateImg.setSrc("subsystems/monitor/Edit_Metric.png");
+ metricTemplateImg.setPrompt("Edit Metric Template");
+ metricTemplateImg.setHeight(16);
+ metricTemplateImg.setWidth(16);
+ metricTemplateImg.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ // http://localhost:7080/admin/platform/monitor/Config.do?nomenu=true&mode=c...
+ SC.say("Metric Template: "
+ + rollOverRecord.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_NAME) + "==>"
+ + rollOverRecord.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_PLUGIN) + "==>"
+ + rollOverRecord.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_ID));
+ }
+ });
+
+ ImgButton alertTemplateImg = new ImgButton();
+ alertTemplateImg.setShowDown(false);
+ alertTemplateImg.setShowRollOver(false);
+ alertTemplateImg.setLayoutAlign(Alignment.CENTER);
+ alertTemplateImg.setSrc("subsystems/alert/Edit_Alert.png");
+ alertTemplateImg.setPrompt("Edit Alert Template");
+ alertTemplateImg.setHeight(16);
+ alertTemplateImg.setWidth(16);
+ alertTemplateImg.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ SC.say("Alert Template : "
+ + rollOverRecord.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_NAME) + "==>"
+ + rollOverRecord.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_PLUGIN) + "==>"
+ + rollOverRecord.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_ID));
+ }
+ });
+
+ rollOverCanvas.addMember(metricTemplateImg);
+ rollOverCanvas.addMember(alertTemplateImg);
+ }
+ return rollOverCanvas;
+ }
+ }
+
+ public static class CustomResourceTypeTreeGrid extends LocatableTreeGrid {
+ private HLayout rollOverCanvas;
+ private ListGridRecord rollOverRecord;
+
+ public CustomResourceTypeTreeGrid(String locatorId) {
+ super(locatorId);
+
+ setWrapCells(true);
+ setFixedRecordHeights(false);
+ setShowRollOverCanvas(true);
+ setEmptyMessage("Loading...");
+ setAnimateFolders(false);
+
+ final TreeGridField name = new TreeGridField(ResourceTypeTreeNodeBuilder.ATTRIB_NAME, "Name");
+ final TreeGridField plugin = new TreeGridField(ResourceTypeTreeNodeBuilder.ATTRIB_PLUGIN, "Plugin");
+ final TreeGridField category = new TreeGridField(ResourceTypeTreeNodeBuilder.ATTRIB_CATEGORY, "Category");
+ final TreeGridField enabledAlertTemplates = new TreeGridField(
+ ResourceTypeTreeNodeBuilder.ATTRIB_ENABLED_ALERT_TEMPLATES, "Enabled Alert Templates");
+ final TreeGridField disabledAlertTemplates = new TreeGridField(
+ ResourceTypeTreeNodeBuilder.ATTRIB_DISABLED_ALERT_TEMPLATES, "Disabled Alert Templates");
+ final TreeGridField enabledMetricTemplates = new TreeGridField(
+ ResourceTypeTreeNodeBuilder.ATTRIB_ENABLED_METRIC_TEMPLATES, "Enabled Metric Templates");
+ final TreeGridField disabledMetricTemplates = new TreeGridField(
+ ResourceTypeTreeNodeBuilder.ATTRIB_DISABLED_METRIC_TEMPLATES, "Disabled Metric Templates");
+
+ name.setWidth("40%");
+ plugin.setWidth("10%");
+ category.setWidth("10%");
+ enabledAlertTemplates.setWidth("10%");
+ disabledAlertTemplates.setWidth("10%");
+ enabledMetricTemplates.setWidth("10%");
+ disabledMetricTemplates.setWidth("10%");
+
+ enabledAlertTemplates.setPrompt("Number of alert templates that are enabled on this resource type");
+ disabledAlertTemplates
+ .setPrompt("Number of alert templates that are created but disabled on this resource type");
+ enabledMetricTemplates
+ .setPrompt("Number of metric schedules that are enabled by default on this resource type");
+ disabledMetricTemplates
+ .setPrompt("Number of metric schedules that are disabled by default on this resource type");
+
+ setFields(name, plugin, category, enabledAlertTemplates, disabledAlertTemplates, enabledMetricTemplates,
+ disabledMetricTemplates);
+ }
+
+ @Override
+ protected Canvas getRollOverCanvas(Integer rowNum, Integer colNum) {
+ rollOverRecord = this.getRecord(rowNum);
+
+ if (rollOverCanvas == null) {
+ rollOverCanvas = new HLayout(3);
+ rollOverCanvas.setSnapTo("TR");
+ rollOverCanvas.setWidth(50);
+ rollOverCanvas.setHeight(22);
+
+ ImgButton metricTemplateImg = new ImgButton();
+ metricTemplateImg.setShowDown(false);
+ metricTemplateImg.setShowRollOver(false);
+ metricTemplateImg.setLayoutAlign(Alignment.CENTER);
+ metricTemplateImg.setSrc("subsystems/monitor/Edit_Metric.png");
+ metricTemplateImg.setPrompt("Edit Metric Template");
+ metricTemplateImg.setHeight(16);
+ metricTemplateImg.setWidth(16);
+ metricTemplateImg.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ // http://localhost:7080/admin/platform/monitor/Config.do?nomenu=true&mode=c...
+ SC.say("Metric Template: "
+ + rollOverRecord.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_NAME) + "==>"
+ + rollOverRecord.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_PLUGIN) + "==>"
+ + rollOverRecord.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_ID));
+ }
+ });
+
+ ImgButton alertTemplateImg = new ImgButton();
+ alertTemplateImg.setShowDown(false);
+ alertTemplateImg.setShowRollOver(false);
+ alertTemplateImg.setLayoutAlign(Alignment.CENTER);
+ alertTemplateImg.setSrc("subsystems/alert/Edit_Alert.png");
+ alertTemplateImg.setPrompt("Edit Alert Template");
+ alertTemplateImg.setHeight(16);
+ alertTemplateImg.setWidth(16);
+ alertTemplateImg.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ SC.say("Alert Template : "
+ + rollOverRecord.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_NAME) + "==>"
+ + rollOverRecord.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_PLUGIN) + "==>"
+ + rollOverRecord.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_ID));
+ }
+ });
+
+ rollOverCanvas.addMember(metricTemplateImg);
+ rollOverCanvas.addMember(alertTemplateImg);
+ }
+ return rollOverCanvas;
+ }
+
+ @Override
+ protected String getIcon(Record record, boolean defaultState) {
+
+ if (record instanceof TreeNode) {
+ if (record instanceof ResourceTypeTreeNodeBuilder.ResourceTypeTreeNode) {
+ ResourceType resourceType = ((ResourceTypeTreeNodeBuilder.ResourceTypeTreeNode) record)
+ .getResourceType();
+
+ switch (resourceType.getCategory()) {
+ case PLATFORM:
+ return "types/Platform_up_16.png";
+ case SERVER:
+ return "types/Server_up_16.png";
+ case SERVICE:
+ return "types/Service_up_16.png";
+ }
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceTypeGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceTypeGWTService.java
index e2eeb96..9d4e471 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceTypeGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceTypeGWTService.java
@@ -2,12 +2,14 @@ package org.rhq.enterprise.gui.coregui.client.gwt;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Map;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourceTypeTemplateCountComposite;
import org.rhq.core.domain.util.PageList;
@RemoteServiceRelativePath("ResourceTypeGWTService")
@@ -20,4 +22,6 @@ public interface ResourceTypeGWTService extends RemoteService {
ArrayList<ResourceType> getAllResourceTypeAncestors(int resourceTypeId);
HashMap<Integer, String> getResourceTypeDescendantsWithOperations(int resourceTypeId);
+
+ Map<Integer, ResourceTypeTemplateCountComposite> getTemplateCountCompositeMap();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
index be25a0b..5cffd24 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
@@ -3,10 +3,12 @@ package org.rhq.enterprise.gui.coregui.server.gwt;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ResourceLineageComposite;
+import org.rhq.core.domain.resource.composite.ResourceTypeTemplateCountComposite;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTService;
@@ -72,4 +74,15 @@ public class ResourceTypeGWTServiceImpl extends AbstractGWTServiceImpl implement
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
}
+
+ @Override
+ public Map<Integer, ResourceTypeTemplateCountComposite> getTemplateCountCompositeMap() {
+ try {
+ ResourceTypeManagerLocal typeManager = LookupUtil.getResourceTypeManager();
+ Map<Integer, ResourceTypeTemplateCountComposite> map = typeManager.getTemplateCountCompositeMap();
+ return SerialUtility.prepare(map, "ResourceTypes.getTemplateCountCompositeMap");
+ } 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/images/subsystems/alert/Edit_Alert.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Edit_Alert.png
new file mode 100644
index 0000000..cecb563
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Edit_Alert.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Edit_Metric.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Edit_Metric.png
new file mode 100644
index 0000000..6e3de53
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/monitor/Edit_Metric.png differ
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java
index 1837023..034cd6e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java
@@ -394,12 +394,45 @@ public class ResourceTypeManagerBean implements ResourceTypeManagerLocal, Resour
@SuppressWarnings("unchecked")
public Map<Integer, ResourceTypeTemplateCountComposite> getTemplateCountCompositeMap() {
Query templateCountQuery = entityManager.createNamedQuery(ResourceType.FIND_ALL_TEMPLATE_COUNT_COMPOSITES);
- List<ResourceTypeTemplateCountComposite> composites = templateCountQuery.getResultList();
+ // the weirdness here is because we needed to JOIN FETCH the parent types, but hibernate bombs when you do that
+ // and try to use a composite constructor in the query itself. We need to build the composites here.
+ // Our results will be a list of arrays that we'll build into the composite below
+ List<?> results = templateCountQuery.getResultList();
+
+ // we don't need to send all the data in resource types over the wire, so we'll be scrubbing the types
+ // to avoid the scrubbed types getting persisted back to the db, let's clear the persistence context
+ entityManager.clear();
Map<Integer, ResourceTypeTemplateCountComposite> compositeMap = new HashMap<Integer, ResourceTypeTemplateCountComposite>();
- for (ResourceTypeTemplateCountComposite next : composites) {
- compositeMap.put(next.getType().getId(), next);
+ for (Object result : results) {
+ Object[] array = (Object[]) result;
+
+ ResourceType type = (ResourceType) array[0];
+
+ // scrub it to avoid sending data over the wire we don't need
+ // some of these are eagerly loaded, but my paranoia says assume everything is eagerly loaded to purge it all
+ type.setBundleType(null);
+ type.setChildResourceTypes(null);
+ type.setChildSubCategories(null);
+ type.setClassLoaderType(null);
+ type.setEventDefinitions(null);
+ type.setMetricDefinitions(null);
+ type.setOperationDefinitions(null);
+ type.setPackageTypes(null);
+ type.setPluginConfigurationDefinition(null);
+ type.setProcessScans(null);
+ type.setProductVersions(null);
+ type.setResourceConfigurationDefinition(null);
+ type.setResourceGroups(null);
+ type.setResources(null);
+ type.setSubCategory(null);
+
+ ResourceTypeTemplateCountComposite composite = new ResourceTypeTemplateCountComposite(type,
+ ((Number) array[1]).longValue(), ((Number) array[2]).longValue(), ((Number) array[3]).longValue(),
+ ((Number) array[4]).longValue());
+ compositeMap.put(composite.getType().getId(), composite);
}
+
return compositeMap;
}
13 years, 8 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java | 2 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java | 2 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java | 2 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java | 15 ++++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java | 2 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java | 8 ++---
modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css | 2 -
7 files changed, 18 insertions(+), 15 deletions(-)
New commits:
commit ae8dfb3eaa8512174d536795aa3f17f5ba2e444b
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Oct 20 15:05:40 2010 -0400
fix a bug i introduced earlier today that was causing the group list views to fail to display; make titles of group list views prettier (separate words rather than camel case)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
index e198fc0..4583a4a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
@@ -89,7 +89,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
if (isAggregateProperty(propertySimple)) {
// Create the "MEMBER VALUES DIFFER" label that is displayed when member values are heterogeneous.
final StaticTextItem staticItem = new StaticTextItem();
- staticItem.setValue("MEMBER VALUES DIFFER");
+ staticItem.setValue("member values differ");
staticItem.setTextBoxStyle("InlineNote");
staticItem.setShowTitle(false);
staticItem.setTooltip("Member values differ - click icon to edit them.");
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 bdb1160..92fc25d 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
@@ -166,7 +166,7 @@ public class GWTServiceLookup {
String sessionId = UserSessionManager.getSessionId();
if (sessionId != null) {
- Log.info("SessionRpcRequestBuilder is adding sessionId to request: " + sessionId);
+ Log.debug("SessionRpcRequestBuilder is adding sessionId to request: " + sessionId);
rb.setHeader(UserSessionManager.SESSION_NAME, sessionId);
} else {
Log.error("SessionRpcRequestBuilder constructed without a value for " + UserSessionManager.SESSION_NAME);
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 2b5097f..b2fea0a 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
@@ -157,7 +157,7 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
record.setAttribute("id", from.getResourceGroup().getId());
record.setAttribute("name", from.getResourceGroup().getName());
record.setAttribute("description", from.getResourceGroup().getDescription());
- record.setAttribute("category", from.getResourceGroup().getGroupCategory());
+ record.setAttribute("category", from.getResourceGroup().getGroupCategory().name());
record.setAttribute("explicitUp", String.valueOf(from.getExplicitUp()));
record.setAttribute("explicitDown", String.valueOf(from.getExplicitDown()));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
index 6aa4e65..32aabb0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
@@ -26,6 +26,7 @@ import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -65,8 +66,10 @@ public class ResourceGroupListView extends Table {
protected void configureTable() {
ListGridField nameField = new ListGridField("name", "Name", 300);
nameField.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- return "<a href=\"#ResourceGroup/" + listGridRecord.getAttribute("id") + "\">" + o + "</a>";
+ public String format(Object value, ListGridRecord record, int i, int i1) {
+ String groupId = record.getAttribute("id");
+ String groupUrl = LinkManager.getResourceGroupLink(Integer.valueOf(groupId));
+ return "<a href=\"" + groupUrl + "\">" + value + "</a>";
}
});
@@ -79,12 +82,12 @@ public class ResourceGroupListView extends Table {
availabilityChildrenField.setWrap(false);
availabilityChildrenField.setAlign(Alignment.CENTER);
- ListGridField availabilityDescendentsField = new ListGridField("availabilityDescendents", "Descendents", 100);
- availabilityDescendentsField.setWrap(false);
- availabilityDescendentsField.setAlign(Alignment.CENTER);
+ ListGridField availabilityDescendantsField = new ListGridField("availabilityDescendents", "Descendants", 100);
+ availabilityDescendantsField.setWrap(false);
+ availabilityDescendantsField.setAlign(Alignment.CENTER);
getListGrid().setFields(nameField, descriptionField, typeNameField, pluginNameField, categoryField,
- availabilityChildrenField, availabilityDescendentsField);
+ availabilityChildrenField, availabilityDescendantsField);
addTableAction(extendLocatorId("Delete"), "Delete", Table.SelectionEnablement.ANY,
"Delete the selected resource groups?", new TableAction() {
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 e0778bb..3f6e197 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
@@ -152,7 +152,7 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
record.setAttribute("id", from.getId());
record.setAttribute("name", from.getName());
record.setAttribute("description", from.getDescription());
- record.setAttribute("category", from.getGroupCategory());
+ record.setAttribute("category", from.getGroupCategory().name());
if (from.getResourceType() != null) {
record.setAttribute("resourceType", from.getResourceType());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index fcef030..dee71d2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -266,19 +266,19 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
} else if (GROUPS_SECTION_VIEW_ID.equals(sectionName)) {
if (PAGE_COMPATIBLE_GROUPS.equals(pageName)) {
content = new ResourceGroupListView(extendLocatorId("Compatible"), new Criteria("category",
- GroupCategory.COMPATIBLE.name()), PAGE_COMPATIBLE_GROUPS, "types/Cluster_up_24.png");
+ GroupCategory.COMPATIBLE.name()), "Compatible Groups", "types/Cluster_up_24.png");
} else if (PAGE_MIXED_GROUPS.equals(pageName)) {
content = new ResourceGroupListView(extendLocatorId("Mixed"), new Criteria("category",
- GroupCategory.MIXED.name()), PAGE_MIXED_GROUPS, "types/Group_up_24.png");
+ GroupCategory.MIXED.name()), "Mixed Groups", "types/Group_up_24.png");
} else if (PAGE_GROUP_DEFINITIONS.equals(pageName)) {
content = new GroupDefinitionListView(extendLocatorId("Definitions"), "types/GroupDefinition_16.png");
} else if (PAGE_PROBLEM_GROUPS.equals(pageName)) {
//TODO - there is no underlying support for this criteria. Also, there should not be an active
// new button on this page.
content = new ResourceGroupListView(extendLocatorId("DownGroups"),
- new Criteria("availability", "down"), PAGE_PROBLEM_GROUPS, "types/Cluster_down_16.png");
+ new Criteria("availability", "down"), "Problem Groups", "types/Cluster_down_16.png");
} else { // selected the Inventory node itself
- content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, PAGE_GROUPS,
+ content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, "All Groups",
"types/Cluster_up_24.png", "types/Group_up_24.png");
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
index d60a616..0c5c221 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
+++ b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
@@ -387,7 +387,7 @@ a:hover {
}
.InlineNote {
- color: #511;
+ color: #C22;
}
.log-panel {
13 years, 8 months
[rhq] Branch 'gwt-ldap' - modules/enterprise
by Joseph Marques
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
New commits:
commit e19fff4cb308169c6972769598f1e23bb3e67b05
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Oct 20 13:02:11 2010 -0400
consolidation of form items into a single DynamicForm for ldap user registration
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 ef1c18c..e5d202e 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
@@ -207,7 +207,6 @@ public class LoginView extends Canvas {
header
.setValue("Welcome to JBoss ON! <br/><br/> Enter/update the following fields to complete your registration process."
+ "<br/> Once you click \"OK\" you will be logged in.<br/><br/>");
- column.addMember(wrapInDynamicForm(1, header));
//build ui elements for registration screen
first = new TextItem(FIRST, "First Name");
{
@@ -238,7 +237,7 @@ public class LoginView extends Canvas {
department.setWidth(fieldWidth);
SpacerItem space = new SpacerItem();
space.setColSpan(1);
- column.addMember(wrapInDynamicForm(6, first, last, username, email, phone, department));
+ column.addMember(wrapInDynamicForm(6, header, first, last, username, email, phone, department));
HTMLFlow hr = new HTMLFlow("<br/><hr/><br/><br/>");
hr.setWidth(750);
hr.setAlign(Alignment.CENTER);
13 years, 8 months
[rhq] Branch 'gwt-ldap' - modules/enterprise
by Joseph Marques
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 39280cec639b1e8be47318cdcdd28ca27a6eaa4f
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Oct 20 12:26:49 2010 -0400
small fix to the logout() method logic
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 8ad6016..06c8604 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
@@ -307,7 +307,7 @@ public class UserSessionManager {
}
public static void logout() {
- if (!isLoggedIn()) {
+ if (isLoggedOut()) {
return; // nothing to do, already called
}
13 years, 8 months
[rhq] Branch 'gwt-ldap' - modules/enterprise
by Joseph Marques
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java | 27 +-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java | 43 ++++------
2 files changed, 26 insertions(+), 44 deletions(-)
New commits:
commit 6eaf988abf1e4d2f485e1b24aba13813deacbe47
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Oct 20 12:24:41 2010 -0400
some LDAP fixes / enhancements:
* use less calls to wrapInDynamicForm, which aligns the form items
* use a tri-boolean variable to represent client-side session state
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 03e46e1..ef1c18c 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
@@ -185,6 +185,7 @@ 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);
@@ -226,7 +227,7 @@ public class LoginView extends Canvas {
username.setDisabled(true);
username.setWidth(fieldWidth);
- column.addMember(wrapInDynamicForm(6, first, last, username));
+ //column.addMember(wrapInDynamicForm(6, first, last, username));
}
email = new TextItem(EMAIL, "Email");
email.setRequired(true);
@@ -237,7 +238,7 @@ public class LoginView extends Canvas {
department.setWidth(fieldWidth);
SpacerItem space = new SpacerItem();
space.setColSpan(1);
- column.addMember(wrapInDynamicForm(6, email, phone, department));
+ column.addMember(wrapInDynamicForm(6, first, last, username, email, phone, department));
HTMLFlow hr = new HTMLFlow("<br/><hr/><br/><br/>");
hr.setWidth(750);
hr.setAlign(Alignment.CENTER);
@@ -250,7 +251,7 @@ public class LoginView extends Canvas {
okButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
//check for session timeout
- if (isSessionStale()) {
+ if (UserSessionManager.isLoggedOut()) {
resetLogin();
}
@@ -308,7 +309,7 @@ public class LoginView extends Canvas {
IButton resetButton = new IButton("Reset");
resetButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
- if (isSessionStale()) {
+ if (UserSessionManager.isLoggedOut()) {
resetLogin();
}
@@ -332,6 +333,7 @@ public class LoginView extends Canvas {
IButton logout = new IButton("Logout");
logout.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
+ UserSessionManager.logout();
resetLogin();
}
});
@@ -379,28 +381,11 @@ public class LoginView extends Canvas {
/** 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 71c62b8..8ad6016 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
@@ -58,12 +58,17 @@ public class UserSessionManager {
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;
- private static boolean loggedIn = false;
+ private enum State {
+ IS_LOGGED_IN, //
+ IS_REGISTERING, //
+ IS_LOGGED_OUT;
+ }
+
+ private static State sessionState = State.IS_LOGGED_OUT;
private static Timer sessionTimer = new Timer() {
@Override
public void run() {
@@ -101,7 +106,6 @@ 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);
@@ -165,6 +169,7 @@ public class UserSessionManager {
public void onSuccess(Subject checked) {
//now pull the flags/information back out of this subject
if (checked == null) {//no new subject was returned.
+ // also handles case where user is JDBC-based
Log.trace("No alternative case insensitive LDAP accounts located.");
locateSubjectOrLogin(subjectId, sessionId, user, password, callback);
} else {//alternative Subject returned meaning we located
@@ -179,7 +184,7 @@ public class UserSessionManager {
}
});
} else {//invalid session. Back to login
- loggedIn = false;
+ sessionState = State.IS_LOGGED_OUT;
new LoginView().showLoginDialog();
}
}
@@ -240,6 +245,7 @@ public class UserSessionManager {
});
} else {
Log.trace("Proceeding with registration for ldap user '" + user + "'.");
+ sessionState = State.IS_REGISTERING;
new LoginView().showRegistrationDialog(user, sessionId, password, callback);
}
}
@@ -257,7 +263,7 @@ public class UserSessionManager {
checkLoginStatus(user, password, new AsyncCallback<Subject>() {
public void onSuccess(Subject result) {
// will build UI if necessary, then fires history event
- loggedIn = true;
+ sessionState = State.IS_LOGGED_IN;
if (result != null) {// subject and session has been updated during this login request
Log.trace("A new subject and session has been returned. Updating sessionSubject.");
sessionSubject = result;
@@ -295,26 +301,17 @@ public class UserSessionManager {
logoutTimer.cancel();
// now continue with the rest of the login logic
- loggedIn = true;
+ sessionState = State.IS_LOGGED_IN;
Log.info("Refreshing session timer...");
sessionTimer.schedule(millis);
}
public static void logout() {
- if (!loggedIn) {
+ if (!isLoggedIn()) {
return; // nothing to do, already called
}
- invalidateSession();
- }
-
- /** There are times when you're logged in but you don't want the application to proceed as if you are.
- * In these cases, like LDAP new user registration, the session only needs
- * to be invalidated to reset the user back to the beginning.
- */
- public static void invalidateSession() {
-
- loggedIn = false;
+ sessionState = State.IS_LOGGED_OUT;
Log.info("Destroying session timer...");
sessionTimer.cancel();
@@ -342,8 +339,12 @@ public class UserSessionManager {
}
public static boolean isLoggedIn() {
- Log.trace("isLoggedIn = " + loggedIn);
- return loggedIn;
+ Log.trace("isLoggedIn = " + sessionState);
+ return sessionState == State.IS_LOGGED_IN;
+ }
+
+ public static boolean isLoggedOut() {
+ return sessionState == State.IS_LOGGED_OUT;
}
public static Subject getSessionSubject() {
@@ -366,8 +367,4 @@ public class UserSessionManager {
public static UserPreferences getUserPreferences() {
return userPreferences;
}
-
- public static String getLastAccessTime() {
- return Cookies.getCookie(SESSION_LAST_ACCESS);
- }
}
13 years, 8 months
[rhq] Branch 'delete-agent-plugin' - modules/core modules/enterprise
by John Sanda
modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java | 7 +------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/GroupSearchAssistant.java | 4 ++--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java | 4 ++--
3 files changed, 5 insertions(+), 10 deletions(-)
New commits:
commit ed4487ba743804f0a7763046be44bd15402ad683
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Oct 20 11:51:59 2010 -0400
Tidying up queries based on feedback from code review
Modified GroupSearchAssistance and ResourceSearchAssistant to use
type.deleted = false instead of rg.resouceType.deleted = false to try
and avoid unnecessarily creating another join.
Removing superflous checks against deleted flag in queries in
ResourceType.java.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
index a2ac4e9..3dd9cd0 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
@@ -197,7 +197,6 @@ import org.rhq.core.domain.util.Summary;
+ "FROM RHQ_resource_type crt, RHQ_resource res, RHQ_resource_type rt, RHQ_resource_type_parents rtp "
+ "WHERE res.id = ? "
+ "AND crt.deleted = false "
- + "AND rt.deleted = false "
+ "AND res.resource_type_id = rt.id "
+ "AND rt.id = rtp.parent_resource_type_id "
+ "AND rtp.resource_type_id = crt.id "
@@ -212,13 +211,11 @@ import org.rhq.core.domain.util.Summary;
+ "(SELECT COUNT(res2.id) "
+ "FROM RHQ_resource res2, RHQ_resource_type rt2 "
+ "WHERE res2.id = ? "
- + "AND rt2.deleted = false "
+ "AND res2.resource_type_id = rt2.id " + "AND rt2.category = 'PLATFORM') "
+ "AND 0 = "
+ "(SELECT COUNT(rtp2.resource_type_id) "
+ "FROM RHQ_resource_type_parents rtp2 "
+ "WHERE rtp2.resource_type_id = crt2.id) "
- + "AND crt2.deleted = false "
+ "AND crt2.category = ? " + " ) ORDER BY name", resultSetMapping = ResourceType.MAPPING_FIND_CHILDREN_BY_CATEGORY),
@NamedNativeQuery(name = ResourceType.QUERY_FIND_CHILDREN_BY_CATEGORY_admin, query = "" //
+ "(SELECT crt.id, crt.name, crt.category, crt.creation_data_type, crt.create_delete_policy, crt.singleton, "
@@ -227,7 +224,6 @@ import org.rhq.core.domain.util.Summary;
+ "FROM RHQ_resource_type crt, RHQ_resource res, RHQ_resource_type rt, RHQ_resource_type_parents rtp "
+ "WHERE res.id = ? "
+ "AND crt.deleted = false "
- + "AND rt.deleted = false "
+ "AND res.resource_type_id = rt.id "
+ "AND rt.id = rtp.parent_resource_type_id "
+ "AND rtp.resource_type_id = crt.id "
@@ -243,12 +239,11 @@ import org.rhq.core.domain.util.Summary;
+ "(SELECT COUNT(res2.id) "
+ "FROM RHQ_resource res2, RHQ_resource_type rt2 "
+ "WHERE res2.id = ? "
- + "AND rt2.deleted = false "
+ "AND res2.resource_type_id = rt2.id " + "AND rt2.category = 'PLATFORM') "
+ "AND 0 = "
+ "(SELECT COUNT(rtp2.resource_type_id) "
+ "FROM RHQ_resource_type_parents rtp2 "
- + "WHERE rtp2.resource_type_id = crt2.id) " + "AND crt2.category = ? AND crt2.deleted = false" +
+ + "WHERE rtp2.resource_type_id = crt2.id) " + "AND crt2.category = ?" +
// "ORDER BY crt2.name" +
")) ORDER BY name", resultSetMapping = ResourceType.MAPPING_FIND_CHILDREN_BY_CATEGORY) //
})
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/GroupSearchAssistant.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/GroupSearchAssistant.java
index ba27137..765d8f6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/GroupSearchAssistant.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/GroupSearchAssistant.java
@@ -62,7 +62,7 @@ public class GroupSearchAssistant extends TabAwareSearchAssistant {
+ "SELECT DISTINCT type.name " //
+ " FROM ResourceType type, ResourceGroup rg " //
+ " WHERE rg.resourceType = type " // only suggest names that exist for visible groups in inventory
- + " AND rg.visible = true AND rg.resourceType.deleted = false" //
+ + " AND rg.visible = true AND type.deleted = false" //
+ conditionallyAddJPQLString("type.name", filter) //
+ conditionallyAddJPQLString("rg.groupCategory", tab) //
+ conditionallyAddAuthzFragment(getAuthzFragment()) //
@@ -73,7 +73,7 @@ public class GroupSearchAssistant extends TabAwareSearchAssistant {
+ "SELECT DISTINCT type.plugin " //
+ " FROM ResourceType type, ResourceGroup rg " //
+ " WHERE rg.resourceType = type " // only suggest names that exist for visible groups in inventory
- + " AND rg.visible = true AND rg.resourceType.deleted = false" //
+ + " AND rg.visible = true AND type.deleted = false" //
+ conditionallyAddJPQLString("type.plugin", filter) //
+ conditionallyAddJPQLString("rg.groupCategory", tab) //
+ conditionallyAddAuthzFragment(getAuthzFragment()) //
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java
index 35c7d17..67cbc2a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java
@@ -66,7 +66,7 @@ public class ResourceSearchAssistant extends TabAwareSearchAssistant {
+ " FROM ResourceType type, Resource res, PropertyDefinitionSimple simpleDefinition " //"
+ " JOIN type.pluginConfigurationDefinition.propertyDefinitions definition " //
+ " WHERE res.resourceType = type " // only suggest names that exist for resources in inventory
- + " AND res.resourceType.deleted = false"
+ + " AND type.deleted = false"
+ " AND simpleDefinition = definition " // only suggest names for simple properties
+ " AND simpleDefinition.type <> 'PASSWORD' " // do not suggest hidden/password property types
+ conditionallyAddJPQLString("definition.name", filter) //
@@ -80,7 +80,7 @@ public class ResourceSearchAssistant extends TabAwareSearchAssistant {
+ " FROM ResourceType type, Resource res, PropertyDefinitionSimple simpleDefinition " //"
+ " JOIN type.resourceConfigurationDefinition.propertyDefinitions definition " //
+ " WHERE res.resourceType = type " // only suggest names that exist for resources in inventory
- + " AND res.resourceType.deleted = false"
+ + " AND type.deleted = false"
+ " AND simpleDefinition = definition " // only suggest names for simple properties
+ " AND simpleDefinition.type <> 'PASSWORD' " // do not suggest hidden/password property types
+ conditionallyAddJPQLString("definition.name", filter) //
13 years, 8 months
[rhq] Branch 'nagios' - 2 commits - modules/core
by Heiko W. Rupp
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java | 48 -
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java | 28
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ChildResourceTypeDiscoveryRunner.java | 463 +++++-----
3 files changed, 277 insertions(+), 262 deletions(-)
New commits:
commit d1abc21a90e34fe2105289cba14cefd12d4edba7
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Oct 20 17:38:08 2010 +0200
Be less verbose - it is expected that only a few types support the child type discovery facet
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ChildResourceTypeDiscoveryRunner.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ChildResourceTypeDiscoveryRunner.java
index 7567324..8e0347e 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ChildResourceTypeDiscoveryRunner.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ChildResourceTypeDiscoveryRunner.java
@@ -1,230 +1,233 @@
-package org.rhq.core.pc.inventory;
-
-/*
- * 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.
- */
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.Callable;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.clientapi.agent.PluginContainerException;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.pc.PluginContainer;
-import org.rhq.core.pc.util.ComponentUtil;
-import org.rhq.core.pc.util.FacetLockType;
-import org.rhq.core.pluginapi.inventory.ChildResourceTypeDiscoveryFacet;
-import org.rhq.core.util.exception.ThrowableUtil;
-
-public class ChildResourceTypeDiscoveryRunner implements Callable<Set<ResourceType>>, Runnable {
-
- private Log log = LogFactory.getLog(ChildResourceTypeDiscoveryRunner.class);
-
- //Default Ctor
- public ChildResourceTypeDiscoveryRunner() {
-
- }
-
- public void run() {
- try {
- call();
- } catch (Exception e) {
- log.error("Could not get measurement report.", e);
- }
- }
-
- public Set<ResourceType> call() {
-
- if (log.isDebugEnabled()) {
- log.info("<ChildResourceTypeDiscoveryRunner>call() called");
- }
-
- //Set<ResourceTypes> for the ResourceTypes which shall be added later
- Set<ResourceType> resourceTypes = null;
-
- long start = System.currentTimeMillis();
-
- //get InventoryManager instance
- InventoryManager im = PluginContainer.getInstance().getInventoryManager();
-
- if (log.isDebugEnabled()) {
- log.info("InventoryManager instance created");
- }
-
- //Get current plattform
- Resource platform = im.getPlatform();
- if (log.isDebugEnabled()) {
- log.info("Platform returned with name: " + platform.getName());
- }
-
- // Next discover all other services and non-top-level servers
- Set<Resource> children = platform.getChildResources();
- if (log.isDebugEnabled()) {
- log.info("Platform " + platform.getName() + " has " + children.size() + " ChildResources");
- }
-
- if (children != null) {
- for (Resource child : children) {
- if (log.isDebugEnabled()) {
- log.debug("Name of server: " + child.getName());
- log.debug("Id of server: " + child.getId());
- log.debug("Category of server: " + child.getResourceType().getCategory().toString());
- }
-
- //Check if really is of Category SERVER because our Plugin has to be of that category
- if (child.getResourceType().getCategory() == ResourceCategory.SERVER) {
-
- if (log.isDebugEnabled()) {
- log.info("Server " + child.getName() + "has passed the Server Category test succesfull");
- }
-
- ResourceContainer container = im.getResourceContainer(child.getId());
-
- if (log.isDebugEnabled()) {
- log.info("Server " + child.getName() + " is running in ResourceContainer "
- + container.toString());
- }
-
- if (container.getResourceComponentState() != ResourceContainer.ResourceComponentState.STARTED
- || container.getAvailability() == null
- || container.getAvailability().getAvailabilityType() == AvailabilityType.DOWN) {
- // Don't collect metrics for resources that are down
- if (log.isDebugEnabled()) {
- log.info("ChildType not discoverd for inactive resource component: "
- + container.getResource());
- }
- } else {
-
- try {
-
- //Get Facet Component
- ChildResourceTypeDiscoveryFacet discoveryComponent = ComponentUtil.getComponent(child
- .getId(), ChildResourceTypeDiscoveryFacet.class, FacetLockType.READ, 30 * 1000, true,
- true);
-
- //get Set<ResourceType> --> all the ChildResourceTypes which shall be added dynamically
- resourceTypes = discoverChildResourceTypes(discoveryComponent);
-
- if (log.isDebugEnabled()) {
- log.info("Container.getResource(): " + container.getResource().getName());
- log.info("Container.getResource().getResourceType(): "
- + container.getResource().getResourceType().getName());
-
- }
-
- //all the ChildResourceTypes which are already part of the plugin
- Set<ResourceType> currentChildTypes = container.getResource().getResourceType()
- .getChildResourceTypes();
-
- if (log.isDebugEnabled()) {
- log.info("Current existing types:");
- for (ResourceType type : currentChildTypes) {
- log.info(type.getName());
- }
- }
-
- Set<ResourceType> newTypesToAdd = new HashSet<ResourceType>();
-
- if (log.isDebugEnabled()) {
- log.info("Size of HashSet<ResourceType> after initialisation: " + newTypesToAdd.size());
- }
-
- //Check all types with were added by the plugin
- for (ResourceType newTypetoAdd : resourceTypes) {
- //Check all ChildResourceTypes that already exist
- boolean childAllreadyExists = false;
-
- for (ResourceType alreadyExistingType : currentChildTypes) {
- //Check if name and plugin of the types are equal
- //Necessary because equal-named ChildResourceTypes can belong to different plugins
- if (newTypetoAdd.getName().equals(alreadyExistingType.getName())
- && newTypetoAdd.getPlugin().equals(alreadyExistingType.getPlugin())) {
- log.info("The ResourceType " + newTypetoAdd.getName()
- + " already exists for the Plugin " + newTypetoAdd.getPlugin());
-
- //if ResourceType already exists set boolean var to true
- childAllreadyExists = true;
- }
- }
-
- //Check if type does not already exist, only add ResourceType to set if so
- if (!childAllreadyExists) {
- if (log.isDebugEnabled()) {
- log.info("new ChildResourceType " + newTypetoAdd.getName()
- + " added to Set<ResourceTypes>");
- }
- newTypesToAdd.add(newTypetoAdd);
- }
- }
-
- //Create a new ResourceType in the DB for the selected type
- //call InventoryManager method only if Set<ResourceType> contains at least one element
- if (newTypesToAdd.size() > 0) {
-
- //pass the Set<Resourcetype> to the inventory manager
- im.createNewResourceType(newTypesToAdd);
- }
-
- } catch (PluginContainerException pce) {
- // This is expected when the ResourceComponent does not implement the ChildResourceTypeDiscoveryFacet
- log.warn("Error submitting service scan: " + pce.getMessage());
- } catch (Exception e) {
- throw new RuntimeException("Error submitting service scan", e);
- }
- }
- }
- }
-
- } else {
- log.info("Set<ResourceType> was returned with value null");
- }
-
- return null;
- }
-
- /**
- *
- * @param discoveryComponent
- * @return
- */
- private Set<ResourceType> discoverChildResourceTypes(ChildResourceTypeDiscoveryFacet discoveryComponent) {
-
- Set<ResourceType> resourceTypes = null;
- try {
- long start = System.currentTimeMillis();
- resourceTypes = discoveryComponent.discoverChildResourceTypes();
- long duration = (System.currentTimeMillis() - start);
-
- if (duration > 2000) {
- log.info("[PERF] Discovery of childResourceTypes for [" + discoveryComponent + "] took [" + duration
- + "ms]");
- }
- } catch (Throwable t) {
-
- log.warn("Failure to discover childResourceType data - cause: " + ThrowableUtil.getAllMessages(t));
- }
-
- return resourceTypes;
- }
-}
+package org.rhq.core.pc.inventory;
+
+/*
+ * 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.
+ */
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.clientapi.agent.PluginContainerException;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.util.ComponentUtil;
+import org.rhq.core.pc.util.FacetLockType;
+import org.rhq.core.pluginapi.inventory.ChildResourceTypeDiscoveryFacet;
+import org.rhq.core.util.exception.ThrowableUtil;
+
+public class ChildResourceTypeDiscoveryRunner implements Callable<Set<ResourceType>>, Runnable {
+
+ private Log log = LogFactory.getLog(ChildResourceTypeDiscoveryRunner.class);
+
+ //Default Ctor
+ public ChildResourceTypeDiscoveryRunner() {
+
+ }
+
+ public void run() {
+ try {
+ call();
+ } catch (Exception e) {
+ log.error("Could not get measurement report.", e);
+ }
+ }
+
+ public Set<ResourceType> call() {
+
+ if (log.isDebugEnabled()) {
+ log.info("<ChildResourceTypeDiscoveryRunner>call() called");
+ }
+
+ //Set<ResourceTypes> for the ResourceTypes which shall be added later
+ Set<ResourceType> resourceTypes = null;
+
+ long start = System.currentTimeMillis();
+
+ //get InventoryManager instance
+ InventoryManager im = PluginContainer.getInstance().getInventoryManager();
+
+ if (log.isDebugEnabled()) {
+ log.info("InventoryManager instance created");
+ }
+
+ //Get current plattform
+ Resource platform = im.getPlatform();
+ if (log.isDebugEnabled()) {
+ log.info("Platform returned with name: " + platform.getName());
+ }
+
+ // Next discover all other services and non-top-level servers
+ Set<Resource> children = platform.getChildResources();
+ if (log.isDebugEnabled()) {
+ log.info("Platform " + platform.getName() + " has " + children.size() + " ChildResources");
+ }
+
+ if (children != null) {
+ for (Resource child : children) {
+ if (log.isDebugEnabled()) {
+ log.debug("Name of server: " + child.getName());
+ log.debug("Id of server: " + child.getId());
+ log.debug("Category of server: " + child.getResourceType().getCategory().toString());
+ }
+
+ //Check if really is of Category SERVER because our Plugin has to be of that category
+ if (child.getResourceType().getCategory() == ResourceCategory.SERVER) {
+
+ if (log.isDebugEnabled()) {
+ log.info("Server " + child.getName() + "has passed the Server Category test succesfull");
+ }
+
+ ResourceContainer container = im.getResourceContainer(child.getId());
+
+ if (log.isDebugEnabled()) {
+ log.info("Server " + child.getName() + " is running in ResourceContainer "
+ + container.toString());
+ }
+
+ if (container.getResourceComponentState() != ResourceContainer.ResourceComponentState.STARTED
+ || container.getAvailability() == null
+ || container.getAvailability().getAvailabilityType() == AvailabilityType.DOWN) {
+ // Don't collect metrics for resources that are down
+ if (log.isDebugEnabled()) {
+ log.info("ChildType not discoverd for inactive resource component: "
+ + container.getResource());
+ }
+ } else {
+
+ try {
+
+ //Get Facet Component
+ ChildResourceTypeDiscoveryFacet discoveryComponent = ComponentUtil.getComponent(child
+ .getId(), ChildResourceTypeDiscoveryFacet.class, FacetLockType.READ, 30 * 1000, true,
+ true);
+
+ //get Set<ResourceType> --> all the ChildResourceTypes which shall be added dynamically
+ resourceTypes = discoverChildResourceTypes(discoveryComponent);
+
+ if (log.isDebugEnabled()) {
+ log.info("Container.getResource(): " + container.getResource().getName());
+ log.info("Container.getResource().getResourceType(): "
+ + container.getResource().getResourceType().getName());
+
+ }
+
+ //all the ChildResourceTypes which are already part of the plugin
+ Set<ResourceType> currentChildTypes = container.getResource().getResourceType()
+ .getChildResourceTypes();
+
+ if (log.isDebugEnabled()) {
+ log.info("Current existing types:");
+ for (ResourceType type : currentChildTypes) {
+ log.info(type.getName());
+ }
+ }
+
+ Set<ResourceType> newTypesToAdd = new HashSet<ResourceType>();
+
+ if (log.isDebugEnabled()) {
+ log.info("Size of HashSet<ResourceType> after initialisation: " + newTypesToAdd.size());
+ }
+
+ //Check all types with were added by the plugin
+ for (ResourceType newTypetoAdd : resourceTypes) {
+ //Check all ChildResourceTypes that already exist
+ boolean childAllreadyExists = false;
+
+ for (ResourceType alreadyExistingType : currentChildTypes) {
+ //Check if name and plugin of the types are equal
+ //Necessary because equal-named ChildResourceTypes can belong to different plugins
+ if (newTypetoAdd.getName().equals(alreadyExistingType.getName())
+ && newTypetoAdd.getPlugin().equals(alreadyExistingType.getPlugin())) {
+ log.info("The ResourceType " + newTypetoAdd.getName()
+ + " already exists for the Plugin " + newTypetoAdd.getPlugin());
+
+ //if ResourceType already exists set boolean var to true
+ childAllreadyExists = true;
+ }
+ }
+
+ //Check if type does not already exist, only add ResourceType to set if so
+ if (!childAllreadyExists) {
+ if (log.isDebugEnabled()) {
+ log.info("new ChildResourceType " + newTypetoAdd.getName()
+ + " added to Set<ResourceTypes>");
+ }
+ newTypesToAdd.add(newTypetoAdd);
+ }
+ }
+
+ //Create a new ResourceType in the DB for the selected type
+ //call InventoryManager method only if Set<ResourceType> contains at least one element
+ if (newTypesToAdd.size() > 0) {
+
+ //pass the Set<Resourcetype> to the inventory manager
+ im.createNewResourceType(newTypesToAdd);
+ }
+
+ } catch (PluginContainerException pce) {
+ // This is expected when the ResourceComponent does not implement the ChildResourceTypeDiscoveryFacet
+ if (pce.getMessage().contains("does not support") && pce.getMessage().contains("ChildResourceTypeDiscoveryFacet"))
+ log.debug("ChildResourceTypeDiscoveryFacet not supported");
+ else
+ log.warn("Error submitting service scan: " + pce.getMessage());
+ } catch (Exception e) {
+ throw new RuntimeException("Error submitting service scan", e);
+ }
+ }
+ }
+ }
+
+ } else {
+ log.info("Set<ResourceType> was returned with value null");
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ * @param discoveryComponent
+ * @return
+ */
+ private Set<ResourceType> discoverChildResourceTypes(ChildResourceTypeDiscoveryFacet discoveryComponent) {
+
+ Set<ResourceType> resourceTypes = null;
+ try {
+ long start = System.currentTimeMillis();
+ resourceTypes = discoveryComponent.discoverChildResourceTypes();
+ long duration = (System.currentTimeMillis() - start);
+
+ if (duration > 2000) {
+ log.info("[PERF] Discovery of childResourceTypes for [" + discoveryComponent + "] took [" + duration
+ + "ms]");
+ }
+ } catch (Throwable t) {
+
+ log.warn("Failure to discover childResourceType data - cause: " + ThrowableUtil.getAllMessages(t));
+ }
+
+ return resourceTypes;
+ }
+}
commit 80b347e94018454644de33e4510a1ab49f125824
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Oct 20 17:31:38 2010 +0200
Parse the plugin descriptor for childType(Discovery) attributes and use this on dynamic types to run discovery on the passed resource type.
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 e0c0e25..0384a38 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,44 +92,54 @@ public class PluginMetadataManager {
PluginMetadataParser parser = this.parsersByPlugin.get(resourceType.getPlugin());
-// 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;
+
+ // Prefer hard coded types (= types from the plugin descriptor)
+ String discoveryComponentClass = parser.getDiscoveryComponentClass(resourceType);
+ if (discoveryComponentClass!=null)
+ return discoveryComponentClass;
+
+ // Not in plugin descriptor? Check if the parent supports dynamic type discovery
+ // and use the discovery class from there
if (resourceType.getParentResourceTypes()!=null && !resourceType.getParentResourceTypes().isEmpty()) {
ResourceType parent = resourceType.getParentResourceTypes().iterator().next();
- if (parser.getChildTypeDiscoveryComponentClass(parent)!=null)
- return parser.getChildTypeDiscoveryComponentClass(parent);
- }
+ String childTypeDiscoveryComponentClass = parser.getChildTypeDiscoveryComponentClass(parent);
- return parser.getDiscoveryComponentClass(resourceType);
+ if (childTypeDiscoveryComponentClass !=null)
+ return childTypeDiscoveryComponentClass;
+ }
+ // No luck ...
+ log.warn("No discovery class for type " + resourceType + " found ");
+ return null;
}
public String getComponentClass(ResourceType resourceType) {
PluginMetadataParser parser = this.parsersByPlugin.get(resourceType.getPlugin());
-// 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;
+ // Prefer hard coded types (= types from the plugin descriptor)
+ String componentClass = parser.getComponentClass(resourceType);
+ if (componentClass!=null)
+ return componentClass;
+
+ // Not in plugin descriptor? Check if the parent supports dynamic type discovery
+ // and use the discovery class from there
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);
+ String childTypeComponentClass = parser.getChildTypeComponentClass(parent);
+ if (childTypeComponentClass !=null)
+ return childTypeComponentClass;
+ }
+ // No luck ...
+ log.warn("No component class for type " + resourceType + " found ");
+ return null;
}
/**
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
index 95a8943..a494d0f 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
@@ -83,7 +83,7 @@ public class PluginMetadataParser {
private String childTypeDiscoveryClass;
private String childTypeComponentClass;
- //Hashmaps for ChildType discovery and component classes
+ //Hashmaps for ChildType discovery and component classes
private Map<ResourceType, String> childTypeDiscoveryClasses = new HashMap<ResourceType, String>();
private Map<ResourceType, String> childTypeComponentClasses = new HashMap<ResourceType, String>();
@@ -206,16 +206,18 @@ public class PluginMetadataParser {
//get childType discovery and component class names
this.childTypeDiscoveryClass = serverDescriptor.getChildTypeDiscovery();
this.childTypeComponentClass = serverDescriptor.getChildTypeClass();
+ childTypeDiscoveryClasses.put(serverResourceType,getFullyQualifiedComponentClassName(pluginDescriptor.getPackage(),childTypeDiscoveryClass));
+ childTypeComponentClasses.put(serverResourceType,getFullyQualifiedComponentClassName(pluginDescriptor.getPackage(),childTypeComponentClass));
//Check if it is the Nagios plugin and if the serverResourceType is a child
//Only nagios plugin decriptor has child type discovery and component class tags
- if (this.childTypeDiscoveryClass != null && this.childTypeComponentClass != null
- && parentServerType != null) {
- parseResourceDescriptor(serverDescriptor, serverResourceType, this.childTypeDiscoveryClass,
- this.childTypeComponentClass, null);
- } else {
+// if (this.childTypeDiscoveryClass != null && this.childTypeComponentClass != null
+// && parentServerType != null) {
+// parseResourceDescriptor(serverDescriptor, serverResourceType, this.childTypeDiscoveryClass,
+// this.childTypeComponentClass, null);
+// } else {
parseResourceDescriptor(serverDescriptor, serverResourceType, null, null, null);
- }
+// }
LOG.debug("Parsed server Resource type: " + serverResourceType);
} else if ((sourcePlugin.length() > 0) && (sourceServer.length() > 0)) {
@@ -336,13 +338,13 @@ public class PluginMetadataParser {
//Check if it is the Nagios plugin and if the serviceResourceType is a child
//Only nagios plugin decriptor has child type discovery and component class tags
- if (this.childTypeDiscoveryClass != null && this.childTypeComponentClass != null && parentType != null) {
- parseResourceDescriptor(serviceDescriptor, serviceResourceType, this.childTypeDiscoveryClass,
- this.childTypeComponentClass, null);
- } else {
+// if (this.childTypeDiscoveryClass != null && this.childTypeComponentClass != null && parentType != null) {
+// parseResourceDescriptor(serviceDescriptor, serviceResourceType, this.childTypeDiscoveryClass,
+// this.childTypeComponentClass, null);
+// } else {
parseResourceDescriptor(serviceDescriptor, serviceResourceType, null, null, null);
- }
+// }
LOG.debug("Parsed service Resource type: " + serviceResourceType);
@@ -657,7 +659,7 @@ public class PluginMetadataParser {
String componentClass) {
this.resourceTypes.add(resourceType);
- //if it is the child resource type of Nagios plugin
+ //if it is the child resource type of Nagios plugin
if (discoveryClass.equals(this.childTypeDiscoveryClass) && componentClass.equals(this.childTypeComponentClass)) {
//Put the childresource type and its discovery and component classes to the childtype map
this.childTypeComponentClasses.put(resourceType, componentClass);
13 years, 8 months
[rhq] Branch 'delete-agent-plugin' - 10 commits - .classpath modules/enterprise
by John Sanda
.classpath | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 217 ++++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java | 151 ++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java | 52 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java | 142 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 5
modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css | 4
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCLoginModule.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCPrincipalCheckLoginModule.java | 3
18 files changed, 465 insertions(+), 178 deletions(-)
New commits:
commit 421f602fea9fdff5b4d02aba1e0f390772c2bc0d
Merge: eded9dd... 96e0b10...
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Oct 20 11:22:03 2010 -0400
Merge branch 'master' into delete-agent-plugin
commit 96e0b10bc8c6f02608c744a8741165d10f881af4
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Oct 20 11:20:39 2010 -0400
Replacing call to finder method that has been removed in favor of criteria query
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp
index 2cc3da3..173fe16 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp
@@ -7,6 +7,7 @@
<%@ page import="org.rhq.core.domain.util.PageControl" %>
<%@ page import="org.rhq.core.domain.util.PageList" %>
<%@ page import="org.rhq.core.domain.util.PageOrdering" %>
+<%@ page import="org.rhq.core.domain.criteria.AlertCriteria" %>
<%@ page import="org.rhq.enterprise.gui.common.tag.FunctionTagLibrary" %>
<%@ page import="org.rhq.enterprise.gui.legacy.ParamConstants" %>
<%@ page import="org.rhq.enterprise.gui.legacy.WebUser" %>
@@ -29,8 +30,14 @@
PageControl pc = new PageControl(0, 100);
pc.setPrimarySortOrder(PageOrdering.DESC);
- PageList<Alert> alerts = alertManager.findAlerts(resourceId, null, null, begin, end, pc);
+ AlertCriteria criteria = new AlertCriteria();
+ criteria.addFilterResourceIds(resourceId);
+ criteria.addFilterStartTime(begin);
+ criteria.addFilterEndTime(end);
+ criteria.setPageControl(pc);
+
+ PageList<Alert> alerts = alertManager.findAlertsByCriteria(user.getSubject(), criteria);
%>
{ "events":
commit 1863896db8bd017e29a385cbb06fcbeb9402262a
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Oct 20 11:06:08 2010 -0400
core group config code for top-level simples and static maps of simples is done; still to do: set-all-values-to controls and support for dynamic/open maps of simples
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index df61aaa..28d5960 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -1326,17 +1326,11 @@ public class ConfigurationEditor extends LocatableVLayout {
// Only update the underlying property when the input is changed if it's a top-level simple or a simple within a
// top-level map.
- PropertyDefinitionMap parentPropertyMapDefinition =
- propertyDefinitionSimple.getParentPropertyMapDefinition();
- if (propertyDefinitionSimple.getConfigurationDefinition() != null ||
- (parentPropertyMapDefinition != null && parentPropertyMapDefinition.getConfigurationDefinition() != null)) {
+ if (updatePropertyValueOnChange(propertyDefinitionSimple, propertySimple)) {
valueItem.addChangedHandler(new ChangedHandler() {
- public void onChanged(ChangedEvent changedEvent) {
- propertySimple.setErrorMessage(null);
+ public void onChanged(ChangedEvent changedEvent) {
+ updatePropertySimpleValue(changedEvent.getValue(), propertySimple, propertyDefinitionSimple);
boolean isValid = changedEvent.getItem().validate();
- if (isValid) {
- propertySimple.setValue(changedEvent.getValue());
- }
firePropertyChangedEvent(propertySimple, propertyDefinitionSimple, isValid);
}
});
@@ -1345,6 +1339,20 @@ public class ConfigurationEditor extends LocatableVLayout {
return valueItem;
}
+ protected boolean updatePropertyValueOnChange(PropertyDefinitionSimple propertyDefinitionSimple,
+ PropertySimple propertySimple) {
+ PropertyDefinitionMap parentPropertyMapDefinition =
+ propertyDefinitionSimple.getParentPropertyMapDefinition();
+ return propertyDefinitionSimple.getConfigurationDefinition() != null ||
+ (parentPropertyMapDefinition != null && parentPropertyMapDefinition.getConfigurationDefinition() != null);
+ }
+
+ protected void updatePropertySimpleValue(Object value, PropertySimple propertySimple,
+ PropertyDefinitionSimple propertyDefinitionSimple) {
+ propertySimple.setErrorMessage(null);
+ propertySimple.setValue(value);
+ }
+
protected static Property getTopLevelProperty(Property property) {
Property currentProperty = property;
while (currentProperty.getConfiguration() == null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
index c3ba6cb..e198fc0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
@@ -159,7 +159,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
for (GroupMemberConfiguration memberConfiguration : memberConfigurations) {
Configuration configuration = memberConfiguration.getConfiguration();
PropertySimple memberPropertySimple =
- getPropertySimple(configuration, propertyDefinitionSimple, propertySimple, null);
+ getPropertySimple(configuration, propertyDefinitionSimple, null);
memberPropertySimple.setValue(value);
}
}
@@ -218,7 +218,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
memberItem.setDefaultValue(memberName);
items.add(memberItem);
Configuration configuration = memberConfiguration.getConfiguration();
- PropertySimple memberPropertySimple = getPropertySimple(configuration, propertyDefinitionSimple, aggregatePropertySimple, index);
+ PropertySimple memberPropertySimple = getPropertySimple(configuration, propertyDefinitionSimple, index);
memberProperties.put(memberName, memberPropertySimple);
FormItem valueItem = buildSimpleField(propertyDefinitionSimple, memberPropertySimple);
valueItem.setAttribute("rhq:property", memberPropertySimple);
@@ -317,13 +317,36 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
popup.show();
}
+ @Override
+ protected boolean updatePropertyValueOnChange(PropertyDefinitionSimple propertyDefinitionSimple,
+ PropertySimple propertySimple) {
+ return isAggregateProperty(propertySimple) && super.updatePropertyValueOnChange(propertyDefinitionSimple, propertySimple); // TODO: Implement this method.
+ }
+
+ @Override
+ protected void updatePropertySimpleValue(Object value, PropertySimple propertySimple,
+ PropertyDefinitionSimple propertyDefinitionSimple) {
+ // Update the aggregate property
+ super.updatePropertySimpleValue(value, propertySimple, propertyDefinitionSimple);
+ propertySimple.setOverride(true);
+
+ // Update all the member properties.
+ for (GroupMemberConfiguration memberConfiguration : this.memberConfigurations) {
+ Configuration configuration = memberConfiguration.getConfiguration();
+ PropertySimple memberPropertySimple =
+ getPropertySimple(configuration, propertyDefinitionSimple, null);
+ memberPropertySimple.setErrorMessage(null);
+ memberPropertySimple.setValue(value);
+ }
+ }
+
private PropertySimple getPropertySimple(Configuration configuration,
PropertyDefinitionSimple propertyDefinitionSimple,
- PropertySimple aggregatePropertySimple, Integer index) {
+ Integer index) {
LinkedList<PropertyDefinition> propertyDefinitionHierarchy = new LinkedList<PropertyDefinition>();
PropertyDefinition currentPropertyDefinition = propertyDefinitionSimple;
- do {
- propertyDefinitionHierarchy.addFirst(currentPropertyDefinition);
+ propertyDefinitionHierarchy.add(currentPropertyDefinition);
+ do {
if (currentPropertyDefinition.getParentPropertyMapDefinition() != null) {
currentPropertyDefinition = currentPropertyDefinition.getParentPropertyMapDefinition();
} else if (currentPropertyDefinition.getParentPropertyListDefinition() != null) {
@@ -331,6 +354,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
} else if (currentPropertyDefinition.getConfigurationDefinition() == null) {
throw new IllegalStateException(currentPropertyDefinition + " has no parent.");
}
+ propertyDefinitionHierarchy.addFirst(currentPropertyDefinition);
}
while (currentPropertyDefinition.getConfigurationDefinition() == null);
@@ -348,10 +372,6 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
}
PropertySimple propertySimple = (PropertySimple)property;
- if (isHomogeneous(aggregatePropertySimple)) {
- // If the aggregate property has its override bit set, make sure the member property has the same value.
- propertySimple.setStringValue(aggregatePropertySimple.getStringValue());
- }
return propertySimple;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java
index 2fd5dfa..9d94650 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java
@@ -20,6 +20,7 @@
package org.rhq.enterprise.gui.coregui.client.test;
import java.util.EnumSet;
+import java.util.Set;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.events.ClickEvent;
@@ -91,15 +92,17 @@ public class TestConfigurationView
MessageCenter messageCenter = CoreGUI.getMessageCenter();
Message message;
if (event.isValidationStateChanged()) {
- if (event.getInvalidPropertyNames().isEmpty()) {
+ Set<String> invalidPropertyNames = event.getInvalidPropertyNames();
+ if (invalidPropertyNames.isEmpty()) {
this.saveButton.enable();
message = new Message("All properties now have valid values, so the configuration can now be saved.",
- Message.Severity.Info, EnumSet.of(Message.Option.Transient));
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
}
else {
this.saveButton.disable();
message = new Message(
- "One or more properties have invalid values. The values must be corrected before the configuration can be saved.",
+ "The following properties have invalid values: " + invalidPropertyNames
+ + " - the values must be corrected before the configuration can be saved.",
Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
}
messageCenter.notify(message);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java
index 7d71c02..f54bb01 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java
@@ -22,6 +22,7 @@ package org.rhq.enterprise.gui.coregui.client.test;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
+import java.util.Set;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.events.ClickEvent;
@@ -100,15 +101,17 @@ public class TestGroupConfigurationView
MessageCenter messageCenter = CoreGUI.getMessageCenter();
Message message;
if (event.isValidationStateChanged()) {
- if (event.getInvalidPropertyNames().isEmpty()) {
+ Set<String> invalidPropertyNames = event.getInvalidPropertyNames();
+ if (invalidPropertyNames.isEmpty()) {
this.saveButton.enable();
message = new Message("All properties now have valid values, so the configuration can now be saved.",
- Message.Severity.Info, EnumSet.of(Message.Option.Transient));
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
}
else {
this.saveButton.disable();
message = new Message(
- "One or more properties have invalid values. The values must be corrected before the configuration can be saved.",
+ "The following properties have invalid values: " + invalidPropertyNames
+ + " - the values must be corrected before the configuration can be saved.",
Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
}
messageCenter.notify(message);
commit 927bc83226129c29feab114910c9d226bd2e5ddf
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Oct 19 18:55:33 2010 -0400
more work on group config component; add test view for group config (#TestGroupConfig); misc datasource fixes
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 6db7fc8..3888cdc 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
@@ -48,6 +48,7 @@ import org.rhq.enterprise.gui.coregui.client.menu.MenuBarView;
import org.rhq.enterprise.gui.coregui.client.report.ReportTopView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
import org.rhq.enterprise.gui.coregui.client.test.TestConfigurationView;
+import org.rhq.enterprise.gui.coregui.client.test.TestGroupConfigurationView;
import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler;
import org.rhq.enterprise.gui.coregui.client.util.WidgetUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.MessageBar;
@@ -217,6 +218,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
canvas = new ReportTopView("Report");
} else if (breadcrumbName.equals(TestConfigurationView.VIEW_ID)) {
canvas = new TestConfigurationView("TestConfig");
+ } else if (breadcrumbName.equals(TestGroupConfigurationView.VIEW_ID)) {
+ canvas = new TestGroupConfigurationView("TestGroupConfig");
} else {
canvas = null;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 2cbebe4..df61aaa 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -128,7 +128,6 @@ import org.rhq.core.domain.configuration.definition.constraint.IntegerRangeConst
import org.rhq.core.domain.configuration.definition.constraint.RegexConstraint;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.RefreshableView;
import org.rhq.enterprise.gui.coregui.client.components.table.PropertyGrid;
import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -558,20 +557,8 @@ public class ConfigurationEditor extends LocatableVLayout {
Property property,
boolean oddRow,
List<FormItem> fields, final boolean firePropertyChangedEvents) {
- List<FormItem> fieldsForThisProperty = new ArrayList<FormItem>();
+ List<FormItem> fieldsForThisProperty;
- StaticTextItem nameItem = new StaticTextItem();
- nameItem.setStartRow(true);
- String title = "<b>"
- + (propertyDefinition.getDisplayName() != null ? propertyDefinition.getDisplayName() : propertyDefinition
- .getName()) + "</b>";
- nameItem.setValue(title);
- nameItem.setShowTitle(false);
-
- fieldsForThisProperty.add(nameItem);
- fields.add(nameItem);
-
- final FormItem valueItem;
if (propertyDefinition instanceof PropertyDefinitionSimple) {
final PropertyDefinitionSimple propertyDefinitionSimple = (PropertyDefinitionSimple)propertyDefinition;
PropertySimple propertySimple = (PropertySimple)property;
@@ -580,34 +567,8 @@ public class ConfigurationEditor extends LocatableVLayout {
propertySimple = new PropertySimple(propertyDefinitionSimple.getName(), null);
}
- final PropertySimple finalPropertySimple = propertySimple;
- valueItem = buildSimpleField(propertyDefinitionSimple, propertySimple);
- valueItem.addChangedHandler(new ChangedHandler() {
- public void onChanged(ChangedEvent changedEvent) {
- finalPropertySimple.setErrorMessage(null);
- boolean isValid = changedEvent.getItem().validate();
- if (isValid) {
- finalPropertySimple.setValue(changedEvent.getValue());
- }
- if (firePropertyChangedEvents) {
- firePropertyChangedEvent(finalPropertySimple, propertyDefinitionSimple, isValid);
- }
- }
- });
-
- FormItem unsetItem = buildUnsetItem(propertyDefinitionSimple, propertySimple, valueItem);
- fieldsForThisProperty.add(unsetItem);
- fields.add(unsetItem);
-
- fieldsForThisProperty.add(valueItem);
- fields.add(valueItem);
-
- StaticTextItem descriptionItem = new StaticTextItem();
- descriptionItem.setValue(propertyDefinition.getDescription());
- descriptionItem.setShowTitle(false);
- descriptionItem.setEndRow(true);
- fieldsForThisProperty.add(descriptionItem);
- fields.add(descriptionItem);
+ fieldsForThisProperty = buildFieldsForPropertySimple(propertyDefinition, propertyDefinitionSimple,
+ propertySimple);
} else if (propertyDefinition instanceof PropertyDefinitionList) {
PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList)propertyDefinition;
PropertyDefinition memberDefinition = propertyDefinitionList.getMemberDefinition();
@@ -615,41 +576,9 @@ public class ConfigurationEditor extends LocatableVLayout {
if (propertyList == null) {
propertyList = new PropertyList(propertyDefinitionList.getName());
}
- if (memberDefinition instanceof PropertyDefinitionMap) {
- // List of Maps is a specially supported case with summary fields as columns in a table
- // Note: This field spans 3 columns.
- PropertyDefinitionMap memberDefinitionMap = (PropertyDefinitionMap)memberDefinition;
- CanvasItem listOfMapsItem = buildListOfMapsField(locatorId,
- memberDefinitionMap,
- propertyList, oddRow);
- fieldsForThisProperty.add(listOfMapsItem);
- fields.add(listOfMapsItem);
- } else if (memberDefinition instanceof PropertyDefinitionSimple) {
- SpacerItem unsetItem = new SpacerItem();
- fieldsForThisProperty.add(unsetItem);
- fields.add(unsetItem);
-
- CanvasItem listOfSimplesItem = buildListOfSimplesField(locatorId, propertyDefinitionList, propertyList,
- oddRow);
- fieldsForThisProperty.add(listOfSimplesItem);
- fields.add(listOfSimplesItem);
-
- StaticTextItem descriptionItem = new StaticTextItem();
- descriptionItem.setValue(propertyDefinition.getDescription());
- descriptionItem.setShowTitle(false);
- descriptionItem.setEndRow(true);
- fieldsForThisProperty.add(descriptionItem);
- fields.add(descriptionItem);
- } else {
- Log.error("List " + propertyList + " has unsupported member type: " + memberDefinition);
- Canvas canvas = new Canvas();
- // TODO: Add label with error message to canvas.
- CanvasItem canvasItem = buildComplexPropertyField(canvas);
- canvasItem.setColSpan(3);
- canvasItem.setEndRow(true);
- fieldsForThisProperty.add(canvasItem);
- fields.add(canvasItem);
- }
+ fieldsForThisProperty = buildFieldsForPropertyList(locatorId, propertyDefinition, oddRow,
+ propertyDefinitionList,
+ memberDefinition, propertyList);
} else if (propertyDefinition instanceof PropertyDefinitionMap) {
PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap)propertyDefinition;
PropertyMap propertyMap = (PropertyMap)property;
@@ -657,18 +586,113 @@ public class ConfigurationEditor extends LocatableVLayout {
propertyMap = new PropertyMap(propertyDefinitionMap.getName());
}
- // Note: This field spans 3 columns.
- FormItem mapField =
- buildMapField(locatorId, propertyDefinitionMap, propertyMap);
- fields.add(mapField);
+ fieldsForThisProperty = buildFieldsForPropertyMap(locatorId, propertyDefinitionMap, propertyMap);
+ } else {
+ throw new IllegalStateException("Property definition null or of unknown type: " + propertyDefinition);
}
- // Set row background color.
+ // Add the fields for this property to the master fields list and set the row background color.
for (FormItem field : fieldsForThisProperty) {
+ fields.add(field);
field.setCellStyle(oddRow ? "OddRow" : "EvenRow");
}
}
+ protected List<FormItem> buildFieldsForPropertySimple(PropertyDefinition propertyDefinition,
+ PropertyDefinitionSimple propertyDefinitionSimple,
+ PropertySimple propertySimple) {
+ List<FormItem> fields = new ArrayList<FormItem>();
+
+ StaticTextItem nameItem = buildNameItem(propertyDefinition);
+ fields.add(nameItem);
+
+ FormItem valueItem;
+ valueItem = buildSimpleField(propertyDefinitionSimple, propertySimple);
+
+ FormItem unsetItem = buildUnsetItem(propertyDefinitionSimple, propertySimple, valueItem);
+ fields.add(unsetItem);
+
+ fields.add(valueItem);
+
+ StaticTextItem descriptionItem = buildDescriptionField(propertyDefinition);
+ fields.add(descriptionItem);
+
+ return fields;
+ }
+
+ protected List<FormItem> buildFieldsForPropertyList(String locatorId, PropertyDefinition propertyDefinition, boolean oddRow,
+ PropertyDefinitionList propertyDefinitionList,
+ PropertyDefinition memberDefinition, PropertyList propertyList) {
+ List<FormItem> fields = new ArrayList<FormItem>();
+
+ StaticTextItem nameItem = buildNameItem(propertyDefinition);
+ fields.add(nameItem);
+
+ if (memberDefinition instanceof PropertyDefinitionMap) {
+ // List of Maps is a specially supported case with summary fields as columns in a table
+ // Note: This field spans 3 columns.
+ PropertyDefinitionMap memberDefinitionMap = (PropertyDefinitionMap)memberDefinition;
+ CanvasItem listOfMapsItem = buildListOfMapsField(locatorId,
+ memberDefinitionMap,
+ propertyList, oddRow);
+ fields.add(listOfMapsItem);
+ } else if (memberDefinition instanceof PropertyDefinitionSimple) {
+ SpacerItem unsetItem = new SpacerItem();
+ fields.add(unsetItem);
+
+ CanvasItem listOfSimplesItem = buildListOfSimplesField(locatorId, propertyDefinitionList, propertyList,
+ oddRow);
+ fields.add(listOfSimplesItem);
+
+ StaticTextItem descriptionItem = buildDescriptionField(propertyDefinition);
+ fields.add(descriptionItem);
+ } else {
+ Log.error("List " + propertyList + " has unsupported member type: " + memberDefinition);
+ Canvas canvas = new Canvas();
+ // TODO: Add label with error message to canvas.
+ CanvasItem canvasItem = buildComplexPropertyField(canvas);
+ canvasItem.setColSpan(3);
+ canvasItem.setEndRow(true);
+ fields.add(canvasItem);
+ }
+
+ return fields;
+ }
+
+ protected List<FormItem> buildFieldsForPropertyMap(String locatorId,
+ PropertyDefinitionMap propertyDefinitionMap, PropertyMap propertyMap) {
+ List<FormItem> fields = new ArrayList<FormItem>();
+
+ StaticTextItem nameItem = buildNameItem(propertyDefinitionMap);
+ fields.add(nameItem);
+
+ // Note: This field spans 3 columns.
+ FormItem mapField =
+ buildMapField(locatorId, propertyDefinitionMap, propertyMap);
+ fields.add(mapField);
+
+ return fields;
+ }
+
+ private StaticTextItem buildNameItem(PropertyDefinition propertyDefinition) {
+ StaticTextItem nameItem = new StaticTextItem();
+ nameItem.setStartRow(true);
+ String title = "<b>"
+ + (propertyDefinition.getDisplayName() != null ? propertyDefinition.getDisplayName() : propertyDefinition
+ .getName()) + "</b>";
+ nameItem.setValue(title);
+ nameItem.setShowTitle(false);
+ return nameItem;
+ }
+
+ private StaticTextItem buildDescriptionField(PropertyDefinition propertyDefinition) {
+ StaticTextItem descriptionItem = new StaticTextItem();
+ descriptionItem.setValue(propertyDefinition.getDescription());
+ descriptionItem.setShowTitle(false);
+ descriptionItem.setEndRow(true);
+ return descriptionItem;
+ }
+
private void firePropertyChangedEvent(Property property,
PropertyDefinition propertyDefinition,
boolean isValid) {
@@ -1300,6 +1324,24 @@ public class ConfigurationEditor extends LocatableVLayout {
valueItem.setShowTitle(false);
valueItem.setWidth(220);
+ // Only update the underlying property when the input is changed if it's a top-level simple or a simple within a
+ // top-level map.
+ PropertyDefinitionMap parentPropertyMapDefinition =
+ propertyDefinitionSimple.getParentPropertyMapDefinition();
+ if (propertyDefinitionSimple.getConfigurationDefinition() != null ||
+ (parentPropertyMapDefinition != null && parentPropertyMapDefinition.getConfigurationDefinition() != null)) {
+ valueItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent changedEvent) {
+ propertySimple.setErrorMessage(null);
+ boolean isValid = changedEvent.getItem().validate();
+ if (isValid) {
+ propertySimple.setValue(changedEvent.getValue());
+ }
+ firePropertyChangedEvent(propertySimple, propertyDefinitionSimple, isValid);
+ }
+ });
+ }
+
return valueItem;
}
@@ -1334,11 +1376,10 @@ public class ConfigurationEditor extends LocatableVLayout {
unsetItem.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent changeEvent) {
Boolean isUnset = (Boolean) changeEvent.getValue();
+ valueItem.setDisabled(isUnset);
if (isUnset) {
setValue(valueItem, null);
- valueItem.setDisabled(true);
} else {
- valueItem.setDisabled(false);
valueItem.focusInItem();
}
valueItem.redraw();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
index de29950..c3ba6cb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
@@ -49,7 +49,6 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
-import org.rhq.enterprise.gui.coregui.client.RefreshableView;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
@@ -60,6 +59,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class GroupConfigurationEditor extends ConfigurationEditor {
private List<GroupMemberConfiguration> memberConfigurations;
+ private Map<String, FormItem> valueItemNameToStaticItemMap = new HashMap<String, FormItem>();
private Map<String, FormItem> valueItemNameToUnsetItemMap = new HashMap<String, FormItem>();
public GroupConfigurationEditor(String locatorId, ConfigurationDefinition configurationDefinition,
@@ -80,6 +80,34 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
}
@Override
+ protected List<FormItem> buildFieldsForPropertySimple(PropertyDefinition propertyDefinition,
+ PropertyDefinitionSimple propertyDefinitionSimple,
+ PropertySimple propertySimple) {
+ List<FormItem> fields = super.buildFieldsForPropertySimple(propertyDefinition, propertyDefinitionSimple,
+ propertySimple);
+
+ if (isAggregateProperty(propertySimple)) {
+ // Create the "MEMBER VALUES DIFFER" label that is displayed when member values are heterogeneous.
+ final StaticTextItem staticItem = new StaticTextItem();
+ staticItem.setValue("MEMBER VALUES DIFFER");
+ staticItem.setTextBoxStyle("InlineNote");
+ staticItem.setShowTitle(false);
+ staticItem.setTooltip("Member values differ - click icon to edit them.");
+ Boolean isHomogeneous = isHomogeneous(propertySimple);
+ staticItem.setVisible(!isHomogeneous);
+
+ FormItem valueItem = fields.get(2);
+ FormItemIcon icon = buildEditMemberValuesIcon(propertyDefinitionSimple, propertySimple, valueItem);
+ staticItem.setIcons(icon);
+
+ this.valueItemNameToStaticItemMap.put(valueItem.getName(), staticItem);
+ fields.add(3, staticItem);
+ }
+
+ return fields;
+ }
+
+ @Override
protected FormItem buildSimpleField(final PropertyDefinitionSimple propertyDefinitionSimple,
final PropertySimple propertySimple) {
final FormItem item = super.buildSimpleField(propertyDefinitionSimple, propertySimple);
@@ -87,40 +115,55 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
boolean isAggregate = isAggregateProperty(propertySimple);
if (isAggregate) {
// Add the icon that user can click to edit the member values.
- FormItemIcon icon = new FormItemIcon();
- icon.setSrc("[SKIN]/actions/edit.png");
- icon.setName("Edit Member Values");
- icon.setNeverDisable(true);
- icon.addFormItemClickHandler(new FormItemClickHandler() {
- public void onFormItemClick(FormItemIconClickEvent event) {
- // TODO: Pass the actual index, rather than null, if the prop is inside a list.
- displayMemberValuesEditor(extendLocatorId("MemberValuesEditor"), propertyDefinitionSimple,
- propertySimple, null, item);
- }
- });
- // TODO: Figure out a way to add a tooltip to the icon.
- item.setIcons(icon);
+ FormItemIcon icon = buildEditMemberValuesIcon(propertyDefinitionSimple, propertySimple, item);
- if (!isHomogeneous(propertySimple)) {
- updateHeterogeneousValueItem(item);
- }
+ item.setIcons(icon);
item.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent changedEvent) {
Object value = changedEvent.getValue();
- for (GroupMemberConfiguration memberConfiguration : memberConfigurations) {
- Configuration configuration = memberConfiguration.getConfiguration();
- PropertySimple memberPropertySimple =
- getPropertySimple(configuration, propertyDefinitionSimple, propertySimple, null);
- memberPropertySimple.setValue(value);
- }
+ updateMemberProperties(propertyDefinitionSimple, propertySimple, value);
}
});
+
+ Boolean isHomogeneous = isHomogeneous(propertySimple);
+ item.setVisible(isHomogeneous);
}
return item;
}
+ private FormItemIcon buildEditMemberValuesIcon(final PropertyDefinitionSimple propertyDefinitionSimple,
+ final PropertySimple propertySimple, final FormItem dynamicItem) {
+ FormItemIcon icon = new FormItemIcon();
+
+ icon.setSrc("[SKIN]/actions/edit.png");
+ icon.setName("Edit Member Values");
+ icon.setNeverDisable(true);
+ icon.addFormItemClickHandler(new FormItemClickHandler() {
+ public void onFormItemClick(FormItemIconClickEvent event) {
+ // TODO: Pass the actual index, rather than null, if the prop is inside a list.
+ displayMemberValuesEditor(extendLocatorId("MemberValuesEditor"), propertyDefinitionSimple,
+ propertySimple, null, dynamicItem);
+ }
+ });
+
+ // TODO: Figure out a way to add a tooltip to the icon.
+
+ return icon;
+ }
+
+ private void updateMemberProperties(PropertyDefinitionSimple propertyDefinitionSimple,
+ PropertySimple propertySimple, Object value
+ ) {
+ for (GroupMemberConfiguration memberConfiguration : memberConfigurations) {
+ Configuration configuration = memberConfiguration.getConfiguration();
+ PropertySimple memberPropertySimple =
+ getPropertySimple(configuration, propertyDefinitionSimple, propertySimple, null);
+ memberPropertySimple.setValue(value);
+ }
+ }
+
@Override
protected FormItem buildUnsetItem(final PropertyDefinitionSimple propertyDefinitionSimple, final PropertySimple propertySimple,
final FormItem valueItem) {
@@ -136,8 +179,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
private void displayMemberValuesEditor(String locatorId, final PropertyDefinitionSimple propertyDefinitionSimple,
final PropertySimple aggregatePropertySimple,
- Integer index, final FormItem aggregateValueItem
- ) {
+ Integer index, final FormItem aggregateValueItem) {
LocatableVLayout layout = new LocatableVLayout(locatorId);
layout.setHeight100();
@@ -215,31 +257,36 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
memberPropertySimple.setErrorMessage(null);
}
+ FormItem aggregateStaticItem = valueItemNameToStaticItemMap.get(aggregateValueItem.getName());
+
FormItem aggregateUnsetItem = valueItemNameToUnsetItemMap.get(aggregateValueItem.getName());
aggregateUnsetItem.setDisabled(!valuesHomogeneous);
+
if (valuesHomogeneous) {
// Update the value of the aggregate property and set its override flag to true.
aggregatePropertySimple.setValue(firstValue);
aggregatePropertySimple.setOverride(true);
+ aggregateUnsetItem.setValue(firstValue == null);
+
// Set the aggregate value item's value to the homogeneous value, enable it, and make sure it has
// validators set.
- aggregateValueItem.setDisabled(false);
setValue(aggregateValueItem, firstValue);
- aggregateValueItem.setTooltip(null);
- aggregateValueItem.setValidateOnChange(true);
- aggregateValueItem.setValidateOnExit(true);
+ aggregateValueItem.show();
+ aggregateValueItem.setDisabled(false);
+
+ aggregateStaticItem.hide();
- aggregateUnsetItem.setValue(firstValue == null);
} else {
aggregatePropertySimple.setValue(null);
aggregatePropertySimple.setOverride(false);
- updateHeterogeneousValueItem(aggregateValueItem);
+ aggregateValueItem.hide();
- aggregateUnsetItem.setValue((String)null);
+ aggregateStaticItem.show();
}
+ form.markForRedraw();
popup.destroy();
}
});
@@ -270,14 +317,6 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
popup.show();
}
- private void updateHeterogeneousValueItem(FormItem item) {
- item.setDisabled(true);
- item.setValidateOnChange(false);
- item.setValidateOnExit(false);
- item.setValue("MEMBER VALUES DIFFER");
- item.setTooltip("Member values differ - click icon to edit them.");
- }
-
private PropertySimple getPropertySimple(Configuration configuration,
PropertyDefinitionSimple propertyDefinitionSimple,
PropertySimple aggregatePropertySimple, Integer index) {
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 6fd1d01..2b5097f 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
@@ -157,7 +157,7 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
record.setAttribute("id", from.getResourceGroup().getId());
record.setAttribute("name", from.getResourceGroup().getName());
record.setAttribute("description", from.getResourceGroup().getDescription());
- record.setAttribute("category", from.getResourceGroup().getGroupCategory().toString());
+ record.setAttribute("category", from.getResourceGroup().getGroupCategory());
record.setAttribute("explicitUp", String.valueOf(from.getExplicitUp()));
record.setAttribute("explicitDown", String.valueOf(from.getExplicitDown()));
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 190baf7..e0778bb 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
@@ -152,7 +152,7 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
record.setAttribute("id", from.getId());
record.setAttribute("name", from.getName());
record.setAttribute("description", from.getDescription());
- record.setAttribute("category", from.getGroupCategory().toString());
+ record.setAttribute("category", from.getGroupCategory());
if (from.getResourceType() != null) {
record.setAttribute("resourceType", from.getResourceType());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
index 59b55e9..be80e8e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
@@ -40,12 +40,12 @@ public enum ResourceDataSourceField {
AVAILABILITY("currentAvailability", "Availability");
/**
- * Corresponds to a property name of Resource
+ * Corresponds to a property name of Resource (e.g. resourceType.name).
*/
private String propertyName;
/**
- * The display name for the field or property
+ * The table header for the field or property (e.g. Type).
*/
private String title;
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 2b3a4c2..7759f53 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
@@ -163,7 +163,7 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
record.setAttribute(DESCRIPTION.propertyName(), from.getDescription());
record.setAttribute(TYPE.propertyName(), from.getResourceType().getId());
record.setAttribute(PLUGIN.propertyName(), from.getResourceType().getPlugin());
- record.setAttribute(CATEGORY.propertyName(), from.getResourceType().getCategory().getDisplayName());
+ record.setAttribute(CATEGORY.propertyName(), from.getResourceType().getCategory());
record.setAttribute("icon", from.getResourceType().getCategory().getDisplayName() + "_"
+ (from.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP ? "up" : "down") + "_16.png");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java
index 396f07a..89d7d53 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java
@@ -45,48 +45,48 @@ import org.rhq.core.domain.configuration.definition.PropertySimpleType;
*/
public abstract class TestConfigurationFactory {
public static ConfigurationDefinition createConfigurationDefinition() {
- ConfigurationDefinition configurationDefinition = new ConfigurationDefinition("TestConfig", "a test config");
+ ConfigurationDefinition configDef = new ConfigurationDefinition("TestConfig", "a test config");
ConfigurationTemplate defaultTemplate = new ConfigurationTemplate(ConfigurationTemplate.DEFAULT_TEMPLATE_NAME, "default template");
- configurationDefinition.putTemplate(defaultTemplate);
+ configDef.putTemplate(defaultTemplate);
Configuration defaultConfiguration = new Configuration();
defaultTemplate.setConfiguration(defaultConfiguration);
Map<String, PropertyDefinition> propertyDefinitions = new HashMap<String, PropertyDefinition>();
- configurationDefinition.setPropertyDefinitions(propertyDefinitions);
+ configDef.setPropertyDefinitions(propertyDefinitions);
int orderIndex = 0;
PropertyDefinitionSimple simplePropDef;
simplePropDef = createStringPropDef1();
- addPropertyDefinition(propertyDefinitions, simplePropDef, orderIndex++);
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
simplePropDef = createStringPropDef2();
- addPropertyDefinition(propertyDefinitions, simplePropDef, orderIndex++);
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
simplePropDef = new PropertyDefinitionSimple("LongString", "a Long String simple prop", false,
PropertySimpleType.LONG_STRING);
simplePropDef.setDisplayName(simplePropDef.getName());
- addPropertyDefinition(propertyDefinitions, simplePropDef, orderIndex++);
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
simplePropDef = new PropertyDefinitionSimple("Password", "a Password simple prop", false,
PropertySimpleType.PASSWORD);
simplePropDef.setDisplayName(simplePropDef.getName());
- addPropertyDefinition(propertyDefinitions, simplePropDef, orderIndex++);
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
simplePropDef = new PropertyDefinitionSimple("Boolean", "a required Boolean simple prop", true,
PropertySimpleType.BOOLEAN);
simplePropDef.setDisplayName(simplePropDef.getName());
- addPropertyDefinition(propertyDefinitions, simplePropDef, orderIndex++);
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
simplePropDef.setRequired(true);
simplePropDef = createIntegerPropDef();
- addPropertyDefinition(propertyDefinitions, simplePropDef, orderIndex++);
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
simplePropDef = new PropertyDefinitionSimple("Float", "a Float simple prop", false, PropertySimpleType.FLOAT);
simplePropDef.setDisplayName(simplePropDef.getName());
- addPropertyDefinition(propertyDefinitions, simplePropDef, orderIndex++);
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
simplePropDef = new PropertyDefinitionSimple("StringEnum1",
"a String enum prop with <=5 items - should be rendered as radio buttons", false,
@@ -98,7 +98,7 @@ public abstract class TestConfigurationFactory {
propDefEnums.add(new PropertyDefinitionEnumeration("NJ", "NJ"));
propDefEnums.add(new PropertyDefinitionEnumeration("PA", "PA"));
simplePropDef.setEnumeratedValues(propDefEnums, false);
- addPropertyDefinition(propertyDefinitions, simplePropDef, orderIndex++);
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
simplePropDef = new PropertyDefinitionSimple("StringEnum2",
"a String enum prop with >5 items - should be rendered as a popup menu", false, PropertySimpleType.STRING);
@@ -112,31 +112,31 @@ public abstract class TestConfigurationFactory {
propDefEnums.add(new PropertyDefinitionEnumeration("blue", "blue"));
propDefEnums.add(new PropertyDefinitionEnumeration("purple", "purple"));
simplePropDef.setEnumeratedValues(propDefEnums, false);
- addPropertyDefinition(propertyDefinitions, simplePropDef, orderIndex++);
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
PropertyDefinitionMap mapPropDef = new PropertyDefinitionMap("MapOfSimples", "a map of simples", false);
mapPropDef.put(createStringPropDef1());
mapPropDef.put(createStringPropDef2());
mapPropDef.put(createIntegerPropDef());
mapPropDef.setDisplayName(mapPropDef.getName());
- addPropertyDefinition(propertyDefinitions, mapPropDef, orderIndex++);
+ addPropertyDefinition(configDef, mapPropDef, orderIndex++);
PropertyDefinitionMap openMapPropDef = new PropertyDefinitionMap("OpenMapOfSimples", "an open map of simples",
false);
openMapPropDef.setDisplayName(openMapPropDef.getName());
- addPropertyDefinition(propertyDefinitions, openMapPropDef, orderIndex++);
+ addPropertyDefinition(configDef, openMapPropDef, orderIndex++);
PropertyDefinitionMap readOnlyOpenMapPropDef = new PropertyDefinitionMap("ReadOnlyOpenMapOfSimples",
"a read-only open map of simples", false);
readOnlyOpenMapPropDef.setDisplayName(readOnlyOpenMapPropDef.getName());
readOnlyOpenMapPropDef.setReadOnly(true);
- addPropertyDefinition(propertyDefinitions, readOnlyOpenMapPropDef, orderIndex++);
+ addPropertyDefinition(configDef, readOnlyOpenMapPropDef, orderIndex++);
PropertyDefinitionList listOfSimplesPropDef = new PropertyDefinitionList("ListOfSimples",
"a list of Integer simples", true, new PropertyDefinitionSimple("integer", "an integer", false,
PropertySimpleType.INTEGER));
listOfSimplesPropDef.setDisplayName(listOfSimplesPropDef.getName());
- addPropertyDefinition(propertyDefinitions, listOfSimplesPropDef, orderIndex++);
+ addPropertyDefinition(configDef, listOfSimplesPropDef, orderIndex++);
PropertyDefinitionMap mapInListPropDef =
new PropertyDefinitionMap("MapOfSimplesInList", "a map of simples in a list", false);
@@ -148,7 +148,7 @@ public abstract class TestConfigurationFactory {
PropertyDefinitionList listPropDef = new PropertyDefinitionList("ListOfMaps", "a list of maps", true,
mapInListPropDef);
listPropDef.setDisplayName(listPropDef.getName());
- addPropertyDefinition(propertyDefinitions, listPropDef, orderIndex++);
+ addPropertyDefinition(configDef, listPropDef, orderIndex++);
PropertyDefinitionMap mapInReadOnlyListPropDef =
new PropertyDefinitionMap("MapOfSimplesInReadOnlyList", "a map of simples in a list", false);
@@ -161,7 +161,7 @@ public abstract class TestConfigurationFactory {
"a read-only list of maps", true, mapInReadOnlyListPropDef);
readOnlyListPropDef.setDisplayName(readOnlyListPropDef.getName());
readOnlyListPropDef.setReadOnly(true);
- addPropertyDefinition(propertyDefinitions, readOnlyListPropDef, orderIndex++);
+ addPropertyDefinition(configDef, readOnlyListPropDef, orderIndex++);
PropertyGroupDefinition propertyGroupDefinition = new PropertyGroupDefinition("myGroup");
propertyGroupDefinition.setDisplayName(propertyGroupDefinition.getName());
@@ -171,14 +171,14 @@ public abstract class TestConfigurationFactory {
PropertySimpleType.STRING);
myString.setDisplayName(myString.getName());
myString.setSummary(true);
- addPropertyDefinition(propertyDefinitions, myString, orderIndex++);
+ addPropertyDefinition(configDef, myString, orderIndex++);
myString.setPropertyGroupDefinition(propertyGroupDefinition);
PropertyDefinitionSimple myString2 = new PropertyDefinitionSimple("myString2", "my other little string", true,
PropertySimpleType.STRING);
myString2.setDisplayName(myString2.getName());
myString2.setSummary(true);
- addPropertyDefinition(propertyDefinitions, myString2, orderIndex++);
+ addPropertyDefinition(configDef, myString2, orderIndex++);
myString2.setPropertyGroupDefinition(propertyGroupDefinition);
PropertyGroupDefinition propertyGroupDefinition2 = new PropertyGroupDefinition("myGroup2");
@@ -189,7 +189,7 @@ public abstract class TestConfigurationFactory {
PropertySimpleType.STRING);
myString3.setDisplayName((myString3.getName()));
myString3.setSummary(true);
- addPropertyDefinition(propertyDefinitions, myString3, orderIndex++);
+ addPropertyDefinition(configDef, myString3, orderIndex++);
myString3.setPropertyGroupDefinition(propertyGroupDefinition2);
PropertyDefinitionSimple enumExample = new PropertyDefinitionSimple("myEnum",
@@ -201,16 +201,16 @@ public abstract class TestConfigurationFactory {
myEnums.add(new PropertyDefinitionEnumeration("Camden", "Camden"));
myEnums.add(new PropertyDefinitionEnumeration("Gloucester", "Gloucester"));
enumExample.setEnumeratedValues(myEnums, false);
- addPropertyDefinition(propertyDefinitions, enumExample, orderIndex++);
+ addPropertyDefinition(configDef, enumExample, orderIndex++);
enumExample.setPropertyGroupDefinition(propertyGroupDefinition2);
- return configurationDefinition;
+ return configDef;
}
- private static void addPropertyDefinition(Map<String, PropertyDefinition> propertyDefinitions,
- PropertyDefinition propDef, int orderIndex) {
+ private static void addPropertyDefinition(ConfigurationDefinition configDef,
+ PropertyDefinition propDef, int orderIndex) {
propDef.setOrder(orderIndex);
- propertyDefinitions.put(propDef.getName(), propDef);
+ configDef.put(propDef);
}
public static Configuration createConfiguration() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java
new file mode 100644
index 0000000..7d71c02
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java
@@ -0,0 +1,139 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * 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.test;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.layout.LayoutSpacer;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.GroupConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.GroupMemberConfiguration;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Ian Springer
+ */
+public class TestGroupConfigurationView
+ extends LocatableVLayout implements PropertyValueChangeListener {
+ public static final String VIEW_ID = "TestGroupConfig";
+
+ private static final int GROUP_SIZE = 2;
+
+ private ConfigurationEditor editor;
+ private LocatableIButton saveButton;
+ private ConfigurationDefinition configurationDefinition;
+ private List<GroupMemberConfiguration> memberConfigurations;
+
+ public TestGroupConfigurationView(String locatorId) {
+ super(locatorId);
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ setWidth100();
+ setHeight100();
+
+ ToolStrip toolStrip = new ToolStrip();
+ toolStrip.setWidth100();
+
+ toolStrip.addMember(new LayoutSpacer());
+
+ this.saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
+ this.saveButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ save();
+ }
+ });
+ this.saveButton.disable();
+ toolStrip.addMember(this.saveButton);
+
+ addMember(toolStrip);
+
+ this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition();
+ this.memberConfigurations = new ArrayList<GroupMemberConfiguration>(GROUP_SIZE);
+ for (int i = 0; i < GROUP_SIZE; i++) {
+ Configuration configuration = TestConfigurationFactory.createConfiguration();
+ GroupMemberConfiguration memberConfiguration = new GroupMemberConfiguration(i, "Member #" + i,
+ configuration);
+ this.memberConfigurations.add(memberConfiguration);
+ }
+
+ reloadConfiguration();
+ }
+
+ @Override
+ public void propertyValueChanged(PropertyValueChangeEvent event) {
+ MessageCenter messageCenter = CoreGUI.getMessageCenter();
+ Message message;
+ if (event.isValidationStateChanged()) {
+ if (event.getInvalidPropertyNames().isEmpty()) {
+ this.saveButton.enable();
+ message = new Message("All properties now have valid values, so the configuration can now be saved.",
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient));
+ }
+ else {
+ this.saveButton.disable();
+ message = new Message(
+ "One or more properties have invalid values. The values must be corrected before the configuration can be saved.",
+ Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ }
+ messageCenter.notify(message);
+ } else {
+ this.saveButton.enable();
+ }
+ }
+
+ private void reloadConfiguration() {
+ this.saveButton.disable();
+ if (editor != null) {
+ editor.destroy();
+ removeMember(editor);
+ }
+
+ editor = new GroupConfigurationEditor(extendLocatorId("Editor"), this.configurationDefinition,
+ this.memberConfigurations);
+ editor.setOverflow(Overflow.AUTO);
+ editor.addPropertyValueChangeListener(this);
+ addMember(editor);
+ }
+
+ private void save() {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Member configurations updated.", "Member configurations updated."));
+ reloadConfiguration();
+ }
+}
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 3314eeb..ce0ce25 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
@@ -24,6 +24,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.JavaScriptObject;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
@@ -328,7 +329,7 @@ public abstract class RPCDataSource<T> extends DataSource {
@SuppressWarnings("unchecked")
public static <S> S getFilter(DSRequest request, String paramName, Class<S> type) {
- com.allen_sauer.gwt.log.client.Log.debug("Fetching " + paramName + " (" + type + ")");
+ Log.debug("Fetching " + paramName + " (" + type + ")");
Criteria criteria = request.getCriteria();
Map<String, Object> criteriaMap = criteria.getValues();
@@ -350,7 +351,7 @@ public abstract class RPCDataSource<T> extends DataSource {
}
}
- com.allen_sauer.gwt.log.client.Log.debug("Result = " + result);
+ Log.debug("Result = " + result);
return result;
}
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
index 54cc3a9..d60a616 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
+++ b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.css
@@ -386,6 +386,10 @@ a:hover {
border-color: #EE1111; /* slightly darker medium red */
}
+.InlineNote {
+ color: #511;
+}
+
.log-panel {
z-index: 9999999 !important;
}
commit 3cdfaed39fe6197cc4a825ba1c9adcb9c3f1892d
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Oct 19 16:47:59 2010 -0400
use the correct cased name of the GroupCategory for filtering groups in the inventory borwser
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index a1683dc..fcef030 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -39,6 +39,7 @@ import com.smartgwt.client.widgets.tree.TreeNode;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewId;
@@ -138,7 +139,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
if (selectionEvent.getState()) {
- TreeNode node = (TreeNode)selectionEvent.getRecord();
+ TreeNode node = (TreeNode) selectionEvent.getRecord();
String pageName = node.getName();
String viewPath = InventoryView.VIEW_ID + "/" + sectionName + "/" + pageName;
String currentViewPath = History.getToken();
@@ -170,7 +171,8 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
final TreeNode onlyServices = new EnhancedTreeNode(PAGE_SERVICES);
onlyServices.setIcon("types/Service_up_16.png");
- final TreeNode inventory = new EnhancedTreeNode(SUBSECTION_RESOURCE_INVENTORY, onlyPlatforms, onlyServers, onlyServices);
+ final TreeNode inventory = new EnhancedTreeNode(SUBSECTION_RESOURCE_INVENTORY, onlyPlatforms, onlyServers,
+ onlyServices);
final TreeNode downServers = new EnhancedTreeNode(PAGE_DOWN);
downServers.setIcon("types/Server_down_16.png");
@@ -209,7 +211,8 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
TreeGrid treeGrid = new LocatableTreeGrid(GROUPS_SECTION_VIEW_ID);
treeGrid.setShowHeader(false);
Tree tree = new Tree();
- TreeNode rootNode = new EnhancedTreeNode(GROUPS_SECTION_VIEW_ID, groupGroupDefinitions, inventory, savedSearches);
+ TreeNode rootNode = new EnhancedTreeNode(GROUPS_SECTION_VIEW_ID, groupGroupDefinitions, inventory,
+ savedSearches);
tree.setRoot(rootNode);
treeGrid.setData(tree);
@@ -263,10 +266,10 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
} else if (GROUPS_SECTION_VIEW_ID.equals(sectionName)) {
if (PAGE_COMPATIBLE_GROUPS.equals(pageName)) {
content = new ResourceGroupListView(extendLocatorId("Compatible"), new Criteria("category",
- "compatible"), PAGE_COMPATIBLE_GROUPS, "types/Cluster_up_24.png");
+ GroupCategory.COMPATIBLE.name()), PAGE_COMPATIBLE_GROUPS, "types/Cluster_up_24.png");
} else if (PAGE_MIXED_GROUPS.equals(pageName)) {
- content = new ResourceGroupListView(extendLocatorId("Mixed"), new Criteria("category", "mixed"),
- PAGE_MIXED_GROUPS, "types/Group_up_24.png");
+ content = new ResourceGroupListView(extendLocatorId("Mixed"), new Criteria("category",
+ GroupCategory.MIXED.name()), PAGE_MIXED_GROUPS, "types/Group_up_24.png");
} else if (PAGE_GROUP_DEFINITIONS.equals(pageName)) {
content = new GroupDefinitionListView(extendLocatorId("Definitions"), "types/GroupDefinition_16.png");
} else if (PAGE_PROBLEM_GROUPS.equals(pageName)) {
commit fec18e5250c61671c12ac0ec80bf617c06c489f1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Oct 19 15:46:56 2010 -0400
use locatable
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
index 5cf3937..47a97c9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
@@ -34,7 +34,6 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.tab.TabSet;
@@ -47,23 +46,26 @@ import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Joseph Marques
+ * @author Ian Springer
*/
-public class AlertDetailsView extends VLayout implements BookmarkableView {
+public class AlertDetailsView extends LocatableVLayout implements BookmarkableView {
private int alertId;
private ViewId viewId;
- private static AlertDetailsView INSTANCE = new AlertDetailsView();
+ private static AlertDetailsView INSTANCE = new AlertDetailsView("alertDetailsView");
public static AlertDetailsView getInstance() {
return INSTANCE;
}
- private AlertDetailsView() {
+ private AlertDetailsView(String locatorId) {
// access through the static singleton only
+ super(locatorId);
}
private void show(int alertId) {
commit 29d5db075f19213dc2536e1ba19ba7769a23de44
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Oct 19 15:25:44 2010 -0400
adding new dependencies to eclipse classpath so we can build again in eclipse
diff --git a/.classpath b/.classpath
index 7d1cd22..ecbd0c8 100644
--- a/.classpath
+++ b/.classpath
@@ -143,6 +143,7 @@
<classpathentry kind="src" path="modules/helpers/rtfilter/src/main/java"/>
<classpathentry kind="src" path="modules/helpers/pluginAnnotations/src/main/java"/>
<classpathentry kind="src" path="modules/helpers/pluginGen/src/main/java"/>
+ <classpathentry kind="src" path="modules/helpers/perftest-support/src/main/java"/>
<classpathentry kind="src" path="etc/samples/skeleton-plugin/src/main/java"/>
<classpathentry kind="src" path="etc/samples/custom-serverplugin/src/main/java"/>
<classpathentry kind="src" path="etc/samples/simplereport-serverplugin/src/main/java"/>
@@ -171,7 +172,7 @@
<classpathentry exported="true" kind="var" path="M2_REPO/struts/struts/1.2.9/struts-1.2.9.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/javax/servlet/jsp-api/2.0/jsp-api-2.0.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/commons-validator/commons-validator/1.1.4/commons-validator-1.1.4.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/testng/testng/5.9/testng-5.9-jdk15.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/testng/testng/5.13.1/testng-5.13.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/snmp4j/snmp4j/1.8.2/snmp4j-1.8.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/tomcat/tomcat-jk/4.1.31/tomcat-jk-4.1.31.jar"/>
@@ -256,5 +257,8 @@
<classpathentry exported="true" kind="var" path="M2_REPO/ca/nanometrics/gflot/1.0.0/gflot-1.0.0.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/com/jcraft/jsch/0.1.29/jsch-0.1.29.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/commons-jxpath/commons-jxpath/1.3/commons-jxpath-1.3.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/dbunit/dbunit/2.4.8/dbunit-2.4.8.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/apache/poi/poi/3.6/poi-3.6.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/bsh/bsh/1.3.0/bsh-1.3.0.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
commit f167d3614e58cc62e02de088b1d3dcaae7a3a19a
Merge: 0f62ed4... 501e5d1...
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Oct 19 14:07:04 2010 -0400
Merge branch 'delete-agent-plugin'
commit 0f62ed4950ae6f39a9905ba614ad2bba8ea3c44b
Merge: e60ff62... 81d68da...
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Oct 19 13:16:52 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 81d68daebaef5b91130f80ec70f759adcf5b7b6d
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Oct 19 11:25:27 2010 -0400
bz 644344 - if the user is attempting to log in as the user "admin", fail.
without this patch, someone can create a user "admin" in LDAP and get overlord access.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCLoginModule.java
index a77b183..c9cf6d0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCLoginModule.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCLoginModule.java
@@ -25,6 +25,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
import java.util.Properties;
+
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.security.auth.Subject;
@@ -32,10 +33,13 @@ import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.FailedLoginException;
import javax.security.auth.login.LoginException;
import javax.sql.DataSource;
+
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.RHQConstants;
/**
@@ -94,6 +98,9 @@ public class JDBCLoginModule extends UsernamePasswordLoginModule {
@Override
protected String getUsersPassword() throws LoginException {
String username = getUsername();
+ if ("admin".equals(username)) {
+ throw new FailedLoginException("Cannot log in as overlord");
+ }
String password = null;
Connection conn = null;
PreparedStatement ps = null;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCPrincipalCheckLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCPrincipalCheckLoginModule.java
index f56747a..e862db9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCPrincipalCheckLoginModule.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCPrincipalCheckLoginModule.java
@@ -87,6 +87,9 @@ public class JDBCPrincipalCheckLoginModule extends UsernamePasswordLoginModule {
@Override
protected String getUsersPassword() throws LoginException {
String username = getUsername();
+ if ("admin".equals(username)) {
+ throw new FailedLoginException("Cannot log in as overlord");
+ }
String password = getUsernameAndPassword()[1]; // what did the user enter?
Connection conn = null;
PreparedStatement ps = null;
13 years, 8 months
[rhq] modules/enterprise
by John Sanda
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
New commits:
commit 96e0b10bc8c6f02608c744a8741165d10f881af4
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Oct 20 11:20:39 2010 -0400
Replacing call to finder method that has been removed in favor of criteria query
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp
index 2cc3da3..173fe16 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp
@@ -7,6 +7,7 @@
<%@ page import="org.rhq.core.domain.util.PageControl" %>
<%@ page import="org.rhq.core.domain.util.PageList" %>
<%@ page import="org.rhq.core.domain.util.PageOrdering" %>
+<%@ page import="org.rhq.core.domain.criteria.AlertCriteria" %>
<%@ page import="org.rhq.enterprise.gui.common.tag.FunctionTagLibrary" %>
<%@ page import="org.rhq.enterprise.gui.legacy.ParamConstants" %>
<%@ page import="org.rhq.enterprise.gui.legacy.WebUser" %>
@@ -29,8 +30,14 @@
PageControl pc = new PageControl(0, 100);
pc.setPrimarySortOrder(PageOrdering.DESC);
- PageList<Alert> alerts = alertManager.findAlerts(resourceId, null, null, begin, end, pc);
+ AlertCriteria criteria = new AlertCriteria();
+ criteria.addFilterResourceIds(resourceId);
+ criteria.addFilterStartTime(begin);
+ criteria.addFilterEndTime(end);
+ criteria.setPageControl(pc);
+
+ PageList<Alert> alerts = alertManager.findAlertsByCriteria(user.getSubject(), criteria);
%>
{ "events":
13 years, 8 months