[rhq] 2 commits - modules/common modules/plugins
by John Sanda
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties | 2 -
modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties | 2 -
modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java | 18 ++--------
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java | 1
4 files changed, 7 insertions(+), 16 deletions(-)
New commits:
commit 0ac8a7e2edaf051813cb7fb70ef9f8ab3136cfda
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Aug 22 15:31:22 2013 -0400
restrict jmx access to storage node to localhost
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties
index 2eb5ab5..1a1a8c2 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties
@@ -107,6 +107,6 @@ GC_TUNING_OPTS="${use_par_new_gc} ${use_concur_mark_sweep_gc} ${cms_parallel_rem
GC_LOGGING_OPTS="${print_gc_details} ${print_gc_datestamps} ${print_heap_at_gc} ${print_tenuring_distribution} ${print_gc_application_stopped_time} ${print_promotion_failure} ${print_flss_stats} ${gc_log_file}"
-JMX_OPTS="-Dcom.sun.management.jmxremote.port=${jmx_port} -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
+JMX_OPTS="-Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.port=${jmx_port} -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
JVM_OPTS="${enable_assertions} ${java_agent} ${use_thread_priorities} ${thread_priority_policy} ${HEAP_OPTS} ${GC_TUNING_OPTS} ${GC_LOGGING_OPTS} ${JMX_OPTS}"
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties
index 588fb3d..2951eaa 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties
@@ -107,6 +107,6 @@ GC_TUNING_OPTS="${use_par_new_gc} ${use_concur_mark_sweep_gc} ${cms_parallel_rem
GC_LOGGING_OPTS="${print_gc_details} ${print_gc_datestamps} ${print_heap_at_gc} ${print_tenuring_distribution} ${print_gc_application_stopped_time} ${print_promotion_failure} ${print_flss_stats} ${gc_log_file}"
-JMX_OPTS="-Dcom.sun.management.jmxremote.port=${jmx_port} -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
+JMX_OPTS="-Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.port=${jmx_port} -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
JVM_OPTS="${enable_assertions} ${java_agent} ${use_thread_priorities} ${thread_priority_policy} ${HEAP_OPTS} ${GC_TUNING_OPTS} ${GC_LOGGING_OPTS} ${JMX_OPTS}"
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
index 0fba996..96da057 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
@@ -81,6 +81,7 @@ import org.rhq.plugins.jmx.JMXServerComponent;
public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent<?>> implements OperationFacet {
private static final Log log = LogFactory.getLog(CassandraNodeComponent.class);
+ private Cluster cluster;
private Session cassandraSession;
private String host;
private ProcessInfo processInfo;
commit dd6b6348a63e8fdc98f926d057dba61c50bfe0ca
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Aug 22 15:28:12 2013 -0400
only store the nodes own address in rhq-storage-auth.conf
diff --git a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
index 3686b6f..bc98a20 100644
--- a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
+++ b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
@@ -386,7 +386,10 @@ public class StorageInstaller {
deployer.unzipDistro();
deployer.applyConfigChanges();
deployer.updateFilePerms();
- deployer.updateStorageAuthConf(getAddresses(hostname, seeds));
+
+ Set<InetAddress> addresses = new HashSet<InetAddress>();
+ addresses.add(InetAddress.getByName(hostname));
+ deployer.updateStorageAuthConf(addresses);
log.info("Finished installing RHQ Storage Node.");
@@ -500,19 +503,6 @@ public class StorageInstaller {
return dir;
}
- private Set<InetAddress> getAddresses(String hostname, String seeds) throws IOException {
- Set<InetAddress> addresses = new HashSet<InetAddress>();
- addresses.add(InetAddress.getByName(hostname));
-
- if (!StringUtil.isEmpty(seeds)) {
- for (String seed : seeds.split(",")) {
- addresses.add(InetAddress.getByName(seed));
- }
- }
-
- return addresses;
- }
-
private PropertiesFileUpdate getServerProperties() {
String sysprop = System.getProperty("rhq.server.properties-file");
if (sysprop == null) {
10 years, 10 months
[rhq] modules/common
by snegrea
modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit bb4bba14f5ecb3e5dfe87f4abfbb0f0f4ffecbae
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 22 15:10:21 2013 -0500
[BZ 999555] Obfuscate the cassandra super user default password in the schema manager code.
diff --git a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java
index 039d749..fb9f127 100644
--- a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java
+++ b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java
@@ -48,7 +48,7 @@ abstract class AbstractManager {
private static final String MANAGEMENT_BASE_FOLDER = "management";
protected static final String DEFAULT_CASSANDRA_USER = "cassandra";
- protected static final String DEFAULT_CASSANDRA_PASSWORD = "cassandra";
+ protected static final String DEFAULT_CASSANDRA_PASSWORD = "-1e4662ac0d7ddef155fd5fac8f894a49";
private final Log log = LogFactory.getLog(AbstractManager.class);
10 years, 10 months
[rhq] modules/plugins
by Jay Shaughnessy
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java | 51 +++++-----
1 file changed, 26 insertions(+), 25 deletions(-)
New commits:
commit 4ab55e2fa95282b5d1ecd26ef30a86910a7d1974
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Aug 22 14:03:35 2013 -0400
Bug 998968 - add EPP product slot to EAP 5 plug-in
(On behalf of Larry O'Leary)
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java
index 312ea80..784fd43 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java
@@ -1,25 +1,21 @@
/*
-* Jopr Management Platform
-* Copyright (C) 2005-2012 Red Hat, Inc.
-* All rights reserved.
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License, version 2, as
-* published by the Free Software Foundation, and/or the GNU Lesser
-* General Public License, version 2.1, also as published by the Free
-* Software Foundation.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License and the GNU Lesser General Public License
-* for more details.
-*
-* You should have received a copy of the GNU General Public License
-* and the GNU Lesser General Public License along with this program;
-* if not, write to the Free Software Foundation, Inc.,
-* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
+ * RHQ Management Platform
+ * Copyright (C) 2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
package org.rhq.plugins.jbossas5.helper;
import java.util.jar.Attributes;
@@ -35,7 +31,8 @@ public enum JBossProductType {
EAP("JBoss EAP", "JBoss Enterprise Application Platform", "default"),
EWP("JBoss EWP", "JBoss Enterprise Web Platform", "default"),
SOA("JBoss SOA-P", "JBoss Enterprise SOA Platform", "default"),
- BRMS("JBoss BRMS", "JBoss Business Rules Management System", "default");
+ BRMS("JBoss BRMS", "JBoss Business Rules Management System", "default"),
+ EPP("JBoss EPP", "JBoss Enterprise Portal Platform", "default");
public final String NAME;
public final String DESCRIPTION;
@@ -45,6 +42,7 @@ public enum JBossProductType {
private static final String EWP_IMPLEMENTATION_TITLE = "JBoss [EWP]";
private static final String SOA_IMPLEMENTATION_TITLE = "JBoss [SOA]";
private static final String BRMS_IMPLEMENTATION_TITLE = "JBoss [BRMS]";
+ private static final String EPP_IMPLEMENTATION_TITLE = "JBoss [EPP]";
JBossProductType(String name, String description, String defaultConfigName) {
this.NAME = name;
@@ -53,7 +51,8 @@ public enum JBossProductType {
}
/**
- * Determines the product type (AS, EAP, EWP, or SOA) based on the Implementation-Title MANIFEST.MF attribute.
+ * Determines the product type (AS or EAP or a layered product like BRMS) based on the
+ * Implementation-Title MANIFEST.MF attribute.
* <p>
* Note that this method is <b>NOT</b> always correct about the actual version of the product, because
* certain version of certain products don't advertise the correct product/version in the manifest.
@@ -62,7 +61,7 @@ public enum JBossProductType {
*
* @param attributes the attributes from a manifest file (typically run.jar or jboss-j2ee.jar)
*
- * @return the product type (AS, EAP, EWP, or SOA)
+ * @return the product type (AS, EAP, EWP, SOA, BRMS, or EPP)
*/
public static JBossProductType determineJBossProductType(Attributes attributes) {
JBossProductType result = JBossProductType.AS;
@@ -77,7 +76,9 @@ public enum JBossProductType {
result = JBossProductType.SOA;
} else if (implementationTitle.equalsIgnoreCase(BRMS_IMPLEMENTATION_TITLE)) {
result = JBossProductType.BRMS;
- }
+ } else if (implementationTitle.equalsIgnoreCase(EPP_IMPLEMENTATION_TITLE)) {
+ result = JBossProductType.EPP;
+ }
}
return result;
}
10 years, 10 months
[rhq] 2 commits - modules/common modules/enterprise modules/plugins
by snegrea
modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java | 8 -
modules/enterprise/server/data-migration/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java | 10 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java | 25 ++--
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java | 60 +++++-----
4 files changed, 59 insertions(+), 44 deletions(-)
New commits:
commit 3989e6ba88ae9bc99a85af859ac266bb8307c562
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 22 12:22:53 2013 -0500
Refactor log variable name.
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
index 09cc77e..0fba996 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
@@ -79,7 +79,7 @@ import org.rhq.plugins.jmx.JMXServerComponent;
* @author John Sanda
*/
public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent<?>> implements OperationFacet {
- private static final Log LOG = LogFactory.getLog(CassandraNodeComponent.class);
+ private static final Log log = LogFactory.getLog(CassandraNodeComponent.class);
private Session cassandraSession;
private String host;
@@ -104,7 +104,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
nativePort = Integer.parseInt(context.getPluginConfiguration()
.getSimpleValue("nativeTransportPort", "9042"));
} catch (Exception e) {
- LOG.debug("Native transport port parsing failed...", e);
+ log.debug("Native transport port parsing failed...", e);
}
@@ -124,7 +124,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
this.cassandraSession = cluster.connect(clusterName);
} catch (Exception e) {
- LOG.error("Connecting to Cassandra " + host + ":" + nativePort
+ log.error("Connecting to Cassandra " + host + ":" + nativePort
+ " failed. Attempting to shutdown the cluster manager and all the connections.", e);
try {
@@ -132,7 +132,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
cluster.shutdown();
}
} catch (Exception shutdownException) {
- LOG.error("Failed attempt to shutdown the cluster manager.", shutdownException);
+ log.error("Failed attempt to shutdown the cluster manager.", shutdownException);
}
throw e;
@@ -142,9 +142,9 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
@Override
public void stop() {
processInfo = null;
- LOG.info("Shutting down Cassandra client");
+ log.info("Shutting down Cassandra client");
cassandraSession.getCluster().shutdown();
- LOG.info("Shutdown is complete");
+ log.info("Shutdown is complete");
}
@Override
@@ -157,11 +157,11 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
return AvailabilityType.DOWN;
} finally {
long totalTimeMillis = NANOSECONDS.toMillis(System.nanoTime() - start);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Finished availability check in " + totalTimeMillis + " ms");
+ if (log.isDebugEnabled()) {
+ log.debug("Finished availability check in " + totalTimeMillis + " ms");
}
if (totalTimeMillis > SECONDS.toMillis(5)) {
- LOG.warn("Availability check exceeded five seconds. Total time was " + totalTimeMillis + " ms");
+ log.warn("Availability check exceeded five seconds. Total time was " + totalTimeMillis + " ms");
}
}
}
@@ -182,8 +182,8 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
return true;
} catch (Exception e) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Failed to make JMX connection to StorageService", e);
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to make JMX connection to StorageService", e);
}
return false;
} finally {
@@ -191,8 +191,8 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
try {
connector.close();
} catch (IOException e) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("An error occurred closing the JMX connector", e);
+ if (log.isDebugEnabled()) {
+ log.debug("An error occurred closing the JMX connector", e);
}
}
}
@@ -220,28 +220,28 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
protected OperationResult shutdownNode() {
ResourceContext<?> context = getResourceContext();
- if (LOG.isInfoEnabled()) {
- LOG.info("Starting shutdown operation on " + CassandraNodeComponent.class.getName() +
+ if (log.isInfoEnabled()) {
+ log.info("Starting shutdown operation on " + CassandraNodeComponent.class.getName() +
" with resource key " + context.getResourceKey());
}
EmsConnection emsConnection = getEmsConnection();
EmsBean storageService = emsConnection.getBean("org.apache.cassandra.db:type=StorageService");
Class[] emptyParams = new Class[0];
- if (LOG.isDebugEnabled()) {
- LOG.debug("Disabling thrift...");
+ if (log.isDebugEnabled()) {
+ log.debug("Disabling thrift...");
}
EmsOperation operation = storageService.getOperation("stopRPCServer", emptyParams);
operation.invoke((Object[]) emptyParams);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Disabling gossip...");
+ if (log.isDebugEnabled()) {
+ log.debug("Disabling gossip...");
}
operation = storageService.getOperation("stopGossiping", emptyParams);
operation.invoke((Object[]) emptyParams);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Initiating drain...");
+ if (log.isDebugEnabled()) {
+ log.debug("Initiating drain...");
}
operation = storageService.getOperation("drain", emptyParams);
operation.invoke((Object[]) emptyParams);
@@ -253,7 +253,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
ProcessInfo process = getResourceContext().getNativeProcess();
if (process == null) {
- LOG.warn("Failed to obtain process info. It appears Cassandra is already shutdown.");
+ log.warn("Failed to obtain process info. It appears Cassandra is already shutdown.");
return new OperationResult("Failed to obtain process info. It appears Cassandra is already shutdown.");
}
@@ -270,7 +270,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
return new OperationResult("Successfully shut down Cassandra daemon with pid " + pid);
} catch (SigarException e) {
- LOG.warn("Failed to shut down Cassandra node with pid " + pid, e);
+ log.warn("Failed to shut down Cassandra node with pid " + pid, e);
OperationResult failure = new OperationResult("Failed to shut down Cassandra node with pid " + pid);
failure.setErrorMessage(ThrowableUtil.getAllMessages(e));
return failure;
@@ -377,7 +377,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
try {
updateSeedsList(addresses);
} catch (Exception e) {
- LOG.error("An error occurred while updating the seeds list property", e);
+ log.error("An error occurred while updating the seeds list property", e);
Throwable rootCause = ThrowableUtil.getRootCause(e);
result.setErrorMessage(ThrowableUtil.getStackAsString(rootCause));
}
@@ -398,7 +398,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
try {
addresses = convertToIPAddresses(seeds);
} catch (UnknownHostException e) {
- LOG.error("Failed to update seeds list", e);
+ log.error("Failed to update seeds list", e);
throw new IOException("Failed to update seeds list. Make sure that " + seeds + " is a list of valid " +
"hostnames or IP addresses that can be resolved.", e);
}
@@ -450,7 +450,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
if (!yamlFile.delete()) {
String msg = "Failed to delete [" + yamlFile + "] in preparation of writing updated configuration. The " +
"changes will be aborted.";
- LOG.error(msg);
+ log.error(msg);
deleteYamlBackupFile(yamlFileBackup);
throw new IOException(msg);
}
@@ -460,8 +460,8 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
yaml.dump(cassandraConfig, writer);
deleteYamlBackupFile(yamlFileBackup);
} catch (Exception e) {
- LOG.error("An error occurred while trying to write the updated configuration back to " + yamlFile, e);
- LOG.error("Reverting changes to " + yamlFile);
+ log.error("An error occurred while trying to write the updated configuration back to " + yamlFile, e);
+ log.error("Reverting changes to " + yamlFile);
if (yamlFile.delete()) {
StreamUtil.copy(new FileInputStream(yamlFileBackup), new FileOutputStream(yamlFile));
@@ -469,7 +469,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
} else {
String msg = "Failed updates to " + yamlFile.getName() + " cannot be rolled back. The file cannot be " +
"deleted. " + yamlFile + " should be replaced by " + yamlFileBackup;
- LOG.error(msg);
+ log.error(msg);
throw new IOException(msg);
}
} finally {
@@ -488,7 +488,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
private void deleteYamlBackupFile(File yamlBackup) {
if (!yamlBackup.delete()) {
- LOG.warn("Failed to delete Cassandra configuration backup file [" + yamlBackup + "]. This file " +
+ log.warn("Failed to delete Cassandra configuration backup file [" + yamlBackup + "]. This file " +
"should be deleted.");
}
}
commit 88402f779d9ea848af27e1b660aff0032f2aeeac
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 22 12:21:20 2013 -0500
Properly close Cassandra cluster sessions in the rest of the code (schema manager, storage cluster client manager bean, data migrator).
diff --git a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java
index 3a6bf21..039d749 100644
--- a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java
+++ b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java
@@ -66,6 +66,7 @@ abstract class AbstractManager {
}
}
+ private Cluster cluster;
private Session session;
private final String username;
private final String password;
@@ -108,10 +109,9 @@ abstract class AbstractManager {
protected void initClusterSession(String username, String password) {
shutdownClusterConnection();
-
log.info("Initializing storage node session.");
- Cluster cluster = new ClusterBuilder().addContactPoints(nodes).withCredentialsObfuscated(username, password)
+ cluster = new ClusterBuilder().addContactPoints(nodes).withCredentialsObfuscated(username, password)
.withPort(this.getCqlPort()).withCompression(Compression.NONE).build();
log.info("Cluster connection configured.");
@@ -125,8 +125,8 @@ abstract class AbstractManager {
*/
protected void shutdownClusterConnection() {
log.info("Shutting down existing cluster connections");
- if (session != null && session.getCluster() != null) {
- session.getCluster().shutdown();
+ if (cluster != null) {
+ cluster.shutdown();
}
}
diff --git a/modules/enterprise/server/data-migration/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java b/modules/enterprise/server/data-migration/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java
index 5e0861e..b145d92 100644
--- a/modules/enterprise/server/data-migration/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java
+++ b/modules/enterprise/server/data-migration/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java
@@ -652,7 +652,7 @@ public class DataMigratorRunner {
* @param session
*/
private void closeCassandraSession(Session session) {
- session.shutdown();
+ session.getCluster().shutdown();
}
/**
@@ -688,7 +688,13 @@ public class DataMigratorRunner {
(String) configuration.get(cassandraPasswordOption))
.build();
- return cluster.connect("rhq");
+ try {
+ return cluster.connect("rhq");
+ } catch (Exception e) {
+ log.debug("Failed to connect to the storage cluster.", e);
+ cluster.shutdown();
+ throw e;
+ }
}
/**
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
index 09de080..c6a21bd 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
@@ -67,6 +67,7 @@ public class StorageClientManagerBean {
@EJB
private StorageNodeManagerLocal storageNodeManager;
+ private Cluster cluster;
private StorageSession session;
private MetricsConfiguration metricsConfiguration;
private MetricsDAO metricsDAO;
@@ -136,16 +137,24 @@ public class StorageClientManagerBean {
}
public synchronized void shutdown() {
- if (!initialized) {
- log.info("Storage client subsystem is already shut down. Skipping shutdown steps.");
- return;
+ log.info("Shutting down storage client subsystem");
+
+ if (metricsServer != null) {
+ metricsServer.shutdown();
+ metricsServer = null;
}
- log.info("Shutting down storage client subsystem");
- metricsServer.shutdown();
metricsDAO = null;
- metricsServer = null;
- session.getCluster().shutdown();
+
+ try {
+ if (cluster != null) {
+ cluster.shutdown();
+ }
+ } catch (Exception e) {
+ log.error("Failed to shutdown the cluster connection manager for the storage cluster.", e);
+ }
+
+ cluster = null;
session = null;
initialized = false;
}
@@ -192,7 +201,7 @@ public class StorageClientManagerBean {
log.debug("Storage client compression is disabled");
}
- Cluster cluster = new ClusterBuilder()
+ cluster = new ClusterBuilder()
.addContactPoints(hostNames.toArray(new String[hostNames.size()]))
.withCredentialsObfuscated(username, password)
.withPort(port)
10 years, 10 months
[rhq] modules/plugins
by snegrea
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java | 17 ++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
New commits:
commit 73a6f01b2d56f4e30e3423f42193b7fd9956bae3
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 22 11:54:52 2013 -0500
Shutdown the cluster manager if the session connection fails; otherwise various mananger specific connections could remain open.
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
index d648ad8..09cc77e 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
@@ -108,6 +108,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
}
+ Cluster cluster = null;
try {
Builder clusterBuilder = Cluster
.builder()
@@ -119,9 +120,21 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
clusterBuilder = clusterBuilder.withCredentials(username, password);
}
- this.cassandraSession = clusterBuilder.build().connect(clusterName);
+ cluster = clusterBuilder.build();
+
+ this.cassandraSession = cluster.connect(clusterName);
} catch (Exception e) {
- LOG.error("Connect to Cassandra " + host + ":" + nativePort, e);
+ LOG.error("Connecting to Cassandra " + host + ":" + nativePort
+ + " failed. Attempting to shutdown the cluster manager and all the connections.", e);
+
+ try {
+ if (cluster != null) {
+ cluster.shutdown();
+ }
+ } catch (Exception shutdownException) {
+ LOG.error("Failed attempt to shutdown the cluster manager.", shutdownException);
+ }
+
throw e;
}
};
10 years, 10 months
[rhq] 2 commits - modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java | 10 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleCreateWizard.java | 36 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java | 13 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java | 6 -
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 6 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties | 4 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 6 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 4 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties | 6 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 4 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties | 6 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 6 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 8 --
13 files changed, 56 insertions(+), 59 deletions(-)
New commits:
commit 51e7603225aab6f19de163c50333313b537fb5de
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Aug 22 11:24:04 2013 -0400
- Fix some error handling workflows
- Complete I18N support
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java
index 4613477..81ad9cc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java
@@ -110,7 +110,7 @@ public abstract class AbstractBundleCreateWizard extends AbstractWizard {
public void cancel() {
final BundleVersion bv = getBundleVersion();
if (bv != null) {
- // the user must have created it already after verification step, delete it
+ // the user must have created it already after verification step, delete it, if possible
BundleGWTServiceAsync bundleServer = GWTServiceLookup.getBundleService();
bundleServer.deleteBundleVersion(bv.getId(), true, new AsyncCallback<Void>() {
public void onSuccess(Void result) {
@@ -120,8 +120,12 @@ public abstract class AbstractBundleCreateWizard extends AbstractWizard {
}
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_bundle_createWizard_cancelFailure(bv.getName(), bv.getVersion()), caught);
+ String msg = MSG.view_bundle_createWizard_cancelFailure(bv.getName(), bv.getVersion());
+ // provide a more specific message if the cancel failed due to the user not having delete permission
+ if (caught.getMessage().contains("PermissionException")) {
+ msg = MSG.view_bundle_createWizard_cancelFailurePerm(bv.getName(), bv.getVersion());
+ }
+ CoreGUI.getErrorHandler().handleError(msg, caught);
}
});
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleCreateWizard.java
index cfc568a..b638625 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleCreateWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleCreateWizard.java
@@ -44,40 +44,4 @@ public class BundleCreateWizard extends AbstractBundleCreateWizard {
steps.add(new BundleSummaryStep(this));
setSteps(steps);
}
-
- // @Override
- // public void startWizard() {
- // BundleGWTServiceAsync bundleServer = GWTServiceLookup.getBundleService();
- //
- // if (globalPermissions.contains(Permission.VIEW_BUNDLES)) {
- // bundleServer.findBundleGroupsByCriteria(new BundleGroupCriteria(),
- // new AsyncCallback<PageList<BundleGroup>>() {
- // public void onSuccess(PageList<BundleGroup> result) {
- //
- // }
- //
- // public void onFailure(Throwable caught) {
- // // TODO
- // }
- // });
- //
- // } else {
- //
- // bundleServer.getCreateBundleGroups(new AsyncCallback<HashSet<BundleGroup>>() {
- // public void onSuccess(HashSet<BundleGroup> result) {
- //
- // }
- //
- // public void onFailure(Throwable caught) {
- // // TODO
- // }
- // });
- //
- //
- // // TODO Auto-generated method stub
- // super.startWizard();
- //
- // }
- //
- // }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java
index 487aedb..f19153d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java
@@ -338,19 +338,18 @@ public class BundleGroupsStep extends AbstractWizardStep {
.getBundle().getId() }, new AsyncCallback<Void>() {
@Override
public void onSuccess(Void result) {
- // I18N
CoreGUI.getMessageCenter().notify(
- new Message("MSG.view_bundle_createWizard_assignSuccessful(result.getName(), result.getVersion())",
- Message.Severity.Info));
+ new Message(MSG.view_bundle_createWizard_groupsStep_successAssign(wizard.getBundleVersion()
+ .getBundle().getName(), wizard.getBundleVersion().getName()), Message.Severity.Info));
wizard.getView().incrementStep(); // go to the next step
}
@Override
public void onFailure(Throwable caught) {
- wizard.getView().showMessage(caught.getMessage());
- CoreGUI.getErrorHandler().handleError(MSG.view_bundle_createWizard_createFailure(), caught);
- wizard.setBundleVersion(null);
- wizard.setCreateInitialBundleVersionRecipe("");
+ String msg = MSG.view_bundle_createWizard_groupsStep_failedAssign(wizard.getBundleVersion().getBundle()
+ .getName(), wizard.getBundleVersion().getName());
+ wizard.getView().showMessage(msg);
+ CoreGUI.getErrorHandler().handleError(msg, caught);
}
});
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java
index f86adff..3a0cdfd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java
@@ -327,11 +327,11 @@ public class BundleUploadDistroFileStep extends AbstractWizardStep {
public void onFailure(Throwable caught) {
setButtonsDisableMode(false);
- // TODO NEW MESSAGE
- CoreGUI.getErrorHandler().handleError("Failed to determine assignable bundle groups.", caught);
+ String message = MSG.view_bundle_createWizard_groupsStep_failedGetAssignable();
+ wizard.getView().showMessage(message);
+ CoreGUI.getErrorHandler().handleError(message, caught);
}
});
-
}
private void processUpload() {
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index b44a67f..ba07960 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -1213,7 +1213,8 @@ view_bundle_bundleType = Bundle Type
view_bundle_bundleVersion = Bundle Version
view_bundle_bundleVersions = Bundle Versions
view_bundle_createWizard_bundleDistro = Bundle Distribution
-view_bundle_createWizard_cancelFailure = Failed to fully cancel the creation of bundle [{0}], version = [{1}] - the bundle may still exist in the database
+view_bundle_createWizard_cancelFailure = Failed to fully cancel the creation of bundle [{0}], version = [{1}] - the bundle may still exist.
+view_bundle_createWizard_cancelFailurePerm = Failed to fully cancel the creation of bundle [{0}], version = [{1}] because the user has create but not delete permissions. The bundle will likley need to be removed by an administrator.
view_bundle_createWizard_cancelSuccessful = Canceled the creation of bundle [{0}], version = [{1}]
view_bundle_createWizard_clickToUploadRecipe = Click to load a recipe file
view_bundle_createWizard_createFailure = Failed to create the bundle
@@ -1224,11 +1225,14 @@ view_bundle_createWizard_failedToUploadDistroFile = Failed to upload bundle dist
view_bundle_createWizard_failedToUploadFile = Failed to upload bundle file
view_bundle_createWizard_groupsStep_assign = Assign at least one of the eligible bundle groups:
view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
+view_bundle_createWizard_groupsStep_failedAssign = Failed to assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]. Please cancel the create wizard and notify your administrator.
+view_bundle_createWizard_groupsStep_failedGetAssignable = Failed to determine assignable bundle groups. Please cancel the create wizard and notify your administrator.
view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
+view_bundle_createWizard_groupsStep_successAssign = You have successfully assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]
view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
view_bundle_createWizard_loadBundleFileFailure = Cannot obtain bundle file information from server
view_bundle_createWizard_noAdditionalFilesNeeded = No additional files need to be uploaded for this bundle
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
index 7ce4b17..bdb265a 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
@@ -1228,6 +1228,7 @@ view_bundle_bundleVersion = Verze balíku
view_bundle_bundleVersions = Verze balíku
view_bundle_createWizard_bundleDistro = Distribuce balíku
view_bundle_createWizard_cancelFailure = Nepodařilo se zrušit vytváření balíku [{0}], verze = [{1}] - balík může stále existovat v databázi
+##view_bundle_createWizard_cancelFailurePerm = Failed to fully cancel the creation of bundle [{0}], version = [{1}] because the user has create but not delete permissions. The bundle will likley need to be removed by an administrator.
view_bundle_createWizard_cancelSuccessful = Zrušeno vytváření balíku [{0}], verze = [{1}]
view_bundle_createWizard_clickToUploadRecipe = Klikněte pro nahrání souboru s receptem
view_bundle_createWizard_createFailure = Nepodařilo se vytvořit balík
@@ -1238,11 +1239,14 @@ view_bundle_createWizard_failedToUploadDistroFile = Nepodařilo se nahrát distr
view_bundle_createWizard_failedToUploadFile = Nepodařilo se nahrát soubor balíku
##view_bundle_createWizard_groupsStep_assign = Assign at least one of the eligible bundle groups:
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
+##view_bundle_createWizard_groupsStep_failedAssign = Failed to assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]. Please cancel the create wizard and notify your administrator.
+##view_bundle_createWizard_groupsStep_failedGetAssignable = Failed to determine assignable bundle groups. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
+##view_bundle_createWizard_groupsStep_successAssign = You have successfully assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
view_bundle_createWizard_loadBundleFileFailure = Nepodařilo se získat soubor s informacemi o balíku ze serveru
view_bundle_createWizard_noAdditionalFilesNeeded = Žádné dodatečné soubory nejsou potřeba pro tento balík
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 6b5e006..f4743a9 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -1130,7 +1130,8 @@ view_bundle_bundleType = Bundle-Type
view_bundle_bundleVersion = Bundle-Version
view_bundle_bundleVersions = Bundle-Versionen
##view_bundle_createWizard_bundleDistro = Bundle Distribution
-##view_bundle_createWizard_cancelFailure = Failed to fully cancel the creation of bundle [{0}], version=[{1}] - the bundle may still exist in the database
+##view_bundle_createWizard_cancelFailure = Failed to fully cancel the creation of bundle [{0}], version=[{1}] - the bundle may still exist.
+##view_bundle_createWizard_cancelFailurePerm = Failed to fully cancel the creation of bundle [{0}], version = [{1}] because the user has create but not delete permissions. The bundle will likley need to be removed by an administrator.
##view_bundle_createWizard_cancelSuccessful = Canceled the creation of bundle [{0}], version=[{1}]
##view_bundle_createWizard_clickToUploadRecipe = Click to upload a recipe file
##view_bundle_createWizard_createFailure = Failed to create the bundle
@@ -1141,11 +1142,14 @@ view_bundle_bundleVersions = Bundle-Versionen
##view_bundle_createWizard_failedToUploadFile = Failed to upload bundle file
##view_bundle_createWizard_groupsStep_assign = Assign at least one of the eligible bundle groups:
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
+##view_bundle_createWizard_groupsStep_failedAssign = Failed to assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]. Please cancel the create wizard and notify your administrator.
+##view_bundle_createWizard_groupsStep_failedGetAssignable = Failed to determine assignable bundle groups. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
+##view_bundle_createWizard_groupsStep_successAssign = You have successfully assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
##view_bundle_createWizard_loadBundleFileFailure = Cannot obtain bundle file information from server
##view_bundle_createWizard_noAdditionalFilesNeeded = No additional files need to be uploaded for this bundle
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 554c47c..7f6465b 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -1203,6 +1203,7 @@ view_bundle_bundleVersion = バンドルバージョン
view_bundle_bundleVersions = バンドルバージョン
view_bundle_createWizard_bundleDistro = バンドル配布
view_bundle_createWizard_cancelFailure = バンドル [{0}], バージョン = [{1}] の作成の完全なキャンセルに失敗しました - バンドルはデータベースにまだ残っているかもしれません
+##view_bundle_createWizard_cancelFailurePerm = Failed to fully cancel the creation of bundle [{0}], version = [{1}] because the user has create but not delete permissions. The bundle will likley need to be removed by an administrator.
view_bundle_createWizard_cancelSuccessful = バンドル [{0}], バージョン = [{1}] の作成をキャンセルしました
view_bundle_createWizard_clickToUploadRecipe = レシピファイルのロードするためにクリックしてください
view_bundle_createWizard_createFailure = バンドルを作成するのに失敗しました
@@ -1213,11 +1214,14 @@ view_bundle_createWizard_failedToUploadDistroFile = バンドル配布ファイ
view_bundle_createWizard_failedToUploadFile = バンドルファイルのアップロードに失敗しました
##view_bundle_createWizard_groupsStep_assign = Assign at least one of the eligible bundle groups:
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
+##view_bundle_createWizard_groupsStep_failedAssign = Failed to assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]. Please cancel the create wizard and notify your administrator.
+##view_bundle_createWizard_groupsStep_failedGetAssignable = Failed to determine assignable bundle groups. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
+##view_bundle_createWizard_groupsStep_successAssign = You have successfully assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
view_bundle_createWizard_loadBundleFileFailure = サーバーからバンドルファイル情報の取得ができません
view_bundle_createWizard_noAdditionalFilesNeeded = このバンドルのためにアップロードされる必要がある追加ファイルはありません
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
index 09cff8a..f70aaa9 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
@@ -1077,7 +1077,8 @@ view_bundle_bundleFiles = 번들 파일
view_bundle_bundleVersion = 번들 버전
view_bundle_bundleVersions = 번들 버전
view_bundle_createWizard_bundleDistro = 번들 배포
-##view_bundle_createWizard_cancelFailure = Failed to fully cancel the creation of bundle [{0}], version = [{1}] - the bundle may still exist in the database
+##view_bundle_createWizard_cancelFailure = Failed to fully cancel the creation of bundle [{0}], version = [{1}] - the bundle may still exist.
+##view_bundle_createWizard_cancelFailurePerm = Failed to fully cancel the creation of bundle [{0}], version = [{1}] because the user has create but not delete permissions. The bundle will likley need to be removed by an administrator.
view_bundle_createWizard_cancelSuccessful = 번들 [{0}], 버전 = [{1}]의 생성을 취소했습니다.
view_bundle_createWizard_clickToUploadRecipe = 레시피 파일을 로드하기 위해 클릭하십시오
view_bundle_createWizard_createFailure = 번들 생성에 실패했습니다
@@ -1088,11 +1089,14 @@ view_bundle_createWizard_enterUrl = Please enter a valid URL from where the bund
##view_bundle_createWizard_failedToUploadFile = Failed to upload bundle file
##view_bundle_createWizard_groupsStep_assign = Assign at least one of the eligible bundle groups:
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
+##view_bundle_createWizard_groupsStep_failedAssign = Failed to assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]. Please cancel the create wizard and notify your administrator.
+##view_bundle_createWizard_groupsStep_failedGetAssignable = Failed to determine assignable bundle groups. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
+##view_bundle_createWizard_groupsStep_successAssign = You have successfully assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
view_bundle_createWizard_loadBundleFileFailure = 서버에서 번들 파일 정보를 획득 할 수 없습니다
##view_bundle_createWizard_noAdditionalFilesNeeded = No additional files need to be uploaded for this bundle
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index bf7a092..3a841ad 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -1216,6 +1216,7 @@ view_bundle_bundleVersion = Vers\u00E3o do Bundle
view_bundle_bundleVersions = Vers\u00F5es do Bundle
view_bundle_createWizard_bundleDistro = Distribui\u00E7\u00E3o do Bundle
view_bundle_createWizard_cancelFailure = Falha ao cancelar a cria\u00E7\u00E3o do bundle [{0}], vers\u00E3o = [{1}] - talvez o bundle ainda esteja gravado no banco de dados
+##view_bundle_createWizard_cancelFailurePerm = Failed to fully cancel the creation of bundle [{0}], version = [{1}] because the user has create but not delete permissions. The bundle will likley need to be removed by an administrator.
view_bundle_createWizard_cancelSuccessful = Cria\u00E7\u00E3o do bundle [{0}] cancelada, vers\u00E3o = [{1}]
view_bundle_createWizard_clickToUploadRecipe = Clique para fazer o upload do arquivo de script
view_bundle_createWizard_createFailure = Falha ao criar o bundle
@@ -1226,11 +1227,14 @@ view_bundle_createWizard_failedToUploadDistroFile = Falha ao fazer o upload do a
view_bundle_createWizard_failedToUploadFile = Falha ao fazer o upload do bundle
##view_bundle_createWizard_groupsStep_assign = Assign at least one of the eligible bundle groups:
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
+##view_bundle_createWizard_groupsStep_failedAssign = Failed to assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]. Please cancel the create wizard and notify your administrator.
+##view_bundle_createWizard_groupsStep_failedGetAssignable = Failed to determine assignable bundle groups. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
+##view_bundle_createWizard_groupsStep_successAssign = You have successfully assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
view_bundle_createWizard_loadBundleFileFailure = N\u00E3o foi poss\u00EDvel obter infoma\u00E7\u00F5es sobre o arquivo de bundle
view_bundle_createWizard_noAdditionalFilesNeeded = N\u00E3o \u00E9 necess\u00E1rio fazer upload de mais arquivos para este bundle
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
index 99bc501..c344361 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
@@ -2777,7 +2777,8 @@ view_admin_systemSettings_LDAPBindPW_name = Пароль
##view_bundleGroup_deletesFailure = Failed to delete the bundle groups
##view_bundleGroup_deletesSuccessful = You successfully deleted the bundle groups
##view_bundle_createWizard_bundleDistro = Bundle Distribution
-##view_bundle_createWizard_cancelFailure = Failed to fully cancel the creation of bundle [{0}], version = [{1}] - the bundle may still exist in the database
+##view_bundle_createWizard_cancelFailure = Failed to fully cancel the creation of bundle [{0}], version = [{1}] - the bundle may still exist.
+##view_bundle_createWizard_cancelFailurePerm = Failed to fully cancel the creation of bundle [{0}], version = [{1}] because the user has create but not delete permissions. The bundle will likley need to be removed by an administrator.
##view_bundle_createWizard_cancelSuccessful = Canceled the creation of bundle [{0}], version = [{1}]
##view_bundle_createWizard_clickToUploadRecipe = Click to load a recipe file
##view_bundle_createWizard_createFailure = Failed to create the bundle
@@ -2788,11 +2789,14 @@ view_admin_systemSettings_LDAPBindPW_name = Пароль
##view_bundle_createWizard_failedToUploadFile = Failed to upload bundle file
##view_bundle_createWizard_groupsStep_assign = Assign at least one of the eligible bundle groups:
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
+##view_bundle_createWizard_groupsStep_failedAssign = Failed to assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]. Please cancel the create wizard and notify your administrator.
+##view_bundle_createWizard_groupsStep_failedGetAssignable = Failed to determine assignable bundle groups. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
+##view_bundle_createWizard_groupsStep_successAssign = You have successfully assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
##view_bundle_createWizard_loadBundleFileFailure = Cannot obtain bundle file information from server
##view_bundle_createWizard_noAdditionalFilesNeeded = No additional files need to be uploaded for this bundle
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index dd1aaf0..13616b0 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -1199,7 +1199,8 @@ view_bundle_bundleType = Bundle\u7c7b\u578b
view_bundle_bundleVersion = Bundle\u7248\u672c
view_bundle_bundleVersions = Bundle\u7248\u672c
view_bundle_createWizard_bundleDistro = Bundle\u53d1\u5e03
-##view_bundle_createWizard_cancelFailure = Failed to fully cancel the creation of bundle [{0}], version = [{1}] - the bundle may still exist in the database
+##view_bundle_createWizard_cancelFailure = Failed to fully cancel the creation of bundle [{0}], version = [{1}] - the bundle may still exist.
+##view_bundle_createWizard_cancelFailurePerm = Failed to fully cancel the creation of bundle [{0}], version = [{1}] because the user has create but not delete permissions. The bundle will likley need to be removed by an administrator.
##view_bundle_createWizard_cancelSuccessful = Canceled the creation of bundle [{0}], version = [{1}]
##view_bundle_createWizard_clickToUploadRecipe = Click to load a recipe file
view_bundle_createWizard_createFailure = \u521b\u5efabundle\u5931\u8d25
@@ -1210,11 +1211,14 @@ view_bundle_createWizard_failedToUploadDistroFile = \u4e0a\u4f20bundle\u53d1\u5e
view_bundle_createWizard_failedToUploadFile = \u4e0a\u4f20bundle\u6587\u4ef6\u5931\u8d25
##view_bundle_createWizard_groupsStep_assign = Assign at least one of the eligible bundle groups:
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
+##view_bundle_createWizard_groupsStep_failedAssign = Failed to assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]. Please cancel the create wizard and notify your administrator.
+##view_bundle_createWizard_groupsStep_failedGetAssignable = Failed to determine assignable bundle groups. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!:
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
+##view_bundle_createWizard_groupsStep_successAssign = You have successfully assigned initial bundle groups to a bundle named [{0}] with a version of [{1}]
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
view_bundle_createWizard_loadBundleFileFailure = \u65e0\u6cd5\u4ece\u670d\u52a1\u5668\u83b7\u5f97bundle\u6587\u4ef6\u4fe1\u606f
view_bundle_createWizard_noAdditionalFilesNeeded = No additional files need to be uploaded for this bundle
commit ec3577bde2763d9717a22914248a2e510f7b7b3c
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Aug 22 11:22:57 2013 -0400
Fix issue with perm check in get assignable bundles
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index 2e44e52..ae30f11 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -2511,11 +2511,9 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
} else {
// if necessary, make sure the bundle is viewable
- if (!hasViewBundles) {
- if (authorizationManager.canViewBundle(assigningSubject, bundleId)) {
- throw new PermissionException("Bundle ID [" + bundleId + "] is not viewable by subject ["
- + assigningSubject.getName() + "]");
- }
+ if (!hasViewBundles && !authorizationManager.canViewBundle(assigningSubject, bundleId)) {
+ throw new PermissionException("Bundle ID [" + bundleId + "] is not viewable by subject ["
+ + assigningSubject.getName() + "]");
}
// can assign to bundle groups for which he has create_bundles_in_group or assign_bundles_to_group
10 years, 10 months
[rhq] modules/core
by Thomas Segismont
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/CreateResourceRunner.java | 115 +++++-----
1 file changed, 66 insertions(+), 49 deletions(-)
New commits:
commit 75845aad84cc337b76e568b3afa1b989bc15ecce
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Aug 22 17:04:12 2013 +0200
Bug 791340 - Exploded WAR deployed through JON never added to inventory
When a new resource deployment takes some time, the CreateResourceRunner won't be able to discover the new resource. Eventually, the user will have to wait for next automatic service scan to see the resource in the inventory, or will have to trigger a service scan manually.
Now CreateResourceRunner will try up to five times to detect the new resource, with a 30 seconds pause between tries. That gives the managed server up to 5 minutes to deploy it.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/CreateResourceRunner.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/CreateResourceRunner.java
index 8d34e9f..f21ae8f 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/CreateResourceRunner.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/CreateResourceRunner.java
@@ -1,25 +1,21 @@
/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
package org.rhq.core.pc.inventory;
import java.util.concurrent.Callable;
@@ -38,6 +34,8 @@ import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.core.util.exception.ThrowableUtil;
+ import static java.util.concurrent.TimeUnit.SECONDS;
+
/**
* Runnable implementation to process Resource create requests.
*
@@ -45,9 +43,12 @@ import org.rhq.core.util.exception.ThrowableUtil;
*/
public class CreateResourceRunner implements Callable, Runnable {
- // Attributes --------------------------------------------
+ private static final Log LOG = LogFactory.getLog(CreateResourceRunner.class);
+
+ private static final int SERVICE_SCAN_MAX_RETRY = 10;
+ private static final long SERVICE_SCAN_RETRY_PAUSE = SECONDS.toMillis(30);
- private final Log log = LogFactory.getLog(CreateResourceRunner.class);
+ // Attributes --------------------------------------------
/**
* Handle to the manager that will do most of the logic.
@@ -98,7 +99,7 @@ public class CreateResourceRunner implements Callable, Runnable {
try {
call();
} catch (Exception e) {
- log.error("Error while chaining run to call", e);
+ LOG.error("Error while chaining run to call", e);
}
}
@@ -106,7 +107,7 @@ public class CreateResourceRunner implements Callable, Runnable {
@Override
public Object call() throws Exception {
- log.info("Creating resource through report: " + report);
+ LOG.info("Creating resource through report: " + report);
String resourceName = null;
String resourceKey = null;
@@ -128,31 +129,31 @@ public class CreateResourceRunner implements Callable, Runnable {
// Validate the status returned from the plugin
CreateResourceStatus reportedStatus = report.getStatus();
if ((reportedStatus == null) || (reportedStatus == CreateResourceStatus.IN_PROGRESS)) {
- log.warn("Plugin did not indicate the result of the request: " + requestId);
+ LOG.warn("Plugin did not indicate the result of the request: " + requestId);
errorMessage = "Plugin did not indicate the result of the resource creation attempt.";
status = CreateResourceStatus.FAILURE;
}
// Ensure a resource key was returned from the plugin if the plugin reports the create was successful
if ((isSuccessStatus(reportedStatus)) && (resourceKey == null)) {
- log.warn("Plugin did not indicate the resource key for this request: " + requestId);
+ LOG.warn("Plugin did not indicate the resource key for this request: " + requestId);
errorMessage = "Plugin did not indicate a resource key for this request.";
status = CreateResourceStatus.FAILURE;
}
// RHQ-666 - The plugin should provide a resource name if the create was successful
if ((isSuccessStatus(reportedStatus)) && (resourceName == null)) {
- log.warn("Plugin did not indicate a resource name for the request: " + requestId);
+ LOG.warn("Plugin did not indicate a resource name for the request: " + requestId);
errorMessage = "Plugin did not indicate a resource name for this request.";
status = CreateResourceStatus.FAILURE;
}
Throwable throwable = report.getException();
if (throwable != null) {
- if (log.isDebugEnabled())
- log.debug("Throwable was found in creation report for request [" + requestId + "].", throwable);
+ if (LOG.isDebugEnabled())
+ LOG.debug("Throwable was found in creation report for request [" + requestId + "].", throwable);
else
- log.warn("Throwable was found in creation report for request [" + requestId + "]: " + throwable
+ LOG.warn("Throwable was found in creation report for request [" + requestId + "]: " + throwable
+ " - Enable DEBUG logging to see the stack trace.");
status = CreateResourceStatus.FAILURE;
String messages = ThrowableUtil.getAllMessages(throwable);
@@ -165,10 +166,10 @@ public class CreateResourceRunner implements Callable, Runnable {
"may want to run a discovery scan to see if the deployment did complete successfully. Also consider " +
"using a higher time out value for future deployments.";
- if (log.isDebugEnabled()) {
- log.debug("Failed to create resource for " + report + ". " + errorMessage, e);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Failed to create resource for " + report + ". " + errorMessage, e);
} else {
- log.info("Failed to create resource for " + report + ". " + errorMessage, e);
+ LOG.info("Failed to create resource for " + report + ". " + errorMessage, e);
}
errorMessage += "\n\nRoot Cause:\n" + e.getMessage();
@@ -181,36 +182,52 @@ public class CreateResourceRunner implements Callable, Runnable {
CreateResourceResponse response =
new CreateResourceResponse(requestId, resourceName, resourceKey, status, errorMessage, configuration);
- log.info("Sending create response to server: " + response);
+ LOG.info("Sending create response to server: " + response);
ResourceFactoryServerService serverService = resourceFactoryManager.getServerService();
if (serverService != null) {
try {
serverService.completeCreateResource(response);
} catch (Throwable throwable) {
- log.error("Error received while attempting to complete report for request: " + requestId, throwable);
+ LOG.error("Error received while attempting to complete report for request: " + requestId, throwable);
}
}
// Trigger a service scan on the parent resource to have the newly created resource discovered if the plugin
// said the create was successful
if (isSuccessStatus(status) && runRuntimeScan) {
- log.debug("Scheduling service scan to discover newly created [" + report.getResourceType()
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Scheduling service scan to discover newly created [" + report.getResourceType()
+ "] managed resource with key [" + report.getResourceKey() + "]...");
+ }
InventoryManager inventoryManager = PluginContainer.getInstance().getInventoryManager();
- try {
- // This will block until the service scan completes.
- InventoryReport inventoryReport = inventoryManager.performServiceScan(parentResourceId);
- } catch (Exception e) {
- log.error("Failed to run service scan to discover newly created [" + report.getResourceType()
+ Resource discoveredResource = null;
+ for (int retry = 1; discoveredResource == null && retry <= SERVICE_SCAN_MAX_RETRY; retry++) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Service scan retry [" + retry + "] for parentResourceId [" + parentResourceId + "]");
+ }
+ if (retry > 1 && retry < SERVICE_SCAN_MAX_RETRY) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Pausing for [" + SERVICE_SCAN_RETRY_PAUSE
+ + "] ms before retrying service scan for parentResourceId [" + parentResourceId + "]");
+ }
+ Thread.sleep(SERVICE_SCAN_RETRY_PAUSE);
+ }
+ try {
+ // This will block until the service scan completes.
+ inventoryManager.performServiceScan(parentResourceId);
+ } catch (Exception e) {
+ LOG.error("Failed to run service scan to discover newly created [" + report.getResourceType()
+ "] managed resource with key [" + report.getResourceKey() + "].", e);
- }
-
- Resource discoveredResource = getDiscoveredResource();
- if (discoveredResource != null) {
- log.info("Discovered " + discoveredResource + ", for a new managed resource created via RHQ.");
- } else {
- log.error("Failed to discover Resource for newly created [" + report.getResourceType()
+ }
+ discoveredResource = getDiscoveredResource();
+ if (discoveredResource != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Discovered " + discoveredResource + ", for a new managed resource created via RHQ.");
+ }
+ } else {
+ LOG.warn("Failed to discover Resource for newly created [" + report.getResourceType()
+ "] managed resource with key [" + report.getResourceKey() + "].");
+ }
}
}
10 years, 10 months
[rhq] 2 commits - modules/common modules/enterprise pom.xml
by snegrea
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties | 2
modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java | 2
modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/UpdateFolder.java | 2
modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java | 3
modules/common/cassandra-util/pom.xml | 6 +
modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java | 33 ++++++++++
modules/enterprise/server/data-migration/pom.xml | 6 +
modules/enterprise/server/data-migration/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java | 3
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java | 24 +++++--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageNodeOperationsHandlerBean.java | 2
pom.xml | 1
12 files changed, 71 insertions(+), 15 deletions(-)
New commits:
commit a72a970f7e44e744a6b13ffc5684cd8be6d195b0
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 22 09:23:09 2013 -0500
Fix file paths for running the schema manager from a disk based distribution.
diff --git a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/UpdateFolder.java b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/UpdateFolder.java
index 31266ca..3b2056f 100644
--- a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/UpdateFolder.java
+++ b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/UpdateFolder.java
@@ -117,7 +117,7 @@ class UpdateFolder {
String updateFile;
while ((updateFile = reader.readLine()) != null) {
- files.add(new UpdateFile(folder + updateFile));
+ files.add(new UpdateFile(folder + "/" + updateFile));
}
} else if (resourceFolderURL.getProtocol().equals("jar")) {
URL jarURL = this.getClass().getClassLoader().getResources(folder).nextElement();
commit 7371e80747cbf082b478c4049f7c57029e2b5554
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 22 09:22:34 2013 -0500
[BZ 999555] Add storage node password obfuscation in the server configuration file using the same method applied to SQL database password.
Also, added a more generic argument to the installer to allow users to encode their desired password prior to running the installer.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties
index ce2be6c..9a1ab75 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties
@@ -10,7 +10,7 @@ rhq.cassandra.basedir=${rhq.rootDir}
rhq.cassandra.username=rhqadmin
# The password with which to authenticate requests to Cassandra.
-rhq.cassandra.password=rhqadmin
+rhq.cassandra.password=1eeb2f255e832171df8592078de921bc
# Defines the number of tokens randomly assigned to a node on the ring. The more tokens,
# relative to other nodes, the larger the proportion of data that this node will store. You
diff --git a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java
index 7dcef1b..3a6bf21 100644
--- a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java
+++ b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java
@@ -111,7 +111,7 @@ abstract class AbstractManager {
log.info("Initializing storage node session.");
- Cluster cluster = new ClusterBuilder().addContactPoints(nodes).withCredentials(username, password)
+ Cluster cluster = new ClusterBuilder().addContactPoints(nodes).withCredentialsObfuscated(username, password)
.withPort(this.getCqlPort()).withCompression(Compression.NONE).build();
log.info("Cluster connection configured.");
diff --git a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java
index 05cee25..36dc036 100644
--- a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java
+++ b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java
@@ -36,6 +36,7 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.cassandra.schema.exception.InstalledSchemaTooAdvancedException;
import org.rhq.cassandra.schema.exception.InstalledSchemaTooOldException;
import org.rhq.cassandra.schema.exception.SchemaNotInstalledException;
+import org.rhq.cassandra.util.ClusterBuilder;
/**
* @author Stefan Negrea
@@ -106,7 +107,7 @@ class VersionManager extends AbstractManager {
properties.put("replication_factor", calculateNewReplicationFactor() + "");
properties.put("cassandra_user_password", UUID.randomUUID() + "");
properties.put("rhq_admin_username", getUsername());
- properties.put("rhq_admin_password", getPassword());
+ properties.put("rhq_admin_password", ClusterBuilder.deobfuscatePassword(getPassword()));
/**
* NOTE: Before applying any schema, we need to create the rhqadmin user. If we have more
diff --git a/modules/common/cassandra-util/pom.xml b/modules/common/cassandra-util/pom.xml
index 7e5fff2..fc59154 100644
--- a/modules/common/cassandra-util/pom.xml
+++ b/modules/common/cassandra-util/pom.xml
@@ -18,6 +18,12 @@
<artifactId>cassandra-driver-core</artifactId>
<version>${cassandra.driver.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.picketbox</groupId>
+ <artifactId>picketbox</artifactId>
+ <version>${picketbox-version}</version>
+ </dependency>
</dependencies>
<profiles>
diff --git a/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java b/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java
index 14f12e1..9796a59 100644
--- a/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java
+++ b/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java
@@ -25,6 +25,8 @@
package org.rhq.cassandra.util;
+import java.lang.reflect.Method;
+
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.PoolingOptions;
import com.datastax.driver.core.ProtocolOptions;
@@ -66,6 +68,14 @@ public class ClusterBuilder {
}
/**
+ * @see Cluster.Builder#withCredentials(String, String)
+ */
+ public ClusterBuilder withCredentialsObfuscated(String username, String obfuscatedPassword) {
+ builder.withCredentials(username, ClusterBuilder.deobfuscatePassword(obfuscatedPassword));
+ return this;
+ }
+
+ /**
* This method will throw an IllegalArgumentException if you try to use snappy
* compression while running on an IBM JRE. See <a href="https://bugzilla.redhat.com/show_bug.cgi?id=907485">BZ 907485</a>
* for details.
@@ -105,4 +115,27 @@ public class ClusterBuilder {
return System.getProperty("java.vm.vendor").startsWith("IBM");
}
+ /**
+ * Use the internal JBossAS mechanism to de-obfuscate a password back to its
+ * clear text form. This is not true encryption.
+ *
+ * @param obfuscatedPassword the obfuscated password
+ * @return the clear-text password
+ */
+ public static String deobfuscatePassword(String obfuscatedPassword) {
+ // We need to do some mumbo jumbo, as the interesting method is private
+ // in SecureIdentityLoginModule
+ try {
+ String className = "org.picketbox.datasource.security.SecureIdentityLoginModule";
+ Class<?> clazz = Class.forName(className);
+ Object object = clazz.newInstance();
+ Method method = clazz.getDeclaredMethod("decode", String.class);
+ method.setAccessible(true);
+ char[] result = (char[]) method.invoke(object, obfuscatedPassword);
+ return new String(result);
+ } catch (Exception e) {
+ throw new RuntimeException("de-obfuscating db password failed: ", e);
+ }
+ }
+
}
diff --git a/modules/enterprise/server/data-migration/pom.xml b/modules/enterprise/server/data-migration/pom.xml
index ea25952..35d1934 100644
--- a/modules/enterprise/server/data-migration/pom.xml
+++ b/modules/enterprise/server/data-migration/pom.xml
@@ -43,6 +43,12 @@
</dependency>
<dependency>
+ <groupId>org.picketbox</groupId>
+ <artifactId>picketbox</artifactId>
+ <version>${picketbox-version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.1</version>
diff --git a/modules/enterprise/server/data-migration/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java b/modules/enterprise/server/data-migration/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java
index 8a0f64c..5e0861e 100644
--- a/modules/enterprise/server/data-migration/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java
+++ b/modules/enterprise/server/data-migration/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java
@@ -362,7 +362,8 @@ public class DataMigratorRunner {
configuration.put(sqlConnectionUrlOption, serverProperties.getProperty("rhq.server.database.connection-url"));
configuration.put(cassandraUserOption, serverProperties.getProperty("rhq.cassandra.username"));
- configuration.put(cassandraPasswordOption, serverProperties.getProperty("rhq.cassandra.password"));
+ String cassandraPasswordProperty = serverProperties.getProperty("rhq.cassandra.password");
+ configuration.put(cassandraPasswordOption, deobfuscatePassword(cassandraPasswordProperty));
if (serverProperties.getProperty("rhq.cassandra.seeds") != null
&& !serverProperties.getProperty("rhq.cassandra.seeds").trim().isEmpty()) {
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java
index 36da859..97b10ce 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java
@@ -145,8 +145,9 @@ public class Installer {
usage.append("\t--force, -f: force the installer to try to install everything").append("\n");
usage.append("\t--listservers, -l: show list of known installed servers (install not performed)").append("\n");
usage.append("\t--setupdb, -b: only perform database schema creation or update").append("\n");
- usage.append("\t--dbpassword, -d: encodes a DB password for rhq-server.properties (install not performed)")
- .append("\n");
+ usage.append("\t--dbpassword, -d: encodes a DB password for rhq-server.properties (install not performed)");
+ usage.append("\t--encodepassword, -e: encodes a password (DB or RHQ Storage Cluster) for rhq-server.properties (install not performed)");
+ usage.append("\n");
LOG.info(usage);
}
@@ -156,6 +157,7 @@ public class Installer {
new LongOpt("host", LongOpt.REQUIRED_ARGUMENT, null, 'h'),
new LongOpt("port", LongOpt.REQUIRED_ARGUMENT, null, 'p'),
new LongOpt("dbpassword", LongOpt.REQUIRED_ARGUMENT, null, 'd'),
+ new LongOpt("encodepassword", LongOpt.REQUIRED_ARGUMENT, null, 'e'),
new LongOpt("setupdb", LongOpt.NO_ARGUMENT, null, 'b'),
new LongOpt("listservers", LongOpt.NO_ARGUMENT, null, 'l'),
new LongOpt("force", LongOpt.NO_ARGUMENT, null, 'f'),
@@ -164,7 +166,7 @@ public class Installer {
boolean test = false;
boolean listservers = false;
boolean setupdb = false;
- String dbpassword = null;
+ String passwordToEncode = null;
Getopt getopt = new Getopt("installer", args, sopts, lopts);
int code;
@@ -228,8 +230,16 @@ public class Installer {
}
case 'd': {
- dbpassword = getopt.getOptarg();
- if (dbpassword == null) {
+ passwordToEncode = getopt.getOptarg();
+ if (passwordToEncode == null) {
+ throw new IllegalArgumentException("Missing password");
+ }
+ break;
+ }
+
+ case 'e': {
+ passwordToEncode = getopt.getOptarg();
+ if (passwordToEncode == null) {
throw new IllegalArgumentException("Missing password");
}
break;
@@ -258,8 +268,8 @@ public class Installer {
}
// if a password was asked to be obfuscated, that's all we are to do
- if (dbpassword != null) {
- String pw = new InstallerServiceImpl(installerConfig).obfuscatePassword(dbpassword);
+ if (passwordToEncode != null) {
+ String pw = new InstallerServiceImpl(installerConfig).obfuscatePassword(passwordToEncode);
LOG.info("*** Encoded Password: " + pw);
return new WhatToDo[] { WhatToDo.DO_NOTHING };
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
index 799abcc..09de080 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
@@ -194,7 +194,7 @@ public class StorageClientManagerBean {
Cluster cluster = new ClusterBuilder()
.addContactPoints(hostNames.toArray(new String[hostNames.size()]))
- .withCredentials(username, password)
+ .withCredentialsObfuscated(username, password)
.withPort(port)
.withCompression(compression)
.build();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageNodeOperationsHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageNodeOperationsHandlerBean.java
index 943458e..96c22b8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageNodeOperationsHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageNodeOperationsHandlerBean.java
@@ -47,8 +47,6 @@ public class StorageNodeOperationsHandlerBean implements StorageNodeOperationsHa
private static final String STORAGE_NODE_TYPE_NAME = "RHQ Storage Node";
private static final String STORAGE_NODE_PLUGIN_NAME = "RHQStorage";
- private static final String USERNAME_PROPERTY = "rhq.cassandra.username";
- private static final String PASSWORD_PROPERTY = "rhq.cassandra.password";
private final static String RUN_REPAIR_PROPERTY = "runRepair";
private final static String UPDATE_SEEDS_LIST = "updateSeedsList";
private final static String SEEDS_LIST = "seedsList";
diff --git a/pom.xml b/pom.xml
index a8cc40d..1f228a2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -177,6 +177,7 @@
<mockito-core.version>1.9.0</mockito-core.version>
<el.version>1.0</el.version>
+ <picketbox-version>4.0.15.Final</picketbox-version>
<!-- cassandra dependency versions -->
<cassandra.version>1.2.4</cassandra.version>
10 years, 10 months
[rhq] modules/enterprise
by mike thompson
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/graph/SparklineUIBean.java | 94
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/AvailHealthChartServlet.java | 51
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/AvailabilityStoplightChartServlet.java | 85
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/ChartServlet.java | 470 ----
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/CurrentHealthChartServlet.java | 259 --
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java | 186 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowMetricValue.java | 167 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/MetricChartServlet.java | 267 --
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/NavMapImageServlet.java | 139 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/PerformanceChartServlet.java | 333 ---
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/UsageHealthChartServlet.java | 51
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/UtilizationHealthChartServlet.java | 37
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/VerticalChartServlet.java | 139 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/ImageUtil.java | 237 --
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/Line.java | 53
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/WebImage.java | 418 ----
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/AreaChart.java | 78
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/AvailabilityChart.java | 100
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/AvailabilityReportChart.java | 193 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/Chart.java | 1040 ----------
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ChartGraphics.java | 253 --
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ColumnChart.java | 135 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ColumnLineChart.java | 91
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/DataPoint.java | 133 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/DataPointCollection.java | 139 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HealthChart.java | 61
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HighLowChart.java | 167 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HighLowDataPoint.java | 72
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HorizontalChart.java | 197 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/LineChart.java | 116 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/PerfDataPointCollection.java | 105 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/PerformanceChart.java | 157 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ScaleFormatter.java | 59
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/SmartLabel.java | 24
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/SmartLabelMaker.java | 93
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/StackedDataPoint.java | 73
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/StackedPerformanceChart.java | 253 --
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/Trend.java | 25
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/UsageChart.java | 39
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/VerticalChart.java | 459 ----
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IComparableDatapoint.java | 22
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IDataPoint.java | 33
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IDisplayDataPoint.java | 36
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IHighLowDataPoint.java | 45
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IResourceTreeNode.java | 30
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IStackedDataPoint.java | 33
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/ITreeNode.java | 43
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/AvailabilityReport.java | 139 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/ResourceTree.java | 879 --------
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/ResourceTreeNode.java | 93
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/TreeNode.java | 197 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/AvailabilityDataPoint.java | 49
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/CurrentHealthAction.java | 93
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java | 419 ----
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorViewsForm.java | 111 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartAction.java | 446 ----
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartForm.java | 686 ------
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java | 796 -------
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewDesignatedChartAction.java | 75
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/ChartDataBean.java | 41
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/ChartedMetricBean.java | 60
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/NumericMetricDataPoint.java | 127 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java | 719 ------
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/rt/SegmentInfo.java | 125 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/uibeans/TreeNode.java | 348 ---
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/uibeans/TreeNodeAlphaComparator.java | 43
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml | 39
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/dashboard-def.xml | 9
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-common-def.xml | 77
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-def.xml | 3
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-hub-def.xml | 3
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-platform-def.xml | 3
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml | 74
modules/enterprise/gui/portal-war/src/main/webapp/js/advanced-metrics.js | 83
modules/enterprise/gui/portal-war/src/main/webapp/js/chart.js | 124 -
modules/enterprise/gui/portal-war/src/main/webapp/js/monitorGraphs.js | 42
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartLayout.jsp | 134 -
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartLegend.jsp | 38
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartLinksNavigation.jsp | 14
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartParams.jsp | 204 -
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartTimeIntervalToolbar.jsp | 45
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/SaveChartToolbar.jsp | 13
82 files changed, 2 insertions(+), 13639 deletions(-)
New commits:
commit 434b099bddadf96ce32c4192ebd9e4bff3d3ab82
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Aug 21 14:35:53 2013 -0700
[BZ 995541] Remove JSF charting from Portal.war. More specifically, remove any java AWT references from classes which are the charting classes. Also make sure to preserve existing portal.war functionality such as content and timeline.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/graph/SparklineUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/graph/SparklineUIBean.java
deleted file mode 100644
index 68b2005..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/graph/SparklineUIBean.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.common.graph;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.GradientPaint;
-import java.awt.Graphics2D;
-import java.awt.Polygon;
-import java.awt.RenderingHints;
-import java.util.List;
-
-import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-/**
- * @author Greg Hinkle
- */
-public class SparklineUIBean {
-
- private int scheduleId;
-
- public void paint(Graphics2D g2d, Object obj) {
-
- String[] keys = ((String) obj).split(":");
-
- int resourceId = Integer.parseInt(keys[0]);
- int scheduleDefId = Integer.parseInt(keys[1]);
-
- List<MeasurementDataNumericHighLowComposite> data = getData(resourceId, scheduleDefId);
-
- double min = Double.MAX_VALUE, max = Integer.MIN_VALUE;
- for (MeasurementDataNumericHighLowComposite d : data) {
- if (d.getLowValue() < min) {
- min = d.getLowValue();
- }
- if (d.getHighValue() > max) {
- max = d.getHighValue();
- }
- }
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
-
- double heightScale = max - min != 0 ? (18d / (max - min)) : 0;
-
- int i = 1;
- g2d.setStroke(new BasicStroke(0.6f));
- Polygon p = new Polygon();
- p.addPoint(0, 18);
- for (MeasurementDataNumericHighLowComposite d : data) {
-
- if (!Double.isNaN(d.getValue())) {
- p.addPoint(i, 18 - (int) (heightScale * (d.getValue() - min)));
- }
- i++;
- }
- p.addPoint(60, 18);
-
- g2d.setPaint(new GradientPaint(0, 18, Color.lightGray, 0, 0, Color.darkGray));
- g2d.fillPolygon(p);
-
- g2d.setColor(Color.lightGray);
- g2d.drawPolygon(p);
-
- }
-
- private List<MeasurementDataNumericHighLowComposite> getData(int resourceId, int scheduleDefId) {
-
- List<List<MeasurementDataNumericHighLowComposite>> dl = LookupUtil.getMeasurementDataManager()
- .findDataForResource(EnterpriseFacesContextUtility.getSubject(), resourceId, new int[] { scheduleDefId },
- System.currentTimeMillis() - (1000L * 60 * 60 * 8), System.currentTimeMillis(), 60);
-
- List<MeasurementDataNumericHighLowComposite> data = dl.get(0);
-
- return data;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/AvailHealthChartServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/AvailHealthChartServlet.java
deleted file mode 100644
index 5c7ba1e..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/AvailHealthChartServlet.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.common.servlet;
-
-import org.rhq.enterprise.gui.image.chart.AvailabilityChart;
-import org.rhq.enterprise.gui.image.chart.Chart;
-import org.rhq.enterprise.server.legacy.measurement.MeasurementConstants;
-
-/**
- * <p>Availability current health chart servlet.</p>
- */
-public class AvailHealthChartServlet extends CurrentHealthChartServlet {
- public AvailHealthChartServlet() {
- }
-
- /**
- * Create and return the chart. This method will be called after the parameters have been parsed.
- *
- * @return the newly created chart
- */
- protected Chart createChart() {
- return new AvailabilityChart(getImageWidth(), getImageHeight());
- }
-
- /**
- * Return the corresponding measurement category.
- *
- * @return <code>{@link org.rhq.enterprise.server.legacy.measurement.MeasurementConstants.CAT_AVAILABILITY}</code>
- */
- protected String getMetricCategory() {
- return MeasurementConstants.CAT_AVAILABILITY;
- }
-}
-
-// EOF
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/AvailabilityStoplightChartServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/AvailabilityStoplightChartServlet.java
deleted file mode 100644
index 7ac3bf1..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/AvailabilityStoplightChartServlet.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.common.servlet;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.enterprise.gui.image.chart.AvailabilityReportChart;
-import org.rhq.enterprise.gui.image.chart.Chart;
-
-public class AvailabilityStoplightChartServlet extends ChartServlet {
- Log log = LogFactory.getLog(AvailabilityStoplightChartServlet.class.getName());
-
- /**
- */
- public AvailabilityStoplightChartServlet() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.rhq.enterprise.gui.common.servlet.ChartServlet#createChart()
- */
- @Override
- protected Chart createChart() {
- return new AvailabilityReportChart();
- }
-
- /* (non-Javadoc)
- * @see org.rhq.enterprise.gui.common.servlet.ChartServlet#plotData(javax.servlet.http.HttpServletRequest)
- */
- @Override
- protected void plotData(HttpServletRequest request, Chart chart) throws ServletException {
- // Subject subject = RequestUtils.getSubject(request);
- //
- // Integer resourceId = RequestUtils.getResourceId(request);
- //
- // // the child resource type
- // AppdefEntityTypeID ctype = RequestUtils.getHqChildResourceTypeId(request);
- //
- // MeasurementBoss boss = ContextUtils.getMeasurementBoss( getServletContext() );
- // try {
- // MeasurementSummary summary = boss.getSummarizedResourceAvailability(0,
- // null, ctype.getType(), ctype.getId());
- // AvailabilityReportChart availChart = (AvailabilityReportChart) chart;
- // DataPointCollection data = availChart.getDataPoints();
- // data.clear();
- // for (Integer integer : summary.asList())
- // {
- // Integer avail = (Integer)integer;
- // data.add(new AvailabilityDataPoint(avail));
- // }
- //
- // } catch (AppdefEntityNotFoundException e) {
- // log.error("failed: ", e);
- // } catch (SessionTimeoutException e) {
- // log.error("failed: ", e);
- // } catch (SessionNotFoundException e) {
- // log.error("failed: ", e);
- // } catch (PermissionException e) {
- // log.error("failed: ", e);
- // } catch (IllegalArgumentException e) {
- // log.error("failed: ", e);
- // } catch (RemoteException e) {
- // log.error("failed: ", e);
- // }
- throw new IllegalStateException("deprecated code");
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/ChartServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/ChartServlet.java
deleted file mode 100644
index 85c7162..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/ChartServlet.java
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.common.servlet;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.enterprise.gui.image.chart.Chart;
-
-/**
- * <p>This servlet returns a response that contains the binary data of an image (JPEG or PNG) that can be viewed in a
- * web browser.</p>
- *
- * <p>The chart servlet takes the following parameters (any applicable defaults are in <b>bold</b> and required
- * parameters are in <i>italics</i>):</p>
- *
- * <table border="1">
- * <tr>
- * <th>key</th>
- * <th>value</th>
- * </tr>
- * <tr>
- * <td>measurementUnits</td>
- * <td><MeasurementUnits.NONE></td>
- * </tr>
- * <tr>
- * <td>showPeak</td>
- * <td>(<b>false</b> | true)</td>
- * </tr>
- * <tr>
- * <td>showHighRange</td>
- * <td>(<b>false</b> | true)</td>
- * </tr>
- * <tr>
- * <td>showValues</td>
- * <td>(false | <b>true</b>)</td>
- * </tr>
- * <tr>
- * <td>showAverage</td>
- * <td>(<b>false</b> | true)</td>
- * </tr>
- * <tr>
- * <td>showLowRange</td>
- * <td>(<b>false</b> | true)</td>
- * </tr>
- * <tr>
- * <td>showLow</td>
- * <td>(<b>false</b> | true)</td>
- * </tr>
- * <tr>
- * <td>showBaseline</td>
- * <td>(<b>false</b> | true)</td>
- * </tr>
- * <tr>
- * <td>baseline*</td>
- * <td><double></td>
- * </tr>
- * <tr>
- * <td>highRange*</td>
- * <td><double></td>
- * </tr>
- * <tr>
- * <td>lowRange*</td>
- * <td><double></td>
- * </tr>
- * </table>
- *
- * <p>* only used and required if corresponding <code>showXXX</code> parameter is <code>true</code><br>
- * </p>
- */
-public abstract class ChartServlet extends ImageServlet {
- public static final String MEASUREMENT_UNITS_PARAM = "measurementUnits";
-
- /**
- * Default image width.
- */
- public static final int IMAGE_WIDTH_DEFAULT = 755;
-
- /**
- * Default image height.
- */
- public static final int IMAGE_HEIGHT_DEFAULT = 300;
-
- /**
- * Request parameter for whether or not to show the peak.
- */
- public static final String SHOW_PEAK_PARAM = "showPeak";
-
- /**
- * Request parameter for whether or not to show high range.
- */
- public static final String SHOW_HIGHRANGE_PARAM = "showHighRange";
-
- /**
- * Request parameter for whether or not to show the actual values.
- */
- public static final String SHOW_VALUES_PARAM = "showValues";
-
- /**
- * Request parameter for whether or not to show average.
- */
- public static final String SHOW_AVERAGE_PARAM = "showAverage";
-
- /**
- * Request parameter for whether or not to show low range.
- */
- public static final String SHOW_LOWRANGE_PARAM = "showLowRange";
-
- /**
- * Request parameter for whether or not to show the low.
- */
- public static final String SHOW_LOW_PARAM = "showLow";
-
- /**
- * Request parameter for whether or not to show baseline.
- */
- public static final String SHOW_BASELINE_PARAM = "showBaseline";
-
- /**
- * Request parameter for baseline.
- */
- public static final String BASELINE_PARAM = "baseline";
-
- /**
- * Request parameter for baseline.
- */
- public static final String HIGHRANGE_PARAM = "highRange";
-
- /**
- * Request parameter for baseline.
- */
- public static final String LOWRANGE_PARAM = "lowRange";
-
- // member data
- private Log log = LogFactory.getLog(ChartServlet.class);
- protected MeasurementUnits units;
- private boolean showPeak;
- private boolean showHighRange;
- private boolean showValues;
- private boolean showAverage;
- private boolean showLowRange;
- private boolean showLow;
- private boolean showBaseline;
- private double baseline;
-
- private double highRange;
- private double lowRange;
-
- /**
- * Create the image being rendered.
- *
- * @param request the servlet request
- */
- @Override
- protected Object createImage(HttpServletRequest request) throws ServletException {
- // initialize the chart
- Chart chart = createChart();
-
- initializeChart(chart);
-
- // the subclass is responsible for plotting the data
- if (log.isDebugEnabled())
- log.debug("Plotting data...");
- plotData(request, chart);
- return chart;
- }
-
- /**
- * Render a PNG version of the image into the output stream.
- *
- * @param out the output stream
- */
- @Override
- protected void renderPngImage(ServletOutputStream out, Object imgObj) throws IOException {
- Chart chart = (Chart) imgObj;
- chart.writePngImage(out);
- }
-
- /**
- * Render a JPEG version of the image into the output stream.
- *
- * @param out the output stream
- */
- @Override
- protected void renderJpegImage(ServletOutputStream out, Object imgObj) throws IOException {
- Chart chart = (Chart) imgObj;
- chart.writeJpegImage(out);
- }
-
- /**
- * This method will be called automatically by the ChartServlet. It should handle the parsing and error-checking of
- * any specific parameters for the chart being rendered.
- *
- * @param request the HTTP request object
- */
- @Override
- protected void parseParameters(HttpServletRequest request) {
- super.parseParameters(request);
-
- // units
- String parameter = request.getParameter(MEASUREMENT_UNITS_PARAM);
- if (parameter != null && !"".equals(parameter)) {
- units = MeasurementUnits.valueOf(parameter);
- } else {
- if (units == null) { // Only set to NONE, when we don't have them yet. Subclasses may have set them.
- units = MeasurementUnits.NONE;
- log.warn("Request did not specify measurement units. Using NONE.");
- }
- }
-
- // chart flags
- showPeak = parseBooleanParameter(request, SHOW_PEAK_PARAM, getDefaultShowPeak());
- showHighRange = parseBooleanParameter(request, SHOW_HIGHRANGE_PARAM, getDefaultShowHighRange());
- showValues = parseBooleanParameter(request, SHOW_VALUES_PARAM, getDefaultShowValues());
- showAverage = parseBooleanParameter(request, SHOW_AVERAGE_PARAM, getDefaultShowAverage());
- showLowRange = parseBooleanParameter(request, SHOW_LOWRANGE_PARAM, getDefaultShowLowRange());
- showLow = parseBooleanParameter(request, SHOW_LOW_PARAM, getDefaultShowLow());
- showBaseline = parseBooleanParameter(request, SHOW_BASELINE_PARAM, getDefaultShowBaseline());
-
- // baseline, high range and low range
- if (showBaseline) {
- try {
- baseline = parseRequiredDoubleParameter(request, BASELINE_PARAM);
- } catch (IllegalArgumentException e) {
- if (log.isDebugEnabled()) {
- log.debug("invalid " + BASELINE_PARAM + ", setting " + SHOW_BASELINE_PARAM + " to: " + false);
- }
-
- showBaseline = false;
- }
- }
-
- if (showHighRange) {
- try {
- highRange = parseRequiredDoubleParameter(request, HIGHRANGE_PARAM);
- } catch (IllegalArgumentException e) {
- if (log.isDebugEnabled()) {
- log.debug("invalid " + HIGHRANGE_PARAM + ", setting " + SHOW_HIGHRANGE_PARAM + " to: " + false);
- }
-
- showHighRange = false;
- }
- }
-
- if (showLowRange) {
- try {
- lowRange = parseRequiredDoubleParameter(request, LOWRANGE_PARAM);
- } catch (IllegalArgumentException e) {
- if (log.isDebugEnabled()) {
- log.debug("invalid " + LOWRANGE_PARAM + ", setting " + SHOW_LOWRANGE_PARAM + " to: " + false);
- }
-
- showLowRange = false;
- }
- }
-
- _logParameters();
- }
-
- /**
- * Create and return the chart. This method will be called after the parameters have been parsed.
- *
- * @return the newly created chart
- */
- protected abstract Chart createChart();
-
- /**
- * Initialize the chart. This method will be called after the parameters have been parsed and the chart has been
- * created.
- *
- * @param chart the chart
- */
- protected void initializeChart(Chart chart) {
- chart.setFormat(units);
- chart.showPeak = showPeak;
- chart.showHighRange = showHighRange;
- chart.showValues = showValues;
- chart.showAverage = showAverage;
- chart.showLowRange = showLowRange;
- chart.showLow = showLow;
- chart.showBaseline = showBaseline;
- chart.baseline = baseline;
- chart.highRange = highRange;
- chart.lowRange = lowRange;
- }
-
- /**
- * This method will be called automatically by the ChartServlet. It should handle adding data to the chart, setting
- * up the X and Y axis labels, etc.
- *
- * @param request the HTTP request
- */
- protected abstract void plotData(HttpServletRequest request, Chart chart) throws ServletException;
-
- /**
- * Return the value of property <code>showLow</code>.
- */
- public boolean getShowLow() {
- return this.showLow;
- }
-
- /**
- * Return the value of property <code>showPeak</code>.
- */
- public boolean getShowPeak() {
- return this.showPeak;
- }
-
- /**
- * Return the value of property <code>showAverage</code>.
- */
- public boolean getShowAvg() {
- return this.showAverage;
- }
-
- /**
- * Return the default <code>imageWidth</code>.
- */
- @Override
- protected int getDefaultImageWidth() {
- return IMAGE_WIDTH_DEFAULT;
- }
-
- /**
- * Return the default <code>imageHeight</code>.
- */
- @Override
- protected int getDefaultImageHeight() {
- return IMAGE_HEIGHT_DEFAULT;
- }
-
- /**
- * Return the default <code>showPeak</code>.
- */
- protected boolean getDefaultShowPeak() {
- return false;
- }
-
- /**
- * Return the default <code>showHighRange</code>.
- */
- protected boolean getDefaultShowHighRange() {
- return false;
- }
-
- /**
- * Return the default <code>showValues</code>.
- */
- protected boolean getDefaultShowValues() {
- return true;
- }
-
- /**
- * Return the default <code>showAverage</code>.
- */
- protected boolean getDefaultShowAverage() {
- return false;
- }
-
- /**
- * Return the default <code>Range</code>.
- */
- protected boolean getDefaultShowLowRange() {
- return false;
- }
-
- /**
- * Return the default <code>showLow</code>.
- */
- protected boolean getDefaultShowLow() {
- return false;
- }
-
- /**
- * Return the default <code>showBaseline</code>.
- */
- protected boolean getDefaultShowBaseline() {
- return false;
- }
-
- //---------------------------------------------------------------
- //-- private helpers
- //---------------------------------------------------------------
- private void _logParameters() {
- if (log.isDebugEnabled()) {
- StringBuffer sb = new StringBuffer("Parameters:");
- sb.append("\n");
- sb.append("\t");
- sb.append(MEASUREMENT_UNITS_PARAM);
- sb.append(": ");
- sb.append(units);
- sb.append("\n");
- sb.append("\t");
- sb.append(SHOW_PEAK_PARAM);
- sb.append(": ");
- sb.append(showPeak);
- sb.append("\n");
- sb.append("\t");
- sb.append(SHOW_HIGHRANGE_PARAM);
- sb.append(": ");
- sb.append(showHighRange);
- sb.append("\n");
- sb.append("\t");
- sb.append(SHOW_VALUES_PARAM);
- sb.append(": ");
- sb.append(showValues);
- sb.append("\n");
- sb.append("\t");
- sb.append(SHOW_AVERAGE_PARAM);
- sb.append(": ");
- sb.append(showAverage);
- sb.append("\n");
- sb.append("\t");
- sb.append(SHOW_LOWRANGE_PARAM);
- sb.append(": ");
- sb.append(showLowRange);
- sb.append("\n");
- sb.append("\t");
- sb.append(SHOW_LOW_PARAM);
- sb.append(": ");
- sb.append(showLow);
- sb.append("\n");
- sb.append("\t");
- sb.append(SHOW_BASELINE_PARAM);
- sb.append(": ");
- sb.append(showBaseline);
- sb.append("\n");
- sb.append("\t");
- sb.append(BASELINE_PARAM);
- sb.append(": ");
- sb.append(baseline);
- sb.append("\n");
- sb.append("\t");
- sb.append(HIGHRANGE_PARAM);
- sb.append(": ");
- sb.append(highRange);
- sb.append("\n");
- sb.append("\t");
- sb.append(LOWRANGE_PARAM);
- sb.append(": ");
- sb.append(lowRange);
- log.debug(sb.toString());
- }
- }
-}
-
-// EOF
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/CurrentHealthChartServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/CurrentHealthChartServlet.java
deleted file mode 100644
index bf0dd8d..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/CurrentHealthChartServlet.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.common.servlet;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.enterprise.gui.image.chart.Chart;
-import org.rhq.enterprise.gui.legacy.Constants;
-
-/**
- * <p>CurrentHealth chart servlet. The default <code>imageWidth</code> is 250 pixels. The default <code>
- * imageHeight</code> is 130 pixels.</p>
- *
- * <p>by default, this servlet will display an 8 column chart for the past 8 hours at 1 hour intervals based on the
- * metric category returned by the <code>{@link getMetricCategory}()</code>.</p>
- *
- * <p>Additional parameters are as follows (any required parameters are in <i>italics</i>):</p>
- *
- * <table border="1">
- * <tr>
- * <th>key</th>
- * <th>value</th>
- * </tr>
- * <tr>
- * <td> <i>eid</i></td>
- * <td><string or string[]></td>
- * </tr>
- * <tr>
- * <td>ctype</td>
- * <td><integer></td>
- * </tr>
- * </table>
- */
-public abstract class CurrentHealthChartServlet extends VerticalChartServlet {
- /**
- * Interval for metrics.
- */
- protected static final long INTERVAL = Constants.MINUTES * 30; // 1/2 hour
-
- /**
- * Default image width.
- */
- public static final int IMAGE_WIDTH_DEFAULT = 200;
-
- /**
- * Default image height.
- */
- public static final int IMAGE_HEIGHT_DEFAULT = 100;
-
- // member data
- private Log log = LogFactory.getLog(CurrentHealthChartServlet.class.getName());
-
- /**
- * Return the default <code>imageWidth</code>.
- */
- @Override
- protected int getDefaultImageWidth() {
- return IMAGE_WIDTH_DEFAULT;
- }
-
- /**
- * Return the default <code>imageHeight</code>.
- */
- @Override
- protected int getDefaultImageHeight() {
- return IMAGE_HEIGHT_DEFAULT;
- }
-
- /**
- * Return the corresponding measurement category.
- *
- * @return <code>{@link org.rhq.enterprise.server.legacy.measurement.MeasurementConstants.CAT_AVAILABILITY}</code>
- * or <code>{@link org.rhq.enterprise.server.legacy.measurement.MeasurementConstants.CAT_THROUGHPUT}</code>
- * or <code>{@link org.rhq.enterprise.server.legacy.measurement.MeasurementConstants.CAT_PERFORMANCE}</code>
- * or <code>{@link org.rhq.enterprise.server.legacy.measurement.MeasurementConstants.CAT_UTILIZATION}</code>
- */
- protected abstract String getMetricCategory();
-
- @Override
- protected void initializeChart(Chart chart) {
- super.initializeChart(chart);
- chart.font = Chart.SMALL_FONT;
- chart.showFullLabels = false;
- }
-
- /**
- * This method will be called automatically by the ChartServlet. It should handle adding data to the chart, setting
- * up the X and Y axis labels, etc.
- *
- * @param request the HTTP request
- */
- @Override
- protected void plotData(HttpServletRequest request, Chart chart) throws ServletException {
- // AppdefEntityID[] eids = null;
- // AppdefEntityTypeID ctype = null;
- // try {
- // eids = RequestUtils.getEntityIds(request);
- // } catch (ParameterNotFoundException e) {
- // /* platform auto-group */
- // }
- //
- // try {
- // ctype = RequestUtils.getHqChildResourceTypeId(request);
- // } catch (ParameterNotFoundException e) {
- // /* non auto-group */
- // }
- //
- // Integer tid = RequestUtils.getIntParameter(request, "tid");
- // try {
- // VerticalChart verticalChart = (VerticalChart) chart;
- //
- // long endTime = System.currentTimeMillis();
- // long beginTime = endTime - (8l * Constants.HOURS);
- //
- // MeasurementBoss mb =
- // ContextUtils.getMeasurementBoss( getServletContext() );
- //
- // List data = null;
- //// try {
- //// String user = RequestUtils.getStringParameter(request, "user");
- //// data = getData(user, mb, verticalChart, tid, eids, ctype,
- //// beginTime, endTime);
- //// } catch (ParameterNotFoundException e) {
- //// int sessionID = RequestUtils.getSessionId(request).intValue();
- //// data = getData(sessionID, mb, verticalChart, tid, eids, ctype,
- //// beginTime, endTime);
- //// }
- //
- // if (log.isDebugEnabled()) {
- // log.debug("Got " + data.size() + " " + getMetricCategory()
- // + " metric data points.");
- // if (log.isTraceEnabled()) {
- // log.debug("data=" + data);
- // }
- // }
- //
- // DataPointCollection chartData = chart.getDataPoints();
- // chartData.addAll(data);
- // } catch (MeasurementNotFoundException e) {
- // if ( log.isDebugEnabled() ) // don't log internal category names PR 6417
- // log.debug( "No " + getMetricCategory() + " metric found for: " +
- // StringUtil.arrayToString(eids) );
- // } catch (AppdefEntityNotFoundException e) {
- // if ( log.isDebugEnabled() )
- // log.debug( "One or more AppdefEntityIDs invalid: " +
- // StringUtil.arrayToString(eids) );
- // } catch (DataNotAvailableException e) {
- // if ( log.isDebugEnabled() )
- // log.debug("No metric data available.");
- // } catch (PermissionException e) {
- // log.warn("Permission denied to view metric.");
- // } catch (SessionNotFoundException e) {
- // log.warn("Session not found.");
- // } catch (SessionTimeoutException e) {
- // log.warn("Session timeout.");
- // } catch (RemoteException e) {
- // log.warn("Unknown error.", e);
- // } catch (TemplateNotFoundException e) {
- // log.warn("Template " + tid + " not found", e);
- // } catch (LoginException e) {
- // log.warn("Unable to login user", e);
- // } catch (ApplicationException e) {
- // log.warn("Error looking measurement data to chart", e);
- // } catch (ConfigPropertyException e) {
- // log.warn("Configuration error", e);
- // }
- }
-
- // private List getData(String user, MeasurementBoss mb, VerticalChart chart,
- // Integer tid, AppdefEntityID[] eids,
- // AppdefEntityTypeID ctype, long beginTime, long endTime)
- // throws LoginException, ApplicationException, RemoteException,
- // ConfigPropertyException {
- // Integer[] tids = new Integer[] { tid };
- //
- // List templates =
- // mb.findMeasurementTemplates(user, tids, PageControl.PAGE_ALL);
- //
- // MeasurementTempl tmpv =
- // (MeasurementTempl) templates.get(0);
- //
- // if (log.isDebugEnabled())
- // log.debug("template ID=" + tmpv.getId());
- //
- // setChartUnits(chart, tmpv);
- //
- // if (null == ctype) {
- // return mb.findMeasurementData(user, eids[0], tmpv,
- // beginTime, endTime, INTERVAL,
- // true, PageControl.PAGE_ALL);
- // } else {
- // return mb.findAGMeasurementData(user, eids, tmpv, ctype,
- // beginTime, endTime, INTERVAL,
- // true, PageControl.PAGE_ALL);
- // }
- // }
- //
- // private List getData(int sessionID, MeasurementBoss mb, VerticalChart chart,
- // Integer tid, AppdefEntityID[] eids,
- // AppdefEntityTypeID ctype, long beginTime, long endTime)
- // throws TemplateNotFoundException, SessionNotFoundException,
- // SessionTimeoutException, DataNotAvailableException,
- // AppdefEntityNotFoundException, MeasurementNotFoundException,
- // PermissionException, RemoteException {
- // Integer[] tids = new Integer[] { tid };
- //
- // List templates =
- // mb.findMeasurementTemplates(sessionID, tids, PageControl.PAGE_ALL);
- //
- // MeasurementTempl tmpv =
- // (MeasurementTempl) templates.get(0);
- //
- // if (log.isDebugEnabled())
- // log.debug("template ID=" + tmpv.getId());
- //
- // setChartUnits(chart, tmpv);
- //
- // if (null == ctype) {
- // return mb.findMeasurementData(sessionID, eids[0], tmpv,
- // beginTime, endTime, INTERVAL,
- // true, PageControl.PAGE_ALL);
- // } else {
- // return mb.findAGMeasurementData(sessionID, eids, tmpv, ctype,
- // beginTime, endTime, INTERVAL,
- // true, PageControl.PAGE_ALL);
- // }
- // }
- //
- // private void setChartUnits(VerticalChart chart,
- // MeasurementTempl tmpv) {
- // // override default / parsed units with the one from the metric
- // UnitsConstants unitUnits = UnitsConvert.getUnitForUnit(tmpv.getUnits());
- // ScaleConstants unitScale = UnitsConvert.getScaleForUnit(tmpv.getUnits());
- // chart.setFormat(unitUnits, unitScale);
- // int cumulativeTrend =
- // getTrendForCollectionType(tmpv.getCollectionType());
- // chart.setCumulativeTrend(cumulativeTrend);
- // }
-}
-
-// EOF
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java
deleted file mode 100755
index 9760900..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.common.servlet;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.servlet.ServletException;
-import javax.servlet.SingleThreadModel;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.common.EntityContext;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.MeasurementSchedule;
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.enterprise.gui.image.chart.Chart;
-import org.rhq.enterprise.gui.image.chart.DataPointCollection;
-import org.rhq.enterprise.gui.image.chart.HighLowChart;
-import org.rhq.enterprise.gui.legacy.DefaultConstants;
-import org.rhq.enterprise.gui.legacy.WebUser;
-import org.rhq.enterprise.gui.legacy.util.SessionUtils;
-import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal;
-import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerLocal;
-import org.rhq.enterprise.server.measurement.MeasurementPreferences;
-import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
-import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-/**
- * Display a high-low chart. This groks three kinds of input:
- *
- * <ul>
- * <li>schedId: show the data for a single schedule denoted by schedid</li>
- * <li>groupId + definitionId: show data for the passed definitionId and the given compatible group</li>
- * <li>id + childTypeId + definitionId: show data for the passed definition of the autogroup id/resourceTypeId</li>
- * </ul>
- *
- * @author Ian Springer
- * @author Heiko W. Rupp
- */
-public class HighLowChartServlet extends ChartServlet implements SingleThreadModel {
- private static final int NUMBER_OF_DATA_POINTS = DefaultConstants.DEFAULT_CHART_POINTS;
-
- private final Log log = LogFactory.getLog(HighLowChartServlet.class);
- private int scheduleId;
- private int definitionId;
- private int groupId;
- private int parentId;
- private int childTypeId;
-
- /* (non-Javadoc)
- * @see org.rhq.enterprise.gui.common.servlet.ChartServlet#createChart()
- */
- @Override
- protected Chart createChart() {
- return new HighLowChart(getImageWidth(), getImageHeight());
- }
-
- /**
- * Initialize the chart. This method will be called after the parameters have been parsed and the chart has been
- * created.
- *
- * @param chart the chart
- */
- @Override
- protected void initializeChart(Chart chart) {
- super.initializeChart(chart);
- HighLowChart highLowChart = (HighLowChart) chart;
- highLowChart.setNumberDataSets(1);
- highLowChart.leftBorder = 0;
- highLowChart.rightLabelWidth = (int) (this.getImageWidth() * 0.1);
- highLowChart.columnWidth = 7;
- }
-
- @Override
- protected void parseParameters(HttpServletRequest request) {
- // TODO if we have a schedule, we should also check the id= and see if that matches
- scheduleId = WebUtility.getOptionalIntRequestParameter(request, "schedId", -1);
- groupId = WebUtility.getOptionalIntRequestParameter(request, "groupId", -1);
- parentId = WebUtility.getOptionalIntRequestParameter(request, "parent", -1);
- childTypeId = WebUtility.getOptionalIntRequestParameter(request, "type", -1);
- definitionId = WebUtility.getOptionalIntRequestParameter(request, "definitionId", -1);
-
- /*
- * RHQ-743 - if we don't parse the request parameters here, on rare occasion the chart will be initialized
- * without any units, which then defaults to percentage; however, if the data represents bytes, and
- * if that value is large (in the GB range) then the Y-axis formatter for the Chart will attempt
- * to render GB labels are percentages, causing results like "227,040,000,000%"; by parsing all
- * HighLowChartServlet parameters here, we can guarantee that even if the caller did not pass the
- * units, they can be deduced from the various other parameters passed
- */
- String parameter = request.getParameter(MEASUREMENT_UNITS_PARAM);
- if (parameter == null || parameter.equals("")) {
- Subject overlord = LookupUtil.getSubjectManager().getOverlord();
- if (scheduleId > 0) {
- units = getUnitsFromScheduleId(overlord, scheduleId);
- } else {
- units = getUnitsFromDefinitionId(overlord, definitionId);
- }
- log.debug("Caller did not pass MeasuremntUnits, calculated them as " + units.getName());
- } else {
- log.debug("Caller passed MeasurementUnits of " + parameter);
- }
-
- super.parseParameters(request);
- }
-
- /* (non-Javadoc)
- * @see org.rhq.enterprise.gui.common.servlet.ChartServlet#plotData(javax.servlet.http.HttpServletRequest)
- */
- @Override
- protected void plotData(HttpServletRequest request, Chart chart) throws ServletException {
- // Make sure the schedule id was passed in.
- // TODO: Pass in a resource/group id and a measurement definition id instead. (ips, 04/16/07)
- if (log.isDebugEnabled()) {
- log.debug("Requesting: " + request.getQueryString());
- }
-
- WebUser user = SessionUtils.getWebUser(request.getSession());
- MeasurementPreferences preferences = user.getMeasurementPreferences();
- Subject subject = user.getSubject();
-
- MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();
- MeasurementDataManagerLocal dataManager = LookupUtil.getMeasurementDataManager();
-
- // set metric range defaults
- MetricRangePreferences rangePreferences = preferences.getMetricRangePreferences();
- long beginTime = rangePreferences.begin;
- long endTime = rangePreferences.end;
- List<MeasurementDataNumericHighLowComposite> dataPoints = null;
-
- int resourceId = -1;
- if (scheduleId > 0) {
- MeasurementSchedule schedule = scheduleManager.getScheduleById(subject, scheduleId);
- resourceId = schedule.getResource().getId();
- definitionId = schedule.getDefinition().getId();
- }
-
- EntityContext context = new EntityContext(resourceId, groupId, parentId, childTypeId);
- dataPoints = dataManager.findDataForContext(subject, context, definitionId, beginTime, endTime,
- NUMBER_OF_DATA_POINTS).get(0);
-
- List<HighLowMetricValue> chartDataPoints = new ArrayList<HighLowMetricValue>(dataPoints.size());
- for (MeasurementDataNumericHighLowComposite dataPoint : dataPoints) {
- chartDataPoints.add(new HighLowMetricValue(dataPoint));
- }
-
- HighLowChart highLowChart = (HighLowChart) chart;
- DataPointCollection bars = highLowChart.getDataPoints(0);
- bars.addAll(chartDataPoints);
- }
-
- private MeasurementUnits getUnitsFromScheduleId(Subject subject, int measurementScheduleId) {
- MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();
- MeasurementSchedule schedule = scheduleManager.getScheduleById(subject, measurementScheduleId);
- return schedule.getDefinition().getUnits();
- }
-
- private MeasurementUnits getUnitsFromDefinitionId(Subject subject, int measurementDefinitionId) {
- MeasurementDefinitionManagerLocal definitionManager = LookupUtil.getMeasurementDefinitionManager();
- MeasurementDefinition definition = definitionManager.getMeasurementDefinition(subject, measurementDefinitionId);
- return definition.getUnits();
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowMetricValue.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowMetricValue.java
deleted file mode 100644
index f0d1574..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowMetricValue.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.common.servlet;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.enterprise.gui.image.data.IHighLowDataPoint;
-import org.rhq.enterprise.gui.legacy.beans.NumericMetricDataPoint;
-
-/**
- * Represents the value of a numeric metric.
- *
- * @see MeasurementPluginManager#getValue
- * @see MeasurementPlugin#getValue
- */
-public class HighLowMetricValue extends NumericMetricDataPoint implements IHighLowDataPoint {
- private double highValue;
- private double lowValue;
- private int count = 0;
-
- /**
- * Full constructor - ultimately called by all other constructors.
- */
- public HighLowMetricValue(double value, double highValue, double lowValue, long rtime) {
- super(new MeasurementDataNumericHighLowComposite(rtime, value, highValue, lowValue));
- this.highValue = highValue;
- this.lowValue = lowValue;
- }
-
- /**
- * Construct with values.
- */
- public HighLowMetricValue(double value, long rtime) {
- this(value, value, value, rtime);
- }
-
- /**
- * Default retrieval time to System.currentTimeMillis()
- */
- public HighLowMetricValue(double value) {
- this(value, System.currentTimeMillis());
- }
-
- /**
- * one can always extend and override getRetrievalTime to be more robust.
- */
- public HighLowMetricValue(Number objectValue, long rtime) {
- this(objectValue.doubleValue(), rtime);
- }
-
- /*
- * one can always extend and override getRetrievalTime to be more robust.
- */
- public HighLowMetricValue(HighLowMetricValue objectValue, long rtime) {
- this(objectValue.getValue(), rtime);
- }
-
- /*
- * one can always extend and override getRetrievalTime to be more robust.
- */
- public HighLowMetricValue(long value, long rtime) {
- this((double) value, rtime);
- }
-
- public HighLowMetricValue(MeasurementDataNumericHighLowComposite dataPoint) {
- this(dataPoint.getValue(), dataPoint.getHighValue(), dataPoint.getLowValue(), dataPoint.getTimestamp());
- }
-
- /**
- * Get the Object value. Useful if you don't yet care what the type is.
- */
- @Override
- public Double getObjectValue() {
- return getValue();
- }
-
- /* (non-Javadoc)
- * @see net.covalent.chart.IDataPoint#getLabel()
- */
- @Override
- public String getLabel() {
- return SimpleDateFormat.getDateTimeInstance().format(new Date(this.getTimestamp()));
- }
-
- public double getLowValue() {
- return lowValue;
- }
-
- public void setLowValue(double lowValue) {
- this.lowValue = lowValue;
- }
-
- public double getHighValue() {
- return highValue;
- }
-
- public void setHighValue(double highValue) {
- this.highValue = highValue;
- }
-
- public void setCount(int count) {
- this.count = count;
- }
-
- public int getCount() {
- return count;
- }
-
- /**
- * This is for the Datapoint interface. It compares only the value of the measurements, not the timestamp.
- */
- @Override
- public int compareTo(Object o) {
- HighLowMetricValue o2 = (HighLowMetricValue) o;
- double difference = this.getValue() - o2.getValue();
-
- // can't just return subtraction, because casting to integer
- // loses the negative values for small differences (< 1), which we
- // need.
- if (difference < 0) {
- return -1;
- }
-
- if (difference > 0) {
- return 1;
- }
-
- return 0;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof HighLowMetricValue) {
- HighLowMetricValue val = (HighLowMetricValue) obj;
- return ((this.getTimestamp() == val.getTimestamp()) && (this.getValue() == val.getValue()));
- }
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.rhq.enterprise.gui.image.data.IStackedDataPoint#getValues()
- */
- public double[] getValues() {
- return new double[] { this.getValue() };
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/MetricChartServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/MetricChartServlet.java
deleted file mode 100644
index f2b2052..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/MetricChartServlet.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.common.servlet;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.enterprise.gui.image.chart.Chart;
-import org.rhq.enterprise.gui.image.chart.ColumnChart;
-import org.rhq.enterprise.gui.image.chart.DataPointCollection;
-import org.rhq.enterprise.gui.image.chart.LineChart;
-import org.rhq.enterprise.gui.image.chart.VerticalChart;
-import org.rhq.enterprise.gui.image.data.IDataPoint;
-import org.rhq.enterprise.gui.legacy.beans.ChartDataBean;
-
-/**
- * <p>Extends ChartServlet to graph one or more metrics. By default, <code>showPeak</code>, <code>showHighRange</code>,
- * <code>showValues</code>, <code>showAverage</code>, <code>showLowRange</code>, <code>showLow</code> and <code>
- * showBaseline</code> are all true.</p>
- *
- * <p>Additional parameters are as follows (any required parameters are in <i>italics</i>):</p>
- *
- * <table border="1">
- * <tr>
- * <th>key</th>
- * <th>value</th>
- * </tr>
- * <tr>
- * <td> <i>chartDataKey</i></td>
- * <td><string></td>
- * </tr>
- * <tr>
- * <td>showEvents</td>
- * <td>(<b>false</b> | true)</td>
- * </tr>
- * </table>
- *
- * <p>The <code>chartDataKey</code> will be used to retrieve the chart data from the session. Once it is pulled, it will
- * be removed from the session.</p>
- */
-public class MetricChartServlet extends VerticalChartServlet {
- /**
- * Request parameter for the chart data key session attribute.
- */
- public static final String CHART_DATA_KEY_PARAM = "chartDataKey";
-
- /**
- * Request parameter for whether or not to show control actions.
- */
- public static final String SHOW_EVENTS_PARAM = "showEvents";
-
- // member data
- private Log log = LogFactory.getLog(MetricChartServlet.class.getName());
- private String chartDataKey;
- private boolean plotLineChart;
-
- public MetricChartServlet() {
- }
-
- /**
- * This method will be called automatically by the ChartServlet. It should handle the parsing and error-checking of
- * any specific parameters for the chart being rendered.
- *
- * @param request the HTTP request object
- */
- @Override
- protected void parseParameters(HttpServletRequest request) {
- super.parseParameters(request);
-
- // chart data key
- chartDataKey = parseRequiredStringParameter(request, CHART_DATA_KEY_PARAM);
-
- // We will actually set a flag here to determine whether we
- // should draw a LineChart or a column chart. If we are
- // charting just one set of data / event points, we'll plot a
- // ColumnChart. Otherwise we'll plot a LineChart.
- ChartDataBean dataBean = (ChartDataBean) request.getSession().getAttribute(chartDataKey);
- List<List<IDataPoint>> dataPointsList;
- if (dataBean != null)
- dataPointsList = dataBean.getDataPoints();
- else
- dataPointsList = new ArrayList<List<IDataPoint>>();
- plotLineChart = (dataPointsList.size() > 1);
-
- // chart flags
- }
-
- /**
- * Create and return the chart. This method will be called after the parameters have been parsed.
- *
- * @return the newly created chart
- */
- @Override
- protected Chart createChart() {
- if (plotLineChart) {
- if (log.isTraceEnabled())
- log.trace("plotting a line chart");
- return new LineChart(getImageWidth(), getImageHeight());
- } else {
- if (log.isTraceEnabled())
- log.trace("plotting a column chart");
- return new ColumnChart(getImageWidth(), getImageHeight());
- }
- }
-
- /**
- * Initialize the chart. This method will be called after the parameters have been parsed and the chart has been
- * created.
- *
- * @param chart the chart
- */
- @Override
- protected void initializeChart(Chart chart) {
- super.initializeChart(chart);
-
- VerticalChart verticalChart = (VerticalChart) chart;
- verticalChart.showRightLabels = false;
- verticalChart.rightLabelWidth = (int) (getImageWidth() * 0.1);
- verticalChart.xLabelsSkip = 5;
- }
-
- /**
- * This method will be called automatically by the ChartServlet. It should handle adding data to the chart, setting
- * up the X and Y axis labels, etc.
- *
- * @param request the HTTP request
- */
- @Override
- protected void plotData(HttpServletRequest request, Chart chart) throws ServletException {
- VerticalChart veritcalChart = (VerticalChart) chart;
-
- ChartDataBean dataBean = (ChartDataBean) request.getSession().getAttribute(chartDataKey);
- List<List<IDataPoint>> dataPointsList;
- if (dataBean != null) {
- dataPointsList = dataBean.getDataPoints();
- } else {
- dataPointsList = new ArrayList<List<IDataPoint>>();
- }
-
- // make sure they're the same size
- if (log.isDebugEnabled()) {
- log.debug("got " + dataPointsList.size() + " set(s) of data points.");
- }
-
- veritcalChart.setNumberDataSets(dataPointsList.size());
- int i = 0;
- Iterator<List<IDataPoint>> it = dataPointsList.iterator();
- while (it.hasNext()) {
- // data points
- List<IDataPoint> data = it.next();
- if (log.isTraceEnabled())
- log.trace("plotting " + data.size() + " data points");
- DataPointCollection chartData = chart.getDataPoints(i);
- chartData.addAll(data);
-
- // increment
- ++i;
- }
-
- request.getSession().removeAttribute(chartDataKey);
- }
-
- /**
- * Return the default <code>showPeak</code>.
- */
- @Override
- protected boolean getDefaultShowPeak() {
- return true;
- }
-
- /**
- * Return the default <code>showHighRange</code>.
- */
- @Override
- protected boolean getDefaultShowHighRange() {
- return true;
- }
-
- /**
- * Return the default <code>showValues</code>.
- */
- @Override
- protected boolean getDefaultShowValues() {
- return true;
- }
-
- /**
- * Return the default <code>showAverage</code>.
- */
- @Override
- protected boolean getDefaultShowAverage() {
- return true;
- }
-
- /**
- * Return the default <code>showLowRange</code>.
- */
- @Override
- protected boolean getDefaultShowLowRange() {
- return true;
- }
-
- /**
- * Return the default <code>showLow</code>.
- */
- @Override
- protected boolean getDefaultShowLow() {
- return true;
- }
-
- /**
- * Return the default <code>showBaseline</code>.
- */
- @Override
- protected boolean getDefaultShowBaseline() {
- return true;
- }
-
- /**
- * Return the default <code>showEvents</code>.
- */
- protected boolean getDefaultShowEvents() {
- return true;
- }
-
- //---------------------------------------------------------------
- //-- private helpers
- //---------------------------------------------------------------
- private void _logParameters() {
- if (log.isDebugEnabled()) {
- StringBuffer sb = new StringBuffer("Parameters:");
- sb.append("\n");
- sb.append("\t");
- sb.append(CHART_DATA_KEY_PARAM);
- sb.append(": ");
- sb.append(chartDataKey);
- sb.append("\n");
- sb.append("\t");
- log.debug(sb.toString());
- }
- }
-}
-
-// EOF
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/NavMapImageServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/NavMapImageServlet.java
deleted file mode 100644
index ef90e60..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/NavMapImageServlet.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.common.servlet;
-
-import java.io.IOException;
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.enterprise.gui.image.WebImage;
-import org.rhq.enterprise.gui.image.widget.ResourceTree;
-
-/**
- * <p>This servlet returns a response that contains the binary data of an image (JPEG or PNG) that can be viewed in a
- * web browser.</p>
- *
- * <p>The navigation map servlet takes the following parameters (any applicable defaults are in <b>bold</b> and required
- * parameters are in <i>italics</i>):</p>
- *
- * <table border="1">
- * <tr>
- * <th>key</th>
- * <th>value</th>
- * </tr>
- * <tr>
- * <td> <i>treeVar</i></td>
- * <td><string></td>
- * </tr>
- * </table>
- */
-public class NavMapImageServlet extends ImageServlet {
- /**
- * Request parameter for the tree variable session attribute.
- */
- public static final String TREE_VAR_PARAM = "treeVar";
-
- /**
- * Default image width.
- */
- public static final int IMAGE_WIDTH_DEFAULT = 800;
-
- // member data
- private Log log = LogFactory.getLog(NavMapImageServlet.class.getName());
- private String treeVar;
-
- public NavMapImageServlet() {
- }
-
- /**
- * Create the image being rendered.
- *
- * @param request the servlet request
- */
- protected Object createImage(HttpServletRequest request) throws ServletException {
- WebImage image = (ResourceTree) request.getSession().getAttribute(treeVar);
- request.getSession().removeAttribute(treeVar);
- return image;
- }
-
- /**
- * Render a PNG version of the image into the output stream.
- *
- * @param out the output stream
- */
- protected void renderPngImage(ServletOutputStream out, Object imgObj) throws IOException {
- WebImage image = (WebImage) imgObj;
- if (null != image) {
- image.writePngImage(out);
- }
- }
-
- /**
- * Render a JPEG version of the image into the output stream.
- *
- * @param out the output stream
- */
- protected void renderJpegImage(ServletOutputStream out, Object imgObj) throws IOException {
- WebImage image = (WebImage) imgObj;
- if (null != image) {
- image.writeJpegImage(out);
- }
- }
-
- /**
- * This method will be called automatically by the ChartServlet. It should handle the parsing and error-checking of
- * any specific parameters for the chart being rendered.
- *
- * @param request the HTTP request object
- */
- protected void parseParameters(HttpServletRequest request) {
- super.parseParameters(request);
-
- // chart data key
- treeVar = parseRequiredStringParameter(request, TREE_VAR_PARAM);
-
- _logParameters();
- }
-
- /**
- * Return the default <code>imageWidth</code>.
- */
- protected int getDefaultImageWidth() {
- return IMAGE_WIDTH_DEFAULT;
- }
-
- //---------------------------------------------------------------
- //-- private helpers
- //---------------------------------------------------------------
- private void _logParameters() {
- if (log.isDebugEnabled()) {
- StringBuffer sb = new StringBuffer("Parameters:");
- sb.append("\n");
- sb.append("\t");
- sb.append(TREE_VAR_PARAM);
- sb.append(": ");
- sb.append(treeVar);
- log.debug(sb.toString());
- }
- }
-}
-
-// EOF
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/PerformanceChartServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/PerformanceChartServlet.java
deleted file mode 100644
index 7597db4..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/PerformanceChartServlet.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.common.servlet;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.core.domain.measurement.calltime.CallTimeDataComposite;
-import org.rhq.enterprise.gui.image.chart.Chart;
-import org.rhq.enterprise.gui.image.chart.DataPoint;
-import org.rhq.enterprise.gui.image.chart.PerfDataPointCollection;
-import org.rhq.enterprise.gui.image.chart.StackedPerformanceChart;
-import org.rhq.enterprise.gui.legacy.Constants;
-import org.rhq.enterprise.gui.legacy.util.ChartData;
-import org.rhq.enterprise.gui.legacy.util.RequestUtils;
-import org.rhq.enterprise.gui.rt.SegmentInfo;
-
-/**
- * Performance chart servlet.
- *
- * <p/>Additional parameters are as follows (any required parameters are in <i>italics</i>):
- *
- * <p/>
- * <table border="1">
- * <tr>
- * <th>key</th>
- * <th>value</th>
- * </tr>
- * <tr>
- * <td>perfChartType</td>
- * <td>{ 'url' | 'urldetail' | 'type' }</td>
- * </tr>
- * </table>
- *
- * @author Ian Springer
- */
-public class PerformanceChartServlet extends ChartServlet {
- // member data
- private Log log = LogFactory.getLog(PerformanceChartServlet.class.getName());
- private String perfChartType = null;
- private int numCharts = 0;
- private String m_destinationType;
-
- private static final int DEFAULT_PERF_IMAGE_HEIGHT = 300;
- private static final int DEFAULT_PERF_IMAGE_WIDTH = 755;
-
- /**
- * Request parameter for performance chart type.
- */
- public static final String PERF_CHART_TYPE_PARAM = "perfChartType";
-
- /**
- * Request parameter value representing a url perfchart.
- */
- public static final String CHART_TYPE_URL = "url";
-
- /**
- * Request parameter value representing a urldetail perf chart.
- */
- public static final String CHART_TYPE_URLDETAIL = "urldetail";
-
- /**
- * Request parameter value representing an type perf chart.
- */
- public static final String CHART_TYPE_TYPE = "type";
-
- // the valid values of PERF_CHART_TYPE_PARAM
- private static final String[] VALID_PERF_CHART_TYPES = { CHART_TYPE_URL, CHART_TYPE_URLDETAIL, CHART_TYPE_TYPE, };
-
- // labels for the performance chart. These correspond to
- // the Rt tier constants in RtConstants
-
- // @see net.covalent.rt.RtConstants
- private static final String WEBSERVER_LABEL_PROPERTY = "resource.common.monitor.visibility.VitualHostHeaderTH";
- private static final String APPSERVER_LABEL_PROPERTY = "resource.common.monitor.visibility.WebappHeaderTH";
- private static final String ENDUSER_LABEL_PROPERTY = "resource.common.monitor.visibility.EndUserHeaderTH";
-
- private static final String LOW_LABEL_PROPERTY = "resource.common.monitor.visibility.LowTH";
- private static final String AVG_LABEL_PROPERTY = "resource.common.monitor.visibility.AvgTH";
- private static final String PEAK_LABEL_PROPERTY = "resource.common.monitor.visibility.PeakTH";
-
- public PerformanceChartServlet() {
- }
-
- /**
- * This method will be called automatically by the ChartServlet. It should handle the parsing and error-checking of
- * any specific parameters for the chart being rendered.
- *
- * <p/>Handles parsing of perfChartType request parameter.
- *
- * @param request the HTTP request object
- */
- @Override
- protected void parseParameters(HttpServletRequest request) {
- String tmpPerfChartType = parseRequiredStringParameter(request, PERF_CHART_TYPE_PARAM, VALID_PERF_CHART_TYPES);
- setPerfChartType(tmpPerfChartType);
-
- // take the chart data from the session.
- HttpSession session = request.getSession(false);
- ChartData chartData = (ChartData) session.getAttribute(Constants.CHART_DATA_SES_ATTR);
- if (chartData != null) {
- if (perfChartType.equals(CHART_TYPE_URL) || perfChartType.equals(CHART_TYPE_TYPE)) {
- setNumCharts(chartData.getSummaries().size());
- } else if (perfChartType.equals(CHART_TYPE_URLDETAIL)) {
- setNumCharts(chartData.getSegments().size());
- }
-
- if (units == null || units == MeasurementUnits.NONE) {
- units = chartData.getMeasurementDefinition().getUnits();
- }
-
- m_destinationType = chartData.getMeasurementDefinition().getDestinationType();
- }
-
- super.parseParameters(request);
- }
-
- /**
- * Create and return the chart. This method will be called after the parameters have been parsed.
- *
- * @return the newly created chart
- */
- @Override
- protected Chart createChart() {
- return new StackedPerformanceChart(getImageWidth(), getNumCharts(), m_destinationType);
- }
-
- /**
- * This method will be called automatically by the ChartServlet. It should handle adding data to the chart, setting
- * up the X and Y axis labels, etc.
- *
- * @param request the HTTP request object
- */
- @Override
- protected void plotData(HttpServletRequest request, Chart chart) throws ServletException {
- StackedPerformanceChart perfChart = (StackedPerformanceChart) chart;
-
- // Grab the chart data from the session.
- HttpSession session = request.getSession(false);
- ChartData chartData = (ChartData) session.getAttribute(Constants.CHART_DATA_SES_ATTR);
- if (chartData == null) {
- log.debug("Did not find performance chart data to plot.");
- return;
- }
-
- /*
- * // labels for the different types of graphs HashMap labels = new HashMap(); labels.put(new
- * Integer(RtConstants.APPSERVER), RequestUtils.message(request, APPSERVER_LABEL_PROPERTY));
- * labels.put(new Integer(RtConstants.WEBSERVER), RequestUtils.message(request,
- * WEBSERVER_LABEL_PROPERTY)); labels.put(new Integer(RtConstants.ENDUSER),
- * RequestUtils.message(request, ENDUSER_LABEL_PROPERTY));
- */
-
- // labels for the different types of measurements
- Map mlabels = new HashMap();
- mlabels.put(LOW_LABEL_PROPERTY, RequestUtils.message(request, LOW_LABEL_PROPERTY));
- mlabels.put(AVG_LABEL_PROPERTY, RequestUtils.message(request, AVG_LABEL_PROPERTY));
- mlabels.put(PEAK_LABEL_PROPERTY, RequestUtils.message(request, PEAK_LABEL_PROPERTY));
-
- if (isTypeChart() || isUrlChart()) {
- List<CallTimeDataComposite> summaries = chartData.getSummaries();
- perfChart.setNumberDataSets(summaries.size());
-
- Iterator summariesIter = summaries.iterator();
- Iterator barsIter = perfChart.getDataSetIterator();
- while (summariesIter.hasNext() && barsIter.hasNext()) {
- PerfDataPointCollection bars = (PerfDataPointCollection) barsIter.next();
- CallTimeDataComposite summary = (CallTimeDataComposite) summariesIter.next();
- Integer segmentId = null;
-
- /*if (isTypeChart())
- * { // dig through the summaries to figure out // which segment has data if (summary.getMinimum() !=
- * null) { segmentId = grovel(summary.getMinimum()); } else if (summary.getAverage() != null) {
- * segmentId = grovel(summary.getAverage()); } else if (summary.getMaximum() != null) { segmentId =
- * grovel(summary.getMaximum()); }}*/
- fillOutSummarySection(bars, chartData, summary, segmentId, mlabels);
- }
- } else if (isUrlDetailChart()) {
- // Map segments = data.getSegments();
- // Set segmentIds = segments.keySet();
- // perfChart.setNumberDataSets(segmentIds.size());
- // PerformanceSummary summary = null;
- // Integer segmentId = null;
- //
- // List summaries = null;
- // Iterator summariesIter = null;
- // Iterator barsIter = perfChart.getDataSetIterator();
- // Iterator segmentIdIter = segmentIds.iterator();
- // while (segmentIdIter.hasNext()) {
- // segmentId = (Integer) segmentIdIter.next();
- //
- // summaries = (List) segments.get(segmentId);
- // summariesIter = summaries.iterator();
- // while (summariesIter.hasNext()) {
- // bars = (PerfDataPointCollection) barsIter.next();
- // summary = (PerformanceSummary) summariesIter.next();
- //
- // fillOutSummarySection(bars, data, summary, segmentId,
- // mlabels);
- // }
- // }
- }
-
- // remove the chart data from the session.
- session.removeAttribute(Constants.CHART_DATA_SES_ATTR);
- }
-
- //---------------------------------------------------------------
- //-- private helpers
- //---------------------------------------------------------------
-
- /*
- * // this method figures out which "tier" we're in private Integer grovel(SegmentInfo info) { for (int i =
- * RtConstants.STARTRTTYPE; i < RtConstants.ENDRTTYPE; i++){ if (info.getSegment(i-1) != null) {
- * return new Integer(i); } } return new Integer(RtConstants.UNKNOWN); }
- */
-
- private void fillOutSummarySection(PerfDataPointCollection bars, ChartData data, CallTimeDataComposite summary,
- Integer segmentId, Map mlabels) {
- // header value
- if (segmentId != null) {
- bars.setType(segmentId.intValue());
- }
-
- // XXX: i really want to be able to set the type string with
- // one of the labels i pulled from message resources, but
- // there's no api for it
-
- bars.setURL(summary.getCallDestination());
-
- if ((data.getShowReq() != null) && data.getShowReq()) {
- bars.setRequest((int) summary.getCount());
- }
-
- if ((data.getShowLow() != null) && data.getShowLow()) {
- bars.add(new DataPoint(summary.getMinimum(), (String) mlabels.get(LOW_LABEL_PROPERTY)));
- //addDataPoint(bars, summary.getMinimum(), (String)mlabels.get(LOW_LABEL_PROPERTY));
- }
-
- if ((data.getShowAvg() != null) && data.getShowAvg()) {
- bars.add(new DataPoint(summary.getAverage(), (String) mlabels.get(AVG_LABEL_PROPERTY)));
- //addDataPoint(bars, summary.getAverage(), (String)mlabels.get(AVG_LABEL_PROPERTY));
- }
-
- if ((data.getShowPeak() != null) && data.getShowPeak()) {
- bars.add(new DataPoint(summary.getMaximum(), (String) mlabels.get(PEAK_LABEL_PROPERTY)));
- //addDataPoint(bars, summary.getMaximum(), (String)mlabels.get(PEAK_LABEL_PROPERTY));
- }
- }
-
- private void addDataPoint(PerfDataPointCollection bars, SegmentInfo segInfo, String label) {
- if (segInfo != null) {
- if (log.isTraceEnabled()) {
- log.trace("adding " + label + " value: " + segInfo.getSegments());
- }
-
- segInfo.setLabel(label);
- bars.add(segInfo);
- } else {
- bars.add(new DataPoint(Double.NaN, label));
- }
- }
-
- /**
- * Return the default <code>imageHeight</code>.
- */
- @Override
- protected int getDefaultImageHeight() {
- return DEFAULT_PERF_IMAGE_HEIGHT;
- }
-
- /**
- * Return the default <code>imageWidth</code>.
- */
- @Override
- protected int getDefaultImageWidth() {
- return DEFAULT_PERF_IMAGE_WIDTH;
- }
-
- public String getPerfChartType() {
- return this.perfChartType;
- }
-
- public void setPerfChartType(String type) {
- this.perfChartType = type;
- }
-
- public int getNumCharts() {
- return this.numCharts;
- }
-
- public void setNumCharts(int size) {
- this.numCharts = size;
- }
-
- public boolean isTypeChart() {
- return getPerfChartType().equals(CHART_TYPE_TYPE);
- }
-
- public boolean isUrlChart() {
- return getPerfChartType().equals(CHART_TYPE_URL);
- }
-
- public boolean isUrlDetailChart() {
- return getPerfChartType().equals(CHART_TYPE_URLDETAIL);
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/UsageHealthChartServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/UsageHealthChartServlet.java
deleted file mode 100644
index 4436291..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/UsageHealthChartServlet.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.common.servlet;
-
-import org.rhq.enterprise.gui.image.chart.Chart;
-import org.rhq.enterprise.gui.image.chart.UsageChart;
-import org.rhq.enterprise.server.legacy.measurement.MeasurementConstants;
-
-/**
- * <p>Usage current health chart servlet.</p>
- */
-public class UsageHealthChartServlet extends CurrentHealthChartServlet {
- public UsageHealthChartServlet() {
- }
-
- /**
- * Create and return the chart. This method will be called after the parameters have been parsed.
- *
- * @return the newly created chart
- */
- protected Chart createChart() {
- return new UsageChart(getImageWidth(), getImageHeight());
- }
-
- /**
- * Return the corresponding measurement category.
- *
- * @return <code>{@link org.rhq.enterprise.server.legacy.measurement.MeasurementConstants.CAT_THROUGHPUT}</code> or
- */
- protected String getMetricCategory() {
- return MeasurementConstants.CAT_THROUGHPUT;
- }
-}
-
-// EOF
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/UtilizationHealthChartServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/UtilizationHealthChartServlet.java
deleted file mode 100644
index d47c5b3..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/UtilizationHealthChartServlet.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.common.servlet;
-
-import org.rhq.enterprise.server.legacy.measurement.MeasurementConstants;
-
-/**
- * <p>Utilization current health chart servlet.</p>
- */
-public class UtilizationHealthChartServlet extends UsageHealthChartServlet {
- /**
- * Return the corresponding measurement category.
- *
- * @return <code>{@link org.rhq.enterprise.server.legacy.measurement.MeasurementConstants.CAT_UTILIZATION}</code>
- */
- protected String getMetricCategory() {
- return MeasurementConstants.CAT_UTILIZATION;
- }
-}
-
-// EOF
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/VerticalChartServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/VerticalChartServlet.java
deleted file mode 100644
index 4e3b9b5..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/VerticalChartServlet.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.common.servlet;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.enterprise.gui.image.chart.Chart;
-import org.rhq.enterprise.gui.image.chart.Trend;
-import org.rhq.enterprise.gui.image.chart.VerticalChart;
-import org.rhq.enterprise.server.legacy.measurement.MeasurementConstants;
-
-/**
- * <p>Abstract base class for vertical charts.</p>
- *
- * <p>The chart servlet takes the following parameters (any applicable
- * defaults are in <b>bold</b> and required parameters are in
- * <i>italics</i>):</p>
- *
- * <table border="1">
- * <tr><th> key </th><th> value </th></tr>
- * <tr><td> collectionType </td><td> <integer <b>(0)</b>>* </td></tr>
- * </table>
- *
- * <p>* Must be a valid value from <code>{@link
- * org.rhq.enterprise.server.legacy.measurement.MeasurementConstants</code>.</p>
- *
- * @see org.rhq.enterprise.server.legacy.measurement.MeasurementConstants
- */
-public abstract class VerticalChartServlet extends ChartServlet {
- /** Request parameter for unit scale. */
- public static final String COLLECTION_TYPE_PARAM = "collectionType";
-
- // member data
- private Log log = LogFactory.getLog(VerticalChartServlet.class.getName());
- private int collectionType;
-
- public VerticalChartServlet() {
- }
-
- /**
- * Return the default <code>collectionType</code>.
- */
- protected int getDefaultCollectionType() {
- return MeasurementConstants.COLL_TYPE_DYNAMIC;
- }
-
- /**
- * This method will be called automatically by the ChartServlet.
- * It should handle the parsing and error-checking of any specific
- * parameters for the chart being rendered.
- *
- * @param request the HTTP request object
- */
- protected void parseParameters(HttpServletRequest request) {
- super.parseParameters(request);
-
- // cumulative trend
- collectionType = parseIntParameter(request, COLLECTION_TYPE_PARAM, getDefaultCollectionType());
- _logParameters();
- }
-
- /**
- * Initialize the chart. This method will be called after the
- * parameters have been parsed and the chart has been created.
- *
- * @param chart the chart
- */
- protected void initializeChart(Chart chart) {
- super.initializeChart(chart);
-
- VerticalChart verticalChart = (VerticalChart) chart;
- int cumulativeTrend = getTrendForCollectionType(collectionType);
- verticalChart.setCumulativeTrend(cumulativeTrend);
- }
-
- /**
- * Get the trend based on the collection type. If the collection
- * type is invalid, it will return <code>TREND_NONE</code>.
- *
- * @param collectionType the collection type from <code>{@link
- * org.rhq.enterprise.server.legacy.measurement.MeasurementConstants}</code>
- * @return the trend from <code>{@link
- * net.covalent.chart.Trend}</code>
- * @see org.rhq.enterprise.server.legacy.measurement.MeasurementConstants
- * @see net.covalent.chart.Trend
- */
- protected int getTrendForCollectionType(int collectionType) {
- int trend = Trend.TREND_NONE;
- switch (collectionType) {
- case MeasurementConstants.COLL_TYPE_DYNAMIC:
- case MeasurementConstants.COLL_TYPE_STATIC:
- trend = Trend.TREND_NONE;
- break;
- case MeasurementConstants.COLL_TYPE_TRENDSUP:
- trend = Trend.TREND_UP;
- break;
- case MeasurementConstants.COLL_TYPE_TRENDSDOWN:
- trend = Trend.TREND_DOWN;
- break;
- default:
- log.warn("Invalid collection type: " + collectionType);
- break;
- }
- return trend;
- }
-
- private void _logParameters() {
- if (log.isDebugEnabled()) {
- StringBuffer sb = new StringBuffer("Parameters:");
- sb.append("\n");
- sb.append("\t");
- sb.append(COLLECTION_TYPE_PARAM);
- sb.append(": ");
- sb.append(collectionType);
- log.debug(sb.toString());
- }
- }
-}
-
-// EOF
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/ImageUtil.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/ImageUtil.java
deleted file mode 100644
index de24277..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/ImageUtil.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.IndexColorModel;
-import java.awt.image.Raster;
-import java.awt.image.WritableRaster;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.imageio.ImageIO;
-
-public class ImageUtil {
- /**
- * Creates a copy of an image and during the process converts the image to an indexed color image.
- *
- * @param image Image to convert.
- *
- * @return BufferedImage with an indexed color pallette
- */
- public static BufferedImage convertToIndexColorImage(BufferedImage image) {
- byte[][] clrs = ImageUtil.scrapeColors(image);
-
- IndexColorModel model = new IndexColorModel(8, clrs[0].length, clrs[0], clrs[1], clrs[2], 0);
- BufferedImage copy = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_BYTE_INDEXED,
- model);
-
- ImageUtil.copyPixels(image, copy);
-
- return copy;
- }
-
- /**
- * Copy pixels from an RGB color model to an Indexed color model.
- */
- private static void copyPixels(BufferedImage src, BufferedImage dst, byte[][] rgb) {
- // Get Destination Index Colors
- IndexColorModel model = (IndexColorModel) dst.getColorModel();
-
- int size = model.getMapSize();
- byte[] r = new byte[size];
- byte[] g = new byte[size];
- byte[] b = new byte[size];
-
- model.getReds(r);
- model.getGreens(g);
- model.getBlues(b);
-
- // Get Source Pixels
- int i;
- Raster srcRaster = src.getRaster();
- int[][] srcPixels = new int[srcRaster.getNumBands()][];
-
- for (int band = 0; band < srcRaster.getNumBands(); band++) {
- srcPixels[band] = srcRaster.getSamples(0, 0, srcRaster.getWidth(), srcRaster.getHeight(), band,
- (int[]) null);
- }
-
- // Get Destination Pixels
- WritableRaster dstRaster = dst.getRaster();
- int[] dstPixels = new int[dstRaster.getWidth() * dstRaster.getHeight()];
-
- // Index Pixels
- for (int pixel = 0; pixel < dstPixels.length; pixel++) {
- // Find the Color in the Index
- for (i = 0; i < r.length; i++) {
- byte red = (byte) srcPixels[0][pixel];
- byte green = (byte) srcPixels[1][pixel];
- byte blue = (byte) srcPixels[2][pixel];
-
- if ((red == r[i]) && (green == g[i]) && (blue == b[i])) {
- dstPixels[pixel] = i;
- break;
- }
- }
-
- if (i == r.length) {
- System.out.println("Missing Color");
- }
- }
-
- dstRaster.setPixels(0, 0, dstRaster.getWidth(), dstRaster.getHeight(), dstPixels);
- }
-
- private static void copyPixels(BufferedImage src, BufferedImage dst) {
- // Get Destination Index Colors
- IndexColorModel model = (IndexColorModel) dst.getColorModel();
-
- int size = model.getMapSize();
- byte[] r = new byte[size];
- byte[] g = new byte[size];
- byte[] b = new byte[size];
-
- model.getReds(r);
- model.getGreens(g);
- model.getBlues(b);
-
- // Get Source Pixels
- int i;
- Raster srcRaster = src.getRaster();
- int[][] srcPixels = new int[srcRaster.getNumBands()][];
-
- for (int band = 0; band < srcRaster.getNumBands(); band++) {
- srcPixels[band] = srcRaster.getSamples(0, 0, srcRaster.getWidth(), srcRaster.getHeight(), band,
- (int[]) null);
- }
-
- // Get Destination Pixels
- WritableRaster dstRaster = dst.getRaster();
- int[] dstPixels = new int[dstRaster.getWidth() * dstRaster.getHeight()];
-
- // Index Pixels
- for (int pixel = 0; pixel < dstPixels.length; pixel++) {
- // Find the Color in the Index
- for (i = 0; i < r.length; i++) {
- byte red = (byte) srcPixels[0][pixel];
- byte green = (byte) srcPixels[1][pixel];
- byte blue = (byte) srcPixels[2][pixel];
-
- if ((red == r[i]) && (green == g[i]) && (blue == b[i])) {
- dstPixels[pixel] = i;
- break;
- }
- }
-
- if (i == r.length) {
- System.out.println("Missing Color");
- }
- }
-
- dstRaster.setPixels(0, 0, dstRaster.getWidth(), dstRaster.getHeight(), dstPixels);
- }
-
- private static byte[] findUnusedColor(byte[][] clrs) {
- byte r = 1;
- byte g = 1;
- byte b = 1;
-
- for (int i = 0; i < clrs.length; i++) {
- if ((r != clrs[0][i]) && (g != clrs[1][i]) && (b != clrs[2][i])) {
- break;
- }
-
- r++;
- g++;
- b++;
- }
-
- byte[] result = { r, g, b };
- return result;
- }
-
- /**
- * Loads an image from a file on disk or in an archive (e.g., .jar).
- *
- * @param path The name of the image file to load. This should be a relative path starting from anywhere in the
- * classpath. For example, 'images/foo.gif'.
- *
- * @return A BufferedImage object that contains the loaded image.
- *
- * @throws IOException
- */
- public static BufferedImage loadImage(String path) throws IOException {
- ClassLoader ldr = ImageUtil.class.getClassLoader();
-
- InputStream i = ldr.getResourceAsStream(path);
- BufferedImage result = ImageIO.read(i);
- i.close();
-
- return result;
- }
-
- /**
- * Get's all of the unique colors in an image.
- *
- * @param image The image.
- */
- public static byte[][] scrapeColors(BufferedImage image) {
- int i;
- Raster raster = image.getRaster();
- byte[][] clrs = new byte[raster.getNumBands()][256];
- int[][] pixels = new int[raster.getNumBands()][];
- int nextClr = 0;
-
- for (int band = 0; band < raster.getNumBands(); band++) {
- pixels[band] = raster.getSamples(0, 0, raster.getWidth(), raster.getHeight(), band, (int[]) null);
- }
-
- for (int pixel = 0; pixel < pixels[0].length; pixel++) {
- byte red = 0;
- byte green = 0;
- byte blue = 0;
-
- // Add the clr if it doesn't already exist in the index
- for (i = 0; i < clrs[0].length; i++) {
- red = (byte) pixels[0][pixel];
- green = (byte) pixels[1][pixel];
- blue = (byte) pixels[2][pixel];
-
- if ((red == clrs[0][i]) && (green == clrs[1][i]) && (blue == clrs[2][i])) {
- break;
- }
- }
-
- if ((i == clrs[0].length) && (nextClr < 256)) {
- clrs[0][nextClr] = red;
- clrs[1][nextClr] = green;
- clrs[2][nextClr++] = blue;
-
- // System.out.println("{"+Integer.toHexString(red & 0x000000FF)+','+
- // Integer.toHexString(green & 0x0000FF00 >> 8)+','+
- // Integer.toHexString(blue & 0x00FF0000 >> 16)+'}');
- }
- }
-
- // System.out.println("Colors: " + nextClr);
-
- return clrs;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/Line.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/Line.java
deleted file mode 100644
index ed9cf94..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/Line.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image;
-
-public class Line {
- public int x1;
- public int y1;
- public int x2;
- public int y2;
-
- private int LineWidth;
-
- public Line() {
- }
-
- public Line(int x1, int y1, int x2, int y2) {
- this.x1 = x1;
- this.y1 = y1;
- this.x2 = x2;
- this.y2 = y2;
- }
-
- public Line(int x1, int y1, int x2, int y2, int width) {
- this(x1, y1, x2, y2);
- this.LineWidth = width;
- }
-
- public String toString() {
- StringBuffer res = new StringBuffer();
-
- res.append(this.getClass().getName()).append('[').append("x1=").append(x1).append(',').append("y1=").append(y1)
- .append(',').append("x2=").append(x2).append(',').append("y2=").append(y2).append(',').append("lineWidth=")
- .append(this.LineWidth).append(']');
-
- return res.toString();
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/WebImage.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/WebImage.java
deleted file mode 100644
index e88ddb2..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/WebImage.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics2D;
-import java.awt.GraphicsEnvironment;
-import java.awt.Image;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.RenderingHints;
-import java.awt.Stroke;
-import java.awt.image.BufferedImage;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import javax.imageio.ImageIO;
-
-public class WebImage {
- /////////////////////////////////////////////////////
- // Class static variables
-
- protected static final String ARG_CANNOT_BE_NULL = "Argument cannot be null";
-
- private static final String IMAGE_JPEG = "jpeg";
- private static final String IMAGE_PNG = "png";
-
- protected static final int DEFAULT_HEIGHT = 300;
- protected static final int DEFAULT_WIDTH = 755;
- protected static final Color DEFAULT_BACKGROUND_COLOR = Color.WHITE;
- protected static final int DEFAULT_BORDER_SIZE = 5;
- protected static final Color DEFAULT_BORDER_COLOR = Color.LIGHT_GRAY;
- protected static final Color DEFAULT_TEXT_COLOR = Color.BLACK;
- protected static final int DEFAULT_SHADOW_WIDTH = 3;
- protected static final String DEFAULT_BOLD_TYPEFACE = "sansserif.bold";
- protected static final String DEFAULT_PLAIN_TYPEFACE = "sansserif.plain";
-
- protected static final Font DEFAULT_FONT = new Font(DEFAULT_PLAIN_TYPEFACE, Font.PLAIN, 11);
- protected static final FontMetrics DEFAULT_FONT_METRICS;
-
- public static final Font SMALL_FONT = new Font(DEFAULT_PLAIN_TYPEFACE, Font.PLAIN, 8);
-
- /////////////////////////////////////////////////////
- // Object variables
-
- private FontMetrics m_fontMetrics; // Set when font is set
- protected Graphics2D m_graphics;
-
- /////////////////////////////////////////////////////
- // Public Properties
-
- /**
- * Text font.
- */
- public Font font = DEFAULT_FONT;
-
- /**
- * Height of the image.
- */
- public int height = DEFAULT_HEIGHT;
-
- /**
- * Width of the image.
- */
- public int width = DEFAULT_WIDTH;
-
- /**
- * Width of the image border on the left side of the image
- */
- public int leftBorder = DEFAULT_BORDER_SIZE;
-
- /**
- * Height of the image border on the top side of the image
- */
- public int topBorder = DEFAULT_BORDER_SIZE;
-
- /**
- * Width of the image border on the right side of the image
- */
- public int rightBorder = DEFAULT_BORDER_SIZE;
-
- /**
- * Height of the image border on the bottom side of the image
- */
- public int bottomBorder = DEFAULT_BORDER_SIZE;
-
- /**
- * Draws a two pixel light gray frame at the edge of the image
- */
- public boolean frameImage = false;
-
- /**
- * Background color for the image.
- */
- public Color backgroundColor = DEFAULT_BACKGROUND_COLOR;
-
- /**
- * Color for text in the image.
- */
- public Color textColor = DEFAULT_TEXT_COLOR;
-
- /**
- * Width of the shadow around the image.
- */
- public int shadowWidth = DEFAULT_SHADOW_WIDTH;
-
- /////////////////////////////////////////////////////
- // Protected Properties
-
- /**
- * Use an IndexColorModel.
- */
- protected boolean antiAliased = true;
-
- /**
- * Anti-alias shapes and text.
- */
- protected boolean indexColors = false;
-
- /////////////////////////////////////////////////////
- // Static constructor
-
- static {
- // Get Font Metrics
- Image img = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_BINARY);
- java.awt.Graphics g = img.getGraphics();
- DEFAULT_FONT_METRICS = g.getFontMetrics(DEFAULT_FONT);
- g.dispose();
- }
-
- /////////////////////////////////////////////////////
- // Constructors
-
- protected WebImage(int width, int height) {
- this.width = width;
- this.height = height;
-
- m_fontMetrics = DEFAULT_FONT_METRICS;
- }
-
- /////////////////////////////////////////////////////
- // Protected Methods
-
- protected void draw(Graphics2D g) {
- g.fillRect(0, 0, this.width + this.shadowWidth, this.height + this.shadowWidth);
-
- if (this.frameImage == true) {
- // Draw the frame
- Stroke orig = g.getStroke();
- g.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
- g.setColor(DEFAULT_BORDER_COLOR);
- g.drawRect(0, 0, this.width - 1, this.height - 1);
-
- // Draw the shadow
- if (this.shadowWidth > 0) {
- int[] x = { this.width + 1, this.width + 1, this.shadowWidth };
- int[] y = { this.shadowWidth, this.height + 1, this.height + 1 };
- g.setColor(Color.BLACK);
- g.drawPolyline(x, y, x.length);
- }
-
- // Put back the color and stroke we started with
- g.setColor(Color.WHITE);
- g.setStroke(orig);
- }
- }
-
- protected void preInit() {
- }
-
- protected void postInit(Graphics2D graphics) {
- this.initFontMetrics();
- }
-
- /////////////////////////////////////////////////////
- // Public Methods
-
- /**
- * Sets the size of the top, left, right and bottom borders.
- *
- * @param border The size to set the borders to.
- *
- * @see #LeftBorder
- */
- public void setBorder(int border) {
- this.topBorder = border;
- this.leftBorder = border;
- this.rightBorder = border;
- this.bottomBorder = border;
- }
-
- /**
- * Retrieves the font metrics.
- *
- * @return A java.awt.Font object that contains the label font.
- *
- * @see java.awt.Font
- */
- public FontMetrics getFontMetrics() {
- return m_fontMetrics;
- }
-
- /**
- * Retrieves the image as a java.awt.Image object. The image is redrawn with the latest data and properties each
- * time this method is called.
- *
- * @return A java.awt.Image that contains the drawn chart image.
- *
- * @see java.awt.Image
- */
- public Image getImage() {
- BufferedImage image;
- Graphics2D g;
-
- this.preInit();
-
- image = new BufferedImage(this.width + this.shadowWidth, this.height + this.shadowWidth,
- BufferedImage.TYPE_INT_RGB);
-
- g = m_graphics = (Graphics2D) image.getGraphics();
-
- if (this.antiAliased == true) {
- g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
- }
-
- this.postInit(g);
-
- g.setColor(this.backgroundColor);
- this.draw(g);
- g.dispose();
-
- if (this.indexColors == true) {
- image = ImageUtil.convertToIndexColorImage(image);
- }
-
- return image;
- }
-
- /**
- * Writes the chart image in a JPEG or PNG format. The chart is redrawn with the latest data and properties each
- * time this method is called.
- *
- * @param filename The path and filename that specifies where the PNG image should be written.
- * @param type The type of image in the format of "image/jpeg" or "image/png".
- *
- * @exception FileNotFoundException If the filename is not a valid name for a file.
- * @exception IOException If there is an IO error while writing to the file.
- * @exception IllegalArgumentException If the filename parameter is null.
- */
- private void writeImage(String filename, String type) throws FileNotFoundException, IOException {
- FileOutputStream out = new FileOutputStream(filename);
- this.writeImage(out, type);
- out.close();
- }
-
- /**
- * Writes the chart image in a JPEG or PNG format. The chart is redrawn with the latest data and properties each
- * time this method is called.
- *
- * @param stream The java.io.OutputStream to write the PNG image to.
- * @param type The type of image in the format of "jpeg" or "png".
- *
- * @exception IOException If there is an IO error while streaming the PNG image.
- * @exception IllegalArgumentException If the stream parameter is null.
- *
- * @see java.io.OutputStream
- */
- private void writeImage(OutputStream stream, String type) throws IOException {
- ImageIO.write((BufferedImage) this.getImage(), type, stream);
- stream.flush();
- }
-
- /**
- * Writes the chart image as a JPEG image. The chart is redrawn with the latest data and properties each time this
- * method is called.
- *
- * @param filename The path and filename that specifies where the PNG image should be written.
- *
- * @exception FileNotFoundException If the filename is not a valid name for a file.
- * @exception IOException If there is an IO error while writing to the file.
- * @exception IllegalArgumentException If the filename parameter is null.
- */
- public void writeJpegImage(String filename) throws FileNotFoundException, IOException {
- if (filename == null) {
- throw new IllegalArgumentException();
- }
-
- this.writeImage(filename, IMAGE_JPEG);
- }
-
- /**
- * Writes the chart image as a JPEG image. The chart is redrawn with the latest data and properties each time this
- * method is called.
- *
- * @param stream The java.io.OutputStream to write the PNG image to.
- *
- * @exception IOException If there is an IO error while streaming the PNG image.
- * @exception IllegalArgumentException If the stream parameter is null.
- *
- * @see java.io.OutputStream
- */
- public void writeJpegImage(OutputStream stream) throws IOException {
- if (stream == null) {
- throw new IllegalArgumentException(ARG_CANNOT_BE_NULL);
- }
-
- this.writeImage(stream, IMAGE_JPEG);
- }
-
- /**
- * Writes the chart image as a PNG image. The chart is redrawn with the latest data and properties each time this
- * method is called.
- *
- * @param filename The path and filename that specifies where the PNG image should be written.
- *
- * @exception FileNotFoundException If the filename is not a valid name for a file.
- * @exception IOException If there is an IO error while writing to the file.
- * @exception IllegalArgumentException If the filename parameter is null.
- */
- public void writePngImage(String filename) throws FileNotFoundException, IOException {
- if (filename == null) {
- throw new IllegalArgumentException(ARG_CANNOT_BE_NULL);
- }
-
- this.writeImage(filename, IMAGE_PNG);
- }
-
- /**
- * Writes the chart image as a PNG image. The chart is redrawn with the latest data and properties each time this
- * method is called.
- *
- * @param stream The java.io.OutputStream to write the PNG image to.
- *
- * @exception IOException If there is an IO error while streaming the PNG image.
- * @exception IllegalArgumentException If the stream parameter is null.
- *
- * @see java.io.OutputStream
- */
- public void writePngImage(OutputStream stream) throws IOException {
- if (stream == null) {
- throw new IllegalArgumentException(ARG_CANNOT_BE_NULL);
- }
-
- this.writeImage(stream, IMAGE_PNG);
- }
-
- ////////////////////////////////////////////////////
- // Private Methods
-
- private void initFontMetrics() {
- if (m_graphics != null) {
- this.m_fontMetrics = m_graphics.getFontMetrics(this.font);
- }
- }
-
- ////////////////////////////////////////////////////
- // Protected Helper Methods
-
- protected java.awt.Point getTextCenter(String text) {
- return this.getTextCenter(text, new Rectangle(0, 0, this.width, this.height));
- }
-
- protected Point getTextCenter(String text, Rectangle rect) {
- return WebImage.getTextCenter(text, rect, m_fontMetrics);
- }
-
- ////////////////////////////////////////////////////
- // Static Methods
-
- protected static Point getTextCenter(String text, Rectangle rect, FontMetrics metrics) {
- return new Point((rect.width / 2) - (metrics.stringWidth(text) / 2), (rect.height / 2)
- + (metrics.getAscent() / 2));
- }
-
- /**
- * Determine if a graphics environment is available. The graphics environment would be X on Unix. GDI on Windows,
- * Mac, etc. This is primarily used as a check for X because it is very difficult to run without a graphics
- * environment on the Windows and Mac operating systems.
- *
- * @return A boolean that is true if a graphics environment is available, false otherwise.
- */
- public static boolean isRunnable() {
- boolean res;
-
- try {
- GraphicsEnvironment.getLocalGraphicsEnvironment();
- res = true;
- } catch (InternalError e) {
- res = false;
- } catch (NoClassDefFoundError e) {
- res = false;
- }
-
- return res;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/AreaChart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/AreaChart.java
deleted file mode 100644
index e072cec..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/AreaChart.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.util.Iterator;
-
-import org.rhq.enterprise.gui.image.data.IDataPoint;
-
-/**
- * HighLowChart draws a horizontal chart with shaded areas to display the data point values. For a description of how to
- * use AreaChart, see net.hyperic.chart.Chart.
- *
- * @see net.hyperic.chart.Chart
- */
-public class AreaChart extends ColumnChart {
- public AreaChart() {
- super();
- }
-
- public AreaChart(int width, int height) {
- super(width, height);
- }
-
- @Override
- protected void init() {
- super.init();
- this.valueIndent = 0;
- }
-
- @Override
- protected void paint(ChartGraphics g, Rectangle rect) {
- g.graphics.setColor(this.columnColor);
-
- DataPointCollection coll = this.getDataPoints();
- Iterator<IDataPoint> iter = coll.iterator();
-
- Rectangle rectBar = new Rectangle();
- rectBar.width = rect.width / coll.size();
-
- for (int index = 0; iter.hasNext() == true; index++) {
- IDataPoint datapt = iter.next();
-
- if (Double.isNaN(datapt.getValue()) == true) {
- continue;
- }
-
- Point ptData = this.getDataPoint(rect, index, coll);
- if (ptData == null) {
- continue;
- }
-
- rectBar.x = ptData.x;
- rectBar.y = ptData.y;
- rectBar.height = (rect.y + rect.height) - rectBar.y;
-
- // Draw Bar
- g.graphics.fillRect(rectBar.x, rectBar.y, rectBar.width, rectBar.height);
- }
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/AvailabilityChart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/AvailabilityChart.java
deleted file mode 100644
index 94845ee..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/AvailabilityChart.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.awt.Color;
-import java.awt.Point;
-import java.awt.Rectangle;
-
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.enterprise.gui.image.data.IDataPoint;
-
-/**
- * AvailabilityChart is a stacked line chart where the stack is always made up of two segments that add up to 100. For a
- * description of how to use AvailabilityChart, see net.hyperic.chart.Chart.
- *
- * @see net.hyperic.chart.Chart
- */
-public class AvailabilityChart extends HealthChart {
- private static final String DEF_UNIT = "%";
-
- private static final Color DEF_AVAIL_COLOR = GOOD_COLOR;
- private static final Color DEF_NOT_AVAIL_COLOR = DANGER_COLOR;
-
- public AvailabilityChart(int width, int height) {
- super(width, height);
- }
-
- @Override
- protected void init() {
- super.init();
-
- this.showAverage = false;
- this.showFullLabels = true;
- this.showRightLabels = false;
- this.showLeftLegend = false;
- this.showBottomLegend = false;
- this.showLow = false;
- this.showPeak = false;
- this.showValueLines = true;
-
- this.floor = 0;
- this.ceiling = 1;
- this.valueLines = 5;
-
- this.setFormat(MeasurementUnits.PERCENTAGE);
- }
-
- @Override
- protected void paint(ChartGraphics g, Rectangle rect) {
- /////////////////////////////////////////////////////////
- // Draw the Column Bars
-
- // Calculate Bar Width
-
- Rectangle rectBar = new Rectangle();
- int cDataPoints = this.getDataPoints().size();
-
- for (int i = 0; i < cDataPoints; i++) {
- Point ptData = this.getDataPoint(rect, i);
- if (ptData == null) {
- continue;
- }
-
- double dVal = ((IDataPoint) this.getDataPoints().get(i)).getValue();
-
- rectBar.x = ptData.x - (this.columnWidth / 2);
- rectBar.width = this.columnWidth;
- rectBar.y = ptData.y;
- rectBar.height = (rect.y + rect.height) - rectBar.y;
-
- // Draw the top bar in the stack
- if (dVal < 100) {
- g.graphics.setColor(DEF_NOT_AVAIL_COLOR);
- g.graphics.fillRect(rectBar.x, rect.y + this.lineWidth, rectBar.width, rectBar.y - rect.y);
- }
-
- // Draw the bottom bar in the stack
- if (dVal > 0) {
- g.graphics.setColor(DEF_AVAIL_COLOR);
- g.graphics.fillRect(rectBar.x, rectBar.y, rectBar.width, rectBar.height);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/AvailabilityReportChart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/AvailabilityReportChart.java
deleted file mode 100644
index ef5f116..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/AvailabilityReportChart.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics2D;
-import java.awt.Image;
-import java.awt.Rectangle;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.NumberFormat;
-import javax.imageio.ImageIO;
-import org.rhq.enterprise.gui.image.data.IDataPoint;
-
-public class AvailabilityReportChart extends Chart {
- private static int CIRCLE_SIZE = 11;
-
- private static BufferedImage GOOD_CIRCLE;
- private static BufferedImage DANGER_CIRCLE;
- private static BufferedImage UNKNOWN_CIRCLE;
-
- private static final int TEXT_HEIGHT = 11;
- private static final Font TEXT_FONT = new Font("Helvetica", Font.PLAIN, TEXT_HEIGHT);
- private static final FontMetrics TEXT_METRICS;
-
- private static final Color COLOR_TRANSPARENT = new Color(0, 0, 255); //,0);
-
- private static final String LARGEST_NUMBER = "999";
-
- private static final int TEXT_BUFFER = 2;
- private static final int SET_BUFFER = 5;
-
- private static final int CIRCLE_WITH_BUFFER_WIDTH;
- private static final int STANDARD_SET_WIDTH;
- private static final int IMAGE_WIDTH;
-
- static {
- // Get Font Metrics
- Image img = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_BINARY);
- java.awt.Graphics g = img.getGraphics();
- TEXT_METRICS = g.getFontMetrics(TEXT_FONT);
- g.dispose();
-
- // Load Images
- InputStream i;
-
- try {
- ClassLoader ldr = AvailabilityReportChart.class.getClassLoader();
-
- i = ldr.getResourceAsStream("images/icon_available_green.gif");
- GOOD_CIRCLE = ImageIO.read(i);
- i.close();
-
- i = ldr.getResourceAsStream("images/icon_available_red.gif");
- DANGER_CIRCLE = ImageIO.read(i);
- i.close();
-
- i = ldr.getResourceAsStream("images/icon_available_error.gif");
- UNKNOWN_CIRCLE = ImageIO.read(i);
- i.close();
- } catch (IOException e) {
- System.out.println(e);
- }
-
- CIRCLE_WITH_BUFFER_WIDTH = GOOD_CIRCLE.getWidth() + TEXT_BUFFER;
- STANDARD_SET_WIDTH = CIRCLE_WITH_BUFFER_WIDTH + TEXT_METRICS.stringWidth(LARGEST_NUMBER) + SET_BUFFER;
- IMAGE_WIDTH = (STANDARD_SET_WIDTH * 3) - SET_BUFFER;
- }
-
- public AvailabilityReportChart() {
- super(IMAGE_WIDTH, GOOD_CIRCLE.getHeight());
-
- this.setBorder(0);
-
- //this.useIndexColors = true;
- this.indexColors = true;
- }
-
- protected void init() {
- this.showLeftLabels = false;
- this.showBottomLabels = false;
- this.showLeftLegend = false;
- this.showTopLegend = false;
- }
-
- protected Rectangle draw(ChartGraphics g) {
- g.graphics.setFont(TEXT_FONT);
-
- int x = 0;
- int yCircle = 0;
- int y2Circle = CIRCLE_SIZE - 1;
-
- g.graphics.setPaint(COLOR_TRANSPARENT);
- g.graphics.fillRect(0, 0, this.width, this.height);
-
- DataPointCollection datapts = this.getDataPoints();
- NumberFormat fmt = NumberFormat.getInstance();
- fmt.setMaximumFractionDigits(0);
-
- g.graphics.setColor(this.textColor);
-
- double val;
- String text;
-
- if (datapts.size() >= 1) {
- val = ((IDataPoint) datapts.get(0)).getValue();
-
- if (val > 0) {
- text = fmt.format(val);
- g.graphics.drawImage(GOOD_CIRCLE, 0, yCircle, COLOR_TRANSPARENT, null);
- g.graphics.drawString(text, CIRCLE_WITH_BUFFER_WIDTH, y2Circle);
- }
- }
-
- if (datapts.size() >= 2) {
- val = ((IDataPoint) datapts.get(1)).getValue();
-
- if (val > 0) {
- text = fmt.format(val);
- g.graphics.drawImage(DANGER_CIRCLE, STANDARD_SET_WIDTH, yCircle, COLOR_TRANSPARENT, null);
- g.graphics.drawString(text, STANDARD_SET_WIDTH + CIRCLE_WITH_BUFFER_WIDTH, y2Circle);
- }
- }
-
- if (datapts.size() >= 3) {
- val = ((IDataPoint) datapts.get(2)).getValue();
-
- if (val > 0) {
- text = fmt.format(val);
- g.graphics.drawImage(UNKNOWN_CIRCLE, STANDARD_SET_WIDTH * 2, yCircle, COLOR_TRANSPARENT, null);
- g.graphics.drawString(text, (STANDARD_SET_WIDTH * 2) + CIRCLE_WITH_BUFFER_WIDTH, y2Circle);
- }
- }
-
- return new Rectangle(0, 0, this.height, this.width);
- }
-
- // protected IndexColorModel getIndexColorModel() {
- // IndexColorModel cm = super.getIndexColorModel();
- //
- // int size = cm.getMapSize();
- // byte r[] = new byte[size];
- // byte g[] = new byte[size];
- // byte b[] = new byte[size];
- //
- // cm.getReds(r);
- // cm.getGreens(g);
- // cm.getBlues(b);
- //
- // // Make room by moving the first color to the end of the list
- // r[size-1] = r[0];
- // g[size-1] = g[0];
- // b[size-1] = b[0];
- //
- // // Set our transparent color as the first in the index
- // r[0] = (byte)COLOR_TRANSPARENT.getRed();
- // g[0] = (byte)COLOR_TRANSPARENT.getGreen();
- // b[0] = (byte)COLOR_TRANSPARENT.getBlue();
- //
- // return new IndexColorModel(8, size, r, g, b, 0);
- // }
-
- protected int getYLabelWidth(Graphics2D g) {
- return 0;
- }
-
- protected Rectangle getInteriorRectangle(ChartGraphics g) {
- return new Rectangle(0, 0, this.width, this.height);
- }
-
- protected String[] getXLabels() {
- return null;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/Chart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/Chart.java
deleted file mode 100644
index 5706f4e..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/Chart.java
+++ /dev/null
@@ -1,1040 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics2D;
-import java.awt.Image;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.image.BufferedImage;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.enterprise.gui.image.WebImage;
-import org.rhq.enterprise.gui.image.data.IDataPoint;
-import org.rhq.enterprise.gui.image.data.IDisplayDataPoint;
-import org.rhq.enterprise.gui.image.data.IHighLowDataPoint;
-import org.rhq.enterprise.gui.image.data.IStackedDataPoint;
-
-/**
- * Chart is an abstract base class for the Covalent charting library. Chart uses Java AWT drawing to draw charts
- * dynamically into a Java Image which can be then be used to display the chart in an application. The most common use
- * of the charting library is to draw the chart image and then convert the image to a GIF to send to a Web Browser.
- * Chart is responsible for all of the background drawing of the Chart the Chart frame, text labels, data point crossing
- * lines, etc. Sublcasses of Chart draw on top of the image produce by the Chart class to draw the actual lines,
- * columns, etc. that represent the data points of the chart. To create a chart you instantiate a subclass of Chart
- * (e.g., LineChart, ColumnChart, etc.), call getData() to retrieve a collection, populate the collection and then call
- * Chart.getImage() to get a java.awt.Image object that represents the drawn chart. The chart class is very configurable
- * through get/set methods including configuring things like the text for labels, fonts, line colors, etc. After
- * changing one or more options you call Chart.getImage() again to get a new image based on your options. The chart
- * should have at least three datums in its Datum collection to display without errors.
- *
- * @see java.awt.Image
- */
-public abstract class Chart extends WebImage {
-
- private Log log = LogFactory.getLog(Chart.class.getName());
-
- ////////////////////////////////////////////////
- // Static Variables
-
- public static final String EMPTY_STRING = "";
-
- protected static final String ARG_MUST_BE_ZERO_OR_GREATER = "Argument value must be zero or greater";
-
- protected static final String AVG = "Average";
- protected static final String BASELINE = "Baseline";
- protected static final String LOW = "Low";
- protected static final String PEAK = "Peak";
-
- protected static final String DEFAULT_UNIT_LEGEND = "TIME";
- protected static final String DEFAULT_VALUE_LEGEND = "VALUE";
- private static final String NO_DATA = "No Metric Data Available";
-
- private static final int DEFAULT_LINE_WIDTH = 1;
- private static final int DEFAULT_VALUE_INDENT = 0;
- private static final int DEFAULT_VALUE_LINES = 11;
- private static final int DEFAULT_TEXT_WHITESPACE = 3;
- private static final int DEFAULT_TICK_MARK_HEIGHT = 6;
-
- protected static final int VARIABLE_HEIGHT = Integer.MIN_VALUE;
- protected static final int VARIABLE_WIDTH = Integer.MIN_VALUE;
-
- private static final Color DEFAULT_FRAME_COLOR = new Color(0xE6, 0xE5, 0xE5); //new Color(0xCC, 0xCC, 0xCC);
- private static final Color DEFAULT_LEGEND_TEXT_COLOR = Color.BLACK;
- private static final Color DEFAULT_X_LINE_COLOR = new Color(0xE6, 0xE5, 0xE5);
- private static final Color DEFAULT_TEXT_COLOR = new Color(0x80, 0x80, 0x80);
-
- private static final Color DEFAULT_AVERAGE_COLOR = new Color(0x8C, 0xBF, 0x73);
- private static final Color DEFAULT_BASELINE_COLOR = new Color(0xBF, 0xB2, 0x73);
- private static final Color DEFAULT_LOW_COLOR = new Color(0x73, 0xBF, 0xB3);
- private static final Color DEFAULT_PEAK_COLOR = new Color(0xD9, 0x98, 0x98);
-
- private static final Color DEFAULT_HIGH_RANGE_COLOR = new Color(0xF7, 0xEB, 0xEB);
- private static final Color DEFAULT_LOW_RANGE_COLOR = new Color(0xEB, 0xF7, 0xF6);
-
- protected static final Font DEFAULT_LABEL_FONT = new Font("Helvetica", Font.PLAIN, 10);
- protected static final Font DEFAULT_LEGEND_PLAIN = new Font("Helvetica", Font.PLAIN, 11);
- protected static final Font DEFAULT_LEGEND_FONT = new Font("Helvetica", Font.BOLD, 11);
-
- protected FontMetrics m_metricsLabel;
- protected FontMetrics m_metricsLegend;
-
- ////////////////////////////////////////////////
- // Instance Variables
-
- private String m_strUnitLegend = DEFAULT_UNIT_LEGEND;
- private String m_strValueLegend = DEFAULT_VALUE_LEGEND;
-
- private Color m_clrFrame = DEFAULT_FRAME_COLOR;
- private Color m_clrLegendText = DEFAULT_LEGEND_TEXT_COLOR;
-
- protected MeasurementUnits m_fmtUnits;
-
- protected double m_dAvgValue = 0;
- protected double m_dLowValue = Double.POSITIVE_INFINITY;
- protected double m_dPeakValue = Double.NEGATIVE_INFINITY;
-
- protected double[] m_adRangeMarks;
- protected double m_floor;
- protected boolean m_bNoData;
-
- private String m_strTitle = EMPTY_STRING;
-
- private ArrayList<DataPointCollection> m_collDataPointColl = new ArrayList<DataPointCollection>(1);
-
- private String m_strNoData = NO_DATA;
-
- public int yTopLegend;
- public int yBottomLegend;
- public int xVertLegend;
- public int yHorzLabels;
- public int x2VertLabels;
- public int xRLabel;
- public int xVertMarks;
- public int x2VertMarks;
- public int xLabelsSkip = 4; // Default to label every 4 ticks
-
- ////////////////////////////////////////////////
- // Property Variables
-
- /**
- * Color of the average data point horizontal line.
- */
- public Color averageLineColor = DEFAULT_AVERAGE_COLOR;
-
- /**
- * Color of the baseline horizontal line.
- */
- public Color baselineColor = DEFAULT_BASELINE_COLOR;
-
- /**
- * Top number for the left axis of the chart.
- */
- public double ceiling = 0;
-
- /**
- * Retrieves the chart's interior background color.
- */
- public Color chartColor = Color.WHITE;
-
- /**
- * Bottom number for the left axis of the chart.
- */
- public double floor = 0;
-
- /**
- * Baseline in the chart.
- */
- public double baseline = 0;
-
- /**
- * High range in the chart.
- */
- public double highRange = Double.NaN;
-
- /**
- * High range color in the chart.
- */
- public Color highRangeColor = DEFAULT_HIGH_RANGE_COLOR;
-
- /**
- * Font that is used to draw the legend for the chart's X and Y axis.
- */
- public Font legendFont = DEFAULT_LEGEND_FONT;
-
- /**
- * Color that is used to draw the legend text for the chart's X and Y axis.
- */
- public Color legendTextColor = DEFAULT_LEGEND_TEXT_COLOR;
-
- /**
- * Width of lines in the chart.
- */
- public int lineWidth = DEFAULT_LINE_WIDTH;
-
- /**
- * Retrieves the color of the low data point horizontal line.
- */
- public Color lowLineColor = DEFAULT_LOW_COLOR;
-
- /**
- * Low range in the chart.
- */
- public double lowRange = Double.NaN;
-
- /**
- * High range color in the chart.
- */
- public Color lowRangeColor = DEFAULT_LOW_RANGE_COLOR;
-
- /**
- * Color of the peak data point horizontal line.
- */
- public Color peakLineColor = DEFAULT_PEAK_COLOR;
-
- /**
- * Sets a fixed size for the label width on the right vertical axis.
- */
- public int rightLabelWidth = -1;
-
- /**
- * Calculates and shows an Average line in the chart.
- */
- public boolean showAverage = false;
-
- /**
- * Shows a Baseline in the chart.
- */
- public boolean showBaseline = false;
-
- /**
- * Shows labels on the X axis bottom side.
- */
- public boolean showBottomLabels = true;
-
- /**
- * Shows a top legend.
- */
- public boolean showBottomLegend = true;
-
- /**
- * Show full labels on the bottom x axis.
- */
- public boolean showFullLabels = false;
-
- /**
- * Shows a shaded high range in the chart.
- */
- public boolean showHighRange = false;
-
- /**
- * Shows labels on the Y axis left side.
- */
- public boolean showLeftLabels = true;
-
- /**
- * Shows a Left legend.
- */
- public boolean showLeftLegend = true;
-
- /**
- * Calculates and shows a Low line in the chart.
- */
- public boolean showLow = false;
-
- /**
- * Shows a shaded low range in the chart.
- */
- public boolean showLowRange = false;
-
- /**
- * Calculates and shows a peak line in the chart.
- */
- public boolean showPeak = false;
-
- /**
- * Shows labels on the Y axis right side.
- */
- public boolean showRightLabels = true;
-
- /**
- * Shows a Right legend.
- */
- public boolean showRightLegend = false;
-
- /**
- * Shows labels on the X axis top side.
- */
- public boolean showTopLabels = false;
-
- /**
- * Shows a top legend.
- */
- public boolean showTopLegend = false;
-
- /**
- * Shows vertical crossing lines at each data point on the y axis.
- */
- public boolean showUnitLines = false;
-
- /**
- * Shows horizontal crossing lines at each data point on the x axis.
- */
- public boolean showValueLines = false;
-
- /**
- * Shows values.
- */
- public boolean showValues = true;
-
- /**
- * The width of the white space between tick marks and the label text.
- */
- public int textWhitespace = DEFAULT_TEXT_WHITESPACE;
-
- /**
- * The height, in pixels, of the tick mark lines that extend outside the chart's border. The tick marks for data
- * points that don't have a label are drawn at half this height.
- */
- public int tickMarkHeight = DEFAULT_TICK_MARK_HEIGHT;
-
- /**
- * Number of pixels to indent the value axis.
- */
- public int valueIndent = DEFAULT_VALUE_INDENT;
-
- /**
- * Number of value lines that the chart draws at data points along the chart's value axis. For vertical chart's this
- * is the Y axis. For horizontal charts this is the chart's X axis. This number includes the chart's top and bottom
- * border.
- */
- public int valueLines = DEFAULT_VALUE_LINES;
-
- /**
- * Color of the border lines, horizontal lines and tick marks
- */
- public Color xLineColor = DEFAULT_X_LINE_COLOR;
-
- /**
- * Amount to offset the chart on the X axis in pixels.
- */
- public int xOffset = 0;
-
- /**
- * Amount to offset the chart on the Y axis in pixels.
- */
- public int yOffset = 0;
-
- ////////////////////////////////////////////////
- // Constructors
-
- /**
- * Constructs a Chart class with a default width of 755 pixels and a default height of 300 pixels.
- */
- protected Chart() {
- this(1);
- }
-
- /**
- * Constructs a Chart class with a default width of 755 pixels and a default height of 300 pixels.
- *
- * @param charts The number of charts to display.
- */
- protected Chart(int charts) {
- this(WebImage.DEFAULT_WIDTH, WebImage.DEFAULT_HEIGHT, charts);
- }
-
- /**
- * Constructs a Chart class with a specified width and height.
- *
- * @param width The width of the chart in pixels.
- * @param height The height of the chart in pixels.
- */
- protected Chart(int width, int height) {
- this(width, height, 1);
- }
-
- /**
- * Constructs a Chart class with a specified width and height.
- *
- * @param width The width of the chart in pixels.
- * @param height The height of the chart in pixels.
- * @param charts The number of charts to display.
- */
- protected Chart(int width, int height, int charts) {
- super(width, height);
- this.shadowWidth = 0;
- this.textColor = DEFAULT_TEXT_COLOR;
-
- if (charts <= 0) {
- charts = 1;
- }
-
- this.setNumberDataSets(charts);
-
- this.initFonts();
- }
-
- ////////////////////////////////////////////////
- // Methods
-
- @Override
- protected void draw(Graphics2D g) {
- super.draw(g);
- this.draw(new ChartGraphics(this, g));
- }
-
- protected Rectangle draw(ChartGraphics g) {
- /////////////////////////////////////////////////////////////
- // Draw the chart outline and fills the interior
-
- // Fill chart background
- Rectangle rect = this.getInteriorRectangle(g);
-
- if (this.m_bNoData == false) {
- // Fill chart interior
- g.graphics.setColor(this.m_clrFrame);
- g.graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
-
- g.graphics.setColor(this.chartColor);
- g.graphics.fillRect(rect.x + this.lineWidth, rect.y + this.lineWidth, rect.width - (this.lineWidth),
- rect.height - (this.lineWidth));
- } else {
- FontMetrics metrics = g.graphics.getFontMetrics(this.legendFont);
-
- g.graphics.setColor(this.m_clrLegendText);
- g.graphics.setFont(DEFAULT_LEGEND_PLAIN);
- g.graphics.drawString(this.m_strNoData, (this.width / 2) - (metrics.stringWidth(this.m_strNoData) / 2),
- this.yOffset + (this.height / 2) + (metrics.getAscent() / 2));
- }
-
- return rect;
- }
-
- protected void calc(Graphics2D g) {
- //FormattedNumber[] fmtValueLabels = UnitsFormat.formatSame(m_adRangeMarks, m_fmtType, m_fmtScale);
-
- Rectangle rect = new Rectangle(this.xOffset, this.yOffset, this.width, this.height);
-
- // Calculate the X axis
- rect.x += this.leftBorder;
-
- if ((this.showHighRange == true) || (this.showLowRange == true)) {
- rect.x += this.lineWidth;
- }
-
- int xVertLabels = (this.showLeftLegend == true) ? (rect.x + m_metricsLegend.charWidth('V') + (this.textWhitespace * 2))
- : 0;
- int cxLabels = (this.rightLabelWidth < 0) ? this.getYLabelWidth(g) : this.rightLabelWidth;
-
- if (this.showLeftLabels == true) {
- x2VertLabels = xVertLabels + cxLabels;
- xVertMarks = x2VertLabels + this.textWhitespace;
- rect.x = xVertMarks + this.tickMarkHeight;
- }
-
- rect.width = rect.width - rect.x - this.rightBorder;
-
- if (this.showRightLabels == true) {
- rect.width -= this.tickMarkHeight;
- rect.width = rect.width - cxLabels;
- } else {
- // We need to bring the right frame in a little if there's no right
- // label, but there are top or bottom labels.
- String[] labels = this.getXLabels();
- if ((labels != null) && (labels.length > 1)) {
- rect.width -= (this.m_metricsLabel.stringWidth(labels[labels.length - 1]) / 2);
- }
- }
-
- // Adjust the interior of the rectangle
- this.adjustRectangle(g, rect);
-
- x2VertMarks = rect.x + rect.width + (this.lineWidth * 2);
- if (this.showRightLabels == true) {
- x2VertMarks += this.tickMarkHeight;
- }
-
- xRLabel = x2VertMarks + this.textWhitespace;
-
- // Calculate the Y axis
- rect.y = rect.y + this.topBorder;
-
- if (this.showTopLegend == true) {
- rect.y += m_metricsLegend.getAscent();
- yTopLegend = rect.y;
- rect.y += this.textWhitespace;
- }
-
- if (this.showTopLabels == true) {
- rect.y += (this.getXLabelHeight() + this.tickMarkHeight);
- }
-
- if ((this.showTopLegend == false) && (this.showTopLabels == false)) {
- rect.y += (m_metricsLabel.getAscent() / 2);
- }
-
- yBottomLegend = this.yOffset + (rect.height - this.bottomBorder);
-
- int yHorzMarks;
- if ((this.showBottomLegend == false) && (this.showBottomLabels == false)) {
- yHorzLabels = yBottomLegend - (m_metricsLabel.getAscent() / 2);
- yHorzMarks = yHorzLabels;
- } else {
- yHorzLabels = yBottomLegend - ((this.showBottomLegend == true) ? this.getXLabelHeight() : 0);
- yHorzMarks = yHorzLabels
- - ((this.showBottomLabels == true) ? (this.m_metricsLabel.getAscent() + this.tickMarkHeight) : 0);
- }
-
- int y2Rect = yHorzMarks - this.lineWidth;
- rect.height = y2Rect - rect.y;
-
- }
-
- /**
- * Give the child class an opportunity to change the size of the interior rectangle. This is done to make the tick
- * marks fit symetrically in the chart rectangle.
- */
- protected Rectangle adjustRectangle(Graphics2D g, Rectangle rect) {
- return rect;
- }
-
- /**
- * Calculates the high, low and average values of the chart data set.
- */
- protected void calcRanges() {
- int cActualVals = 0;
- double unit;
- double topRange;
-
- // Calculate Top and Bottom Range
- double dVal;
-
- // ///////////////////////////////////////////////////////////////
- // Iterator through the DataSets to calculate the avg, low & peak
- Iterator<DataPointCollection> iterDataSet = this.m_collDataPointColl.iterator();
- while (iterDataSet.hasNext() == true) {
- // Each DataSet has a collection of data points.
- Iterator<IDataPoint> iterDataPt = (iterDataSet.next()).iterator();
-
- while (iterDataPt.hasNext() == true) {
- IDisplayDataPoint datapt = (IDisplayDataPoint) iterDataPt.next();
-
- // Skip NaN
- if (Double.isNaN(datapt.getValue()) == true) {
- continue;
- }
-
- if (checkHighLow()) {
- if (datapt instanceof IHighLowDataPoint) {
- IHighLowDataPoint hlPt = (IHighLowDataPoint) datapt;
- if (!Double.isNaN(hlPt.getLowValue())) {
- this.m_dLowValue = Math.min(this.m_dLowValue, hlPt.getLowValue());
- }
-
- if (!Double.isNaN(hlPt.getHighValue())) {
- this.m_dPeakValue = Math.max(this.m_dPeakValue, hlPt.getHighValue());
- }
- }
- }
-
- double[] vals = (datapt instanceof IStackedDataPoint) ? ((IStackedDataPoint) datapt).getValues()
- : new double[] { datapt.getValue() };
-
- for (int i = 0; i < vals.length; i++) {
- dVal = vals[i];
-
- // Accumulate a total and number of points that make up the
- // total
- this.m_dAvgValue += dVal;
- cActualVals++;
-
- // Set the low
- this.m_dLowValue = Math.min(this.m_dLowValue, dVal);
-
- // Set the high
- this.m_dPeakValue = Math.max(this.m_dPeakValue, dVal);
- }
- }
- }
-
- // Set the NoData flag and exit if we don't have any
- this.m_bNoData = (cActualVals == 0);
- if (this.m_bNoData == true) {
- this.m_adRangeMarks = new double[0];
- return;
- }
-
- // Caclulate the average
- this.m_dAvgValue /= cActualVals;
-
- ///////////////////////////////////////////////////////////////////
- // Calculate the value axis units (X for horiz, Y for vertical)
-
- if (this.ceiling == this.floor) {
- double range = (this.m_dPeakValue - this.m_dLowValue);
-
- if (range != 0) {
- // Buffer the top and bottom by 10%
- double buffer = range * .1;
- double topbuf = buffer / 2;
- double botbuf = ((this.m_dLowValue - topbuf) < 0) ? m_dLowValue : topbuf;
-
- range += (topbuf + botbuf);
- unit = range / (this.valueLines - 1);
-
- this.m_floor = this.m_dLowValue - botbuf;
- topRange = this.m_dPeakValue + topbuf;
- } else {
- // If the peak value and low value are the same create a range
- // that puts the charted value 1/2 up the chart
- this.m_floor = 0;
-
- if (this.m_dPeakValue == 0) {
- topRange = (this.valueLines - 1);
- if (this.m_fmtUnits.getFamily() == MeasurementUnits.Family.DURATION) {
- topRange *= 1000;
- }
- } else {
- topRange = this.m_dPeakValue * 2;
- }
-
- unit = (topRange - this.m_floor) / (this.valueLines - 1);
- }
- } else {
- // We just accept the floor and ceiling if they are preset by
- // whoever instantiated the chart
- this.m_floor = this.floor;
- unit = (this.ceiling - this.floor) / (this.valueLines - 1);
- }
-
- ////////////////////////////////////////////////////////////////////
- // Calculate Cross Line Values
-
- this.m_adRangeMarks = new double[this.valueLines];
-
- for (int i = 0; i < this.valueLines; i++) {
- this.m_adRangeMarks[i] = this.m_floor + (i * unit);
- }
- }
-
- protected int calcVariableHeight() {
- return this.height;
- }
-
- protected int calcVariableWidth() {
- return this.width;
- }
-
- /**
- * Calculates the label width of the horizontal axis of the chart.
- *
- * @param graph The java.awt.Graphics context to draw into.
- *
- * @return The width of the widest label on the X (horizontal) axis.
- */
- protected int getXLabelWidth() {
- int iWidth;
- int iMaxWidth = 0;
-
- Iterator<IDataPoint> iter = this.getDataPoints().iterator();
-
- while (iter.hasNext()) {
- iWidth = m_metricsLabel.stringWidth(((IDisplayDataPoint) iter.next()).getLabel());
-
- if (iWidth > iMaxWidth) {
- iMaxWidth = iWidth;
- }
- }
-
- return iMaxWidth;
- }
-
- protected int getXLegendHeight() {
- int height = m_metricsLegend.getAscent() + (this.textWhitespace * 2);
- int result = 0;
-
- if (this.showTopLegend == true) {
- result += height;
- }
-
- if (this.showBottomLegend == true) {
- result += height;
- }
-
- return result;
- }
-
- /**
- * Calculates the label width of the vertical axis of the chart.
- *
- * @param graph The ChartGraphics context to draw into.
- *
- * @return The width of the widest label on the Y (vertical) axis.
- */
- protected abstract int getYLabelWidth(Graphics2D g);
-
- protected abstract String[] getXLabels();
-
- protected int getXLabelHeight() {
- int result = 0;
-
- if ((this.showTopLabels == true) || (this.showBottomLabels == true)) {
- String[] labels = this.getXLabels();
- int labelHeight = 0;
-
- if ((labels != null) && (labels.length > 0)) {
- labelHeight = this.tickMarkHeight + ChartGraphics.getStringHeight(labels[0], this.m_metricsLabel);
- } else {
- labelHeight = this.tickMarkHeight + m_metricsLabel.getAscent();
- }
-
- if (this.showTopLabels == true) {
- result += labelHeight;
- }
-
- if (this.showBottomLabels == true) {
- result += labelHeight;
- }
- }
-
- return result;
- }
-
- protected abstract Rectangle getInteriorRectangle(ChartGraphics g);
-
- protected int getExteriorHeight() {
- int cyLabel = this.getXLabelHeight();
- int cyLegend = this.getXLegendHeight();
-
- int cyBuf = (m_metricsLabel.getAscent() / 2);
-
- // Provide a little extra space if there is no bottom label or legend
- if ((this.showBottomLabels == false) && (this.showBottomLegend == false)) {
- cyBuf += (m_metricsLabel.getAscent() / 2);
- }
-
- return (this.topBorder + cyLegend + cyLabel + cyBuf + this.bottomBorder);
- }
-
- protected Collection<DataPointCollection> initData(Collection<DataPointCollection> coll) {
- return coll;
- }
-
- protected void initFonts() {
- // Initialize FontMetrics
- Image img = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_BINARY);
- Graphics2D g = (Graphics2D) img.getGraphics();
- m_metricsLabel = g.getFontMetrics(this.font);
- m_metricsLegend = g.getFontMetrics(this.legendFont);
- g.dispose();
- }
-
- @Override
- protected void preInit() {
- // Create the ChartGraphics
- Collection<DataPointCollection> coll = this.initData(this.m_collDataPointColl);
- if (coll instanceof ArrayList) {
- this.m_collDataPointColl = (ArrayList<DataPointCollection>) coll;
- } else {
- throw new ClassCastException("initData() must return a collection of type ArrayList.");
- }
-
- // Set the variable width and height
- if (this.height == Chart.VARIABLE_HEIGHT) {
- this.height = this.calcVariableHeight();
- }
-
- if (this.width == Chart.VARIABLE_WIDTH) {
- this.width = this.calcVariableWidth();
- }
- }
-
- @Override
- protected void postInit(Graphics2D g) {
- // Calculate the base part of the image
- this.calcRanges();
- this.calc(g);
- }
-
- /**
- * Retrieves the value and unit coordinate for a data point in the chart.
- *
- * @param valuePixels An int that specifies the size of the value axis in pixels.
- * @param unitPixels An int that specifies the size of the unit axis in pixels.
- * @param datapoint An int that specifies the zero-based index of the datum to calculate coordinates for.
- * @param collection The DataPointCollection the datapoint is located in.
- *
- * @return A java.awt.Point object that contains the X and Y coordinate.
- *
- * @see java.awt.Rectangle
- */
- protected Point getDataPoint(int valuePixels, int unitPixels, int datapoint, DataPointCollection coll) {
- int cDataPts = coll.size();
- double dVal = ((IDisplayDataPoint) coll.get(datapoint)).getValue();
- return this.getDisplayPoint(valuePixels, unitPixels, cDataPts, dVal, datapoint);
- }
-
- /**
- * Retrieves the value and unit coordinate for a value on the x and y axis in the chart.
- *
- * @param valuePixels An int that specifies the size of the value axis in pixels.
- * @param unitPixels An int that specifies the size of the unit axis in pixels.
- * @param unitPoints Number of ticks on the unit axis.
- * @param value A double that specifies the value to get coordinates for.
- * @param unitIndex Ticks on the unit axis to get coordinates for.
- *
- * @return A java.awt.Point object that contains the X and Y coordinate.
- */
- protected Point getDisplayPoint(int valuePixels, int unitPixels, int unitPoints, double value, int unitIndex) {
- int iSpread = unitPixels - (this.valueIndent * 2);
- iSpread = (unitPoints > 1) ? (iSpread / (unitPoints - 1)) : iSpread;
-
- if (Double.isNaN(value) == true) {
- return null;
- }
-
- if (this.ceiling != this.floor) {
- if (value < this.floor) {
- // This is a problem, set value to the floor
- log.error("Data point value (" + value + ") lower than floor (" + this.floor + ")");
- value = this.floor;
- } else if (value > this.ceiling) {
- // This is a problem, set value to the ceiling
- log.error("Data point value (" + value + ") higher than ceiling (" + this.ceiling + ")");
- value = this.ceiling;
- }
- }
-
- // X = unitPixels, Y = valuePixels
- int x = this.valueIndent + (iSpread * unitIndex);
- int y = valuePixels - (int) Math.round((value - this.m_floor) * this.scale(valuePixels));
-
- if (x == 0) {
- x++;
- } else if (x == (unitPixels - this.lineWidth)) {
- x--;
- }
-
- if (y == 0) {
- y++;
- } else if (y == valuePixels) {
- y--;
- }
-
- return new Point(x, y);
- }
-
- protected String getUnitLabel(IDisplayDataPoint data) {
- return data.getLabel();
- }
-
- protected boolean hasData() {
- return (this.m_bNoData == false);
- }
-
- /**
- * Calculates the scale of the graph data points. This is the number of pixels per data point.
- *
- * @param height The height of the rectangle to calculate the vertical scale for.
- *
- * @return A floating point value that specifies the scale multiplier of the vertical axis.
- */
- protected double scale(int height) {
- double result = (height / (this.m_adRangeMarks[this.m_adRangeMarks.length - 1] - this.m_adRangeMarks[0]));
- return result;
- }
-
- protected Class<DataPointCollection> getDataCollectionClass() {
- return DataPointCollection.class;
- }
-
- protected boolean checkHighLow() {
- return false;
- }
-
- // protected IndexColorModel getIndexColorModel() {
- // return (IndexColorModel)(new BufferedImage(
- // 1, 1, BufferedImage.TYPE_BYTE_INDEXED)).getColorModel();
- // }
-
- ////////////////////////////////////////////////
- // Properties
-
- /**
- * Retrieves the average value of the chart's data set.
- *
- * @return A floating point value that is the average value of the chart's data set.
- */
- public double getAverageValue() {
- return this.m_dAvgValue;
- }
-
- public String getNoDataString() {
- return this.m_strNoData;
- }
-
- public void setNoDataString(String s) {
- this.m_strNoData = (s == null) ? EMPTY_STRING : s;
- }
-
- /**
- * Retrieves the data set of the chart.
- *
- * @return A net.hyperic.chart.DataPointCollection object that contains the current data set points.
- *
- * @see net.hyperic.chart.DataPointCollection
- */
- public DataPointCollection getDataPoints() {
- return this.getDataPoints(0);
- }
-
- public DataPointCollection getDataPoints(int index) {
- return this.m_collDataPointColl.get(index);
- }
-
- public int getDataSetCount() {
- return this.m_collDataPointColl.size();
- }
-
- public Iterator<DataPointCollection> getDataSetIterator() {
- return this.m_collDataPointColl.iterator();
- }
-
- public void setNumberDataSets(int number) {
- int delta = number - m_collDataPointColl.size();
-
- if (delta > 0) {
- try {
- for (int i = 0; i < delta; i++) {
- m_collDataPointColl.add(this.getDataCollectionClass().newInstance());
- }
- } catch (Exception e) {
- System.out.println(e);
- }
- } else if (delta < 0) {
- for (int i = delta; i < 0; i++) {
- m_collDataPointColl.remove(m_collDataPointColl.size() - 1);
- }
- }
-
- // Make sure we allways have at least one empty collection
- if (this.getDataSetCount() == 0) {
- try {
- m_collDataPointColl.add(getDataCollectionClass().newInstance());
- } catch (Exception e) {
- System.out.println(e);
- }
- }
- }
-
- public void setFormat(MeasurementUnits units) {
- this.m_fmtUnits = units;
- }
-
- public Rectangle getExteriorRectangle() {
- return new Rectangle(this.xOffset, this.yOffset, this.width, this.height);
- }
-
- /**
- * Retrieves the low value of the chart's data set.
- *
- * @return A floating point value that is the low value of the chart's data set.
- */
- public double getLowValue() {
- return this.m_dLowValue;
- }
-
- /**
- * Retrieves the peak value of the chart's data set.
- *
- * @return A floating point value that is the peak value of the chart's data set.
- */
- public double getPeakValue() {
- return this.m_dPeakValue;
- }
-
- /**
- * Get the chart's title.
- *
- * @return A string containing the chart's title.
- */
- public String getTitle() {
- return this.m_strTitle;
- }
-
- /**
- * Set the chart's title.
- *
- * @param title A string containing the chart's title.
- */
- public void setTitle(String title) {
- this.m_strTitle = ((title == null) ? Chart.EMPTY_STRING : title);
- }
-
- /**
- * Retrieves the legend for the chart's Unit axis. The default legend is "TIME".
- *
- * @return A java.lang.String object that contains the chart's Unit axis lagend.
- */
- public String getUnitLegend() {
- return this.m_strUnitLegend;
- }
-
- /**
- * Sets the legend for the chart's Unit axis.
- *
- * @param label A java.lang.String object that contains the chart's Unit axis legend.
- *
- * @exception IllegalArgumentException If the legend parameter is null.
- */
- public void setUnitLegend(String legend) {
- this.m_strUnitLegend = ((legend == null) ? Chart.EMPTY_STRING : legend);
- }
-
- /**
- * Retrieves the legend for the chart's Value axis. The default legend is "VALUE".
- *
- * @return A java.lang.String object that contains the chart's Value axis legend.
- */
- public String getValueLegend() {
- return this.m_strValueLegend;
- }
-
- /**
- * Sets the legend for the chart's Value axis.
- *
- * @param label A java.lang.String object that contains the chart's Value axis legend.
- *
- * @exception IllegalArgumentException If the legend parameter is null.
- */
- public void setValueLegend(String legend) {
- this.m_strValueLegend = ((legend == null) ? Chart.EMPTY_STRING : legend);
- }
-
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ChartGraphics.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ChartGraphics.java
deleted file mode 100644
index 06dc158..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ChartGraphics.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics2D;
-import java.awt.Rectangle;
-import java.util.StringTokenizer;
-
-public class ChartGraphics {
- private static final int DRAW_CENTERED = 1;
-
- protected static final int EVENT_HEIGHT = 11;
- protected static final int EVENT_WIDTH = 11;
- protected static final int HALF_EVENT_HEIGHT = EVENT_HEIGHT / 2;
- protected static final int HALF_EVENT_WIDTH = EVENT_HEIGHT / 2;
-
- private static final Font EVENT_FONT = new Font("Helvetica", Font.BOLD, 9);
-
- private Chart m_chart;
- public Graphics2D graphics;
-
- public ChartGraphics(Chart chart, Graphics2D graph) {
- this.m_chart = chart;
- this.graphics = graph;
-
- }
-
- public void dispose() {
- this.graphics.dispose();
- }
-
- public void drawEvent(int eventId, int x, int y) {
- String evt = Integer.toString(eventId);
- this.graphics.fillOval(x - HALF_EVENT_WIDTH, y - HALF_EVENT_HEIGHT, EVENT_WIDTH, EVENT_HEIGHT);
-
- // Backup drawing objects
- Font fontOrig = this.graphics.getFont();
- Color clrOrig = this.graphics.getColor();
-
- this.graphics.setColor(Color.WHITE);
- this.graphics.setFont(EVENT_FONT);
- this.graphics.drawString(evt, x - (m_chart.m_metricsLabel.stringWidth(evt) / 2) + 1, y
- + (m_chart.m_metricsLabel.getAscent() / 2) - 1);
-
- // Restore drawing objects
- this.graphics.setColor(clrOrig);
- this.graphics.setFont(fontOrig);
- }
-
- public void drawXLegendString(String text) {
- this.graphics.setColor(m_chart.legendTextColor);
-
- Rectangle rect = m_chart.getInteriorRectangle(this);
-
- // Split out anything in parens (e.g., TIME (2:00pm to 3:00pm)
- String text1;
- String text2;
- int textWidth;
- int text1Width = 0;
-
- int paren = text.indexOf('(');
- if (paren != -1) {
- text1 = text.substring(0, paren);
- text2 = text.substring(paren);
- text1Width = m_chart.m_metricsLegend.stringWidth(text1);
- textWidth = text1Width + m_chart.m_metricsLabel.stringWidth(text2);
- } else {
- text1 = text;
- text2 = null;
- textWidth = m_chart.m_metricsLegend.stringWidth(text1);
- }
-
- int x = (m_chart.width / 2) - (textWidth / 2);
- int x2 = x + text1Width;
-
- if (m_chart.showTopLegend == true) {
- this.graphics.setFont(m_chart.legendFont);
- this.graphics.drawString(text1, x, m_chart.yTopLegend);
-
- if (text2 != null) {
- this.graphics.setFont(m_chart.font);
- this.graphics.drawString(text2, x2, m_chart.yTopLegend);
- }
- }
-
- if (m_chart.showBottomLegend == true) {
- this.graphics.setFont(m_chart.legendFont);
- this.graphics.drawString(text1, x, m_chart.yBottomLegend);
-
- if (text2 != null) {
- this.graphics.setFont(m_chart.font);
- this.graphics.drawString(text2, x2, m_chart.yBottomLegend);
- }
- }
- }
-
- public void drawYLegendString(String text) {
- char[] achVal = text.toCharArray();
-
- graphics.setColor(m_chart.legendTextColor);
- graphics.setFont(m_chart.legendFont);
-
- for (int i = 0, y = (m_chart.height / 2) - (m_chart.m_metricsLegend.getAscent() * text.length() / 2); i < achVal.length; i++, y += m_chart.m_metricsLegend
- .getAscent()) {
- if (m_chart.showLeftLegend) {
- this.graphics.drawChars(achVal, i, 1, m_chart.xVertLegend, y);
- }
- }
- }
-
- public void drawXLines(int[] lines, String[] labels, boolean fullLines) {
- graphics.setFont(m_chart.font);
- FontMetrics metrics = this.graphics.getFontMetrics(m_chart.font);
-
- Rectangle rect = m_chart.getInteriorRectangle(this);
- int x2 = rect.x + ((fullLines == true) ? rect.width : 0);
- int y2 = rect.y + rect.height;
- int xBeginLine = rect.x;
-
- if (m_chart.showLeftLabels == true) {
- xBeginLine -= (m_chart.lineWidth + m_chart.tickMarkHeight);
- }
-
- for (int i = 0; i < lines.length; i++) {
- int y = rect.y + y2 - lines[i];
-
- int xEndLine = x2;
- if (m_chart.showRightLabels == true) {
- xEndLine += (m_chart.lineWidth + m_chart.tickMarkHeight);
- }
-
- this.graphics.setColor(m_chart.xLineColor);
- this.graphics.drawLine(xBeginLine, y, xEndLine, y);
-
- this.graphics.setColor(m_chart.textColor);
-
- if (m_chart.showLeftLabels == true) {
- this.graphics.drawString(labels[i], m_chart.x2VertLabels - metrics.stringWidth(labels[i]), y
- + (metrics.getAscent() / 2) - 1);
- }
-
- if (m_chart.showRightLabels == true) {
- this.graphics.drawString(labels[i], m_chart.xRLabel, y + (metrics.getAscent() / 2) - 1);
- }
- }
- }
-
- public void drawYLines(int[] lines, String[] labels, boolean fullLines, int skip) {
- if ((m_chart.showBottomLabels == false) && (m_chart.showTopLabels == false)) {
- return;
- }
-
- graphics.setFont(m_chart.font);
-
- Rectangle rect = m_chart.getInteriorRectangle(this);
- int yBegin = rect.y + m_chart.lineWidth;
- int yEnd = yBegin + rect.height;
- int y = (fullLines == true) ? yBegin : yEnd;
- int y1;
- int y2;
-
- for (int i = 0; i < lines.length; i++) {
- if (m_chart.showTopLabels == false) {
- y1 = yBegin;
- } else if ((m_chart.showFullLabels == false) && ((i % skip) != 0)) {
- y1 = yBegin - (m_chart.lineWidth * 2) - (m_chart.tickMarkHeight / 2);
- } else {
- y1 = yBegin - (m_chart.lineWidth * 2) - m_chart.tickMarkHeight;
- }
-
- if (m_chart.showBottomLabels == false) {
- y2 = yEnd;
- } else if ((m_chart.showFullLabels == false) && ((i % skip) != 0)) {
- y2 = yEnd + (m_chart.tickMarkHeight / 2);
- } else {
- y2 = yEnd + m_chart.tickMarkHeight;
- }
-
- graphics.setColor(m_chart.xLineColor);
- if (m_chart.showTopLabels == true) {
- graphics.drawLine(lines[i], y1, lines[i], yEnd);
- } else if (m_chart.showBottomLabels == true) {
- graphics.drawLine(lines[i], y, lines[i], y2);
- } else {
- graphics.drawLine(lines[i], y1, lines[i], y2 - this.m_chart.lineWidth);
- }
-
- // Draw the text label
- if ((m_chart.showFullLabels == true) || ((i % skip) == 0) || ((i + 1) == labels.length)) {
- graphics.setColor(m_chart.textColor);
-
- if ((m_chart.showTopLabels == true) && (labels[i] != null)) {
- this.drawString(labels[i], lines[i], y1 - m_chart.textWhitespace, DRAW_CENTERED);
- }
-
- if ((m_chart.showBottomLabels == true) && (labels[i] != null)) {
- this.drawString(labels[i], lines[i], m_chart.yHorzLabels, DRAW_CENTERED);
- }
- }
- }
- }
-
- /**
- * Draws multiline strings
- *
- * @param s String to draw.
- * @param x x coordinate.
- * @param y y coordinate.
- */
- public void drawString(String s, int x, int y, int effect) {
- FontMetrics metrics = this.graphics.getFontMetrics();
- StringTokenizer tok = new StringTokenizer(s);
-
- while (tok.hasMoreTokens() == true) {
- String text = tok.nextToken();
- int xText = (effect == DRAW_CENTERED) ? (x - (metrics.stringWidth(text) / 2)) : x;
-
- this.graphics.drawString(text, xText, y);
-
- y += metrics.getAscent();
- }
- }
-
- public static int getStringHeight(String s, FontMetrics metrics) {
- int result = 0;
-
- int cTokens = (new StringTokenizer(s)).countTokens();
- for (int i = 0; i < cTokens; i++) {
- result += metrics.getAscent();
- }
-
- return result;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ColumnChart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ColumnChart.java
deleted file mode 100644
index afda72e..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ColumnChart.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.awt.Color;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.util.Iterator;
-
-import org.rhq.enterprise.gui.image.data.IDataPoint;
-import org.rhq.enterprise.gui.image.data.IHighLowDataPoint;
-
-/**
- * ColumnChart draws a chart with vertical bars that represent the value of each data point. For a description of how to
- * use ColumnChart, see net.hyperic.chart.Chart.
- *
- * @see net.hyperic.chart.Chart
- */
-public class ColumnChart extends VerticalChart {
- protected static final int DEFAULT_COLUMN_WIDTH = 5;
- protected static final Color DEFAULT_COLUMN_COLOR = new Color(0x66, 0x99, 0xFF);
- protected static final Color DEFAULT_HIGHLOW_COLOR = new Color(0x66, 0x66, 0x66);
-
- /**
- * Width of column bars.
- */
- public int columnWidth = DEFAULT_COLUMN_WIDTH;
-
- /**
- * Color of column bars.
- */
- public Color columnColor = DEFAULT_COLUMN_COLOR;
-
- /**
- * Determines whether cumulative data point calculations should be performed.
- */
- public boolean isCumulative = false;
-
- public ColumnChart() {
- super();
- }
-
- public ColumnChart(int width, int height) {
- super(width, height);
- }
-
- @Override
- protected void init() {
- super.init();
- this.columnWidth = DEFAULT_COLUMN_WIDTH;
- this.valueIndent = 8;
- }
-
- @Override
- protected void paint(ChartGraphics g, Rectangle rect) {
- /////////////////////////////////////////////////////////
- // Draw the Column Bars
-
- // Calculate Bar Width
- int halfcol = this.columnWidth / 2;
-
- Rectangle rectBar = new Rectangle();
- rectBar.width = this.columnWidth;
-
- DataPointCollection coll = this.getDataPoints();
- Iterator<IDataPoint> iter = coll.iterator();
-
- for (int index = 0; iter.hasNext() == true; index++) {
- IDataPoint datapt = iter.next();
-
- Point ptData = this.getDataPoint(rect, index, coll);
- if (ptData == null) {
- continue;
- }
-
- rectBar.x = ptData.x - halfcol;
- rectBar.y = ptData.y;
- rectBar.height = (rect.y + rect.height) - rectBar.y;
-
- // Draw Bar
- g.graphics.setColor(this.columnColor);
- g.graphics.fillRect(rectBar.x, rectBar.y, rectBar.width, rectBar.height);
-
- if (datapt instanceof IHighLowDataPoint) {
- IHighLowDataPoint hlPt = (IHighLowDataPoint) datapt;
-
- // Make sure there's actually a range
- if (hlPt.getHighValue() == hlPt.getLowValue()) {
- continue;
- }
-
- Point ptHigh = this.adjustBorders(this.getDisplayPoint(rect.height, rect.width, coll.size(), hlPt
- .getHighValue(), index));
- Point ptLow = this.adjustBorders(this.getDisplayPoint(rect.height, rect.width, coll.size(), hlPt
- .getLowValue(), index));
-
- // Skip if the bars will not be clearly separated
- if ((ptLow.y - ptHigh.y) < 2) {
- continue;
- }
-
- g.graphics.setColor(DEFAULT_HIGHLOW_COLOR);
- g.graphics.drawLine(ptLow.x, ptLow.y, ptHigh.x, ptHigh.y);
-
- ptHigh.x -= halfcol;
- ptLow.x -= halfcol;
-
- // Draw the High, Low Lines
- g.graphics.drawLine(ptHigh.x, ptHigh.y, ptHigh.x + rectBar.width - 1, ptHigh.y);
- g.graphics.drawLine(ptLow.x, ptLow.y, ptLow.x + rectBar.width - 1, ptLow.y);
- }
- }
- }
-
- @Override
- protected boolean checkHighLow() {
- return true;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ColumnLineChart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ColumnLineChart.java
deleted file mode 100644
index c47f54d..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ColumnLineChart.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.awt.Color;
-import java.awt.Rectangle;
-
-/**
- * ColumnLineChart draws a chart with vertical bars that represent the value of each data point with a connecting data
- * points on top of the bars. For a description of how to use ColumnChart, see net.hyperic.chart.Chart.
- *
- * @see net.hyperic.chart.Chart
- */
-public class ColumnLineChart extends ColumnChart {
- private final LineChart m_lineChart = new LineChart();
-
- /**
- * Constructs a ColumnLineChart class with a default width, height and properties.
- */
- public ColumnLineChart() {
- }
-
- /**
- * Constructs a ColumnLineChart class with a specified width and height.
- *
- * @param width The width of the chart in pixels.
- * @param height The height of the chart in pixels.
- */
- public ColumnLineChart(int width, int height) {
- super(width, height);
- }
-
- protected Rectangle draw(ChartGraphics g) {
- Rectangle rect = super.draw(g);
-
- this.m_lineChart.width = this.width;
- this.m_lineChart.height = this.height;
-
- this.m_lineChart.getDataPoints().addAll(this.getDataPoints());
- this.m_lineChart.calcRanges();
-
- this.m_lineChart.paint(g, rect);
-
- return rect;
- }
-
- /**
- * Retrieves the color of the chart's datum line. This is the line that represents the chart's data points.
- *
- * @return A java.awt.Color object that contains the datum line color.
- *
- * @see java.awt.Color
- */
- public Color getDataLineColor() {
- return this.m_lineChart.getDataLineColor(0);
- }
-
- /**
- * Sets the color of the chart's datum line. This is the line that represents the chart's data points.
- *
- * @param value A java.awt.Color object that contains the datum line color.
- *
- * @exception IllegalArgumentException If the value parameter is null.
- *
- * @see java.awt.Color
- */
- public Color setDataLineColor(Color value) {
- if (value == null) {
- throw new IllegalArgumentException();
- }
-
- this.m_lineChart.setDataLineColor(0, value);
- return value;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/DataPoint.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/DataPoint.java
deleted file mode 100644
index f6062a0..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/DataPoint.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import org.rhq.enterprise.gui.image.data.IDisplayDataPoint;
-
-/**
- * DataPoint holds a data and label for a single data point in a chart. A collection of DataPoint objects are used to
- * chart a series of data points.
- */
-public class DataPoint implements IDisplayDataPoint {
- private String m_strLabel;
- private double m_dValue;
- private long m_timestamp;
-
- /**
- * Constructs a DataPoint object with the specified value and an empty label.
- *
- * @param value A floating point value for the object data point.
- */
- public DataPoint(double value) {
- this(value, null);
- }
-
- /**
- * Constructs a DataPoint object with the specified value and and specified label.
- *
- * @param value A floating point value for the object's data point.
- * @param timestamp A timestamp for the object's data point.
- */
- public DataPoint(double value, long timestamp) {
- this.m_dValue = value;
- this.m_timestamp = timestamp;
- }
-
- /**
- * Constructs a DataPoint object with the specified value and and specified label.
- *
- * @param value A floating point value for the object's data point.
- * @param label A String label for the object's data point.
- */
- public DataPoint(double value, String label) {
- this.m_dValue = value;
- this.m_strLabel = label;
- }
-
- /**
- * Retrieves the absolute time.
- *
- * @return A long value for the absolute time.
- */
- public long getTimestamp() {
- return this.m_timestamp;
- }
-
- /**
- * Retrieves the label of a chart data point.
- *
- * @return A String label for a chart data point.
- */
- public String getLabel() {
- return this.m_strLabel;
- }
-
- /**
- * Sets the label of a chart data point. The label is displayed on the X axis for line and column charts.
- *
- * @param label A String label for a chart data point.
- */
- public void setLabel(String label) {
- if (label == null) {
- this.m_strLabel = Chart.EMPTY_STRING;
- } else {
- this.m_strLabel = label;
- }
- }
-
- /**
- * Retrieves the value of a chart data point. The data point is charted on the Y axis for line and column charts.
- *
- * @return A floating point value for a chart data point.
- */
- public double getValue() {
- return this.m_dValue;
- }
-
- /**
- * Sets the value of a chart data point. The data point is charted on the Y axis for line and column charts.
- *
- * @param value A floating point value for a chart data point.
- */
- public void setValue(double value) {
- this.m_dValue = value;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- long temp;
- temp = Double.doubleToLongBits(m_dValue);
- result = prime * result + (int) (temp ^ (temp >>> 32));
- result = prime * result + (int) (m_timestamp ^ (m_timestamp >>> 32));
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof DataPoint) {
- DataPoint val = (DataPoint) obj;
- return ((this.getTimestamp() == val.getTimestamp()) && (this.getValue() == val.getValue()));
- }
-
- return false;
- }
-
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/DataPointCollection.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/DataPointCollection.java
deleted file mode 100644
index d8efc54..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/DataPointCollection.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.rhq.enterprise.gui.image.data.IDataPoint;
-
-/**
- * DataPointCollection holds a collection of objects that implement the org.rhq.enterprise.gui.image.data.IDataPoint
- * interface. The collection of objects form are charted when give to a subclass of net.hyperic.chart.Chart.
- */
-public class DataPointCollection extends ArrayList {
- public DataPointCollection() {
- }
-
- public DataPointCollection(int initialCapacity) {
- super(initialCapacity);
- }
-
- /**
- * Adds an element to the collection.
- *
- * @param element The object to add to the collection.
- *
- * @return true of object was successfully added to the collection.
- *
- * @throws ClassCastException If the element does not implement the IDataPoint interface.
- */
- public boolean add(IDataPoint element) {
- return super.add(element);
- }
-
- /**
- * Adds the elements of the specified collection to this collection.
- *
- * @param c The collection to add to this collection.
- *
- * @return true if the objects was successfully added to the collection.
- *
- * @throws ClassCastException If the specified collection is not a net.hyperic.chart.DataCollection or subclass.
- */
- public boolean addAll(DataPointCollection c) {
- return super.addAll(c);
- }
-
- /**
- * Determines whether the collection contains the specified element.
- *
- * @param element The object to test for in the collection.
- *
- * @return true if the collection contains the specified element.
- *
- * @throws ClassCastException If the element does not implement the net.hyperic.chart.IDataPoint interface.
- */
- public boolean contains(IDataPoint element) {
- return super.contains(element);
- }
-
- /**
- * Determines whether the collection contains all of the elements in the specified collection.
- *
- * @param c The collection containing the element to check for.
- *
- * @return true if the collection contains the specified objects.
- *
- * @throws ClassCastException If the specified collection is not a net.hyperic.chart.DataCollection or subclass.
- */
- public boolean containsAll(DataPointCollection c) {
- return super.containsAll(c);
- }
-
- /**
- * Removes the specified element from the collection.
- *
- * @param o The object to remove from the collection.
- *
- * @return true if object was successfully removed from the collection.
- *
- * @throws ClassCastException If the element does not implement the IDataPoint interface.
- */
- public boolean remove(IDataPoint element) {
- return super.remove(element);
- }
-
- /**
- * Removes all of the elements in the specified collection from this collection.
- *
- * @param c The collection of objects to remove.
- *
- * @return true if the elements were successfully removed from the collection.
- *
- * @throws ClassCastException If the specified collection is not a net.hyperic.chart.DataCollection or subclass.
- */
- public boolean removeAll(DataPointCollection c) {
- return super.removeAll(c);
- }
-
- /**
- * Removes all of the elements in the collection except those in the specified collection.
- *
- * @param c The collection of objects to retain.
- *
- * @return true if the elements were succesfully retained.
- *
- * @throws ClassCastException If the specified collection is not a net.hyperic.chart.DataCollection or subclass.
- */
- public boolean retainAll(DataPointCollection c) {
- return super.retainAll(c);
- }
-
- @Override
- public Iterator<IDataPoint> iterator() {
- return super.iterator();
- }
-
- @Override
- public IDataPoint get(int index) {
- return (IDataPoint) super.get(index);
- }
-
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HealthChart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HealthChart.java
deleted file mode 100644
index 28fceb0..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HealthChart.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import org.rhq.enterprise.gui.image.data.IDisplayDataPoint;
-
-public class HealthChart extends ColumnChart {
- protected HealthChart(int width, int height) {
- super(width, height);
- }
-
- protected void init() {
- super.init();
- this.columnWidth = 11;
- }
-
- protected String[] getXLabels() {
- return HealthChart.getUnitStrings(this.getDataPoints(), true);
- }
-
- protected static String[] getUnitStrings(DataPointCollection datapts, boolean showHealthLabels) {
- String[] result = new String[datapts.size()];
-
- // Assume 8 hours
- double interval = 8.0 / result.length;
- for (int i = 0; i < result.length; i++) {
- if (showHealthLabels == true) {
- int remainder = result.length - i;
-
- if (remainder > 1) {
- double time = remainder * interval;
- String label = ((time % 1) == 0) ? String.valueOf((int) time) : String.valueOf(time);
-
- result[i] = "-" + label + "hr";
- } else {
- result[i] = "Now";
- }
- } else {
- result[i] = ((IDisplayDataPoint) datapts.get(i)).getLabel();
- }
- }
-
- return result;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HighLowChart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HighLowChart.java
deleted file mode 100644
index 55ed0e3..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HighLowChart.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.awt.Color;
-import java.awt.Point;
-import java.awt.Rectangle;
-import org.rhq.enterprise.gui.image.WebImage;
-import org.rhq.enterprise.gui.image.data.IHighLowDataPoint;
-
-/**
- * HighLowChart draws a horizontal chart with columns that display the high, low and average values for each time unit
- * on the chart. For a description of how to use LineChart, see net.hyperic.chart.Chart.
- *
- * @see net.hyperic.chart.Chart
- */
-public class HighLowChart extends ColumnChart {
- protected static final Color DEFAULT_HIGHLOW_COLOR = new Color(0x00, 0x00, 0x80);
- protected static final int DEFAULT_HIGHLOW_HEIGHT = 125;
-
- /**
- * Color of High-Low bars.
- */
- public Color highLowColor = DEFAULT_HIGHLOW_COLOR;
-
- public HighLowChart() {
- this(WebImage.DEFAULT_WIDTH);
- }
-
- public HighLowChart(int width) {
- super(width, DEFAULT_HIGHLOW_HEIGHT);
- }
-
- public HighLowChart(int width, int height) {
- super(width, height);
- }
-
- protected void init() {
- super.init();
- this.showLeftLabels = false;
- this.showBottomLabels = false;
- this.showBottomLegend = false;
- this.valueLines = 5;
- this.showAverage = false;
- this.showPeak = false;
- this.showLow = false;
- this.showBaseline = false;
- this.showHighRange = true;
- this.showLowRange = true;
- }
-
- /**
- * Retrieves the color of the high-low line.
- *
- * @return A java.awt.Color object that contains the color of the columns.
- *
- * @see java.awt.Color
- */
- public Color getHighLowLineColor() {
- return this.highLowColor;
- }
-
- /**
- * Sets the color of the columns.
- *
- * @param value A java.awt.Color object that contains the color of the high-low line.
- *
- * @exception IllegalArgumentException If the value parameter is null.
- *
- * @see java.awt.Color
- */
- public void setHighLowLineColor(Color value) {
- if (value == null) {
- throw new IllegalArgumentException();
- }
-
- this.highLowColor = value;
- }
-
- protected void paint(ChartGraphics g, Rectangle rect) {
- /////////////////////////////////////////////////////////
- // Draw the High-Low Column Bars
-
- // Calculate Bar Width
- int halfcol = this.columnWidth / 2;
-
- Rectangle rectBar = new Rectangle();
- rectBar.width = this.columnWidth;
-
- DataPointCollection coll = this.getDataPoints();
- int collSize = coll.size();
-
- for (int index = 0; index < collSize; index++) {
- Object obj = coll.get(index);
-
- if (obj instanceof IHighLowDataPoint) {
- IHighLowDataPoint datapt = (IHighLowDataPoint) obj;
-
- if ((Double.isNaN(datapt.getValue()) == true) || (Double.isNaN(datapt.getHighValue()) == true)
- || (Double.isNaN(datapt.getLowValue()) == true)) {
- continue;
- }
-
- Point ptHigh = this.adjustBorders(this.getDisplayPoint(rect.height, rect.width, collSize, datapt
- .getHighValue(), index));
- Point ptLow = this.adjustBorders(this.getDisplayPoint(rect.height, rect.width, collSize, datapt
- .getLowValue(), index));
- Point ptAvg = this.adjustBorders(this.getDisplayPoint(rect.height, rect.width, collSize, datapt
- .getValue(), index));
-
- ptHigh.x -= halfcol;
- ptLow.x -= halfcol;
- ptAvg.x -= halfcol;
-
- rectBar.x = ptHigh.x;
- rectBar.y = ptHigh.y;
- rectBar.height = (ptLow.y - ptHigh.y);
-
- // Draw Bar
- g.graphics.setColor(DEFAULT_COLUMN_COLOR);
- g.graphics.fillRect(rectBar.x, rectBar.y, rectBar.width, rectBar.height);
-
- // Draw the High, Low Average Lines
- g.graphics.setColor(this.highLowColor);
- g.graphics.drawLine(ptAvg.x, ptAvg.y, ptAvg.x + rectBar.width - 1, ptAvg.y);
-
- // Draw the dot in the middle
- g.graphics.drawOval(ptAvg.x + halfcol - 1, ptAvg.y - 1, 2, 2);
- }
- }
- }
-
- protected void calcRanges() {
- // We are going to set the peak and low values first
- DataPointCollection coll = this.getDataPoints();
-
- for (Object obj : coll) {
- if (obj instanceof IHighLowDataPoint) {
- IHighLowDataPoint datapt = (IHighLowDataPoint) obj;
- if (Double.isNaN(datapt.getHighValue()) || Double.isNaN(datapt.getLowValue())) {
- continue;
- }
-
- this.m_dPeakValue = Math.max(this.m_dPeakValue, datapt.getHighValue());
- this.m_dLowValue = Math.min(this.m_dLowValue, datapt.getLowValue());
- }
- }
-
- super.calcRanges();
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HighLowDataPoint.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HighLowDataPoint.java
deleted file mode 100644
index ffd9230..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HighLowDataPoint.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import org.rhq.enterprise.gui.image.data.IHighLowDataPoint;
-
-/**
- * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code
- * Templates
- */
-public class HighLowDataPoint extends DataPoint implements IHighLowDataPoint {
- private double m_high;
- private double m_low;
-
- public HighLowDataPoint(double high, double low, double avg) {
- super(avg, null);
- init(high, low);
- }
-
- public HighLowDataPoint(double high, double low, double avg, long timestamp) {
- super(avg, timestamp);
- init(high, low);
- }
-
- public HighLowDataPoint(double high, double low, double avg, String label) {
- super(avg, label);
- init(high, low);
- }
-
- private void init(double high, double low) {
- m_high = high;
- m_low = low;
- }
-
- public double getAverageValue() {
- return this.getValue();
- }
-
- public double getLowValue() {
- return m_low;
- }
-
- public double getHighValue() {
- return m_high;
- }
-
- public double[] getValues() {
- double[] vals = new double[3];
-
- vals[0] = m_high;
- vals[1] = m_low;
- vals[2] = this.getValue();
-
- return vals;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HorizontalChart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HorizontalChart.java
deleted file mode 100644
index a5afb1f..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/HorizontalChart.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import org.rhq.core.server.MeasurementConverter;
-import org.rhq.enterprise.gui.image.data.IDataPoint;
-import org.rhq.enterprise.gui.image.data.IDisplayDataPoint;
-
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.util.Iterator;
-
-public class HorizontalChart extends Chart {
- private Rectangle m_rect;
-
- protected HorizontalChart() {
- this.init();
- }
-
- protected HorizontalChart(int width, int height) {
- super(width, height);
- this.init();
- }
-
- protected HorizontalChart(int width, int height, int charts) {
- super(width, height, charts);
- init();
- }
-
- protected void init() {
- this.showUnitLines = true;
- }
-
- @Override
- protected Rectangle adjustRectangle(Graphics2D g, Rectangle rect) {
- int cDataPts = this.getDataPoints().size();
- int iSpread = this.getUnitSpread(g, rect);
- rect.height = (iSpread * (cDataPts - 1)) + (this.valueIndent * 2) + this.lineWidth;
-
- this.m_rect = rect;
- return rect;
- }
-
- @Override
- protected Rectangle getInteriorRectangle(ChartGraphics g) {
- return m_rect;
- }
-
- protected String[] getUnitLabels() {
- DataPointCollection coll = this.getDataPoints();
- Iterator<IDataPoint> iter = coll.iterator();
- String[] result = new String[coll.size()];
-
- for (int i = 0; iter.hasNext() == true; i++) {
- result[i] = ((IDisplayDataPoint) iter.next()).getLabel();
- }
-
- return result;
- }
-
- @Override
- protected String[] getXLabels() {
- if (this.m_adRangeMarks == null) {
- return null;
- }
-
- String[] result = MeasurementConverter.formatToSignificantPrecision(m_adRangeMarks, m_fmtUnits, true);
-
- return result;
- }
-
- private int getUnitSpread(Graphics2D g, Rectangle rect) {
- int cDataPts = this.getDataPoints().size();
- int iSpread = rect.height - (this.valueIndent * 2);
-
- return (cDataPts > 1) ? (iSpread / (cDataPts - 1)) : iSpread;
- }
-
- @Override
- protected int getYLabelWidth(Graphics2D g) {
- int maxWidth = 0;
-
- String[] labels = this.getUnitLabels();
-
- for (int i = 0; i < labels.length; i++) {
- int labelWidth = this.m_metricsLabel.stringWidth(labels[i]);
-
- if (labelWidth > maxWidth) {
- maxWidth = labelWidth;
- }
- }
-
- return maxWidth;
- }
-
- @Override
- protected Rectangle draw(ChartGraphics g) {
- ///////////////////////////////
- // Paint the chart background
-
- Rectangle rect = super.draw(g);
-
- if (this.hasData() == false) {
- return rect;
- }
-
- ///////////////////////////////////////
- // Paint the chart exterior and lines
-
- // Calculate points
- double dScale = this.scale(rect.width);
-
- //////////////////////////////////////////////////////////
- // Draw the Value (Y) Legend
-
- if (this.showLeftLegend == true) {
- g.drawYLegendString(this.getUnitLegend());
- }
-
- //////////////////////////////////////////////////////////
- // Draw the unit (Y) axis cross lines and labels
-
- DataPointCollection coll = this.getDataPoints();
-
- int[] lines = new int[coll.size()];
- String[] labels = this.getUnitLabels();
-
- int spread = this.getUnitSpread(g.graphics, rect);
-
- for (int i = 0, y = rect.y + rect.height - this.valueIndent; i < coll.size(); i++, y -= spread) {
- lines[i] = y;
- }
-
- g.drawXLines(lines, labels, false);
-
- //////////////////////////////////////////////////////////
- // Draw the unit (X) axis tick marks and labels
-
- labels = this.getXLabels();
- lines = new int[this.m_adRangeMarks.length];
-
- for (int i = 0; i < this.m_adRangeMarks.length; i++) {
- lines[i] = rect.x + (int) Math.round((this.m_adRangeMarks[i] - this.m_floor) * dScale);
- }
-
- g.drawYLines(lines, labels, true, xLabelsSkip);
-
- ////////////////////////////////////////////////////////////
- // Draw the Top & Bottom Legend
-
- g.drawXLegendString(this.getValueLegend());
-
- ///////////////////////////////
- // Paint the chart interior
-
- if (this.showValues == true) {
- paint(g, rect);
- }
-
- return rect;
- }
-
- protected void paint(ChartGraphics g, Rectangle rect) {
- }
-
- protected Point getDataPoint(Rectangle rect, int datapoint) {
- return this.getDataPoint(rect, datapoint, this.getDataPoints());
- }
-
- protected Point getDataPoint(Rectangle rect, int datapoint, DataPointCollection coll) {
- Point ptResult = super.getDataPoint(rect.width, rect.height, datapoint, coll);
-
- // Add & Flip the units
- if (ptResult != null) {
- ptResult = new Point(rect.x + (rect.width - ptResult.y), rect.y + ptResult.x);
- }
-
- return ptResult;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/LineChart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/LineChart.java
deleted file mode 100644
index bf38e90..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/LineChart.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.Stroke;
-import java.util.Iterator;
-
-/**
- * LineChart draws a horizontal chart with a line that represents data point along the line. For a description of how to
- * use LineChart, see net.hyperic.chart.Chart.
- *
- * @see net.hyperic.chart.Chart
- */
-public class LineChart extends VerticalChart {
-
- private Color[] m_clrDataLines = VerticalChart.DEFAULT_COLORS;
-
- /**
- * Specified whether the data to be charted is cumulative data.
- */
- public boolean isCumulative = false;
-
- public LineChart() {
- super();
- }
-
- public LineChart(int charts) {
- super(charts);
- }
-
- public LineChart(int width, int height) {
- super(width, height);
- }
-
- public LineChart(int width, int height, int charts) {
- super(width, height, charts);
- }
-
- @Override
- protected Rectangle draw(ChartGraphics g) {
- Rectangle result = super.draw(g);
-
- return result;
- }
-
- @Override
- protected void paint(ChartGraphics g, Rectangle rect) {
- int yLabelEvtDot = rect.y + rect.height + ChartGraphics.HALF_EVENT_HEIGHT + this.lineWidth;
-
- // Backup the current stroke and set the line width to 2 pixels
- Stroke origStroke = g.graphics.getStroke();
- BasicStroke stroke = new BasicStroke(2);
- g.graphics.setStroke(stroke);
-
- // Iterator through each data set
- Iterator<DataPointCollection> iterLines = this.getDataSetIterator();
- for (int line = 0; iterLines.hasNext() == true; line++) {
- // Draw the Line
- DataPointCollection collDataPoints = iterLines.next();
-
- Point ptData;
- int cActualPts = 0;
- int cDataPts = collDataPoints.size();
- int[] aiX = new int[cDataPts];
- int[] aiY = new int[cDataPts];
- int[] yDataPt = new int[cDataPts];
-
- for (int index = 0; index < cDataPts; index++) {
- ptData = this.getDataPoint(rect, index, collDataPoints);
-
- if (ptData != null) {
- aiX[cActualPts] = ptData.x;
- aiY[cActualPts] = ptData.y;
- yDataPt[index] = ptData.y;
- cActualPts++;
- } else {
- yDataPt[index] = yLabelEvtDot;
- }
- }
-
- g.graphics.setColor(this.m_clrDataLines[line]);
- g.graphics.drawPolyline(aiX, aiY, cActualPts);
- }
-
- // Reset the stroke as it was when we were called
- g.graphics.setStroke(origStroke);
- }
-
- public Color getDataLineColor(int index) {
- return this.m_clrDataLines[index];
- }
-
- public void setDataLineColor(int index, Color color) {
- this.m_clrDataLines[index] = color;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/PerfDataPointCollection.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/PerfDataPointCollection.java
deleted file mode 100644
index 196f18b..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/PerfDataPointCollection.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import org.rhq.enterprise.gui.image.data.IStackedDataPoint;
-
-public class PerfDataPointCollection extends DataPointCollection {
- public static final int UNKNOWN = 0;
- public static final int ENDUSER = 1;
- public static final int WEBSERVER = 2;
- public static final int APPSERVER = 3;
-
- private static final String ENDUSER_NAME = "End User";
- private static final String WEBSERVER_NAME = "Virtual Host";
- private static final String APPSERVER_NAME = "Web Application";
-
- private String m_url;
- private int m_type;
- private String m_typeName;
- private int m_requests;
-
- public int getRequest() {
- return m_requests;
- }
-
- public int getType() {
- return m_type;
- }
-
- public String getTypeName() {
- return this.m_typeName;
- }
-
- public String getTypeString() {
- String result;
-
- switch (m_type) {
- case ENDUSER: {
- result = ENDUSER_NAME;
- break;
- }
-
- case WEBSERVER: {
- result = WEBSERVER_NAME;
- break;
- }
-
- case APPSERVER: {
- result = APPSERVER_NAME;
- break;
- }
-
- default: {
- result = "";
- }
- }
-
- return result;
- }
-
- public String getURL() {
- return m_url;
- }
-
- public void setRequest(int requests) {
- m_requests = requests;
- }
-
- public void setType(int type) {
- m_type = type;
- }
-
- public void setType(int type, String name) {
- this.setType(type);
- this.setTypeName(name);
- }
-
- public void setTypeName(String name) {
- m_typeName = name;
- }
-
- public void setURL(String url) {
- m_url = url;
- }
-
- public boolean isStacked() {
- return ((this.size() > 0) && (this.get(0) instanceof IStackedDataPoint));
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/PerformanceChart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/PerformanceChart.java
deleted file mode 100644
index baeeb0f..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/PerformanceChart.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.awt.Color;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.util.Iterator;
-
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.core.server.MeasurementConverter;
-import org.rhq.enterprise.gui.image.data.IDataPoint;
-import org.rhq.enterprise.gui.image.data.IStackedDataPoint;
-
-public class PerformanceChart extends HorizontalChart {
- private static final Color[] DEFAULT_BAR_COLORS = { new Color(0x9B, 0xBA, 0x70), new Color(0x12, 0xB3, 0xB3),
- new Color(0xE7, 0x5A, 0x00), };
-
- protected static final int DEFAULT_BAR_HEIGHT = 7;
- private int m_cyBar;
- private Color[] m_clrBars = DEFAULT_BAR_COLORS;
- private boolean m_bHealthChart = true;
-
- public boolean showMinDigits = true;
- public boolean showStacked = false;
-
- public PerformanceChart() {
- super();
- }
-
- public PerformanceChart(int width, int height) {
- super(width, height);
- }
-
- @Override
- protected void init() {
- this.m_cyBar = DEFAULT_BAR_HEIGHT;
-
- this.showFullLabels = true;
- this.showRightLabels = false;
- this.showLeftLegend = false;
- this.showBottomLegend = false;
- this.valueIndent = (this.m_cyBar / 2) + this.lineWidth;
- this.valueLines = 5;
-
- this.setFormat(MeasurementUnits.EPOCH_MILLISECONDS);
- }
-
- @Override
- protected String[] getUnitLabels() {
- return HealthChart.getUnitStrings(this.getDataPoints(), this.m_bHealthChart);
- }
-
- @Override
- protected String[] getXLabels() {
- if (this.m_adRangeMarks == null) {
- return null;
- }
-
- if (this.showMinDigits == true) {
- return super.getXLabels();
- }
-
- String[] result = new String[m_adRangeMarks.length];
-
- for (int i = 0; i < m_adRangeMarks.length; i++) {
- result[i] = MeasurementConverter.format(m_adRangeMarks[i], m_fmtUnits, true);
- }
-
- return result;
- }
-
- @Override
- protected void paint(ChartGraphics g, Rectangle rect) {
- super.paint(g, rect);
-
- /////////////////////////////////////////////////////////
- // Draw the Column Bars
-
- // Calculate Bar Width
- Rectangle rectBar = new Rectangle(rect.x + this.lineWidth, rect.y + this.lineWidth, 0, this.m_cyBar);
-
- int cDataPoints = this.getDataPoints().size();
-
- if (cDataPoints == 0) {
- return;
- }
-
- int overhang = this.m_cyBar / 2;
-
- Iterator iter = this.getDataPoints().iterator();
- for (int i = 0; iter.hasNext() == true; i++) {
- IDataPoint datapt = (IDataPoint) iter.next();
-
- if (Double.isNaN(datapt.getValue())) {
- continue;
- }
-
- Point ptData = this.getDataPoint(rect, i);
- if (ptData == null) {
- continue;
- }
-
- // Draw the max bar
- int cx = ((ptData.x == rectBar.x) ? 1 : (ptData.x - rectBar.x + this.lineWidth));
- g.graphics.setColor(this.m_clrBars[2]);
- g.graphics.fillRect(rectBar.x, ptData.y - overhang, cx, this.m_cyBar);
-
- if ((this.showStacked == true) && (datapt instanceof IStackedDataPoint)
- && (((IStackedDataPoint) datapt).getValues().length > 1)) {
- IStackedDataPoint sdp = (IStackedDataPoint) datapt;
- double scale = this.scale(rect.width);
-
- double[] vals = sdp.getValues();
-
- if (sdp.getValues().length >= 2) {
- double tmp = (scale * (vals[1] - this.m_floor));
- cx = (int) Math.round(tmp) + xOffset;
- if (cx == 0) {
- cx++;
- }
-
- g.graphics.setColor(this.m_clrBars[1]);
- g.graphics.fillRect(rectBar.x, ptData.y - overhang + 2, cx, this.m_cyBar - 2);
- }
-
- cx = (int) (scale * (vals[2] - this.m_floor));
- if (cx == 0) {
- cx++;
- }
-
- g.graphics.setColor(this.m_clrBars[0]);
- g.graphics.fillRect(rectBar.x, ptData.y - overhang + 2, cx, this.m_cyBar - 2);
- }
- }
- }
-
- protected void setHealthChart(boolean health) {
- this.m_bHealthChart = health;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ScaleFormatter.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ScaleFormatter.java
deleted file mode 100644
index 55849cf..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/ScaleFormatter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.text.DateFormatSymbols;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public class ScaleFormatter {
- private static final int MINUTE = 60000;
- private static final int HOUR = 60 * MINUTE;
- private static final int DAY = 24 * HOUR;
-
- private static final String DATE_FORMAT = "M/d";
- private static final String TIME_FORMAT = "h:mma";
- private static final String DATETIME_FORMAT = "M/d/yyyy h:mma";
- private static final String MULTILINE_DATETIME_FORMAT = TIME_FORMAT + '\n' + DATE_FORMAT;
-
- private static final String[] AM_PM = { "a", "p" };
-
- private static final SimpleDateFormat m_fmt = new SimpleDateFormat();
-
- public static String formatTime(long time) {
- m_fmt.applyPattern(DATETIME_FORMAT);
- return m_fmt.format(new Date(time));
- }
-
- public static String formatTime(long time, long scale, long units) {
- DateFormatSymbols symMod = m_fmt.getDateFormatSymbols();
- symMod.setAmPmStrings(AM_PM);
- m_fmt.setDateFormatSymbols(symMod);
-
- // long tmp = (scale / units );
- // if( tmp > DAY)
- // m_fmt.applyLocalizedPattern(DATE_FORMAT);
- // else
- // m_fmt.applyLocalizedPattern(TIME_FORMAT);
-
- m_fmt.applyPattern(MULTILINE_DATETIME_FORMAT);
-
- return m_fmt.format(new Date(time));
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/SmartLabel.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/SmartLabel.java
deleted file mode 100644
index 892d319..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/SmartLabel.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-class SmartLabel {
- public String top;
- public String bottom;
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/SmartLabelMaker.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/SmartLabelMaker.java
deleted file mode 100644
index 0aeccd3..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/SmartLabelMaker.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import org.rhq.core.clientapi.util.TimeUtil;
-
-class SmartLabelMaker {
- private static final SimpleDateFormat DF_SHORT_FULL = new SimpleDateFormat("H:mm");
- private static final SimpleDateFormat DF_SHORT_ABBREV = new SimpleDateFormat(":mm");
- private static final SimpleDateFormat DF_SHORT_CHECKDIFF = new SimpleDateFormat("H");
-
- private static final SimpleDateFormat DF_MEDIUM_FULL_TOP = new SimpleDateFormat("H:mm");
- private static final SimpleDateFormat DF_MEDIUM_FULL_BOTTOM = new SimpleDateFormat("M/d");
- private static final SimpleDateFormat DF_MEDIUM_ABBREV = new SimpleDateFormat("H:mm");
- private static final SimpleDateFormat DF_MEDIUM_CHECKDIFF = new SimpleDateFormat("d");
-
- private static final SimpleDateFormat DF_LONG_FULL_TOP = new SimpleDateFormat("M/d");
- private static final SimpleDateFormat DF_LONG_FULL_BOTTOM = new SimpleDateFormat("H:mm");
- private static final SimpleDateFormat DF_LONG_ABBREV_TOP = new SimpleDateFormat("M/d");
- private static final SimpleDateFormat DF_LONG_ABBREV_BOTTOM = new SimpleDateFormat("H:mm");
- private static final SimpleDateFormat DF_LONG_CHECKDIFF = new SimpleDateFormat("d");
-
- private SimpleDateFormat _fullFormatTop = null;
- private SimpleDateFormat _fullFormatBottom = null;
- private SimpleDateFormat _abbrevFormatTop = null;
- private SimpleDateFormat _abbrevFormatBottom = null;
- private SimpleDateFormat _checkDiff = null;
- private int _labelSpacing = 4;
- private String _lastCheck = "";
-
- public SmartLabelMaker(long interval) {
- // Decide which formatter we use
- long absInterval = Math.abs(interval);
- if (absInterval < (TimeUtil.MILLIS_IN_MINUTE * 10)) {
- _fullFormatTop = DF_SHORT_FULL;
- _abbrevFormatTop = DF_SHORT_ABBREV;
- _checkDiff = DF_SHORT_CHECKDIFF;
- _labelSpacing = 4; // label every other major tick mark
- } else if (absInterval < (TimeUtil.MILLIS_IN_HOUR * 2)) {
- _fullFormatTop = DF_MEDIUM_FULL_TOP;
- _fullFormatBottom = DF_MEDIUM_FULL_BOTTOM;
- _abbrevFormatTop = DF_MEDIUM_ABBREV;
- _checkDiff = DF_MEDIUM_CHECKDIFF;
- _labelSpacing = 4; // label every 4th major tick mark
- } else {
- _fullFormatTop = DF_LONG_FULL_TOP;
- _fullFormatBottom = DF_LONG_FULL_BOTTOM;
- _abbrevFormatTop = DF_LONG_ABBREV_TOP;
- _abbrevFormatBottom = DF_LONG_ABBREV_BOTTOM;
- _checkDiff = DF_LONG_CHECKDIFF;
- _labelSpacing = 4; // label every 4th major tick mark
- }
- }
-
- public int getLabelSpacing() {
- return _labelSpacing;
- }
-
- public SmartLabel getLabels(boolean forceFullLabel, long absoluteMillis) {
- SmartLabel label = new SmartLabel();
- Date d = new Date(absoluteMillis);
- String check = _checkDiff.format(d);
-
- if (forceFullLabel || !check.equals(_lastCheck)) {
- _lastCheck = check;
- label.top = _fullFormatTop.format(d);
- label.bottom = (_fullFormatBottom == null) ? "" : _fullFormatBottom.format(d);
- } else {
- label.top = _abbrevFormatTop.format(d);
- label.bottom = (_abbrevFormatBottom == null) ? "" : _abbrevFormatBottom.format(d);
- }
-
- return label;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/StackedDataPoint.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/StackedDataPoint.java
deleted file mode 100644
index c958b42..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/StackedDataPoint.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import org.rhq.enterprise.gui.image.data.IStackedDataPoint;
-
-public class StackedDataPoint extends DataPoint implements IStackedDataPoint {
- private static final String NO_SET_VALUE = "setValue not support for" + " StackedDataPoint object";
-
- private double[] m_dValues;
-
- /**
- * Constructs a StackedDataPoint object with the specified value and an empty label.
- *
- * @param value A floating point value for the object data point.
- */
- public StackedDataPoint(double[] values) {
- this(values, null);
- }
-
- /**
- * Constructs a DataPoint object with the specified value and and specified label.
- *
- * @param value A floating point value for the object's data point.
- * @param label A String label for the object's data point.
- */
- public StackedDataPoint(double[] values, String label) {
- super(values[0], label);
- this.m_dValues = values;
-
- // Calculate and set the sum value
- double max = 0;
-
- if (values.length > 0) {
- for (int i = 0; i < values.length; i++) {
- max = Math.max(max, values[i]);
- }
- } else {
- max = Double.NaN;
- }
-
- super.setValue(max);
- }
-
- /**
- * Retrieves the value of a chart data point. The label is displayed on the X axis for stacked performance charts.
- *
- * @return A floating point value for a chart data point.
- */
- public double[] getValues() {
- return m_dValues;
- }
-
- public void setValue(double value) {
- throw new IllegalArgumentException(NO_SET_VALUE);
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/StackedPerformanceChart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/StackedPerformanceChart.java
deleted file mode 100644
index 032b1ae..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/StackedPerformanceChart.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Rectangle;
-import java.util.Iterator;
-
-import org.rhq.core.domain.measurement.MeasurementUnits;
-
-public class StackedPerformanceChart extends HorizontalChart {
- private static String CALLS = "Calls: ";
- private static String SEMICOLON = ": ";
- private static String DEFAULT_DESTINATION_TYPE = "Destination";
-
- //private static final int DEFAULT_HEIGHT = 52;
- private static final int CHART_INDENT = 25;
-
- private static final Font DEFAULT_TITLE_FONT = new Font("Helvetica", Font.BOLD, 11);
- private static final Font DEFAULT_TITLE_TEXT_FONT = new Font("Helvetica", Font.PLAIN, 11);
-
- private PerformanceChart m_perf;
- private int m_interiorHeight;
- private String m_destinationType;
-
- public StackedPerformanceChart() {
- this(Chart.DEFAULT_WIDTH, VARIABLE_HEIGHT);
- }
-
- public StackedPerformanceChart(int width, int charts) {
- this(width, VARIABLE_HEIGHT, charts);
- }
-
- public StackedPerformanceChart(int width, int charts, String destinationType) {
- this(width, VARIABLE_HEIGHT, charts, destinationType);
- }
-
- public StackedPerformanceChart(int width, int height, int charts) {
- this(width, height, charts, DEFAULT_DESTINATION_TYPE);
- }
-
- public StackedPerformanceChart(int width, int height, int charts, String destinationType) {
- super(width, Chart.VARIABLE_HEIGHT, charts);
-
- this.m_interiorHeight = height;
- m_perf = new PerformanceChart(width, 1);
- m_perf.valueIndent = 8;
- m_perf.valueLines = 10;
- m_perf.setValueLegend("Call Time");
- m_destinationType = (destinationType != null) ? destinationType : DEFAULT_DESTINATION_TYPE;
- }
-
- @Override
- protected void init() {
- super.init();
-
- this.showBottomLegend = false;
- this.showLeftLegend = false;
- this.topBorder = 0;
- this.bottomBorder = 0;
- }
-
- @Override
- protected int calcVariableHeight() {
- int height = 0;
-
- if (this.m_interiorHeight == Chart.VARIABLE_HEIGHT) {
- this.m_interiorHeight = ((PerformanceChart.DEFAULT_BAR_HEIGHT * 2) * this.getDataPoints().size())
- + (this.lineWidth * 2);
- }
-
- // Iterator through each data set
- Iterator<DataPointCollection> iterBars = this.getDataSetIterator();
- for (int line = 0; iterBars.hasNext(); line++) {
- // Calculate the height
- PerfDataPointCollection coll = (PerfDataPointCollection) iterBars.next();
- if (coll.size() == 0) {
- continue;
- }
-
- this.setChartProperties(m_perf, coll, line, this.getDataSetCount());
- if (line < (this.getDataSetCount() - 1)) {
- height++;
- }
-
- height += (this.m_interiorHeight + m_perf.getExteriorHeight());
- }
-
- if (height == 0) {
- height = this.m_metricsLegend.getHeight();
- this.m_bNoData = true;
- }
-
- return height;
- }
-
- @Override
- protected Class getDataCollectionClass() {
- return PerfDataPointCollection.class;
- }
-
- private int getTitleHeight(PerfDataPointCollection coll) {
- int cyText = m_metricsLegend.getHeight();
- int result = cyText;
-
- if (coll.getURL() != null) {
- result += cyText;
- }
-
- if (coll.getTypeString().length() > 0) {
- result += cyText;
- }
-
- return result;
- }
-
- @Override
- protected Rectangle draw(ChartGraphics g) {
- Rectangle rect = null;
-
- if (!this.hasData()) {
- return super.draw(g);
- }
-
- // Iterator through each data set
- Iterator iterLines = this.getDataSetIterator();
- for (int line = 0; iterLines.hasNext(); line++) {
- // Draw the chart
- PerfDataPointCollection src = (PerfDataPointCollection) iterLines.next();
-
- if (src.size() == 0) {
- continue;
- }
-
- DataPointCollection dest = m_perf.getDataPoints();
- dest.clear();
- dest.addAll(src);
-
- this.setChartProperties(m_perf, src, line, this.getDataSetCount());
- m_perf.height = m_interiorHeight + m_perf.getExteriorHeight();
-
- ChartGraphics g2 = new ChartGraphics(m_perf, g.graphics);
- m_perf.floor = this.m_adRangeMarks[0];
- m_perf.ceiling = this.m_adRangeMarks[this.m_adRangeMarks.length - 1];
- m_perf.calcRanges();
- m_perf.calc(g2.graphics);
- m_perf.draw(g2);
-
- rect = m_perf.getExteriorRectangle();
- m_perf.yOffset += m_perf.height;
-
- // Draw titles
- this.drawTitles(g, src, rect);
-
- g.graphics.setColor(this.xLineColor);
- g.graphics.drawLine(rect.x, m_perf.yOffset, rect.x + rect.width, m_perf.yOffset);
-
- m_perf.yOffset += this.lineWidth;
- }
-
- return rect;
- }
-
- private void drawTitles(ChartGraphics g, PerfDataPointCollection coll, Rectangle rect) {
- g.graphics.setColor(this.legendTextColor);
-
- FontMetrics metrics = g.graphics.getFontMetrics(DEFAULT_TITLE_FONT);
- int x = DEFAULT_BORDER_SIZE;
- int cyTitle = this.getTitleHeight(coll);
- int yTitle = rect.y + metrics.getAscent();
-
- String text = coll.getURL();
- if (text != null) {
- String label = m_destinationType + SEMICOLON;
- g.graphics.setFont(DEFAULT_TITLE_FONT);
- g.graphics.drawString(label, x, yTitle);
- g.graphics.setFont(DEFAULT_TITLE_TEXT_FONT);
- g.graphics.drawString(coll.getURL(), x + metrics.stringWidth(label), yTitle);
-
- yTitle += this.m_metricsLabel.getHeight();
- }
-
- String title = coll.getTypeString();
- if (title.length() > 0) {
- title += SEMICOLON;
- g.graphics.setFont(DEFAULT_TITLE_FONT);
- g.graphics.drawString(title, x, yTitle);
-
- text = coll.getTypeName();
- if (text != null) {
- g.graphics.setFont(DEFAULT_TITLE_TEXT_FONT);
- g.graphics.drawString(coll.getTypeName(), x + metrics.stringWidth(title), yTitle);
- }
-
- yTitle += this.m_metricsLabel.getHeight();
- }
-
- g.graphics.setFont(DEFAULT_TITLE_FONT);
- g.graphics.drawString(CALLS, x, yTitle);
- g.graphics.setFont(DEFAULT_TITLE_TEXT_FONT);
- g.graphics.drawString(Integer.toString(coll.getRequest()), x + metrics.stringWidth(CALLS), yTitle);
- }
-
- private void setChartProperties(Chart chart, PerfDataPointCollection coll, int chartnum, int total) {
- if (chartnum == 0) // First Chart
- {
- m_perf.showTopLabels = true;
- m_perf.showTopLegend = true;
- m_perf.showBottomLabels = false;
- m_perf.showBottomLegend = false;
- } else if (chartnum < (this.getDataSetCount() - 1)) // Middle Chart
- {
- m_perf.showTopLabels = false;
- m_perf.showTopLegend = false;
- m_perf.showBottomLabels = false;
- m_perf.showBottomLegend = false;
- } else { // Last Chart
- m_perf.showTopLabels = false;
- m_perf.showTopLegend = false;
- m_perf.showBottomLabels = true;
- m_perf.showBottomLegend = true;
- }
-
- m_perf.topBorder = this.getTitleHeight(coll);
- m_perf.leftBorder = CHART_INDENT;
- m_perf.setHealthChart(false);
- m_perf.showMinDigits = false;
- m_perf.showStacked = true;
- }
-
- @Override
- public void setFormat(MeasurementUnits units) {
- super.setFormat(units);
- m_perf.setValueLegend(m_perf.getValueLegend() + " (" + m_fmtUnits + ")");
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/Trend.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/Trend.java
deleted file mode 100644
index 0d79af7..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/Trend.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-public interface Trend {
- public static final int TREND_NONE = 0;
- public static final int TREND_DOWN = 1;
- public static final int TREND_UP = 2;
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/UsageChart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/UsageChart.java
deleted file mode 100644
index aa836c8..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/UsageChart.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-public class UsageChart extends HealthChart {
- public UsageChart(int width, int height) {
- super(width, height);
- }
-
- protected void init() {
- super.init();
-
- this.showAverage = false;
- this.showFullLabels = true;
- this.showRightLabels = false;
- this.showLeftLegend = false;
- this.showBottomLegend = false;
- this.showLow = false;
- this.showPeak = false;
-
- this.valueLines = 5;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/VerticalChart.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/VerticalChart.java
deleted file mode 100644
index 9e823a2..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/chart/VerticalChart.java
+++ /dev/null
@@ -1,459 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.chart;
-
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.core.server.MeasurementConverter;
-import org.rhq.enterprise.gui.image.data.IDataPoint;
-import org.rhq.enterprise.gui.image.data.IDisplayDataPoint;
-import org.rhq.enterprise.gui.image.data.IHighLowDataPoint;
-
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.util.Collection;
-import java.util.Iterator;
-
-public class VerticalChart extends Chart {
-
- protected static final Color[] DEFAULT_COLORS = { new Color(0x00, 0x00, 0xFF), new Color(0xFF, 0x00, 0x00),
- new Color(0xCC, 0x00, 0x99), new Color(0x9B, 0xBA, 0x70), new Color(0xFF, 0xFF, 0x33),
- new Color(0x00, 0xFF, 0x00), new Color(0x00, 0xFF, 0xFF), new Color(0xA6, 0x78, 0x38),
- new Color(0x99, 0x66, 0x99), new Color(0x74, 0x90, 0xAA), };
-
- protected static final Color GOOD_COLOR // Green
- = new Color(0x48, 0xB3, 0x68);
- protected static final Color DANGER_COLOR // Red
- = new Color(0xD5, 0x3E, 0x3E);
- protected static final Color UNKNOWN_COLOR // Grey
- = new Color(0x00, 0x00, 0xCC);
-
- private Rectangle m_rect;
- private long m_timeScale;
- private int m_cumulativeTrend = Trend.TREND_NONE;
-
- public VerticalChart() {
- super();
- init();
- }
-
- public int getCumulativeTrend() {
- return m_cumulativeTrend;
- }
-
- public void setCumulativeTrend(int trend) {
- if ((trend < Trend.TREND_NONE) || (trend > Trend.TREND_UP)) {
- throw new IllegalArgumentException("Argument must be a Cumulative type.");
- }
-
- m_cumulativeTrend = trend;
- }
-
- protected VerticalChart(int width, int height) {
- super(width, height);
- init();
- }
-
- protected VerticalChart(int charts) {
- super(charts);
- init();
- }
-
- protected VerticalChart(int width, int height, int charts) {
- super(width, height, charts);
- init();
- }
-
- protected void init() {
- this.showAverage = true;
- this.showValueLines = true;
- this.showLow = true;
- this.showPeak = true;
- }
-
- @Override
- protected Collection<DataPointCollection> initData(Collection<DataPointCollection> coll) {
-
- if (this.m_fmtUnits == MeasurementUnits.PERCENTAGE) {
- this.floor = 0;
- this.ceiling = 1;
- for (DataPointCollection dpc : coll) {
- Iterator<IDataPoint> it = dpc.iterator();
- while (it.hasNext()) {
- IDataPoint point = it.next();
- double ref;
- if (point instanceof IHighLowDataPoint) {
- ref = ((IHighLowDataPoint) point).getHighValue();
- } else
- ref = point.getValue();
- if (ref > this.ceiling)
- this.ceiling = ref;
- }
- }
- }
-
- // if ((this.m_fmtUnits == MeasurementUnits.PERCENTAGE) && ((this.m_dLowValue >= 0) && (this.m_dPeakValue <= 1))) {
- // this.floor = 0;
- // this.ceiling = 1;
- // }
-
- return coll;
- }
-
- protected Point adjustBorders(Point pt) {
- if (pt != null) {
- // Adjust to add the left and top margins to put in the interior rectangle
- pt.x += m_rect.x;
- pt.y += m_rect.y;
- }
-
- return pt;
- }
-
- @Override
- protected Rectangle adjustRectangle(Graphics2D g, Rectangle rect) {
- int cDataPts = this.getDataPoints().size();
- int spread = this.getUnitSpread(g, rect);
- rect.width = (spread * (cDataPts - 1)) + (this.valueIndent * 2) + this.lineWidth;
-
- this.m_rect = rect;
- return rect;
- }
-
- @Override
- protected Rectangle getInteriorRectangle(ChartGraphics g) {
- return m_rect;
- }
-
- @Override
- protected String[] getXLabels() {
- DataPointCollection coll = this.getDataPoints();
- int collSize = coll.size();
- String[] result = new String[collSize];
-
- for (int i = 0; i < collSize; i++) {
- IDisplayDataPoint dp = (IDisplayDataPoint) coll.get(i);
- result[i] = ScaleFormatter.formatTime(dp.getTimestamp(), this.m_timeScale, collSize);
- }
-
- return result;
- }
-
- protected int[] getXPoints(ChartGraphics g, Rectangle rect) {
- DataPointCollection coll = this.getDataPoints();
- int collSize = coll.size();
- int[] res = new int[collSize];
- int spread = this.getUnitSpread(g.graphics, this.getInteriorRectangle(g));
- int xHorzMarks = rect.x + this.valueIndent;
-
- for (int i = 0, x = xHorzMarks; i < collSize; i++, x += spread) {
- res[i] = x;
- }
-
- return res;
- }
-
- private int getUnitSpread(Graphics2D g, Rectangle rect) {
- int cDataPts = this.getDataPoints().size();
- int iSpread = rect.width - (this.valueIndent * 2);
-
- return (cDataPts > 1) ? (iSpread / (cDataPts - 1)) : iSpread;
- }
-
- @Override
- protected int getYLabelWidth(Graphics2D g) {
- int width;
- int maxWidth = 0;
-
- String[] formatted = MeasurementConverter.formatToSignificantPrecision(m_adRangeMarks, m_fmtUnits, true);
-
- for (int i = 0; i < formatted.length; i++) {
- width = this.m_metricsLabel.stringWidth(formatted[i]);
-
- if (width > maxWidth) {
- maxWidth = width;
- }
- }
-
- return maxWidth;
- }
-
- @Override
- protected Rectangle draw(ChartGraphics g) {
- ///////////////////////////////
- // Paint the chart background
-
- Rectangle rect = super.draw(g);
-
- if (this.hasData() == false) {
- return rect;
- }
-
- ///////////////////////////////////////
- // Paint the chart exterior and lines
-
- Graphics2D graph = g.graphics;
-
- // Calculate points
- double dScale = this.scale(rect.height);
-
- int x2 = rect.x + rect.width;
- int y2 = rect.y + rect.height;
-
- int yAvgLine = y2 - (int) Math.round((this.getAverageValue() - this.m_floor) * dScale);
- int yLowLine = y2 - (int) Math.round((this.getLowValue() - this.m_floor) * dScale);
- int yBaseLine = y2 - (int) Math.round((this.baseline - this.m_floor) * dScale);
- int yPeakLine = y2 - (int) Math.round((this.getPeakValue() - this.m_floor) * dScale);
-
- int yHighBottom = 0;
- if (Double.isNaN(this.highRange) == false) {
- yHighBottom = Math.min(y2 - lineWidth, y2 - (int) Math.round((this.highRange - this.m_floor) * dScale));
- }
-
- yHighBottom = Math.max(yHighBottom, rect.y);
-
- int yLowTop = 0;
- if (Double.isNaN(this.lowRange) == false) {
- yLowTop = Math.max(rect.y + lineWidth, y2 - (int) Math.round((this.lowRange - this.m_floor) * dScale));
- }
-
- yLowTop = Math.min(yLowTop, y2);
-
- int xAvgLabel = x2 - m_metricsLabel.stringWidth(Chart.AVG) - 3;
- int yAvgLabel = yAvgLine - 3;
- Rectangle avgLabel = new Rectangle();
- if (this.showAverage == true) {
- avgLabel.setRect(xAvgLabel, yAvgLabel, m_metricsLabel.stringWidth(Chart.AVG), m_metricsLabel.getHeight());
- }
-
- int xBaselineLabel = x2 - m_metricsLabel.stringWidth(Chart.BASELINE) - 4;
- int yBaselineLabel = yBaseLine - 3;
- Rectangle baselineLabel = new Rectangle();
- if (this.showBaseline == true) {
- baselineLabel.setRect(xBaselineLabel, yBaselineLabel, m_metricsLabel.stringWidth(Chart.BASELINE),
- m_metricsLabel.getHeight());
- }
-
- int xLowLabel = x2 - m_metricsLabel.stringWidth(Chart.LOW) - 4;
- int yLowLabel = yLowLine - 3;
- Rectangle lowLabel = new Rectangle();
- if (this.showLow == true) {
- lowLabel.setRect(xLowLabel, yLowLabel, m_metricsLabel.stringWidth(Chart.LOW), m_metricsLabel.getHeight());
- }
-
- int xPeakLabel = x2 - m_metricsLabel.stringWidth(Chart.PEAK) - 4;
- int yPeakLabel = yPeakLine - 3;
- Rectangle peakLabel = new Rectangle();
- if (this.showPeak == true) {
- peakLabel.setRect(xPeakLabel, yPeakLabel, m_metricsLabel.stringWidth(Chart.PEAK), m_metricsLabel
- .getHeight());
- }
-
- //////////////////////////////////////////////////////////
- // Draw the Value (Y) Legend
-
- if (this.showTopLegend == true) {
- g.drawYLegendString(this.getValueLegend());
- }
-
- //////////////////////////////////////////////////////////
- // Draw the value (Y) axis cross lines and labels
-
- String[] labels = MeasurementConverter.formatToSignificantPrecision(m_adRangeMarks, m_fmtUnits, true);
- int[] lines = new int[this.m_adRangeMarks.length];
-
- for (int i = 0; i < lines.length; i++) {
- lines[i] = rect.y + (int) Math.round((this.m_adRangeMarks[i] - this.m_floor) * dScale);
- }
-
- g.drawXLines(lines, labels, true);
-
- //////////////////////////////////////////////////////////
- // Draw the high range and low range
-
- boolean bHighLow = false;
- int cxGuide = lineWidth * 3;
- int xGuide = rect.x - cxGuide;
-
- if ((this.showHighRange == true) && (Double.isNaN(this.highRange) == false)
- && (yHighBottom > (rect.y + lineWidth))) {
- graph.setColor(this.highRangeColor);
- graph.fillRect(rect.x + lineWidth, rect.y + lineWidth, rect.width - lineWidth, yHighBottom - rect.y);
-
- graph.setColor(DANGER_COLOR);
- graph.fillRect(xGuide, rect.y + lineWidth, cxGuide, yHighBottom - rect.y);
-
- bHighLow = true;
- }
-
- if ((this.showLowRange == true) && (Double.isNaN(this.lowRange) == false) && (yLowTop < (y2 - lineWidth))) {
- graph.setColor(this.lowRangeColor);
- graph.fillRect(rect.x + lineWidth, yLowTop, rect.width - lineWidth, y2 - yLowTop);
-
- graph.setColor(DANGER_COLOR);
- graph.fillRect(xGuide, yLowTop, cxGuide, y2 - yLowTop);
-
- bHighLow = true;
- }
-
- if (bHighLow == true) {
- if (this.showHighRange == false) {
- yHighBottom = rect.y + lineWidth;
- } else {
- yHighBottom++;
- if (this.showLowRange == false) {
- yLowTop = y2;
- }
- }
-
- graph.setColor(GOOD_COLOR);
- graph.fillRect(xGuide, yHighBottom, cxGuide, yLowTop - yHighBottom);
- }
-
- //////////////////////////////////////////////////////////
- // Draw the unit (X) axis tick marks and labels
-
- lines = this.getXPoints(g, rect);
- g.drawYLines(lines, this.getXLabels(), false, xLabelsSkip);
-
- ////////////////////////////////////////////////////////////
- // Draw the Bottom Legend
-
- if (this.showBottomLegend == true) {
- g.drawXLegendString(this.getUnitLegend());
- }
-
- //////////////////////////////////////////////////////////
- // Draw the Peak, Avg and Low Lines
-
- graph.setFont(this.font);
-
- int xLast = 0;
-
- if (this.showLow == true) {
- graph.setColor(this.lowLineColor);
- graph.drawLine(this.xVertMarks, yLowLine, this.x2VertMarks, yLowLine);
- graph.drawString(Chart.LOW, xLowLabel, yLowLabel);
-
- xLast = xLowLabel;
- }
-
- if (this.showAverage == true) {
- if (avgLabel.intersects(lowLabel) == true) {
- xAvgLabel = xLast - this.m_metricsLabel.stringWidth(Chart.AVG) - this.m_metricsLabel.charWidth('W');
- }
-
- graph.setColor(this.averageLineColor);
- graph.drawLine(xVertMarks, yAvgLine, x2VertMarks, yAvgLine);
- graph.drawString(Chart.AVG, xAvgLabel, yAvgLabel);
-
- xLast = Math.min(xLast, xAvgLabel);
- }
-
- if (this.showPeak == true) {
- if ((peakLabel.intersects(lowLabel) == true) || (peakLabel.intersects(avgLabel) == true)) {
- xPeakLabel = xLast - this.m_metricsLabel.stringWidth(Chart.PEAK) - this.m_metricsLabel.charWidth('W');
- }
-
- graph.setColor(this.peakLineColor);
- graph.drawLine(xVertMarks, yPeakLine, x2VertMarks, yPeakLine);
- graph.drawString(Chart.PEAK, xPeakLabel, yPeakLabel);
-
- xLast = Math.min(xLast, xPeakLabel);
- }
-
- if ((this.showBaseline == true) && (yBaseLine > rect.y) && (yBaseLine < y2)) {
- if ((baselineLabel.intersects(lowLabel) == true) || (baselineLabel.intersects(avgLabel) == true)
- || (baselineLabel.intersects(peakLabel) == true)) {
- xBaselineLabel = xLast - this.m_metricsLabel.stringWidth(Chart.BASELINE)
- - this.m_metricsLabel.charWidth('W');
- }
-
- graph.setColor(this.baselineColor);
- graph.drawLine(xVertMarks, yBaseLine, x2VertMarks, yBaseLine);
- graph.drawString(Chart.BASELINE, xBaselineLabel, yBaselineLabel);
- }
-
- ///////////////////////////////////////////////////////////
- // Paint the chart interior
-
- if (this.showValues == true) {
- this.paint(g, rect);
- }
-
- return rect;
- }
-
- protected void paint(ChartGraphics graph, Rectangle rect) {
- // Subclasses will take care of the painting
- }
-
- protected Point getDataPoint(Rectangle rect, int datapoint) {
- return this.getDataPoint(rect, datapoint, this.getDataPoints());
- }
-
- protected Point getDataPoint(Rectangle rect, int datapoint, DataPointCollection coll) {
- Point ptResult = super.getDataPoint(rect.height, rect.width, datapoint, coll);
-
- if (ptResult != null) {
- this.adjustBorders(ptResult);
- }
-
- return ptResult;
- }
-
- protected void setTimeScale(long scale) {
- this.m_timeScale = scale;
- }
-
- protected int findDataPointIndex(long timestamp, DataPointCollection coll) {
- int collSize = coll.size();
-
- if (collSize == 0) {
- return -1;
- }
-
- long first = ((IDisplayDataPoint) coll.get(0)).getTimestamp();
-
- if (collSize == 1) {
- return ((first == timestamp) ? 0 : -1);
- }
-
- long second = ((IDisplayDataPoint) coll.get(1)).getTimestamp();
- long interval = second - first;
- long prev = first - interval;
- int index;
-
- for (index = 0; index < collSize; index++) {
- IDisplayDataPoint datapt = (IDisplayDataPoint) coll.get(index);
-
- // Break if we find what we're looking for
- if ((timestamp > prev) && (timestamp <= datapt.getTimestamp())) {
- break;
- }
-
- // Prepare for the next loop
- prev = datapt.getTimestamp();
- }
-
- // Return a index for an actual point
- return ((index == collSize) ? -1 : index);
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IComparableDatapoint.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IComparableDatapoint.java
deleted file mode 100644
index 36cb170..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IComparableDatapoint.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.data;
-
-public interface IComparableDatapoint extends Comparable, IDataPoint {
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IDataPoint.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IDataPoint.java
deleted file mode 100644
index 4a947d0..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IDataPoint.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.data;
-
-/**
- * IDataPoint is an interface that is used to allow the chart to retrieve the value and label of an individual data
- * point. For line and column charts the value is drawn on the Y axis and label is displayed on the X axis. Any that are
- * added to the chart datum collection must implement the IDataPoint interface.
- */
-public interface IDataPoint {
- /**
- * Retrieves the value of a chart data point. The label is displayed on the Y axis for line and column charts.
- *
- * @return A floating point value for a chart data point.
- */
- public double getValue();
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IDisplayDataPoint.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IDisplayDataPoint.java
deleted file mode 100644
index 7d72f32..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IDisplayDataPoint.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.data;
-
-/**
- * This interface defines APIs that are required to display a data point in the UI
- */
-public interface IDisplayDataPoint extends IDataPoint {
- /**
- * @return The absolute time of the datum, in milliseconds.
- */
- public long getTimestamp();
-
- /**
- * Retrieves the label of a chart data point. The data point is charted on the X axis for line and column charts.
- *
- * @return A String label for a chart data point.
- */
- public String getLabel();
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IHighLowDataPoint.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IHighLowDataPoint.java
deleted file mode 100644
index dedbadb..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IHighLowDataPoint.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.data;
-
-/**
- * IHighLowDataPoint is an interface that is used to allow the chart to retrieve the high value and low value of an
- * individual data point. This interface extends IStackedDataPoint and must implement the getValues() method from that
- * interface by returning an array of three double values with the high, low and average. The values can be placed in
- * the array in any order. IStackedDataPoint extends the IDisplayDataPoint interface. The getValue method from that
- * interface should return the average value for the HighLow chart.
- *
- * @see org.rhq.enterprise.gui.image.data.IDisplayDataPoint
- * @see org.rhq.enterprise.gui.image.data.IStackedDataPoint
- */
-public interface IHighLowDataPoint extends IStackedDataPoint {
- /**
- * Retrieves the high value of a chart data point.
- *
- * @return A floating point value for a chart data point.
- */
- public double getHighValue();
-
- /**
- * Retrieves the low value of a chart data point.
- *
- * @return A floating point value for a chart data point.
- */
- public double getLowValue();
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IResourceTreeNode.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IResourceTreeNode.java
deleted file mode 100644
index e441a51..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IResourceTreeNode.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.data;
-
-public interface IResourceTreeNode extends ITreeNode {
- public static final int NONE = 0;
- public static final int RESOURCE = 1;
- public static final int AUTO_GROUP = 2;
- public static final int CLUSTER = 3;
-
- public int getType();
-}
-
-// EOF
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IStackedDataPoint.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IStackedDataPoint.java
deleted file mode 100644
index 7c81e58..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/IStackedDataPoint.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.data;
-
-/**
- * IStackedDataPoint is an interface that is used to allow the chart to retrieve multiple values for per column in a
- * stacked column chart. This interface is a sub-interface of the IDisplayDataPoint interface. The getValue member
- * should return the sum of all of the values in the stack.
- */
-public interface IStackedDataPoint extends IDisplayDataPoint {
- /**
- * Retrieves the value of a chart data point. The label is displayed on the X axis for stacked performance charts.
- *
- * @return A floating point value for a chart data point.
- */
- public double[] getValues();
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/ITreeNode.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/ITreeNode.java
deleted file mode 100644
index b7e0d80..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/data/ITreeNode.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.data;
-
-import java.awt.Rectangle;
-
-public interface ITreeNode {
- public void addRectangle(int x, int y, int cx, int cy);
-
- public String getDescription();
-
- public ITreeNode[] getDownChildren();
-
- public String getName();
-
- public Rectangle[] getRectangles();
-
- public ITreeNode[] getUpChildren();
-
- public boolean hasDownChildren();
-
- public boolean hasUpChildren();
-
- public boolean isSelected();
-
- public void reset();
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/AvailabilityReport.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/AvailabilityReport.java
deleted file mode 100644
index d6ff5fa..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/AvailabilityReport.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.widget;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.NumberFormat;
-import org.rhq.enterprise.gui.image.ImageUtil;
-import org.rhq.enterprise.gui.image.WebImage;
-
-public class AvailabilityReport extends WebImage {
- private static int CIRCLE_SIZE = 11;
-
- private static BufferedImage GOOD_CIRCLE;
- private static BufferedImage DANGER_CIRCLE;
- private static BufferedImage UNKNOWN_CIRCLE;
-
- private static final Font FONT = new Font("sansserif.plain", Font.PLAIN, 10);
- private static final Color COLOR_TRANSPARENT = new Color(0x3, 0x3, 0x3);
-
- private static final String LARGEST_NUMBER = "999";
-
- private static final int TEXT_BUFFER = 2;
- private static final int SET_BUFFER = 5;
-
- private static final int CIRCLE_WITH_BUFFER_WIDTH;
- private static final int STANDARD_SET_WIDTH;
- private static final int IMAGE_WIDTH;
-
- /////////////////////////////////////////////
- // Public Properties
-
- /**
- * Number of Available Resources
- */
- public int Available;
-
- /**
- * Number of Unavailable Resources
- */
- public int Unavailable;
-
- /**
- * Number of Unknown Resources
- */
- public int Unknown;
-
- /////////////////////////////////////////////
- // Static constructors
-
- static {
- // Load Images
- InputStream i;
-
- try {
- GOOD_CIRCLE = ImageUtil.loadImage("images/icon_available_green.gif");
- DANGER_CIRCLE = ImageUtil.loadImage("images/icon_available_red.gif");
- UNKNOWN_CIRCLE = ImageUtil.loadImage("images/icon_available_error.gif");
- } catch (IOException e) {
- System.out.println(e);
- }
-
- CIRCLE_WITH_BUFFER_WIDTH = GOOD_CIRCLE.getWidth() + TEXT_BUFFER;
- STANDARD_SET_WIDTH = CIRCLE_WITH_BUFFER_WIDTH + DEFAULT_FONT_METRICS.stringWidth(LARGEST_NUMBER) + SET_BUFFER;
- IMAGE_WIDTH = (STANDARD_SET_WIDTH * 3) - SET_BUFFER;
- }
-
- //////////////////////////////////////////////
- // Object Constructors
-
- public AvailabilityReport() {
- super(IMAGE_WIDTH, GOOD_CIRCLE.getHeight());
- this.antiAliased = false;
- this.indexColors = true;
- }
-
- //////////////////////////////////////////////
- // Methods
-
- protected void draw(Graphics2D g) {
- int x = 0;
- int yCircle = 0;
- int y2Circle = CIRCLE_SIZE - 1;
- String text;
-
- g.setPaint(COLOR_TRANSPARENT);
- g.fillRect(0, 0, this.width, this.height);
-
- NumberFormat fmt = NumberFormat.getInstance();
- fmt.setMaximumFractionDigits(0);
-
- g.setColor(this.textColor);
- g.setFont(FONT);
-
- if (this.Available > 0) {
- text = fmt.format(this.Available);
- g.drawImage(GOOD_CIRCLE, 0, yCircle, COLOR_TRANSPARENT, null);
- g.drawString(text, CIRCLE_WITH_BUFFER_WIDTH, y2Circle);
- }
-
- if (this.Unavailable > 0) {
- text = fmt.format(this.Unavailable);
- g.drawImage(DANGER_CIRCLE, STANDARD_SET_WIDTH, yCircle, COLOR_TRANSPARENT, null);
- g.drawString(text, STANDARD_SET_WIDTH + CIRCLE_WITH_BUFFER_WIDTH, y2Circle);
- }
-
- if (this.Unknown > 0) {
- text = fmt.format(this.Unknown);
- g.drawImage(UNKNOWN_CIRCLE, STANDARD_SET_WIDTH * 2, yCircle, COLOR_TRANSPARENT, null);
- g.drawString(text, (STANDARD_SET_WIDTH * 2) + CIRCLE_WITH_BUFFER_WIDTH, y2Circle);
- }
- }
-
- // protected IndexColorModel getIndexColorModel() {
- // IndexColorModel cm = super.getIndexColorModel();
- // ImageUtil.getColors(DANGER_CIRCLE);
- // return ImageUtil.getTransparentColorModel(cm, COLOR_TRANSPARENT);
- // }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/ResourceTree.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/ResourceTree.java
deleted file mode 100644
index 54f6579..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/ResourceTree.java
+++ /dev/null
@@ -1,879 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.widget;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics2D;
-import java.awt.Rectangle;
-import java.awt.Stroke;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Vector;
-import org.rhq.enterprise.gui.image.ImageUtil;
-import org.rhq.enterprise.gui.image.Line;
-import org.rhq.enterprise.gui.image.WebImage;
-import org.rhq.enterprise.gui.image.data.IResourceTreeNode;
-import org.rhq.enterprise.gui.image.data.ITreeNode;
-
-public class ResourceTree extends WebImage {
- //******** Private Static Variables *********
- private static final int NODE_WHITESPACE = 10;
- private static final int ICON_WHITESPACE = 2;
- private static final int LEVEL_WHITESPACE = 14;
- private static final int LEVEL_DESCENT = (LEVEL_WHITESPACE / 2);
- private static final int LEVEL_INDENT = 0; //(NODE_WHITESPACE / 2);
-
- private static final int THIN_LINE = 1;
- private static final int THICK_LINE = 2;
-
- private static int ICON_HEIGHT; // Set in static constructor
- private static int ICON_WIDTH; // Set in static constructor
-
- private static BufferedImage IMG_RESOURCE;
- private static BufferedImage IMG_AUTO_GROUP;
- private static BufferedImage IMG_CLUSTER;
-
- //******** Protected Static Variables *******
- protected static final Font NAME_FONT = new Font(DEFAULT_BOLD_TYPEFACE, Font.BOLD, 11);
- protected static final Font DESC_FONT = new Font(DEFAULT_PLAIN_TYPEFACE, Font.PLAIN, 8);
- protected static final Font SELECTED_FONT = new Font(DEFAULT_BOLD_TYPEFACE, Font.BOLD, 11);
-
- protected static final Color NAME_COLOR = new Color(0x00, 0x31, 0x9C);
- protected static final Color DESC_COLOR = Color.BLACK;
- protected static final Color LINE_COLOR = new Color(0x90, 0x90, 0x90); //Color(0x80, 0x80, 0x80);
- protected static final Color SOFT_LINE_COLOR = new Color(0xC0, 0xC0, 0xC0);
- protected static final Color SELECTED_COLOR = new Color(0xDE, 0x65, 0x2D);
- protected static final Color TRANSPARENT_COLOR = new Color(3, 3, 3);
-
- protected static final Stroke LINE_STROKE = new BasicStroke(THICK_LINE, BasicStroke.CAP_BUTT,
- BasicStroke.JOIN_MITER);
-
- //******** Private Instance Variables *******
- private FontMetrics m_nameMetrics; // Set in preInit()
- private FontMetrics m_descMetrics; // Set in preInit()
-
- private Vector m_root = new Vector();
- private Vector m_lines = new Vector();
-
- private Dimension m_imageSize = new Dimension();
- private int m_yDividerLine;
-
- //************** Test Variables **************
- // Change the next line assigned from null to the
- // vector to get debug whitespace rectangles.
- private Vector m_testRects = null; //new Vector();
-
- //************* Static Constructor ***********
- static {
- try {
- IMG_RESOURCE = ImageUtil.loadImage("images/icon_resource.gif");
- IMG_AUTO_GROUP = ImageUtil.loadImage("images/icon_auto-group.gif");
- IMG_CLUSTER = ImageUtil.loadImage("images/icon_cluster.gif");
-
- ICON_HEIGHT = IMG_CLUSTER.getHeight();
- ICON_WIDTH = IMG_CLUSTER.getWidth();
- } catch (IOException e) {
- System.out.println(e);
- }
- }
-
- //*************** Constructors **************
- public ResourceTree(int width) {
- super(width, 1);
- }
-
- public ResourceTree(int width, int height) {
- super(width, height);
- }
-
- //************* Public Methods **************
- public void addLevel(IResourceTreeNode[] resources) {
- m_root.add(resources);
- }
-
- public Dimension getImageSize() {
- return m_imageSize;
- }
-
- public IResourceTreeNode[][] getLevels() {
- IResourceTreeNode[][] levels = new IResourceTreeNode[m_root.size()][];
- for (int i = 0; i < levels.length; ++i) {
- levels[i] = (IResourceTreeNode[]) m_root.get(i);
- }
-
- return levels;
- }
-
- public void calculateCoordinates() {
- this.calcTree();
- }
-
- public void reset() {
- this.m_imageSize.setSize(0, 0);
-
- Iterator iter = m_root.iterator();
- while (iter.hasNext() == true) {
- ITreeNode[] nodes = (ITreeNode[]) iter.next();
- this.resetNodes(nodes);
- }
-
- this.m_lines.clear();
- }
-
- private void resetNodes(ITreeNode[] nodes) {
- if (nodes == null) {
- throw new IllegalArgumentException("The \'nodes\' argument cannot be null");
- }
-
- for (int i = 0; i < nodes.length; i++) {
- ITreeNode node = nodes[i];
- node.reset();
-
- if (node.hasUpChildren() == true) {
- this.resetNodes(node.getUpChildren());
- }
-
- if (node.hasDownChildren() == true) {
- this.resetNodes(node.getDownChildren());
- }
- }
- }
-
- public String toString() {
- StringBuffer res = new StringBuffer();
-
- res.append(this.getClass().getName()).append('[').append("Nodes=").append(m_root).append(',').append("Lines=")
- .append(m_lines).append(',').append("Size=").append(m_imageSize).append(',').append("Divider=").append(
- m_yDividerLine).append(']');
-
- return res.toString();
- }
-
- //*********** Protected Methods *************
- protected void addTestRect(Rectangle rect) {
- if (m_testRects != null) {
- m_testRects.add(new Rectangle(rect));
- }
- }
-
- protected void draw(Graphics2D g) {
- super.draw(g);
-
- // g.setPaint(TRANSPARENT_COLOR);
- // g.fillRect(0, 0, this.getWidth(), this.getHeight());
-
- this.drawLines(g);
- this.drawNodes(g);
- }
-
- protected void postInit(Graphics2D g) {
- this.font = NAME_FONT;
- this.textColor = NAME_COLOR;
- }
-
- protected void preInit() {
- this.frameImage = true;
- this.setBorder(7);
-
- BufferedImage im = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
- Graphics2D g = (Graphics2D) im.getGraphics();
-
- m_nameMetrics = g.getFontMetrics(NAME_FONT);
- m_descMetrics = g.getFontMetrics(DESC_FONT);
-
- g.dispose();
- im.flush();
-
- Rectangle imageSize = this.calcTree();
- if (imageSize != null) {
- // if the tree is non-existent, let's avoid an IllegalArgumentException
- if (imageSize.width <= 0) {
- imageSize.width = 1;
- }
-
- if (imageSize.height <= 0) {
- imageSize.height = 1;
- }
-
- this.width = imageSize.width;
- this.height = imageSize.height;
- }
- }
-
- //*********** Private Methods ***************
- private Rectangle calcTree() {
- if (m_imageSize.width != 0) {
- return null;
- }
-
- int xLevelLine = 0;
- int yLevelLine = this.topBorder;
- int yFirstLevel = 0;
- int cyLastLevel = 0;
- int cxBorder = this.leftBorder + this.rightBorder;
- int[] x = null;
- int[] y = null;
- int level;
- CalcResult childResult = null;
- IResourceTreeNode selected = null;
-
- // Width and height of the entire image
- Rectangle result = new Rectangle(0, 0, cxBorder, this.topBorder + this.bottomBorder);
-
- m_lines.clear();
-
- boolean topImage = m_root.size() > 1;
-
- if ((topImage == false) && (m_root.size() > 0)) {
- ITreeNode[] nodes = (ITreeNode[]) m_root.get(0);
-
- topImage = ((nodes.length > 1) || ((nodes[0].hasDownChildren() == false) && (nodes[0].hasUpChildren() == false)));
- }
-
- // Draw top image
- if (topImage == true) {
- Iterator iter = m_root.iterator();
- for (level = 0; iter.hasNext() == true; level++) {
- IResourceTreeNode[] nodes = (IResourceTreeNode[]) iter.next();
- xLevelLine = this.leftBorder + (LEVEL_INDENT * level);
- yLevelLine = yLevelLine + cyLastLevel;
-
- childResult = this.calcDownChildren(nodes, new Rectangle(xLevelLine, yLevelLine, this.width, 0));
- this.addTestRect(childResult.bounding);
-
- if (selected == null) {
- selected = childResult.selected;
- }
-
- cyLastLevel = childResult.bounding.height + LEVEL_DESCENT;
- ;
-
- result.height += cyLastLevel;
- result.width = Math.max(result.width, childResult.bounding.width + cxBorder);
-
- if (level == 0) {
- yFirstLevel = childResult.yLevelLine;
- }
- }
-
- if (level > 1) {
- m_lines.add(new Line(this.leftBorder, yFirstLevel - 1, xLevelLine, childResult.yLevelLine + 1));
- }
- } else if (m_root.size() > 0) {
- selected = ((IResourceTreeNode[]) m_root.get(0))[0];
- }
-
- // Draw bottom image
- if ((selected != null) && ((selected.hasDownChildren() == true) || (selected.hasUpChildren() == true))) {
- Rectangle boundry = new Rectangle();
- boundry.x = this.leftBorder;
- boundry.y = this.topBorder + ((topImage == true) ? (yLevelLine + cyLastLevel) : 0);
- boundry.width = this.width;
-
- // Add horizontal line
- if (topImage == true) {
- m_yDividerLine = boundry.y - LEVEL_DESCENT;
- result.height += LEVEL_DESCENT;
- }
-
- childResult = this.calcNodeTree(selected, boundry);
- this.addTestRect(childResult.bounding);
-
- result.height += childResult.bounding.height;
- result.width = Math.max(result.width, childResult.bounding.width + cxBorder);
- } else {
- // Remove the level that was added for whitespace between the top
- // and bottom image.
- result.height -= LEVEL_DESCENT;
- ;
- }
-
- // Get rid of the bottom line descent so that the top and bottom borders
- // look the same size.
- result.height -= this.m_descMetrics.getDescent();
- m_imageSize.width = result.width;
- m_imageSize.height = result.height;
-
- return result;
- }
-
- private CalcResult calcNodeTree(IResourceTreeNode node, Rectangle boundry) {
- CalcResult result = null;
- Rectangle nodeRect;
- int x;
- int y;
-
- int type = node.getType();
-
- if ((type == IResourceTreeNode.AUTO_GROUP) || (type == IResourceTreeNode.CLUSTER)) {
- Rectangle parentRect = null;
-
- // Draw the parent node for the group if we have it
- if (node.hasUpChildren() == true) {
- parentRect = this.calcNode((IResourceTreeNode) node.getUpChildren()[0], boundry.x, boundry.y);
-
- boundry.y += (parentRect.height );
- boundry.grow(0, -LEVEL_DESCENT);
-
- // result.width += nodeRect.width;
- }
-
- // Draw the selected node
- nodeRect = this.calcNode(node, boundry.x, boundry.y);
- this.addTestRect(nodeRect);
-
- x = boundry.x + (ICON_WIDTH / 2);
- y = boundry.y + (ICON_HEIGHT / 2);
-
- // Add the line from the parent node to this node if there is a
- // parent node
- if (parentRect != null) {
- m_lines.add(new Line(parentRect.x + (ICON_WIDTH / 2), parentRect.y + (ICON_HEIGHT / 2), x, y));
- }
-
- // Add the lines for this node
- m_lines.add(new Line(x, y, x, boundry.y + (LEVEL_WHITESPACE * 2) + 12));
-
- y = nodeRect.y + nodeRect.height + 3;
-
- m_lines.add(new Line(x, y, x + (NODE_WHITESPACE * 2), y));
-
- boundry.grow(-NODE_WHITESPACE, 0);
- boundry.y = nodeRect.y + nodeRect.height + LEVEL_DESCENT;
-
- // Draw the down children
- result = this.calcChildren((IResourceTreeNode[]) node.getDownChildren(), boundry, true, false, true);
- this.addTestRect(result.bounding);
-
- result.bounding.width = Math.max(result.bounding.width + ICON_WIDTH, nodeRect.width);
- result.bounding.height += nodeRect.height + LEVEL_DESCENT;
-
- if (parentRect != null) {
- result.bounding.height += (parentRect.height + LEVEL_DESCENT);
- }
- } else {
- IResourceTreeNode[] children;
-
- // Calculate Up Children
- children = (IResourceTreeNode[]) node.getUpChildren();
-
- if ((children != null) && (children.length > 0)) {
- boundry.grow(-NODE_WHITESPACE, 0);
- result = this.calcUpChildren(children, boundry);
- this.addTestRect(result.bounding);
-
- result.bounding.height += LEVEL_DESCENT;
-
- boundry.x -= NODE_WHITESPACE;
- boundry.y += result.bounding.height;
- result.bounding.x -= NODE_WHITESPACE;
- result.bounding.width += NODE_WHITESPACE;
- }
-
- // Calc Node
- nodeRect = this.calcNode(node, boundry.x, boundry.y);
- this.addTestRect(nodeRect);
-
- if (result != null) {
- if (nodeRect.width > result.bounding.width) {
- result.bounding.width += (nodeRect.width - result.bounding.width);
- }
-
- m_lines.add(new Line(nodeRect.x + (ICON_WIDTH / 2) + 1, nodeRect.y + (ICON_HEIGHT / 2), nodeRect.x
- + NODE_WHITESPACE + 1, result.yLevelLine));
- } else {
- result = new CalcResult();
- result.bounding = new Rectangle();
- result.bounding.width += nodeRect.width;
- result.selected = node;
- }
-
- // Calculate Down Children
- children = (IResourceTreeNode[]) node.getDownChildren();
-
- if ((children != null) && (children.length > 0)) {
- boundry.grow(-NODE_WHITESPACE, 0);
- boundry.y += nodeRect.height + LEVEL_DESCENT;
-
- CalcResult downResult = this.calcDownChildren(children, boundry);
- this.addTestRect(downResult.bounding);
-
- m_lines.add(new Line(nodeRect.x + (ICON_WIDTH / 2) + 1, nodeRect.y + (ICON_HEIGHT / 2), nodeRect.x
- + NODE_WHITESPACE + 1, downResult.yLevelLine));
-
- if (result != null) {
- result.bounding.height += downResult.bounding.height;
- if (downResult.bounding.width > result.bounding.width) {
- result.bounding.width = downResult.bounding.width + downResult.bounding.x - nodeRect.x;
- }
-
- // Look for children attached to children if there is only
- // one child at the initial level.
- if (children.length == 1) {
- IResourceTreeNode[] down = (IResourceTreeNode[]) children[0].getDownChildren();
-
- if ((down != null) && (down.length > 0)) {
- boundry.grow(-(NODE_WHITESPACE * 2), -(downResult.bounding.height + LEVEL_DESCENT));
-
- downResult = this.calcDownChildren((IResourceTreeNode[]) down, boundry);
- this.addTestRect(downResult.bounding);
-
- Rectangle[] rects = children[0].getRectangles();
- nodeRect = rects[rects.length - 1];
-
- m_lines.add(new Line(nodeRect.x + (ICON_WIDTH / 2) + 1, nodeRect.y + (ICON_HEIGHT / 2) + 1,
- nodeRect.x + NODE_WHITESPACE + 1, downResult.yLevelLine + 1));
-
- result.bounding.height += downResult.bounding.height + LEVEL_DESCENT;
- if (downResult.bounding.width > result.bounding.width) {
- result.bounding.width = downResult.bounding.width + (NODE_WHITESPACE * 3);
- }
- }
- }
- } else {
- result = downResult;
- }
-
- result.bounding.height += LEVEL_DESCENT;
- }
-
- // Add height of selected node to the result height
- result.bounding.height += nodeRect.height;
- }
-
- return result;
- }
-
- private CalcResult calcChildren(IResourceTreeNode[] nodes, Rectangle boundry, boolean wrap, boolean calcLines,
- boolean down) {
- int yHorzLine;
- int xNode = 0;
- int yNode = 0;
- int cxLastNode = 0;
- int cyTallestNode = 0;
- int xLevelLine = boundry.x;
- int yLevelLine = boundry.y;
- int wrapLevel;
- int xFirstNode = 0;
- int yFirstNode = 0;
- int xLastNode = 0;
- int yLastNode = 0;
- int nodeIndex = 0;
- int lastWrapIndex = 0;
-
- Rectangle nodeRect = null;
- IResourceTreeNode node = null;
-
- CalcResult result = new CalcResult();
- result.bounding = new Rectangle(boundry.x, boundry.y, 0, 0);
-
- FontMetrics nameMetrics = this.getFontMetrics();
- Rectangle[] rects = new Rectangle[nodes.length];
- Vector levelLines = new Vector();
-
- for (wrapLevel = ((wrap == true) ? 1 : 0); nodeIndex < nodes.length; wrapLevel++) {
- if (down == true) {
- yHorzLine = (wrapLevel > 1) ? (yLastNode + cyTallestNode + LEVEL_DESCENT) : yLevelLine;
- } else {
- yHorzLine = (wrapLevel > 1) ? (yLastNode - cyTallestNode - LEVEL_WHITESPACE - LEVEL_DESCENT)
- : yLevelLine;
- }
-
- xNode = xLevelLine;
- if (calcLines == true) {
- xNode += NODE_WHITESPACE;
- }
-
- // Calc Level and Node Position
- if (nodes.length == 1) {
- yNode = yHorzLine;
- if (down == false) {
- yNode += LEVEL_DESCENT;
- }
-
- yHorzLine += ICON_HEIGHT / 2;
-
- if (wrapLevel == 0) {
- xNode -= ICON_WHITESPACE;
- yLevelLine = yHorzLine;
- }
- } else {
- yNode = yHorzLine + ((calcLines == true) ? LEVEL_DESCENT : 0);
- }
-
- // Reset the last node height for the level to zero
- cyTallestNode = 0;
-
- int levelStart;
- for (levelStart = nodeIndex; nodeIndex < nodes.length; nodeIndex++) {
- node = nodes[nodeIndex];
-
- // Set the selected parameter
- if (node.isSelected() == true) {
- if (result.selected == null) {
- result.selected = node;
- }
- }
-
- nodeRect = this.calcNode(node, xNode, yNode, false);
- //this.addTestRect(nodeRect);
-
- // Add the rect to an array to set after the loop. This allows
- // us to set the node rects transactionally.
- rects[nodeIndex] = nodeRect;
-
- // Determine if the node can fit in the image width. If not,
- // we should wrap the node to the next line, unless it also
- // won't fit on the next line. If it can't fit on this line
- // or the next line then the right side is cutoff.
- if (((nodeRect.x + nodeRect.width) > (boundry.x + boundry.width)) && (nodeIndex != lastWrapIndex)) {
- // If we didn't already know we need to wrap, then we must
- // start all over again because the wrapping has a differnt
- // layout.
- if (wrap == false) {
- boundry.grow(-NODE_WHITESPACE, 0);
- result = this.calcChildren(nodes, boundry, true, true, down);
- boundry.grow(NODE_WHITESPACE, 0);
- return result;
- }
-
- // If we knew then we calculate this node again on a new
- // line. The break will automatically start a new line.
- lastWrapIndex = nodeIndex;
- break;
- }
-
- // Keep track of the height of the talest node
- cxLastNode = nodeRect.width;
- cyTallestNode = Math.max(cyTallestNode, nodeRect.height);
-
- // Setup for the next node
- if (nodeIndex == 0) {
- xFirstNode = xNode;
- yFirstNode = yNode;
- }
-
- xLastNode = xNode;
- yLastNode = yNode;
-
- xNode += (nodeRect.width + NODE_WHITESPACE);
- }
-
- // Swap the nodes left to right
- if (down == false) {
- this.swapNodes(rects, levelStart, nodeIndex - 1);
- }
-
- // Add Horizontal Level Line
- if (calcLines == true) {
- Line line = new Line();
- line.x1 = xLevelLine - ((wrapLevel == 1) ? NODE_WHITESPACE : 0);
- line.y1 = yHorzLine;
-
- if (nodes.length > 1) {
- line.x2 = ((down == true) ? xLastNode : rects[levelStart].x) - (NODE_WHITESPACE / 2)
- + (ICON_WIDTH / 2) + 1;
- } else {
- line.x2 = xLastNode + (ICON_WIDTH / 2);
- }
-
- levelLines.add(line);
- }
-
- // Update the tree width
- result.bounding.width = Math.max(result.bounding.width, xLastNode - xLevelLine + cxLastNode
- + ((wrapLevel == 1) ? NODE_WHITESPACE : 0));
- result.bounding.height += ((nodeIndex <= 1) && (wrap == false)) ? nodeRect.height
- : (nodeRect.height + ((calcLines == true) ? LEVEL_DESCENT : 0));
- }
-
- if (--wrapLevel == 0) {
- wrapLevel = 1;
- }
-
- // Set all the node rectangles, transactionally
- for (int i = 0; i < nodes.length; i++) {
- Rectangle rect = rects[i];
-
- if (down == false) {
- if (wrap == true) {
- rect.y += ((cyTallestNode + LEVEL_WHITESPACE) * (wrapLevel - 1)) - LEVEL_DESCENT;
- } else {
- rect.y -= LEVEL_DESCENT;
- }
- }
-
- nodes[i].addRectangle(rect.x, rect.y, rect.width, rect.height);
- this.addTestRect(rect);
- }
-
- // Set all the level lines
- Line line = null;
- Iterator iter = levelLines.iterator();
- for (int i = 0; iter.hasNext() == true; i++) {
- line = (Line) iter.next();
-
- if ((down == false) && (nodes.length > 1)) {
- line.y1 += (((cyTallestNode + LEVEL_WHITESPACE) * wrapLevel) - LEVEL_DESCENT);
- }
-
- line.y2 = line.y1;
- m_lines.add(line);
-
- if (i == 0) {
- result.yLevelLine = line.y1;
- }
- }
-
- // Add wrap line if necessary
- if ((calcLines == true) && (wrapLevel >= 1)) {
- m_lines.add(new Line(xLevelLine + 1, result.yLevelLine, xLevelLine + 1, line.y1));
- }
-
- // Add Node Lines
- if ((calcLines == true) && (nodes.length > 1)) {
- for (int i = 0; i < rects.length; i++) {
- Rectangle rect = rects[i];
-
- line = new Line();
- line.x1 = rect.x;
- line.y2 = rect.y + 2;
-
- if (down == true) {
- line.y1 = rect.y - LEVEL_DESCENT;
- line.x2 = rect.x + (ICON_WIDTH / 2) - 1;
- } else {
- line.y1 = rect.y + LEVEL_DESCENT + rect.height;
- line.x2 = rect.x + (ICON_WIDTH / 2) + 1;
- }
-
- m_lines.add(line);
- }
- }
-
- // Update the tree width and height
- if (calcLines == false) {
- result.bounding.width -= NODE_WHITESPACE;
- }
-
- if (wrapLevel > 0) {
- result.bounding.height += (wrapLevel - 1) * LEVEL_DESCENT;
- }
-
- return result;
- }
-
- private CalcResult calcDownChildren(IResourceTreeNode[] nodes, Rectangle boundry) {
- return this.calcChildren(nodes, boundry, false, true, true);
- }
-
- private CalcResult calcUpChildren(IResourceTreeNode[] nodes, Rectangle boundry) {
- return this.calcChildren(nodes, boundry, false, true, false);
- }
-
- private Rectangle calcNode(IResourceTreeNode node, int x, int y) {
- return this.calcNode(node, x, y, true);
- }
-
- private Rectangle calcNode(IResourceTreeNode node, int x, int y, boolean set) {
- int cxImg;
- int cyImg;
- int cxNode;
- int cyNode;
-
- String name = node.getName();
- String desc = node.getDescription();
- BufferedImage img = getIcon(node.getType());
-
- cxImg = (img != null) ? ICON_WIDTH : 0;
- cyImg = (img != null) ? ICON_HEIGHT : 0;
-
- // Calc Node Width
- int cxName = (name != null) ? m_nameMetrics.stringWidth(name) : 0;
- int cxDesc = (desc != null) ? m_descMetrics.stringWidth(desc) : 0;
- cxNode = Math.max(cxName, cxDesc);
- cxNode += (cxImg + ICON_WHITESPACE);
-
- // Calc Node Height
- cyNode = (name != null) ? m_nameMetrics.getAscent() : 0;
- cyNode += (desc != null) ? m_descMetrics.getAscent() : 0;
-
- // Save the Node Rectangle for anyone interested in creating
- // an image map on top of this image
- if (set == true) {
- node.addRectangle(x, y, cxNode, cyNode);
- }
-
- return new Rectangle(x, y, cxNode, cyNode);
- }
-
- private void drawLines(Graphics2D g) {
- Stroke strokeOrig = g.getStroke();
- g.setStroke(LINE_STROKE);
- g.setColor(LINE_COLOR);
-
- Iterator iter = m_lines.iterator();
-
- while (iter.hasNext() == true) {
- Line line = (Line) iter.next();
- g.drawLine(line.x1, line.y1, line.x2, line.y2);
- }
-
- g.setStroke(strokeOrig);
- }
-
- private void drawNodes(Graphics2D g) {
- Iterator iter = m_root.iterator();
- while (iter.hasNext() == true) {
- IResourceTreeNode[] nodes = (IResourceTreeNode[]) iter.next();
- this.drawNodes(g, nodes, NAME_FONT);
- }
- }
-
- private void drawNodes(Graphics2D g, IResourceTreeNode[] nodes, Font nameFont) {
- int cyAscent = g.getFontMetrics(nameFont).getAscent();
-
- for (int i = 0; i < nodes.length; i++) {
- IResourceTreeNode node = nodes[i];
-
- String name = node.getName();
- String desc = node.getDescription();
- BufferedImage img = getIcon(node.getType());
- Rectangle[] rects = node.getRectangles();
-
- if (rects == null) {
- continue;
- }
-
- for (int r = 0; r < rects.length; r++) {
- Rectangle rect = rects[r];
-
- int xText = rect.x + ICON_WHITESPACE;
- int yText = rect.y + cyAscent - 3;
-
- if (img != null) {
- g.drawImage(img, rect.x, rect.y, null);
- xText += img.getWidth();
- }
-
- if (name != null) {
- g.setColor((node.isSelected() == true) ? SELECTED_COLOR : this.textColor);
- g.setFont((node.isSelected() == true) ? SELECTED_FONT : nameFont);
- g.drawString(name, xText, yText);
- }
-
- if (desc != null) {
- g.setColor(DESC_COLOR);
- g.setFont(DESC_FONT);
- g.drawString(desc, xText, yText + m_descMetrics.getAscent());
- }
- }
-
- if (m_yDividerLine > 0) {
- g.setColor(DEFAULT_BORDER_COLOR);
- g.drawLine(0, m_yDividerLine, this.width - 1, m_yDividerLine);
- }
-
- if (node.hasUpChildren() == true) {
- this.drawNodes(g, (IResourceTreeNode[]) node.getUpChildren(), NAME_FONT);
- }
-
- if (node.hasDownChildren() == true) {
- this.drawNodes(g, (IResourceTreeNode[]) node.getDownChildren(), NAME_FONT);
- }
-
- // Draw test rectangles if they're turned on
- if (m_testRects != null) {
- g.setColor(DEFAULT_BORDER_COLOR);
-
- Iterator iter = m_testRects.iterator();
- while (iter.hasNext() == true) {
- Rectangle rect = (Rectangle) iter.next();
- g.drawRect(rect.x, rect.y, rect.width, rect.height);
- }
- }
- }
- }
-
- private IResourceTreeNode getNodeWithUpChildren(IResourceTreeNode[] nodes) {
- IResourceTreeNode result = null;
-
- for (int i = 0; i < nodes.length; i++) {
- if (nodes[i].hasUpChildren() == true) {
- result = nodes[i];
- }
- }
-
- return result;
- }
-
- private void swapNodes(Rectangle[] rects, int start, int end) {
- if (((end - start) < 1) || (rects.length <= 1)) {
- return;
- }
-
- int x = rects[start].x;
- int space = rects[start + 1].x - (x + rects[start].width);
-
- for (int i = end; i >= start; i--) {
- rects[i].x = x;
- x += (rects[i].width + space);
- }
- }
-
- //*********** Static Methods ****************
- public static BufferedImage getIcon(int type) {
- BufferedImage result;
-
- switch (type) {
- case IResourceTreeNode.RESOURCE: {
- result = IMG_RESOURCE;
- break;
- }
-
- case IResourceTreeNode.AUTO_GROUP: {
- result = IMG_AUTO_GROUP;
- break;
- }
-
- case IResourceTreeNode.CLUSTER: {
- result = IMG_CLUSTER;
- break;
- }
-
- default: {
- result = null;
- }
- }
-
- return result;
- }
-
- //*********** Inner Classes *****************
- private class CalcResult {
- private Rectangle bounding;
- private IResourceTreeNode selected;
- private int yLevelLine;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/ResourceTreeNode.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/ResourceTreeNode.java
deleted file mode 100644
index c04c445..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/ResourceTreeNode.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.widget;
-
-import org.rhq.enterprise.gui.image.data.IResourceTreeNode;
-import org.rhq.enterprise.gui.image.data.ITreeNode;
-
-public class ResourceTreeNode extends TreeNode implements IResourceTreeNode {
- private int m_type;
-
- //**************** Constructors *************
- public ResourceTreeNode(String name, String desc) {
- this(name, desc, false, NONE);
- }
-
- public ResourceTreeNode(String name, int type) {
- this(name, null, false, type);
- }
-
- public ResourceTreeNode(String name, String desc, int type) {
- this(name, desc, false, type);
- }
-
- public ResourceTreeNode(String name, String desc, boolean selected) {
- this(name, desc, selected, NONE);
- }
-
- public ResourceTreeNode(String name, String desc, boolean selected, int type) {
- super(name, desc, selected);
-
- if (this.isValidType(type) == false) {
- throw new IllegalArgumentException("Invalid Type: " + type);
- }
-
- m_type = type;
- }
-
- //************ ITreeNode Methods ************
- /**
- * @see org.rhq.enterprise.gui.image.data.ITreeNode#getUpChildren()
- */
- public ITreeNode[] getUpChildren() {
- return (IResourceTreeNode[]) m_upChildren.toArray(new IResourceTreeNode[m_upChildren.size()]);
- }
-
- /**
- * @see org.rhq.enterprise.gui.image.data.ITreeNode#getDownChildren()
- */
- public ITreeNode[] getDownChildren() {
- return (IResourceTreeNode[]) m_downChildren.toArray(new IResourceTreeNode[m_downChildren.size()]);
- }
-
- /**
- * @see org.rhq.enterprise.gui.image.data.ITreeNode#getResourceType()
- */
- public int getType() {
- return m_type;
- }
-
- //******** IResourceTreeNode Methods ********
-
- //************ Public Methods ***************
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("[").append(" name=").append(getName()).append(" desc=").append(getDescription()).append(" type=")
- .append(getType()).append(" up-children: ").append(getUpChildren()).append(" down-chilren: ").append(
- getDownChildren()).append(" ]");
- return buf.toString();
- }
-
- //************* Private Methods *************
- private boolean isValidType(int type) {
- return ((type >= NONE) && (type <= CLUSTER));
- }
-}
-
-// EOF
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/TreeNode.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/TreeNode.java
deleted file mode 100644
index c089524..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/image/widget/TreeNode.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.image.widget;
-
-import java.awt.Rectangle;
-import java.awt.image.BufferedImage;
-import java.io.Serializable;
-import java.util.Vector;
-import org.rhq.enterprise.gui.image.data.ITreeNode;
-
-public class TreeNode implements ITreeNode, Serializable {
- protected Vector m_upChildren = new Vector();
- protected Vector m_downChildren = new Vector();
- private String m_desc;
- private String m_name;
- private Vector m_rects;
- private boolean m_selected;
-
- public TreeNode(String name, String desc) {
- this(name, desc, false);
- }
-
- public TreeNode(String name, String desc, boolean selected) {
- m_name = name;
- m_desc = desc;
- m_selected = selected;
- }
-
- /**
- * Adds a single child to the up children list.
- *
- * @param child An object that implements the IResourceTreeNode interface.
- *
- * @see org.rhq.enterprise.gui.image.data.IResourceTreeNode
- */
- public void addUpChild(ITreeNode child) {
- m_upChildren.add(child);
- }
-
- /**
- * Add an array of children to the up children list.
- *
- * @param children An array of objects that implement the IResourceTreeNode interface.
- *
- * @see org.rhq.enterprise.gui.image.data.IResourceTreeNode
- */
- public void addUpChildren(ITreeNode[] children) {
- for (int i = 0; i < children.length; i++) {
- m_upChildren.add(children[i]);
- }
- }
-
- /**
- * @see org.rhq.enterprise.gui.image.data.ITreeNode#getUpChildren()
- */
- public ITreeNode[] getUpChildren() {
- return (ITreeNode[]) m_upChildren.toArray(new ITreeNode[m_upChildren.size()]);
- }
-
- /**
- * @return The number of up children for this node.
- */
- public int getUpChildrenCount() {
- return m_upChildren.size();
- }
-
- /**
- * @return Whether the node has up children.
- */
- public boolean hasUpChildren() {
- return (this.getUpChildrenCount() > 0);
- }
-
- /**
- * Adds a single child to the down children list.
- *
- * @param child An object that implements the IResourceTreeNode interface.
- *
- * @see org.rhq.enterprise.gui.image.data.IResourceTreeNode
- */
- public void addDownChild(ITreeNode child) {
- m_downChildren.add(child);
- }
-
- /**
- * Add an array of children to the down children list.
- *
- * @param children An array of objects that implement the IResourceTreeNode interface.
- *
- * @see org.rhq.enterprise.gui.image.data.IResourceTreeNode
- */
- public void addDownChildren(ITreeNode[] children) {
- for (int i = 0; i < children.length; i++) {
- m_downChildren.add(children[i]);
- }
- }
-
- /**
- * @see org.rhq.enterprise.gui.image.data.ITreeNode#getDownChildren()
- */
- public ITreeNode[] getDownChildren() {
- return (ITreeNode[]) m_downChildren.toArray(new ITreeNode[m_downChildren.size()]);
- }
-
- /**
- * @return The number of down children for this node.
- */
- public int getDownChildrenCount() {
- return m_downChildren.size();
- }
-
- /**
- * @return Whether the node has down children.
- */
- public boolean hasDownChildren() {
- return (this.getDownChildrenCount() > 0);
- }
-
- /**
- * Empties the list of both up and down children.
- */
- public void clear() {
- m_upChildren.clear();
- m_downChildren.clear();
- }
-
- /**
- * @see org.rhq.enterprise.gui.image.data.ITreeNode#getDescription()
- */
- public String getDescription() {
- return m_desc;
- }
-
- /**
- */
- public BufferedImage getImage() {
- return null;
- }
-
- /**
- * @see org.rhq.enterprise.gui.image.data.ITreeNode#getName()
- */
- public String getName() {
- return m_name;
- }
-
- /**
- * @see org.rhq.enterprise.gui.image.data.ITreeNode#getRectangles()
- */
- public Rectangle[] getRectangles() {
- return (m_rects == null) ? null : (Rectangle[]) m_rects.toArray(new Rectangle[m_rects.size()]);
- }
-
- /**
- * @see org.rhq.enterprise.gui.image.data.ITreeNode#isSelected()
- */
- public boolean isSelected() {
- return m_selected;
- }
-
- /**
- * @see org.rhq.enterprise.gui.image.data.ITreeNode#addRectangle(int, int, int, int)
- */
- public void addRectangle(int x, int y, int cx, int cy) {
- if (m_rects == null) {
- m_rects = new Vector();
- }
-
- m_rects.add(new Rectangle(x, y, cx, cy));
- }
-
- /**
- * Clears the internal state of the node. The list of rectangles must be cleared at a minumum. This method is called
- * by the ResourceTree.reset() method.
- *
- * @see org.rhq.enterprise.gui.image.widget.ResourceTree#reset()
- */
- public void reset() {
- m_rects = null;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/AvailabilityDataPoint.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/AvailabilityDataPoint.java
deleted file mode 100644
index b9725c5..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/AvailabilityDataPoint.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility;
-
-import org.rhq.enterprise.gui.image.data.IDisplayDataPoint;
-
-public class AvailabilityDataPoint implements IDisplayDataPoint {
- private double value;
-
- public AvailabilityDataPoint(Integer integerValue) {
- setValue(integerValue.doubleValue());
- }
-
- public long getTimestamp() {
- return 0;
- }
-
- public double getValue() {
- return value;
- }
-
- public void setValue(double value) {
- this.value = value;
- }
-
- public void setValue(Integer integerValue) {
- setValue(integerValue.doubleValue());
- }
-
- public String getLabel() {
- return null;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/CurrentHealthAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/CurrentHealthAction.java
deleted file mode 100644
index c0a0453..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/CurrentHealthAction.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-import org.apache.struts.tiles.ComponentContext;
-import org.apache.struts.tiles.actions.TilesAction;
-
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.enterprise.gui.legacy.AttrConstants;
-import org.rhq.enterprise.gui.legacy.ParamConstants;
-import org.rhq.enterprise.gui.legacy.WebUser;
-import org.rhq.enterprise.gui.legacy.util.RequestUtils;
-import org.rhq.enterprise.gui.legacy.util.SessionUtils;
-import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.measurement.MeasurementPreferences;
-import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricViewsPreferences;
-
-/**
- * An <code>TilesAction</code> that retrieves metric data to facilitate display of a current health page. Input is
- * either a single resource (param 'id'), a group (param 'groupId') or an autogroup (params 'type' and 'parent')
- */
-public class CurrentHealthAction extends TilesAction {
-
- protected static Log log = LogFactory.getLog(CurrentHealthAction.class);
-
- @Override
- public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) throws Exception {
-
- Resource resource = (Resource) request.getAttribute(AttrConstants.RESOURCE_ATTR);
- Integer groupId = (Integer) request.getAttribute(AttrConstants.GROUP_ID);
- int parent = WebUtility.getOptionalIntRequestParameter(request, "parent", -1);
- int type = WebUtility.getOptionalIntRequestParameter(request, "type", -1);
-
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
- String key;
- if (resource != null) {
- key = String.valueOf((resource.getId()));
- } else if (groupId != null) {
- key = "cg=" + String.valueOf(groupId);
- } else if ((type > 0) && (parent > 0)) {
- ivf.setCtype(type);
- ivf.setParent(parent);
- key = "ag=" + parent + ":" + type;
- } else {
- throw new IllegalStateException("Unknown or unsupported IndicatorViewsForm mode '" + ivf + "'");
- }
-
- setupViews(request, ivf, key);
-
- return null;
- }
-
- /**
- * Set up the {@link IndicatorViewsForm#getViews()} list of views for the current indicator charts page. The key
- * generated here needs to correspond to the one in
- * {@link IndicatorChartsAction#generateSessionKey(IndicatorViewsForm form, true)}
- */
- protected void setupViews(HttpServletRequest request, IndicatorViewsForm ivf, String key) {
- WebUser user = SessionUtils.getWebUser(request.getSession());
- MeasurementPreferences preferences = user.getMeasurementPreferences();
-
- MetricViewsPreferences metricViews = preferences.getMetricViews(key);
- ivf.setViews(metricViews.views.toArray(new String[metricViews.views.size()]));
-
- String viewName = RequestUtils.getStringParameter(request, ParamConstants.PARAM_VIEW, metricViews.views.get(0));
- ivf.setView(viewName);
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java
deleted file mode 100755
index 23a15f4..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility;
-
-import java.text.CharacterIterator;
-import java.text.StringCharacterIterator;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-import org.apache.struts.actions.DispatchAction;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.common.EntityContext;
-import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
-import org.rhq.enterprise.gui.legacy.AttrConstants;
-import org.rhq.enterprise.gui.legacy.KeyConstants;
-import org.rhq.enterprise.gui.legacy.ParamConstants;
-import org.rhq.enterprise.gui.legacy.RetCodeConstants;
-import org.rhq.enterprise.gui.legacy.WebUser;
-import org.rhq.enterprise.gui.legacy.util.MonitorUtils;
-import org.rhq.enterprise.gui.legacy.util.RequestUtils;
-import org.rhq.enterprise.gui.legacy.util.SessionUtils;
-import org.rhq.enterprise.gui.util.MetricsDisplayMode;
-import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.measurement.MeasurementChartsManagerLocal;
-import org.rhq.enterprise.server.measurement.MeasurementPreferences;
-import org.rhq.enterprise.server.measurement.MeasurementViewException;
-import org.rhq.enterprise.server.measurement.MeasurementViewManagerLocal;
-import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences;
-import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-/**
- * Generate the metric info for the indicator charts to be displayed.
- *
- * Identifying individual metric summaries / charts very much use the concept of a metricToken.
- * This token is a string, that identifies the metric summary and where it comes from - if
- * it is a metric summary for a single resource or for a group. See {@link #getContextKeyChart(MetricDisplaySummary)} and
- * {@link #parseMetricToken(String)} on how the metric token looks like.
- * This token is also used in ListChildResources.jsp to add new charts and in DashCharts.jsp
- * to generate the input for up/down/remove.
- *
- * The used {@link IndicatorViewsForm} is filled in the {@link CurrentHealthAction} class,
- * which unlike most of the actions preparing a form is not called *PrepareAction.
- *
- * @author Heiko W. Rupp (for the RHQ rewrite)
- * @author Joseph Marques
- */
-public class IndicatorChartsAction extends DispatchAction {
-
- private final static Log log = LogFactory.getLog(IndicatorChartsAction.class);
-
- private MeasurementChartsManagerLocal chartsManager = LookupUtil.getMeasurementChartsManager();
- private MeasurementViewManagerLocal viewManager = LookupUtil.getMeasurementViewManager();
-
- /**
- * Generate a key, that identifies the summary.
- * The format of the token is (without quotation marks):
- * <ul>
- * <li>For a compatible group: "cg,<i>groupId</i>,<i>definitionId</i>"</li>
- * <li>For an autogroup : "ag,<i>parentId</i>,<i>definitionId</i>,<i>childTypeId</i>"</li>
- * <li>For a single resource: "<i>resourceId</i>,<i>scheduleId</i>"</li>
- * </ul>
- * @see #parseMetricToken(String)
- */
- private String getContextKeyChart(MetricDisplaySummary summary) {
-
- MetricsDisplayMode mode = getDisplayModeForSummary(summary);
-
- switch (mode) {
- case RESOURCE:
- if (summary.getScheduleId() != null)
- return summary.getResourceId() + "," + summary.getScheduleId().toString();
- throw new IllegalStateException("MetricsDisplayMode was 'RESOURCE', but the scheduleId was null");
- case COMPGROUP:
- return "cg," + summary.getGroupId() + "," + summary.getDefinitionId();
- case AUTOGROUP:
- return "ag," + summary.getParentId() + "," + summary.getDefinitionId() + "," + summary.getChildTypeId();
- default:
- throw new IllegalArgumentException("Unknown or unsupported MetricsDisplayMode '" + mode + "'");
- }
- }
-
- private EntityContext getContext(HttpServletRequest request) {
- int resourceId = WebUtility.getOptionalIntRequestParameter(request, ParamConstants.RESOURCE_ID_PARAM, -1);
- int groupId = WebUtility.getOptionalIntRequestParameter(request, ParamConstants.GROUP_ID_PARAM, -1);
- int parentResourceId = WebUtility.getOptionalIntRequestParameter(request, "parent", -1);
- int resourceTypeId = WebUtility.getOptionalIntRequestParameter(request, ParamConstants.RESOURCE_TYPE_ID_PARAM,
- -1);
-
- return new EntityContext(resourceId, groupId, parentResourceId, resourceTypeId);
- }
-
- public ActionForward fresh(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- HttpSession session = request.getSession();
- WebUser user = SessionUtils.getWebUser(session);
- //MeasurementPreferences preferences = user.getMeasurementPreferences();
-
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
- String viewName = ivf.getView();
-
- List<MetricDisplaySummary> metrics = new ArrayList<MetricDisplaySummary>();
-
- /*
- * First try to load the metrics from the user preferences for that key.
- * If that fails, we load defaults for it.
- */
- EntityContext context = WebUtility.getEntityContext(request);
- try {
-
- List<String> charts = viewManager.getCharts(user.getSubject(), context, viewName);
-
- for (String token : charts) {
- MetricDisplaySummary tmp = MeasurementUtils.parseMetricToken(token);
- metrics.add(tmp);
- }
- metrics = reloadMetrics(request, metrics, true);
-
- return mapping.findForward(RetCodeConstants.SUCCESS_URL);
-
- } catch (MeasurementViewException mve) {
- // expected the first time the user is viewing this particular charts context
- if (log.isDebugEnabled())
- log.debug("Error getting charts: " + mve.getMessage());
- }
-
- // TODO twist the logic around. First try to get the metrics from the preferences
- // and act accordingly with loading the MetricDisplaySummary s and only if that
- // fails, use the defaults.
- // The load from prefs / session and then get the MetricDisplaySummary stuff
- // can be reused for refresh()
-
- if (context.type == EntityContext.Type.Resource) {
- metrics = chartsManager.getMetricDisplaySummariesForResource(user.getSubject(), context.resourceId,
- viewName);
- for (MetricDisplaySummary summary : metrics) {
- summary.setMetricToken(getContextKeyChart(summary));
- }
- } else if (context.type == EntityContext.Type.ResourceGroup) {
- metrics = chartsManager.getMetricDisplaySummariesForCompatibleGroup(user.getSubject(), context.groupId,
- viewName);
- // loop over the metrics, put the groupId in and format the provided value
- for (MetricDisplaySummary summary : metrics) {
- summary.setMetricToken(getContextKeyChart(summary));
- MonitorUtils.formatSimpleMetrics(summary, null);
- }
-
- request.setAttribute(AttrConstants.CHART_DATA_KEYS, metrics); // for the big charts and DashCharts.jsp
- } else if (context.type == EntityContext.Type.AutoGroup) {
- metrics = chartsManager.getMetricDisplaySummariesForAutoGroup(user.getSubject(), context.parentResourceId,
- context.resourceTypeId, viewName);
- for (MetricDisplaySummary summary : metrics) {
- summary.setMetricToken(getContextKeyChart(summary));
- MonitorUtils.formatSimpleMetrics(summary, null);
- }
- request.setAttribute(AttrConstants.CHART_DATA_KEYS, metrics);
- }
-
- return mapping.findForward(RetCodeConstants.SUCCESS_URL);
- }
-
- /**
- * Reload the passed metrics from the backend. The metrics need to be "preinitialized", which
- * means for each metric needs the identifiers (resource id, definition, group id, etc.) be set.
- *
- * @param request http servlet request needed to get the time range preferences for the user.
- * @param metrics The List of metrics to reload
- * @param force If true, always go to the backend, even if the time range preferences show a range in the past.
- * @return the refreshed list of metrics.
- * @todo Implement the timerange check
- */
- private List<MetricDisplaySummary> reloadMetrics(HttpServletRequest request, List<MetricDisplaySummary> metrics,
- boolean force) {
- HttpSession session = request.getSession();
- WebUser user = SessionUtils.getWebUser(session);
- MeasurementPreferences preferences = user.getMeasurementPreferences();
- MetricRangePreferences rangePreferences = preferences.getMetricRangePreferences();
- long begin = rangePreferences.begin;
- long end = rangePreferences.end;
-
- // TODO: if the user selected a fixed time range and not "last xxx" and force == false, then
- // we should not go to the backend
-
- List<MetricDisplaySummary> ret = new ArrayList<MetricDisplaySummary>(metrics.size());
- Locale userLocale = request.getLocale();
- for (MetricDisplaySummary sum : metrics) {
- MetricsDisplayMode mode = getDisplayModeForSummary(sum);
-
- List<MetricDisplaySummary> tmpList;
- MetricDisplaySummary tmp;
- switch (mode) {
- case RESOURCE:
- tmpList = chartsManager.getMetricDisplaySummariesForResource(user.getSubject(), sum.getResourceId(),
- new int[] { sum.getScheduleId() }, begin, end);
- break;
- case AUTOGROUP:
- tmpList = chartsManager.getMetricDisplaySummariesForAutoGroup(user.getSubject(), sum.getParentId(), sum
- .getChildTypeId(), new int[] { sum.getDefinitionId() }, begin, end, false);
- break;
- case COMPGROUP:
- tmpList = chartsManager.getMetricDisplaySummariesForCompatibleGroup(user.getSubject(),
- sum.getGroupId(), new int[] { sum.getDefinitionId() }, begin, end, false);
- break;
- default:
- tmpList = null;
- }
- if (tmpList != null && tmpList.size() > 0) {
- tmp = tmpList.get(0);
- tmp.setMetricToken(getContextKeyChart(tmp));
- if (tmp.getMetricKeys().length > 0)
- MonitorUtils.formatSimpleMetrics(tmp, userLocale);
- ret.add(tmp);
- } else if (log.isDebugEnabled())
- log.debug("We did not get a result back for " + sum);
- }
-
- return ret;
- }
-
- public ActionForward addChart(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
-
- Subject subject = WebUtility.getSubject(request);
- EntityContext context = new EntityContext(ivf.getId(), ivf.getGroupId(), ivf.getParent(), ivf.getCtype());
- viewManager.addChart(subject, context, ivf.getView(), ivf.getMetric()[0]);
-
- return mapping.findForward(RetCodeConstants.AJAX_URL);
- }
-
- public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
-
- Subject subject = WebUtility.getSubject(request);
- EntityContext context = new EntityContext(ivf.getId(), ivf.getGroupId(), ivf.getParent(), ivf.getCtype());
- viewManager.removeChart(subject, context, ivf.getView(), ivf.getMetric()[0]);
-
- return mapping.findForward(RetCodeConstants.AJAX_URL);
- }
-
- public ActionForward moveUp(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
-
- Subject subject = WebUtility.getSubject(request);
- EntityContext context = new EntityContext(ivf.getId(), ivf.getGroupId(), ivf.getParent(), ivf.getCtype());
- viewManager.moveChartUp(subject, context, ivf.getView(), ivf.getMetric()[0]);
-
- return mapping.findForward(RetCodeConstants.AJAX_URL);
- }
-
- public ActionForward moveDown(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
-
- Subject subject = WebUtility.getSubject(request);
- EntityContext context = new EntityContext(ivf.getId(), ivf.getGroupId(), ivf.getParent(), ivf.getCtype());
- viewManager.moveChartDown(subject, context, ivf.getView(), ivf.getMetric()[0]);
-
- return mapping.findForward(RetCodeConstants.AJAX_URL);
- }
-
- public ActionForward go(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- return mapping.findForward(KeyConstants.MODE_MON_CUR);
- }
-
- //this used to be in StringUtil but was only used here.
- //we should probably handle all user input cases the same,
- //escapeHTML if needed before save, unescapeHTML after retrieving.
- /**
- * Find characters having special meaning <em>inside</em> HTML tags and URLs.
- * <p/>
- * <p/>
- * The special characters are : <ul> <li>< <li>> <li>" <li>' <li>\ <li>& <li>| <li>? </ul>
- * <p/>
- * <p/>
- */
- private static int indexOfSpecialChars(String aTagFragment) {
- final StringCharacterIterator iterator = new StringCharacterIterator(aTagFragment);
-
- int i = 0;
- for (char character = iterator.current(); character != CharacterIterator.DONE; character = iterator.next(), i++) {
- switch (character) {
- case '<':
- case '>':
- case '\"':
- case '\'':
- case '\\':
- case '&':
- case '|':
- case '?':
- return i;
- default:
- break;
- }
- }
- return -1;
- }
-
- /**
- * Creates a new view with the passed metrics and the passed name.
- * If a view with the new name exist, an error is reported.
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
- WebUser user = SessionUtils.getWebUser(request.getSession());
- MeasurementPreferences preferences = user.getMeasurementPreferences();
-
- // A couple of checks
- String newViewName = ivf.getView();
- if (newViewName.length() == 0) {
- RequestUtils.setError(request, "resource.common.monitor.visibility.view.error.empty");
- return mapping.findForward(KeyConstants.MODE_MON_CUR);
- }
-
- if (indexOfSpecialChars(newViewName) > -1) {
- RequestUtils.setError(request, "error.input.badchars");
- return mapping.findForward(KeyConstants.MODE_MON_CUR);
- }
-
- EntityContext context = new EntityContext(ivf.getId(), ivf.getGroupId(), ivf.getParent(), ivf.getCtype());
-
- try {
- // Make sure that we're not duplicating names
- viewManager.createView(user.getSubject(), context, newViewName);
- } catch (MeasurementViewException mve) {
- RequestUtils.setError(request, "resource.common.monitor.visibility.view.error.exists");
- return mapping.findForward(KeyConstants.MODE_MON_CUR);
- }
-
- List<String> viewNames = viewManager.getViewNames(user.getSubject(), context);
- ivf.setViews(viewNames.toArray(new String[viewNames.size()]));
-
- // Call update to save the metrics to be viewed
- return update(mapping, ivf, request, response);
- }
-
- public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- //refresh(mapping, form, request, response);
-
- return mapping.findForward(KeyConstants.MODE_MON_CUR);
- }
-
- public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
- Subject subject = WebUtility.getSubject(request);
-
- String doomedView = ivf.getUpdate();
- EntityContext context = new EntityContext(ivf.getId(), ivf.getGroupId(), ivf.getParent(), ivf.getCtype());
- viewManager.deleteView(subject, context, doomedView);
-
- return mapping.findForward(KeyConstants.MODE_MON_CUR);
- }
-
- /**
- * Determine if the passed summary represents single resource, a compatible
- * group or an autogroup.
- * @param summary a {@link MetricDisplaySummary} to check
- * @return the appropriate {@link MetricsDisplayMode} or UNSET if undeterminable.
- */
- private MetricsDisplayMode getDisplayModeForSummary(MetricDisplaySummary summary) {
- if (summary.getResourceId() > 0)
- return MetricsDisplayMode.RESOURCE;
- else if (summary.getGroupId() > 0)
- return MetricsDisplayMode.COMPGROUP;
- else if (summary.getParentId() > 0 && summary.getChildTypeId() > 0)
- return MetricsDisplayMode.AUTOGROUP;
- else {
- log.debug("Mode could not be determined for " + summary);
- return MetricsDisplayMode.UNSET;
- }
- }
-
- private static int getChildTypeId(HttpServletRequest request) {
- int type = WebUtility.getOptionalIntRequestParameter(request, ParamConstants.RESOURCE_TYPE_ID_PARAM, -1);
- if (type == -1) // TODO JBNADM-2630
- type = WebUtility.getRequiredIntRequestParameter(request, ParamConstants.CHILD_RESOURCE_TYPE_ID_PARAM);
- return type;
- }
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorViewsForm.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorViewsForm.java
deleted file mode 100755
index 56c8842..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorViewsForm.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.struts.action.ActionMapping;
-
-import org.rhq.enterprise.server.measurement.MeasurementPreferences;
-
-/**
- * The form object which captures the view name used for the indicator charts
- */
-public class IndicatorViewsForm extends MetricDisplayRangeForm {
- private String action;
- private String view;
- private String[] views;
- private String[] metric;
- private String addMetric;
- private long timeToken;
- private String update;
-
- public String getAction() {
- return action;
- }
-
- public void setAction(String action) {
- this.action = action;
- }
-
- public String getView() {
- if (view == null || "".equals(view))
- view = MeasurementPreferences.PREF_MEASUREMENT_INDICATOR_VIEW_DEFAULT_NAME;
- return view;
- }
-
- public void setView(String view) {
- this.view = view;
- }
-
- public String[] getViews() {
- return views;
- }
-
- public void setViews(String[] views) {
- this.views = views;
- }
-
- public String[] getMetric() {
- return metric;
- }
-
- public void setMetric(String[] metric) {
- this.metric = metric;
- }
-
- public void setAddMetric(String addMetric) {
- this.addMetric = addMetric;
- }
-
- public String getAddMetric() {
- return addMetric;
- }
-
- public long getTimeToken() {
- return timeToken;
- }
-
- public void setTimeToken(long timeToken) {
- this.timeToken = timeToken;
- }
-
- public String getUpdate() {
- return update;
- }
-
- public void setUpdate(String update) {
- this.update = update;
- }
-
- @Override
- protected void setDefaults() {
- this.action = null;
- this.view = null;
- this.metric = new String[0];
- this.addMetric = null;
- this.timeToken = System.currentTimeMillis();
- }
-
- @Override
- public void reset(ActionMapping mapping, HttpServletRequest request) {
- setDefaults();
- super.reset(mapping, request);
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartAction.java
deleted file mode 100644
index da263cc..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartAction.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility;
-
-import java.text.CharacterIterator;
-import java.text.StringCharacterIterator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.measurement.MeasurementBaseline;
-import org.rhq.core.domain.measurement.MeasurementSchedule;
-import org.rhq.core.domain.measurement.util.MeasurementConversionException;
-import org.rhq.core.server.MeasurementParser;
-import org.rhq.enterprise.gui.legacy.ParamConstants;
-import org.rhq.enterprise.gui.legacy.RetCodeConstants;
-import org.rhq.enterprise.gui.legacy.WebUser;
-import org.rhq.enterprise.gui.legacy.WebUserPreferences;
-import org.rhq.enterprise.gui.legacy.WebUserPreferences.SavedChartsPortletPreferences;
-import org.rhq.enterprise.gui.legacy.util.ActionUtils;
-import org.rhq.enterprise.gui.legacy.util.RequestUtils;
-import org.rhq.enterprise.gui.legacy.util.SessionUtils;
-import org.rhq.enterprise.server.measurement.MeasurementBaselineManagerLocal;
-import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
-import org.rhq.enterprise.server.resource.ResourceManagerLocal;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-/**
- * View a chart for a metric.
- */
-public class ViewChartAction extends MetricDisplayRangeAction {
- private final Log log = LogFactory.getLog(ViewChartAction.class.getName());
-
- MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();
- MeasurementBaselineManagerLocal baselineManager = LookupUtil.getMeasurementBaselineManager();
- ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
-
- /**
- * Modify the metric chart as specified in the given <code>{@link
- * ViewActionForm}</code>.
- */
- @Override
- public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- ViewChartForm chartForm = (ViewChartForm) form;
- Subject subject = SessionUtils.getWebUser(request.getSession()).getSubject();
-
- Integer[] resourceIds = chartForm.getResourceIds();
-
- Map<String, Object> forwardParams = new HashMap<String, Object>(3);
- // The autogroup metrics pages pass the ctype to us, and we
- // need to pass it back. If this happens, we don't need the
- // extra "mode" parameter. See bug #7501. (2003/06/24 -- JW)
- if (null != chartForm.getCtype() && chartForm.getCtype() != -1) {
- forwardParams.put(ParamConstants.CHILD_RESOURCE_TYPE_ID_PARAM, chartForm.getCtype());
- } else {
- forwardParams.put(ParamConstants.MODE_PARAM, chartForm.getMode());
- }
-
- if (chartForm.getSaveChart()) {
- ActionForward success = returnRedraw(request, mapping, forwardParams);
-
- // build the chart URL
- Map chartParams = new HashMap();
- chartParams.put("m", chartForm.getM());
- chartParams.put("showPeak", chartForm.getShowPeak());
- chartParams.put("showHighRange", chartForm.getShowHighRange());
- chartParams.put("showValues", chartForm.getShowValues());
- chartParams.put("showAverage", chartForm.getShowAverage());
- chartParams.put("showLowRange", chartForm.getShowLowRange());
- chartParams.put("showLow", chartForm.getShowLow());
- chartParams.put("showBaseline", chartForm.getShowBaseline());
- chartParams.put("threshold", chartForm.getThreshold());
-
- if (chartForm.getGroupId() > 0) { // comp group
- chartParams.put("groupId", chartForm.getGroupId());
- chartParams.put("mode", chartForm.getMode());
- } else if (chartForm.getParent() > 0 && chartForm.getCtype() > 0) { // autogroup
- chartParams.put("parent", chartForm.getParent());
- chartParams.put("type", chartForm.getCtype());
- chartParams.put("mode", chartForm.getMode());
- } else { // single resource
- // TODO for a list of mostly independent resources that don't come from one of the above groups
- if (chartForm.getId() != null)
- chartParams.put("id", chartForm.getId());
- }
-
- String url = ActionUtils.changeUrl(success.getPath(), chartParams);
- boolean changed = _saveUserChart(url, chartForm.getChartName(), request);
-
- if (log.isDebugEnabled()) {
- log.debug("Saving chart to dashboard ...\n\tchartName=" + chartForm.getChartName() + "\n\turl=" + url);
- }
-
- if (changed) {
- RequestUtils.setConfirmation(request, "resource.common.monitor.visibility.chart.confirm.ChartSaved");
- } else {
- RequestUtils.setConfirmation(request,
- "resource.common.monitor.visibility.chart.confirm.ChartAlreadySaved");
- }
-
- return success;
- } else if (chartForm.isChangeBaselineClicked()) {
- request.setAttribute("editBaseline", Boolean.TRUE);
- return returnRedraw(request, mapping, forwardParams);
- } else if (chartForm.isSaveBaselineClicked()) {
-
- Boolean baselineWasNull = null;
- if (chartForm.getMode().equals(ParamConstants.MODE_MON_CHART_SMSR)) {
- // get the derived measurement in question
- MeasurementSchedule schedule = scheduleManager.getSchedule(subject, chartForm.getId(),
- chartForm.getM()[0], true);
- baselineWasNull = (schedule.getBaseline() == null);
-
- baselineManager.calculateAutoBaseline(subject, schedule.getId(), chartForm.getStartDate().getTime(),
- chartForm.getEndDate().getTime(), true /* save */);
- } else if (chartForm.getMode().equals(ParamConstants.MODE_MON_CHART_SMMR)) {
- MeasurementBaseline baselineIfEqual = baselineManager.getBaselineIfEqual(subject, chartForm
- .getGroupId(), chartForm.getM()[0]);
-
- baselineWasNull = (baselineIfEqual == null);
-
- baselineManager.calculateAutoBaseline(subject, chartForm.getGroupId(), chartForm.getM()[0], chartForm
- .getStartDate().getTime(), chartForm.getEndDate().getTime(), true /* save */);
- }
- request.setAttribute("editBaseline", Boolean.FALSE);
- request.setAttribute("justSavedBaseline", Boolean.TRUE);
- request.setAttribute("baselineWasNull", Boolean.valueOf(baselineWasNull));
-
- RequestUtils.setConfirmation(request, "resource.common.monitor.visibility.chart.confirm.BaselineSet");
-
- return returnRedraw(request, mapping, forwardParams);
- } else if (chartForm.isCancelBaselineClicked()) {
- request.setAttribute("editBaseline", Boolean.FALSE);
- return returnRedraw(request, mapping, forwardParams);
- } else if (chartForm.isChangeHighRangeClicked()) {
- request.setAttribute("editHighRange", Boolean.TRUE);
- return returnRedraw(request, mapping, forwardParams);
- } else if (chartForm.isSaveHighRangeClicked()) {
- // get the derived measurement in question
- if (chartForm.getMode().equals(ParamConstants.MODE_MON_CHART_SMSR)) {
- int definitionId = chartForm.getM()[0];
- int resourceId = chartForm.getId();
- boolean success = setBaselineMax(subject, request, resourceId, definitionId, chartForm.getHighRange());
- if (!success) {
- return returnFailure(request, mapping, forwardParams);
- }
- } else if (chartForm.getMode().equals(ParamConstants.MODE_MON_CHART_SMMR)) {
- int groupId = chartForm.getGroupId();
- int definitionId = chartForm.getM()[0];
- List<Integer> groupMemberIds = resourceManager.findImplicitResourceIdsByResourceGroup(groupId);
- for (int resourceMemberId : groupMemberIds) {
- boolean success = setBaselineMax(subject, request, resourceMemberId, definitionId, chartForm
- .getHighRange());
- if (!success) {
- return returnFailure(request, mapping, forwardParams);
- }
- }
- }
- request.setAttribute("editHighRange", Boolean.FALSE);
- request.setAttribute("justSavedHighRange", Boolean.TRUE);
-
- return returnRedraw(request, mapping, forwardParams);
- } else if (chartForm.isCancelHighRangeClicked()) {
- request.setAttribute("editHighRange", Boolean.FALSE);
- return returnRedraw(request, mapping, forwardParams);
- } else if (chartForm.isChangeLowRangeClicked()) {
- request.setAttribute("editLowRange", Boolean.TRUE);
- return returnRedraw(request, mapping, forwardParams);
- } else if (chartForm.isSaveLowRangeClicked()) {
- // get the derived measurement in question
- if (chartForm.getMode().equals(ParamConstants.MODE_MON_CHART_SMSR)) {
- int definitionId = chartForm.getM()[0];
- int resourceId = chartForm.getId();
- boolean success = setBaselineMin(subject, request, resourceId, definitionId, chartForm.getLowRange());
- if (!success) {
- return returnFailure(request, mapping, forwardParams);
- }
- } else if (chartForm.getMode().equals(ParamConstants.MODE_MON_CHART_SMMR)) {
- int groupId = chartForm.getGroupId();
- int definitionId = chartForm.getM()[0];
- List<Integer> groupMemberIds = resourceManager.findImplicitResourceIdsByResourceGroup(groupId);
- for (int resourceMemberId : groupMemberIds) {
- boolean success = setBaselineMax(subject, request, resourceMemberId, definitionId, chartForm
- .getLowRange());
- if (!success) {
- return returnFailure(request, mapping, forwardParams);
- }
- }
- }
-
- request.setAttribute("editLowRange", Boolean.FALSE);
- request.setAttribute("justSavedLowRange", Boolean.TRUE);
-
- return returnRedraw(request, mapping, forwardParams);
- } else if (chartForm.isCancelLowRangeClicked()) {
- request.setAttribute("editLowRange", Boolean.FALSE);
- return returnRedraw(request, mapping, forwardParams);
- } else if (chartForm.isPrevPageClicked()) {
- return returnSuccess(request, mapping, forwardParams);
- } else {
- // If prev or next buttons were clicked, the dates
- // caused by those clicks will override what's
- // actually in the form, so we must update the form as
- // appropriate.
- if (chartForm.isNextRangeClicked() || chartForm.isPrevRangeClicked()) {
- MetricRange range = new MetricRange();
- if (chartForm.isNextRangeClicked()) {
- long newBegin = chartForm.getEndDate().getTime();
- long diff = newBegin - chartForm.getStartDate().getTime();
- long newEnd = newBegin + diff;
-
- range.setBegin(newBegin);
- range.setEnd(newEnd);
- } else if (chartForm.isPrevRangeClicked()) {
- long newEnd = chartForm.getStartDate().getTime();
- long diff = chartForm.getEndDate().getTime() - newEnd;
- long newBegin = newEnd - diff;
-
- range.setBegin(newBegin);
- range.setEnd(newEnd);
- }
- chartForm.setA(MetricDisplayRangeForm.ACTION_DATE_RANGE);
- chartForm.populateStartDate(new Date(range.getBegin()), request.getLocale());
- chartForm.populateEndDate(new Date(range.getEnd()), request.getLocale());
- range.shiftNow();
- request.setAttribute(ParamConstants.METRIC_RANGE, range);
- }
-
- // Update metric display range.
- ActionForward retVal = super.execute(mapping, form, request, response);
- if (retVal.getName().equals(RetCodeConstants.SUCCESS_URL)) {
- return returnRedraw(request, mapping, forwardParams);
- } else {
- if (log.isTraceEnabled()) {
- log.trace("returning " + retVal.getName());
- }
- return retVal;
- }
- }
-
- }
-
- private boolean setBaselineMax(Subject subject, HttpServletRequest request, int resourceId, int definitionId,
- String highRangeStr) throws Exception {
- MeasurementSchedule schedule = scheduleManager.getSchedule(subject, resourceId, definitionId, true);
-
- // validate here rather than in ViewChartForm.validate() because we don't want to parse the number twice
- if (highRangeStr.length() > 0) {
- try {
- double highRange = MeasurementParser.parse(highRangeStr, schedule).getValue();
-
- MeasurementBaseline baseline = schedule.getBaseline();
-
- if (baseline != null) {
- if (null != baseline.getMin()) {
- if (highRange <= baseline.getMin()) {
- RequestUtils.setError(request, "resource.common.monitor.visibility.error.HighGreaterLow",
- "highRange");
- request.setAttribute("editHighRange", Boolean.TRUE);
- return false;
- }
- }
- } else {
- baseline = new MeasurementBaseline();
- baseline.setSchedule(schedule); // add relationship both ways
- }
-
- baseline.setMax(highRange);
- baseline.setUserEntered(true);
- RequestUtils.setConfirmation(request, "resource.common.monitor.visibility.chart.confirm.HighRangeSet");
- } catch (MeasurementConversionException mce) {
- RequestUtils.setError(request, "resource.common.monitor.visibility.error.RangeParseException",
- "highRange");
- request.setAttribute("editHighRange", Boolean.TRUE);
- return false;
- }
- } else {
- RequestUtils.setConfirmation(request, "resource.common.monitor.visibility.chart.confirm.HighRangeCleared");
- }
-
- scheduleManager.updateSchedule(subject, schedule);
-
- return true;
- }
-
- private boolean setBaselineMin(Subject subject, HttpServletRequest request, int resourceId, int definitionId,
- String lowRangeStr) throws Exception {
- MeasurementSchedule schedule = scheduleManager.getSchedule(subject, resourceId, definitionId, true);
-
- // validate here rather than in ViewChartForm.validate() because we don't want to parse the number twice
- if (lowRangeStr.length() > 0) {
- try {
- double lowRange = MeasurementParser.parse(lowRangeStr, schedule).getValue();
-
- MeasurementBaseline baseline = schedule.getBaseline();
-
- if (baseline != null) {
- if (null != baseline.getMax()) {
- if (lowRange >= baseline.getMax()) {
- RequestUtils.setError(request, "resource.common.monitor.visibility.error.HighGreaterLow",
- "lowRange");
- request.setAttribute("editLowRange", Boolean.TRUE);
- return false;
- }
- }
- } else {
- baseline = new MeasurementBaseline();
- baseline.setSchedule(schedule); // add relationship both ways
- }
-
- baseline.setMin(lowRange);
- baseline.setUserEntered(true);
- RequestUtils.setConfirmation(request, "resource.common.monitor.visibility.chart.confirm.LowRangeSet");
- } catch (MeasurementConversionException mce) {
- RequestUtils.setError(request, "resource.common.monitor.visibility.error.RangeParseException",
- "lowRange");
- request.setAttribute("editLowRange", Boolean.TRUE);
- return false;
- }
- } else {
- RequestUtils.setConfirmation(request, "resource.common.monitor.visibility.chart.confirm.LowRangeCleared");
- }
-
- scheduleManager.updateSchedule(subject, schedule);
-
- return true;
- }
-
- public ActionForward returnRedraw(HttpServletRequest request, ActionMapping mapping, Map params) throws Exception {
- return constructForward(request, mapping, RetCodeConstants.REDRAW_URL, params, false);
- }
-
- // --------------------------------------------------------------------------------
- // -- private helpers
- // --------------------------------------------------------------------------------
- // forHTMLTag is copy-n-pasted from: http://www.javapractices.com/Topic96.cjp
- // used to be in our util.StringUtil, we should really use jakarta's
- // StringEscapeUtils.escapeHTML()
- /**
- * Replace characters having special meaning <em>inside</em> HTML tags with
- * their escaped equivalents, using character entities such as
- * <tt>'&'</tt>.
- * <P>
- * The escaped characters are :
- * <ul>
- * <li><
- * <li>>
- * <li>"
- * <li>'
- * <li>\
- * <li>&
- * </ul>
- * <P>
- * This method ensures that arbitrary text appearing inside a tag does not
- * "confuse" the tag. For example, <tt>HREF='Blah.do?Page=1&Sort=ASC'</tt>
- * does not comply with strict HTML because of the ampersand, and should be
- * changed to <tt>HREF='Blah.do?Page=1&Sort=ASC'</tt>. This is
- * commonly seen in building query strings. (In JSTL, the c:url tag performs
- * this task automatically.)
- *
- * @param aTagFragment
- * some HTML to be escaped
- * @return escaped HTML
- */
- private static String forHTMLTag(String aTagFragment) {
- final StringBuffer result = new StringBuffer();
-
- final StringCharacterIterator iterator = new StringCharacterIterator(aTagFragment);
-
- for (char character = iterator.current(); character != CharacterIterator.DONE; character = iterator.next()) {
- switch (character) {
- case '<':
- result.append("<");
- break;
- case '>':
- result.append(">");
- break;
- case '\"':
- result.append(""");
- break;
- case '\'':
- result.append("'");
- break;
- case '\\':
- result.append("\");
- break;
- case '&':
- result.append("&");
- break;
- case '|':
- result.append("|");
- break;
- case ',':
- result.append(",");
- break;
- default:
- // the char is not a special one add it to the result as is
- result.append(character);
- break;
- }
- }
- return result.toString();
- }
-
- private boolean _saveUserChart(String url, String name, HttpServletRequest request) throws Exception {
- WebUser user = SessionUtils.getWebUser(request.getSession());
- WebUserPreferences preferences = user.getWebPreferences();
- SavedChartsPortletPreferences savedCharts = preferences.getSavedChartsPortletPreferences();
-
- boolean changed = savedCharts.add(name, url);
- if (changed) {
- preferences.setSavedChartsPortletPreferences(savedCharts);
- }
- return changed;
- }
-
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartForm.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartForm.java
deleted file mode 100644
index 8f30861..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartForm.java
+++ /dev/null
@@ -1,686 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility;
-
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.struts.action.ActionErrors;
-import org.apache.struts.action.ActionMapping;
-import org.apache.struts.action.ActionMessage;
-import org.apache.struts.util.ImageButtonBean;
-import org.apache.struts.util.LabelValueBean;
-
-import org.rhq.enterprise.gui.legacy.DefaultConstants;
-import org.rhq.enterprise.gui.legacy.util.MonitorUtils;
-import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
-import org.rhq.enterprise.server.measurement.util.NumberConstants;
-
-/**
- * Represents the controls on the metric chart page(s).
- */
-public class ViewChartForm extends MetricDisplayRangeForm {
- public static final String NO_CHILD_TYPE = "";
-
- private String mode;
- private Integer type;
-
- /**
- * the metric definition id's for the metrics to be charted *
- */
- private Integer[] m;
- private Integer[] origM;
- private Integer[] resourceIds;
- private boolean showPeak;
- private boolean showHighRange;
- private boolean showValues;
- private boolean showAverage;
- private boolean showLowRange;
- private boolean showLow;
- private boolean showBaseline;
- private boolean saveChart;
- private boolean suppressBaselineSection;
- private ImageButtonBean redraw;
- private ImageButtonBean prevRange;
- private ImageButtonBean nextRange;
- private ImageButtonBean changeBaseline;
- private ImageButtonBean saveBaseline;
- private ImageButtonBean cancelBaseline;
- private ImageButtonBean changeHighRange;
- private ImageButtonBean saveHighRange;
- private ImageButtonBean cancelHighRange;
- private ImageButtonBean changeLowRange;
- private ImageButtonBean saveLowRange;
- private ImageButtonBean cancelLowRange;
- private ImageButtonBean prevPage;
- private String baseline;
- private String newBaseline;
- private String highRange;
- private String lowRange;
- private String baselineRaw;
- private String newBaselineRaw;
- private String highRangeRaw;
- private String lowRangeRaw;
- private Integer threshold;
- private String chartName; // just for saving to dashboard
-
- public ViewChartForm() {
- super();
- setDefaults();
- }
-
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("\n");
- sb.append("\t");
- sb.append("mode=");
- sb.append(mode);
- sb.append("\n");
- sb.append("\t");
- sb.append("showPeak=");
- sb.append(showPeak);
- sb.append("\n");
- sb.append("\t");
- sb.append("showHighRange=");
- sb.append(showHighRange);
- sb.append("\n");
- sb.append("\t");
- sb.append("showValues=");
- sb.append(showValues);
- sb.append("\n");
- sb.append("\t");
- sb.append("showAverage=");
- sb.append(showAverage);
- sb.append("\n");
- sb.append("\t");
- sb.append("showLowRange=");
- sb.append(showLowRange);
- sb.append("\n");
- sb.append("\t");
- sb.append("showLow=");
- sb.append(showLow);
- sb.append("\n");
- sb.append("\t");
- sb.append("showBaseline=");
- sb.append(showBaseline);
- sb.append("\n");
- sb.append("\t");
- sb.append("isRedrawClicked=");
- sb.append(isRedrawClicked());
- sb.append("\n");
- sb.append("\t");
- sb.append("isPrevRangeClicked=");
- sb.append(isPrevRangeClicked());
- sb.append("\n");
- sb.append("\t");
- sb.append("isNextRangeClicked=");
- sb.append(isNextRangeClicked());
- sb.append("\n");
- sb.append("\t");
- sb.append("isChangeBaselineClicked=");
- sb.append(isChangeBaselineClicked());
- sb.append("\n");
- sb.append("\t");
- sb.append("isSaveBaselineClicked=");
- sb.append(isSaveBaselineClicked());
- sb.append("\n");
- sb.append("\t");
- sb.append("isCancelBaselineClicked=");
- sb.append(isCancelBaselineClicked());
- sb.append("\n");
- sb.append("\t");
- sb.append("isChangeHighRangeClicked=");
- sb.append(isChangeHighRangeClicked());
- sb.append("\n");
- sb.append("\t");
- sb.append("isSaveHighRangeClicked=");
- sb.append(isSaveHighRangeClicked());
- sb.append("\n");
- sb.append("\t");
- sb.append("isCancelHighRangeClicked=");
- sb.append(isCancelHighRangeClicked());
- sb.append("\n");
- sb.append("\t");
- sb.append("isChangeLowRangeClicked=");
- sb.append(isChangeLowRangeClicked());
- sb.append("\n");
- sb.append("\t");
- sb.append("isSaveLowRangeClicked=");
- sb.append(isSaveLowRangeClicked());
- sb.append("\n");
- sb.append("\t");
- sb.append("isCancelLowRangeClicked=");
- sb.append(isCancelLowRangeClicked());
- sb.append("\n");
- sb.append("\t");
- sb.append("isPrevPageClicked=");
- sb.append(isPrevPageClicked());
- sb.append("baseline=");
- sb.append(baseline);
- sb.append("\n");
- sb.append("\t");
- sb.append("newBaseline=");
- sb.append(newBaseline);
- sb.append("\n");
- sb.append("\t");
- sb.append("highRange=");
- sb.append(highRange);
- sb.append("\n");
- sb.append("\t");
- sb.append("lowRange=");
- sb.append(lowRange);
- sb.append("\n");
- sb.append("\t");
- sb.append("baselineRaw=");
- sb.append(baselineRaw);
- sb.append("\n");
- sb.append("\t");
- sb.append("newBaselineRaw=");
- sb.append(newBaselineRaw);
- sb.append("\n");
- sb.append("\t");
- sb.append("highRangeRaw=");
- sb.append(highRangeRaw);
- sb.append("\n");
- sb.append("\t");
- sb.append("lowRangeRaw=");
- sb.append(lowRangeRaw);
- sb.append("\n");
- sb.append("\t");
- sb.append("threshold=");
- sb.append(threshold);
- sb.append("\n");
- sb.append("\t");
- sb.append("chartName=");
- sb.append(chartName);
- return sb.toString();
- }
-
- @Override
- public void reset(ActionMapping mapping, HttpServletRequest request) {
- setDefaults();
- super.reset(mapping, request);
- }
-
- public String getMode() {
- return mode;
- }
-
- public void setMode(String mode) {
- this.mode = mode;
- }
-
- public Integer getType() {
- return type;
- }
-
- public void setType(Integer type) {
- this.type = type;
- }
-
- public Integer[] getM() {
- return m;
- }
-
- public void setM(Integer[] m) {
- this.m = m;
- }
-
- public Integer[] getOrigM() {
- return origM;
- }
-
- public void setOrigM(Integer[] origM) {
- this.origM = origM;
- }
-
- public Integer[] getResourceIds() {
- return resourceIds;
- }
-
- public void setResourceIds(Integer[] resourceIds) {
- this.resourceIds = resourceIds;
- }
-
- public boolean getShowPeak() {
- return showPeak;
- }
-
- public void setShowPeak(boolean showPeak) {
- this.showPeak = showPeak;
- }
-
- public boolean getShowHighRange() {
- return showHighRange;
- }
-
- public void setShowHighRange(boolean showHighRange) {
- this.showHighRange = showHighRange;
- }
-
- public boolean getShowValues() {
- return showValues;
- }
-
- public void setShowValues(boolean showValues) {
- this.showValues = showValues;
- }
-
- public boolean getShowAverage() {
- return showAverage;
- }
-
- public void setShowAverage(boolean showAverage) {
- this.showAverage = showAverage;
- }
-
- public boolean getShowBaseline() {
- return showBaseline;
- }
-
- public void setShowBaseline(boolean showBaseline) {
- this.showBaseline = showBaseline;
- }
-
- public boolean getSuppressBaselineSection() {
- return suppressBaselineSection;
- }
-
- public void setSuppressBaselineSection(boolean suppressBaselineSection) {
- this.suppressBaselineSection = suppressBaselineSection;
- }
-
- public boolean getShowLowRange() {
- return showLowRange;
- }
-
- public void setShowLowRange(boolean showLowRange) {
- this.showLowRange = showLowRange;
- }
-
- public boolean getShowLow() {
- return showLow;
- }
-
- public void setShowLow(boolean showLow) {
- this.showLow = showLow;
- }
-
- public ImageButtonBean getRedraw() {
- return redraw;
- }
-
- public void setRedraw(ImageButtonBean redraw) {
- this.redraw = redraw;
- }
-
- public boolean isRedrawClicked() {
- return getRedraw().isSelected();
- }
-
- public ImageButtonBean getPrevRange() {
- return prevRange;
- }
-
- public void setPrevRange(ImageButtonBean prevRange) {
- this.prevRange = prevRange;
- }
-
- public boolean isPrevRangeClicked() {
- return getPrevRange().isSelected();
- }
-
- public ImageButtonBean getNextRange() {
- return nextRange;
- }
-
- public void setNextRange(ImageButtonBean nextRange) {
- this.nextRange = nextRange;
- }
-
- public boolean isNextRangeClicked() {
- return getNextRange().isSelected();
- }
-
- public boolean isRangeNow() {
- if (getEndDate() == null) {
- return false;
- }
-
- return ((System.currentTimeMillis() - getEndDate().getTime()) < MetricRange.SHIFT_RANGE);
- }
-
- public boolean getSaveChart() {
- return saveChart;
- }
-
- public void setSaveChart(boolean b) {
- saveChart = b;
- }
-
- public ImageButtonBean getChangeBaseline() {
- return changeBaseline;
- }
-
- public void setChangeBaseline(ImageButtonBean changeBaseline) {
- this.changeBaseline = changeBaseline;
- }
-
- public boolean isChangeBaselineClicked() {
- return getChangeBaseline().isSelected();
- }
-
- public ImageButtonBean getSaveBaseline() {
- return saveBaseline;
- }
-
- public void setSaveBaseline(ImageButtonBean saveBaseline) {
- this.saveBaseline = saveBaseline;
- }
-
- public boolean isSaveBaselineClicked() {
- return getSaveBaseline().isSelected();
- }
-
- public ImageButtonBean getCancelBaseline() {
- return cancelBaseline;
- }
-
- public void setCancelBaseline(ImageButtonBean cancelBaseline) {
- this.cancelBaseline = cancelBaseline;
- }
-
- public boolean isCancelBaselineClicked() {
- return getCancelBaseline().isSelected();
- }
-
- public ImageButtonBean getChangeHighRange() {
- return changeHighRange;
- }
-
- public void setChangeHighRange(ImageButtonBean changeHighRange) {
- this.changeHighRange = changeHighRange;
- }
-
- public boolean isChangeHighRangeClicked() {
- return getChangeHighRange().isSelected();
- }
-
- public ImageButtonBean getSaveHighRange() {
- return saveHighRange;
- }
-
- public void setSaveHighRange(ImageButtonBean saveHighRange) {
- this.saveHighRange = saveHighRange;
- }
-
- public boolean isSaveHighRangeClicked() {
- return getSaveHighRange().isSelected();
- }
-
- public ImageButtonBean getCancelHighRange() {
- return cancelHighRange;
- }
-
- public void setCancelHighRange(ImageButtonBean cancelHighRange) {
- this.cancelHighRange = cancelHighRange;
- }
-
- public boolean isCancelHighRangeClicked() {
- return getCancelHighRange().isSelected();
- }
-
- public ImageButtonBean getChangeLowRange() {
- return changeLowRange;
- }
-
- public void setChangeLowRange(ImageButtonBean changeLowRange) {
- this.changeLowRange = changeLowRange;
- }
-
- public boolean isChangeLowRangeClicked() {
- return getChangeLowRange().isSelected();
- }
-
- public ImageButtonBean getSaveLowRange() {
- return saveLowRange;
- }
-
- public void setSaveLowRange(ImageButtonBean saveLowRange) {
- this.saveLowRange = saveLowRange;
- }
-
- public boolean isSaveLowRangeClicked() {
- return getSaveLowRange().isSelected();
- }
-
- public ImageButtonBean getCancelLowRange() {
- return cancelLowRange;
- }
-
- public void setCancelLowRange(ImageButtonBean cancelLowRange) {
- this.cancelLowRange = cancelLowRange;
- }
-
- public boolean isCancelLowRangeClicked() {
- return getCancelLowRange().isSelected();
- }
-
- public ImageButtonBean getPrevPage() {
- return prevPage;
- }
-
- public void setPrevPage(ImageButtonBean prevPage) {
- this.prevPage = prevPage;
- }
-
- public boolean isPrevPageClicked() {
- return getPrevPage().isSelected();
- }
-
- public String getBaseline() {
- return baseline;
- }
-
- public void setBaseline(String baseline) {
- this.baseline = baseline;
- }
-
- public String getNewBaseline() {
- return newBaseline;
- }
-
- public void setNewBaseline(String newBaseline) {
- this.newBaseline = newBaseline;
- }
-
- public String getHighRange() {
- return highRange;
- }
-
- public void setHighRange(String highRange) {
- this.highRange = highRange;
- }
-
- public String getLowRange() {
- return lowRange;
- }
-
- public void setLowRange(String lowRange) {
- this.lowRange = lowRange;
- }
-
- public String getBaselineRaw() {
- return baselineRaw;
- }
-
- public void setBaselineRaw(String baselineRaw) {
- this.baselineRaw = baselineRaw;
- }
-
- public String getNewBaselineRaw() {
- return newBaselineRaw;
- }
-
- public void setNewBaselineRaw(String newBaselineRaw) {
- this.newBaselineRaw = newBaselineRaw;
- }
-
- public String getHighRangeRaw() {
- return highRangeRaw;
- }
-
- public void setHighRangeRaw(String highRangeRaw) {
- this.highRangeRaw = highRangeRaw;
- }
-
- public String getLowRangeRaw() {
- return lowRangeRaw;
- }
-
- public void setLowRangeRaw(String lowRangeRaw) {
- this.lowRangeRaw = lowRangeRaw;
- }
-
- public Integer getThreshold() {
- return threshold;
- }
-
- public void setThreshold(Integer threshold) {
- this.threshold = threshold;
- }
-
- public String getChartName() {
- return chartName;
- }
-
- public void setChartName(String chartName) {
- this.chartName = chartName;
- }
-
- public void synchronizeDisplayRange() {
- long now = System.currentTimeMillis();
- if ((now - getEndDate().getTime()) < MetricRange.SHIFT_RANGE) {
- long diff = getEndDate().getTime() - getStartDate().getTime();
- if ((diff % NumberConstants.DAYS) == 0) {
- setA(ACTION_LASTN);
- int days = (int) (diff / NumberConstants.DAYS);
- setRn(days);
- setRu(MeasurementUtils.UNIT_DAYS);
- } else if ((diff % NumberConstants.HOURS) == 0) {
- setA(ACTION_LASTN);
- int hours = (int) (diff / NumberConstants.HOURS);
- setRn(hours);
- setRu(MeasurementUtils.UNIT_HOURS);
- } else if ((diff % NumberConstants.MINUTES) == 0) {
- setA(ACTION_LASTN);
- int minutes = (int) (diff / NumberConstants.MINUTES);
- setRn(minutes);
- setRu(MeasurementUtils.UNIT_MINUTES);
- }
- } else {
- setA(ACTION_DATE_RANGE);
- }
- }
-
- @Override
- public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
- if (!shouldValidate(mapping, request)) {
- return null;
- }
-
- ActionErrors errs = super.validate(mapping, request);
- if (errs == null) {
- errs = new ActionErrors();
- }
-
- // If we are doing "Last N collection points", N must be
- // between 1 and 60.
- if (ACTION_LASTN.equals(getA()) && (getRu() == MeasurementUtils.UNIT_COLLECTION_POINTS)) {
- if (getRn() != null) {
- int numPoints = getRn();
- if ((numPoints < 1) || (numPoints > DefaultConstants.DEFAULT_CHART_POINTS)) {
- errs
- .add("rn", new ActionMessage("errors.range", getRn(), 1, DefaultConstants.DEFAULT_CHART_POINTS));
- }
- }
- }
-
- return errs;
- }
-
- /*
- * Only validate if. 1) Any self-submitting buttons were clicked, and 2) the mapping specifies an input form to
- * return to. Child classes should call this to decide whether or not to perform custom validation steps.
- */
- @Override
- protected boolean shouldValidate(ActionMapping mapping, HttpServletRequest request) {
- boolean isRedrawing = isRedrawClicked() || isPrevRangeClicked() || isNextRangeClicked() || getSaveChart()
- || isChangeBaselineClicked() || isSaveBaselineClicked() || isCancelBaselineClicked()
- || isChangeHighRangeClicked() || isSaveHighRangeClicked() || isCancelHighRangeClicked()
- || isChangeLowRangeClicked() || isSaveLowRangeClicked() || isCancelLowRangeClicked();
- return isRedrawing && (mapping.getInput() != null);
- }
-
- // -------------------------------------drop-downs
-
- public List<LabelValueBean> getThresholdMenu() {
- return MonitorUtils.getThresholdMenu();
- }
-
- @Override
- protected void setDefaults() {
- super.setDefaults();
- super.setWantEndDate(true);
- this.mode = null;
- this.showPeak = true;
- this.showHighRange = true;
- this.showValues = true;
- this.showAverage = true;
- this.showLowRange = true;
- this.showLow = true;
- this.showBaseline = true;
- this.redraw = new ImageButtonBean();
- this.prevRange = new ImageButtonBean();
- this.nextRange = new ImageButtonBean();
- this.saveChart = false;
- this.changeBaseline = new ImageButtonBean();
- this.saveBaseline = new ImageButtonBean();
- this.cancelBaseline = new ImageButtonBean();
- this.changeHighRange = new ImageButtonBean();
- this.saveHighRange = new ImageButtonBean();
- this.cancelHighRange = new ImageButtonBean();
- this.changeLowRange = new ImageButtonBean();
- this.saveLowRange = new ImageButtonBean();
- this.cancelLowRange = new ImageButtonBean();
- this.prevPage = new ImageButtonBean();
- this.baseline = null;
- this.newBaseline = null;
- this.highRange = null;
- this.lowRange = null;
- this.baselineRaw = null;
- this.newBaselineRaw = null;
- this.highRangeRaw = null;
- this.lowRangeRaw = null;
- this.threshold = null;
- this.chartName = null;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java
deleted file mode 100644
index 3f9f998..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewChartFormPrepareAction.java
+++ /dev/null
@@ -1,796 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-import org.apache.struts.tiles.ComponentContext;
-
-import org.rhq.core.clientapi.util.ArrayUtil;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.measurement.MeasurementBaseline;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.MeasurementSchedule;
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.core.domain.measurement.NumericType;
-import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.core.domain.measurement.ui.BaseMetricDisplay;
-import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.group.Group;
-import org.rhq.core.domain.resource.group.GroupCategory;
-import org.rhq.core.domain.util.PageControl;
-import org.rhq.core.server.MeasurementConverter;
-import org.rhq.core.util.StringUtil;
-import org.rhq.enterprise.gui.common.servlet.HighLowMetricValue;
-import org.rhq.enterprise.gui.legacy.AttrConstants;
-import org.rhq.enterprise.gui.legacy.DefaultConstants;
-import org.rhq.enterprise.gui.legacy.ParamConstants;
-import org.rhq.enterprise.gui.legacy.WebUser;
-import org.rhq.enterprise.gui.legacy.WebUserPreferences;
-import org.rhq.enterprise.gui.legacy.WebUserPreferences.SavedChartsPortletPreferences;
-import org.rhq.enterprise.gui.legacy.beans.ChartDataBean;
-import org.rhq.enterprise.gui.legacy.beans.ChartedMetricBean;
-import org.rhq.enterprise.gui.legacy.beans.NumericMetricDataPoint;
-import org.rhq.enterprise.gui.legacy.exception.ParameterNotFoundException;
-import org.rhq.enterprise.gui.legacy.util.MonitorUtils;
-import org.rhq.enterprise.gui.legacy.util.RequestUtils;
-import org.rhq.enterprise.gui.legacy.util.SessionUtils;
-import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.auth.SessionNotFoundException;
-import org.rhq.enterprise.server.measurement.AvailabilityManagerLocal;
-import org.rhq.enterprise.server.measurement.AvailabilityPoint;
-import org.rhq.enterprise.server.measurement.BaselineCreationException;
-import org.rhq.enterprise.server.measurement.MeasurementBaselineManagerLocal;
-import org.rhq.enterprise.server.measurement.MeasurementChartsManagerLocal;
-import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal;
-import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerLocal;
-import org.rhq.enterprise.server.measurement.MeasurementNotFoundException;
-import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
-import org.rhq.enterprise.server.resource.ResourceManagerLocal;
-import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
-import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-/**
- * An <code>Action</code> that retrieves data from the BizApp to facilitate display of the various pages that provide
- * metrics summaries.
- *
- * @author Ian Springer
- */
-public class ViewChartFormPrepareAction extends MetricDisplayRangeFormPrepareAction {
- private static final int NUMBER_OF_DATA_POINTS = DefaultConstants.DEFAULT_CHART_POINTS;
- private static final int DEFAULT_MAX_RESOURCES = 10;
-
- private final Log log = LogFactory.getLog(ViewChartFormPrepareAction.class);
-
- MeasurementDataManagerLocal dataManager;
- MeasurementScheduleManagerLocal scheduleManager;
- MeasurementChartsManagerLocal chartsManager;
- ResourceManagerLocal resMgr;
- ResourceGroupManagerLocal resGrpMgr;
- ResourceTypeManagerLocal resTypeMgr;
-
- /**
- * Retrieve data needed to display a Metrics Display Form. Respond to certain button clicks that alter the form
- * display.
- */
- @Override
- public ActionForward workflow(ComponentContext cc, ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) throws Exception {
- super.workflow(cc, mapping, form, request, response);
-
- ViewChartForm chartForm = (ViewChartForm) form;
-
- Subject subject = WebUtility.getSubject(request);
-
- int groupId = -1;
- Resource resource = RequestUtils.getResource(request);
- int parent = WebUtility.getOptionalIntRequestParameter(request, "parent", -1);
- int type = WebUtility.getOptionalIntRequestParameter(request, ParamConstants.RESOURCE_TYPE_ID_PARAM, -1);
- if (resource == null) {
- // no resource? Look for a group
- groupId = WebUtility.getOptionalIntRequestParameter(request, ParamConstants.GROUP_ID_PARAM, -1);
- if ((groupId == -1) && (parent == 1)) {
- return removeBadDashboardLink(request);
- }
- }
-
- dataManager = LookupUtil.getMeasurementDataManager();
- scheduleManager = LookupUtil.getMeasurementScheduleManager();
- chartsManager = LookupUtil.getMeasurementChartsManager();
- resMgr = LookupUtil.getResourceManager();
- resGrpMgr = LookupUtil.getResourceGroupManager();
- resTypeMgr = LookupUtil.getResourceTypeManager();
-
- if (resource != null) {
- chartForm.setId(resource.getId());
- chartForm.setCategory(resource.getResourceType().getCategory().name());
-
- try {
- int childResourceTypeId = WebUtility.getChildResourceTypeId(request);
- chartForm.setCtype(childResourceTypeId);
- chartForm.setType(childResourceTypeId);
- } catch (ParameterNotFoundException e) {
- // This is not an autogroup.
- }
- } else if ((groupId > 0) || (parent > 0)) {
- int definitionId = WebUtility.getOptionalIntRequestParameter(request, "definitionId", -1);
- if (definitionId > 0) {
- chartForm.setM(new Integer[] { definitionId });
- }
-
- if (parent > 0) {
- chartForm.setCtype(type);
- chartForm.setParent(parent);
- Resource parentResource = resMgr.getResourceById(subject, parent);
- ResourceType childType = resTypeMgr.getResourceTypeById(subject, type);
- String name = parentResource.getName() + "/" + childType.getName();
- chartForm.setChartName(name);
- }
-
- if (groupId > 0) {
- chartForm.setGroupId(groupId);
- Group group = resGrpMgr.getResourceGroupById(subject, groupId, GroupCategory.COMPATIBLE);
- chartForm.setChartName(group.getName());
- }
- }
-
- // These private methods have side-effects and must be
- // called in this order. Lame, I know, but I wanted to
- // have this stuff in easier-to-manage code blocks (JW).
- _setupDateRange(request, chartForm);
- _setupMetricIds(request, chartForm);
- List<List<Resource>> resources = null;
- List<Resource> allResources = null;
- String[] r = request.getParameterValues("r");
- String[] resourceIdsParam = request.getParameterValues("resourceIds");
-
- if (resource != null) {
- resources = _setupResources(request, chartForm, resource, subject);
- allResources = resources.get(0);
- } else if ((groupId > 0) || (parent > 0)) {
- if (groupId > 0) {
- allResources = resGrpMgr.findResourcesForResourceGroup(subject, groupId, GroupCategory.COMPATIBLE);
- } else {
- allResources = resGrpMgr.findResourcesForAutoGroup(subject, parent, type);
- }
-
- List<Resource> checked = new ArrayList<Resource>(DEFAULT_MAX_RESOURCES);
- int i = 0;
-
- Integer[] resourceIds = chartForm.getResourceIds();
- List<Integer> resIds;
-
- if (resourceIds != null) {
- resIds = Arrays.asList(resourceIds);
- } else {
- /* Form does not have the list of participating resources so we need
- * to add it to the form so that they will all be checked at the bottom of the ui
- * Use the 'r' parameters if supplied, otherwise, all group resources
- */
- if ((null != r) && (r.length > 0)) {
- resourceIds = new Integer[r.length];
- resIds = new ArrayList<Integer>();
- for (int j = 0; j < r.length; ++j) {
- if (j < DEFAULT_MAX_RESOURCES) {
- Integer resourceId = 0;
- try {
- resourceId = Integer.valueOf(r[j]);
- } catch (NumberFormatException e) {
- // this should not happen, resource ids should be guaranteed ints
- resourceId = -1;
- }
- resIds.add(resourceId);
- resourceIds[j] = resourceId;
- }
- }
- } else {
- int allResourcesSize = allResources.size();
- resourceIds = new Integer[allResourcesSize];
- resIds = new ArrayList<Integer>();
- for (int j = 0; j < allResourcesSize; j++) {
- if (j < DEFAULT_MAX_RESOURCES) {
- Integer resourceId = allResources.get(j).getId();
- resIds.add(resourceId);
- resourceIds[j] = resourceId;
- }
- }
- }
-
- chartForm.setResourceIds(resourceIds);
- }
-
- for (Resource res : allResources) {
- if (i < DEFAULT_MAX_RESOURCES) {
- if (resIds.contains(res.getId())) {
- checked.add(res);
- i++;
- }
- } else {
- break;
- }
- }
-
- resources = new ArrayList<List<Resource>>(2);
- resources.add(allResources);
- resources.add(checked);
-
- request.setAttribute("resources", allResources.toArray(new Resource[allResources.size()]));
- request.setAttribute("resourcesSize", allResources.size());
-
- // TODO fill in the right ones depending on what was selected
- request.setAttribute("checkedResources", checked.toArray(new Resource[checked.size()]));
- request.setAttribute("checkedResourcesSize", checked.size());
- } else if (((r != null) && (r.length > 0)) || ((resourceIdsParam != null) && (resourceIdsParam.length > 0))) // multiple scattered resources
- {
- /*
- * We have different paths to get here. One is that only r or only resourceIds are filled. In that case,
- * just display everything they have. If r and resourceIds are filled, then it means that r is the list of
- * all resources and resourceIds the ones that were checked.
- */
-
- if ((resourceIdsParam != null) && (r == null)) {
- r = resourceIdsParam;
- }
-
- int length = r.length;
- resources = new ArrayList<List<Resource>>(2);
- int[] resIds = new int[length];
- for (int i = 0; i < length; i++) {
- resIds[i] = Integer.parseInt(r[i]);
- }
-
- allResources = resMgr.findResourceByIds(subject, resIds, false, PageControl.getUnlimitedInstance());
- resources.add(allResources);
-
- // now see which ones are checked
- List<Resource> checked = new ArrayList<Resource>(allResources.size());
- if ((resourceIdsParam != null) && (resourceIdsParam.length > 0)) {
- for (String tmp : resourceIdsParam) {
- // get Resource from the allResources list as it needs to be in it and we don't need to
- // go to the backend again.
- int id = Integer.parseInt(tmp);
- for (Resource re : allResources) {
- if (re.getId() == id) {
- checked.add(re);
- break;
- }
- }
- }
- } else {
- checked.addAll(allResources); // they are all checked :)
- }
-
- resources.add(checked);
- request.setAttribute("resources", allResources.toArray(new Resource[allResources.size()]));
- request.setAttribute("resourcesSize", allResources.size());
-
- // TODO checkedResources can be at most 10 !!
- request.setAttribute("checkedResources", checked.toArray(new Resource[checked.size()]));
- request.setAttribute("checkedResourcesSize", checked.size());
- } else {
- resources = new ArrayList<List<Resource>>(2);
- allResources = new ArrayList<Resource>(); // TODO what are we?
- resources.add(allResources);
- resources.add(allResources);
- }
-
- if (allResources.isEmpty()) {
- return removeBadDashboardLink(request);
- }
-
- try {
- List<Resource> checkedResources = resources.get(1);
- _setupMetricData(request, chartForm, checkedResources, subject);
- } catch (MeasurementNotFoundException e) {
- return removeBadDashboardLink(request);
- }
-
- request.setAttribute("canSaveChart", "true");
-
- _setupPageData(request, chartForm, allResources, subject);
- _setupBaselineExpectedRange(request, chartForm, allResources, subject);
-
- _setupParentResources(request, subject);
-
- return null;
- }
-
- private void _setupParentResources(HttpServletRequest request, Subject subject) {
- Resource[] resources = (Resource[]) request.getAttribute("resources");
- for (int i = 0; i < resources.length; i++) {
- Resource resource = resources[i];
- Resource parent = resMgr.getParentResource(resource.getId());
- resource.setParentResource(parent);
- }
- }
-
- private ActionForward removeBadDashboardLink(HttpServletRequest request) throws Exception, SessionNotFoundException {
- // This was probably a bad favorites chart
- String query = request.getQueryString();
- WebUser user = SessionUtils.getWebUser(request.getSession());
- WebUserPreferences preferences = user.getWebPreferences();
- SavedChartsPortletPreferences savedCharts = preferences.getSavedChartsPortletPreferences();
- savedCharts.removeByURL(query);
- return null;
- }
-
- private void _setupDateRange(HttpServletRequest request, ViewChartForm chartForm) {
- // Decide what timeframe we're showing - it may have been
- // shifted on previous views of this page.
- MetricRange range = (MetricRange) request.getAttribute(ParamConstants.METRIC_RANGE);
- if (null == range) {
- // This is the first time out.
- range = new MetricRange();
- range.setBegin(chartForm.getStartDate().getTime());
- range.setEnd(chartForm.getEndDate().getTime());
- range.shiftNow();
- request.setAttribute(ParamConstants.METRIC_RANGE, range);
- }
-
- // Since we have two ways to adjust the range of data we're
- // looking at (paging back and forth and explicitly choosing
- // something in the display range tile), we will try to always
- // keep the display range tile "up to date". That is, if the
- // end date is "now", we'll select "last n" and otherwise
- // we'll select "date range".
- chartForm.synchronizeDisplayRange();
- }
-
- private void _setupMetricIds(HttpServletRequest request, ViewChartForm chartForm) {
- String[] m = request.getParameterValues(ParamConstants.METRIC_ID_PARAM);
- Integer[] metricIds = ArrayUtil.stringToInteger(m);
- chartForm.setM(metricIds);
- String[] origM = request.getParameterValues("origM");
- if ((origM != null) && (origM.length != 0)) {
- Integer[] originallySelectedMetricIds = ArrayUtil.stringToInteger(origM);
- chartForm.setOrigM(originallySelectedMetricIds);
- } else {
- chartForm.setOrigM(chartForm.getM().clone());
- }
- }
-
- private List<List<Resource>> _setupResources(HttpServletRequest request, ViewChartForm chartForm,
- Resource resource, Subject subject) throws Exception {
- List<List<Resource>> resources = new ArrayList<List<Resource>>();
- List<Resource> allResources = new ArrayList<Resource>();
- resources.add(allResources);
- List<Resource> checkedResources = new ArrayList<Resource>();
- resources.add(checkedResources);
- if ((chartForm.getCtype() != null) && chartForm.getCtype() != -1) {
- // It's an autogroup - get the child resources...
- List<Resource> childResources = new ArrayList<Resource>();
-
- //ab.findChildResources( sessionId, adeId,;
- // atid,
- // PageControl.PAGE_ALL ); // TODO
- Integer[] resourceIds = RequestUtils.getResourceIds(request);
-
- // if we've been passed a list of resource ids, we are
- // comparing metrics and need to prune out all but the
- // resources corresponding to the passed-in resource ids
- if (resourceIds != null) {
- log.debug("r=" + StringUtil.arrayToString(resourceIds));
- for (Resource childResource : childResources) {
- boolean found = false;
- for (Integer resourceId : resourceIds) {
- if (childResource.getId() == resourceId) {
- found = true;
- break;
- }
- }
-
- if (!found) {
- log.debug("removing resource: " + childResource.getId());
- childResources.remove(childResource); // TODO (ips): Use Iterator#remove() instead to avoid ConcurrentModification exceptions.
- }
- }
- }
- } else {
- // It's a single resource.
- allResources.add(resource);
- }
-
- request.setAttribute("resources", allResources.toArray(new Resource[allResources.size()]));
- request.setAttribute("resourcesSize", allResources.size());
-
- // If no specific resourceIds were checked, checkedResources is the same as
- // resources and chartForm.resourceIds contains all resource ids.
- Integer[] resourceIds = RequestUtils.getResourceIds(request);
- chartForm.setResourceIds(resourceIds);
- if ((null == resourceIds) || (resourceIds.length == 0)) {
- int maxResources = _getMaxResources(request, allResources.size());
- log.debug("maxResources=" + maxResources);
- checkedResources.addAll(allResources.subList(0, maxResources));
- Integer[] rids = new Integer[checkedResources.size()];
- for (int i = 0; i < rids.length; ++i) {
- rids[i] = checkedResources.get(i).getId();
- }
-
- chartForm.setResourceIds(rids);
- if (log.isDebugEnabled()) {
- log.debug("no resourceIds specified: " + StringUtil.arrayToString(rids));
- }
- } else {
- for (Integer resourceId : resourceIds) {
- for (Resource aResource : allResources) {
- if (aResource.getId() == resourceId) {
- checkedResources.add(resource);
- }
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug("resourceIds specified: " + StringUtil.arrayToString(resourceIds));
- }
- }
-
- request.setAttribute("checkedResources", checkedResources.toArray(new Resource[checkedResources.size()]));
- request.setAttribute("checkedResourcesSize", checkedResources.size());
-
- return resources;
- }
-
- private void _setupMetricData(HttpServletRequest request, ViewChartForm chartForm, List<Resource> resources,
- Subject subject) throws Exception {
- AvailabilityManagerLocal availabilityManager = LookupUtil.getAvailabilityManager();
- //EventsBoss eventsBoss = ContextUtils.getEventsBoss(getServlet().getServletContext());
- //List eventPointsList = new ArrayList(resources.length);
-
- // Get data for charts and put it in session. In reality only
- // one of either resources or metrics can have more than one
- // entry, so it's really not as much of a nested loop as it
- // seems. However, the code is written this way so that it
- // can be used in both the multi-resource and the multi-metric
- // case.
- Integer[] metricDefIds = chartForm.getM();
- if (log.isTraceEnabled()) {
- log.trace("number of metrics: " + metricDefIds.length);
- log.trace("number of resources: " + resources.size());
- }
- String[] chartKeys = new String[metricDefIds.length];
- List<List<List<NumericMetricDataPoint>>> chartDataPointsListList = new ArrayList<List<List<NumericMetricDataPoint>>>(
- metricDefIds.length);
- boolean displayAvailability = false;
- List<List<NumericMetricDataPoint>> availabilityChartDataPointsList = new ArrayList<List<NumericMetricDataPoint>>();
- List<Integer> metricDefIdList = new ArrayList<Integer>();
-
- for (int i = 0; i < metricDefIds.length; i++) {
- int metricDefId = metricDefIds[i];
- List<List<NumericMetricDataPoint>> chartDataPointsList = new ArrayList<List<NumericMetricDataPoint>>(
- resources.size());
-
- // TODO get eventPointsList
-
- // Use current time concatenated with metric definition id for key.
- chartKeys[i] = String.valueOf(System.currentTimeMillis()) + metricDefId;
- request.getSession().setAttribute(chartKeys[i], new ChartDataBean(chartDataPointsList));
- metricDefIdList.add(metricDefId);
- chartDataPointsListList.add(chartDataPointsList);
- }
-
- int[] metricDefinitionIds = new int[metricDefIdList.size()];
- for (int i = 0; i < metricDefIdList.size(); i++) {
- metricDefinitionIds[i] = metricDefIdList.get(i);
- }
-
- long startDate = chartForm.getStartDate().getTime();
- long endDate = chartForm.getEndDate().getTime();
- for (Resource resource : resources) {
- List<List<MeasurementDataNumericHighLowComposite>> metricDataPointsList = dataManager.findDataForResource(
- subject, resource.getId(), metricDefinitionIds, startDate, endDate, NUMBER_OF_DATA_POINTS);
- if (log.isDebugEnabled()) {
- log.debug("Found " + metricDataPointsList.size() + " data points.");
- if (log.isTraceEnabled()) {
- log.trace("data: " + metricDataPointsList);
- }
- }
-
- if (displayAvailability) {
- List<AvailabilityPoint> availabilityPoints = availabilityManager.findAvailabilitiesForResource(subject,
- resource.getId(), startDate, endDate, NUMBER_OF_DATA_POINTS, false);
- List<NumericMetricDataPoint> chartDataPoints = new ArrayList<NumericMetricDataPoint>(availabilityPoints
- .size());
- for (AvailabilityPoint availabilityPoint : availabilityPoints) {
- NumericMetricDataPoint chartDataPoint = new NumericMetricDataPoint(availabilityPoint);
- chartDataPoints.add(chartDataPoint);
- }
-
- availabilityChartDataPointsList.add(chartDataPoints);
- }
-
- for (int i = 0; i < metricDataPointsList.size(); i++) {
- List<MeasurementDataNumericHighLowComposite> metricDataPoints = metricDataPointsList.get(i); // data points for a single metric on a single resource
- int metricId = metricDefinitionIds[i];
- if (log.isDebugEnabled()) {
- log.debug("mtid=" + metricId + ", rid=" + resource.getId() + ", startDate=" + startDate
- + ", endDate=" + endDate);
- }
-
- // TODO: ispringer: don't transform from Composite to DataPoint, just get the UI to display the composite directly
- List<NumericMetricDataPoint> chartDataPoints = new ArrayList<NumericMetricDataPoint>(metricDataPoints
- .size());
- for (MeasurementDataNumericHighLowComposite metricDataPoint : metricDataPoints) {
- NumericMetricDataPoint chartDataPoint = new HighLowMetricValue(metricDataPoint);
- chartDataPoints.add(chartDataPoint);
- }
-
- List<List<NumericMetricDataPoint>> chartDataPointsList = chartDataPointsListList.get(i);
- chartDataPointsList.add(chartDataPoints);
- }
-
- }
-
- /*
- * We need one List<Event> per graph that we are drawing -- they need to be paired with the
- * MetricDataPoints
- */
-
- request.getSession().setAttribute(AttrConstants.CHART_DATA_KEYS, chartKeys);
- request.getSession().setAttribute(AttrConstants.CHART_DATA_KEYS_SIZE, chartKeys.length);
-
- }
-
- private static final class BaseMetricDisplayComparator implements Comparator<BaseMetricDisplay> {
- public int compare(BaseMetricDisplay bmd1, BaseMetricDisplay bmd2) {
- return bmd1.getLabel().compareTo(bmd2.getLabel());
- }
- }
-
- private static final BaseMetricDisplayComparator comp = new BaseMetricDisplayComparator();
-
- private void _setupPageData(HttpServletRequest request, ViewChartForm chartForm, List<Resource> resources,
- Subject subject) throws Exception {
- int[] metricDefinitionIds = new int[chartForm.getOrigM().length];
- for (int i = 0; i < chartForm.getOrigM().length; i++) {
- metricDefinitionIds[i] = chartForm.getOrigM()[i];
- }
-
- List<MetricDisplaySummary> allMetricSummaries = new ArrayList<MetricDisplaySummary>();
- for (Resource resource : resources) {
- int[] metricScheduleIds = new int[metricDefinitionIds.length];
- for (int i = 0; i < metricDefinitionIds.length; i++) {
- int definitionId = metricDefinitionIds[i];
- MeasurementSchedule schedule = scheduleManager.getSchedule(subject, resource.getId(), definitionId,
- false);
- metricScheduleIds[i] = schedule.getId();
- }
-
- List<MetricDisplaySummary> metricSummariesList = chartsManager.getMetricDisplaySummariesForResource(
- subject, resource.getId(), metricScheduleIds, chartForm.getStartDate().getTime(), chartForm
- .getEndDate().getTime());
- MonitorUtils.formatMetrics(metricSummariesList, request.getLocale(), getResources(request));
- allMetricSummaries.addAll(metricSummariesList);
- }
-
- Collections.sort(allMetricSummaries, comp);
- request.setAttribute("metricSummaries", allMetricSummaries);
- request.setAttribute("metricSummariesSize", allMetricSummaries.size());
-
- // Create an array of charted metric beans for the metrics, and make sure it's sorted in the same order as the
- // metric summaries list.
- ChartedMetricBean[] chartedMetrics = new ChartedMetricBean[chartForm.getM().length];
- for (int i = 0; i < chartedMetrics.length; i++) {
- for (MetricDisplaySummary metricSummary : allMetricSummaries) {
- if (metricSummary.getDefinitionId().equals(chartForm.getM()[i])) {
- MeasurementUnits units = MeasurementUnits.valueOf(metricSummary.getUnits());
- chartedMetrics[i] = new ChartedMetricBean(metricSummary.getLabel(), units, metricSummary
- .getCollectionType());
- break;
- }
- }
- }
-
- request.setAttribute("chartedMetrics", chartedMetrics);
- }
-
- /**
- * Populates the form properties that are needed for the BaselineExpectedRangeParams.jsp tile, which is only
- * included in SMSR mode.
- */
- private void _setupBaselineExpectedRange(HttpServletRequest request, ViewChartForm chartForm,
- List<Resource> resources, Subject subject) throws Exception {
- MeasurementDefinitionManagerLocal definitionManager = LookupUtil.getMeasurementDefinitionManager();
- MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();
- MeasurementBaselineManagerLocal baselineManager = LookupUtil.getMeasurementBaselineManager();
- int metricId = chartForm.getM()[0];
-
- // This tile is only present for dynamic, numeric metrics in either in single-metric, single-resource mode or
- // single-metric, multiple-resource mode.
- if (chartForm.getMode().equals(ParamConstants.MODE_MON_CHART_SMSR) && (metricId != 0)) {
- Resource resource = resources.get(0);
- MeasurementSchedule schedule = scheduleManager.getSchedule(subject, resource.getId(), metricId, true);
- if (schedule.getDefinition().getNumericType() != NumericType.DYNAMIC) {
- chartForm.setSuppressBaselineSection(true);
- return;
- }
-
- // Set the name to be displayed.
- //chartForm.setChartName(schedule.getDefinition().getName());
-
- // Format the baseline, old baseline, high and low ranges.
- MeasurementBaseline newBLValue = null;
- try {
- /*
- * as a convenience to the user, let's try and calculate the baseline for the selected time-range, but
- * don't persist it unless the user explicitly sets it (which should / will be guarded by the
- * MANAGE_MEASUREMENTS permissions
- *
- * thus, since this is a system-side effect, let the overlord make the call out
- */
- //Subject overlord = LookupUtil.getSubjectManager().getOverlord();
- newBLValue = baselineManager.calculateAutoBaseline(subject, schedule.getId(), chartForm.getStartDate()
- .getTime(), chartForm.getEndDate().getTime(), false);
- } catch (BaselineCreationException e) {
- log.debug("Baseline could not be calculated, possibly due to lack of data.", e);
- }
-
- if (newBLValue != null) {
- chartForm.setNewBaseline(MeasurementConverter.format(newBLValue.getMean(), schedule.getDefinition()
- .getUnits(), true));
- chartForm.setNewBaselineRaw(String.valueOf(newBLValue.getMean()));
- }
-
- setBaselineValues(schedule.getDefinition(), schedule.getBaseline(), chartForm);
-
- postProcessBaselines(request, chartForm);
-
- } else if (chartForm.getMode().equals(ParamConstants.MODE_MON_CHART_SMMR) && (metricId != 0)) {
- boolean isAutoGroup = (chartForm.getParent() > 0);
- if (isAutoGroup) {
- // TODO: Add support for calculating baselines for autogroups.
- chartForm.setSuppressBaselineSection(true);
- return;
- }
- MeasurementDefinition definition = definitionManager.getMeasurementDefinition(subject, metricId);
- if (definition.getNumericType() != NumericType.DYNAMIC) {
- chartForm.setSuppressBaselineSection(true);
- return;
- }
-
- // Format the baseline, old baseline, high and low ranges.
- MeasurementBaseline newBaseline = null;
- try {
- newBaseline = baselineManager.calculateAutoBaseline(LookupUtil.getSubjectManager().getOverlord(),
- chartForm.getGroupId(), chartForm.getM()[0], chartForm.getStartDate().getTime(), chartForm
- .getEndDate().getTime(), false);
- } catch (BaselineCreationException e) {
- log.debug("Baseline could not be calculated, possibly due to lack of data.", e);
- }
-
- if (newBaseline != null) {
- chartForm.setNewBaseline(MeasurementConverter
- .format(newBaseline.getMean(), definition.getUnits(), true));
- chartForm.setNewBaselineRaw(String.valueOf(newBaseline.getMean()));
- }
-
- MeasurementBaseline baselineIfEqual = baselineManager.getBaselineIfEqual(subject, chartForm.getGroupId(),
- metricId);
-
- setBaselineValues(definition, baselineIfEqual, chartForm);
-
- postProcessBaselines(request, chartForm);
- }
- }
-
- private void setBaselineValues(MeasurementDefinition definition, MeasurementBaseline baseline,
- ViewChartForm chartForm) {
- if (baseline != null) {
- if (baseline.getMean() != null) {
- // group baselines will be -1 if values are mixed
- if (Math.abs(baseline.getMean() + 1.0) < 1e-9) {
- chartForm.setBaseline("Multiple Values");
- chartForm.setBaselineRaw("Multiple Values");
- } else {
- chartForm.setBaseline(MeasurementConverter.format(baseline.getMean(), definition.getUnits(), true));
- chartForm.setBaselineRaw(String.valueOf(baseline.getMean()));
- }
- }
-
- if (baseline.getMax() != null) {
- // group baselines will be -1 if values are mixed
- if (Math.abs(baseline.getMax() + 1.0) < 1e-9) {
- chartForm.setHighRange("Multiple Values");
- chartForm.setHighRangeRaw("Multiple Values");
- } else {
- chartForm.setHighRange(MeasurementConverter.format(baseline.getMax(), definition.getUnits(), true));
- chartForm.setHighRangeRaw(String.valueOf(baseline.getMax()));
- }
- }
-
- if (baseline.getMin() != null) {
- // group baselines will be -1 if values are mixed
- if (Math.abs(baseline.getMin() + 1.0) < 1e-9) {
- chartForm.setLowRange("Multiple Values");
- chartForm.setLowRangeRaw("Multiple Values");
- } else {
- chartForm.setLowRange(MeasurementConverter.format(baseline.getMin(), definition.getUnits(), true));
- chartForm.setLowRangeRaw(String.valueOf(baseline.getMin()));
- }
- }
- }
- }
-
- private void postProcessBaselines(HttpServletRequest request, ViewChartForm chartForm) {
- if ((chartForm.getBaseline() == null) || (chartForm.getBaseline().length() == 0)) {
- chartForm.setShowBaseline(false);
- } else {
- Boolean justSavedBaseline = (Boolean) request.getAttribute("justSavedBaseline");
- if ((justSavedBaseline != null) && justSavedBaseline) {
- chartForm.setShowBaseline(true);
-
- Boolean baselineWasNull = (Boolean) request.getAttribute("baselineWasNull");
- if ((baselineWasNull != null) && baselineWasNull) {
- chartForm.setShowLowRange(true);
- chartForm.setShowHighRange(true);
- }
- }
- }
-
- if ((chartForm.getHighRange() == null) || (chartForm.getHighRange().length() == 0)) {
- chartForm.setShowHighRange(false);
- } else {
- Boolean justSavedHighRange = (Boolean) request.getAttribute("justSavedHighRange");
- if ((justSavedHighRange != null) && justSavedHighRange) {
- chartForm.setShowHighRange(true);
- }
- }
-
- if ((chartForm.getLowRange() == null) || (chartForm.getLowRange().length() == 0)) {
- chartForm.setShowLowRange(false);
- } else {
- Boolean justSavedLowRange = (Boolean) request.getAttribute("justSavedLowRange");
- if ((justSavedLowRange != null) && justSavedLowRange) {
- chartForm.setShowLowRange(true);
- }
- }
- }
-
- private int _getMaxResources(HttpServletRequest request, int allResourcesLength) {
- int maxResources = DEFAULT_MAX_RESOURCES;
- String maxResourcesS = RequestUtils.message(request, "resource.common.monitor.visibility.chart.MaxResources");
- if ((null != maxResourcesS) && !maxResourcesS.startsWith("???")) {
- try {
- maxResources = Integer.parseInt(maxResourcesS);
- } catch (NumberFormatException e) {
- log.trace("invalid resource.common.monitor.visibility.chart.MaxResources resource: " + maxResourcesS);
- }
- }
-
- if (maxResources > allResourcesLength) {
- maxResources = allResourcesLength;
- }
-
- return maxResources;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewDesignatedChartAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewDesignatedChartAction.java
deleted file mode 100755
index 592436f..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/ViewDesignatedChartAction.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-
-/**
- * Forward to chart page for a designated metric.
- *
- * @deprecated the functionality in this class will be merged into ViewChartFormPrepareAction (ips, 04/04/07)
- */
-@Deprecated
-public class ViewDesignatedChartAction extends MetricDisplayRangeAction {
- protected final Log log = LogFactory.getLog(ViewDesignatedChartAction.class);
-
- /**
- * Modify the metric chart as specified in the given <code>{@link ViewActionForm}</code>.
- */
- @Override
- public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- return null;
- // Map forwardParams = new HashMap(4);
- // Integer resourceId = RequestUtils.getResourceId(request);
- // forwardParams.put(Constants.RESOURCE_ID_PARAM, resourceId);
- //
- // // TODO (ips): Refactor the below code.
- // MeasurementBoss boss =
- // ContextUtils.getMeasurementBoss(getServlet().getServletContext());
- // int sessionId = RequestUtils.getSessionId(request).intValue();
- // MeasurementTempl mtv;
- // try {
- // forwardParams.put(Constants.CHILD_RESOURCE_TYPE_ID_PARAM,
- // WebUtility.getChildResourceTypeId(request));
- // forwardParams.put(Constants.MODE_PARAM,
- // Constants.MODE_MON_CHART_SMMR);
- //
- // // Now we have to look up the designated metric template ID
- // mtv = boss.getAvailabilityMetricTemplate(sessionId, null, null);
- // } catch (ParameterNotFoundException e) {
- // forwardParams.put(Constants.MODE_PARAM,
- // Constants.MODE_MON_CHART_SMSR);
- // // Now we have to look up the designated metric template ID
- // mtv = boss.getAvailabilityMetricTemplate(sessionId, null);
- // }
- //
- // forwardParams.put(Constants.METRIC_ID_PARAM, mtv.getId());
- //
- // return constructForward(request, mapping, Constants.REDRAW_URL,
- // forwardParams, false);
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/ChartDataBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/ChartDataBean.java
deleted file mode 100644
index 024f0ad..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/ChartDataBean.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.legacy.beans;
-
-import java.util.List;
-
-/**
- * Helper bean for passing chart data between action class and chart servlet.
- */
-public final class ChartDataBean {
-
- private List dataPoints;
-
- public ChartDataBean(List dataPoints) {
- this.dataPoints = dataPoints;
- }
-
- /**
- * Returns a <code>List</code> of <code>List</code> of IDataPoint objects.
- */
- public List getDataPoints() {
- return dataPoints;
- }
-
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/ChartedMetricBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/ChartedMetricBean.java
deleted file mode 100644
index d3dcc52..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/ChartedMetricBean.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.legacy.beans;
-
-import org.rhq.core.domain.measurement.MeasurementUnits;
-
-/**
- * Helper bean for chart rendering.
- */
-public final class ChartedMetricBean {
- private String metricName;
- private MeasurementUnits units;
- private int collectionType;
-
- public ChartedMetricBean(String metricName, MeasurementUnits units, int collectionType) {
- this.metricName = metricName;
- this.units = units;
- this.collectionType = collectionType;
- }
-
- public String getMetricName() {
- return metricName;
- }
-
- public void setMetricName(String metricName) {
- this.metricName = metricName;
- }
-
- public MeasurementUnits getUnits() {
- return units;
- }
-
- public void setUnits(MeasurementUnits units) {
- this.units = units;
- }
-
- public int getCollectionType() {
- return collectionType;
- }
-
- public void setCollectionType(int collectionType) {
- this.collectionType = collectionType;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/NumericMetricDataPoint.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/NumericMetricDataPoint.java
deleted file mode 100644
index 875bbd4..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/beans/NumericMetricDataPoint.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.legacy.beans;
-
-import java.io.Serializable;
-import java.text.NumberFormat;
-import java.text.SimpleDateFormat;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.enterprise.gui.image.data.IComparableDatapoint;
-import org.rhq.enterprise.gui.image.data.IDisplayDataPoint;
-import org.rhq.enterprise.server.measurement.AvailabilityPoint;
-
-/**
- * A numeric metric data point that can be plotted on a chart.
- *
- * @author Ian Springer
- */
-public class NumericMetricDataPoint implements IDisplayDataPoint, IComparableDatapoint, Serializable {
- private long timestamp;
- private double value;
-
- public NumericMetricDataPoint(MeasurementDataNumericHighLowComposite dataPoint) {
- this.timestamp = dataPoint.getTimestamp();
- this.value = dataPoint.getValue();
- }
-
- public NumericMetricDataPoint(AvailabilityPoint availabilityPoint) {
- this.timestamp = availabilityPoint.getTimestamp();
- this.value = (availabilityPoint.getAvailabilityType() == AvailabilityType.UP) ? 100 : 0;
- }
-
- public long getTimestamp() {
- return this.timestamp;
- }
-
- public String getLabel() {
- return SimpleDateFormat.getDateTimeInstance().format(this.timestamp);
- }
-
- public double getValue() {
- return this.value;
- }
-
- public Double getObjectValue() {
- return this.value;
- }
-
- /**
- * This is for the Datapoint interface. It compares only the values of the measurements, not the timestamps.
- */
- public int compareTo(Object obj) {
- NumericMetricDataPoint that = (NumericMetricDataPoint) obj;
- double difference = this.value - that.value;
-
- // can't just return subtraction, because casting to integer
- // loses the negative values for small differences (< 1), which we
- // need.
- if (difference < 0) {
- return -1;
- }
-
- if (difference > 0) {
- return 1;
- }
-
- return 0;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if ((obj == null) || (getClass() != obj.getClass())) {
- return false;
- }
-
- NumericMetricDataPoint that = (NumericMetricDataPoint) obj;
-
- if (timestamp != that.timestamp) {
- return false;
- }
-
- if (Double.compare(that.value, value) != 0) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result;
- long temp;
- result = (int) (timestamp ^ (timestamp >>> 32));
- temp = (value != +0.0d) ? Double.doubleToLongBits(value) : 0L;
- result = (31 * result) + (int) (temp ^ (temp >>> 32));
- return result;
- }
-
- @Override
- public String toString() {
- if (Double.isNaN(getValue())) {
- return "NaN";
- }
-
- return NumberFormat.getInstance().format(getValue());
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java
deleted file mode 100644
index fb00859..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java
+++ /dev/null
@@ -1,719 +0,0 @@
-package org.rhq.enterprise.gui.measurement.graphs;
-
-import java.text.CharacterIterator;
-import java.text.StringCharacterIterator;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.common.EntityContext;
-import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.enterprise.gui.legacy.AttrConstants;
-import org.rhq.enterprise.gui.legacy.KeyConstants;
-import org.rhq.enterprise.gui.legacy.RetCodeConstants;
-import org.rhq.enterprise.gui.legacy.WebUser;
-import org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility.IndicatorViewsForm;
-import org.rhq.enterprise.gui.legacy.util.MonitorUtils;
-import org.rhq.enterprise.gui.legacy.util.RequestUtils;
-import org.rhq.enterprise.gui.legacy.util.SessionUtils;
-import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
-import org.rhq.enterprise.gui.util.MetricsDisplayMode;
-import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.auth.SessionNotFoundException;
-import org.rhq.enterprise.server.auth.SessionTimeoutException;
-import org.rhq.enterprise.server.authz.PermissionException;
-import org.rhq.enterprise.server.measurement.MeasurementChartsManagerLocal;
-import org.rhq.enterprise.server.measurement.MeasurementPreferences;
-import org.rhq.enterprise.server.measurement.MeasurementViewException;
-import org.rhq.enterprise.server.measurement.MeasurementViewManagerLocal;
-import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences;
-import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricViewData;
-import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-public class IndicatorChartsUIBean {
-
- private final static Log log = LogFactory.getLog(IndicatorChartsUIBean.class);
-
- private MeasurementChartsManagerLocal chartsManager = LookupUtil.getMeasurementChartsManager();
- private MeasurementViewManagerLocal viewManager = LookupUtil.getMeasurementViewManager();
-
- EntityContext context;
- List<MetricDisplaySummary> data = new ArrayList<MetricDisplaySummary>();
- List<String> views;
- String view;
- String groupType;
-
- public EntityContext getContext() {
- return context;
- }
-
- public List<MetricDisplaySummary> getData() {
- return data;
- }
-
- public List<String> getViews() {
- return views;
- }
-
- public String getView() {
- return view;
- }
-
- public String getGroupType() {
- return groupType;
- }
-
- public IndicatorChartsUIBean() {
- log.debug("Creating " + IndicatorChartsUIBean.class.getSimpleName());
- WebUser user = EnterpriseFacesContextUtility.getWebUser();
- Subject subject = user.getSubject();
-
- try {
- HttpServletRequest request = FacesContextUtility.getRequest();
-
- context = WebUtility.getEntityContext(request);
- groupType = WebUtility.getOptionalRequestParameter(request, "groupType", "group");
- view = viewManager.getSelectedView(subject, context);
- views = viewManager.getViewNames(subject, context);
-
- if (context.type == EntityContext.Type.Resource) {
- data = chartsManager.getMetricDisplaySummariesForResource(subject, context.resourceId, view);
- } else if (context.type == EntityContext.Type.ResourceGroup) {
- //when invoked from the GWT GUI, this is where we read the data for autogroups as well.
- //the data is correct, because the autogroups are backed by a "real" group now (as opposed to pre RHQ 3)
- //For the UI to correctly generate the links to various subsystems, we now employ the "groupType" property
- //that is being passed from the GWT GUI (namely ResourceGroupDetailView#updateMonitoringTab()), where it is
- //known what type of group we're dealing with.
- //This is so that we don't have to read the group from the database here yet again to determine
- //its type.
- //Yes, this is slightly hacky and error-prone but here's hoping the JSF UI won't survive much longer.
- data = chartsManager.getMetricDisplaySummariesForCompatibleGroup(subject, context.groupId, view);
- } else if (context.type == EntityContext.Type.AutoGroup) {
- data = chartsManager.getMetricDisplaySummariesForAutoGroup(subject, context.parentResourceId,
- context.resourceTypeId, view);
- groupType = "auto";
- }
-
- // re-persist just in case we created the list for the first time
- if (data != null) {
- MetricViewData viewData = new MetricViewData();
- viewData.charts = new ArrayList<String>();
- for (MetricDisplaySummary mds : data) {
- String chart = getContextKeyChart(context, mds);
- log.debug("Chart was " + chart);
- viewData.charts.add(chart);
- }
-
- viewManager.saveCharts(subject, context, view, viewData.charts);
- }
-
- } catch (Exception e) {
- log.error("Error while looking up metric chart data for " + context, e);
- }
-
- for (MetricDisplaySummary summary : data) {
- summary.setMetricToken(getContextKeyChart(context, summary));
- MonitorUtils.formatSimpleMetrics(summary, null);
- }
-
- return;
- }
-
- /**
- * Generate a key, that identifies the summary.
- * The format of the token is (without quotation marks):
- * <ul>
- * <li>For a compatible group: "cg,<i>groupId</i>,<i>definitionId</i>"</li>
- * <li>For an autogroup : "ag,<i>parentId</i>,<i>definitionId</i>,<i>childTypeId</i>"</li>
- * <li>For a single resource: "<i>resourceId</i>,<i>scheduleId</i>"</li>
- * </ul>
- * @see #parseMetricToken(String)
- */
- private String getContextKeyChart(MetricDisplaySummary summary) {
-
- MetricsDisplayMode mode = getDisplayModeForSummary(summary);
-
- switch (mode) {
- case RESOURCE:
- if (summary.getScheduleId() != null)
- return summary.getResourceId() + "," + summary.getScheduleId().toString();
- throw new IllegalStateException("MetricsDisplayMode was 'RESOURCE', but the scheduleId was null");
- case COMPGROUP:
- return "cg," + summary.getGroupId() + "," + summary.getDefinitionId();
- case AUTOGROUP:
- return "ag," + summary.getParentId() + "," + summary.getDefinitionId() + "," + summary.getChildTypeId();
- default:
- throw new IllegalArgumentException("Unknown or unsupported MetricsDisplayMode '" + mode + "'");
- }
- }
-
- private String getContextKeyChart(EntityContext context, MetricDisplaySummary summary) {
- if (context.type == EntityContext.Type.Resource) {
- if (summary.getScheduleId() != null)
- return context.getResourceId() + "," + summary.getScheduleId().toString();
- throw new IllegalStateException("MetricsDisplayMode was 'RESOURCE', but the scheduleId was null");
- } else if (context.type == EntityContext.Type.ResourceGroup) {
- return "cg," + context.getGroupId() + "," + summary.getDefinitionId();
- } else if (context.type == EntityContext.Type.AutoGroup) {
- return "ag," + context.getParentResourceId() + "," + summary.getDefinitionId() + ","
- + context.getResourceTypeId();
- } else {
- throw new IllegalArgumentException("Unknown or unsupported context '" + context + "'");
- }
- }
-
- /**
- * Stores the metric in the session and also in the passed form, so it can be
- * identified in moveUp()/moveDown()/remove()
- */
- private void storeMetricsInSession(HttpServletRequest request, List<MetricDisplaySummary> metrics,
- IndicatorViewsForm form) throws ServletException, SessionTimeoutException, SessionNotFoundException {
- request.setAttribute(AttrConstants.CHART_DATA_KEYS, metrics);
-
- String[] scheduleIds = new String[metrics.size()];
- int i = 0;
- for (MetricDisplaySummary summary : metrics) {
- scheduleIds[i++] = getContextKeyChart(summary);
- }
- form.setMetric(scheduleIds);
-
- // Set the metrics in the session
- EntityContext context = new EntityContext(form.getId(), form.getGroupId(), form.getParent(), form.getCtype());
- String key = context.getLegacyKey() + "." + form.getView();
- HttpSession session = request.getSession();
-
- session.setAttribute(key, metrics);
- session.setAttribute("metricKey", key);
-
- storeMetricsInUserPreferences(request, metrics, form);
- }
-
- /**
- * Look up metrics from session and load them if they are not yet there
- */
- private List<MetricDisplaySummary> retrieveMetricsFromSession(HttpServletRequest request, IndicatorViewsForm form)
- throws SessionNotFoundException, SessionTimeoutException, PermissionException, ServletException {
-
- List<MetricDisplaySummary> metrics = new ArrayList<MetricDisplaySummary>();
-
- Subject subject = WebUtility.getSubject(request);
- try {
- String viewName = form.getView();
- EntityContext context = null;
- try {
- context = new EntityContext(form.getId(), form.getGroupId(), form.getParent(), form.getCtype());
- } catch (IllegalArgumentException iae) {
- // ok, the form didn't have what we wanted, let's fallback on the request
- context = WebUtility.getEntityContext();
- }
-
- if (context.type == EntityContext.Type.Resource) {
- metrics = chartsManager.getMetricDisplaySummariesForResource(subject, context.resourceId, viewName);
- } else if (context.type == EntityContext.Type.ResourceGroup) {
- metrics = chartsManager.getMetricDisplaySummariesForCompatibleGroup(subject, context.groupId, viewName);
- } else if (context.type == EntityContext.Type.AutoGroup) {
- metrics = chartsManager.getMetricDisplaySummariesForAutoGroup(subject, context.parentResourceId,
- context.resourceTypeId, viewName);
- } else {
- throw new IllegalArgumentException("Unknown or unsupported context: " + context);
- }
- } catch (Exception e) {
- log.error("Error loading metrics (they were not found in the session)", e);
- }
-
- return metrics;
- }
-
- public ActionForward fresh(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- log.debug("Calling " + IndicatorChartsUIBean.class.getSimpleName() + " fresh");
- HttpSession session = request.getSession();
- WebUser user = SessionUtils.getWebUser(session);
- //MeasurementPreferences preferences = user.getMeasurementPreferences();
-
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
- String viewName = ivf.getView();
-
- List<MetricDisplaySummary> metrics = new ArrayList<MetricDisplaySummary>();
-
- /*
- * First try to load the metrics from the user preferences for that key.
- * If that fails, we load defaults for it.
- */
- EntityContext context = WebUtility.getEntityContext(request);
- try {
-
- List<String> charts = viewManager.getCharts(user.getSubject(), context, viewName);
-
- for (String token : charts) {
- MetricDisplaySummary tmp = MeasurementUtils.parseMetricToken(token);
- metrics.add(tmp);
- }
- metrics = reloadMetrics(request, metrics, true);
- storeMetricsInSession(request, metrics, ivf);
-
- return mapping.findForward(RetCodeConstants.SUCCESS_URL);
-
- } catch (MeasurementViewException mve) {
- // expected the first time the user is viewing this particular charts context
- if (log.isDebugEnabled())
- log.debug("Error getting charts: " + mve.getMessage());
- }
-
- // TODO twist the logic around. First try to get the metrics from the preferences
- // and act accordingly with loading the MetricDisplaySummary s and only if that
- // fails, use the defaults.
- // The load from prefs / session and then get the MetricDisplaySummary stuff
- // can be reused for refresh()
-
- if (context.type == EntityContext.Type.Resource) {
- metrics = chartsManager.getMetricDisplaySummariesForResource(user.getSubject(), context.resourceId,
- viewName);
- for (MetricDisplaySummary summary : metrics) {
- summary.setMetricToken(getContextKeyChart(summary));
- MonitorUtils.formatSimpleMetrics(summary, null);
- }
- } else if (context.type == EntityContext.Type.ResourceGroup) {
- metrics = chartsManager.getMetricDisplaySummariesForCompatibleGroup(user.getSubject(), context.groupId,
- viewName);
- // loop over the metrics, put the groupId in and format the provided value
- for (MetricDisplaySummary summary : metrics) {
- summary.setMetricToken(getContextKeyChart(summary));
- MonitorUtils.formatSimpleMetrics(summary, null);
- }
-
- request.setAttribute(AttrConstants.CHART_DATA_KEYS, metrics); // for the big charts and DashCharts.jsp
- } else if (context.type == EntityContext.Type.AutoGroup) {
- metrics = chartsManager.getMetricDisplaySummariesForAutoGroup(user.getSubject(), context.parentResourceId,
- context.resourceTypeId, viewName);
- for (MetricDisplaySummary summary : metrics) {
- summary.setMetricToken(getContextKeyChart(summary));
- MonitorUtils.formatSimpleMetrics(summary, null);
- }
- request.setAttribute(AttrConstants.CHART_DATA_KEYS, metrics);
- }
- // Set the metrics in the session and preferences
- storeMetricsInSession(request, metrics, ivf);
-
- return mapping.findForward(RetCodeConstants.SUCCESS_URL);
- }
-
- /**
- * Reload the passed metrics from the backend. The metrics need to be "preinitialized", which
- * means for each metric needs the identifiers (resource id, definition, group id, etc.) be set.
- *
- * @param request http servlet request needed to get the time range preferences for the user.
- * @param metrics The List of metrics to reload
- * @param force If true, always go to the backend, even if the time range preferences show a range in the past.
- * @return the refreshed list of metrics.
- * @todo Implement the timerange check
- */
- private List<MetricDisplaySummary> reloadMetrics(HttpServletRequest request, List<MetricDisplaySummary> metrics,
- boolean force) {
- HttpSession session = request.getSession();
- WebUser user = SessionUtils.getWebUser(session);
- MeasurementPreferences preferences = user.getMeasurementPreferences();
- MetricRangePreferences rangePreferences = preferences.getMetricRangePreferences();
- long begin = rangePreferences.begin;
- long end = rangePreferences.end;
-
- // TODO: if the user selected a fixed time range and not "last xxx" and force == false, then
- // we should not go to the backend
-
- List<MetricDisplaySummary> ret = new ArrayList<MetricDisplaySummary>(metrics.size());
- Locale userLocale = request.getLocale();
- for (MetricDisplaySummary sum : metrics) {
- MetricsDisplayMode mode = getDisplayModeForSummary(sum);
-
- List<MetricDisplaySummary> tmpList;
- MetricDisplaySummary tmp;
- switch (mode) {
- case RESOURCE:
- tmpList = chartsManager.getMetricDisplaySummariesForResource(user.getSubject(), sum.getResourceId(),
- new int[] { sum.getScheduleId() }, begin, end);
- break;
- case AUTOGROUP:
- tmpList = chartsManager.getMetricDisplaySummariesForAutoGroup(user.getSubject(), sum.getParentId(), sum
- .getChildTypeId(), new int[] { sum.getDefinitionId() }, begin, end, false);
- break;
- case COMPGROUP:
- tmpList = chartsManager.getMetricDisplaySummariesForCompatibleGroup(user.getSubject(),
- sum.getGroupId(), new int[] { sum.getDefinitionId() }, begin, end, false);
- break;
- default:
- tmpList = null;
- }
- if (tmpList != null && tmpList.size() > 0) {
- tmp = tmpList.get(0);
- tmp.setMetricToken(getContextKeyChart(tmp));
- if (tmp.getMetricKeys().length > 0)
- MonitorUtils.formatSimpleMetrics(tmp, userLocale);
- ret.add(tmp);
- } else if (log.isDebugEnabled())
- log.debug("We did not get a result back for " + sum);
- }
-
- return ret;
- }
-
- /**
- * A refresh() event coming in from the JSP layer. Is also called at the end of add() to
- * get the actual data from the backend of the newly added metric.
- */
- public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- log.debug("Calling " + IndicatorChartsUIBean.class.getSimpleName() + " refresh");
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
-
- // Look up the metrics from the session
- List<MetricDisplaySummary> metrics = retrieveMetricsFromSession(request, ivf);
-
- // refresh the metrics
- metrics = reloadMetrics(request, metrics, false);
-
- // Now store the metrics back
- storeMetricsInSession(request, metrics, ivf);
-
- return mapping.findForward(RetCodeConstants.SUCCESS_URL);
- }
-
- /**
- * Add a metric encoded in the form to the list of indicator charts to display.
- */
- public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- log.debug("Calling " + IndicatorChartsUIBean.class.getSimpleName() + " add");
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
-
- // Look up the metrics from the session
- List<MetricDisplaySummary> metrics = retrieveMetricsFromSession(request, ivf);
-
- if (metrics == null) {
- return mapping.findForward(RetCodeConstants.FAILURE_URL);
- }
-
- // Now look up the metric that we have to add and parse it
- String newMetric = ivf.getAddMetric();
- MetricDisplaySummary newSummary = MeasurementUtils.parseMetricToken(newMetric);
-
- // Get the Metric Display summary , taking the display mode into account
- MetricsDisplayMode mode = getDisplayModeForSummary(newSummary); //WebUtility.getMetricsDisplayMode(request);
-
- // First check if the metric to add is already present
- boolean found = false;
- for (MetricDisplaySummary metric : metrics) {
- Integer definitionId = metric.getDefinitionId();
- switch (mode) {
- case RESOURCE:
- Integer schedId = metric.getScheduleId();
- if (schedId != null && schedId.equals(newSummary.getScheduleId())) {
- found = true;
- break;
- }
- break;
- case COMPGROUP:
- if (metric.getGroupId() == newSummary.getGroupId() && definitionId == newSummary.getDefinitionId()) {
- found = true;
- break;
- }
- break;
- case AUTOGROUP:
- int parent = metric.getParentId();
- int type = metric.getChildTypeId();
- if (parent == newSummary.getParentId() && type == newSummary.getChildTypeId()
- && definitionId == newSummary.getDefinitionId()) {
- found = true;
- break;
- }
- break;
- default:
- throw new IllegalArgumentException(mode + " not valid here");
-
- }
- }
-
- // Add the new metrics
- List<MetricDisplaySummary> newSummaries = new ArrayList<MetricDisplaySummary>();
- if (!found) {
- WebUser user = SessionUtils.getWebUser(request.getSession());
- MeasurementPreferences preferences = user.getMeasurementPreferences();
- MetricRangePreferences rangePreferences = preferences.getMetricRangePreferences();
- long begin = rangePreferences.begin;
- long end = rangePreferences.end;
-
- switch (mode) {
- case RESOURCE:
- newSummaries = chartsManager.getMetricDisplaySummariesForResource(user.getSubject(), newSummary
- .getResourceId(), new int[] { newSummary.getScheduleId() }, begin, end);
- break;
- case COMPGROUP:
- newSummaries = chartsManager.getMetricDisplaySummariesForCompatibleGroup(user.getSubject(), newSummary
- .getGroupId(), new int[] { newSummary.getDefinitionId() }, begin, end, false);
- break;
- case AUTOGROUP:
- newSummaries = chartsManager.getMetricDisplaySummariesForAutoGroup(user.getSubject(), newSummary
- .getParentId(), newSummary.getChildTypeId(), new int[] { newSummary.getDefinitionId() }, begin,
- end, false);
- break;
- default:
- throw new IllegalArgumentException(mode + " not valid here");
- }
- }
-
- metrics.addAll(newSummaries);
-
- // Set the metrics in the session
- storeMetricsInSession(request, metrics, ivf);
-
- // trigger an immediate refresh
- // return mapping.findForward(RetCodeConstants.SUCCESS_URL);
- return refresh(mapping, form, request, response);
- }
-
- public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- log.debug("Calling " + IndicatorChartsUIBean.class.getSimpleName() + " remove");
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
-
- Subject subject = WebUtility.getSubject(request);
- EntityContext context = new EntityContext(ivf.getId(), ivf.getGroupId(), ivf.getParent(), ivf.getCtype());
- viewManager.removeChart(subject, context, ivf.getView(), ivf.getMetric()[0]);
-
- List<MetricDisplaySummary> metrics = retrieveMetricsFromSession(request, ivf);
- // Now store the metrics back
- storeMetricsInSession(request, metrics, ivf);
-
- return mapping.findForward(RetCodeConstants.AJAX_URL);
- }
-
- public ActionForward moveUp(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- log.debug("Calling " + IndicatorChartsUIBean.class.getSimpleName() + " moveUp");
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
-
- Subject subject = WebUtility.getSubject(request);
- EntityContext context = new EntityContext(ivf.getId(), ivf.getGroupId(), ivf.getParent(), ivf.getCtype());
- viewManager.moveChartUp(subject, context, ivf.getView(), ivf.getMetric()[0]);
-
- List<MetricDisplaySummary> metrics = retrieveMetricsFromSession(request, ivf);
- // Now store the metrics back
- storeMetricsInSession(request, metrics, ivf);
-
- return mapping.findForward(RetCodeConstants.AJAX_URL);
- }
-
- public ActionForward moveDown(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- log.debug("Calling " + IndicatorChartsUIBean.class.getSimpleName() + " moveDown");
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
-
- Subject subject = WebUtility.getSubject(request);
- EntityContext context = new EntityContext(ivf.getId(), ivf.getGroupId(), ivf.getParent(), ivf.getCtype());
- viewManager.moveChartDown(subject, context, ivf.getView(), ivf.getMetric()[0]);
-
- List<MetricDisplaySummary> metrics = retrieveMetricsFromSession(request, ivf);
- // Now store the metrics back
- storeMetricsInSession(request, metrics, ivf);
-
- return mapping.findForward(RetCodeConstants.AJAX_URL);
- }
-
- public ActionForward go(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- log.debug("Calling " + IndicatorChartsUIBean.class.getSimpleName() + " go");
- return mapping.findForward(KeyConstants.MODE_MON_CUR);
- }
-
- //this used to be in StringUtil but was only used here.
- //we should probably handle all user input cases the same,
- //escapeHTML if needed before save, unescapeHTML after retrieving.
- /**
- * Find characters having special meaning <em>inside</em> HTML tags and URLs.
- * <p/>
- * <p/>
- * The special characters are : <ul> <li>< <li>> <li>" <li>' <li>\ <li>& <li>| <li>? </ul>
- * <p/>
- * <p/>
- */
- private static int indexOfSpecialChars(String aTagFragment) {
- final StringCharacterIterator iterator = new StringCharacterIterator(aTagFragment);
-
- int i = 0;
- for (char character = iterator.current(); character != CharacterIterator.DONE; character = iterator.next(), i++) {
- switch (character) {
- case '<':
- case '>':
- case '\"':
- case '\'':
- case '\\':
- case '&':
- case '|':
- case '?':
- return i;
- default:
- break;
- }
- }
- return -1;
- }
-
- /**
- * Creates a new view with the passed metrics and the passed name.
- * If a view with the new name exist, an error is reported.
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- log.debug("Calling " + IndicatorChartsUIBean.class.getSimpleName() + " create");
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
- WebUser user = SessionUtils.getWebUser(request.getSession());
- MeasurementPreferences preferences = user.getMeasurementPreferences();
-
- // A couple of checks
- String newViewName = ivf.getView();
- if (newViewName.length() == 0) {
- RequestUtils.setError(request, "resource.common.monitor.visibility.view.error.empty");
- return mapping.findForward(KeyConstants.MODE_MON_CUR);
- }
-
- if (indexOfSpecialChars(newViewName) > -1) {
- RequestUtils.setError(request, "error.input.badchars");
- return mapping.findForward(KeyConstants.MODE_MON_CUR);
- }
-
- EntityContext context = new EntityContext(ivf.getId(), ivf.getGroupId(), ivf.getParent(), ivf.getCtype());
-
- try {
- // Make sure that we're not duplicating names
- viewManager.createView(user.getSubject(), context, newViewName);
- } catch (MeasurementViewException mve) {
- RequestUtils.setError(request, "resource.common.monitor.visibility.view.error.exists");
- return mapping.findForward(KeyConstants.MODE_MON_CUR);
- }
-
- List<String> viewNames = viewManager.getViewNames(user.getSubject(), context);
- ivf.setViews(viewNames.toArray(new String[viewNames.size()]));
-
- // Call update to save the metrics to be viewed
- return update(mapping, ivf, request, response);
- }
-
- public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- log.debug("Calling " + IndicatorChartsUIBean.class.getSimpleName() + " update");
-
- refresh(mapping, form, request, response);
-
- return mapping.findForward(KeyConstants.MODE_MON_CUR);
- }
-
- /**
- * Stores the metrics in the user preferences so that they
- * survive a logout.
- */
- private void storeMetricsInUserPreferences(HttpServletRequest request, List<MetricDisplaySummary> metrics,
- IndicatorViewsForm ivf) throws SessionNotFoundException, SessionTimeoutException, ServletException {
-
- MetricViewData data = new MetricViewData();
- data.charts = new ArrayList<String>();
- for (MetricDisplaySummary mds : metrics) {
- String chart = getContextKeyChart(mds);
- data.charts.add(chart);
- }
-
- // Set the user preferences now
- Subject subject = WebUtility.getSubject(request);
-
- EntityContext context = new EntityContext(ivf.getId(), ivf.getGroupId(), ivf.getParent(), ivf.getCtype());
- viewManager.saveCharts(subject, context, ivf.getView(), data.charts);
- }
-
- public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- log.debug("Calling " + IndicatorChartsUIBean.class.getSimpleName() + " delete");
- IndicatorViewsForm ivf = (IndicatorViewsForm) form;
- Subject subject = WebUtility.getSubject(request);
-
- String doomedView = ivf.getUpdate();
- EntityContext context = new EntityContext(ivf.getId(), ivf.getGroupId(), ivf.getParent(), ivf.getCtype());
- viewManager.deleteView(subject, context, doomedView);
-
- return mapping.findForward(KeyConstants.MODE_MON_CUR);
- }
-
- /**
- * Determine if the passed summary represents single resource, a compatible
- * group or an autogroup.
- * @param summary a {@link MetricDisplaySummary} to check
- * @return the appropriate {@link MetricsDisplayMode} or UNSET if undeterminable.
- */
- private MetricsDisplayMode getDisplayModeForSummary(MetricDisplaySummary summary) {
- if (summary.getResourceId() > 0)
- return MetricsDisplayMode.RESOURCE;
- else if (summary.getGroupId() > 0)
- return MetricsDisplayMode.COMPGROUP;
- else if (summary.getParentId() > 0 && summary.getChildTypeId() > 0)
- return MetricsDisplayMode.AUTOGROUP;
- else {
- log.debug("Mode could not be determined for " + summary);
- return MetricsDisplayMode.UNSET;
- }
- }
-
- public String processAction() {
- Subject subject = EnterpriseFacesContextUtility.getSubject();
- HttpServletRequest request = FacesContextUtility.getRequest();
- EntityContext context = WebUtility.getEntityContext(request);
- String action = WebUtility.getOptionalRequestParameter(request, "action", null);
- String viewName = WebUtility.getOptionalRequestParameter(request, "view", null);
- if (action == null) {
- // do nothing
- } else if (action.equals("create")) {
- try {
- // Make sure that we're not duplicating names
- if (viewName != null && !viewName.equals("")) {
- // only create names if the user specified one
- viewManager.createView(subject, context, viewName);
- viewManager.setSelectedView(subject, context, viewName);
- }
- } catch (MeasurementViewException mve) {
- //RequestUtils.setError(request, "resource.common.monitor.visibility.view.error.exists");
- //return mapping.findForward(KeyConstants.MODE_MON_CUR);
- }
- } else if (action.equals("delete")) {
- // delete action is special, the 'view' param is blanked out because
- // you can currently only delete the element you're currently viewing
- try {
- viewManager.deleteView(subject, context, this.view);
- } catch (Exception e) {
- log.error("Error deleting view " + this.view + " for " + context.toShortString(), e);
- }
- List<String> remainingViews = viewManager.getViewNames(subject, context);
- String newSelectedView = remainingViews.get(0);
- viewManager.setSelectedView(subject, context, newSelectedView);
- this.view = newSelectedView;
- } else if (action.equals("go")) {
- viewManager.setSelectedView(subject, context, viewName);
- }
- return "success";
- }
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/rt/SegmentInfo.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/rt/SegmentInfo.java
deleted file mode 100644
index 212c081..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/rt/SegmentInfo.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.rt;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.List;
-import org.rhq.enterprise.gui.image.data.IStackedDataPoint;
-
-/**
- * Provides segmented and total response time measurement for an individual request (or average for a group of
- * requests).
- */
-public class SegmentInfo implements Serializable, IStackedDataPoint {
- private Segment[] segments;
- private double total;
- private String chartLabel = null;
- private long timestamp;
-
- public SegmentInfo(String label) {
- segments = new Segment[3];
- chartLabel = label;
- }
-
- public void addSegment(int index, Segment s) {
- if ((segments[index] != null) && !Double.isNaN(segments[index].getValue())) {
- total -= segments[index].getValue();
- }
-
- segments[index] = s;
- if (!Double.isNaN(segments[index].getValue())) {
- total += segments[index].getValue();
- }
- }
-
- public Segment getSegment(int index) {
- return segments[index];
- }
-
- public List getSegments() {
- return Arrays.asList(segments);
- }
-
- public boolean removeSegment(Segment s) {
- for (int i = 0; i < 3; i++) {
- if (segments[i].equals(s)) {
- segments[i] = null;
- return true;
- }
- }
-
- return false;
- }
-
- public double getTotal() {
- return total;
- }
-
- public void setTotal(double d) {
- total = d;
- }
-
- public double getValue() {
- for (int i = 0; i < 3; i++) {
- if ((segments[i] != null) && !Double.isNaN(segments[i].getValue())) {
- return segments[i].getValue();
- }
- }
-
- return Double.NaN;
- }
-
- public double[] getValues() {
- double[] values = new double[3];
- for (int i = 0; i < 3; i++) {
- if (segments[i] != null) {
- values[i] = segments[i].getValue();
- }
- }
-
- return values;
- }
-
- public void setLabel(String label) {
- chartLabel = label;
- }
-
- public String getLabel() {
- return chartLabel;
- }
-
- public void setTimestamp(long time) {
- timestamp = time;
- }
-
- public long getTimestamp() {
- return timestamp;
- }
-
- @Override
- public String toString() {
- StringBuffer s = new StringBuffer("{");
- s.append("total=").append(total);
- s.append(" segments=[").append(segments[0]);
- s.append(",").append(segments[1]);
- s.append(",").append(segments[2]).append("]");
- return s.append("}").toString();
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/uibeans/TreeNode.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/uibeans/TreeNode.java
deleted file mode 100644
index 326d3df..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/uibeans/TreeNode.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.uibeans;
-
-import java.awt.Rectangle;
-import java.io.Serializable;
-import java.util.ArrayList;
-import org.rhq.enterprise.gui.image.data.ITreeNode;
-
-/**
- * Implementation of the tree node interface for rendering the navigation map.
- */
-public class TreeNode implements ITreeNode, Serializable {
- /**
- * Constant representing no ctype.
- */
- public static final int NO_CTYPE = -1;
-
- private String desc;
- private String name;
- private ArrayList rectangles = new ArrayList(2); // we'll rarely, if ever, have more than 2
- private boolean selected;
-
- /**
- * Children that are one level up from this node.
- */
- protected ArrayList upChildren = new ArrayList();
-
- /**
- * Children that are one level down from this node.
- */
- protected ArrayList downChildren = new ArrayList();
-
- /**
- * Creates a new <code>TreeNode</code> instance.
- *
- * @param name the name
- * @param desc the description
- */
- public TreeNode(String name, String desc) {
- this.name = name;
- this.desc = desc;
- }
-
- /**
- * Get the name.
- *
- * @return the name of the node
- */
- public String getName() {
- return name;
- }
-
- /**
- * Set the name.
- *
- * @param name the name of the node
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Get the description.
- *
- * @return the description of the node
- */
- public String getDescription() {
- return desc;
- }
-
- /**
- * Set the description.
- *
- * @param desc the description of the node
- */
- public void setDescription(String desc) {
- this.desc = desc;
- }
-
- /**
- * Get the rectangles of coordinates for the image map.
- *
- * @return the coordinate rectangles
- */
- public Rectangle[] getRectangles() {
- return (Rectangle[]) rectangles.toArray(new Rectangle[0]);
- }
-
- /**
- * Set the rectangle of coordinates for the image map.
- *
- * @param x top left corner horizontal position
- * @param y top left corner horizontal position
- * @param cx width
- * @param cy height
- */
- public void addRectangle(int x, int y, int cx, int cy) {
- rectangles.add(new Rectangle(x, y, cx, cy));
- }
-
- /**
- * Returns true if the node is selected, false otherwise.
- *
- * @return true or false
- */
- public boolean isSelected() {
- return selected;
- }
-
- /**
- * Set whether or not this node is selected.
- *
- * @param selected true or false
- */
- public void setSelected(boolean selected) {
- this.selected = selected;
- }
-
- /**
- * Add a child one level above this node.
- *
- * @param child the child to add
- */
- public void addUpChild(ITreeNode child) {
- upChildren.add(child);
- }
-
- /**
- * Add several children one level above this node.
- *
- * @param children the children to add
- */
- public void addUpChildren(ITreeNode[] children) {
- for (int i = 0; i < children.length; ++i) {
- upChildren.add(children[i]);
- }
- }
-
- /**
- * Get the children one level up from this node.
- *
- * @return the children above this node
- */
- public ITreeNode[] getUpChildren() {
- return (ITreeNode[]) upChildren.toArray(new ITreeNode[0]);
- }
-
- /**
- * Return the number of children one level above this node.
- *
- * @return the number of children
- */
- public int getUpChildrenCount() {
- return upChildren.size();
- }
-
- /**
- * Returns true if this node has children one level above.
- *
- * @return true or false
- */
- public boolean hasUpChildren() {
- return (this.getUpChildrenCount() > 0);
- }
-
- /**
- * Add a child one level below this node.
- *
- * @param child the child to add
- */
- public void addDownChild(ITreeNode child) {
- downChildren.add(child);
- }
-
- /**
- * Add several children one level below this node.
- *
- * @param children the children to add
- */
- public void addDownChildren(ITreeNode[] children) {
- for (int i = 0; i < children.length; ++i) {
- downChildren.add(children[i]);
- }
- }
-
- /**
- * Replace down children
- *
- * @param children the children to replace
- */
- public void replaceDownChildren(ITreeNode[] children) {
- downChildren.clear();
- addDownChildren(children);
- }
-
- /**
- * Replace up children
- *
- * @param children the children to replace
- */
- public void replaceUpChildren(ITreeNode[] children) {
- upChildren.clear();
- addUpChildren(children);
- }
-
- /**
- * Get the children one level down from this node.
- *
- * @return the children above this node
- */
- public ITreeNode[] getDownChildren() {
- return (ITreeNode[]) downChildren.toArray(new ITreeNode[0]);
- }
-
- /**
- * Return the number of children one level below this node.
- *
- * @return the number of children
- */
- public int getDownChildrenCount() {
- return downChildren.size();
- }
-
- /**
- * Returns true if this node has children one level below.
- *
- * @return true or false
- */
- public boolean hasDownChildren() {
- return (this.getDownChildrenCount() > 0);
- }
-
- /**
- * Describe <code>clear</code> method here.
- */
- public void clear() {
- upChildren.clear();
- downChildren.clear();
- }
-
- /**
- * Clears the internal state of the node. The list of rectangles must be cleared at a minumum. This method is called
- * by the ResourceTree.reset() method.
- *
- * @see net.covalent.image.widget.ResourceTree#reset()
- */
- public void reset() {
- rectangles.clear();
- }
-
- /**
- * Determines whether two objects are equal.
- *
- * @return true or false
- */
- public boolean equals(Object o) {
- if (!(o instanceof TreeNode)) {
- return false;
- }
-
- TreeNode other = (TreeNode) o;
- if (other == null) // I'm not null but you are, good-bye
- {
- return false;
- }
-
- boolean otherHasDescription = other.getDescription() != null;
- boolean thisHasDescription = this.getDescription() != null;
-
- // both are null (or both are not)
- if (otherHasDescription != thisHasDescription) {
- return false;
- }
-
- if (otherHasDescription && thisHasDescription && !other.getDescription().equals(this.getDescription())) {
- return false;
- }
-
- if (other.getName().equals(this.getName())
-
- &&
- /* we already checked if the descriptions are equal */
- (other.isSelected() == this.isSelected()) && (other.hasDownChildren() == this.hasDownChildren())
- && (other.hasUpChildren() == this.hasUpChildren())) {
- // XXX compare children
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns the hashcode of this object.
- *
- * @return hash code.
- */
- public int hashCode() {
- int result = 19;
- int pri = 13;
- result = (pri * result) + ((this.getName() != null) ? this.getName().length() : 0);
- result = (pri * result) + ((this.getDescription() != null) ? this.getDescription().length() : 0);
- Rectangle[] rects = this.getRectangles();
- if (rects != null) {
- for (int i = 0; i < rects.length; ++i) {
- result = (pri * result) + (int) rects[i].getX();
- result = (pri * result) + (int) rects[i].getY();
- result = (pri * result) + (int) rects[i].getWidth();
- result = (pri * result) + (int) rects[i].getLocation().getX();
- result = (pri * result) + (int) rects[i].getLocation().getY();
- }
- }
-
- return result;
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append(" name:").append(getName()).append(" description:").append(getDescription()).append(" isSel:")
- .append(isSelected());
- Rectangle[] rects = this.getRectangles();
- if (rects != null) {
- for (int i = 0; i < rects.length; ++i) {
- sb.append(" rect[").append(i).append("]:").append(rects[i]);
- }
- }
-
- return sb.toString();
- }
-}
-
-// EOF
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/uibeans/TreeNodeAlphaComparator.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/uibeans/TreeNodeAlphaComparator.java
deleted file mode 100644
index e47e1de..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/uibeans/TreeNodeAlphaComparator.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.uibeans;
-
-import java.util.Comparator;
-
-public class TreeNodeAlphaComparator implements Comparator {
- private boolean reverse;
-
- public TreeNodeAlphaComparator() {
- reverse = false;
- }
-
- public TreeNodeAlphaComparator(boolean reverse) {
- this.reverse = reverse;
- }
-
- public int compare(Object o1, Object o2) {
- if (!(o1 instanceof TreeNode) || !(o2 instanceof TreeNode)) {
- throw new IllegalArgumentException("Comparator for TreeNodes only");
- }
-
- String s1 = ((TreeNode) o1).getName();
- String s2 = ((TreeNode) o2).getName();
- return (reverse) ? s2.toUpperCase().compareTo(s1.toUpperCase()) : s1.toUpperCase().compareTo(s2.toUpperCase());
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml
index f6899d5..8d5600c 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml
@@ -207,8 +207,6 @@
<form-bean name="MetricsControlForm"
type="org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility.MetricsControlForm"/>
- <form-bean name="ViewChartForm"
- type="org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility.ViewChartForm"/>
<form-bean name="PerformanceForm"
type="org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility.PerformanceForm"/>
@@ -863,8 +861,6 @@
<forward name="adhocGroup" path="/resource/group/Inventory.do?mode=view"/>
</action>
- <action path="/resource/hub/MiniChart"
- type="org.rhq.enterprise.gui.legacy.action.resource.hub.ResourceDesignatedMetricsAction"/>
<action path="/resource/hub/ResourceHubPortal"
name="ResourceHubForm"
@@ -2973,32 +2969,6 @@
</action>
- <action path="/resource/common/monitor/visibility/ViewChartFormPrepare"
- name="ViewChartForm"
- scope="request"
- type="org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility.ViewChartFormPrepareAction">
- <set-property property="workflow" value="visibility/ViewChart"/>
- <set-property property="title" value="Chart"/>
- </action>
-
- <action path="/resource/common/monitor/visibility/ViewChart"
- name="ViewChartForm"
- scope="request"
- input="/resource/common/monitor/Visibility.do"
- type="org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility.ViewChartAction">
- <set-property property="workflow" value="visibility/ViewChart"/>
- <!-- path is ignored ... uses returnPath -->
- <forward name="success" path="/" redirect="true"/>
- <forward name="redraw" path="/resource/common/monitor/Visibility.do"/>
- <forward name="failure" path="/resource/common/monitor/Visibility.do"/>
- <forward name="reset" path="/resource/common/monitor/Visibility.do"/>
- </action>
-
- <action path="/resource/common/monitor/visibility/ViewDesignatedChart"
- type="org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility.ViewDesignatedChartAction">
- <forward name="redraw" path="/resource/common/monitor/Visibility.do"
- redirect="true"/>
- </action>
<action path="/resource/common/monitor/visibility/CurrentHealth"
name="IndicatorViewsForm"
@@ -3081,15 +3051,6 @@
type="org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility.ProblemMetricsDisplayAction">
</action>
- <action path="/resource/common/monitor/visibility/IndicatorCharts"
- name="IndicatorViewsForm"
- scope="request"
- parameter="action"
- type="org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility.IndicatorChartsAction">
- <forward name="success" path="/resource/common/monitor/visibility/DashCharts.jsp"/>
- <forward name="failure" path="/Dashboard.do" redirect="true"/>
- <forward name="currentHealth" path="/resource/common/monitor/Visibility.do?mode=currentHealth"/>
- </action>
<action path="/resource/common/monitor/visibility/AllIndicators"
name="IndicatorViewsForm"
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/dashboard-def.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/dashboard-def.xml
index fc63e9e..c7fdbb2 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/dashboard-def.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/dashboard-def.xml
@@ -22,14 +22,7 @@
<put name="portletName" value=".dashContent.searchResources" />
</definition>
- <definition name=".dashContent.savedCharts"
- controllerUrl="/dashboard/ViewSavedQueries.do"
- path="/portlet/savedQueries/View.jsp">
- <put name="adminUrl" value="/dashboard/Admin.do?mode=savedQueries" />
- <put name="portletName" value=".dashContent.savedCharts" />
- <put name="showRefresh" value="true" />
- </definition>
-
+
<definition name=".dashContent.admin.savedQueries"
controllerUrl="/dashboard/EditSavedQueries.do"
path="/portlet/savedQueries/Properties.jsp">
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-common-def.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-common-def.xml
index 53bcb7f..1c75b2e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-common-def.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-common-def.xml
@@ -346,9 +346,6 @@
<definition name=".resource.common.monitor.visibility.metricsSeeMore"
path="/resource/common/monitor/visibility/MetricsSeeMore.jsp"/>
- <definition name=".resource.common.monitor.visibility.charts"
- path="/resource/common/monitor/visibility/CurrentHealthCharts.jsp"/>
-
<definition name=".resource.common.monitor.visibility.charts.availability"
path="/resource/common/monitor/visibility/CurrentHealthAvailability.jsp"/>
@@ -364,43 +361,18 @@
<definition name=".resource.common.monitor.visibility.charts.events"
path="/resource/common/monitor/visibility/EventsList.jsp"/>
- <definition name=".resource.common.monitor.visibility.charts.metric.smsr"
- controllerUrl="/resource/common/monitor/visibility/ViewChartFormPrepare.do"
- path="/resource/common/monitor/visibility/ChartLayout.jsp"/>
-
- <definition name=".resource.common.monitor.visibility.charts.metric.smmr"
- controllerUrl="/resource/common/monitor/visibility/ViewChartFormPrepare.do"
- path="/resource/common/monitor/visibility/ChartLayout.jsp"/>
-
- <definition name=".resource.common.monitor.visibility.charts.metric.mmsr"
- controllerUrl="/resource/common/monitor/visibility/ViewChartFormPrepare.do"
- path="/resource/common/monitor/visibility/ChartLayout.jsp"/>
<definition name=".resource.common.monitor.visibility.trait.history"
controllerUrl="/resource/common/monitor/visibility/TraitHistoryFormPrepare.do"
path="/resource/common/monitor/visibility/TraitHistoryLayout.jsp"/>
- <definition name=".resource.common.monitor.visibility.charts.metric.chart"
- path="/resource/common/monitor/visibility/MetricChart.jsp"/>
-
- <definition name=".resource.common.monitor.visibility.charts.metric.navigation"
- path="/resource/common/monitor/visibility/ChartLinksNavigation.jsp"/>
-
- <definition name=".resource.common.monitor.visibility.charts.metric.savecharttoolbar"
- path="/resource/common/monitor/visibility/SaveChartToolbar.jsp"/>
-
<definition name=".resource.common.monitor.visibility.charts.metric.partrsrcs"
path="/resource/common/monitor/visibility/ParticipatingResources.jsp"/>
<definition name=".resource.common.monitor.visibility.charts.metric.baselinerangeparams"
path="/resource/common/monitor/visibility/BaselineExpectedRangeParams.jsp"/>
- <definition name=".resource.common.monitor.visibility.charts.metric.chartparams"
- path="/resource/common/monitor/visibility/ChartParams.jsp"/>
-
- <definition name=".resource.common.monitor.visibility.charts.metric.chartlegend"
- path="/resource/common/monitor/visibility/ChartLegend.jsp"/>
<definition name=".resource.common.monitor.visibility.childResourcesCurrentHealthSummary"
path="/resource/common/monitor/visibility/ChildResourcesCurrentHealthSummary.jsp"/>
@@ -457,61 +429,12 @@
<definition name=".resource.common.monitor.config.ShowOneResourceType"
path="/resource/common/monitor/config/ShowOneResourceType.jsp"/>
- <!-- monitor mini charts -->
- <definition name=".resource.common.monitor.visibility.minicharts"
- path="/resource/common/monitor/visibility/MiniCharts.jsp"/>
<!-- monitor problem metrics -->
<definition name=".resource.common.monitor.visibility.problemmetrics"
path="/resource/common/monitor/visibility/ProblemMetrics.jsp"
controllerUrl="/resource/common/monitor/visibility/ProblemMetricsDisplay.do"/>
- <!-- monitor dash minitabs -->
- <definition name=".resource.common.monitor.visibility.dashminitabs"
- path="/resource/common/monitor/visibility/DashMiniTabs.jsp">
- <put name="tabUrl" value="/Resource.do"/>
- <putList name="standard">
- <item icon="Indicators"
- mode="currentHealth"
- value="0" link="XXX"
- height="21" width="102"
- classtype="org.rhq.enterprise.gui.legacy.util.Tab"/>
- <item icon="MetricData"
- mode="resourceMetrics"
- value="1" link="XXX"
- height="21" width="102"
- classtype="org.rhq.enterprise.gui.legacy.util.Tab"/>
- </putList>
- <putList name="nometrics">
- <item icon="Indicators"
- mode="currentHealth"
- value="0" link="XXX"
- height="21" width="102"
- classtype="org.rhq.enterprise.gui.legacy.util.Tab"/>
- <item icon="Perf"
- mode="performance"
- value="1" link="XXX"
- height="21" width="102"
- classtype="org.rhq.enterprise.gui.legacy.util.Tab"/>
- </putList>
- <putList name="perf">
- <item icon="Indicators"
- mode="currentHealth"
- value="0" link="XXX"
- height="21" width="102"
- classtype="org.rhq.enterprise.gui.legacy.util.Tab"/>
- <item icon="MetricData"
- mode="resourceMetrics"
- value="1" link="XXX"
- height="21" width="102"
- classtype="org.rhq.enterprise.gui.legacy.util.Tab"/>
- <item icon="Perf"
- mode="performance"
- value="2" link="XXX"
- height="21" width="102"
- classtype="org.rhq.enterprise.gui.legacy.util.Tab"/>
- </putList>
- </definition>
<!-- monitor timeline -->
<definition name=".resource.common.monitor.visibility.timeline"
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-def.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-def.xml
index 1d75c3d..45f729e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-def.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-def.xml
@@ -193,9 +193,6 @@
<put name="section" value="common"/>
</definition>
- <!-- monitor mini charts -->
- <definition name=".resource.monitor.visibility.minicharts"
- extends=".resource.common.monitor.visibility.minicharts"/>
<definition name=".resource.monitor.visibility.listchildresources"
extends=".resource.common.monitor.visibility.listchildresources"
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-hub-def.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-hub-def.xml
index ad900f9..cc04a03 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-hub-def.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-hub-def.xml
@@ -42,8 +42,5 @@
<put name="tabKey" value="resource.hub.ListResourcesTab"/>
</definition>
- <definition name=".resource.hub.minichart"
- path="/resource/hub/MiniChart.jsp"
- controllerUrl="/resource/hub/MiniChart.do"/>
</tiles-definitions>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-platform-def.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-platform-def.xml
index 455667a..6254d10 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-platform-def.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/resource-platform-def.xml
@@ -237,9 +237,6 @@
<put name="section" value="common"/>
</definition>
- <!-- monitor mini charts -->
- <definition name=".resource.platform.monitor.visibility.minicharts"
- extends=".resource.common.monitor.visibility.minicharts"/>
<definition name=".resource.platform.monitor.visibility.listchildresources"
extends=".resource.common.monitor.visibility.listchildresources"
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
index b1d3cb3..f623679 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
@@ -335,46 +335,6 @@
</servlet>
<!-- standalone servlets used by the JSPs -->
- <servlet>
- <servlet-name>navMapImage</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.common.servlet.NavMapImageServlet</servlet-class>
- <load-on-startup>3</load-on-startup>
- </servlet>
- <servlet>
- <servlet-name>availHealthChart</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.common.servlet.AvailHealthChartServlet</servlet-class>
- <load-on-startup>3</load-on-startup>
- </servlet>
- <servlet>
- <servlet-name>usageHealthChart</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.common.servlet.UsageHealthChartServlet</servlet-class>
- <load-on-startup>3</load-on-startup>
- </servlet>
- <servlet>
- <servlet-name>utilizationHealthChart</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.common.servlet.UtilizationHealthChartServlet</servlet-class>
- <load-on-startup>3</load-on-startup>
- </servlet>
- <servlet>
- <servlet-name>highLowChart</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.common.servlet.HighLowChartServlet</servlet-class>
- <load-on-startup>3</load-on-startup>
- </servlet>
- <servlet>
- <servlet-name>metricChart</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.common.servlet.MetricChartServlet</servlet-class>
- <load-on-startup>3</load-on-startup>
- </servlet>
- <servlet>
- <servlet-name>performanceChart</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.common.servlet.PerformanceChartServlet</servlet-class>
- <load-on-startup>3</load-on-startup>
- </servlet>
- <servlet>
- <servlet-name>availStoplight</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.common.servlet.AvailabilityStoplightChartServlet</servlet-class>
- <load-on-startup>3</load-on-startup>
- </servlet>
<!-- Struts ActionServlet configuration (with debugging) -->
<servlet>
@@ -435,39 +395,7 @@
<url-pattern>/downloads/*</url-pattern>
</servlet-mapping>
- <!-- standalone servlets used by the JSPs -->
- <servlet-mapping>
- <servlet-name>navMapImage</servlet-name>
- <url-pattern>/resource/NavMapImage</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>availHealthChart</servlet-name>
- <url-pattern>/resource/AvailHealthChart</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>usageHealthChart</servlet-name>
- <url-pattern>/resource/UsageHealthChart</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>utilizationHealthChart</servlet-name>
- <url-pattern>/resource/UtilizationHealthChart</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>highLowChart</servlet-name>
- <url-pattern>/resource/HighLowChart</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>metricChart</servlet-name>
- <url-pattern>/resource/MetricChart</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>performanceChart</servlet-name>
- <url-pattern>/resource/PerformanceChart</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>availStoplight</servlet-name>
- <url-pattern>/resource/AvailStoplight</url-pattern>
- </servlet-mapping>
+
<!-- mappings for Struts ActionServlet -->
<servlet-mapping>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/advanced-metrics.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/advanced-metrics.js
deleted file mode 100644
index 21a7452..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/js/advanced-metrics.js
+++ /dev/null
@@ -1,83 +0,0 @@
-function toggleControls(elementId) {
- var element = document.getElementById(elementId);
- if (element.disabled = true) {
- enableElement(element);
- } else {
- disableElement(element);
- }
-}
-
-function disableElement(elementId) {
- document.getElementById(elementId).disabled = true;
-}
-
-function enableElement(elementId) {
- document.getElementById(elementId).disabled = false;
-}
-
-function uncheckRadio(elementName) {
- var elementsList = document.getElementsByName(elementName);
- for (i = 0; i < elementsList.length; i++) {
- elementsList[i].checked = false;
- }
-}
-
-function checkRadio(elementName) {
- var elementsList = document.getElementsByName(elementName);
- for (i = 0; i < elementsList.length; i++) {
- elementsList[i].checked = true;
- }
-}
-
-function checkUncheckRadio(elementName1, elementName2) {
- checkRadio(elementName1);
- uncheckRadio(elementName2);
-}
-
-function closePopupAndReloadParent() {
- window.opener.location.href = window.opener.location.href;
- if (window.opener.progressWindow) {
- window.opener.progressWindow.close();
- }
- window.opener.location.reload();
- window.opener.focus();
- window.close();
-}
-
-function validateFields() {
- var duration = document.getElementById('advancedMetricsValuesForm:durationMetricType:0').checked;
- var interval = document.getElementById('advancedMetricsValuesForm:intervalMetricType:0').checked;
-
- if(duration) {
- var durationValue = document.getElementById('advancedMetricsValuesForm:duration').value;
- if (isNaN(durationValue)){
- alert("Please enter a valid number");
- return false;
- } else {
- document.advancedMetricsValuesForm.submit();
- closePopupAndReloadParent();
- }
- } else if(interval) {
- var from= document.getElementById('advancedMetricsValuesForm:fromDateInputDate').value;
- var to= document.getElementById('advancedMetricsValuesForm:toDateInputDate').value;
-
- if(from== "" || to == "") {
- alert ("Please fill in the required dates");
- return false;
- } else {
- var fromDate = new Date(from);
- var toDate = new Date(to);
- var now = new Date();
- if(fromDate > now || toDate > now) {
- alert ("Cannot select a date in the future");
- return false;
- } else if (fromDate > toDate ) {
- alert ("From date cannot be greater than to date");
- return false;
- } else {
- document.advancedMetricsValuesForm.submit();
- closePopupAndReloadParent();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/chart.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/chart.js
deleted file mode 100644
index 8a3465d..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/js/chart.js
+++ /dev/null
@@ -1,124 +0,0 @@
-
-/*-- START chart.js --*/
-function ReplaceButton(divId, tdId, tdState, imageId, btnFunction) {
- var td = document.getElementById(tdId);
- var oldDiv = document.getElementById(divId);
-
- var newDiv = document.createElement("DIV");
- newDiv.setAttribute("id", divId);
-
- var newImg;
- var imgState = "";
- if (tdState=="off")
- imgState = "_gray";
-
- var imgName = imagePath + "tbb_" + imageId;
-
- var inputName = btnFunction;
- var inputValue = btnFunction;
-
- imgPath = imgName + imgState + ".gif";
- newImg = getNewImage (imgPath, false, false, "0");
-
- if (tdState == "on") {
- var newInput = document.createElement("INPUT");
- newInput.setAttribute("type", "image");
- newInput.setAttribute("src", imgPath);
- newInput.setAttribute("name", inputName);
- newDiv.appendChild(newInput);
- }
-
- else {
- newDiv.appendChild(newImg);
- }
-
- if (td!=null)
- td.replaceChild(newDiv,oldDiv);
-}
-
-function ToggleButtons(widgetInstanceName, prefix, form) {
- var btnFunction = "redraw";
- var imgName = "redrawselectedonchart";
-
- var numSelected = getWidgetProperty(widgetInstanceName, "numSelected");
-
- if (numSelected < 0) {
- numSelected = getNumCheckedByClass(form, "listMember");
- setWidgetProperty(widgetInstanceName, "numSelected", numSelected);
- }
-
- if (numSelected == 0) {
- ReplaceButton(prefix + "RedrawDiv", prefix + "RedrawTd", "off", imgName, btnFunction);
- }
-
- else if (numSelected >= 1) {
- ReplaceButton(prefix + "RedrawDiv", prefix + "RedrawTd", "on", imgName, btnFunction);
- }
-}
-
-function ToggleSelection(e, widgetProperties, maxNum, messageStr) {
- if (isIE)
- e = event.srcElement;
-
- if (maxNum!=null) {
- var numChecked = getNumChecked(e.form, e.getAttribute("name"));
- if (numChecked > maxNum) {
- e.checked = false;
- alert(messageStr);
- return;
- }
- }
-
- widgetInstanceName = widgetProperties["name"];
- var prefix = widgetInstanceName;
-
- var form = e.form;
- var numSelected = getWidgetProperty(widgetInstanceName, "numSelected");
-
- if (e.checked) {
- highlight(e);
- setWidgetProperty(widgetInstanceName, "numSelected", ++numSelected);
- } else {
- unhighlight(e);
- var numSelected = getWidgetProperty(widgetInstanceName, "numSelected");
- setWidgetProperty(widgetInstanceName, "numSelected", --numSelected);
- }
-
- ToggleButtons(widgetInstanceName, prefix, form);
-}
-
-function getNumChecked(uList, nameStr) {
- var len = uList.elements.length;
- var numCheckboxes = 0;
-
- for (var i = 0; i < len; i++) {
- var e = uList.elements[i];
- if (e.getAttribute("name")==nameStr && e.checked) {
- numCheckboxes++;
- }
- }
-
- return numCheckboxes;
-}
-
-function checkboxToggled(cb, hidden) {
- var checkbox = document.getElementsByName(cb)[0];
- var field = document.getElementsByName(hidden)[0];
-
- if (checkbox.checked) {
- field.value = "true";
- } else {
- field.value = "false";
- }
-}
-
-function testCheckboxes(widgetInstanceName) {
- var e = document.getElementById("privateChart");
- var thisForm = e.form;
-
- var numChecked = getNumCheckedByClass(thisForm, "metricList") + getNumCheckedByClass(thisForm, "resourceList");
- setWidgetProperty(widgetInstanceName, "numSelected", numChecked);
-
- ToggleButtons(widgetInstanceName, widgetInstanceName, thisForm);
-}
-/*-- END chart.js --*/
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/monitorGraphs.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/monitorGraphs.js
deleted file mode 100644
index e898e4a..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/js/monitorGraphs.js
+++ /dev/null
@@ -1,42 +0,0 @@
- var eventsTime = 0;
- var detailsShowing = false;
-
- function initEventDetails() {
- ajaxEngine.registerRequest( 'getEventDetails', '/resource/common/monitor/visibility/EventDetails.do');
- ajaxEngine.registerAjaxElement('eventsSummary',document.getElementById('eventsSummary'));
- }
-
-
- function showEventsCallback() {
- var detail = $('eventsSummary');
- if (detail.innerHTML == "") {
- setTimeout("showEventsCallback()", 200);
- }
- else {
- var div = $('eventDetailTable');
- if (div.style.display == 'none')
- new Effect.Appear(div, {afterFinish: function (obj) {
- maxIndicatorDivHeight();
- }});
- }
- }
-
- function hideEventDetail() {
- new Effect.Fade($('eventsSummary'));
- }
-
- var statusArr =
- new Array ("ALL", "ERR", "WRN", "INF", "DBG", "ALR", "CTL");
-
- function filterEventsDetails(severity) {
- for (i = 0; i < statusArr.length; i++) {
- $(statusArr[i] + "EventsTab").className = "eventsTab";
- }
-
- $(severity + "EventsTab").className = "eventsTabOn";
-
- if (severity != statusArr[0])
- showEventsDetails(eventsTime, severity);
- else
- showEventsDetails(eventsTime);
- }
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartLayout.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartLayout.jsp
deleted file mode 100644
index 4176916..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartLayout.jsp
+++ /dev/null
@@ -1,134 +0,0 @@
-<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %>
-<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<%@ taglib uri="/WEB-INF/tld/hq.tld" prefix="hq" %>
-
-<c:choose>
-<c:when test="${not empty toDashboard}">
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td rowspan="3" class="PageTitle">
- <html:img page="/images/spacer.gif" width="5" height="1" alt="" border="0"/>
- </td>
- <td width="100%">
- <table width="100%" border="0" cellspacing="0" cellpadding="4">
- <tr class="ListHeader">
- <td>
- <fmt:message key="dash.home.SavedQueries"/>
- </td>
- </tr>
- <tr class="ListRow">
- <td>
- <fmt:message key="resource.common.monitor.visibility.error.ChartRemoved"/>
- </td>
- </tr>
- <tr class="ListRow">
- <td>
- <html:link page="/Dashboard.do">
- <fmt:message key="alert.current.detail.link.noresource.Rtn"/>
- </html:link>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-</c:when>
-<c:otherwise>
-
- <hq:constant classname="org.rhq.enterprise.gui.legacy.Constants"
- symbol="MODE_MON_CHART_SMSR"
- var="MODE_MON_CHART_SMSR"/>
- <hq:constant classname="org.rhq.enterprise.gui.legacy.Constants"
- symbol="MODE_MON_CHART_MMSR"
- var="MODE_MON_CHART_MMSR"/>
- <hq:constant classname="org.rhq.enterprise.gui.legacy.Constants"
- symbol="MODE_MON_CHART_SMMR"
- var="MODE_MON_CHART_SMMR"/>
-
- <script language="JavaScript" src="<html:rewrite page="/js/chart.js"/>" type="text/javascript"></script>
-
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td colspan="3">
- <c:choose>
- <c:when test="${param.mode == MODE_MON_CHART_MMSR}">
- <c:set var="metricName">
- <fmt:message key="resource.common.monitor.visibility.MultipleMetric"/>
- </c:set>
- </c:when>
- <c:otherwise>
- <c:set var="metricName" value="${ViewChartForm.chartName}"/>
- </c:otherwise>
- </c:choose>
- <tiles:insert definition=".page.title.resource.generic">
- <tiles:put name="titleKey" value="resource.common.monitor.visibility.SingleResourceChartPageTitle"/>
- <tiles:put name="titleName" beanName="Resource" beanProperty="name"/>
- <tiles:put name="subTitleName" beanName="metricName"/>
-
- </tiles:insert>
- </td>
- </tr>
- <tr>
- <td>
- <html:img page="/images/spacer.gif" width="75" height="1" alt="" border="0"/>
- </td>
- <td width="100%">
- <tiles:insert definition=".portlet.confirm"/>
- <html:form action="/resource/common/monitor/visibility/ViewChart">
- <c:choose>
- <c:when test="${param.mode == MODE_MON_CHART_SMSR}">
- <html:hidden property="chartName" value="${Resource.name}: ${chartedMetrics[0].metricName}"/>
- <tiles:insert definition=".resource.common.monitor.visibility.charts.metric.chart"/>
- <br>
- <html:hidden property="m" value="${ViewChartForm.m[0]}"/>
-<%-- <tiles:insert definition=".resource.common.monitor.visibility.charts.metric.partrsrcs"/>
- <br>
---%>
- <tiles:insert definition=".resource.common.monitor.visibility.charts.metric.baselinerangeparams">
- <tiles:put name="edit" value="false"/>
- </tiles:insert>
- <br>
- </c:when>
-
- <c:when test="${param.mode == MODE_MON_CHART_MMSR}">
- <html:hidden property="chartName" value="${Resource.name}: Multimetric "/>
- <tiles:insert definition=".resource.common.monitor.visibility.charts.metric.chart">
- <tiles:put name="multiMetric" value="true"/>
- </tiles:insert>
- <tiles:insert definition=".resource.common.monitor.visibility.charts.metric.savecharttoolbar"/>
- <br>
- <tiles:insert definition=".resource.common.monitor.visibility.charts.metric.partrsrcs">
- <tiles:put name="multiMetric" value="true"/>
- </tiles:insert>
- <br>
- </c:when>
-
- <c:when test="${param.mode == MODE_MON_CHART_SMMR}">
- <html:hidden property="chartName" value="${ViewChartForm.chartName}: ${chartedMetrics[0].metricName}" />
- <tiles:insert definition=".resource.common.monitor.visibility.charts.metric.chart">
- <tiles:put name="multiResource" value="true"/>
- </tiles:insert>
- <br>
- <%--
- <tiles:insert definition=".resource.common.monitor.visibility.charts.metric.baselinerangeparams">
- <tiles:put name="edit" value="false"/>
- </tiles:insert>
- <br>
- --%>
- <tiles:insert definition=".resource.common.monitor.visibility.charts.metric.partrsrcs">
- <tiles:put name="multiResource" value="true"/>
- </tiles:insert>
- <br>
- </c:when>
- </c:choose>
- </html:form>
- </td>
- <td>
- <html:img page="/images/spacer.gif" width="80" height="1" alt="" border="0"/>
- </td>
- </tr>
- </table>
-</c:otherwise>
-</c:choose>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartLegend.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartLegend.jsp
deleted file mode 100644
index 87b624a..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartLegend.jsp
+++ /dev/null
@@ -1,38 +0,0 @@
-<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %>
-<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<%@ taglib uri="/WEB-INF/tld/hq.tld" prefix="hq" %>
-
-<table width="100%" cellpadding="3" cellspacing="0" border="0">
- <tr>
- <td width="100%">
- <b><fmt:message key="resource.common.monitor.visibility.chart.ResourceAndControlActionKeyLabel"/></b><br>
-
- <c:forEach var="resource" varStatus="resStatus" items="${checkedResources}">
- <c:url var="resourceUrl" value="/rhq/resource/monitor/graphs.xhtml">
- <c:param name="id" value="${resource.id}"/>
- </c:url>
- <c:url var="parentResourceUrl" value="/rhq/resource/monitor/graphs.xhtml">
- <c:param name="id" value="${resource.parentResource.id}"/>
- </c:url>
- <fmt:formatNumber var="imgidx" pattern="00" value="${resStatus.index + 1}"/>
- <p><b><fmt:message key="resource.common.monitor.visibility.chart.ResourceLabel"/></b>
- <html:img page="/images/icon_resource_${imgidx}.gif" width="11" height="11" border="0"/>
- <%--<html:link href="${parentResourceUrl}">--%>
- <c:out value="${resource.parentResource.name}"/>
- <%--</html:link>--%>
- <br>
-
-
-
-
- <html:img page="/images/hierarchy.gif" width="16" height="16" alt="" border="0"/>
- <%--<html:link href="${resourceUrl}">--%>
- <c:out value="${resource.name}"/>
- <%--</html:link>--%>
- <br>
- </c:forEach>
- </td>
- </tr>
-</table>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartLinksNavigation.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartLinksNavigation.jsp
deleted file mode 100644
index 3a44246..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartLinksNavigation.jsp
+++ /dev/null
@@ -1,14 +0,0 @@
-<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-
-
-<%-- NOT in v1
- |
-<html:link href="#"><fmt:message
-key="resource.common.monitor.visibility.chart.PreviousMetricLink"/></html:link> |
-<html:link href="#"><fmt:message
-key="resource.common.monitor.visibility.chart.NextMetricLink"/></html:link>
---%>
-
- <br><br>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartParams.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartParams.jsp
deleted file mode 100644
index deca40f..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartParams.jsp
+++ /dev/null
@@ -1,204 +0,0 @@
-<%@ page language="java" %>
-<%@ page errorPage="/common/Error.jsp" %>
-<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %>
-<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<%@ taglib uri="/WEB-INF/tld/hq.tld" prefix="hq" %>
-
-<tiles:importAttribute name="multiResource" ignore="true"/>
-<c:if test="${empty multiResource}">
- <c:set var="multiResource" value="false"/>
-</c:if>
-
-<hq:constant classname="org.rhq.enterprise.gui.legacy.Constants"
- symbol="CONTROL_ENABLED_ATTR" var="CONST_CONTROLLABLE"/>
-<c:set var="canControl" value="${requestScope[CONST_CONTROLLABLE]}"/>
-
-<c:choose>
- <c:when test="${not empty groupId}">
- <html:hidden property="groupId" value="${groupId}"/>
- </c:when>
- <c:when test="${not empty parent}">
- <html:hidden property="parent" value="${parent}"/>
- <html:hidden property="type" value="${type}"/>
- </c:when>
- <c:otherwise>
- <html:hidden property="id" value="${Resource.id}"/>
- </c:otherwise>
-</c:choose>
-
-<html:hidden property="ctype"/>
-<html:hidden property="mode" value="${param.mode}"/>
-
-<c:forEach var="mid" items="${ViewChartForm.origM}">
- <html:hidden property="origM" value="${mid}"/>
-</c:forEach>
-
-<table width="100%" cellpadding="3" cellspacing="0" border="0">
-<tr>
- <td colspan="6" class="BlockBottomLine">
- <html:img
- page="/images/spacer.gif" width="1" height="1" border="0"/>
- </td>
-</tr>
-<tr>
- <td width="30" rowspan="4">
- <html:img
- page="/images/spacer.gif" width="30" height="1" border="0"/>
- </td>
- <td width="125">
- <html:hidden property="showValues"/>
- <input type="checkbox" name="showValuesCB"
- <c:if test="${ViewChartForm.showValues}"> checked</c:if>
- onclick="javascript:checkboxToggled('showValuesCB', 'showValues');">
- <html:img page="/images/icon_actual.gif" width="11"
- height="11" border="0"/>
- <fmt:message
- key="resource.common.monitor.visibility.chart.Actual"/>
- </td>
- <td width="125">
- <html:hidden property="showPeak"/>
- <input type="checkbox" name="showPeakCB"
- <c:if test="${ViewChartForm.showPeak}"> checked</c:if>
- onclick="javascript:checkboxToggled('showPeakCB', 'showPeak');">
- <html:img page="/images/icon_peak.gif" width="11" height="11"
- border="0"/>
- <fmt:message
- key="resource.common.monitor.visibility.chart.Peak"/>
- </td>
- <td width="125">
- <html:hidden property="showHighRange"/>
- <input type="checkbox" name="showHighRangeCB"
- <c:if test="${ViewChartForm.showHighRange}"> checked</c:if>
- <c:if test="${empty ViewChartForm.highRange}"> disabled</c:if>
- onclick="javascript:checkboxToggled('showHighRangeCB', 'showHighRange');">
- <html:img page="/images/icon_highrange.gif" width="11"
- height="11" border="0"/>
- <fmt:message
- key="resource.common.monitor.visibility.chart.HighRange"/>
- </td>
- <td rowspan="4">
- <html:img page="/images/spacer.gif" width="30" height="1" border="0"/>
- </td>
- <!-- commenting for iframe display in coregui.-->
- <!--<td rowspan="4" valign="top">
-
- <table border="0">
- <tr>
- <td class="LinkBox">
- <hq:authorization permission="MANAGE_ALERTS">
- <c:if test="${not multiResource}">
- <c:url var="alertLink" value="/alerts/Config.do">
- <c:param name="mode" value="new"/>
- <c:param name="id" value="${Resource.id}"/>
- <c:param name="metricId" value="${param.m}"/>
- </c:url>
- <html:link href="${alertLink}">
- <fmt:message key="resource.common.monitor.visibility.NewAlertLink"/>
- <html:img page="/images/title_arrow.gif" width="11" height="9" alt="" border="0"/>
- </html:link>
- <br>
- </c:if>
- </hq:authorization>
-
- <html:hidden property="saveChart" value="false"/>
- <html:link href="."
- onclick="ViewChartForm.saveChart.value='true'; ViewChartForm.submit(); return false;">
- <fmt:message key="resource.common.monitor.visibility.SaveChartToDash"/>
- <html:img page="/images/title_arrow.gif" width="11" height="9" alt="" border="0"/>
- </html:link>
- <br>
-
- <c:if test="${not empty back}">
- <html:link page="${back}">
- <fmt:message key="resource.common.monitor.visibility.Back2Resource"/>
- <html:img page="/images/title_arrow.gif" width="11" height="9" alt="" border="0"/>
- </html:link>
- </c:if>
-
- </td>
- </tr>
- </table>
-
- </td>-->
-</tr>
-<tr>
- <td>
- <c:if test="${canControl}">
- <html:hidden property="showEvents"/>
- <input type="checkbox" name="showEventsCB"
- <c:if test="${ViewChartForm.showEvents}"> checked</c:if>
- onclick="javascript:checkboxToggled('showEventsCB', 'showEvents');">
- <html:img page="/images/icon_controlactions.gif"
- width="11" height="11" border="0"/>
- <fmt:message
- key="resource.common.monitor.visibility.chart.ControlActions"/>
- </c:if>
- </td>
- <td>
- <html:hidden property="showAverage"/>
- <input type="checkbox" name="showAverageCB"
- <c:if test="${ViewChartForm.showAverage}"> checked</c:if>
- onclick="javascript:checkboxToggled('showAverageCB', 'showAverage');">
- <html:img page="/images/icon_average.gif" width="11" height="11"
- border="0"/>
- <fmt:message
- key="resource.common.monitor.visibility.chart.Average"/>
- </td>
- <td>
- <html:hidden property="showBaseline"/>
- <input type="checkbox" name="showBaselineCB"
- <c:if test="${ViewChartForm.showBaseline}"> checked</c:if>
- <c:if test="${empty ViewChartForm.baseline}"> disabled</c:if>
- onclick="javascript:checkboxToggled('showBaselineCB', 'showBaseline');">
- <html:img page="/images/icon_baseline.gif" width="11"
- height="11" border="0"/>
- <fmt:message
- key="resource.common.monitor.visibility.chart.Baseline"/>
- </td>
-</tr>
-<tr>
- <td> </td>
- <td>
- <html:hidden property="showLow"/>
- <input type="checkbox" name="showLowCB"
- <c:if test="${ViewChartForm.showLow}"> checked</c:if>
- onclick="javascript:checkboxToggled('showLowCB', 'showLow');">
- <html:img page="/images/icon_low.gif" width="11" height="11"
- border="0"/>
- <fmt:message
- key="resource.common.monitor.visibility.chart.Low"/>
- </td>
- <td>
- <html:hidden property="showLowRange"/>
- <input type="checkbox" name="showLowRangeCB"
- <c:if test="${ViewChartForm.showLowRange}"> checked</c:if>
- <c:if test="${empty ViewChartForm.lowRange}"> disabled</c:if>
- onclick="javascript:checkboxToggled('showLowRangeCB', 'showLowRange');">
- <html:img page="/images/icon_lowrange.gif" width="11"
- height="11" border="0"/>
- <fmt:message
- key="resource.common.monitor.visibility.chart.LowRange"/>
- </td>
-</tr>
-<tr>
- <td colspan="3">
- <html:image page="/images/fb_redraw.gif" property="redraw" border="0"
- onmouseover="imageSwap(this, imagePath + 'fb_redraw', '_over');"
- onmouseout="imageSwap(this, imagePath + 'fb_redraw', '');"
- onmousedown="imageSwap(this, imagePath + 'fb_redraw', '_down')" tabindex="1" accesskey="r"/>
- </td>
-</tr>
-<tr>
- <td colspan="6" class="BlockBottomLine">
- <html:img
- page="/images/spacer.gif" width="1" height="1" border="0"/>
- </td>
-</tr>
-</table>
-<script language="JavaScript" type="text/javascript">
- <!--
- document.forms["ViewChartForm"].elements["showValuesCB"].focus();
- // -->
-</script>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartTimeIntervalToolbar.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartTimeIntervalToolbar.jsp
deleted file mode 100644
index 642baff..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/ChartTimeIntervalToolbar.jsp
+++ /dev/null
@@ -1,45 +0,0 @@
-<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %>
-<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<%@ taglib uri="/WEB-INF/tld/hq.tld" prefix="hq" %>
-
-<tiles:importAttribute name="rangeNow"/>
-<tiles:importAttribute name="begin"/>
-<tiles:importAttribute name="end"/>
-<tiles:importAttribute name="prevProperty" ignore="true"/>
-<tiles:importAttribute name="nextProperty" ignore="true"/>
-
-<c:if test="${empty prevProperty}">
-<c:set var="prevProperty" value="prevRange"/>
-</c:if>
-<c:if test="${empty nextProperty}">
-<c:set var="nextProperty" value="nextRange"/>
-</c:if>
-
-<table width="100%" cellpadding="0" cellspacing="0" border="0">
- <tr>
- <td class="BlockBottomLine" colspan="3"><html:img
- page="/images/spacer.gif" width="1" height="1" border="0"/></td>
- </tr>
- <tr>
- <td class="BlockContent" width="100%" align="right">
- <html:image property="${prevProperty}" page="/images/tbb_pageleft.gif" border="0"/>
- </td>
- <td class="BlockContent" nowrap>
- <hq:dateFormatter value="${begin}"/>
- <fmt:message key="resource.common.monitor.visibility.chart.to"/>
- <hq:dateFormatter value="${end}"/>
- </td>
- <td class="BlockContent">
- <c:choose>
- <c:when test="${rangeNow}">
- <html:img page="/images/tbb_pageright_gray.gif" border="0"/>
- </c:when>
- <c:otherwise>
- <html:image property="${nextProperty}" page="/images/tbb_pageright.gif" border="0"/>
- </c:otherwise>
- </c:choose>
- </td>
- </tr>
-</table>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/SaveChartToolbar.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/SaveChartToolbar.jsp
deleted file mode 100644
index 773462f..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/visibility/SaveChartToolbar.jsp
+++ /dev/null
@@ -1,13 +0,0 @@
-<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %>
-
-<table width="100%" cellpadding="0" cellspacing="0" border="0">
- <tr>
- <td class="BlockBottomLine"><html:img page="/images/spacer.gif"
- width="1" height="1" border="0"/></td>
- </tr>
- <tr>
- <td class="BlockContent" width="100%">
- <html:image property="saveChart" page="/images/tbb_savecharttodashboard.gif" border="0"/>
- </td>
- </tr>
-</table>
10 years, 10 months
[rhq] 4 commits - modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java | 7 ----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java | 16 ++++++++--
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 2 -
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties | 2 -
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 2 -
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 2 -
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties | 2 -
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 2 -
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties | 2 -
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 2 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java | 4 +-
11 files changed, 24 insertions(+), 19 deletions(-)
New commits:
commit 8541740a34c72d69452568370900c787ec4c421a
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Aug 21 18:17:53 2013 -0400
bundle create wizard, Fix issue when there are no assignable groups
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java
index b9869b8..487aedb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java
@@ -143,7 +143,19 @@ public class BundleGroupsStep extends AbstractWizardStep {
canvas.addMember(selector);
} else {
- throw new IllegalStateException(MSG.view_bundle_createWizard_groupsStep_noAssignable());
+ // can't call wizard show message, the canvas is not yet created, so make the canvas the message
+ DynamicForm form = new DynamicForm();
+ form.setWidth100();
+ HeaderItem errorHeaderItem = new HeaderItem();
+ errorHeaderItem.setAttribute("wrap", true); // forum tip, only way I could get the text to wrap
+ errorHeaderItem.setWidth(650);
+ errorHeaderItem.setValue(MSG.view_bundle_createWizard_groupsStep_noAssignable());
+ FormUtility.addContextualHelp(errorHeaderItem, MSG.view_bundle_createWizard_groupsStep_help());
+ form.setItems(errorHeaderItem);
+
+ canvas.addMember(form);
+
+ CoreGUI.getErrorHandler().handleError(MSG.view_bundle_createWizard_groupsStep_noAssignable());
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 93bb22e..b44a67f 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -1226,7 +1226,7 @@ view_bundle_createWizard_groupsStep_assign = Assign at least one of the eligible
view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
-view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your RHQ administrator.
+view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
index 015917d..7ce4b17 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
@@ -1240,7 +1240,7 @@ view_bundle_createWizard_failedToUploadFile = Nepodařilo se nahrát soubor bal
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
-##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your RHQ administrator.
+##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 9cbe726..6b5e006 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -1143,7 +1143,7 @@ view_bundle_bundleVersions = Bundle-Versionen
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
-##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your RHQ administrator.
+##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 124a395..554c47c 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -1215,7 +1215,7 @@ view_bundle_createWizard_failedToUploadFile = バンドルファイルのアッ
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
-##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your RHQ administrator.
+##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
index f62c248..09cff8a 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
@@ -1090,7 +1090,7 @@ view_bundle_createWizard_enterUrl = Please enter a valid URL from where the bund
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
-##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your RHQ administrator.
+##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index c42b32e..bf7a092 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -1228,7 +1228,7 @@ view_bundle_createWizard_failedToUploadFile = Falha ao fazer o upload do bundle
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
-##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your RHQ administrator.
+##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
index 72efd32..99bc501 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
@@ -2790,7 +2790,7 @@ view_admin_systemSettings_LDAPBindPW_name = Пароль
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
-##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your RHQ administrator.
+##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 174591c..dd1aaf0 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -1212,7 +1212,7 @@ view_bundle_createWizard_failedToUploadFile = \u4e0a\u4f20bundle\u6587\u4ef6\u59
##view_bundle_createWizard_groupsStep_assigned = The new bundle version is for an existing bundle and inherits its bundle group assignments:
##view_bundle_createWizard_groupsStep_help = A new bundle is created when uploading the first version for that bundle. The new bundle is then assigned to its initial bundle groups. A user can only assign the new bundle to bundle groups for which he has Create Bundles permission, either global or at the bundle group level. At least one bundle group must be assigned unless the user has global Create and global View Bundles permission, in which case it can be left unassigned.
##view_bundle_createWizard_groupsStep_leaveUnassigned = Leave the new bundle unsassigned.
-##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your RHQ administrator.
+##view_bundle_createWizard_groupsStep_noAssignable = Unable to create initial bundle version because the user has no bundle groups to which it can be assigned. Please cancel the create wizard and notify your administrator.
##view_bundle_createWizard_groupsStep_noneAssigned = The new bundle version must be assigned to at least one bundle group!:
##view_bundle_createWizard_groupsStep_radioTitle = Initial bundle group assignment for the new bundle
##view_bundle_createWizard_groupsStep_unassigned = The new bundle version is for an existing bundle and inherits its bundle group assignments. The bundle is not currently assigned to any bundle groups.
commit f2d33e1a47d56c50ddc44d6f7cf5d73370006b1d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Aug 21 18:03:25 2013 -0400
Fix issue with bundle group removal from role.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
index 198018c..b56dce4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
@@ -485,10 +485,10 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
Set<BundleGroup> newBundleGroups = role.getBundleGroups();
if (newBundleGroups != null) {
- Set<BundleGroup> currentBundleGroups = attachedRole.getBundleGroups();
// wrap in new HashSet to avoid ConcurrentModificationExceptions.
+ Set<BundleGroup> currentBundleGroups = attachedRole.getBundleGroups();
Set<BundleGroup> bundleGroupsToRemove = new HashSet<BundleGroup>(currentBundleGroups);
- for (BundleGroup bg : currentBundleGroups) {
+ for (BundleGroup bg : newBundleGroups) {
bundleGroupsToRemove.remove(bg);
}
for (BundleGroup bg : bundleGroupsToRemove) {
commit 35de1a2f924cc5f4489f95161de4f3aabb36f278
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Aug 21 17:35:04 2013 -0400
remove unwanted tooltip from bundle create wizard
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java
index 67b7470..b9869b8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java
@@ -140,8 +140,6 @@ public class BundleGroupsStep extends AbstractWizardStep {
canvas.addMember(form);
selector = getSelector(map, false);
- selector.setTitle(MSG.view_bundle_createWizard_groupsStep_assign());
- selector.setTooltip(MSG.view_bundle_createWizard_groupsStep_help());
canvas.addMember(selector);
} else {
commit b810840958d71d8638f8bae59e54fba72d10b8a0
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Aug 21 17:34:35 2013 -0400
remove view_bundles_in_group from the permission editor, it's implied and
should not be manipulated in the editor (like view_resources)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java
index d270844..e62bdbf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java
@@ -74,7 +74,7 @@ public class PermissionsEditor extends EnhancedVStack {
this.roleEditView = roleEditView;
this.isReadOnly = isReadOnly;
// Default permission set
- this.selectedPermissions = EnumSet.of(Permission.VIEW_RESOURCE);
+ this.selectedPermissions = EnumSet.of(Permission.VIEW_RESOURCE, Permission.VIEW_BUNDLES_IN_GROUP);
setWidth("95%");
setHeight100();
@@ -362,11 +362,6 @@ public class PermissionsEditor extends EnhancedVStack {
MSG.view_adminRoles_permissions_permDesc_deleteBundlesFromGroup());
records.add(record);
- record = createPermissionRecord(MSG.view_adminRoles_permissions_perm_viewBundlesInGroup(),
- "subsystems/bundle/BundleGroup", Permission.VIEW_BUNDLES_IN_GROUP,
- MSG.view_adminRoles_permissions_permDesc_viewBundlesInGroup());
- records.add(record);
-
grid.setData(records.toArray(new ListGridRecord[records.size()]));
return grid;
10 years, 10 months