[rhq] 2 commits - modules/plugins
by John Sanda
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 5
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 4
modules/plugins/apache/src/main/java/org/rhq/plugins/www/util/WWWUtils.java | 66 +++++++++-
modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml | 16 ++
4 files changed, 83 insertions(+), 8 deletions(-)
New commits:
commit b0b1faebbac98f652f713aa56f7fff97f564f36e
Merge: 7e3d988 04323ed
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Apr 7 11:47:26 2011 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 7e3d9889259a68be7a1461df2ff1908dcc2b8f67
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Apr 7 10:05:47 2011 -0400
[BZ 690430] Adding support for disabling SSL cert verification
Adding the ability to disable certification validation for availability
checks. This may be useful when working with self-signed certs in a dev
or testing environment.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
index 4582f13..053be8a 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
@@ -42,6 +42,7 @@ import org.rhq.augeas.tree.AugeasTree;
import org.rhq.augeas.util.Glob;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.event.EventSeverity;
@@ -230,10 +231,12 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
// try to find a pid file under the server root, and then check if the
// process is running.
boolean available;
+ Configuration pluginConfig = resourceContext.getPluginConfiguration();
+ PropertySimple disableCertValidation = pluginConfig.getSimple("disableCertificateValidation");
try {
if (this.url != null) {
long t1 = System.currentTimeMillis();
- available = WWWUtils.isAvailable(this.url);
+ available = WWWUtils.isAvailable(this.url, disableCertValidation.getBooleanValue());
availPingTime = System.currentTimeMillis() - t1;
} else {
available = getSNMPSession().ping();
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index b43e156..898a9b3 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -130,7 +130,9 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
}
public AvailabilityType getAvailability() {
- return (this.url != null && WWWUtils.isAvailable(this.url)) ? AvailabilityType.UP : AvailabilityType.DOWN;
+ Configuration pluginConfig = resourceContext.getPluginConfiguration();
+ PropertySimple disableCertValidation = pluginConfig.getSimple("disableCertificateValidation");
+ return (this.url != null && WWWUtils.isAvailable(this.url, disableCertValidation.getBooleanValue())) ? AvailabilityType.UP : AvailabilityType.DOWN;
}
public Configuration loadResourceConfiguration() throws Exception {
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/www/util/WWWUtils.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/www/util/WWWUtils.java
index 8e9f709..c1ff6eb 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/www/util/WWWUtils.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/www/util/WWWUtils.java
@@ -21,6 +21,19 @@ package org.rhq.plugins.www.util;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Helper class that contains methods that send http requests and evaluate results
@@ -28,16 +41,24 @@ import java.net.URL;
*/
public abstract class WWWUtils {
- /**
- * Sends a HEAD request to the passed url and returns if the server was reachable
- * @param httpURL a http or https URL to check
- * @return true if connecting to the URL succeeds, or false otherwise
- */
- public static boolean isAvailable(URL httpURL) {
+ private static final Log log = LogFactory.getLog(WWWUtils.class);
+
+ /**
+ * Sends a HEAD request to the passed url and returns if the server was reachable
+ * @param httpURL a http or https URL to check
+ * @return true if connecting to the URL succeeds, or false otherwise
+ */
+
+ public static boolean isAvailable(URL httpURL, boolean disableCertValidation) {
try {
HttpURLConnection connection = (HttpURLConnection) httpURL.openConnection();
connection.setRequestMethod("HEAD");
connection.setConnectTimeout(3000);
+
+ if ((connection instanceof HttpsURLConnection) && disableCertValidation) {
+ disableCertificateVerification((HttpsURLConnection) connection);
+ }
+
connection.connect();
// get the respone code to actually trigger sending the Request.
connection.getResponseCode();
@@ -70,4 +91,37 @@ public abstract class WWWUtils {
}
return ret;
}
+
+ // This method has been added in support of https://bugzilla.redhat.com/show_bug.cgi?id=690430.
+ private static void disableCertificateVerification(HttpsURLConnection connection) {
+ TrustManager[] trustAllCerts = new TrustManager[]{
+ new X509TrustManager() {
+ public X509Certificate[] getAcceptedIssuers() {
+ return new X509Certificate[] {};
+ }
+
+ public void checkClientTrusted(X509Certificate[] certs, String authType) {
+ }
+
+ public void checkServerTrusted(X509Certificate[] certs, String authType) {
+ }
+ }
+ };
+ try {
+ SSLContext sslContext = SSLContext.getInstance("SSL");
+ sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
+ connection.setSSLSocketFactory(sslContext.getSocketFactory());
+ connection.setHostnameVerifier(new HostnameVerifier() {
+ @Override
+ public boolean verify(String s, SSLSession sslSession) {
+ return true;
+ }
+ });
+ } catch (NoSuchAlgorithmException e) {
+ log.warn("Failed to disable certificate validation.", e);
+ } catch (KeyManagementException e) {
+ log.warn("Failed to disable certificate validation.", e);
+ }
+ }
+
}
\ No newline at end of file
diff --git a/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
index 420aa01..674b2fb 100644
--- a/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
@@ -280,6 +280,14 @@
description="the UDP port of the Apache SNMP agent (typically '1610')"/>
<c:simple-property name="snmpAgentCommunity" displayName="SNMP Agent Community" default="public"
description="the SNMP community of the Apache SNMP agent (typically 'public')"/>
+ <c:simple-property name="disableCertificateValidation" type="boolean" default="false"
+ description="If you use HTTPS URLs for availability checks and the certificates aren't
+ trusted by the JVM that runs the agent or the certificates aren't issued for the
+ hostname that you use for the availability checks, you can use this property to switch
+ off the certificate validation. Note that this opens up a possilibity of
+ man-in-the-middle attacks and other SSL related security issues. The agent will switch
+ off the validation only for the duration of the request to the configured URL and will
+ contact no other URL than the one configured."/>
<c:simple-property name="restartAfterConfigurationUpdate" type="boolean" default="true" required="true">
<c:description>
@@ -493,6 +501,14 @@
<plugin-configuration>
<c:simple-property name="url" displayName="URL"
description="the http or https URL that will be used to check availability for this virtual host"/>
+ <c:simple-property name="disableCertificateValidation" type="boolean" default="false"
+ description="If you use HTTPS URLs for availability checks and the certificates aren't
+ trusted by the JVM that runs the agent or the certificates aren't issued for the
+ hostname that you use for the availability checks, you can use this property to switch
+ off the certificate validation. Note that this opens up a possilibity of
+ man-in-the-middle attacks and other SSL related security issues. The agent will switch
+ off the validation only for the duration of the request to the configured URL and will
+ contact no other URL than the one configured."/>
<c:group name="ResponseTime">
<c:simple-property name="responseTimeLogFile" required="false"
description="the full path to the log file containing response-time stats for this virtual host"/>
13 years, 1 month
[rhq] Branch 'release-3.0.1' - modules/plugins
by John Sanda
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 7 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 4
modules/plugins/apache/src/main/java/org/rhq/plugins/www/util/WWWUtils.java | 66 +++++++++-
modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml | 16 ++
4 files changed, 84 insertions(+), 9 deletions(-)
New commits:
commit f541d7383773529cc12d30faf9f154c9b5bae1fc
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Apr 7 10:05:47 2011 -0400
[BZ 690430] Adding support for disabling SSL cert verification
Adding the ability to disable certification validation for availability
checks. This may be useful when working with self-signed certs in a dev
or testing environment.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
index b320028..369c18f 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
@@ -44,6 +44,7 @@ import org.rhq.augeas.tree.AugeasTree;
import org.rhq.augeas.util.Glob;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.event.EventSeverity;
@@ -232,10 +233,12 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
// try to find a pid file under the server root, and then check if the
// process is running.
boolean available;
+ Configuration pluginConfig = resourceContext.getPluginConfiguration();
+ PropertySimple disableCertValidation = pluginConfig.getSimple("disableCertificateValidation");
try {
if (this.url != null) {
long t1 = System.currentTimeMillis();
- available = WWWUtils.isAvailable(this.url);
+ available = WWWUtils.isAvailable(this.url, disableCertValidation.getBooleanValue());
availPingTime = System.currentTimeMillis() - t1;
} else {
available = getSNMPSession().ping();
@@ -923,4 +926,4 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
return false;
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index c894fa9..d470b03 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -133,7 +133,9 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
}
public AvailabilityType getAvailability() {
- return (this.url != null && WWWUtils.isAvailable(this.url)) ? AvailabilityType.UP : AvailabilityType.DOWN;
+ Configuration pluginConfig = resourceContext.getPluginConfiguration();
+ PropertySimple disableCertValidation = pluginConfig.getSimple("disableCertificateValidation");
+ return (this.url != null && WWWUtils.isAvailable(this.url, disableCertValidation.getBooleanValue())) ? AvailabilityType.UP : AvailabilityType.DOWN;
}
public Configuration loadResourceConfiguration() throws Exception {
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/www/util/WWWUtils.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/www/util/WWWUtils.java
index 8e9f709..c1ff6eb 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/www/util/WWWUtils.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/www/util/WWWUtils.java
@@ -21,6 +21,19 @@ package org.rhq.plugins.www.util;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Helper class that contains methods that send http requests and evaluate results
@@ -28,16 +41,24 @@ import java.net.URL;
*/
public abstract class WWWUtils {
- /**
- * Sends a HEAD request to the passed url and returns if the server was reachable
- * @param httpURL a http or https URL to check
- * @return true if connecting to the URL succeeds, or false otherwise
- */
- public static boolean isAvailable(URL httpURL) {
+ private static final Log log = LogFactory.getLog(WWWUtils.class);
+
+ /**
+ * Sends a HEAD request to the passed url and returns if the server was reachable
+ * @param httpURL a http or https URL to check
+ * @return true if connecting to the URL succeeds, or false otherwise
+ */
+
+ public static boolean isAvailable(URL httpURL, boolean disableCertValidation) {
try {
HttpURLConnection connection = (HttpURLConnection) httpURL.openConnection();
connection.setRequestMethod("HEAD");
connection.setConnectTimeout(3000);
+
+ if ((connection instanceof HttpsURLConnection) && disableCertValidation) {
+ disableCertificateVerification((HttpsURLConnection) connection);
+ }
+
connection.connect();
// get the respone code to actually trigger sending the Request.
connection.getResponseCode();
@@ -70,4 +91,37 @@ public abstract class WWWUtils {
}
return ret;
}
+
+ // This method has been added in support of https://bugzilla.redhat.com/show_bug.cgi?id=690430.
+ private static void disableCertificateVerification(HttpsURLConnection connection) {
+ TrustManager[] trustAllCerts = new TrustManager[]{
+ new X509TrustManager() {
+ public X509Certificate[] getAcceptedIssuers() {
+ return new X509Certificate[] {};
+ }
+
+ public void checkClientTrusted(X509Certificate[] certs, String authType) {
+ }
+
+ public void checkServerTrusted(X509Certificate[] certs, String authType) {
+ }
+ }
+ };
+ try {
+ SSLContext sslContext = SSLContext.getInstance("SSL");
+ sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
+ connection.setSSLSocketFactory(sslContext.getSocketFactory());
+ connection.setHostnameVerifier(new HostnameVerifier() {
+ @Override
+ public boolean verify(String s, SSLSession sslSession) {
+ return true;
+ }
+ });
+ } catch (NoSuchAlgorithmException e) {
+ log.warn("Failed to disable certificate validation.", e);
+ } catch (KeyManagementException e) {
+ log.warn("Failed to disable certificate validation.", e);
+ }
+ }
+
}
\ No newline at end of file
diff --git a/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
index b3f5aa3..adb7f73 100644
--- a/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
@@ -280,6 +280,14 @@
description="the UDP port of the Apache SNMP agent (typically '1610')"/>
<c:simple-property name="snmpAgentCommunity" displayName="SNMP Agent Community" default="public"
description="the SNMP community of the Apache SNMP agent (typically 'public')"/>
+ <c:simple-property name="disableCertificateValidation" type="boolean" default="false"
+ description="If you use HTTPS URLs for availability checks and the certificates aren't
+ trusted by the JVM that runs the agent or the certificates aren't issued for the
+ hostname that you use for the availability checks, you can use this property to switch
+ off the certificate validation. Note that this opens up a possilibity of
+ man-in-the-middle attacks and other SSL related security issues. The agent will switch
+ off the validation only for the duration of the request to the configured URL and will
+ contact no other URL than the one configured."/>
<c:simple-property name="restartAfterConfigurationUpdate" type="boolean" default="true" required="true">
<c:description>
@@ -492,6 +500,14 @@
<plugin-configuration>
<c:simple-property name="url" displayName="URL"
description="the http or https URL that will be used to check availability for this virtual host"/>
+ <c:simple-property name="disableCertificateValidation" type="boolean" default="false"
+ description="If you use HTTPS URLs for availability checks and the certificates aren't
+ trusted by the JVM that runs the agent or the certificates aren't issued for the
+ hostname that you use for the availability checks, you can use this property to switch
+ off the certificate validation. Note that this opens up a possilibity of
+ man-in-the-middle attacks and other SSL related security issues. The agent will switch
+ off the validation only for the duration of the request to the configured URL and will
+ contact no other URL than the one configured."/>
<c:group name="ResponseTime">
<c:simple-property name="responseTimeLogFile" required="false"
description="the full path to the log file containing response-time stats for this virtual host"/>
13 years, 1 month
[rhq] 7 commits - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryDetails.java | 202 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryView.java | 343 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 21
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 9
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/CreateNewPackageChildResourceUIBean.java | 9
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DetermineChildResourceCreationTypeUIBean.java | 5
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ListCreateResourceHistoryUIBean.java | 4
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ListDeleteResourceHistoryUIBean.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java | 16
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java | 35 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java | 43 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 12
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java | 11
15 files changed, 672 insertions(+), 58 deletions(-)
New commits:
commit 04323eda616be9cab37bf48d9a0c704ba70ffd20
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Apr 6 21:03:58 2011 -0400
can't figure out workaround to smartgwt bug - don't use date range editor, just a spinner for past N days
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryView.java
index 9327c1b..d5c1ec4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryView.java
@@ -20,11 +20,13 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DateRange;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.types.SortDirection;
@@ -33,6 +35,8 @@ import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.events.DoubleClickEvent;
import com.smartgwt.client.widgets.events.DoubleClickHandler;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.SpinnerItem;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGrid;
@@ -65,6 +69,7 @@ public class ChildHistoryView extends Table<ChildHistoryView.DataSource> {
public static final String CHILD_DELETED_ICON = "[skin]/images/MultiUploadItem/icon_remove_files.png";
private final ResourceComposite resourceComposite;
+ private FormItem dateRangeItem;
public ChildHistoryView(String locatorId, ResourceComposite resourceComposite) {
super(locatorId, VIEW_ID.getTitle());
@@ -73,6 +78,23 @@ public class ChildHistoryView extends Table<ChildHistoryView.DataSource> {
}
@Override
+ protected void configureTableFilters() {
+ dateRangeItem = new SpinnerItem("filterDateRange", MSG.view_resource_inventory_childhistory_filterTitle());
+ dateRangeItem.setValue(30);
+
+ /* smartgwt has a bad bug that prohibits us from using this - its getValue throws exception
+ dateRangeItem = new DateRangeItem("filterDateRange", MSG.common_title_dateRange());
+ dateRangeItem.setAllowRelativeDates(true);
+ DateRange dateRange = new DateRange();
+ dateRange.setRelativeStartDate(new RelativeDate("-1m"));
+ dateRange.setRelativeEndDate(RelativeDate.TODAY);
+ dateRangeItem.setValue(dateRange);
+ */
+
+ setFilterFormItems(dateRangeItem);
+ }
+
+ @Override
protected void configureTable() {
ListGridField idField = new ListGridField(DataSource.Field.ID, MSG.common_title_id());
idField.setWidth(75);
@@ -239,8 +261,18 @@ public class ChildHistoryView extends Table<ChildHistoryView.DataSource> {
@Override
protected void executeFetch(final DSRequest request, final DSResponse response, Criteria criteria) {
- final Long beginDate = System.currentTimeMillis() - (1000L * 60 * 60 * 24 * 30);
- final Long endDate = System.currentTimeMillis();
+
+ long now = System.currentTimeMillis();
+ DateRange beginEndRange = null;
+ if (dateRangeItem != null) {
+ beginEndRange = new DateRange();
+ beginEndRange.setStartDate(new Date(now
+ - (1000L * 60 * 60 * 24 * Integer.parseInt(dateRangeItem.getValue().toString())))); // user entered # of days
+ beginEndRange.setEndDate(new Date(now));
+ }
+ final Long beginDate = (beginEndRange != null) ? beginEndRange.getStartDate().getTime() : now
+ - (1000L * 60 * 60 * 24 * 30);
+ final Long endDate = (beginEndRange != null) ? beginEndRange.getEndDate().getTime() : now;
final PageControl pc1 = PageControl.getUnlimitedInstance();
final PageControl pc2 = PageControl.getUnlimitedInstance();
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 0156a7a..36a9b95 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
@@ -115,6 +115,7 @@ common_title_count = Count
common_title_custom = Custom
common_title_dashboard_name = Dashboard Name
common_title_dateCreated = Date Created
+common_title_dateRange = Date Range
common_title_default = Default
common_title_description = Description
common_title_details = Details
@@ -1626,6 +1627,7 @@ view_resource_inventory_childhistory_createdChild = Created Child
view_resource_inventory_childhistory_deletedChild = Deleted Child
view_resource_inventory_childhistory_status_invalidArtifact = Invalid Artifact
view_resource_inventory_childhistory_status_invalidConfig = Invalid Configuration
+view_resource_inventory_childhistory_filterTitle = Past N Days
view_resource_monitor_availability_loadFailed = Failed to load availability history
view_resource_monitor_graphs_noneAvailable = No graphs available
view_resource_monitor_graphs_loadFailed = Failed to load graph data
commit 327a5df559ccfc66aa07cee1193758dc8b8615bf
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Apr 6 12:27:36 2011 -0400
show details on double click
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryDetails.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryDetails.java
new file mode 100644
index 0000000..1b7fe79
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryDetails.java
@@ -0,0 +1,202 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+
+import com.smartgwt.client.types.TitleOrientation;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.TextAreaItem;
+
+import org.rhq.core.domain.resource.CreateResourceHistory;
+import org.rhq.core.domain.resource.DeleteResourceHistory;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * Details view for a single child history entity.
+ *
+ * @author John Mazzitelli
+ */
+public class ChildHistoryDetails extends LocatableVLayout {
+ private CreateResourceHistory createHistory;
+ private DeleteResourceHistory deleteHistory;
+
+ public ChildHistoryDetails(String locatorId, CreateResourceHistory history) {
+ super(locatorId);
+ createHistory = history;
+ deleteHistory = null;
+ }
+
+ public ChildHistoryDetails(String locatorId, DeleteResourceHistory history) {
+ super(locatorId);
+ createHistory = null;
+ deleteHistory = history;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ DynamicForm form = null;
+ if (createHistory != null) {
+ form = buildForCreate(createHistory);
+ } else if (deleteHistory != null) {
+ form = buildForDelete(deleteHistory);
+ }
+ addMember(form);
+ }
+
+ private DynamicForm buildForCreate(CreateResourceHistory history) {
+ DynamicForm form = new LocatableDynamicForm(extendLocatorId("createForm"));
+ form.setWidth100();
+ form.setHeight100();
+ form.setWrapItemTitles(false);
+
+ StaticTextItem id = new StaticTextItem("id", MSG.common_title_id());
+ id.setValue(history.getId());
+
+ StaticTextItem type = new StaticTextItem("type", MSG.common_title_type());
+ String typeValue = Canvas.imgHTML(ChildHistoryView.CHILD_CREATED_ICON);
+ typeValue += MSG.view_resource_inventory_childhistory_createdChild();
+ type.setValue(typeValue);
+
+ StaticTextItem createdTimestamp = new StaticTextItem("created", MSG.common_title_dateCreated());
+ createdTimestamp.setValue(TimestampCellFormatter.format(history.getCreatedDate(),
+ TimestampCellFormatter.DATE_TIME_FORMAT_FULL));
+
+ StaticTextItem modifiedTimestamp = new StaticTextItem("created", MSG.common_title_lastUpdated());
+ modifiedTimestamp.setValue(TimestampCellFormatter.format(history.getLastModifiedDate(),
+ TimestampCellFormatter.DATE_TIME_FORMAT_FULL));
+
+ StaticTextItem subject = new StaticTextItem("subject", MSG.common_title_user());
+ subject.setValue(history.getSubjectName());
+
+ StaticTextItem status = new StaticTextItem("status", MSG.common_title_status());
+ switch (history.getStatus()) {
+ case SUCCESS:
+ status.setValue(MSG.common_status_success());
+ break;
+ case FAILURE:
+ status.setValue(MSG.common_status_failed());
+ break;
+ case IN_PROGRESS:
+ status.setValue(MSG.common_status_inprogress());
+ break;
+ case INVALID_ARTIFACT:
+ status.setValue(MSG.view_resource_inventory_childhistory_status_invalidArtifact());
+ break;
+ case INVALID_CONFIGURATION:
+ status.setValue(MSG.view_resource_inventory_childhistory_status_invalidConfig());
+ break;
+ case TIMED_OUT:
+ status.setValue(MSG.common_status_timedOut());
+ break;
+ default:
+ status.setValue("?");
+ }
+
+ StaticTextItem createdResourceName = new StaticTextItem("createdResourceName", MSG.common_title_resource_name());
+ createdResourceName.setValue(history.getCreatedResourceName());
+
+ StaticTextItem createdResourceKey = new StaticTextItem("createdResourceKey", MSG.common_title_resource_key());
+ createdResourceKey.setValue(history.getNewResourceKey());
+
+ // TODO: show resource info, like type
+
+ TextAreaItem errorMessage = new TextAreaItem("errorMessage", MSG.common_title_error());
+ errorMessage.setValue(history.getErrorMessage());
+ errorMessage.setTitleOrientation(TitleOrientation.TOP);
+ errorMessage.setColSpan(2);
+ errorMessage.setWidth("100%");
+ errorMessage.setHeight("100%");
+
+ if (history.getErrorMessage() != null && history.getErrorMessage().length() > 0) {
+ form.setItems(id, type, createdTimestamp, modifiedTimestamp, subject, createdResourceName,
+ createdResourceKey, status, errorMessage);
+ } else {
+ form.setItems(id, type, createdTimestamp, modifiedTimestamp, subject, createdResourceName,
+ createdResourceKey, status);
+ }
+
+ return form;
+ }
+
+ private DynamicForm buildForDelete(DeleteResourceHistory history) {
+ DynamicForm form = new LocatableDynamicForm(extendLocatorId("deleteForm"));
+ form.setWidth100();
+ form.setHeight100();
+ form.setWrapItemTitles(false);
+
+ StaticTextItem id = new StaticTextItem("id", MSG.common_title_id());
+ id.setValue(history.getId());
+
+ StaticTextItem type = new StaticTextItem("type", MSG.common_title_type());
+ String typeValue = Canvas.imgHTML(ChildHistoryView.CHILD_DELETED_ICON);
+ typeValue += MSG.view_resource_inventory_childhistory_deletedChild();
+ type.setValue(typeValue);
+
+ StaticTextItem createdTimestamp = new StaticTextItem("created", MSG.common_title_dateCreated());
+ createdTimestamp.setValue(TimestampCellFormatter.format(history.getCreatedDate(),
+ TimestampCellFormatter.DATE_TIME_FORMAT_FULL));
+
+ StaticTextItem modifiedTimestamp = new StaticTextItem("created", MSG.common_title_lastUpdated());
+ modifiedTimestamp.setValue(TimestampCellFormatter.format(history.getLastModifiedDate(),
+ TimestampCellFormatter.DATE_TIME_FORMAT_FULL));
+
+ StaticTextItem subject = new StaticTextItem("subject", MSG.common_title_user());
+ subject.setValue(history.getSubjectName());
+
+ StaticTextItem status = new StaticTextItem("status", MSG.common_title_status());
+ switch (history.getStatus()) {
+ case SUCCESS:
+ status.setValue(MSG.common_status_success());
+ break;
+ case FAILURE:
+ status.setValue(MSG.common_status_failed());
+ break;
+ case IN_PROGRESS:
+ status.setValue(MSG.common_status_inprogress());
+ break;
+ case TIMED_OUT:
+ status.setValue(MSG.common_status_timedOut());
+ break;
+ default:
+ status.setValue("?");
+ }
+
+ // TODO: show resource info, like name, type
+
+ TextAreaItem errorMessage = new TextAreaItem("errorMessage", MSG.common_title_error());
+ errorMessage.setValue(history.getErrorMessage());
+ errorMessage.setTitleOrientation(TitleOrientation.TOP);
+ errorMessage.setColSpan(2);
+ errorMessage.setWidth("100%");
+ errorMessage.setHeight("100%");
+
+ if (history.getErrorMessage() != null && history.getErrorMessage().length() > 0) {
+ form.setItems(id, type, createdTimestamp, modifiedTimestamp, subject, status, errorMessage);
+ } else {
+ form.setItems(id, type, createdTimestamp, modifiedTimestamp, subject, status);
+ }
+
+ return form;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryView.java
index 945554b..9327c1b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryView.java
@@ -20,35 +20,49 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
import java.util.ArrayList;
+import java.util.HashMap;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.Record;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
+import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.resource.CreateResourceHistory;
+import org.rhq.core.domain.resource.CreateResourceStatus;
import org.rhq.core.domain.resource.DeleteResourceHistory;
+import org.rhq.core.domain.resource.DeleteResourceStatus;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/**
* @author John Mazzitelli
*/
-public class ChildHistoryView extends TableSection<ChildHistoryView.DataSource> {
+public class ChildHistoryView extends Table<ChildHistoryView.DataSource> {
public static final ViewName VIEW_ID = new ViewName("ChildHistory", MSG.view_tabs_common_child_history());
- public static final String CHILD_CREATED_ICON = "[skin]/MultiUploadItem/icon_add_files.png";
- public static final String CHILD_DELETED_ICON = "[skin]/MultiUploadItem/icon_remove_files.png";
+ public static final String CHILD_CREATED_ICON = "[skin]/images/MultiUploadItem/icon_add_files.png";
+ public static final String CHILD_DELETED_ICON = "[skin]/images/MultiUploadItem/icon_remove_files.png";
private final ResourceComposite resourceComposite;
@@ -61,40 +75,119 @@ public class ChildHistoryView extends TableSection<ChildHistoryView.DataSource>
@Override
protected void configureTable() {
ListGridField idField = new ListGridField(DataSource.Field.ID, MSG.common_title_id());
+ idField.setWidth(75);
- ListGridField errorMessageField = new ListGridField(DataSource.Field.ERROR_MESSAGE, MSG.common_title_error());
-
- ListGridField subjectField = new ListGridField(DataSource.Field.SUBJECT_NAME, MSG.common_title_user());
+ ListGridField typeField = new ListGridField(DataSource.Field.TYPE, MSG.common_title_type());
+ typeField.setWidth(75);
+ typeField.setType(ListGridFieldType.ICON);
+ HashMap<String, String> typeIcons = new HashMap<String, String>(2);
+ typeIcons.put(DataSource.TYPE_CREATE, CHILD_CREATED_ICON);
+ typeIcons.put(DataSource.TYPE_DELETE, CHILD_DELETED_ICON);
+ typeField.setValueIcons(typeIcons);
+ typeField.setShowHover(true);
+ typeField.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String type = record.getAttribute(DataSource.Field.TYPE);
+ if (DataSource.TYPE_CREATE.equals(type)) {
+ return MSG.view_resource_inventory_childhistory_createdChild();
+ } else if (DataSource.TYPE_DELETE.equals(type)) {
+ return MSG.view_resource_inventory_childhistory_deletedChild();
+ } else {
+ return "?"; // should never happen
+ }
+ }
+ });
ListGridField createdField = new ListGridField(DataSource.Field.CREATED_DATE, MSG.common_title_dateCreated());
+ TimestampCellFormatter.prepareDateField(createdField);
ListGridField modifiedField = new ListGridField(DataSource.Field.LAST_MODIFIED_TIME, MSG
.common_title_lastUpdated());
+ TimestampCellFormatter.prepareDateField(modifiedField);
+
+ ListGridField subjectField = new ListGridField(DataSource.Field.SUBJECT_NAME, MSG.common_title_user());
ListGridField statusField = new ListGridField(DataSource.Field.STATUS, MSG.common_title_status());
+ statusField.setCellFormatter(new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String type = record.getAttribute(DataSource.Field.TYPE);
+ if (DataSource.TYPE_CREATE.equals(type)) {
+ switch (CreateResourceStatus.valueOf(value.toString())) {
+ case SUCCESS:
+ return MSG.common_status_success();
+ case FAILURE:
+ return MSG.common_status_failed();
+ case IN_PROGRESS:
+ return MSG.common_status_inprogress();
+ case INVALID_ARTIFACT:
+ return MSG.view_resource_inventory_childhistory_status_invalidArtifact();
+ case INVALID_CONFIGURATION:
+ return MSG.view_resource_inventory_childhistory_status_invalidConfig();
+ case TIMED_OUT:
+ return MSG.common_status_timedOut();
+ }
+ } else if (DataSource.TYPE_DELETE.equals(type)) {
+ switch (DeleteResourceStatus.valueOf(value.toString())) {
+ case SUCCESS:
+ return MSG.common_status_success();
+ case FAILURE:
+ return MSG.common_status_failed();
+ case IN_PROGRESS:
+ return MSG.common_status_inprogress();
+ case TIMED_OUT:
+ return MSG.common_status_timedOut();
+ }
+ }
+ return "?"; // should never happen
+ }
+ });
- ListGridField detailsField = new ListGridField("details", MSG.common_title_details());
- }
+ setListGridFields(idField, typeField, createdField, modifiedField, subjectField, statusField);
- @Override
- public Canvas getDetailsView(int id) {
- // TODO Auto-generated method stub
- return null;
+ // Add a double click handler to show the details for the selected row.
+ // Notice this goes against our normal UI design. I would normally have used TableSection
+ // and have the details canvas created via the getDetails API.
+ // This would make our details view bookmarkable. However, the old design of the create/delete
+ // history makes determining what entity to use via an ID is not possible (the create/delete
+ // history is split into two tables). So, I'll just pop up the audit details in a dialog window.
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid listGrid = (ListGrid) event.getSource();
+ ListGridRecord[] selectedRows = listGrid.getSelection();
+ if (selectedRows != null && selectedRows.length == 1) {
+ String typeString = selectedRows[0].getAttribute(DataSource.Field.TYPE);
+ ChildHistoryDetails detailsView = null;
+ if (DataSource.TYPE_CREATE.equals(typeString)) {
+ CreateResourceHistory history = (CreateResourceHistory) selectedRows[0]
+ .getAttributeAsObject(DataSource.Field.OBJECT);
+ detailsView = new ChildHistoryDetails(extendLocatorId("details"), history);
+ } else if (DataSource.TYPE_DELETE.equals(typeString)) {
+ DeleteResourceHistory history = (DeleteResourceHistory) selectedRows[0]
+ .getAttributeAsObject(DataSource.Field.OBJECT);
+ detailsView = new ChildHistoryDetails(extendLocatorId("details"), history);
+ }
+ new DetailsWindow(extendLocatorId("detailsWin"), detailsView).show();
+ }
+ }
+ });
+
+ ListGrid listGrid = getListGrid();
+ listGrid.setSortField(DataSource.Field.CREATED_DATE);
+ listGrid.setSortDirection(SortDirection.DESCENDING);
}
class DataSource extends RPCDataSource<Object, Criteria> {
+ public static final String TYPE_CREATE = "create";
+ public static final String TYPE_DELETE = "delete";
+
public class Field {
public static final String ID = "id";
- public static final String ERROR_MESSAGE = "errorMessage";
- public static final String SUBJECT_NAME = "subjectName";
public static final String CREATED_DATE = "createdDate";
public static final String LAST_MODIFIED_TIME = "lastModifiedDate";
+ public static final String SUBJECT_NAME = "subjectName";
public static final String STATUS = "status"; // name of either [Create,Delete]ResourceStatus
+ public static final String TYPE = "historyType"; // will be either TYPE_CREATE or TYPE_DELETE
public static final String OBJECT = "object";
-
- // create history only
- public static final String CREATED_RESOURCE_NAME = "createdResourceName";
- public static final String NEW_RESOURCE_KEY = "newResourceKey";
}
/**
@@ -123,18 +216,16 @@ public class ChildHistoryView extends TableSection<ChildHistoryView.DataSource>
if (from instanceof CreateResourceHistory) {
CreateResourceHistory history = (CreateResourceHistory) from;
+ record.setAttribute(Field.TYPE, TYPE_CREATE);
record.setAttribute(Field.ID, history.getId());
- record.setAttribute(Field.ERROR_MESSAGE, history.getErrorMessage());
record.setAttribute(Field.SUBJECT_NAME, history.getSubjectName());
record.setAttribute(Field.CREATED_DATE, history.getCreatedDate());
record.setAttribute(Field.LAST_MODIFIED_TIME, history.getLastModifiedDate());
record.setAttribute(Field.STATUS, history.getStatus().name());
- record.setAttribute(Field.CREATED_RESOURCE_NAME, history.getCreatedResourceName());
- record.setAttribute(Field.NEW_RESOURCE_KEY, history.getNewResourceKey());
} else if (from instanceof DeleteResourceHistory) {
DeleteResourceHistory history = (DeleteResourceHistory) from;
+ record.setAttribute(Field.TYPE, TYPE_DELETE);
record.setAttribute(Field.ID, history.getId());
- record.setAttribute(Field.ERROR_MESSAGE, history.getErrorMessage());
record.setAttribute(Field.SUBJECT_NAME, history.getSubjectName());
record.setAttribute(Field.CREATED_DATE, history.getCreatedDate());
record.setAttribute(Field.LAST_MODIFIED_TIME, history.getLastModifiedDate());
@@ -148,7 +239,7 @@ public class ChildHistoryView extends TableSection<ChildHistoryView.DataSource>
@Override
protected void executeFetch(final DSRequest request, final DSResponse response, Criteria criteria) {
- final Long beginDate = System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 30;
+ final Long beginDate = System.currentTimeMillis() - (1000L * 60 * 60 * 24 * 30);
final Long endDate = System.currentTimeMillis();
final PageControl pc1 = PageControl.getUnlimitedInstance();
final PageControl pc2 = PageControl.getUnlimitedInstance();
@@ -191,4 +282,30 @@ public class ChildHistoryView extends TableSection<ChildHistoryView.DataSource>
return null; // using special server side API to get the create/delete histories, no criteria involved
}
}
+
+ class DetailsWindow extends LocatableWindow {
+ public DetailsWindow(String locatorId, Canvas canvas) {
+ super(locatorId);
+ setTitle(MSG.common_title_details());
+ setShowMinimizeButton(false);
+ setShowMaximizeButton(true);
+ setIsModal(true);
+ setShowModalMask(true);
+ setWidth(600);
+ setHeight(400);
+ setAutoCenter(true);
+ setShowResizer(true);
+ setCanDragResize(true);
+ centerInPage();
+ addCloseClickHandler(new CloseClickHandler() {
+ public void onCloseClick(CloseClientEvent event) {
+ markForDestroy();
+ }
+ });
+ if (canvas != null) {
+ addItem(canvas);
+ }
+ }
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/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 96ef8cf..0156a7a 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
@@ -179,6 +179,7 @@ common_title_resourceGroups = Resource Groups
common_title_resource_inventory = Resource Inventory
common_title_resource_id = Resource ID
common_title_resource_name = Resource Name
+common_title_resource_key = Resource Key
common_title_resource_type = Resource Type
common_title_results_count = Results Count
common_title_results_count_tooltip = Displays this number of results
@@ -244,7 +245,7 @@ common_status_inprogress = In Progress
common_status_nochange = No Change
common_status_success = Success
common_status_unknown = Unknown
-
+common_status_timedOut = Timed Out
common_status_partial = Partial
# 1st, 2nd, 3rd, 4th, etc.
@@ -1621,6 +1622,10 @@ view_resource_inventory_activity_no_recent_metrics=This resource has no recent m
view_resource_inventory_activity_no_recent_oob=No OOB conditions found
view_resource_inventory_activity_no_recent_operations=No recent operation history
view_resource_inventory_activity_no_recent_pkg_history=No recent package history
+view_resource_inventory_childhistory_createdChild = Created Child
+view_resource_inventory_childhistory_deletedChild = Deleted Child
+view_resource_inventory_childhistory_status_invalidArtifact = Invalid Artifact
+view_resource_inventory_childhistory_status_invalidConfig = Invalid Configuration
view_resource_monitor_availability_loadFailed = Failed to load availability history
view_resource_monitor_graphs_noneAvailable = No graphs available
view_resource_monitor_graphs_loadFailed = Failed to load graph data
commit 9e0dfd7f1754b5167808fd585df8da205b212c6f
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Apr 5 09:49:42 2011 -0400
start of the child history page
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryView.java
new file mode 100644
index 0000000..945554b
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ChildHistoryView.java
@@ -0,0 +1,194 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+
+import java.util.ArrayList;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.Criteria;
+import org.rhq.core.domain.resource.CreateResourceHistory;
+import org.rhq.core.domain.resource.DeleteResourceHistory;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author John Mazzitelli
+ */
+public class ChildHistoryView extends TableSection<ChildHistoryView.DataSource> {
+
+ public static final ViewName VIEW_ID = new ViewName("ChildHistory", MSG.view_tabs_common_child_history());
+ public static final String CHILD_CREATED_ICON = "[skin]/MultiUploadItem/icon_add_files.png";
+ public static final String CHILD_DELETED_ICON = "[skin]/MultiUploadItem/icon_remove_files.png";
+
+ private final ResourceComposite resourceComposite;
+
+ public ChildHistoryView(String locatorId, ResourceComposite resourceComposite) {
+ super(locatorId, VIEW_ID.getTitle());
+ this.resourceComposite = resourceComposite;
+ setDataSource(new DataSource());
+ }
+
+ @Override
+ protected void configureTable() {
+ ListGridField idField = new ListGridField(DataSource.Field.ID, MSG.common_title_id());
+
+ ListGridField errorMessageField = new ListGridField(DataSource.Field.ERROR_MESSAGE, MSG.common_title_error());
+
+ ListGridField subjectField = new ListGridField(DataSource.Field.SUBJECT_NAME, MSG.common_title_user());
+
+ ListGridField createdField = new ListGridField(DataSource.Field.CREATED_DATE, MSG.common_title_dateCreated());
+
+ ListGridField modifiedField = new ListGridField(DataSource.Field.LAST_MODIFIED_TIME, MSG
+ .common_title_lastUpdated());
+
+ ListGridField statusField = new ListGridField(DataSource.Field.STATUS, MSG.common_title_status());
+
+ ListGridField detailsField = new ListGridField("details", MSG.common_title_details());
+ }
+
+ @Override
+ public Canvas getDetailsView(int id) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ class DataSource extends RPCDataSource<Object, Criteria> {
+ public class Field {
+ public static final String ID = "id";
+ public static final String ERROR_MESSAGE = "errorMessage";
+ public static final String SUBJECT_NAME = "subjectName";
+ public static final String CREATED_DATE = "createdDate";
+ public static final String LAST_MODIFIED_TIME = "lastModifiedDate";
+ public static final String STATUS = "status"; // name of either [Create,Delete]ResourceStatus
+ public static final String OBJECT = "object";
+
+ // create history only
+ public static final String CREATED_RESOURCE_NAME = "createdResourceName";
+ public static final String NEW_RESOURCE_KEY = "newResourceKey";
+ }
+
+ /**
+ * Given a record, returns either the CreateResourceHistory or the DeleteResourceHistory entity object
+ * that the record represents.
+ *
+ * @param from a record that represents either a create or delete resource history item
+ * @return the create/delete resource history item
+ */
+ @Override
+ public Object copyValues(Record from) {
+ return from.getAttributeAsObject(Field.OBJECT);
+ }
+
+ /**
+ * Given either a CreateResourceHistory or a DeleteResourceHistory entity object,
+ * returns its record representation.
+ *
+ * @param from a create or delete resource history item
+ * @return the record that represents the given history item
+ */
+ @Override
+ public ListGridRecord copyValues(Object from) {
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(Field.OBJECT, from);
+
+ if (from instanceof CreateResourceHistory) {
+ CreateResourceHistory history = (CreateResourceHistory) from;
+ record.setAttribute(Field.ID, history.getId());
+ record.setAttribute(Field.ERROR_MESSAGE, history.getErrorMessage());
+ record.setAttribute(Field.SUBJECT_NAME, history.getSubjectName());
+ record.setAttribute(Field.CREATED_DATE, history.getCreatedDate());
+ record.setAttribute(Field.LAST_MODIFIED_TIME, history.getLastModifiedDate());
+ record.setAttribute(Field.STATUS, history.getStatus().name());
+ record.setAttribute(Field.CREATED_RESOURCE_NAME, history.getCreatedResourceName());
+ record.setAttribute(Field.NEW_RESOURCE_KEY, history.getNewResourceKey());
+ } else if (from instanceof DeleteResourceHistory) {
+ DeleteResourceHistory history = (DeleteResourceHistory) from;
+ record.setAttribute(Field.ID, history.getId());
+ record.setAttribute(Field.ERROR_MESSAGE, history.getErrorMessage());
+ record.setAttribute(Field.SUBJECT_NAME, history.getSubjectName());
+ record.setAttribute(Field.CREATED_DATE, history.getCreatedDate());
+ record.setAttribute(Field.LAST_MODIFIED_TIME, history.getLastModifiedDate());
+ record.setAttribute(Field.STATUS, history.getStatus().name());
+ } else {
+ CoreGUI.getErrorHandler().handleError("invalid child history type: " + from.getClass()); // should never occur
+ }
+
+ return record;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, Criteria criteria) {
+ final Long beginDate = System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 30;
+ final Long endDate = System.currentTimeMillis();
+ final PageControl pc1 = PageControl.getUnlimitedInstance();
+ final PageControl pc2 = PageControl.getUnlimitedInstance();
+
+ GWTServiceLookup.getResourceService().findCreateChildResourceHistory(
+ resourceComposite.getResource().getId(), beginDate, endDate, pc1,
+ new AsyncCallback<PageList<CreateResourceHistory>>() {
+ @Override
+ public void onSuccess(final PageList<CreateResourceHistory> createList) {
+ GWTServiceLookup.getResourceService().findDeleteChildResourceHistory(
+ resourceComposite.getResource().getId(), beginDate, endDate, pc2,
+ new AsyncCallback<PageList<DeleteResourceHistory>>() {
+ @Override
+ public void onSuccess(final PageList<DeleteResourceHistory> deleteList) {
+ ArrayList<Object> fullList = new ArrayList<Object>();
+ fullList.addAll(createList);
+ fullList.addAll(deleteList);
+ ListGridRecord[] records = buildRecords(fullList);
+ response.setData(records);
+ processResponse(request.getRequestId(), response);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler()
+ .handleError("Failed to load child delete history", caught);
+ }
+ });
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load child create history", caught);
+ }
+ });
+ }
+
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ return null; // using special server side API to get the create/delete histories, no criteria involved
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 8ddb631..84555a8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -304,13 +304,14 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
};
updateSubTab(this.inventoryTab, this.inventoryChildren, visible, true, viewFactory);
- updateSubTab(this.inventoryTab, this.inventoryChildHistory, visible, true, new ViewFactory() {
+ visible = !type.getChildResourceTypes().isEmpty();
+ viewFactory = (!visible) ? null : new ViewFactory() {
@Override
public Canvas createView() {
- // TODO
- return new Canvas();
+ return new ChildHistoryView(inventoryTab.extendLocatorId("ChildHistory"), resourceComposite);
}
- });
+ };
+ updateSubTab(this.inventoryTab, this.inventoryChildHistory, visible, true, viewFactory);
visible = facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION);
viewFactory = (!visible) ? null : new ViewFactory() {
commit dbb73dfaaaa1404d936cd0ce177cd37855693b31
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Apr 5 08:57:57 2011 -0400
add create/delete history retreival API to gwt service
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
index 921b82d..e7fb10e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
@@ -26,6 +26,7 @@ import com.google.gwt.user.client.rpc.RemoteService;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.resource.CreateResourceHistory;
import org.rhq.core.domain.resource.DeleteResourceHistory;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
@@ -51,6 +52,12 @@ public interface ResourceGWTService extends RemoteService {
List<DeleteResourceHistory> deleteResources(int[] resourceIds) throws RuntimeException;
+ PageList<CreateResourceHistory> findCreateChildResourceHistory(int parentId, Long beginDate, Long endDate,
+ PageControl pc) throws RuntimeException;
+
+ PageList<DeleteResourceHistory> findDeleteChildResourceHistory(int parentId, Long beginDate, Long endDate,
+ PageControl pc) throws RuntimeException;
+
List<RecentlyAddedResourceComposite> findRecentlyAddedResources(long ctime, int maxItems) throws RuntimeException;
PageList<Resource> findResourcesByCriteria(ResourceCriteria criteria) throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index 13fc75a..69f815b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.resource.CreateResourceHistory;
import org.rhq.core.domain.resource.DeleteResourceHistory;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
@@ -271,6 +272,26 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
}
}
+ public PageList<CreateResourceHistory> findCreateChildResourceHistory(int parentId, Long beginDate, Long endDate,
+ PageControl pc) throws RuntimeException {
+ try {
+ return SerialUtility.prepare(resourceFactoryManager.findCreateChildResourceHistory(getSessionSubject(),
+ parentId, beginDate, endDate, pc), "ResourceService.findCreateChildResourceHistory");
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
+ public PageList<DeleteResourceHistory> findDeleteChildResourceHistory(int parentId, Long beginDate, Long endDate,
+ PageControl pc) throws RuntimeException {
+ try {
+ return SerialUtility.prepare(resourceFactoryManager.findDeleteChildResourceHistory(getSessionSubject(),
+ parentId, beginDate, endDate, pc), "ResourceService.findDeleteChildResourceHistory");
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
public Map<Resource, List<Resource>> getQueuedPlatformsAndServers(HashSet<InventoryStatus> statuses, PageControl pc)
throws RuntimeException {
try {
commit cc8e25f47950466b83fd714a38fe110c6bc23519
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 4 17:32:52 2011 -0400
add to webservices API
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index e06d5ae..7a161ea 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -883,7 +883,17 @@ public class WebservicesManagerBean implements WebservicesRemote {
return resourceFactoryManager.deleteResources(subject, resourceIds);
}
- //RESOURCEFACTORYMANAGER: END ----------------------------------
+ public PageList<CreateResourceHistory> findCreateChildResourceHistory(Subject subject, int parentResourceId,
+ Long beginDate, Long endDate, PageControl pageControl) {
+ return resourceFactoryManager.findCreateChildResourceHistory(subject, parentResourceId, beginDate, endDate,
+ pageControl);
+ }
+
+ public PageList<DeleteResourceHistory> findDeleteChildResourceHistory(Subject subject, int parentResourceId,
+ Long beginDate, Long endDate, PageControl pageControl) {
+ return resourceFactoryManager.findDeleteChildResourceHistory(subject, parentResourceId, beginDate, endDate,
+ pageControl);
+ }
//RESOURCEMANAGER: BEGIN ----------------------------------
public List<Resource> findResourceLineage(Subject subject, int resourceId) {
commit 69c6dad9f7abdf8ef4ec5ba807ebc445132ebfdc
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 4 17:26:50 2011 -0400
add the two history find methods to the remote interface
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java
index adfa015..d5e3cbb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java
@@ -127,38 +127,6 @@ public interface ResourceFactoryManagerLocal {
int getDeleteChildResourceHistoryCount(int parentResourceId, Long beginDate, Long endDate);
/**
- * Returns a pagination enabled list of requests for the creation of new child resources to the specified parent.
- * These requests may be completed or still in progress; it represents the history of creation attempts for this
- * parent resource.
- *
- * @param subject the user making the request
- * @param parentResourceId resource to check for child resource creations
- * @param beginDate filter used to show only results occurring after this epoch millis parameter, nullable
- * @param endDate filter used to show only results occurring before this epoch millis parameter, nullable
- * @param pageControl control for pagination
- *
- * @return list of requests
- */
- PageList<CreateResourceHistory> findCreateChildResourceHistory(Subject subject, int parentResourceId,
- Long beginDate, Long endDate, PageControl pageControl);
-
- /**
- * Returns a pagination enabled list of requests to delete a child resource on the specified parent. These requests
- * may be complete or still in progress; it represents the history of all delete attempts of child resources to this
- * resource.
- *
- * @param subject the user making the request
- * @param parentResourceId resource to check for deleted child resources
- * @param beginDate filter used to show only results occurring after this epoch millis parameter, nullable
- * @param endate filter used to show only results occurring before this epoch millis parameter, nullable
- * @param pageControl control for pagination
- *
- * @return list of requests
- */
- PageList<DeleteResourceHistory> findDeleteChildResourceHistory(Subject subject, int parentResourceId,
- Long beginDate, Long endDate, PageControl pageControl);
-
- /**
* Persists a record in the resource history to indicate a request has been made to create a configuration-backed
* resource.
*
@@ -238,4 +206,9 @@ public interface ResourceFactoryManagerLocal {
*/
List<DeleteResourceHistory> deleteResources(Subject subject, int[] resourceIds);
+ PageList<CreateResourceHistory> findCreateChildResourceHistory(Subject subject, int parentResourceId,
+ Long beginDate, Long endDate, PageControl pageControl);
+
+ PageList<DeleteResourceHistory> findDeleteChildResourceHistory(Subject subject, int parentResourceId,
+ Long beginDate, Long endDate, PageControl pageControl);
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
index a579434..a3682df 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
@@ -33,6 +33,8 @@ import org.rhq.core.domain.resource.CreateDeletePolicy;
import org.rhq.core.domain.resource.CreateResourceHistory;
import org.rhq.core.domain.resource.DeleteResourceHistory;
import org.rhq.core.domain.resource.ResourceCreationDataType;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.jaxb.adapter.ConfigurationAdapter;
import org.rhq.enterprise.server.system.ServerVersion;
@@ -165,4 +167,45 @@ public interface ResourceFactoryManagerRemote {
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "resourceIds") int[] resourceIds);
+ /**
+ * Returns a pagination enabled list of requests for the creation of new child resources to the specified parent.
+ * These requests may be completed or still in progress; it represents the history of creation attempts for this
+ * parent resource.
+ *
+ * @param subject the user making the request
+ * @param parentResourceId resource to check for child resource creations
+ * @param beginDate filter used to show only results occurring after this epoch millis parameter, nullable
+ * @param endDate filter used to show only results occurring before this epoch millis parameter, nullable
+ * @param pageControl control for pagination
+ *
+ * @return list of requests
+ */
+ @WebMethod
+ PageList<CreateResourceHistory> findCreateChildResourceHistory( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "parentResourceId") int parentResourceId, //
+ @WebParam(name = "beginDate") Long beginDate, //
+ @WebParam(name = "endDate") Long endDate, //
+ @WebParam(name = "pageControl") PageControl pageControl);
+
+ /**
+ * Returns a pagination enabled list of requests to delete a child resource on the specified parent. These requests
+ * may be complete or still in progress; it represents the history of all delete attempts of child resources to this
+ * resource.
+ *
+ * @param subject the user making the request
+ * @param parentResourceId resource to check for deleted child resources
+ * @param beginDate filter used to show only results occurring after this epoch millis parameter, nullable
+ * @param endate filter used to show only results occurring before this epoch millis parameter, nullable
+ * @param pageControl control for pagination
+ *
+ * @return list of requests
+ */
+ @WebMethod
+ PageList<DeleteResourceHistory> findDeleteChildResourceHistory( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "parentResourceId") int parentResourceId, //
+ @WebParam(name = "beginDate") Long beginDate, //
+ @WebParam(name = "endDate") Long endDate, //
+ @WebParam(name = "pageControl") PageControl pageControl);
}
commit a179dc3be16ebe1323810be2c8dec8fef1128e6c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 4 17:22:05 2011 -0400
add subject to the first param of the find create/delete resource history as I think this might require authz in the future plus these are going to be remote apis that gwt clients access, so we need to require subject auth
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/CreateNewPackageChildResourceUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/CreateNewPackageChildResourceUIBean.java
index 904eb48..3479c4a 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/CreateNewPackageChildResourceUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/CreateNewPackageChildResourceUIBean.java
@@ -120,8 +120,8 @@ public class CreateNewPackageChildResourceUIBean {
//store information about uploaded file for packageDetails as most of it is already available
Map<String, String> packageUploadDetails = new HashMap<String, String>();
packageUploadDetails.put(ContentManagerLocal.UPLOAD_FILE_SIZE, String.valueOf(fileItem.getFileSize()));
- packageUploadDetails.put(ContentManagerLocal.UPLOAD_FILE_INSTALL_DATE, String
- .valueOf(System.currentTimeMillis()));
+ packageUploadDetails.put(ContentManagerLocal.UPLOAD_FILE_INSTALL_DATE, String.valueOf(System
+ .currentTimeMillis()));
packageUploadDetails.put(ContentManagerLocal.UPLOAD_OWNER, user.getName());
packageUploadDetails.put(ContentManagerLocal.UPLOAD_FILE_NAME, fileItem.getFileName());
@@ -319,12 +319,13 @@ public class CreateNewPackageChildResourceUIBean {
* @return list of failed create history requests
*/
public SelectItem[] getFailedCreateHistory() {
+ Subject subject = EnterpriseFacesContextUtility.getSubject();
Resource parentResource = EnterpriseFacesContextUtility.getResource();
ResourceFactoryManagerLocal resourceFactoryManager = LookupUtil.getResourceFactoryManager();
PageControl pageControl = new PageControl(0, 1000);
- PageList<CreateResourceHistory> pageList = resourceFactoryManager.findCreateChildResourceHistory(parentResource
- .getId(), null, null, pageControl);
+ PageList<CreateResourceHistory> pageList = resourceFactoryManager.findCreateChildResourceHistory(subject,
+ parentResource.getId(), null, null, pageControl);
List<SelectItem> selectItemsList = new ArrayList<SelectItem>();
for (CreateResourceHistory history : pageList) {
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DetermineChildResourceCreationTypeUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DetermineChildResourceCreationTypeUIBean.java
index c698e19..cde57b7 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DetermineChildResourceCreationTypeUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DetermineChildResourceCreationTypeUIBean.java
@@ -143,12 +143,13 @@ public class DetermineChildResourceCreationTypeUIBean {
* @return list of failed create history requests
*/
public SelectItem[] getFailedCreateHistory() {
+ Subject user = EnterpriseFacesContextUtility.getSubject();
Resource parentResource = EnterpriseFacesContextUtility.getResource();
ResourceFactoryManagerLocal resourceFactoryManager = LookupUtil.getResourceFactoryManager();
PageControl pageControl = new PageControl(0, 1000);
- PageList<CreateResourceHistory> pageList = resourceFactoryManager.findCreateChildResourceHistory(parentResource
- .getId(), null, null, pageControl);
+ PageList<CreateResourceHistory> pageList = resourceFactoryManager.findCreateChildResourceHistory(user,
+ parentResource.getId(), null, null, pageControl);
List<SelectItem> selectItemsList = new ArrayList<SelectItem>();
for (CreateResourceHistory history : pageList) {
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ListCreateResourceHistoryUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ListCreateResourceHistoryUIBean.java
index a17fb33..7736c5c 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ListCreateResourceHistoryUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ListCreateResourceHistoryUIBean.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.gui.inventory.resource;
import javax.faces.model.DataModel;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.CreateResourceHistory;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageControl;
@@ -69,10 +70,11 @@ public class ListCreateResourceHistoryUIBean extends PagedDataTableUIBean {
@Override
public PageList<CreateResourceHistory> fetchPage(PageControl pageControl) {
+ Subject user = EnterpriseFacesContextUtility.getSubject();
Resource parentresource = EnterpriseFacesContextUtility.getResourceIfExists();
ResourceFactoryManagerLocal resourceFactoryManager = LookupUtil.getResourceFactoryManager();
- PageList<CreateResourceHistory> pageList = resourceFactoryManager.findCreateChildResourceHistory(
+ PageList<CreateResourceHistory> pageList = resourceFactoryManager.findCreateChildResourceHistory(user,
parentresource.getId(), null, null, pageControl);
return pageList;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ListDeleteResourceHistoryUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ListDeleteResourceHistoryUIBean.java
index 19611a9..d5a81aa 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ListDeleteResourceHistoryUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ListDeleteResourceHistoryUIBean.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.gui.inventory.resource;
import javax.faces.model.DataModel;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.DeleteResourceHistory;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageControl;
@@ -73,11 +74,12 @@ public class ListDeleteResourceHistoryUIBean extends PagedDataTableUIBean {
@Override
public PageList<DeleteResourceHistory> fetchPage(PageControl pageControl) {
+ Subject user = EnterpriseFacesContextUtility.getSubject();
Resource parentresource = EnterpriseFacesContextUtility.getResourceIfExists();
ResourceFactoryManagerLocal resourceFactoryManager = LookupUtil.getResourceFactoryManager();
pageControl.initDefaultOrderingField("drh.id", PageOrdering.DESC);
- PageList<DeleteResourceHistory> pageList = resourceFactoryManager.findDeleteChildResourceHistory(
+ PageList<DeleteResourceHistory> pageList = resourceFactoryManager.findDeleteChildResourceHistory(user,
parentresource.getId(), null, null, pageControl);
return pageList;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
index b85f056..6ddfa87 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java
@@ -346,8 +346,8 @@ public class ResourceFactoryManagerBean implements ResourceFactoryManagerLocal,
}
@SuppressWarnings("unchecked")
- public PageList<CreateResourceHistory> findCreateChildResourceHistory(int parentResourceId, Long beginDate,
- Long endDate, PageControl pageControl) {
+ public PageList<CreateResourceHistory> findCreateChildResourceHistory(Subject subject, int parentResourceId,
+ Long beginDate, Long endDate, PageControl pageControl) {
pageControl.initDefaultOrderingField("crh.id", PageOrdering.DESC);
int totalCount = getCreateChildResourceHistoryCount(parentResourceId, beginDate, endDate);
@@ -379,8 +379,8 @@ public class ResourceFactoryManagerBean implements ResourceFactoryManagerLocal,
}
@SuppressWarnings("unchecked")
- public PageList<DeleteResourceHistory> findDeleteChildResourceHistory(int parentResourceId, Long beginDate,
- Long endDate, PageControl pageControl) {
+ public PageList<DeleteResourceHistory> findDeleteChildResourceHistory(Subject subject, int parentResourceId,
+ Long beginDate, Long endDate, PageControl pageControl) {
pageControl.initDefaultOrderingField("drh.id", PageOrdering.DESC);
int totalCount = getDeleteChildResourceHistoryCount(parentResourceId, beginDate, endDate);
@@ -435,11 +435,11 @@ public class ResourceFactoryManagerBean implements ResourceFactoryManagerLocal,
// Create/locate package and package version
PackageVersion packageVersion = null;
if (packageUploadDetails == null) {
- packageVersion = contentManager.createPackageVersion(user, packageName,
- newPackageType.getId(), packageVersionNumber, architectureId, packageBitStream);
+ packageVersion = contentManager.createPackageVersion(user, packageName, newPackageType.getId(),
+ packageVersionNumber, architectureId, packageBitStream);
} else {
- packageVersion = contentManager.getUploadedPackageVersion(user, packageName,
- newPackageType.getId(), packageVersionNumber, architectureId, packageBitStream, packageUploadDetails, null);
+ packageVersion = contentManager.getUploadedPackageVersion(user, packageName, newPackageType.getId(),
+ packageVersionNumber, architectureId, packageBitStream, packageUploadDetails, null);
}
return doCreatePackageBackedResource(user, parentResource, newResourceType, newResourceName,
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java
index 261aff5..adfa015 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerLocal.java
@@ -131,6 +131,7 @@ public interface ResourceFactoryManagerLocal {
* These requests may be completed or still in progress; it represents the history of creation attempts for this
* parent resource.
*
+ * @param subject the user making the request
* @param parentResourceId resource to check for child resource creations
* @param beginDate filter used to show only results occurring after this epoch millis parameter, nullable
* @param endDate filter used to show only results occurring before this epoch millis parameter, nullable
@@ -138,14 +139,15 @@ public interface ResourceFactoryManagerLocal {
*
* @return list of requests
*/
- PageList<CreateResourceHistory> findCreateChildResourceHistory(int parentResourceId, Long beginDate, Long endDate,
- PageControl pageControl);
+ PageList<CreateResourceHistory> findCreateChildResourceHistory(Subject subject, int parentResourceId,
+ Long beginDate, Long endDate, PageControl pageControl);
/**
* Returns a pagination enabled list of requests to delete a child resource on the specified parent. These requests
* may be complete or still in progress; it represents the history of all delete attempts of child resources to this
* resource.
*
+ * @param subject the user making the request
* @param parentResourceId resource to check for deleted child resources
* @param beginDate filter used to show only results occurring after this epoch millis parameter, nullable
* @param endate filter used to show only results occurring before this epoch millis parameter, nullable
@@ -153,8 +155,8 @@ public interface ResourceFactoryManagerLocal {
*
* @return list of requests
*/
- PageList<DeleteResourceHistory> findDeleteChildResourceHistory(int parentResourceId, Long beginDate, Long endDate,
- PageControl pageControl);
+ PageList<DeleteResourceHistory> findDeleteChildResourceHistory(Subject subject, int parentResourceId,
+ Long beginDate, Long endDate, PageControl pageControl);
/**
* Persists a record in the resource history to indicate a request has been made to create a configuration-backed
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java
index aa30bf5..f38c1a4 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java
@@ -55,7 +55,6 @@ import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.server.plugin.pc.ServerPluginService;
import org.rhq.enterprise.server.resource.ResourceFactoryManagerLocal;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
@@ -94,9 +93,9 @@ public class ResourceFactoryManagerBeanTest extends AbstractEJB3Test {
prepareScheduler();
TestServerCommunicationsService agentServiceContainer = prepareForTestAgents();
agentServiceContainer.resourceFactoryService = mockAgentService;
-
+
//the server plugins are in play when package types are involved
- StandardServerPluginService serverPluginService = new StandardServerPluginService();
+ StandardServerPluginService serverPluginService = new StandardServerPluginService();
prepareCustomServerPluginService(serverPluginService);
serverPluginService.startMasterPluginContainer();
}
@@ -353,7 +352,7 @@ public class ResourceFactoryManagerBeanTest extends AbstractEJB3Test {
PageControl pageControl = new PageControl(0, 10000);
pageControl.initDefaultOrderingField("createdResourceName");
- PageList<CreateResourceHistory> historyList = resourceFactoryManager.findCreateChildResourceHistory(
+ PageList<CreateResourceHistory> historyList = resourceFactoryManager.findCreateChildResourceHistory(overlord,
parentResource.getId(), null, null, pageControl);
assert historyList.getTotalSize() == 3 : "Incorrect number of entries in page list. Expected: 3, Found: "
@@ -386,7 +385,7 @@ public class ResourceFactoryManagerBeanTest extends AbstractEJB3Test {
PageControl pageControl = new PageControl(0, 10000);
pageControl.initDefaultOrderingField("drh.id");
- PageList<DeleteResourceHistory> historyList = resourceFactoryManager.findDeleteChildResourceHistory(
+ PageList<DeleteResourceHistory> historyList = resourceFactoryManager.findDeleteChildResourceHistory(overlord,
parentResource.getId(), null, null, pageControl);
assert historyList.getTotalSize() == 3 : "Incorrect number of entries in page list. Expected: 3, Found: "
@@ -406,7 +405,7 @@ public class ResourceFactoryManagerBeanTest extends AbstractEJB3Test {
resourceConfiguration.getMap();
resourceFactoryManager.createResource(overlord, parentResource.getId(), childResourceType.getId(),
"NewResource", null, resourceConfiguration);
- PageList<CreateResourceHistory> historyList = resourceFactoryManager.findCreateChildResourceHistory(
+ PageList<CreateResourceHistory> historyList = resourceFactoryManager.findCreateChildResourceHistory(overlord,
parentResource.getId(), null, null, new PageControl(0, 1000));
int historyItemId = historyList.get(0).getId();
13 years, 1 month
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/help/HelpView.java | 24 +++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java | 20 ++++++--
2 files changed, 33 insertions(+), 11 deletions(-)
New commits:
commit 5a40add5ff601db923a576b918a181b730a84eb4
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Apr 6 17:46:42 2011 -0400
pretty up header and desc of Help and Test top views
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/help/HelpView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/help/HelpView.java
index 47865a8..1488e5d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/help/HelpView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/help/HelpView.java
@@ -28,19 +28,21 @@ import java.util.MissingResourceException;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Label;
import org.rhq.core.domain.common.ProductInfo;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.MessageConstants;
import org.rhq.enterprise.gui.coregui.client.components.AboutModalWindow;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
+import org.rhq.enterprise.gui.coregui.client.components.TitleBar;
import org.rhq.enterprise.gui.coregui.client.components.view.AbstractSectionedLeftNavigationView;
import org.rhq.enterprise.gui.coregui.client.components.view.NavigationItem;
import org.rhq.enterprise.gui.coregui.client.components.view.NavigationSection;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* The Help top-level view.
@@ -48,6 +50,7 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
* @author Jay Shaughnessy
*/
public class HelpView extends AbstractSectionedLeftNavigationView {
+
public static final ViewName VIEW_ID = new ViewName("Help", MSG.common_title_help());
private static final ViewName SECTION_PRODUCT_VIEW_ID = new ViewName("Product", MSG.view_help_section_product());
@@ -72,11 +75,19 @@ public class HelpView extends AbstractSectionedLeftNavigationView {
}
@Override
- protected HTMLFlow defaultView() {
- String contents = "<h1>" + MSG.common_title_help() + "</h1>\n" + MSG.view_helpTop_description();
- HTMLFlow flow = new HTMLFlow(contents);
- flow.setPadding(20);
- return flow;
+ protected LocatableVLayout defaultView() {
+ LocatableVLayout vLayout = new LocatableVLayout(this.extendLocatorId("Default"));
+ vLayout.setWidth100();
+
+ // TODO: Help icon.
+ TitleBar titleBar = new TitleBar(this, MSG.common_title_help());
+ vLayout.addMember(titleBar);
+
+ Label label = new Label(MSG.view_helpTop_description());
+ label.setPadding(10);
+ vLayout.addMember(label);
+
+ return vLayout;
}
private NavigationSection buildProductSection() {
@@ -140,4 +151,5 @@ public class HelpView extends AbstractSectionedLeftNavigationView {
sections.add(section);
}
}
+
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
index 8aae428..11e4f9e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
@@ -22,8 +22,9 @@ import java.util.ArrayList;
import java.util.List;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Label;
+import org.rhq.enterprise.gui.coregui.client.components.TitleBar;
import org.rhq.enterprise.gui.coregui.client.components.view.AbstractSectionedLeftNavigationView;
import org.rhq.enterprise.gui.coregui.client.components.view.NavigationItem;
import org.rhq.enterprise.gui.coregui.client.components.view.NavigationSection;
@@ -38,6 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.test.configuration.TestReadOnlyGrou
import org.rhq.enterprise.gui.coregui.client.test.i18n.TestPluralizationView;
import org.rhq.enterprise.gui.coregui.client.test.i18n.TestRemoteServiceStatisticsView;
import org.rhq.enterprise.gui.coregui.client.test.inventory.TestSearchBarView;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* The Test top-level view. This view is "hidden", i.e. there are no links to it, so the user must go to the URL
@@ -73,10 +75,18 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
}
protected Canvas defaultView() {
- String contents = "<h1>" + MSG.view_testTop_title() + "</h1>\n" + MSG.view_testTop_description();
- HTMLFlow flow = new HTMLFlow(contents);
- flow.setPadding(20);
- return flow;
+ LocatableVLayout vLayout = new LocatableVLayout(this.extendLocatorId("Default"));
+ vLayout.setWidth100();
+
+ // TODO: Help icon.
+ TitleBar titleBar = new TitleBar(this, MSG.view_testTop_title());
+ vLayout.addMember(titleBar);
+
+ Label label = new Label(MSG.view_testTop_description());
+ label.setPadding(10);
+ vLayout.addMember(label);
+
+ return vLayout;
}
@Override
13 years, 1 month
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java | 4 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java | 21 +++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java | 3 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java | 30 ++++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 16 ++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java | 10 +--
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/error.xhtml | 1
7 files changed, 56 insertions(+), 29 deletions(-)
New commits:
commit 87467591b42db71bbc38256e06032a474b0f4835
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Apr 6 17:31:44 2011 -0400
on Administration view, gray out left menu items if current user does not have the required global perm; add authz checks to buttons on alert template list view; do not display JSF menu bar on JSF error pages; add HTML escaping of alertdef names and descriptions for XSS prevention
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
index 9e005d2..4e47c0a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
@@ -39,7 +39,6 @@ import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
-import org.rhq.enterprise.server.measurement.MeasurementPreferences;
/**
* Upon application load, if already loggedIn on the server-side, local loggedIn bit will be set to true.
@@ -612,7 +611,8 @@ public class UserSessionManager {
/**
* Obtain an object that you can use to add/modify/remove/retrieve user preferences.
- * You can optionally wrap the returned object with a {@link MeasurementPreferences}
+ * You can optionally wrap the returned object with a
+ * {@link org.rhq.enterprise.gui.coregui.client.util.preferences.MeasurementUserPreferences}
* object to work with measurement preferences.
*
* @return user preferences object
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
index 757fad6..2285d8e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
@@ -1,13 +1,13 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
- * This program is free software; you can retribute it and/or modify
+ * 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 tributed in the hope that it will be useful,
+ * 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.
@@ -49,6 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Ian Springer
*/
public class AdministrationView extends AbstractSectionedLeftNavigationView {
+
public static final ViewName VIEW_ID = new ViewName("Administration", MSG.view_admin_administration());
public static final ViewName SECTION_SECURITY_VIEW_ID = new ViewName("Security", MSG.view_admin_security());
@@ -136,14 +137,14 @@ public class AdministrationView extends AbstractSectionedLeftNavigationView {
return new FullHTMLPane(extendLocatorId(PAGE_SERVERS_VIEW_ID.getName()),
"/rhq/ha/listServers-plain.xhtml?nomenu=true");
}
- });
+ }, getGlobalPermissions().contains(Permission.MANAGE_INVENTORY));
NavigationItem agentsItem = new NavigationItem(PAGE_AGENTS_VIEW_ID, "global/Agent_16.png", new ViewFactory() {
public Canvas createView() {
return new FullHTMLPane(extendLocatorId(PAGE_AGENTS_VIEW_ID.getName()),
"/rhq/ha/listAgents-plain.xhtml?nomenu=true");
}
- });
+ }, getGlobalPermissions().contains(Permission.MANAGE_INVENTORY));
NavigationItem affinityGroupsItem = new NavigationItem(PAGE_AFFINITY_GROUPS_VIEW_ID, "types/Group_up_16.png",
new ViewFactory() {
@@ -151,7 +152,7 @@ public class AdministrationView extends AbstractSectionedLeftNavigationView {
return new FullHTMLPane(extendLocatorId(PAGE_AFFINITY_GROUPS_VIEW_ID.getName()),
"/rhq/ha/listAffinityGroups-plain.xhtml?nomenu=true");
}
- });
+ }, getGlobalPermissions().contains(Permission.MANAGE_INVENTORY));
NavigationItem partitionEventsItem = new NavigationItem(PAGE_PARTITION_EVENTS_VIEW_ID,
"subsystems/event/Events_16.png", new ViewFactory() {
@@ -159,14 +160,14 @@ public class AdministrationView extends AbstractSectionedLeftNavigationView {
return new FullHTMLPane(extendLocatorId(PAGE_PARTITION_EVENTS_VIEW_ID.getName()),
"/rhq/ha/listPartitionEvents-plain.xhtml?nomenu=true");
}
- });
+ }, getGlobalPermissions().contains(Permission.MANAGE_INVENTORY));
NavigationItem remoteAgentInstallItem = new NavigationItem(RemoteAgentInstallView.VIEW_ID,
"global/Agent_16.png", new ViewFactory() {
public Canvas createView() {
return new RemoteAgentInstallView(extendLocatorId("RemoteAgentInstall"));
}
- });
+ }, getGlobalPermissions().contains(Permission.MANAGE_INVENTORY));
return new NavigationSection(SECTION_TOPOLOGY_VIEW_ID, serversItem, agentsItem, affinityGroupsItem,
partitionEventsItem, remoteAgentInstallItem);
@@ -178,7 +179,7 @@ public class AdministrationView extends AbstractSectionedLeftNavigationView {
public Canvas createView() {
return new SystemSettingsView(extendLocatorId(SystemSettingsView.VIEW_ID.getName()));
}
- });
+ }, getGlobalPermissions().contains(Permission.MANAGE_SETTINGS));
systemSettingsItem.setRefreshRequired(true); // refresh so it always reloads the latest settings
NavigationItem templatesItem = new NavigationItem(ResourceTypeTreeView.VIEW_ID, ImageManager
@@ -202,7 +203,7 @@ public class AdministrationView extends AbstractSectionedLeftNavigationView {
return new FullHTMLPane(extendLocatorId(PAGE_PLUGINS_VIEW_ID.getName()),
"/rhq/admin/plugin/plugin-list-plain.xhtml?nomenu=true");
}
- });
+ }, getGlobalPermissions().contains(Permission.MANAGE_SETTINGS));
return new NavigationSection(SECTION_CONFIGURATION_VIEW_ID, systemSettingsItem, templatesItem, downloadsItem,
pluginsItem);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
index c221bd4..24176bb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
@@ -41,6 +41,7 @@ import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.EscapedHtmlCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -79,10 +80,12 @@ public abstract class AbstractAlertDefinitionsDataSource extends
ListGridField nameField = new ListGridField(FIELD_NAME, MSG.view_alerts_field_name());
nameField.setWidth("20%");
+ nameField.setCellFormatter(new EscapedHtmlCellFormatter());
fields.add(nameField);
ListGridField descriptionField = new ListGridField(FIELD_DESCRIPTION, MSG.common_title_description());
descriptionField.setWidth("20%");
+ descriptionField.setCellFormatter(new EscapedHtmlCellFormatter());
fields.add(descriptionField);
ListGridField ctimeField = new ListGridField(FIELD_CTIME, MSG.view_alerts_field_created_time());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index 4d8b846..c3f817b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -21,7 +21,6 @@ package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -39,7 +38,6 @@ import org.rhq.enterprise.gui.coregui.client.components.table.EscapedHtmlCellFor
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
/**
* Superclass to the different alert definition views. This should be subclassed
@@ -79,32 +77,44 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
boolean permitted = isAllowedToModifyAlertDefinitions();
- TableActionEnablement enablement = (permitted) ? TableActionEnablement.ALWAYS : TableActionEnablement.NEVER;
- addTableAction(extendLocatorId("New"), MSG.common_button_new(), null, new AbstractTableAction(enablement) {
+ addTableAction(extendLocatorId("New"), MSG.common_button_new(), null, new AbstractTableAction() {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ return super.isEnabled(selection) && isAllowedToModifyAlertDefinitions();
+ }
+
public void executeAction(ListGridRecord[] selection, Object actionValue) {
newButtonPressed(selection);
- // I don't think you want this refresh, it will recreate the new alert detail
- //refresh();
}
});
- enablement = (permitted) ? TableActionEnablement.ANY : TableActionEnablement.NEVER;
addTableAction(extendLocatorId("Enable"), MSG.common_button_enable(), MSG
- .view_alert_definitions_enable_confirm(), new AbstractTableAction(enablement) {
+ .view_alert_definitions_enable_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ return super.isEnabled(selection) && isAllowedToModifyAlertDefinitions();
+ }
+
public void executeAction(ListGridRecord[] selection, Object actionValue) {
enableButtonPressed(selection);
refresh();
}
});
addTableAction(extendLocatorId("Disable"), MSG.common_button_disable(), MSG
- .view_alert_definitions_disable_confirm(), new AbstractTableAction(enablement) {
+ .view_alert_definitions_disable_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ return super.isEnabled(selection) && isAllowedToModifyAlertDefinitions();
+ }
+
public void executeAction(ListGridRecord[] selection, Object actionValue) {
disableButtonPressed(selection);
refresh();
}
});
addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), MSG
- .view_alert_definitions_delete_confirm(), new AbstractTableAction(enablement) {
+ .view_alert_definitions_delete_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ return super.isEnabled(selection) && isAllowedToModifyAlertDefinitions();
+ }
+
public void executeAction(ListGridRecord[] selection, Object actionValue) {
deleteButtonPressed(selection);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
index ff98eec..2a83fbd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
@@ -23,15 +23,20 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.Collections;
import java.util.EnumSet;
+import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.MetadataType;
@@ -46,6 +51,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
public static final String CRITERIA_RESOURCE_TYPE_ID = "resourceTypeId";
private ResourceType resourceType;
+ private Set<Permission> globalPermissions;
public TemplateAlertDefinitionsView(String locatorId, ResourceType resourceType) {
super(locatorId, "Alert Templates");
@@ -71,6 +77,13 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
});
}
+
+ this.globalPermissions = Collections.emptySet();
+ new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
+ public void onPermissionsLoaded(Set<Permission> globalPermissions) {
+ TemplateAlertDefinitionsView.this.globalPermissions = globalPermissions;
+ }
+ });
}
@Override
@@ -102,8 +115,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
protected boolean isAllowedToModifyAlertDefinitions() {
- // TODO: see if user can modify template alerts
- return true;
+ return globalPermissions.contains(Permission.MANAGE_SETTINGS);
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java
index d481d86..f66b76e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java
@@ -37,6 +37,7 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
@@ -115,7 +116,7 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D
int resourceId = alertDef.getResource().getId();
int alertDefId = alertDef.getId();
String link = LinkManager.getSubsystemAlertDefinitionLink(resourceId, alertDefId);
- return "<a href=\"" + link + "\">" + alertDef.getName() + "</a>";
+ return "<a href=\"" + link + "\">" + StringUtility.escapeHtml(alertDef.getName()) + "</a>";
}
});
}
@@ -131,7 +132,7 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D
if (record.getAttribute(FIELD_PARENT) != null) {
return MSG.view_reports_alertDefinitions_parentHover();
}
- return null;
+ return MSG.common_val_na();
}
});
parentField.addRecordClickHandler(new RecordClickHandler() {
@@ -181,15 +182,14 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D
ListGridField resourceField = new ListGridField(FIELD_RESOURCE, MSG.common_title_resource());
resourceField.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ public String format(Object value, ListGridRecord listGridRecord, int i, int i1) {
String url = LinkManager
.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
- return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ return SeleniumUtility.getLocatableHref(url, StringUtility.escapeHtml(value.toString()), null);
}
});
resourceField.setShowHover(true);
resourceField.setHoverCustomizer(new HoverCustomizer() {
-
public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/error.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/error.xhtml
index 5efff7f..d71ba87 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/error.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/error.xhtml
@@ -16,6 +16,7 @@
<ui:composition template="/rhq/layout/main-layout.xhtml">
+<ui:param name="disableMenu" value="true"/>
<ui:param name="defaultPageTitle" value="Error processing page"/>
<ui:define name="body-area">
13 years, 1 month
[rhq] 4 commits - modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/AbstractOperationHistoryPortlet.java | 394 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationHistoryPortlet.java | 48
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationSchedulePortlet.java | 356 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 530 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java | 357 ------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java | 81 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java | 447 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java | 179 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java | 314 -----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java | 25
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java | 78 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 5
21 files changed, 1558 insertions(+), 1322 deletions(-)
New commits:
commit 308b5785caa567a4b7770a33c8c16d8c7f181ac7
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 6 17:17:31 2011 -0400
More Op portlet tweaks
- Remove ID column for op hist views
- Fix result size issue for op schedule portlet
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java
index a9a1c3f..eec9831 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java
@@ -123,10 +123,6 @@ public class OperationHistoryDataSource extends
public ArrayList<ListGridField> getListGridFields() {
ArrayList<ListGridField> fields = new ArrayList<ListGridField>(6);
- ListGridField idField = new ListGridField(Field.ID, MSG.common_title_id());
- idField.setWidth(70);
- fields.add(idField);
-
ListGridField startTimeField = createStartedTimeField();
fields.add(startTimeField);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index d7bfdad..fca0e8f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -212,7 +212,13 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati
record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record));
}
response.setData(records);
- response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+ // for paging to work we have to specify size of full result set, but if a limit has been set,
+ // respect the limit
+ int resultSize = result.getTotalSize();
+ if (operationsRangeScheduled > 0 && operationsRangeScheduled < resultSize) {
+ resultSize = operationsRangeScheduled;
+ }
+ response.setTotalRows(resultSize);
processResponse(request.getRequestId(), response);
}
});
commit 88e888b07dd22fe7155a7993d5a6b3f9a38ddb64
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 6 16:11:59 2011 -0400
Work on Operation History Portlets and Views
- Fixed issues in Operation portlets but went a bit further and normalized
all of the resource operation history views. So, the report view, global
portlet, resource portlet, and resource detail views now share the same
underlying code, normalizing presentation and consolidating fixes. The
config is more advanced for the global portlet as it now shares what
was in place for the resource level portlet.
- Split global operations portlet into two portlets: Recent Operations and
Scheduled Operations. Only Recent Operations is now on the default dash.
This saves some space in the dash, gives the user more options, and
is more clear as the configuration is different for each view.
- The new scheduled operations portlet fixes some legacy issues for the
scheduled ops from the original portlet.
- Added status filtering to non-portlet history views
- Fixed a bug preventing navigation to th operation schedule detail view for
readonly situations.
Note that due to the difficulty of the operation *schedule* data model and
the fewer number of related views, similar refactoring was not carried out
and the views may not be normalized. Also, group op history was not
affected as the views for group history in general are probably going to
be revised.
- Fixes overall spanned links, hover, ordering, buttin enablement, etc.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
index 2a6beeb..e4ed6f0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
@@ -152,6 +152,18 @@ public class LinkManager {
return link;
}
+ public static String getSubsystemResourceOperationScheduleLink(int resourceId, int opScheduleId) {
+ String link;
+ if (GWT) {
+ link = "#Resource/" + resourceId + "/Operations/Schedules/" + opScheduleId;
+ } else {
+ link = "/rhq/resource/operation/resourceOperationScheduleDetails-plain.xhtml?id=" + resourceId + "&opId="
+ + opScheduleId;
+
+ }
+ return link;
+ }
+
public static String getSubsystemAlertHistoryLink(int resourceId, int alertHistoryId) {
String link;
if (GWT) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index d72abbf..7d0ec7a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -62,7 +62,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.NamedTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.NamedTabSet;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationHistoryPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems.ProblemResourcesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.InventorySummaryPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MashupPortlet;
@@ -390,12 +390,8 @@ public class DashboardsView extends LocatableVLayout implements DashboardContain
ProblemResourcesPortlet.defaultValue));
dashboard.addPortlet(problemResources, 1, 1);
- DashboardPortlet operations = new DashboardPortlet(OperationsPortlet.NAME, OperationsPortlet.KEY, 350);
- //initialize config for the operations portlet.
- operations.getConfiguration().put(
- new PropertySimple(OperationsPortlet.OPERATIONS_RANGE_COMPLETED, OperationsPortlet.defaultValue));
- operations.getConfiguration().put(
- new PropertySimple(OperationsPortlet.OPERATIONS_RANGE_SCHEDULED, OperationsPortlet.defaultValue));
+ DashboardPortlet operations = new DashboardPortlet(OperationHistoryPortlet.NAME, OperationHistoryPortlet.KEY,
+ 200);
dashboard.addPortlet(operations, 1, 2);
return dashboard;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 2ccb582..7b23c0a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -45,7 +45,8 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resour
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformSummaryPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported.RecentlyAddedResourcesPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationHistoryPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationSchedulePortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems.ProblemResourcesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceAlertsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceBundleDeploymentsPortlet;
@@ -96,7 +97,8 @@ public class PortletFactory {
registeredPortletFactoryMap.put(MashupPortlet.KEY, MashupPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(MessagePortlet.KEY, MessagePortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(ProblemResourcesPortlet.KEY, ProblemResourcesPortlet.Factory.INSTANCE);
- registeredPortletFactoryMap.put(OperationsPortlet.KEY, OperationsPortlet.Factory.INSTANCE);
+ registeredPortletFactoryMap.put(OperationHistoryPortlet.KEY, OperationHistoryPortlet.Factory.INSTANCE);
+ registeredPortletFactoryMap.put(OperationSchedulePortlet.KEY, OperationSchedulePortlet.Factory.INSTANCE);
// defines portlet name mappings for global Dashboard
registeredPortletNameMap = new HashMap<String, String>(registeredPortletFactoryMap.size());
@@ -112,7 +114,8 @@ public class PortletFactory {
registeredPortletNameMap.put(MashupPortlet.KEY, MashupPortlet.NAME);
registeredPortletNameMap.put(MessagePortlet.KEY, MessagePortlet.NAME);
registeredPortletNameMap.put(ProblemResourcesPortlet.KEY, ProblemResourcesPortlet.NAME);
- registeredPortletNameMap.put(OperationsPortlet.KEY, OperationsPortlet.NAME);
+ registeredPortletNameMap.put(OperationHistoryPortlet.KEY, OperationHistoryPortlet.NAME);
+ registeredPortletNameMap.put(OperationSchedulePortlet.KEY, OperationSchedulePortlet.NAME);
//############## Group Activity Dashboard ############################################
//defines mapping for Group Activity Dashboard
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/AbstractOperationHistoryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/AbstractOperationHistoryPortlet.java
new file mode 100644
index 0000000..77b8af8
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/AbstractOperationHistoryPortlet.java
@@ -0,0 +1,394 @@
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.user.client.Timer;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
+import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
+import com.smartgwt.client.widgets.form.fields.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.resource.composite.ResourcePermission;
+import org.rhq.core.domain.util.OrderingField;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryDataSource;
+import org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryView;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * A base class for deriving recent resource operations portlets for different entity contexts. In this way the
+ * basic plumbing is shared, giving a consistent behavior and configuration for the concrete portlets.
+ *
+ * @author Jay Shaughnessy
+ * @author Simeon Pinder
+ */
+public abstract class AbstractOperationHistoryPortlet extends OperationHistoryView implements CustomSettingsPortlet,
+ AutoRefreshPortlet {
+
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+ private OperationHistoryPortletDataSource dataSource;
+ private Boolean hasControlPermission;
+
+ // autorefresh timer
+ private Timer refreshTimer;
+
+ public AbstractOperationHistoryPortlet(String locatorId, EntityContext entityContext) {
+ super(locatorId, null, entityContext);
+
+ setShowFilterForm(false); //disable filter form for portlet
+ setOverflow(Overflow.VISIBLE);
+ setShowFooterRefresh(false); //disable footer refresh button as redundant for portlets
+ setShowHeader(false);//disable header for portlets
+ }
+
+ public Timer getRefreshTimer() {
+ return refreshTimer;
+ }
+
+ public void setRefreshTimer(Timer refreshTimer) {
+ this.refreshTimer = refreshTimer;
+ }
+
+ public PortletWindow getPortletWindow() {
+ return portletWindow;
+ }
+
+ @Override
+ public OperationHistoryPortletDataSource getDataSource() {
+ if (null == this.dataSource) {
+ this.dataSource = new OperationHistoryPortletDataSource(getContext());
+ }
+ return this.dataSource;
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_operations_criteria());
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+
+ // the portletWindow does not change, so we can hold onto it locally
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ // if there is no configuration there is nothing to set
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+
+ Configuration config = storedPortlet.getConfiguration();
+
+ // not sure I love the fact that this common portlet config assigns some irrelevant/unused config props,
+ // may be better to prune the common set and add the specific properties locally in this method
+ for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
+ if (config.getSimple(key) == null) {
+ config.put(new PropertySimple(key, PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION
+ .get(key)));
+ }
+ }
+
+ getDataSource().setConfiguration(config);
+ }
+
+ @Override
+ public DynamicForm getCustomSettingsForm() {
+
+ LocatableDynamicForm customSettingsForm = new LocatableDynamicForm(extendLocatorId("CustomSettings"));
+ LocatableVLayout page = new LocatableVLayout(customSettingsForm.extendLocatorId("Page"));
+ LocatableDynamicForm filterForm = new LocatableDynamicForm(page.extendLocatorId("Filter"));
+ filterForm.setMargin(5);
+
+ final DashboardPortlet storedPortlet = this.portletWindow.getStoredPortlet();
+ final Configuration portletConfig = storedPortlet.getConfiguration();
+
+ // operation history status selector
+ final SelectItem operationStatusSelector = PortletConfigurationEditorComponent
+ .getOperationStatusEditor(portletConfig);
+
+ // result count selector
+ final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
+
+ // range selector
+ final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent
+ .getMeasurementRangeEditor(portletConfig);
+
+ filterForm.setItems(operationStatusSelector, resultCountSelector);
+
+ //submit handler
+ customSettingsForm.addSubmitValuesHandler(new SubmitValuesHandler() {
+
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+ // operation status
+ String selectedValue = operationStatusSelector.getValue().toString();
+ if ((selectedValue.trim().isEmpty())
+ || (selectedValue.split(",").length == OperationRequestStatus.values().length)) {
+ selectedValue = "";
+ }
+ portletConfig.put(new PropertySimple(Constant.OPERATION_STATUS, selectedValue));
+
+ // result count
+ selectedValue = resultCountSelector.getValue().toString();
+ if (selectedValue.trim().isEmpty()) {
+ selectedValue = Constant.RESULT_COUNT_DEFAULT;
+ }
+ portletConfig.put(new PropertySimple(Constant.RESULT_COUNT, selectedValue));
+
+ // time range settings
+ saveMeasurementRangeEditorSettings(measurementRangeEditor, portletConfig);
+
+ // persist and reload portlet
+ storedPortlet.setConfiguration(portletConfig);
+ configure(portletWindow, storedPortlet);
+ //apply latest settings to the visible result set
+ refresh();
+ }
+ });
+
+ page.addMember(measurementRangeEditor);
+ page.addMember(filterForm);
+ customSettingsForm.addChild(page);
+
+ return customSettingsForm;
+ }
+
+ /**
+ * Takes the current value of the widget and persists it into the configuration object passed in.
+ *
+ * @param measurementRangeEditor
+ * @param portletConfig
+ * returns populated configuration object.
+ */
+ private void saveMeasurementRangeEditorSettings(final CustomConfigMeasurementRangeEditor measurementRangeEditor,
+ Configuration portletConfig) {
+ String selectedValue = null;
+ if ((measurementRangeEditor != null) && (portletConfig != null)) {
+ //time range filter. Check for enabled and then persist property. Dealing with compound widget.
+ FormItem item = measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM);
+ CheckboxItem itemC = (CheckboxItem) item;
+ boolean persistTimeRangeSettings = itemC.getValueAsBoolean();
+ if (persistTimeRangeSettings) {//retrieve values and persist
+ selectedValue = String.valueOf(itemC.getValueAsBoolean());
+ if (!selectedValue.trim().isEmpty()) {//then call
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, selectedValue));
+ }
+
+ //time advanced time filter enabled.
+ boolean isAdvanceTimeSetting = false;
+ selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
+ if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) {
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
+ isAdvanceTimeSetting = Boolean.valueOf(selectedValue);
+ }
+
+ //time frame
+ List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
+ if (isAdvanceTimeSetting) {//advanced settings
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1))));
+ } else {
+ //save not advanced time range
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_LASTN, measurementRangeEditor
+ .getMetricRangePreferences().lastN));
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_UNIT, measurementRangeEditor
+ .getMetricRangePreferences().unit));
+ }
+ } else {//if disabled, reset time defaults
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, false));
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, false));
+ List<Long> rangeArray = MeasurementUtility.calculateTimeFrame(Integer
+ .valueOf(Constant.METRIC_RANGE_LASTN_DEFAULT), Integer.valueOf(Constant.METRIC_RANGE_UNIT_DEFAULT));
+ // String[] range = {String.valueOf(rangeArray.get(0)),String.valueOf(rangeArray.get(1))};
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE,
+ (String.valueOf(rangeArray.get(0)) + "," + String.valueOf(rangeArray.get(1)))));
+ }
+ }
+ }
+
+ protected boolean hasControlPermission() {
+ if (null == this.hasControlPermission) {
+ Set<Permission> globalPerm = this.getPortletWindow().getGlobalPermissions();
+ ResourcePermission resPerm = this.getPortletWindow().getResourcePermissions();
+
+ this.hasControlPermission = (globalPerm.contains(Permission.MANAGE_INVENTORY) || (null != resPerm && resPerm
+ .isControl()));
+ }
+
+ return this.hasControlPermission;
+ }
+
+ @Override
+ protected void refreshTableInfo() {
+ super.refreshTableInfo();
+ if (getTableInfo() != null) {
+ int count = getListGrid().getSelection().length;
+ getTableInfo().setContents(
+ MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
+ }
+ }
+
+ public void startRefreshCycle() {
+ refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer);
+ }
+
+ public boolean isRefreshing() {
+ // TODO: actually keep track of when the portlet is refreshing data
+ return false;
+ }
+
+ @Override
+ protected void onDestroy() {
+ AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
+
+ super.onDestroy();
+ }
+
+ @Override
+ public void redraw() {
+ super.refresh();
+ markForRedraw();
+ }
+
+ static public class OperationHistoryPortletDataSource extends OperationHistoryDataSource {
+ private Configuration configuration;
+
+ public OperationHistoryPortletDataSource(EntityContext entityContext) {
+ this(entityContext, null);
+ }
+
+ public OperationHistoryPortletDataSource(EntityContext entityContext, Configuration configuration) {
+ super(entityContext);
+ this.configuration = configuration;
+ }
+
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ /* (non-Javadoc)
+ * This override allows us to set the total rows to the number of recent op histpry configured for
+ * the portlet. This sets the counter appropriately and stops further queries to the server.
+ *
+ * @see org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryDataSource#dataRetrieved(org.rhq.core.domain.util.PageList, com.smartgwt.client.data.DSResponse, com.smartgwt.client.data.DSRequest)
+ */
+ @Override
+ protected void dataRetrieved(PageList<ResourceOperationHistory> result, DSResponse response, DSRequest request) {
+ super.dataRetrieved(result, response, request);
+
+ response.setTotalRows(result.size());
+ }
+
+ @Override
+ protected ResourceOperationHistoryCriteria getFetchCriteria(DSRequest request) {
+ ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
+
+ // result count
+ String currentSetting = this.configuration.getSimpleValue(Constant.RESULT_COUNT,
+ Constant.RESULT_COUNT_DEFAULT);
+
+ // We have to set a PageControl override here, or RPCDataSource will apply default paging based on the
+ // request. But, once setting a paging override the CriteriaQueryGenerator will use it for
+ // paging *and* sorting, so we need to also ensure our desired sorting is included in the override. So,
+ // to get the most recent op histories, apply a descending ordering on create time.
+ int pageNumber = 0;
+ int pageSize = Integer.valueOf(currentSetting);
+ OrderingField orderingField = new OrderingField(OperationHistoryDataSource.Field.CREATED_TIME,
+ PageOrdering.DESC);
+ criteria.setPageControl(new PageControl(pageNumber, pageSize, orderingField));
+
+ // status
+ currentSetting = this.configuration.getSimpleValue(Constant.OPERATION_STATUS, "");
+ String[] parsedValues = currentSetting.trim().split(",");
+ if (!(currentSetting.trim().isEmpty() || parsedValues.length == OperationRequestStatus.values().length)) {
+ OperationRequestStatus[] operationStatuses = new OperationRequestStatus[parsedValues.length];
+ int indx = 0;
+ for (String priority : parsedValues) {
+ OperationRequestStatus s = OperationRequestStatus.valueOf(priority);
+ operationStatuses[indx++] = s;
+ }
+ criteria.addFilterStatuses(operationStatuses);
+ }
+
+ //result timeframe if enabled
+ currentSetting = this.configuration.getSimpleValue(Constant.METRIC_RANGE_ENABLE, null);
+ if (Boolean.valueOf(currentSetting)) {//then proceed setting
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ PropertySimple property = this.configuration.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
+ if (property != null) {
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ property = this.configuration.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ criteria.addFilterStartTime(Long.valueOf(range[0]));
+ criteria.addFilterEndTime(Long.valueOf(range[1]));
+ }
+ } else {
+ //Simple time settings
+ property = this.configuration.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property = this.configuration.getSimple(Constant.METRIC_RANGE_UNIT);
+ int lastUnits = property.getIntegerValue();
+ ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, Integer
+ .valueOf(lastUnits));
+ criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0)));
+ criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1)));
+ }
+ }
+ }
+
+ // add any context related filters
+ switch (getEntityContext().type) {
+ case Resource:
+ criteria.addFilterResourceIds(getEntityContext().getResourceId());
+ break;
+
+ case ResourceGroup:
+ criteria.addFilterGroupOperationHistoryId(getEntityContext().getGroupId());
+ }
+
+ return criteria;
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationHistoryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationHistoryPortlet.java
new file mode 100644
index 0000000..90aedd8
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationHistoryPortlet.java
@@ -0,0 +1,48 @@
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class OperationHistoryPortlet extends AbstractOperationHistoryPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "Operations";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_operations();
+
+ public OperationHistoryPortlet(String locatorId) {
+ super(locatorId, EntityContext.forSubsystemView());
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+
+ return new OperationHistoryPortlet(locatorId);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationSchedulePortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationSchedulePortlet.java
new file mode 100644
index 0000000..252f6d2
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationSchedulePortlet.java
@@ -0,0 +1,356 @@
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+import com.google.gwt.user.client.Timer;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
+import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
+import com.smartgwt.client.widgets.form.fields.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.VStack;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * A view that displays a live table of completed Operations and scheduled operations.
+ *
+ * @author Simeon Pinder
+ */
+public class OperationSchedulePortlet extends LocatableVLayout implements CustomSettingsPortlet, AutoRefreshPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "OperationSchedule";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.common_title_scheduled_operations();
+
+ public static final String OPERATIONS_RANGE_SCHEDULED_ENABLED = "operations-scheduled-enabled";
+ public static final String OPERATIONS_RANGE_SCHEDULED = "operations-range-scheduled";
+ public static String RANGE_DISABLED_MESSAGE = MSG.view_portlet_operations_disabled();
+ //TODO: change this to use the Smart GWT default value.
+ public static String RANGE_DISABLED_MESSAGE_DEFAULT = MSG.common_msg_noItemsToShow();
+
+ private static final int WIDTH_RECENT_TIME = 150;
+ private static final int WIDTH_RECENT_STATUS = 50;
+ private static final int WIDTH_SCHEDULED_TIME = WIDTH_RECENT_TIME + WIDTH_RECENT_STATUS;
+
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+
+ //ListGrids for operations
+ private LocatableListGrid scheduledOperationsGrid = null;
+
+ private ScheduledOperationsDataSource dataSourceScheduled;
+ public static String unlimited = MSG.common_label_unlimited();
+ public static String defaultValue = "5";
+ public static boolean defaultEnabled = true;
+
+ private Timer refreshTimer;
+
+ //default no-args constructor for serialization.
+ private OperationSchedulePortlet() {
+ super("(unitialized)");
+ }
+
+ public OperationSchedulePortlet(String locatorId) {
+ super(locatorId);
+ this.dataSourceScheduled = new ScheduledOperationsDataSource(this);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ this.scheduledOperationsGrid = new LocatableListGrid(extendLocatorId("Scheduled"));
+ scheduledOperationsGrid.setDataSource(getDataSourceScheduled());
+ scheduledOperationsGrid.setAutoFetchData(true);
+ scheduledOperationsGrid.setWidth100();
+ scheduledOperationsGrid.setWrapCells(true);
+
+ addMember(scheduledOperationsGrid);
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ ListGridField timeNext = new ListGridField(ScheduledOperationsDataSource.Field.TIME.propertyName(),
+ ScheduledOperationsDataSource.Field.TIME.title(), WIDTH_SCHEDULED_TIME);
+ timeNext.setCellFormatter(new TimestampCellFormatter() {
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ if (value != null) {
+ String timestamp = super.format(value, record, rowNum, colNum);
+ Integer resourceId = record.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
+ Integer opScheduleId = record.getAttributeAsInt("id");
+ String url = LinkManager.getSubsystemResourceOperationScheduleLink(resourceId, opScheduleId);
+ return SeleniumUtility.getLocatableHref(url, timestamp, null);
+ } else {
+ return "<i>" + MSG.common_label_none() + "</i>";
+ }
+ }
+ });
+ timeNext.setShowHover(true);
+ timeNext.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(ScheduledOperationsDataSource.Field.TIME
+ .propertyName()));
+
+ ListGridField operationNext = new ListGridField(ScheduledOperationsDataSource.Field.OPERATION.propertyName(),
+ ScheduledOperationsDataSource.Field.OPERATION.title());
+
+ ListGridField resourceNext = new ListGridField(ScheduledOperationsDataSource.Field.RESOURCE.propertyName(),
+ ScheduledOperationsDataSource.Field.RESOURCE.title());
+ resourceNext.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ }
+ });
+ resourceNext.setShowHover(true);
+ resourceNext.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
+
+ ListGridField ancestryNext = AncestryUtil.setupAncestryListGridField();
+
+ scheduledOperationsGrid.setFields(timeNext, operationNext, resourceNext, ancestryNext);
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+
+ PropertySimple property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED);
+ if ((property != null) && (property.getStringValue() != null)) {
+ //retrieve and translate to int
+ String retrieved = property.getStringValue();
+ if (unlimited.equals(retrieved)) {
+ getDataSourceScheduled().setOperationsRangeScheduled(-1);
+ } else {
+ getDataSourceScheduled().setOperationsRangeScheduled(Integer.parseInt(retrieved));
+ }
+ } else {//create setting
+ storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue));
+ getDataSourceScheduled().setOperationsRangeScheduled(-1);
+ }
+ //Checkbox settings property
+ property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
+ if ((property != null) && (property.getBooleanValue() != null)) {
+ getDataSourceScheduled().setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue());
+ } else {//create setting
+ storedPortlet.getConfiguration()
+ .put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, defaultEnabled));
+ getDataSourceScheduled().setOperationsRangeScheduleEnabled(defaultEnabled);
+ }
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_scheduledOperations());
+ }
+
+ /** Constructs the dynamic form instance using 1 column and multiple row layouts.
+ */
+ public DynamicForm getCustomSettingsForm() {
+
+ //root dynamic form instance
+ final LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("CustomSettings"));
+
+ final DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+
+ //vertical layout
+ VStack column = new VStack();
+
+ //horizontal layout
+ LocatableHLayout sheduledOperationsLayout = new LocatableHLayout(extendLocatorId("EnableScheduledOperations"));
+
+ final CheckboxItem enableScheduledOperationsGrouping = new CheckboxItem();
+ enableScheduledOperationsGrouping.setName(OPERATIONS_RANGE_SCHEDULED_ENABLED);
+ enableScheduledOperationsGrouping.setTitle(" " + MSG.view_portlet_operations_config_show_next() + " ");
+ enableScheduledOperationsGrouping.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ String selectedItem = "" + event.getValue();
+ //stuff into the master form for retrieval
+ form.setValue(OPERATIONS_RANGE_SCHEDULED_ENABLED, selectedItem);
+ }
+ });
+
+ //wrap field item in dynamicform for addition
+ DynamicForm fieldWrapper = new DynamicForm();
+ fieldWrapper.setFields(enableScheduledOperationsGrouping);
+ sheduledOperationsLayout.addMember(fieldWrapper);
+
+ //retrieve previous value otherwise initialize to true(live unlimited list)
+ PropertySimple retrieved = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
+ if (retrieved != null) {
+ enableScheduledOperationsGrouping.setValue(retrieved.getBooleanValue());
+ } else {
+ enableScheduledOperationsGrouping.setValue(true);
+ }
+
+ //------------- Build second combobox for timeframe for problem resources search.
+ final SelectItem maximumScheduledOperationsComboBox = new SelectItem(OPERATIONS_RANGE_SCHEDULED);
+ maximumScheduledOperationsComboBox.setTitle("");
+ maximumScheduledOperationsComboBox.setHint("<nobr><b> " + MSG.common_label_scheduled_operations()
+ + ".</b></nobr>");
+ maximumScheduledOperationsComboBox.setType("selection");
+ //define acceptable values for display amount
+ String[] acceptableDisplayValues = { "1", "5", "10", "15", unlimited };
+ maximumScheduledOperationsComboBox.setValueMap(acceptableDisplayValues);
+ maximumScheduledOperationsComboBox.setWidth(100);
+ maximumScheduledOperationsComboBox.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ String selectedItem = "" + event.getValue();
+ //stuff into the master form for retrieval
+ form.setValue(OPERATIONS_RANGE_SCHEDULED, selectedItem);
+ }
+ });
+
+ //set to default
+ String selectedValue = defaultValue;
+ if (storedPortlet != null) {
+ //if property exists retrieve it
+ if (storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED) != null) {
+ selectedValue = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED).getStringValue();
+ } else {//insert default value
+ storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue));
+ }
+ }
+ //prepopulate the combobox with the previously stored selection
+ maximumScheduledOperationsComboBox.setDefaultValue(selectedValue);
+ DynamicForm fieldWrapper2 = new DynamicForm();
+ fieldWrapper2.setFields(maximumScheduledOperationsComboBox);
+ sheduledOperationsLayout.addMember(fieldWrapper2);
+ column.addMember(sheduledOperationsLayout);
+ form.addChild(column);
+
+ //submit handler
+ form.addSubmitValuesHandler(new SubmitValuesHandler() {
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+ //no need to insert validation here as user not allowed to enter values
+ if (form.getValue(OPERATIONS_RANGE_SCHEDULED) != null) {//if new value supplied
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(OPERATIONS_RANGE_SCHEDULED, form.getValue(OPERATIONS_RANGE_SCHEDULED)));
+ }
+ if (form.getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED) != null) {//if new value supplied
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, form
+ .getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED)));
+ }
+
+ configure(portletWindow, storedPortlet);
+
+ redraw();
+ }
+ });
+
+ return form;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+
+ return new OperationSchedulePortlet(locatorId);
+ }
+ }
+
+ /** Custom refresh operation as we cannot directly extend Table because it only
+ * contains one ListGrid while the OperationsPortlet displays two tables.
+ */
+ @Override
+ public void redraw() {
+ super.redraw();
+ //now reload the table data
+ this.scheduledOperationsGrid.invalidateCache();
+ this.scheduledOperationsGrid.markForRedraw();
+ }
+
+ public ConfigurationDefinition getConfigurationDefinition() {
+ ConfigurationDefinition definition = new ConfigurationDefinition(MSG.view_portlet_configure_definitionTitle(),
+ MSG.view_portlet_configure_definitionDesc());
+
+ definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED, MSG
+ .view_portlet_operations_config_scheduled_maximum(), true, PropertySimpleType.STRING));
+ definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, MSG
+ .view_portlet_operations_config_scheduled_enable(), true, PropertySimpleType.BOOLEAN));
+
+ return definition;
+ }
+
+ public ScheduledOperationsDataSource getDataSourceScheduled() {
+ return this.dataSourceScheduled;
+ }
+
+ public LocatableListGrid getScheduledOperationsGrid() {
+ return this.scheduledOperationsGrid;
+ }
+
+ public void startRefreshCycle() {
+ refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer);
+ }
+
+ @Override
+ protected void onDestroy() {
+ AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
+
+ super.onDestroy();
+ }
+
+ public boolean isRefreshing() {
+ return false;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
deleted file mode 100644
index 0b02c38..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ /dev/null
@@ -1,530 +0,0 @@
-package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations;
-
-/*
- * RHQ Management Platform
- * Copyright (C) 2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-import com.google.gwt.user.client.Timer;
-import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
-import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
-import com.smartgwt.client.widgets.form.fields.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
-import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
-import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.HeaderSpan;
-import com.smartgwt.client.widgets.grid.HoverCustomizer;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.layout.VStack;
-
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
-import org.rhq.core.domain.configuration.definition.PropertySimpleType;
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
-import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil;
-import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
-import org.rhq.enterprise.gui.coregui.client.operation.RecentOperationsDataSource;
-import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
-
-/**
- * A view that displays a live table of completed Operations and scheduled operations.
- *
- * @author Simeon Pinder
- */
-public class OperationsPortlet extends LocatableVLayout implements CustomSettingsPortlet, AutoRefreshPortlet {
-
- // A non-displayed, persisted identifier for the portlet
- public static final String KEY = "Operations";
- // A default displayed, persisted name for the portlet
- public static final String NAME = MSG.view_portlet_defaultName_operations();
-
- //unique field/form identifiers
- public static final String OPERATIONS_RANGE_COMPLETED_ENABLED = "operations-completed-enabled";
- public static final String OPERATIONS_RANGE_SCHEDULED_ENABLED = "operations-scheduled-enabled";
- public static final String OPERATIONS_RANGE_COMPLETED = "operations-range-completed";
- public static final String OPERATIONS_RANGE_SCHEDULED = "operations-range-scheduled";
- public static String RANGE_DISABLED_MESSAGE = MSG.view_portlet_operations_disabled();
- //TODO: change this to use the Smart GWT default value.
- public static String RANGE_DISABLED_MESSAGE_DEFAULT = MSG.common_msg_noItemsToShow();
-
- private static final String RECENT_OPERATIONS = MSG.common_title_recent_operations();
- private static final String SCHEDULED_OPERATIONS = MSG.common_title_scheduled_operations();
-
- private static final int WIDTH_RECENT_TIME = 150;
- private static final int WIDTH_RECENT_STATUS = 50;
- private static final int WIDTH_SCHEDULED_TIME = WIDTH_RECENT_TIME + WIDTH_RECENT_STATUS;
-
- // set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
-
- //ListGrids for operations
- private LocatableListGrid recentOperationsGrid = null;
- private LocatableListGrid scheduledOperationsGrid = null;
-
- private RecentOperationsDataSource dataSourceCompleted;
- private ScheduledOperationsDataSource dataSourceScheduled;
- public static String unlimited = MSG.common_label_unlimited();
- public static String defaultValue = "5";
- public static boolean defaultEnabled = true;
-
- private Timer refreshTimer;
-
- //default no-args constructor for serialization.
- private OperationsPortlet() {
- super("(unitialized)");
- }
-
- public OperationsPortlet(String locatorId) {
- super(locatorId);
- this.dataSourceCompleted = new RecentOperationsDataSource(this);
- this.dataSourceScheduled = new ScheduledOperationsDataSource(this);
- }
-
- @Override
- protected void onInit() {
- super.onInit();
-
- this.recentOperationsGrid = new LocatableListGrid(RECENT_OPERATIONS);
- recentOperationsGrid.setDataSource(getDataSourceCompleted());
- recentOperationsGrid.setAutoFetchData(true);
- recentOperationsGrid.setTitle(RECENT_OPERATIONS);
- recentOperationsGrid.setWidth100();
- //defining header span
- String[] completedRows = new String[] { //
- RecentOperationsDataSource.Field.RESOURCE.propertyName(), //
- AncestryUtil.RESOURCE_ANCESTRY, //
- RecentOperationsDataSource.Field.OPERATION.propertyName(), //
- RecentOperationsDataSource.Field.TIME.propertyName(), //
- RecentOperationsDataSource.Field.STATUS.propertyName() };
- recentOperationsGrid.setHeaderSpans(new HeaderSpan(RECENT_OPERATIONS, completedRows));
- recentOperationsGrid.setHeaderSpanHeight(20);
- recentOperationsGrid.setHeaderHeight(40);
- //recentOperationsGrid.setResizeFieldsInRealTime(true);
- recentOperationsGrid.setWrapCells(true);
- addMember(recentOperationsGrid);
-
- // Add the list table as the top half of the view.
- this.scheduledOperationsGrid = new LocatableListGrid(SCHEDULED_OPERATIONS);
- scheduledOperationsGrid.setDataSource(getDataSourceScheduled());
- scheduledOperationsGrid.setAutoFetchData(true);
- scheduledOperationsGrid.setTitle(SCHEDULED_OPERATIONS);
- scheduledOperationsGrid.setWidth100();
- String[] scheduledRows = new String[] { //
- ScheduledOperationsDataSource.Field.RESOURCE.propertyName(), //
- AncestryUtil.RESOURCE_ANCESTRY, //
- ScheduledOperationsDataSource.Field.OPERATION.propertyName(), //
- ScheduledOperationsDataSource.Field.TIME.propertyName() };
- scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(SCHEDULED_OPERATIONS, scheduledRows));
- scheduledOperationsGrid.setHeaderSpanHeight(20);
- scheduledOperationsGrid.setHeaderHeight(40);
-
- scheduledOperationsGrid.setTitle(SCHEDULED_OPERATIONS);
- //scheduledOperationsGrid.setResizeFieldsInRealTime(true);
- scheduledOperationsGrid.setWrapCells(true);
-
- addMember(scheduledOperationsGrid);
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
-
- ListGridField resourceRecent = new ListGridField(RecentOperationsDataSource.Field.RESOURCE.propertyName(),
- RecentOperationsDataSource.Field.RESOURCE.title());
- resourceRecent.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
- return SeleniumUtility.getLocatableHref(url, o.toString(), null);
- }
- });
- resourceRecent.setShowHover(true);
- resourceRecent.setHoverCustomizer(new HoverCustomizer() {
- public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
- }
- });
-
- ListGridField ancestryRecent = AncestryUtil.setupAncestryListGridField();
-
- ListGridField operationRecent = new ListGridField(RecentOperationsDataSource.Field.OPERATION.propertyName(),
- RecentOperationsDataSource.Field.OPERATION.title());
-
- ListGridField timeRecent = new ListGridField(RecentOperationsDataSource.Field.TIME.propertyName(),
- RecentOperationsDataSource.Field.TIME.title(), WIDTH_RECENT_TIME);
- TimestampCellFormatter.prepareDateField(timeRecent);
-
- ListGridField statusRecent = new ListGridField(RecentOperationsDataSource.Field.STATUS.propertyName(),
- RecentOperationsDataSource.Field.STATUS.title(), WIDTH_RECENT_STATUS);
- statusRecent.setAlign(Alignment.CENTER);
-
- recentOperationsGrid.setFields(resourceRecent, ancestryRecent, operationRecent, timeRecent, statusRecent);
-
- ListGridField resourceNext = new ListGridField(ScheduledOperationsDataSource.Field.RESOURCE.propertyName(),
- ScheduledOperationsDataSource.Field.RESOURCE.title());
- resourceNext.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
- return SeleniumUtility.getLocatableHref(url, o.toString(), null);
- }
- });
- resourceNext.setShowHover(true);
- resourceNext.setHoverCustomizer(new HoverCustomizer() {
- public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
- }
- });
-
- ListGridField ancestryNext = AncestryUtil.setupAncestryListGridField();
-
- ListGridField operationNext = new ListGridField(ScheduledOperationsDataSource.Field.OPERATION.propertyName(),
- ScheduledOperationsDataSource.Field.OPERATION.title());
-
- ListGridField timeNext = new ListGridField(ScheduledOperationsDataSource.Field.TIME.propertyName(),
- ScheduledOperationsDataSource.Field.TIME.title(), WIDTH_SCHEDULED_TIME);
- TimestampCellFormatter.prepareDateField(timeNext);
-
- scheduledOperationsGrid.setFields(resourceNext, ancestryNext, operationNext, timeNext);
- }
-
- @Override
- public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
-
- if (null == this.portletWindow && null != portletWindow) {
- this.portletWindow = portletWindow;
- }
-
- if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
- return;
- }
-
- //Operation range property - retrieve existing value
- PropertySimple property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED);
- if ((property != null) && (property.getStringValue() != null)) {
- //retrieve and translate to int
- String retrieved = property.getStringValue();
- if (unlimited.equals(retrieved)) {
- getDataSourceCompleted().setOperationsRangeCompleted(-1);
- } else {
- getDataSourceCompleted().setOperationsRangeCompleted(Integer.parseInt(retrieved));
- }
- } else {//create setting
- storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_COMPLETED, defaultValue));
- getDataSourceCompleted().setOperationsRangeCompleted(-1);
- }
-
- property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED);
- if ((property != null) && (property.getStringValue() != null)) {
- //retrieve and translate to int
- String retrieved = property.getStringValue();
- if (unlimited.equals(retrieved)) {
- getDataSourceScheduled().setOperationsRangeScheduled(-1);
- } else {
- getDataSourceScheduled().setOperationsRangeScheduled(Integer.parseInt(retrieved));
- }
- } else {//create setting
- storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue));
- getDataSourceScheduled().setOperationsRangeScheduled(-1);
- }
- //Checkbox settings property
- property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
- if ((property != null) && (property.getBooleanValue() != null)) {
- getDataSourceScheduled().setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue());
- } else {//create setting
- storedPortlet.getConfiguration()
- .put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, defaultEnabled));
- getDataSourceScheduled().setOperationsRangeScheduleEnabled(defaultEnabled);
- }
- property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED_ENABLED);
- if ((property != null) && (property.getBooleanValue() != null)) {
- getDataSourceCompleted().setOperationsRangeCompleteEnabled(property.getBooleanValue().booleanValue());
- } else {//create setting
- storedPortlet.getConfiguration()
- .put(new PropertySimple(OPERATIONS_RANGE_COMPLETED_ENABLED, defaultEnabled));
- getDataSourceCompleted().setOperationsRangeCompleteEnabled(defaultEnabled);
- }
- }
-
- @Override
- public Canvas getHelpCanvas() {
- return new HTMLFlow(MSG.view_portlet_help_operations());
- }
-
- /** Constructs the dynamic form instance using 1 column and multiple row layouts.
- */
- public DynamicForm getCustomSettingsForm() {
-
- //root dynamic form instance
- final LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("custom-settings"));
-
- final DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
-
- //vertical layout
- VStack column = new VStack();
-
- //label
- LocatableLabel operationRange = new LocatableLabel(extendLocatorId("operation-range"), MSG
- .common_title_operations_range());
- column.addMember(operationRange);
-
- //horizontal layout
- LocatableHLayout row = new LocatableHLayout(extendLocatorId("enable.completed.operations"));
-
- //checkbox indicating whether to apply completed operations grouping settings
- final CheckboxItem enableCompletedOperationsGrouping = new CheckboxItem();
- enableCompletedOperationsGrouping.setName(OPERATIONS_RANGE_COMPLETED_ENABLED);
- enableCompletedOperationsGrouping.setTitle(" " + MSG.view_portlet_operations_config_show_last() + " ");
- //add change listener
- enableCompletedOperationsGrouping.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- String selectedItem = "" + event.getValue();
- //stuff into the master form for retrieval
- form.setValue(OPERATIONS_RANGE_COMPLETED_ENABLED, selectedItem);
- }
- });
- //retrieve previous value otherwise initialize to true(live unlimited list)
- PropertySimple retrieved = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED_ENABLED);
- if (retrieved != null) {
- enableCompletedOperationsGrouping.setValue(retrieved.getBooleanValue());
- } else {//default
- enableCompletedOperationsGrouping.setValue(true);
- }
-
- //wrap field item in dynamicform for addition as a field item
- DynamicForm item = new DynamicForm();
- item.setFields(enableCompletedOperationsGrouping);
- row.addMember(item);
-
- //-------------combobox for number of completed scheduled ops to display on the dashboard
- final SelectItem maximumCompletedOperationsComboBox = new SelectItem(OPERATIONS_RANGE_COMPLETED);
- maximumCompletedOperationsComboBox.setTitle("");
- maximumCompletedOperationsComboBox.setHint("<nobr><b> " + MSG.view_portlet_operations_config_completed()
- + ".</b></nobr>");
- //spinder: required to disable editability
- maximumCompletedOperationsComboBox.setType("selection");
- //define acceptable values for display amount
- String[] acceptableDisplayValues = { "1", "5", "10", "15", unlimited };
- maximumCompletedOperationsComboBox.setValueMap(acceptableDisplayValues);
- //set width of dropdown display region
- maximumCompletedOperationsComboBox.setWidth(100);
- maximumCompletedOperationsComboBox.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- String selectedItem = "" + event.getValue();
- //stuff into the master form for retrieval
- form.setValue(OPERATIONS_RANGE_COMPLETED, selectedItem);
- }
- });
-
- //default selected value to 'unlimited'(live lists) and check both combobox settings here.
- String selectedValue = defaultValue;
- if (storedPortlet != null) {
- //if property exists retrieve it
- if (storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED) != null) {
- selectedValue = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED).getStringValue();
- } else {//insert default value
- storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_COMPLETED, defaultValue));
- }
- }
- //prepopulate the combobox with the previously stored selection
- maximumCompletedOperationsComboBox.setDefaultValue(selectedValue);
- DynamicForm item2 = new DynamicForm();
- item2.setFields(maximumCompletedOperationsComboBox);
- row.addMember(item2);
-
- //horizontal layout
- LocatableHLayout sheduledOperationsLayout = new LocatableHLayout(extendLocatorId("enable.scheduled.operations"));
-
- final CheckboxItem enableScheduledOperationsGrouping = new CheckboxItem();
- enableScheduledOperationsGrouping.setName(OPERATIONS_RANGE_SCHEDULED_ENABLED);
- enableScheduledOperationsGrouping.setTitle(" " + MSG.view_portlet_operations_config_show_next() + " ");
- enableScheduledOperationsGrouping.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- String selectedItem = "" + event.getValue();
- //stuff into the master form for retrieval
- form.setValue(OPERATIONS_RANGE_SCHEDULED_ENABLED, selectedItem);
- }
- });
-
- //wrap field item in dynamicform for addition
- DynamicForm fieldWrapper = new DynamicForm();
- fieldWrapper.setFields(enableScheduledOperationsGrouping);
- sheduledOperationsLayout.addMember(fieldWrapper);
-
- //retrieve previous value otherwise initialize to true(live unlimited list)
- retrieved = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
- if (retrieved != null) {
- enableScheduledOperationsGrouping.setValue(retrieved.getBooleanValue());
- } else {
- enableScheduledOperationsGrouping.setValue(true);
- }
-
- //------------- Build second combobox for timeframe for problem resources search.
- final SelectItem maximumScheduledOperationsComboBox = new SelectItem(OPERATIONS_RANGE_SCHEDULED);
- maximumScheduledOperationsComboBox.setTitle("");
- maximumScheduledOperationsComboBox.setHint("<nobr><b> " + MSG.common_label_scheduled_operations()
- + ".</b></nobr>");
- maximumScheduledOperationsComboBox.setType("selection");
- maximumScheduledOperationsComboBox.setValueMap(acceptableDisplayValues);
- maximumScheduledOperationsComboBox.setWidth(100);
- maximumScheduledOperationsComboBox.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- String selectedItem = "" + event.getValue();
- //stuff into the master form for retrieval
- form.setValue(OPERATIONS_RANGE_SCHEDULED, selectedItem);
- }
- });
-
- //set to default
- selectedValue = defaultValue;
- if (storedPortlet != null) {
- //if property exists retrieve it
- if (storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED) != null) {
- selectedValue = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED).getStringValue();
- } else {//insert default value
- storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue));
- }
- }
- //prepopulate the combobox with the previously stored selection
- maximumScheduledOperationsComboBox.setDefaultValue(selectedValue);
- DynamicForm fieldWrapper2 = new DynamicForm();
- fieldWrapper2.setFields(maximumScheduledOperationsComboBox);
- sheduledOperationsLayout.addMember(fieldWrapper2);
- column.addMember(row);
- column.addMember(sheduledOperationsLayout);
- form.addChild(column);
-
- //submit handler
- form.addSubmitValuesHandler(new SubmitValuesHandler() {
- @Override
- public void onSubmitValues(SubmitValuesEvent event) {
- //no need to insert validation here as user not allowed to enter values
- if (form.getValue(OPERATIONS_RANGE_SCHEDULED) != null) {//if new value supplied
- storedPortlet.getConfiguration().put(
- new PropertySimple(OPERATIONS_RANGE_SCHEDULED, form.getValue(OPERATIONS_RANGE_SCHEDULED)));
- }
- if (form.getValue(OPERATIONS_RANGE_COMPLETED) != null) {//if new value supplied
- storedPortlet.getConfiguration().put(
- new PropertySimple(OPERATIONS_RANGE_COMPLETED, form.getValue(OPERATIONS_RANGE_COMPLETED)));
- }
- if (form.getValue(OPERATIONS_RANGE_COMPLETED_ENABLED) != null) {//if new value supplied
- storedPortlet.getConfiguration().put(
- new PropertySimple(OPERATIONS_RANGE_COMPLETED_ENABLED, form
- .getValue(OPERATIONS_RANGE_COMPLETED_ENABLED)));
- }
- if (form.getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED) != null) {//if new value supplied
- storedPortlet.getConfiguration().put(
- new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, form
- .getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED)));
- }
-
- configure(portletWindow, storedPortlet);
-
- redraw();
- }
- });
-
- return form;
- }
-
- public static final class Factory implements PortletViewFactory {
- public static PortletViewFactory INSTANCE = new Factory();
-
- public final Portlet getInstance(String locatorId) {
-
- return new OperationsPortlet(locatorId);
- }
- }
-
- /** Custom refresh operation as we cannot directly extend Table because it only
- * contains one ListGrid while the OperationsPortlet displays two tables.
- */
- @Override
- public void redraw() {
- super.redraw();
- //now reload the table data
- this.recentOperationsGrid.invalidateCache();
- this.recentOperationsGrid.markForRedraw();
- this.scheduledOperationsGrid.invalidateCache();
- this.scheduledOperationsGrid.markForRedraw();
- }
-
- public ConfigurationDefinition getConfigurationDefinition() {
- ConfigurationDefinition definition = new ConfigurationDefinition(MSG.view_portlet_configure_definitionTitle(),
- MSG.view_portlet_configure_definitionDesc());
-
- definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_COMPLETED, MSG
- .view_portlet_operations_config_completed_maximum(), true, PropertySimpleType.STRING));
- definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED, MSG
- .view_portlet_operations_config_scheduled_maximum(), true, PropertySimpleType.STRING));
- definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_COMPLETED_ENABLED, MSG
- .view_portlet_operations_config_completed_enable(), true, PropertySimpleType.BOOLEAN));
- definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, MSG
- .view_portlet_operations_config_scheduled_enable(), true, PropertySimpleType.BOOLEAN));
-
- return definition;
- }
-
- public RecentOperationsDataSource getDataSourceCompleted() {
- return this.dataSourceCompleted;
- }
-
- public ScheduledOperationsDataSource getDataSourceScheduled() {
- return this.dataSourceScheduled;
- }
-
- public LocatableListGrid getCompletedOperationsGrid() {
- return this.recentOperationsGrid;
- }
-
- public LocatableListGrid getScheduledOperationsGrid() {
- return this.scheduledOperationsGrid;
- }
-
- public void startRefreshCycle() {
- refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer);
- }
-
- @Override
- protected void onDestroy() {
- AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
-
- super.onDestroy();
- }
-
- public boolean isRefreshing() {
- return false;
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
index 9ca8f5c..7862175 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
@@ -18,370 +18,45 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource;
-import java.util.ArrayList;
-
-import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.History;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
-import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.ResourceCriteria;
-import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
-import org.rhq.core.domain.operation.OperationRequestStatus;
-import org.rhq.core.domain.operation.ResourceOperationHistory;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.core.domain.util.PageControl;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDetailsView;
-import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.AbstractOperationHistoryPortlet;
/**
* @author Simeon Pinder
+ * @author Jay Shaughnessy
*/
-public class ResourceOperationsPortlet extends GroupOperationsPortlet {
+public class ResourceOperationsPortlet extends AbstractOperationHistoryPortlet {
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "ResourceOperations";
// A default displayed, persisted name for the portlet
public static final String NAME = MSG.view_portlet_defaultName_resource_operations();
- private int resourceId;
- private ResourceComposite resourceComposite;
- private ResourceOperationsCriteriaHistoryListView resourceOperations;
-
- public ResourceOperationsPortlet(String locatorId) {
- super(locatorId);
- this.locatorId = locatorId;
- //figure out which page we're loading
- String currentPage = History.getToken();
- String[] elements = currentPage.split("/");
- this.resourceId = Integer.valueOf(elements[1]);
- //populate basepath
- baseViewPath = elements[0];
- }
-
- @Override
- protected void onInit() {
- setCurrentlyRefreshing(true);
- initializeUi();
- loadData();
- }
-
- @Override
- public void redraw() {
- loadData();
- }
-
- @Override
- public DynamicForm getCustomSettingsForm() {
- LocatableDynamicForm customSettings = new LocatableDynamicForm(extendLocatorId("customSettings"));
- LocatableVLayout page = new LocatableVLayout(customSettings.extendLocatorId("page"));
- //build editor form container
- final LocatableDynamicForm form = new LocatableDynamicForm(page.extendLocatorId("alert-filter"));
- form.setMargin(5);
-
- //add label about what configuration affects? redundant?
- //add filter operation status type selector
- final SelectItem operationStatusSelector = PortletConfigurationEditorComponent
- .getOperationStatusEditor(portletConfig);
- // //add sort priority selector
- // final SelectItem resultSortSelector = PortletConfigurationEditorComponent
- // .getResulSortOrderEditor(portletConfig);
- //add result count selector
- final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
-
- //add range selector
- final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent
- .getMeasurementRangeEditor(portletConfig);
-
- form.setItems(operationStatusSelector, resultCountSelector);
-
- //submit handler
- customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
-
- @Override
- public void onSubmitValues(SubmitValuesEvent event) {
-
- //result count
- portletConfig = AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
-
- //time range configuration
- portletConfig = AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
- portletConfig);
-
- //operation priority
- portletConfig = AbstractActivityView.saveOperationStatusSelectorSettings(operationStatusSelector,
- portletConfig);
-
- //persist and reload portlet
- storedPortlet.setConfiguration(portletConfig);
- configure(portletWindow, storedPortlet);
- //resynch the config object in the datasource
- resourceOperations.setDatasource(new ResourceOperationsCriteriaDataSource(portletConfig));
- //apply latest settings to the visible result set
- redraw();
- }
- });
- form.markForRedraw();
- page.addMember(measurementRangeEditor);
- page.addMember(form);
- customSettings.addChild(page);
- return customSettings;
- }
-
- private void loadData() {
- //populate composite data
- ResourceCriteria criteria = new ResourceCriteria();
- criteria.addFilterId(this.resourceId);
-
- criteria.fetchOperationHistories(false);
-
- //locate the resource
- GWTServiceLookup.getResourceService().findResourceCompositesByCriteria(criteria,
- new AsyncCallback<PageList<ResourceComposite>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving resource composite for resource [" + resourceId + "]:"
- + caught.getMessage());
- setCurrentlyRefreshing(false);
- }
-
- @Override
- public void onSuccess(PageList<ResourceComposite> results) {
- if (!results.isEmpty()) {
- resourceComposite = results.get(0);
- //instantiate view
- //populated GWT criteria objects
- Criteria criteria = new Criteria(ResourceOperationHistoryDataSource.CriteriaField.RESOURCE_ID,
- String.valueOf(resourceComposite.getResource().getId()));
-
- resourceOperations = new ResourceOperationsCriteriaHistoryListView(locatorId,
- new ResourceOperationsCriteriaDataSource(portletConfig), null, criteria, resourceComposite);
-
- //cleanup
- for (Canvas child : recentOperationsContent.getChildren()) {
- child.destroy();
- }
- recentOperationsContent.addChild(resourceOperations);
- recentOperationsContent.markForRedraw();
- }
- setCurrentlyRefreshing(false);
- }
- });
+ public ResourceOperationsPortlet(String locatorId, int resourceId) {
+ super(locatorId, EntityContext.forResource(resourceId));
}
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
+ /* (non-Javadoc)
+ * TODO: This factory ASSUMES the user is currently navigated to a resource detail view, and generates a portlet
+ * for that resource. It will fail in other scenarios. This mechanism should be improved such that the
+ * factory method can take an EntityContext explicitly indicating, in this case, the resource.
+ * @see org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory#getInstance(java.lang.String)
+ */
public final Portlet getInstance(String locatorId) {
- return new ResourceOperationsPortlet(locatorId);
- }
- }
-}
-
-/** Provide implementation of ResourceOperationsHistoryListView using datasource
- * that customizes fetch based on Configuration parameters.
- *
- * @author spinder
- */
-class ResourceOperationsCriteriaHistoryListView extends
- AbstractOperationHistoryListView<ResourceOperationsCriteriaDataSource> {
-
- private ResourceOperationsCriteriaDataSource datasource;
-
- public ResourceOperationsCriteriaHistoryListView(String locatorId, ResourceOperationsCriteriaDataSource dataSource,
- String title, Criteria criteria, ResourceComposite composite) {
- super(locatorId, dataSource, title, criteria);
- this.datasource = dataSource;
- this.resourceComposite = composite;
- setShowFooterRefresh(false); //disable footer refresh
- }
-
- private ResourceComposite resourceComposite;
-
- @Override
- protected boolean hasControlPermission() {
- return this.resourceComposite.getResourcePermission().isControl();
- }
-
- @Override
- public Canvas getDetailsView(int id) {
- return new ResourceOperationHistoryDetailsView(extendLocatorId("DetailsView"), this.resourceComposite);
- }
-
- public ResourceOperationsCriteriaDataSource getDatasource() {
- return datasource;
- }
- public void setDatasource(ResourceOperationsCriteriaDataSource datasource) {
- this.datasource = datasource;
- }
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ int resourceId = Integer.valueOf(elements[1]);
- @Override
- protected void refreshTableInfo() {
- super.refreshTableInfo();
- if (getTableInfo() != null) {
- int count = getListGrid().getSelection().length;
- getTableInfo().setContents(
- MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
+ return new ResourceOperationsPortlet(locatorId, resourceId);
}
- }
-
- @Override
- protected String getBasePath() {
- return "Resource/" + resourceComposite.getResource().getId() + "/Operations/History";
- }
- @Override
- protected void onInit() {
- super.onInit();
- getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
- }
-}
-
-/** Provide implementation of ResourceOperationHistoryDataSource that dynamically
- * configures fetch requests for this table view.
- *
- * @author spinder
- */
-class ResourceOperationsCriteriaDataSource extends ResourceOperationHistoryDataSource {
-
- public ResourceOperationsCriteriaDataSource(Configuration portletConfig) {
- this.portletConfig = portletConfig;
- }
-
- private Configuration portletConfig;
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response,
- final ResourceOperationHistoryCriteria criteria) {
- operationService.findResourceOperationHistoriesByCriteria(criteria,
- new AsyncCallback<PageList<ResourceOperationHistory>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.dataSource_operationHistory_error_fetchFailure(), caught);
- }
-
- public void onSuccess(PageList<ResourceOperationHistory> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- protected ResourceOperationHistoryCriteria getFetchCriteria(final DSRequest request) {
- ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
-
- if (request.getCriteria().getValues().containsKey(CriteriaField.RESOURCE_ID)) {
- int resourceId = Integer
- .parseInt((String) request.getCriteria().getValues().get(CriteriaField.RESOURCE_ID));
- Integer[] resourceIds = new Integer[1];
- resourceIds[0] = resourceId;
- criteria.addFilterResourceIds(resourceIds);
- }
-
- //initialize to only five for quick queries.
- PageControl pageControl = new PageControl(0, 5);//default to displaying five
- //customize query with latest configuration selections
-
- //retrieve previous settings from portlet config
- if (portletConfig != null) {
- // //result sort order
- // PropertySimple property = portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
- // if (property != null) {
- // String currentSetting = property.getStringValue();
- // if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
- // criteria.addSortStatus(PageOrdering.DESC);
- // } else {
- // criteria.addSortStatus(PageOrdering.ASC);
- // }
- // }
- //result timeframe if enabled
- PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
- if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
-
- boolean isAdvanced = false;
- //detect type of widget[Simple|Advanced]
- property = portletConfig.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
- if (property != null) {
- isAdvanced = property.getBooleanValue();
- }
- if (isAdvanced) {
- //Advanced time settings
- property = portletConfig.getSimple(Constant.METRIC_RANGE);
- if (property != null) {
- String currentSetting = property.getStringValue();
- String[] range = currentSetting.split(",");
- criteria.addFilterStartTime(Long.valueOf(range[0]));
- criteria.addFilterEndTime(Long.valueOf(range[1]));
- }
- } else {
- //Simple time settings
- property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
- if (property != null) {
- int lastN = property.getIntegerValue();
- property = portletConfig.getSimple(Constant.METRIC_RANGE_UNIT);
- int lastUnits = property.getIntegerValue();
- ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, Integer
- .valueOf(lastUnits));
- criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0)));
- criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1)));
- }
- }
- }
-
- //result count
- property = portletConfig.getSimple(Constant.RESULT_COUNT);
- if (property != null) {
- String currentSetting = property.getStringValue();
- if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) {
- pageControl.setPageSize(5);
- } else {
- pageControl = new PageControl(0, Integer.valueOf(currentSetting));
- }
- }
- criteria.setPageControl(pageControl);
-
- //detect operation status filter
- property = portletConfig.getSimple(Constant.OPERATION_STATUS);
- if (property != null) {
- String currentSetting = property.getStringValue();
- String[] parsedValues = currentSetting.trim().split(",");
- if (currentSetting.trim().isEmpty() || parsedValues.length == OperationRequestStatus.values().length) {
- //all operation stati assumed
- } else {
- OperationRequestStatus[] operationStati = new OperationRequestStatus[parsedValues.length];
- int indx = 0;
- for (String priority : parsedValues) {
- OperationRequestStatus s = OperationRequestStatus.valueOf(priority);
- operationStati[indx++] = s;
- }
- criteria.addFilterStatuses(operationStati);
- }
- }
- }
- return criteria;
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
index 118cec2..0cb1411 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
@@ -40,9 +40,9 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
-
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.VLayout;
+
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
@@ -69,7 +69,8 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*
* @author Ian Springer
*/
-public abstract class AbstractOperationScheduleDetailsView extends AbstractRecordEditor<AbstractOperationScheduleDataSource> {
+public abstract class AbstractOperationScheduleDetailsView extends
+ AbstractRecordEditor<AbstractOperationScheduleDataSource> {
private static final String FIELD_OPERATION_DESCRIPTION = "operationDescription";
private static final String FIELD_OPERATION_PARAMETERS = "operationParameters";
@@ -78,8 +79,7 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
private Map<Integer, String> operationIdToNameMap = new HashMap<Integer, String>();
private Map<String, String> operationNameToDescriptionMap = new HashMap<String, String>();
- private Map<String, ConfigurationDefinition> operationNameToParametersDefinitionMap =
- new HashMap<String, ConfigurationDefinition>();
+ private Map<String, ConfigurationDefinition> operationNameToParametersDefinitionMap = new HashMap<String, ConfigurationDefinition>();
private StaticTextItem operationDescriptionItem;
private StaticTextItem operationParametersItem;
private LocatableHLayout operationParametersConfigurationHolder;
@@ -89,15 +89,15 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
private Integer operationDefinitionId;
public AbstractOperationScheduleDetailsView(String locatorId, AbstractOperationScheduleDataSource dataSource,
- ResourceType resourceType, int scheduleId) {
+ ResourceType resourceType, int scheduleId) {
super(locatorId, dataSource, scheduleId, MSG.view_operationScheduleDetails_operationSchedule(), null);
Set<OperationDefinition> operationDefinitions = resourceType.getOperationDefinitions();
for (OperationDefinition operationDefinition : operationDefinitions) {
this.operationIdToNameMap.put(operationDefinition.getId(), operationDefinition.getName());
this.operationNameToDescriptionMap.put(operationDefinition.getName(), operationDefinition.getDescription());
- this.operationNameToParametersDefinitionMap.put(operationDefinition.getName(),
- operationDefinition.getParametersConfigurationDefinition());
+ this.operationNameToParametersDefinitionMap.put(operationDefinition.getName(), operationDefinition
+ .getParametersConfigurationDefinition());
}
}
@@ -146,13 +146,13 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
}
});
- this.operationDescriptionItem = new StaticTextItem(FIELD_OPERATION_DESCRIPTION,
- MSG.view_operationScheduleDetails_field_description());
+ this.operationDescriptionItem = new StaticTextItem(FIELD_OPERATION_DESCRIPTION, MSG
+ .view_operationScheduleDetails_field_description());
this.operationDescriptionItem.setShowTitle(false);
items.add(this.operationDescriptionItem);
- this.operationParametersItem = new StaticTextItem(FIELD_OPERATION_PARAMETERS,
- MSG.view_operationScheduleDetails_field_parameters());
+ this.operationParametersItem = new StaticTextItem(FIELD_OPERATION_PARAMETERS, MSG
+ .view_operationScheduleDetails_field_parameters());
this.operationParametersItem.setColSpan(2);
items.add(this.operationParametersItem);
@@ -190,20 +190,20 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
supportedUnits.add(TimeUnit.SECONDS);
supportedUnits.add(TimeUnit.MINUTES);
supportedUnits.add(TimeUnit.HOURS);
- DurationItem timeoutItem = new DurationItem(AbstractOperationScheduleDataSource.Field.TIMEOUT,
- MSG.view_operationScheduleDetails_field_timeout(),
- supportedUnits, false, isReadOnly(), this.notesForm);
+ DurationItem timeoutItem = new DurationItem(AbstractOperationScheduleDataSource.Field.TIMEOUT, MSG
+ .view_operationScheduleDetails_field_timeout(), supportedUnits, false, isReadOnly(), this.notesForm);
timeoutItem.setContextualHelp(MSG.view_operationScheduleDetails_fieldHelp_timeout());
notesFields.add(timeoutItem);
if (!isNewRecord()) {
- StaticTextItem nextFireTimeItem = new StaticTextItem(AbstractOperationScheduleDataSource.Field.NEXT_FIRE_TIME,
- MSG.dataSource_operationSchedule_field_nextFireTime());
+ StaticTextItem nextFireTimeItem = new StaticTextItem(
+ AbstractOperationScheduleDataSource.Field.NEXT_FIRE_TIME, MSG
+ .dataSource_operationSchedule_field_nextFireTime());
notesFields.add(nextFireTimeItem);
}
- TextAreaItem notesItem = new TextAreaItem(ResourceOperationScheduleDataSource.Field.DESCRIPTION,
- MSG.dataSource_operationSchedule_field_description());
+ TextAreaItem notesItem = new TextAreaItem(ResourceOperationScheduleDataSource.Field.DESCRIPTION, MSG
+ .dataSource_operationSchedule_field_description());
notesItem.setWidth(450);
notesItem.setHeight(60);
notesItem.setShowTitle(true);
@@ -220,7 +220,11 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
@Override
protected ButtonBar buildButtonBar() {
ButtonBar buttonBar = super.buildButtonBar();
- buttonBar.getSaveButton().setTitle(MSG.common_button_schedule());
+
+ if (null != buttonBar) {
+ buttonBar.getSaveButton().setTitle(MSG.common_button_schedule());
+ }
+
return buttonBar;
}
@@ -239,8 +243,8 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
}
Subject sessionSubject = UserSessionManager.getSessionSubject();
- AbstractOperationScheduleDataSource.SubjectRecord subjectRecord =
- new AbstractOperationScheduleDataSource.SubjectRecord(sessionSubject);
+ AbstractOperationScheduleDataSource.SubjectRecord subjectRecord = new AbstractOperationScheduleDataSource.SubjectRecord(
+ sessionSubject);
record.setAttribute(ResourceOperationScheduleDataSource.Field.SUBJECT, subjectRecord);
return record;
@@ -256,26 +260,29 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
@Override
protected void editExistingRecord(Record record) {
- JavaScriptObject jobTriggerJavaScriptObject =
- (JavaScriptObject) getForm().getValue(AbstractOperationScheduleDataSource.Field.JOB_TRIGGER);
- Record jobTriggerRecord = new ListGridRecord(jobTriggerJavaScriptObject);
+ JavaScriptObject jobTriggerJavaScriptObject = (JavaScriptObject) getForm().getValue(
+ AbstractOperationScheduleDataSource.Field.JOB_TRIGGER);
+ Record jobTriggerRecord = new ListGridRecord(jobTriggerJavaScriptObject);
JobTrigger jobTrigger = getDataSource().createJobTrigger(jobTriggerRecord);
this.triggerEditor.setJobTrigger(jobTrigger);
FormItem nextFireTimeItem = this.notesForm.getField(AbstractOperationScheduleDataSource.Field.NEXT_FIRE_TIME);
nextFireTimeItem.setValue(getForm().getValue(AbstractOperationScheduleDataSource.Field.NEXT_FIRE_TIME));
- DurationItem timeoutItem = (DurationItem) this.notesForm.getField(AbstractOperationScheduleDataSource.Field.TIMEOUT);
+ DurationItem timeoutItem = (DurationItem) this.notesForm
+ .getField(AbstractOperationScheduleDataSource.Field.TIMEOUT);
Object value = getForm().getValue(AbstractOperationScheduleDataSource.Field.TIMEOUT);
Integer integerValue = TypeConversionUtility.toInteger(value);
timeoutItem.setValue(integerValue, UnitType.TIME);
- StaticTextItem notesItem = (StaticTextItem) this.notesForm.getField(AbstractOperationScheduleDataSource.Field.DESCRIPTION);
+ StaticTextItem notesItem = (StaticTextItem) this.notesForm
+ .getField(AbstractOperationScheduleDataSource.Field.DESCRIPTION);
// Notes field is user-editable, so escape HTML to prevent an XSS attack.
notesItem.setOutputAsHTML(true);
notesItem.setValue(getForm().getValue(AbstractOperationScheduleDataSource.Field.DESCRIPTION));
- this.parameters = (Configuration) record.getAttributeAsObject(AbstractOperationScheduleDataSource.Field.PARAMETERS);
+ this.parameters = (Configuration) record
+ .getAttributeAsObject(AbstractOperationScheduleDataSource.Field.PARAMETERS);
super.editExistingRecord(record);
}
@@ -309,16 +316,17 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
form.setValue(AbstractOperationScheduleDataSource.Field.JOB_TRIGGER, jobTriggerRecord);
- DurationItem timeoutItem = (DurationItem)this.notesForm.getItem(AbstractOperationScheduleDataSource.Field.TIMEOUT);
+ DurationItem timeoutItem = (DurationItem) this.notesForm
+ .getItem(AbstractOperationScheduleDataSource.Field.TIMEOUT);
Long timeout = timeoutItem.getValueAsLong();
if (timeout != null) {
form.setValue(AbstractOperationScheduleDataSource.Field.TIMEOUT, timeout);
} else {
- form.setValue(AbstractOperationScheduleDataSource.Field.TIMEOUT, (String)null);
+ form.setValue(AbstractOperationScheduleDataSource.Field.TIMEOUT, (String) null);
}
FormItem notesItem = this.notesForm.getField(AbstractOperationScheduleDataSource.Field.DESCRIPTION);
- form.setValue(AbstractOperationScheduleDataSource.Field.DESCRIPTION, (String)notesItem.getValue());
+ form.setValue(AbstractOperationScheduleDataSource.Field.DESCRIPTION, (String) notesItem.getValue());
super.save(requestProperties);
}
@@ -340,7 +348,8 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
if (operationName == null) {
value = "<i>" + MSG.view_operationScheduleDetails_fieldDefault_parameters() + "</i>";
} else {
- ConfigurationDefinition parametersDefinition = this.operationNameToParametersDefinitionMap.get(operationName);
+ ConfigurationDefinition parametersDefinition = this.operationNameToParametersDefinitionMap
+ .get(operationName);
if (parametersDefinition == null || parametersDefinition.getPropertyDefinitions().isEmpty()) {
value = "<i>" + MSG.view_operationScheduleDetails_noParameters() + "</i>";
@@ -361,13 +370,13 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
this.operationParametersConfigurationHolder.addMember(horizontalSpacer);
if (isNewRecord()) {
- this.parameters = (parametersDefinition.getDefaultTemplate() != null) ?
- parametersDefinition.getDefaultTemplate().createConfiguration() : new Configuration();
+ this.parameters = (parametersDefinition.getDefaultTemplate() != null) ? parametersDefinition
+ .getDefaultTemplate().createConfiguration() : new Configuration();
} else {
}
- ConfigurationEditor configurationEditor = new ConfigurationEditor("ParametersEditor", parametersDefinition,
- this.parameters);
+ ConfigurationEditor configurationEditor = new ConfigurationEditor("ParametersEditor",
+ parametersDefinition, this.parameters);
configurationEditor.setReadOnly(isReadOnly());
this.operationParametersConfigurationHolder.addMember(configurationEditor);
this.operationParametersConfigurationHolder.show();
@@ -378,7 +387,7 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
private String getSelectedOperationName() {
FormItem operationNameItem = getForm().getField(AbstractOperationScheduleDataSource.Field.OPERATION_NAME);
- return (String)operationNameItem.getValue();
+ return (String) operationNameItem.getValue();
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
index 291bf07..3d64039 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
@@ -19,24 +19,25 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history;
-import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.widgets.Canvas;
+
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
+import org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryView;
/**
* A table that displays all of the operation histories for a particular Resource.
*
* @author Ian Springer
+ * @author Jay Shaughnessy
*/
-public class ResourceOperationHistoryListView extends AbstractOperationHistoryListView {
+public class ResourceOperationHistoryListView extends OperationHistoryView {
private ResourceComposite resourceComposite;
public ResourceOperationHistoryListView(String locatorId, ResourceComposite resourceComposite) {
- super(locatorId, new ResourceOperationHistoryDataSource(), null,
- new Criteria(ResourceOperationHistoryDataSource.CriteriaField.RESOURCE_ID,
- String.valueOf(resourceComposite.getResource().getId())));
+ super(locatorId, null, EntityContext.forResource(resourceComposite.getResource().getId()));
+
this.resourceComposite = resourceComposite;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java
new file mode 100644
index 0000000..a9a1c3f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java
@@ -0,0 +1,451 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.operation;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.rpc.RPCResponse;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
+import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
+import org.rhq.core.domain.operation.OperationHistory;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * @author Jay Shaughnessy
+ * @author Ian Springer
+ */
+public class OperationHistoryDataSource extends
+ RPCDataSource<ResourceOperationHistory, ResourceOperationHistoryCriteria> {
+
+ private EntityContext entityContext;
+
+ private ResourceOperationHistory currentOperationHistory;
+
+ public static abstract class Field {
+ public static final String ID = "id";
+ public static final String OPERATION_NAME = "operationName";
+ public static final String STATUS = "status";
+ public static final String STARTED_TIME = "startedTime";
+ public static final String CREATED_TIME = "createdTime";
+ public static final String DURATION = "duration";
+ public static final String SUBJECT = "subject";
+ public static final String OPERATION_DEFINITION = "operationDefinition";
+ public static final String ERROR_MESSAGE = "errorMessage";
+ public static final String PARAMETERS = "parameters";
+ }
+
+ protected OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
+
+ public OperationHistoryDataSource() {
+ this(EntityContext.forSubsystemView());
+ }
+
+ public OperationHistoryDataSource(EntityContext context) {
+ super();
+ this.entityContext = context;
+
+ addDataSourceFields();
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ // for some reason, the client seems to crash if you don't specify any data source fields
+ // even though we know we defined override ListGridFields for all columns.
+ List<DataSourceField> fields = super.addDataSourceFields();
+ fields.add(new DataSourceTextField(Field.OPERATION_NAME));
+ return fields;
+ }
+
+ /**
+ * The view that contains the list grid which will display this datasource's data will call this
+ * method to get the field information which is used to control the display of the data.
+ *
+ * @return list grid fields used to display the datasource data
+ */
+ public ArrayList<ListGridField> getListGridFields() {
+ ArrayList<ListGridField> fields = new ArrayList<ListGridField>(6);
+
+ ListGridField idField = new ListGridField(Field.ID, MSG.common_title_id());
+ idField.setWidth(70);
+ fields.add(idField);
+
+ ListGridField startTimeField = createStartedTimeField();
+ fields.add(startTimeField);
+
+ ListGridField opNameField = new ListGridField(Field.OPERATION_NAME, MSG
+ .view_operationHistoryDetails_operation());
+ fields.add(opNameField);
+
+ ListGridField subjectField = new ListGridField(Field.SUBJECT, MSG.view_operationHistoryDetails_requestor());
+ fields.add(subjectField);
+
+ ListGridField statusField = createStatusField();
+ fields.add(statusField);
+
+ if (this.entityContext.type != EntityContext.Type.Resource) {
+ ListGridField resourceNameField = new ListGridField(AncestryUtil.RESOURCE_NAME, MSG.common_title_resource());
+ resourceNameField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String url = LinkManager
+ .getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ }
+ });
+ resourceNameField.setShowHover(true);
+ resourceNameField.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
+ fields.add(resourceNameField);
+
+ ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
+ fields.add(ancestryField);
+
+ startTimeField.setWidth(200);
+ opNameField.setWidth("25%");
+ subjectField.setWidth("15%");
+ statusField.setWidth(100);
+ resourceNameField.setWidth("25%");
+ ancestryField.setWidth("35%");
+ } else {
+ startTimeField.setWidth(200);
+ opNameField.setWidth("*");
+ subjectField.setWidth("*");
+ statusField.setWidth(100);
+ }
+
+ return fields;
+ }
+
+ protected ListGridField createStartedTimeField() {
+ ListGridField startedTimeField = new ListGridField(Field.STARTED_TIME, MSG
+ .view_operationHistoryDetails_dateSubmitted());
+ startedTimeField.setAlign(Alignment.LEFT);
+ startedTimeField.setCellAlign(Alignment.LEFT);
+ startedTimeField.setCellFormatter(new TimestampCellFormatter() {
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ if (value != null) {
+ String timestamp = super.format(value, record, rowNum, colNum);
+ Integer resourceId = record.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
+ Integer opHistoryId = record.getAttributeAsInt("id");
+ String url = LinkManager.getSubsystemResourceOperationHistoryLink(resourceId, opHistoryId);
+ return SeleniumUtility.getLocatableHref(url, timestamp, null);
+ } else {
+ return "<i>" + MSG.view_operationHistoryList_notYetStarted() + "</i>";
+ }
+ }
+ });
+ startedTimeField.setShowHover(true);
+ startedTimeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(Field.STARTED_TIME));
+
+ return startedTimeField;
+ }
+
+ protected ListGridField createStatusField() {
+ ListGridField statusField = new ListGridField(Field.STATUS, MSG.view_operationHistoryDetails_status());
+ statusField.setAlign(Alignment.CENTER);
+ statusField.setCellAlign(Alignment.CENTER);
+ statusField.setShowHover(true);
+ statusField.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String statusStr = record.getAttribute(Field.STATUS);
+ OperationRequestStatus status = OperationRequestStatus.valueOf(statusStr);
+ switch (status) {
+ case SUCCESS: {
+ return MSG.common_status_success();
+ }
+ case FAILURE: {
+ return MSG.common_status_failed();
+ }
+ case INPROGRESS: {
+ return MSG.common_status_inprogress();
+ }
+ case CANCELED: {
+ return MSG.common_status_canceled();
+ }
+ }
+ // should never get here
+ return MSG.common_status_unknown();
+ }
+ });
+ statusField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ OperationRequestStatus status = OperationRequestStatus.valueOf((String) o);
+ String icon = ImageManager.getOperationResultsIcon(status);
+ return Canvas.imgHTML(icon, 16, 16);
+ }
+ });
+ statusField.addRecordClickHandler(new RecordClickHandler() {
+ @Override
+ public void onRecordClick(RecordClickEvent event) {
+ Record record = event.getRecord();
+ String statusStr = record.getAttribute(Field.STATUS);
+ OperationRequestStatus status = OperationRequestStatus.valueOf(statusStr);
+ if (status == OperationRequestStatus.FAILURE) {
+ final Window winModal = new LocatableWindow("StatusDetailsWin");
+ winModal.setTitle(MSG.common_title_details());
+ winModal.setOverflow(Overflow.VISIBLE);
+ winModal.setShowMinimizeButton(false);
+ winModal.setShowMaximizeButton(true);
+ winModal.setIsModal(true);
+ winModal.setShowModalMask(true);
+ winModal.setAutoSize(true);
+ winModal.setAutoCenter(true);
+ winModal.setShowResizer(true);
+ winModal.setCanDragResize(true);
+ winModal.centerInPage();
+ winModal.addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ winModal.markForDestroy();
+ }
+ });
+
+ LocatableHTMLPane htmlPane = new LocatableHTMLPane("StatusDetailsPane");
+ htmlPane.setMargin(10);
+ htmlPane.setDefaultWidth(500);
+ htmlPane.setDefaultHeight(400);
+ String errorMsg = record.getAttribute(Field.ERROR_MESSAGE);
+ if (errorMsg == null) {
+ errorMsg = MSG.common_status_failed();
+ }
+ htmlPane.setContents("<pre>" + errorMsg + "</pre>");
+ winModal.addItem(htmlPane);
+ winModal.show();
+ }
+ }
+ });
+
+ return statusField;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final ResourceOperationHistoryCriteria criteria) {
+
+ if (criteria == null) {
+ // the user selected no statuses in the filter - it makes sense from the UI perspective to show 0 rows
+ response.setTotalRows(0);
+ processResponse(request.getRequestId(), response);
+ return;
+ }
+
+ final long start = System.currentTimeMillis();
+
+ this.operationService.findResourceOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceOperationHistory>>() {
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler()
+ .handleError(MSG.view_operationHistoryDetails_error_fetchFailure(), caught);
+ response.setStatus(RPCResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<ResourceOperationHistory> result) {
+ long fetchTime = System.currentTimeMillis() - start;
+ Log.info(result.size() + " operation histories fetched in: " + fetchTime + "ms");
+
+ dataRetrieved(result, response, request);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ /**
+ * Additional processing to support entity-specific or cross-resource views, and something that can be overidden.
+ */
+ protected void dataRetrieved(final PageList<ResourceOperationHistory> result, final DSResponse response,
+ final DSRequest request) {
+ switch (entityContext.type) {
+
+ // no need to disambiguate the history for a single resource
+ case Resource:
+ response.setData(buildRecords(result));
+ // for paging to work we have to specify size of full result set
+ response.setTotalRows(result.getTotalSize());
+ break;
+
+ // disambiguate as the results could be cross-resource
+ default:
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (ResourceOperationHistory history : result) {
+ Resource resource = history.getResource();
+ typesSet.add(resource.getResourceType().getId());
+ ancestries.add(resource.getAncestry());
+ }
+
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
+
+ Record[] records = buildRecords(result);
+ for (Record record : records) {
+ // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
+ // Store the types map off the records so we can build a detailed hover string as needed.
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+
+ // Build the decoded ancestry Strings now for display
+ record
+ .setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record));
+ }
+ response.setData(records);
+ // for paging to work we have to specify size of full result set
+ response.setTotalRows(result.getTotalSize());
+ }
+ });
+ }
+ }
+
+ @Override
+ protected ResourceOperationHistoryCriteria getFetchCriteria(DSRequest request) {
+ OperationRequestStatus[] statusFilter = getArrayFilter(request, Constant.OPERATION_STATUS,
+ OperationRequestStatus.class);
+
+ if (statusFilter == null || statusFilter.length == 0) {
+ return null; // user didn't select any severities - return null to indicate no data should be displayed
+ }
+
+ ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
+
+ criteria.addFilterStatuses(statusFilter);
+
+ switch (entityContext.type) {
+ case Resource:
+ criteria.addFilterResourceIds(entityContext.resourceId);
+ break;
+
+ case ResourceGroup:
+ criteria.addFilterGroupOperationHistoryId(entityContext.groupId);
+ break;
+ }
+
+ criteria.setPageControl(getPageControl(request));
+ return criteria;
+ }
+
+ @Override
+ protected void executeRemove(Record recordToRemove, DSRequest request, DSResponse response) {
+ final OperationHistory operationHistoryToRemove = copyValues(recordToRemove);
+ Boolean forceValue = request.getAttributeAsBoolean("force");
+ boolean force = ((forceValue != null) && forceValue);
+ operationService.deleteOperationHistory(operationHistoryToRemove.getId(), force, new AsyncCallback<Void>() {
+ public void onSuccess(Void result) {
+ return;
+ }
+
+ public void onFailure(Throwable caught) {
+ throw new RuntimeException("Failed to delete " + operationHistoryToRemove + ".", caught);
+ }
+ });
+ }
+
+ @Override
+ public ResourceOperationHistory copyValues(Record from) {
+ return this.currentOperationHistory;
+ }
+
+ @Override
+ public ListGridRecord copyValues(ResourceOperationHistory from) {
+ this.currentOperationHistory = from;
+
+ ListGridRecord record = new ListGridRecord();
+
+ record.setAttribute(Field.ID, from.getId());
+ record.setAttribute(Field.CREATED_TIME, convertTimestampToDate(from.getCreatedTime()));
+ record.setAttribute(Field.STARTED_TIME, convertTimestampToDate(from.getStartedTime()));
+ record.setAttribute(Field.DURATION, from.getDuration());
+ record.setAttribute(Field.SUBJECT, from.getSubjectName());
+ record.setAttribute(Field.OPERATION_DEFINITION, from.getOperationDefinition());
+ record.setAttribute(Field.OPERATION_NAME, from.getOperationDefinition().getDisplayName());
+ record.setAttribute(Field.ERROR_MESSAGE, from.getErrorMessage());
+ record.setAttribute(Field.STATUS, from.getStatus().name());
+ record.setAttribute(Field.PARAMETERS, from.getParameters());
+
+ // for ancestry handling
+ Resource resource = from.getResource();
+ record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId());
+ record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
+
+ return record;
+ }
+
+ protected EntityContext getEntityContext() {
+ return entityContext;
+ }
+
+ protected void setEntityContext(EntityContext entityContext) {
+ this.entityContext = entityContext;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
new file mode 100644
index 0000000..aa02adc
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
@@ -0,0 +1,179 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.operation;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.MultipleAppearance;
+import com.smartgwt.client.types.SortDirection;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.AbstractConfigurationHistoryDataSource.Field;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDetailsView;
+
+/**
+ * A view that displays a paginated table of operation history. Support exists of subsystem and resource contexts.
+ * Group operation history is (currently) handled separately as the view is comprised of group operation history
+ * entities, not [resource] operation history entities.
+ (
+ * @author Jay Shaughnessy
+ */
+public class OperationHistoryView extends TableSection<OperationHistoryDataSource> {
+
+ public static final ViewName SUBSYSTEM_VIEW_ID = new ViewName("RecentOperations", MSG
+ .common_title_recent_operations());
+
+ private static final String HEADER_ICON = "subsystems/control/Operation_24.png";
+ private static final SortSpecifier DEFAULT_SORT_SPECIFIER = new SortSpecifier(Field.CREATED_TIME,
+ SortDirection.DESCENDING);
+
+ EntityContext context;
+ boolean hasControlPermission;
+ OperationHistoryDataSource dataSource;
+
+ // for subsystem views
+ public OperationHistoryView(String locatorId) {
+ this(locatorId, SUBSYSTEM_VIEW_ID.getTitle(), EntityContext.forSubsystemView(), false);
+ }
+
+ public OperationHistoryView(String locatorId, EntityContext entityContext) {
+ this(locatorId, SUBSYSTEM_VIEW_ID.getTitle(), entityContext, false);
+ }
+
+ public OperationHistoryView(String locatorId, String tableTitle, EntityContext entityContext) {
+ this(locatorId, tableTitle, entityContext, false);
+ }
+
+ protected OperationHistoryView(String locatorId, String tableTitle, EntityContext context,
+ boolean hasControlPermission) {
+ super(locatorId, tableTitle, new SortSpecifier[] { DEFAULT_SORT_SPECIFIER });
+ this.context = context;
+ this.hasControlPermission = hasControlPermission;
+
+ setDataSource(getDataSource());
+ }
+
+ @Override
+ public OperationHistoryDataSource getDataSource() {
+ if (null == this.dataSource) {
+ this.dataSource = new OperationHistoryDataSource(context);
+ }
+ return this.dataSource;
+ }
+
+ @Override
+ protected void configureTableFilters() {
+ SelectItem statusFilter = new SelectItem(Constant.OPERATION_STATUS, MSG.common_title_operation_status());
+ statusFilter.setWrapTitle(false);
+ statusFilter.setWidth(325);
+ statusFilter.setMultiple(true);
+ statusFilter.setMultipleAppearance(MultipleAppearance.PICKLIST);
+
+ LinkedHashMap<String, String> stati = new LinkedHashMap<String, String>(4);
+ stati.put(OperationRequestStatus.SUCCESS.name(), MSG.common_status_success());
+ stati.put(OperationRequestStatus.INPROGRESS.name(), MSG.common_status_inprogress());
+ stati.put(OperationRequestStatus.CANCELED.name(), MSG.common_status_canceled());
+ stati.put(OperationRequestStatus.FAILURE.name(), MSG.common_status_failed());
+
+ LinkedHashMap<String, String> statusIcons = new LinkedHashMap<String, String>(3);
+ statusIcons.put(OperationRequestStatus.SUCCESS.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.SUCCESS));
+ statusIcons.put(OperationRequestStatus.INPROGRESS.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.INPROGRESS));
+ statusIcons.put(OperationRequestStatus.CANCELED.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.CANCELED));
+ statusIcons.put(OperationRequestStatus.FAILURE.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.FAILURE));
+ statusFilter.setValueMap(stati);
+ statusFilter.setValueIcons(statusIcons);
+ statusFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.INPROGRESS.name(),
+ OperationRequestStatus.FAILURE.name(), OperationRequestStatus.CANCELED.name());
+
+ if (isShowFilterForm()) {
+ setFilterFormItems(statusFilter);
+ }
+ }
+
+ @Override
+ protected void configureTable() {
+ ArrayList<ListGridField> dataSourceFields = getDataSource().getListGridFields();
+ getListGrid().setFields(dataSourceFields.toArray(new ListGridField[dataSourceFields.size()]));
+
+ setupTableInteractions();
+
+ super.configureTable();
+ }
+
+ protected boolean hasControlPermission() {
+ return this.hasControlPermission;
+ }
+
+ protected void setupTableInteractions() {
+
+ addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), getDeleteConfirmMessage(),
+ new TableAction() {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ int count = selection.length;
+ return (count >= 1 && hasControlPermission());
+ }
+
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ deleteSelectedRecords();
+ }
+ });
+
+ addTableAction(extendLocatorId("ForceDelete"), MSG.view_operationHistoryList_button_forceDelete(),
+ getDeleteConfirmMessage(), new TableAction() {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ int count = selection.length;
+ return (count >= 1 && hasControlPermission());
+ }
+
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ DSRequest requestProperties = new DSRequest();
+ requestProperties.setAttribute("force", true);
+ deleteSelectedRecords(requestProperties);
+ }
+ });
+ }
+
+ public EntityContext getContext() {
+ return context;
+ }
+
+ @Override
+ public Canvas getDetailsView(int id) {
+ return new ResourceOperationHistoryDetailsView(extendLocatorId("Detail"));
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
deleted file mode 100644
index 1af0364..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.operation;
-
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.criteria.Criteria;
-import org.rhq.core.domain.operation.OperationRequestStatus;
-import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.util.PageControl;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-
-/**
- * Responsible for defining and populating the Smart GWT datasource details and
- * translating the deserialized content into specific record entries for display
- *
- * @author Simeon Pinder
- * @author Jay Shaughnessy
- */
-public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationLastCompletedComposite, Criteria> {
-
- public enum Field {
-
- OPERATION("operationName", MSG.dataSource_operationSchedule_field_operationName()),
-
- RESOURCE("resource", MSG.common_title_resource()),
-
- STATUS("operationStatus", MSG.common_title_status()),
-
- TIME("operationStartTime", MSG.common_title_timestamp());
-
- /**
- * Corresponds to a property name of Resource (e.g. resourceType.name).
- */
- private String propertyName;
-
- /**
- * The table header for the field or property (e.g. Type).
- */
- private String title;
-
- private Field(String propertyName, String title) {
- this.propertyName = propertyName;
- this.title = title;
- }
-
- public String propertyName() {
- return propertyName;
- }
-
- public String title() {
- return title;
- }
-
- public ListGridField getListGridField() {
- return new ListGridField(propertyName, title);
- }
-
- public ListGridField getListGridField(int width) {
- return new ListGridField(propertyName, title, width);
- }
-
- }
-
- private Portlet portlet;
-
- //config attributes
- private boolean operationsRangeLastEnabled = false;
- private int operationsRangeCompleted = -1;
-
- /** Build list of fields for the datasource and then adds them to it.
- */
- public RecentOperationsDataSource(Portlet portlet) {
- this.portlet = portlet;
-
- List<DataSourceField> fields = addDataSourceFields();
- addFields(fields);
- }
-
- @Override
- protected List<DataSourceField> addDataSourceFields() {
- List<DataSourceField> fields = super.addDataSourceFields();
-
- DataSourceTextField resourceField = new DataSourceTextField(Field.RESOURCE.propertyName, Field.RESOURCE.title);
- fields.add(resourceField);
-
- DataSourceTextField operationField = new DataSourceTextField(Field.OPERATION.propertyName(), Field.OPERATION
- .title());
- fields.add(operationField);
-
- DataSourceTextField timeField = new DataSourceTextField(Field.TIME.propertyName(), Field.TIME.title());
- fields.add(timeField);
-
- DataSourceTextField statusField = new DataSourceTextField(Field.STATUS.propertyName, Field.STATUS.title(), 20);
- fields.add(statusField);
-
- return fields;
- }
-
- /** Fetch the ProblemResource data, and populate the response object appropriately.
- *
- * @param request incoming request
- * @param response outgoing response
- */
- @Override
- public void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
- PageControl pageControl = new PageControl();
- //retrieve current portlet display settings
- if ((this.portlet != null) && (this.portlet instanceof OperationsPortlet)) {
- OperationsPortlet operationsPortlet = (OperationsPortlet) this.portlet;
- //populate criteria with portlet preferences defined.
- if (operationsPortlet != null) {
- if (isOperationsRangeCompletedEnabled()) {
- pageControl.setPageSize(getOperationsRangeCompleted());
- operationsPortlet.getCompletedOperationsGrid().setEmptyMessage(
- OperationsPortlet.RANGE_DISABLED_MESSAGE_DEFAULT);
- } else {//show the component, return no results and indicate that you've disabled this display
- pageControl.setPageSize(0);
- operationsPortlet.getCompletedOperationsGrid().setEmptyMessage(
- OperationsPortlet.RANGE_DISABLED_MESSAGE);
- response.setData(null);
- response.setTotalRows(0);
- //pass off for processing
- processResponse(request.getRequestId(), response);
- return;
- }
- }
- }
-
- int resourceId = -1;
-
- GWTServiceLookup.getOperationService().findRecentCompletedOperations(resourceId, pageControl,
- new AsyncCallback<PageList<ResourceOperationLastCompletedComposite>>() {
-
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError(MSG.dataSource_recentOperations_error_fetchFailure(),
- throwable);
- }
-
- public void onSuccess(PageList<ResourceOperationLastCompletedComposite> result) {
- dataRetrieved(result, response, request);
- }
- });
- }
-
- @Override
- protected Criteria getFetchCriteria(DSRequest request) {
- // we don't use criterias for this datasource, just return null
- return null;
- }
-
- protected void dataRetrieved(final PageList<ResourceOperationLastCompletedComposite> result,
- final DSResponse response, final DSRequest request) {
- HashSet<Integer> typesSet = new HashSet<Integer>();
- HashSet<String> ancestries = new HashSet<String>();
- for (ResourceOperationLastCompletedComposite composite : result) {
- typesSet.add(composite.getResourceTypeId());
- ancestries.add(composite.getAncestry());
- }
-
- // In addition to the types of the result resources, get the types of their ancestry
- // NOTE: this may be too labor intensive in general, but since this datasource is a singleton I couldn't
- // make it easily optional.
- typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
-
- ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
- typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() {
- @Override
- public void onTypesLoaded(Map<Integer, ResourceType> types) {
- // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
- AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
-
- Record[] records = buildRecords(result);
- for (Record record : records) {
- // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
- // Store the types map off the records so we can build a detailed hover string as needed.
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
-
- // Build the decoded ancestry Strings now for display
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record));
- }
- response.setData(records);
-
- // for paging to work we have to specify size of full result set, but if a limit has been set,
- // respect the limit
- int resultSize = result.getTotalSize();
- int limit = getOperationsRangeCompleted();
- if (limit > 0 && limit < resultSize) {
- resultSize = limit;
- }
- response.setTotalRows(resultSize);
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- public ListGridRecord copyValues(ResourceOperationLastCompletedComposite from) {
- ListGridRecord record = new ListGridRecord();
- record.setAttribute(Field.OPERATION.propertyName, from.getOperationName());
- record.setAttribute(Field.RESOURCE.propertyName, from.getResourceName());
- record.setAttribute(Field.STATUS.propertyName, getStatusIconLink(from));
- record.setAttribute(Field.TIME.propertyName, new Date(from.getOperationStartTime()));
-
- // for ancestry handling
- record.setAttribute(AncestryUtil.RESOURCE_ID, from.getResourceId());
- record.setAttribute(AncestryUtil.RESOURCE_NAME, from.getResourceName());
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, from.getAncestry());
- record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, from.getResourceTypeId());
-
- record.setAttribute("entity", from);
- return record;
- }
-
- @Override
- public ResourceOperationLastCompletedComposite copyValues(Record from) {
- throw new UnsupportedOperationException("ResourceOperationLastCompletedComposite data is read only");
- }
-
- private String getStatusIconLink(ResourceOperationLastCompletedComposite composite) {
-
- OperationRequestStatus opStatus = composite.getOperationStatus();
- String statusStr = "";
- switch (opStatus) {
- case SUCCESS: {
- statusStr = MSG.common_status_success();
- break;
- }
- case FAILURE: {
- statusStr = MSG.common_status_failed();
- break;
- }
- case INPROGRESS: {
- statusStr = MSG.common_status_inprogress();
- break;
- }
- case CANCELED: {
- statusStr = MSG.common_status_canceled();
- break;
- }
- }
-
- String iconLink = ImageManager.getOperationResultsIcon(opStatus);
- StringBuilder sbImg = new StringBuilder();
- sbImg.append("<img alt='");
- sbImg.append(statusStr);
- sbImg.append("' title='");
- sbImg.append(statusStr);
- sbImg.append("' src='");
- sbImg.append(ImageManager.getFullImagePath(iconLink));
- sbImg.append("'></img>");
-
- String url = LinkManager.getSubsystemResourceOperationHistoryLink(composite.getResourceId(), composite
- .getOperationHistoryId());
-
- return "<a href='" + url + "'>" + sbImg.toString() + "</a>";
- }
-
- public boolean isOperationsRangeCompletedEnabled() {
- return operationsRangeLastEnabled;
- }
-
- public void setOperationsRangeCompleteEnabled(boolean operationsRangeLastEnabled) {
- this.operationsRangeLastEnabled = operationsRangeLastEnabled;
- }
-
- public int getOperationsRangeCompleted() {
- return operationsRangeCompleted;
- }
-
- public void setOperationsRangeCompleted(int operationsRangeCompleted) {
- this.operationsRangeCompleted = operationsRangeCompleted;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index e9ee1c2..d7bfdad 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -38,16 +38,20 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationSchedulePortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+// Note, there is nothing in this class that requires ResourceOperationScheduleComposite, it can all be driven
+// off ResourceOperationSchedule. We should improve te scheduled op datamodel/api at some point and the
+// composite could probably go away.
+
/**
* Responsible for defining and populating the Smart GWT datasource details and
- * translating the deserialized content into specific record entries for display
+ * translating the deserialized content into specific record entries for display.
*
* @author Simeon Pinder
* @author Jay Shaughnessy
@@ -136,18 +140,18 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati
int pageSize = -1;
//retrieve current portlet display settings
- if ((this.portlet != null) && (this.portlet instanceof OperationsPortlet)) {
- OperationsPortlet operationsPortlet = (OperationsPortlet) this.portlet;
+ if ((this.portlet != null) && (this.portlet instanceof OperationSchedulePortlet)) {
+ OperationSchedulePortlet operationsPortlet = (OperationSchedulePortlet) this.portlet;
//populate criteria with portlet preferences defined.
if (operationsPortlet != null) {
if (isOperationsRangeScheduleEnabled()) {
pageSize = getOperationsRangeScheduled();
operationsPortlet.getScheduledOperationsGrid().setEmptyMessage(
- OperationsPortlet.RANGE_DISABLED_MESSAGE_DEFAULT);
+ OperationSchedulePortlet.RANGE_DISABLED_MESSAGE_DEFAULT);
} else {//show the component, return no results and indicate that you've disabled this display
pageSize = 0;
operationsPortlet.getScheduledOperationsGrid().setEmptyMessage(
- OperationsPortlet.RANGE_DISABLED_MESSAGE);
+ OperationSchedulePortlet.RANGE_DISABLED_MESSAGE);
response.setData(null);
response.setTotalRows(0);
//pass off for processing
@@ -222,6 +226,7 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati
@Override
public ListGridRecord copyValues(ResourceOperationScheduleComposite from) {
ListGridRecord record = new ListGridRecord();
+ record.setAttribute("id", from.getId());
record.setAttribute(Field.OPERATION.propertyName, from.getOperationName());
record.setAttribute(Field.RESOURCE.propertyName, from.getResourceName());
record.setAttribute(Field.TIME.propertyName, new Date(from.getOperationNextFireTime()));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
index 186a5b7..90e3ea4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
@@ -42,6 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformSummaryPortlet;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView;
+import org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryView;
import org.rhq.enterprise.gui.coregui.client.report.measurement.MeasurementOOBView;
import org.rhq.enterprise.gui.coregui.client.report.operation.SubsystemOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
@@ -116,11 +117,11 @@ public class ReportTopView extends AbstractSectionedLeftNavigationView {
}
});
- NavigationItem recentOperationsItem = new NavigationItem(SubsystemOperationHistoryListView.VIEW_ID,
+ NavigationItem recentOperationsItem = new NavigationItem(OperationHistoryView.SUBSYSTEM_VIEW_ID,
"subsystems/control/Operation_16.png", new ViewFactory() {
public Canvas createView() {
- return new SubsystemOperationHistoryListView(
- extendLocatorId(SubsystemOperationHistoryListView.VIEW_ID.getName()));
+ return new SubsystemOperationHistoryListView(extendLocatorId(OperationHistoryView.SUBSYSTEM_VIEW_ID
+ .getName()), getGlobalPermissions().contains(Permission.MANAGE_INVENTORY));
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
index 0d4e46f..cea9e70 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
@@ -19,81 +19,17 @@
*/
package org.rhq.enterprise.gui.coregui.client.report.operation;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Set;
-
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.grid.ListGridField;
-
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
-import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDetailsView;
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryView;
/**
* @author Ian Springer
+ * @author Jay Shaughnessy
*/
-public class SubsystemOperationHistoryListView extends AbstractOperationHistoryListView {
-
- public static final ViewName VIEW_ID = new ViewName("RecentOperations", MSG.common_title_recent_operations());
-
- private Set<Permission> globalPermissions;
-
- public SubsystemOperationHistoryListView(String locatorId) {
- super(locatorId, new ResourceOperationHistoryDataSource(), VIEW_ID.getTitle());
-
- this.globalPermissions = EnumSet.noneOf(Permission.class);
- loadGlobalPermissions();
- }
-
- @Override
- protected boolean hasControlPermission() {
- loadGlobalPermissions();
- return this.globalPermissions.contains(Permission.MANAGE_INVENTORY);
- }
+public class SubsystemOperationHistoryListView extends OperationHistoryView {
- private void loadGlobalPermissions() {
- new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
- public void onPermissionsLoaded(Set<Permission> permissions) {
- globalPermissions = permissions;
- }
- });
+ public SubsystemOperationHistoryListView(String locatorId, boolean hasControlPermission) {
+ super(locatorId, OperationHistoryView.SUBSYSTEM_VIEW_ID.getTitle(), EntityContext.forSubsystemView(),
+ hasControlPermission);
}
-
- @Override
- protected List<ListGridField> createFields() {
- List<ListGridField> fields = super.createFields();
-
- ListGridField resourceField = createResourceField();
- resourceField.setWidth("20%");
- fields.add(1, resourceField);
-
- ListGridField ancestryField = createAncestryField();
- resourceField.setWidth("20%");
- fields.add(2, ancestryField);
-
- for (ListGridField field : fields) {
- String fieldName = field.getName();
- if (fieldName.equals(AbstractOperationHistoryDataSource.Field.SUBJECT)) {
- field.setWidth("10%");
- }
- if (fieldName.equals(AbstractOperationHistoryDataSource.Field.OPERATION_NAME)
- || fieldName.equals(AbstractOperationHistoryDataSource.Field.STARTED_TIME)) {
- field.setWidth("25%");
- }
- }
-
- return fields;
- }
-
- @Override
- public Canvas getDetailsView(int id) {
- return new ResourceOperationHistoryDetailsView(this.extendLocatorId("DetailsView"), true);
- }
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index 3fa0171..4e4348e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -50,6 +50,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -506,6 +507,8 @@ public abstract class RPCDataSource<T, C extends org.rhq.core.domain.criteria.Cr
return (S[]) new AlertPriority[size];
} else if (genericEnumType == EventSeverity.class) {
return (S[]) new EventSeverity[size];
+ } else if (genericEnumType == OperationRequestStatus.class) {
+ return (S[]) new OperationRequestStatus[size];
} else if (genericEnumType == ResourceCategory.class) {
return (S[]) new ResourceCategory[size];
} else {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
index 59ad907..ad42c8c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
@@ -38,6 +38,7 @@ import org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposit
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.operation.OperationManagerLocal;
@@ -196,6 +197,7 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
public PageList<ResourceOperationScheduleComposite> findScheduledOperations(int pageSize) throws RuntimeException {
try {
PageControl pageControl = new PageControl(0, pageSize);
+ pageControl.initDefaultOrderingField("ro.nextFireTime", PageOrdering.ASC);
PageList<ResourceOperationScheduleComposite> scheduledResourceOps = operationManager
.findCurrentlyScheduledResourceOperations(getSessionSubject(), pageControl);
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 4a9cfa4..96ef8cf 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
@@ -1468,7 +1468,7 @@ view_portlet_defaultName_groupMetric = Resource Group Metric Graph
view_portlet_defaultName_inventorySummary = Inventory Summary
view_portlet_defaultName_mashup = Mashup
view_portlet_defaultName_message = Message
-view_portlet_defaultName_operations = Operations
+view_portlet_defaultName_operations = Recent Operations
view_portlet_defaultName_platformSummary = Platform Utilization
view_portlet_defaultName_problemResources = Alerted or Unavailable Resources
view_portlet_defaultName_recentAlerts = Recent Alerts
@@ -1503,7 +1503,8 @@ view_portlet_help_mashup = This portlet displays the returned content of a remot
view_portlet_help_metrics = This portlet graphs relevant recent metric data based on display criteria configured.
view_portlet_help_message = This portlet displays a static HTML message. The <i>message</i> property must be configured.
view_portlet_help_oobs = This portlet displays OOB(Out of Bound) metric conditions.
-view_portlet_help_operations = This portlet displays executing, completed and scheduled operations for the current user''s inventory.
+view_portlet_help_operations = This portlet displays the most recently executed operations for the current user''s inventory.
+view_portlet_help_scheduledOperations = This portlet displays the next scheduled operations for the current user''s inventory.
view_portlet_help_operations_criteria = This portlet displays Operations consistent with display criteria configured.
view_portlet_help_pkg_history = This portlet shows relevant package history based on display criteria configured.
view_portlet_help_platformSummary = This portlet displays utilization data (such as current CPU and memory usage) for platform resources that are accessible by the current user.
commit 3266eae064d066c7366c302e05cb1ad6306e184d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 5 15:41:17 2011 -0400
Fix locatable issue for wizards. Make sure the dialog window is locatable
so tests can access dialog controls.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
index 8713ecc..1a52e12 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
@@ -41,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Messages;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/**
* @author Greg Hinkle
@@ -282,7 +283,7 @@ public class WizardView extends LocatableVLayout {
}
public void displayDialog() {
- wizardWindow = new Window();
+ wizardWindow = new LocatableWindow(extendLocatorId("Wizard"));
wizardWindow.setTitle(wizard.getWindowTitle());
wizardWindow.setWidth(800);
wizardWindow.setHeight(600);
commit 9369a27013749abc46249c66001396cb7e305e64
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 5 15:40:31 2011 -0400
Fix Locatable issue with login dialog box, make it always be the same
regardless of parent widget.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index 865793a..bf4ecf7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -157,7 +157,12 @@ public class LoginView extends LocatableCanvas {
form.setFields(logo, header, new RowSpacerItem(), user, password, loginButton);
- window = new LocatableWindow(extendLocatorId("LoginWindow"));
+ // we ant the login window to have the same locator regardless of its parent. It can be
+ // created from at least two different paths (LoginView, UserSessionManager) but for test purposes
+ // we want a single login script. There will only be one login dialog at any time, so it is safe
+ // to use a non-extended locator.
+ // is parented by the Login
+ window = new LocatableWindow("Login");
window.setWidth(400);
window.setHeight(275);
window.setTitle(MSG.common_title_welcome());
13 years, 1 month
[rhq] 2 commits - modules/enterprise
by ips
modules/enterprise/gui/coregui/pom.xml | 2 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java | 4 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/util/MessagePortlet.java | 15 ++++++++--
3 files changed, 14 insertions(+), 7 deletions(-)
New commits:
commit 4e5db13557b7252088110c795b7218c8c47fbd7f
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Apr 6 16:08:27 2011 -0400
only display HTML within the message portlet's content if the logged-in user is rhqadmin; otherwise escape HTML to prevent XSS attacks (https://bugzilla.redhat.com/show_bug.cgi?id=636734)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index 95780fd..d72abbf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -268,7 +268,7 @@ public class DashboardsView extends LocatableVLayout implements DashboardContain
}
/**
- * The stored name for a dashboard is initally set to a generated, localizable name. It can later be edited
+ * The stored name for a dashboard is initially set to a generated, localizable name. It can later be edited
* by the user. Automation tests must be valid independent of localization so we must use repeatable locators.
* This method checks for generated dash names and returns a repeatable locator for them.
*
@@ -363,8 +363,6 @@ public class DashboardsView extends LocatableVLayout implements DashboardContain
// Left Column
DashboardPortlet welcome = new DashboardPortlet(MessagePortlet.NAME, MessagePortlet.KEY, 250);
- welcome.getConfiguration().put(
- new PropertySimple("message", MSG.view_dashboardsManager_message_title_details()));
dashboard.addPortlet(welcome, 0, 0);
DashboardPortlet summary = new DashboardPortlet(InventorySummaryPortlet.NAME, InventorySummaryPortlet.KEY, 250);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/util/MessagePortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/util/MessagePortlet.java
index ead9cc2..26b85a3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/util/MessagePortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/util/MessagePortlet.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -30,6 +30,8 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.admin.users.UsersDataSource;
import org.rhq.enterprise.gui.coregui.client.dashboard.ConfigurablePortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
@@ -48,6 +50,7 @@ public class MessagePortlet extends LocatableHTMLPane implements ConfigurablePor
public static final String NAME = MSG.view_portlet_defaultName_message();
private static final String MESSAGE_PROPERTY = "message";
+ private static final String DEFAULT_MESSAGE = MSG.view_dashboardsManager_message_title_details();
public MessagePortlet(String locatorId) {
super(locatorId);
@@ -57,9 +60,15 @@ public class MessagePortlet extends LocatableHTMLPane implements ConfigurablePor
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
String contents = storedPortlet.getConfiguration().getSimpleValue(MESSAGE_PROPERTY, null);
if (contents != null) {
- setContents(StringUtility.sanitizeHtml(contents));
+ if (UserSessionManager.getSessionSubject().getId() != UsersDataSource.ID_RHQADMIN &&
+ !contents.equals(DEFAULT_MESSAGE)) {
+ // To avoid XSS attacks, don't allow non-superusers to enter HTML.
+ // TODO (ips, 04/06/11): Sanitize this, rather than escaping it, once we upgrade to GWT 2.1 or later.
+ contents = StringUtility.escapeHtml(contents);
+ }
+ setContents(contents);
} else {
- setContents("<br/><i>" + MSG.view_portlet_configure_needed() + "</i>");
+ setContents(DEFAULT_MESSAGE);
}
}
commit 0478d26932be341fa68c72edf05307d8de022a73
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Apr 6 16:04:39 2011 -0400
minor fix to config of gwt plugin
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index bf14b52..527bd94 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -278,7 +278,7 @@
<servicePattern>**/gwt/*GWTService.java</servicePattern>
<i18nMessagesBundle>org.rhq.enterprise.gui.coregui.client.Messages</i18nMessagesBundle>
<i18nConstantsWithLookupBundle>org.rhq.enterprise.gui.coregui.client.MessageConstants</i18nConstantsWithLookupBundle>
- <compileSourcesArtifacts>org.rhq:rhq-core-domain</compileSourcesArtifacts>
+ <compileSourcesArtifact>org.rhq:rhq-core-domain</compileSourcesArtifact>
<style>DETAILED</style>
</configuration>
13 years, 1 month
[rhq] Branch 'as7plugin' - 41 commits - modules/core modules/enterprise modules/plugins
by Heiko W. Rupp
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AbstractConfigurationUpdateCriteria.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/GetRevertInfoStep.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 61 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EditableFormItem.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AuthorizedTableAction.java | 95 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/EscapedHtmlCellFormatter.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/IconField.java | 73 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/RecordExtractor.java | 38
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/ResourceAuthorizedTableAction.java | 101 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java | 111 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java | 93 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java | 554 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java | 28
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceConfigurationUpdatesPortlet.java | 330 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/util/MessagePortlet.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AuthorizationGWTService.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java | 45
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDetailsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java | 22
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java | 108 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java | 28
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationDataSource.java | 97 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java | 100 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java | 58 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 44
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java | 339 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsDataSource.java | 106 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsView.java | 189 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java | 333 ------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java | 106 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java | 189 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java | 65 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java | 11
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 28
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java | 49
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java | 3
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventConfigJSON.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp | 4
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventCreateDeleteChildJSON.jsp | 4
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp | 4
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventOperationsJSON.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventPluginConfigJSON.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/events/data-plain.xhtml | 4
modules/enterprise/remoting/cli/pom.xml | 1
modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml | 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java | 12
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementProblemManagerBean.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 3
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java | 2
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerOperationsDelegate.java | 78 -
modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml | 13
modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml | 28
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java | 2
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerOperationsDelegate.java | 27
modules/plugins/tomcat/src/main/resources/META-INF/rhq-plugin.xml | 13
105 files changed, 3010 insertions(+), 1120 deletions(-)
New commits:
commit 1054ae44f1831fc3c7787bd118d4d5e7c1ad725b
Merge: 7bda199 7b91cb2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 6 21:52:03 2011 +0200
Merge branch 'master' into as7plugin
commit 7b91cb2e587aac2017094f313f89047cc89f275f
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Apr 6 12:21:38 2011 -0400
class i missed in a commit yesterday
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java
index eaca3b6..d92e7ba 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java
@@ -38,6 +38,7 @@ public abstract class SubjectPreferencesBase {
/** delimiter for preferences that are multi-valued and stringified */
protected static final String PREF_LIST_DELIM = ",";
protected static final String PREF_ITEM_DELIM = "|";
+ protected static final String PREF_ITEM_DELIM_REGEX = "\\|";
private int subjectId;
private Set<String> changed;
@@ -50,7 +51,6 @@ public abstract class SubjectPreferencesBase {
/**
* Get the value of a preference as a boolean.
* @param key the preference to get
- * @param ifNull if the pref is undefined, return this value instead
* @return the boolean value of 'key', or if key is null, returns the
* 'ifNull' value.
*/
@@ -204,11 +204,11 @@ public abstract class SubjectPreferencesBase {
protected List<Integer> getPreferenceAsIntegerList(String key, String delimiter) {
try {
- List<String> value = getPreferenceAsList(key, delimiter);
+ List<String> values = getPreferenceAsList(key, delimiter);
- List<Integer> result = new ArrayList<Integer>(value.size());
- for (int i = 0; i < value.size(); i++) {
- String trimmed = value.get(i).trim();
+ List<Integer> result = new ArrayList<Integer>(values.size());
+ for (String value : values) {
+ String trimmed = value.trim();
if (trimmed.length() > 0) {
result.add(Integer.valueOf(trimmed));
}
@@ -230,7 +230,7 @@ public abstract class SubjectPreferencesBase {
}
public void setPreference(String key, Object value) throws IllegalArgumentException {
- String val = null;
+ String val;
if (value == null) {
val = "";
} else if (value instanceof String) {
commit 4228e9661ede4596981453f225117ab403e8be66
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Apr 5 17:06:19 2011 -0400
fix exception caused by different format for recentResources user pref between portal-war and coregui (https://bugzilla.redhat.com/show_bug.cgi?id=693411)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
index 3e34ceb..9006bec 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java
@@ -308,6 +308,8 @@ public class UserPreferences {
}
return result;
} catch (Exception e) {
+ // value was probably in be the old comma-delimited format used by portal-war -
+ // throw it away and return an empty list
return new ArrayList<Integer>();
}
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
index e2414a7..5d317b0 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserPreferences.java
@@ -1,5 +1,6 @@
package org.rhq.enterprise.gui.legacy;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -769,7 +770,7 @@ public class WebUserPreferences extends SubjectPreferencesBase {
return; // nothing is stored in session for the special NONE view
}
- List pageControlProperties = new ArrayList();
+ List<Serializable> pageControlProperties = new ArrayList<Serializable>();
pageControlProperties.add(pageControl.getPageSize());
pageControlProperties.add(pageControl.getPageNumber());
@@ -797,16 +798,37 @@ public class WebUserPreferences extends SubjectPreferencesBase {
visits.remove(10);
}
- setPreference(PREF_RECENT_RESOURCES, visits, ",");
+ setPreference(PREF_RECENT_RESOURCES, visits, PREF_LIST_DELIM);
}
public List<ResourceVisit> getRecentResourceVisits() {
- List<String> stringList = getPreferenceAsList(PREF_RECENT_RESOURCES, ",");
List<ResourceVisit> visits = new ArrayList<ResourceVisit>();
- for (String string : stringList) {
- String[] data = string.split("\\|");
- if (data.length == 3)
- visits.add(new ResourceVisit(Integer.parseInt(data[0]), data[2], ResourceVisit.Kind.valueOf(data[1])));
+ try {
+ // first try the new coregui format
+ List<Integer> resourceIds = getPreferenceAsIntegerList(PREF_RECENT_RESOURCES, "|");
+ for (Integer resourceId : resourceIds) {
+ ResourceVisit visit = new ResourceVisit(resourceId, "", ResourceVisit.Kind.resource);
+ visits.add(visit);
+ }
+ } catch (RuntimeException e) {
+ // if an exception occurs, try the legacy portal-war format
+ List<String> stringList = getPreferenceAsList(PREF_RECENT_RESOURCES, PREF_LIST_DELIM);
+ for (String string : stringList) {
+ String[] data = string.split(PREF_ITEM_DELIM_REGEX);
+ if (data.length != 3) {
+ throw new RuntimeException("Failed to parse resource visit item: " + string);
+ }
+ ResourceVisit.Kind kind = ResourceVisit.Kind.valueOf(data[1]);
+ // throw away recent groups, since the new coregui format only supports resources
+ if (kind == ResourceVisit.Kind.resource || kind == ResourceVisit.Kind.PLATFORM
+ || kind == ResourceVisit.Kind.SERVER || kind == ResourceVisit.Kind.SERVICE) {
+ int resourceId = Integer.parseInt(data[0]);
+ ResourceVisit visit = new ResourceVisit(resourceId, "", ResourceVisit.Kind.resource);
+ visits.add(visit);
+ }
+ }
+ // overwrite the pref value with the new coregui format
+ setPreference(PREF_RECENT_RESOURCES, visits, "|");
}
return visits;
}
@@ -814,9 +836,14 @@ public class WebUserPreferences extends SubjectPreferencesBase {
public static class ResourceVisit {
public enum Kind {
@Deprecated
- resource("Resource"), @Deprecated
- group("Group"), PLATFORM("Platform"), SERVER("Server"), SERVICE("Service"), COMPATIBLE_GROUP("Cluster"), MIXED_GROUP(
- "Group");
+ resource("Resource"),
+ @Deprecated
+ group("Group"),
+ PLATFORM("Platform"),
+ SERVER("Server"),
+ SERVICE("Service"),
+ COMPATIBLE_GROUP("Cluster"),
+ MIXED_GROUP("Group");
private String displayName;
@@ -881,7 +908,7 @@ public class WebUserPreferences extends SubjectPreferencesBase {
@Override
public String toString() {
- return id + "|" + kind.name() + "|" + name;
+ return String.valueOf(id);
}
}
commit 3447a66c09dfdec0ea2bdcc45798bd1caf6f41ac
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Apr 5 15:06:43 2011 -0400
escape HTML in names and descriptions on groupdef list and details views (https://bugzilla.redhat.com/show_bug.cgi?id=691547)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
index 9106e60..f5f7ba0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -36,6 +36,7 @@ import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.EscapedHtmlCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
@@ -56,8 +57,8 @@ public class GroupDefinitionListView extends TableSection<GroupDefinitionDataSou
super(locatorId, TITLE);
setHeaderIcon(headerIcon);
-
setDataSource(GroupDefinitionDataSource.getInstance());
+ setEscapeHtmlInDetailsLinkColumn(true);
}
@Override
@@ -67,7 +68,9 @@ public class GroupDefinitionListView extends TableSection<GroupDefinitionDataSou
idField.setWidth(50);
ListGridField nameField = new ListGridField("name", MSG.common_title_name(), 150);
+ nameField.setCellFormatter(new EscapedHtmlCellFormatter());
ListGridField descriptionField = new ListGridField("description", MSG.common_title_description());
+ descriptionField.setCellFormatter(new EscapedHtmlCellFormatter());
ListGridField expressionField = new ListGridField("expression", MSG.view_dynagroup_expressionSet(), 250);
expressionField.setCellFormatter(new CellFormatter() {
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
index a302455..10daf03 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -73,10 +73,12 @@ import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.table.EscapedHtmlCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions.GroupDefinitionExpressionBuilder.AddExpressionHandler;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -139,11 +141,8 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
form.setDataSource(GroupDefinitionDataSource.getInstance());
form.setHiliteRequiredFields(true);
form.setRequiredTitleSuffix(" <span style=\"color: red;\">* </span>:");
- if (groupDefinition.getId() == 0) {
- form.setSaveOperationType(DSOperationType.ADD);
- } else {
- form.setSaveOperationType(DSOperationType.UPDATE);
- }
+ DSOperationType saveOperationType = (groupDefinition.getId() == 0) ? DSOperationType.ADD : DSOperationType.UPDATE;
+ form.setSaveOperationType(saveOperationType);
final DynaGroupChildrenView dynaGroupChildrenView = new DynaGroupChildrenView(extendLocatorId("DynaGroups"),
groupDefinitionId);
@@ -201,7 +200,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
} else {
Record newRecord = results[0];
GroupDefinition newGroupDefinition = GroupDefinitionDataSource.getInstance().copyValues(
- (ListGridRecord) newRecord);
+ newRecord);
if (recalc) {
recalculate(dynaGroupChildrenView, newGroupDefinition.getId());
}
@@ -257,12 +256,13 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
String linkName = record.getAttributeAsString(NAME.propertyName());
String linkUrl = LinkManager.getResourceGroupLink(record.getAttributeAsInt("id"));
- return "<a href=\"" + linkUrl + "\">" + linkName + "</a>";
+ return "<a href=\"" + linkUrl + "\">" + StringUtility.escapeHtml(linkName) + "</a>";
}
});
ListGridField descriptionField = new ListGridField(DESCRIPTION.propertyName(), DESCRIPTION.title());
descriptionField.setWidth("300");
+ descriptionField.setCellFormatter(new EscapedHtmlCellFormatter());
ListGridField typeNameField = new ListGridField(TYPE.propertyName(), TYPE.title());
typeNameField.setWidth("100");
@@ -350,12 +350,12 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
templateSelectorTitleSpacer.setColSpan(1);
templateSelectorTitleSpacer.setEndRow(false);
- templateSelector = new SelectItem("templateSelector");
+ // TODO: i18n title
+ templateSelector = new SelectItem("templateSelector", "Saved Expression");
templateStrings = getTemplates();
templateSelector.setValueMap(templateStrings.keySet().toArray(new String[templateStrings.size()]));
templateSelector.setAllowEmptyValue(true);
templateSelector.setWidth(300);
- templateSelector.setShowTitle(false);
templateSelector.setColSpan(1);
templateSelector.setEndRow(true);
templateSelector.setStartRow(false);
commit 1a711ed042d252270dcf81ebfbb0001f4bf45225
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Apr 5 13:00:37 2011 -0400
add hibernate-annotations.jar to the CLI's lib dir, so users can compile custom RHQ remote clients using CLI/lib/*.jar as the compile classpath (https://bugzilla.redhat.com/show_bug.cgi?id=683136)
diff --git a/modules/enterprise/remoting/cli/pom.xml b/modules/enterprise/remoting/cli/pom.xml
index 1c5207c..370f509 100644
--- a/modules/enterprise/remoting/cli/pom.xml
+++ b/modules/enterprise/remoting/cli/pom.xml
@@ -126,6 +126,7 @@
<property name="opencsv.version" value="${opencsv.version}" />
<property name="concurrent.version" value="${concurrent.version}" />
<property name="getopt.version" value="${getopt.version}" />
+ <property name="hibernate-annotations.version" value="${hibernate-annotations.version}" />
<property name="i18nlog.version" value="${i18nlog.version}" />
<property name="jboss-common.version" value="${jboss-common.version}" />
<property name="jboss.version" value="${jboss.version}" />
diff --git a/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml b/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
index f54a691..baf99e5 100644
--- a/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
+++ b/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
@@ -65,6 +65,7 @@
<copy file="${settings.localRepository}/net/sf/opencsv/opencsv/${opencsv.version}/opencsv-${opencsv.version}.jar" tofile="${lib.home}/opencsv-${opencsv.version}.jar" verbose="true" />
<copy file="${settings.localRepository}/org/testng/testng/${testng.version}/testng-${testng.version}.jar" tofile="${lib.home}/testng-${testng.version}.jar" verbose="true" />
<copy file="${settings.localRepository}/org/rhq/rhq-script-bindings/${project.version}/rhq-script-bindings-${project.version}.jar" tofile="${lib.home}/rhq-script-bindings-${project.version}.jar" verbose="true" />
+ <copy file="${settings.localRepository}/hibernate-annotations/hibernate-annotations/${hibernate-annotations.version}/hibernate-annotations-${hibernate-annotations.version}.jar" todir="${lib.home}" verbose="true" />
</target>
</project>
commit 08da74a83a3122f2df503fe87532dcf660515e9f
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Apr 4 17:24:38 2011 -0400
update default message for resource ops portlet.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
index a0ef80ffba..9ca8f5c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
@@ -253,6 +253,12 @@ class ResourceOperationsCriteriaHistoryListView extends
protected String getBasePath() {
return "Resource/" + resourceComposite.getResource().getId() + "/Operations/History";
}
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ }
}
/** Provide implementation of ResourceOperationHistoryDataSource that dynamically
commit 9c5652e29fda9c0bbf5ed880616ecd3620b9ed26
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Apr 4 16:36:06 2011 -0400
i)several refresh issues
ii)BZ:636733: platform util portlet always scrolling.
iii)BZ:636723: Platform util not refreshing.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
index 7c0f8d3..256f9c1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
@@ -404,7 +404,6 @@ public class GroupConfigurationUpdatesPortlet extends LocatableVLayout implement
public GroupConfigurationHistoryCriteriaTable(String locatorId, ResourceGroupComposite groupComposite) {
super(locatorId, groupComposite);
- getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
}
@Override
@@ -416,6 +415,13 @@ public class GroupConfigurationUpdatesPortlet extends LocatableVLayout implement
MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
}
}
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ }
+
}
class GroupConfigurationUdpatesCriteriaDataSource extends GroupResourceConfigurationDataSource {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
index a0171c2..6f38d63 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
@@ -25,6 +25,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.Autofit;
+import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.Img;
@@ -79,7 +80,6 @@ public class PlatformSummaryPortlet extends LocatableListGrid implements Portlet
public PlatformSummaryPortlet(String locatorId) {
super(locatorId);
-
setWidth100();
setHeight100();
@@ -89,7 +89,8 @@ public class PlatformSummaryPortlet extends LocatableListGrid implements Portlet
setShowRecordComponentsByCell(true);
setUseAllDataSourceFields(true);
- setAutoFitData(Autofit.HORIZONTAL);
+ setAutoFitData(Autofit.VERTICAL);
+ setOverflow(Overflow.AUTO);
setDataSource(new PlatformMetricDataSource(this));
setInitialCriteria(new Criteria(ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.PLATFORM
@@ -387,4 +388,13 @@ public class PlatformSummaryPortlet extends LocatableListGrid implements Portlet
return new PlatformSummaryPortlet(locatorId);
}
}
+
+ /** Custom refresh operation as we are not directly extending Table
+ */
+ @Override
+ public void redraw() {
+ super.redraw();
+ invalidateCache();
+ markForRedraw();
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
index 1ffacf6..4519b95 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
@@ -68,9 +68,6 @@ public abstract class AbstractRecentAlertsPortlet extends AlertHistoryView imple
setOverflow(Overflow.VISIBLE);
setShowFooterRefresh(false); //disable footer refresh button as redundant for portlets
setShowHeader(false);//disable header for portlets
- if (getListGrid() != null) {
- getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
- }
}
public Timer getRefreshTimer() {
@@ -396,4 +393,10 @@ public abstract class AbstractRecentAlertsPortlet extends AlertHistoryView imple
return criteria;
}
}
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 7eac876..e739098 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -353,6 +353,11 @@ public class ProblemResourcesPortlet extends Table<ProblemResourcesDataSource> i
return false;
}
+ @Override
+ public void redraw() {
+ super.refresh();
+ markForRedraw();
+ }
}
/**Construct table widget Label to display timerange settings used with latest datasource query.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceConfigurationUpdatesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceConfigurationUpdatesPortlet.java
index a4a6e67..bd5c4ac 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceConfigurationUpdatesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceConfigurationUpdatesPortlet.java
@@ -195,6 +195,12 @@ public class ResourceConfigurationUpdatesPortlet extends GroupConfigurationUpdat
protected String getBasePath() {
return "Resource/" + resourceComposite.getResource().getId() + "/Configuration/History";
}
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ }
}
class ConfigurationUdpatesCriteriaDataSource extends ConfigurationHistoryDataSource {
commit 3f6374cf07943d7403752d4a5367d7b0ce0e59ac
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Apr 4 15:03:35 2011 -0400
adding npe check.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
index af95e7a..1ffacf6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
@@ -68,7 +68,9 @@ public abstract class AbstractRecentAlertsPortlet extends AlertHistoryView imple
setOverflow(Overflow.VISIBLE);
setShowFooterRefresh(false); //disable footer refresh button as redundant for portlets
setShowHeader(false);//disable header for portlets
- getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ if (getListGrid() != null) {
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ }
}
public Timer getRefreshTimer() {
commit 2009d4df168098b31cc6e833392a5ed8cd40c133
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Apr 4 12:53:44 2011 -0400
i)modify table empty/populated messages for portlets to indicate matching results.
ii)enable auto-refresh for Alert* portlets.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
index f002795..7c0f8d3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
@@ -112,7 +112,7 @@ public class GroupConfigurationUpdatesPortlet extends LocatableVLayout implement
protected boolean portletConfigInitialized = false;
protected boolean currentlyLoading = false;
protected String baseViewPath = "";
- private HistoryGroupResourceConfigurationTable groupHistoryTable;
+ private GroupConfigurationHistoryCriteriaTable groupHistoryTable;
protected static HashMap<String, String> updatedMapping = new HashMap<String, String>();
static {
@@ -300,16 +300,6 @@ public class GroupConfigurationUpdatesPortlet extends LocatableVLayout implement
loadData();
}
- // @Override
- // protected void refreshTableInfo() {
- // super.refreshTableInfo();
- // if (getTableInfo() != null) {
- // int count = getListGrid().getSelection().length;
- // getTableInfo().setContents(
- // MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
- // }
- // }
-
@Override
public boolean isRefreshing() {
return this.currentlyLoading;
@@ -370,29 +360,18 @@ public class GroupConfigurationUpdatesPortlet extends LocatableVLayout implement
filterResourceGroupIds.add(groupId);
criteria.addFilterResourceGroupIds(filterResourceGroupIds);
- groupHistoryTable = new HistoryGroupResourceConfigurationTable(extendLocatorId("Table"),
+ groupHistoryTable = new GroupConfigurationHistoryCriteriaTable(extendLocatorId("Table"),
groupComposite);
- // groupHistoryTable.setDataSource(new GroupConfigurationUdpatesCriteriaDataSource(portletConfig,
- // groupId));
- // groupHistoryTable.setShowHeader(false);
- // groupHistoryTable.setShowFooterRefresh(false);
} else {
- //TODO: spinder fix for empties
- // Criteria criteria = new Criteria();
ResourceGroup emptyGroup = new ResourceGroup("");
emptyGroup.setId(-1);
Long zero = new Long(0);
groupComposite = new ResourceGroupComposite(zero, zero, zero, zero, emptyGroup);
- // groupOperations = new GroupOperationsCriteriaHistoryListView(locatorId,
- // new GroupOperationsCriteriaDataSource(portletConfig), null, criteria, groupComposite);
- groupHistoryTable = new HistoryGroupResourceConfigurationTable(extendLocatorId("Table"),
+ groupHistoryTable = new GroupConfigurationHistoryCriteriaTable(extendLocatorId("Table"),
groupComposite);
- // groupHistoryTable.setDataSource(new GroupConfigurationUdpatesCriteriaDataSource(portletConfig,
- // groupId));
- // groupHistoryTable.setShowHeader(false);
- // groupHistoryTable.setShowFooterRefresh(false);
}
+ //update table for portlet display.
groupHistoryTable.setDataSource(new GroupConfigurationUdpatesCriteriaDataSource(portletConfig,
groupId));
groupHistoryTable.setShowHeader(false);
@@ -421,6 +400,24 @@ public class GroupConfigurationUpdatesPortlet extends LocatableVLayout implement
return baseViewPath;
}
+ class GroupConfigurationHistoryCriteriaTable extends HistoryGroupResourceConfigurationTable {
+
+ public GroupConfigurationHistoryCriteriaTable(String locatorId, ResourceGroupComposite groupComposite) {
+ super(locatorId, groupComposite);
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ }
+
+ @Override
+ protected void refreshTableInfo() {
+ super.refreshTableInfo();
+ if (getTableInfo() != null) {
+ int count = getListGrid().getSelection().length;
+ getTableInfo().setContents(
+ MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
+ }
+ }
+ }
+
class GroupConfigurationUdpatesCriteriaDataSource extends GroupResourceConfigurationDataSource {
public GroupConfigurationUdpatesCriteriaDataSource(Configuration portletConfig, int groupId) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java
index 008c34b..b06c9a4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java
@@ -240,6 +240,7 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings
recentOobContent.addChild(column);
recentOobContent.markForRedraw();
currentlyLoading = false;
+ markForRedraw();
}
});
}
@@ -247,6 +248,7 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings
public void startRefreshCycle() {
refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer);
recentOobContent.markForRedraw();
+ markForRedraw();
}
@Override
@@ -263,6 +265,7 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings
@Override
public void redraw() {
super.redraw();
+ //spinder 4/3/11: although screen does not flash autorefresh is being called on time. Too fast for user to notice.
loadData();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
index 188b2a1..af95e7a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
@@ -68,6 +68,7 @@ public abstract class AbstractRecentAlertsPortlet extends AlertHistoryView imple
setOverflow(Overflow.VISIBLE);
setShowFooterRefresh(false); //disable footer refresh button as redundant for portlets
setShowHeader(false);//disable header for portlets
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
}
public Timer getRefreshTimer() {
@@ -273,6 +274,12 @@ public abstract class AbstractRecentAlertsPortlet extends AlertHistoryView imple
super.onDestroy();
}
+ @Override
+ public void redraw() {
+ super.refresh();
+ markForRedraw();
+ }
+
static public class AlertsPortletDataSource extends AlertDataSource {
private Configuration configuration;
commit 877170b93dacaa5e71b83709fdea29e10f70fe57
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Apr 4 16:51:02 2011 -0400
Work on issues revolving around direct navigation to either a resource/group
subtab list view, or detail for that view.
- rake sure to always invoke a bookmarkable view's renderView method in
order to get basePath set correctly, which is required for list entry link creation.
- remove restriction that the subTabLayout be drawn prior to adding a
member canvas. It may not be fully drawn in the direct navigation use case.
- make it more clear when we should handle tab selection events and when we
ignore them.
Maybe *this* time I finally got it right...
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
index 1d684ff..1dbc33d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
@@ -210,7 +210,7 @@ public class SubTabLayout extends LocatableVLayout {
}
if (foundTab) {
- refresh();
+ setCurrentlySelected();
}
return foundTab;
@@ -248,7 +248,7 @@ public class SubTabLayout extends LocatableVLayout {
return false;
}
this.currentlySelected = subTab.getLocatorId();
- refresh();
+ setCurrentlySelected();
return true;
}
}
@@ -293,8 +293,8 @@ public class SubTabLayout extends LocatableVLayout {
}
}
- private void refresh() {
- if (isDrawn() && null != this.currentlySelected) {
+ private void setCurrentlySelected() {
+ if (null != this.currentlySelected) {
Button button = this.subTabs.get(this.currentlySelected).getButton();
button.select();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
index cac30b2..c6867ac 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
@@ -228,7 +228,8 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo
TwoLevelTab tab = (tabName != null) ? this.tabSet.getTabByName(tabName) : null;
SubTab subtab = null;
- // if the requested tab is not available for the tabset then select the defaults (firing a new event)
+ // if the requested tab is not available for the tabset then select the default tab/subtab. Fire
+ // an event in order to navigate to the new path
if (tab == null || tab.getDisabled()) {
this.tabSet.setIgnoreSelectEvents(false);
subtab = selectDefaultTabAndSubTab();
@@ -239,39 +240,36 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo
subtab = (subtabName != null) ? tab.getSubTabByName(subtabName) : tab.getDefaultSubTab();
// due to our attempt to perform sticky tabbing we may request an invalid subtab when
- // switching resources. If the requested subtab is not available the select the default subtab for the tab
+ // switching resources. If the requested subtab is not available the select the default subtab
+ // for the tab. Fire an event in order to navigate to the new path.
if (subtab == null || tab.getLayout().isSubTabDisabled(subtab)) {
- subtab = tab.getLayout().getDefaultSubTab();
+ this.tabSet.setIgnoreSelectEvents(false);
+ subtab = selectDefaultSubTab(tab);
+ return;
}
- // select the subTab (this does not fire an event, just sets the subtab)
- tab.getLayout().selectSubTab(subtab);
-
- // the target tab/subtab is now determined. if the currently selected tab is not the target tab then
- // select it now.
- if (!tab.equals(this.tabSet.getSelectedTab())) {
-
- // Fire a tab selection event only if we're at the end of the path. If not then it is assumed that
- // the subtab view is a BookmarkableView and the navigation will continue in that way, below.
- if (viewPath.isEnd()) {
- this.tabSet.setIgnoreSelectEvents(false);
- this.tabSet.selectTab(tab);
- return;
- }
+ // the requested tab/subtab are valid, continue with this path
- this.tabSet.selectTab(tab);
- }
+ // select the tab and subTab (no event fired, we're already dealing with the correct path)
+ this.tabSet.selectTab(tab);
+ // this call adds the subtab canvas as a member of the subtablayout
+ tab.getLayout().selectSubTab(subtab);
- // if the desired tab/subtab are already selected, now we can render the subtab canvas
+ // get the target canvas
Canvas subView = subtab.getCanvas();
+ // if this is a bookmarkable view then further rendering is deferred to its renderView method. This
+ // will set the basePath as well as handle any remaining view items (e.g. id of a selected item in
+ // a subtab that contains a Master-Details view). Otherwise, make sure we perform any required
+ // refresh.
if (subView instanceof BookmarkableView) {
- // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view).
((BookmarkableView) subView).renderView(viewPath);
+
} else if (subView instanceof RefreshableView && subView.isDrawn()) {
// Refresh the data on the subtab, so it's not stale.
Log.debug("Refreshing data for [" + subView.getClass().getName() + "]...");
((RefreshableView) subView).refresh();
+
}
// ensure the tabset is enabled (disabled in onTabSelected), and redraw
@@ -291,6 +289,11 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo
throw new IllegalStateException("No default tab is defined.");
}
+ return selectDefaultSubTab(tab);
+ }
+
+ private SubTab selectDefaultSubTab(TwoLevelTab tab) {
+
SubTab subTab = tab.getDefaultSubTab();
if (subTab == null || tab.getLayout().isSubTabDisabled(subTab)) {
CoreGUI.getErrorHandler().handleError(MSG.view_tabs_invalidSubTab(subTab.getName()));
commit 6773ca8922f29b95bf5b286f2f8a8330493d169e
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Apr 4 14:48:13 2011 -0400
fix bug in checkboxes for implied-read resource perms in permissions editor (https://bugzilla.redhat.com/show_bug.cgi?id=683852)
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 447659b..506850a 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
@@ -20,7 +20,6 @@ package org.rhq.enterprise.gui.coregui.client.admin.roles;
import java.util.ArrayList;
import java.util.EnumSet;
-import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
@@ -73,7 +72,8 @@ public class PermissionsEditor extends LocatableVStack {
this.roleEditView = roleEditView;
this.isReadOnly = isReadOnly;
- this.selectedPermissions = new HashSet<Permission>();
+ // Default permission set
+ this.selectedPermissions = EnumSet.of(Permission.VIEW_RESOURCE);
setWidth("95%");
setHeight100();
@@ -337,7 +337,6 @@ public class PermissionsEditor extends LocatableVStack {
Permission permission = Permission.valueOf(permissionName);
if (permission == Permission.VIEW_RESOURCE) {
event.getItem().setValue(true);
- event.getItem().disable();
String permissionDisplayName = record.getAttribute("displayName");
Message message = new Message(
MSG.view_adminRoles_permissions_readAccessImplied(permissionDisplayName),
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
index 3af67b6..fd2a086 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
@@ -251,6 +251,8 @@ public class RolesDataSource extends RPCDataSource<Role, RoleCriteria> {
public static Set<Permission> toPermissionSet(Record[] permissionRecords) {
Set<Permission> permissions = new HashSet<Permission>();
+ // VIEW_RESOURCE is implied, so make sure it's always in the returned Set.
+ permissions.add(Permission.VIEW_RESOURCE);
for (Record permissionRecord : permissionRecords) {
String permissionName = permissionRecord.getAttribute("name");
Permission permission = Permission.valueOf(permissionName);
commit 25cfc0c27b8a0224dd628acde62722e92915e707
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Apr 4 12:17:46 2011 -0400
on new op schedule page, select mode=calendar and run=now by default and change title of Save button to "Schedule"; fix bug where read-only prop values were displayed as " "
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 69a3c52..b7f1adf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -120,6 +120,7 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
@@ -1261,10 +1262,7 @@ public class ConfigurationEditor extends LocatableVLayout {
// TODO (ips, 03/25/11): We eventually want to use StaticTextItems for read-only PASSWORD props too, but we have
// to wait until we implement masking/unmasking of PASSWORD props at the SLSB layer first.
if (propertyIsReadOnly && propertyDefinitionSimple.getType() != PropertySimpleType.PASSWORD) {
- StaticTextItem staticItem = new StaticTextItem();
- // Property values are user-editable, so escape HTML to prevent an XSS attack.
- staticItem.setOutputAsHTML(true);
- valueItem = staticItem;
+ valueItem = new StaticTextItem();
} else {
List<PropertyDefinitionEnumeration> enumeratedValues = propertyDefinitionSimple.getEnumeratedValues();
if (enumeratedValues != null && !enumeratedValues.isEmpty()) {
@@ -1336,13 +1334,20 @@ public class ConfigurationEditor extends LocatableVLayout {
}
}
- // for more robust and repeatable item locators (not positional) assign a name and title
+ // For more robust and repeatable item locators (not positional), assign a name and a title.
valueItem.setName(propertySimple.getName());
valueItem.setTitle("none");
valueItem.setShowTitle(false);
+
+ String value = propertySimple.getStringValue();
+ if (valueItem instanceof StaticTextItem) {
+ // Property values are user-editable, so escape HTML when displayed as static text, to prevent XSS attacks.
+ value = StringUtility.escapeHtml(value);
+ }
// TODO (ips): I don't think we want to use setDefaultValue(), as it will cause the input to be reset to the
// value if the user clears it.
- valueItem.setDefaultValue(propertySimple.getStringValue());
+ valueItem.setDefaultValue(value);
+
valueItem.setRequired(propertyDefinitionSimple.isRequired());
valueItem.setWidth(220);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
index 13ebe7d..47f9014 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
@@ -190,12 +190,12 @@ public class JobTriggerEditor extends LocatableVLayout {
modeItem.setValueMap(modeValueMap);
modeItem.setVertical(false);
modeItem.setShowTitle(true);
+ modeItem.setValue("calendar");
this.modeForm.setFields(modeItem);
addMember(this.modeForm);
this.calendarModeLayout = new LocatableVLayout(extendLocatorId("CalendarModeLayout"));
- this.calendarModeLayout.setVisible(false);
this.calendarTypeForm = new EnhancedDynamicForm(extendLocatorId("CalendarTypeForm"), this.isReadOnly);
@@ -209,6 +209,7 @@ public class JobTriggerEditor extends LocatableVLayout {
calendarTypeValueMap.put("laterAndRepeat", MSG.widget_jobTriggerEditor_value_laterAndRepeat());
calendarTypeItem.setValueMap(calendarTypeValueMap);
calendarTypeItem.setVertical(false);
+ calendarTypeItem.setValue("now");
this.calendarTypeForm.setFields(calendarTypeItem);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
index 387c4d5..118cec2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
@@ -218,6 +218,13 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
}
@Override
+ protected ButtonBar buildButtonBar() {
+ ButtonBar buttonBar = super.buildButtonBar();
+ buttonBar.getSaveButton().setTitle(MSG.common_button_schedule());
+ return buttonBar;
+ }
+
+ @Override
protected String getTitleFieldName() {
return ResourceOperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME;
}
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 0e5dadc..4a9cfa4 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
@@ -13,7 +13,7 @@ common_buildInfo_gwtVersion = ${gwt.version}
# Button Labels
#--------------
-common_button_ack = Acknowlege
+common_button_ack = Acknowledge
common_button_ack_all = Acknowledge All
common_button_add = Add
common_button_advanced = Advanced...
@@ -37,6 +37,7 @@ common_button_purgeAll = Purge All
common_button_refresh = Refresh
common_button_reset = Reset
common_button_save = Save
+common_button_schedule = Schedule
common_button_search = Search
common_button_set = Set
common_button_showDetails = Show Details...
commit a89e5f870173e6c9df210a97cb39ed12d2fa64f6
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Apr 4 08:17:06 2011 -0400
remove config-updates portlet unless compatible grp.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index 650c9a3..f087202 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -527,6 +527,7 @@ public class DashboardView extends LocatableVLayout {
groupKeyNameMap.remove(GroupMetricsPortlet.KEY);
groupKeyNameMap.remove(GroupOobsPortlet.KEY);
groupKeyNameMap.remove(GroupPkgHistoryPortlet.KEY);
+ groupKeyNameMap.remove(GroupConfigurationUpdatesPortlet.KEY);
} else {
//for compatible may still need to do some pruning.
if (!facets.isEmpty()) {
commit 687c8c170ac700896242e59e2e5d7acc5d301335
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sun Apr 3 15:03:34 2011 -0400
remove old activityView2 tabs.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 86a7c1c..8e8eca7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -64,7 +64,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule.GroupOperationScheduleListView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.ActivityView;
-import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.ActivityView3;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
/**
@@ -91,7 +90,6 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
// subtabs
private SubTab summaryActivity;
- private SubTab summaryActivity2;
private SubTab summaryTimeline;
private SubTab monitorGraphs;
private SubTab monitorTables;
@@ -155,13 +153,9 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
.view_tabs_common_summary()), ImageManager.getResourceIcon(ResourceCategory.SERVICE, Boolean.TRUE));
summaryActivity = new SubTab(summaryTab.extendLocatorId("Activity"), new ViewName("Activity", MSG
.view_tabs_common_activity()), null);
- summaryActivity2 = new SubTab(summaryTab.extendLocatorId("Activity2"), new ViewName("Activity2", MSG
- .view_tabs_common_activity()
- + "2"), null);
summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"), new ViewName("Timeline", MSG
.view_tabs_common_timeline()), null);
- // summaryTab.registerSubTabs(summaryActivity, summaryTimeline);
- summaryTab.registerSubTabs(summaryActivity, summaryActivity2, summaryTimeline);
+ summaryTab.registerSubTabs(summaryActivity, summaryTimeline);
tabs.add(summaryTab);
inventoryTab = new TwoLevelTab(getTabSet().extendLocatorId("Inventory"), new ViewName("Inventory", MSG
@@ -260,12 +254,6 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
return new ActivityView(summaryActivity.extendLocatorId("View"), groupComposite);
}
});
- updateSubTab(this.summaryTab, this.summaryActivity2, true, true, new ViewFactory() {
- @Override
- public Canvas createView() {
- return new ActivityView3(summaryActivity2.extendLocatorId("View2"), groupComposite);
- }
- });
// TODO (ips): Add Timeline subtab?
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 91f617d..8ddb631 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -68,7 +68,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitorin
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleListView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ActivityView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ActivityView3;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -113,7 +112,6 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
private TwoLevelTab contentTab;
private SubTab summaryActivity;
- private SubTab summaryActivity2;
private SubTab summaryTimeline;
private SubTab monitorGraphs;
private SubTab monitorTables;
@@ -153,12 +151,9 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
.view_tabs_common_summary()), ImageManager.getResourceIcon(ResourceCategory.SERVICE, Boolean.TRUE));
summaryActivity = new SubTab(summaryTab.extendLocatorId("Activity"), new ViewName("Activity", MSG
.view_tabs_common_activity()), null);
- summaryActivity2 = new SubTab(summaryTab.extendLocatorId("Activity2"), new ViewName("Activity2", MSG
- .view_tabs_common_activity()
- + "2"), null);
summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"), new ViewName("Timeline", MSG
.view_tabs_common_timeline()), null);
- summaryTab.registerSubTabs(summaryActivity, summaryActivity2, summaryTimeline);
+ summaryTab.registerSubTabs(summaryActivity, summaryTimeline);
tabs.add(summaryTab);
inventoryTab = new TwoLevelTab(getTabSet().extendLocatorId("Inventory"), new ViewName("Inventory", MSG
@@ -285,13 +280,6 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
}
});
- updateSubTab(this.summaryTab, this.summaryActivity2, true, true, new ViewFactory() {
- @Override
- public Canvas createView() {
- return new ActivityView3(summaryActivity2.extendLocatorId("View"), resourceComposite);
- }
- });
-
updateSubTab(this.summaryTab, this.summaryTimeline, true, true, new ViewFactory() {
@Override
public Canvas createView() {
commit 076c5fd6ad952765cab9e92b815c2fddfd723e9b
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sun Apr 3 14:59:22 2011 -0400
update portlet table view message to better reflect criteria filtering.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
index 93fd686..188b2a1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
@@ -247,6 +247,16 @@ public abstract class AbstractRecentAlertsPortlet extends AlertHistoryView imple
super.setupTableInteractions(hasWriteAccess);
}
+ @Override
+ protected void refreshTableInfo() {
+ super.refreshTableInfo();
+ if (getTableInfo() != null) {
+ int count = getListGrid().getSelection().length;
+ getTableInfo().setContents(
+ MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
+ }
+ }
+
public void startRefreshCycle() {
refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer);
}
commit 39f958f9bb1723096d99f54a9834fbe3c103ecc1
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sun Apr 3 13:42:45 2011 -0400
modify default portlet arangements to include config updates where necessary.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index ba91415..650c9a3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -67,11 +67,13 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.form.ColorButtonItem;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupConfigurationUpdatesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOobsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupPkgHistoryPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceBundleDeploymentsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceConfigurationUpdatesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceEventsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceMetricsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceOperationsPortlet;
@@ -495,6 +497,10 @@ public class DashboardView extends LocatableVLayout {
if (!facets.contains(ResourceTypeFacet.EVENT)) {
resourceKeyNameMap.remove(ResourceEventsPortlet.KEY);
}
+ //Configuration related portlets
+ if (!facets.contains(ResourceTypeFacet.CONFIGURATION)) {
+ resourceKeyNameMap.remove(ResourceConfigurationUpdatesPortlet.KEY);
+ }
}
//Bundle related portlet
if (!resource.getResourceType().getCategory().equals(ResourceCategory.PLATFORM)) {
@@ -537,6 +543,10 @@ public class DashboardView extends LocatableVLayout {
if (!facets.contains(ResourceTypeFacet.CONTENT)) {
groupKeyNameMap.remove(GroupPkgHistoryPortlet.KEY);
}
+ //CONFIGURATION related portlets(CONFIGURATION)
+ if (!facets.contains(ResourceTypeFacet.CONFIGURATION)) {
+ groupKeyNameMap.remove(GroupConfigurationUpdatesPortlet.KEY);
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
index dc74fb6..c6b36b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
@@ -56,6 +56,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupConfigurationUpdatesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
@@ -269,6 +270,12 @@ public class ActivityView extends LocatableVLayout implements DashboardContainer
dashboard.addPortlet(ops, colRight, rowRight++);
groupKeyNameMap.remove(GroupOperationsPortlet.KEY);
}
+ if (groupKeyNameMap.containsKey(GroupConfigurationUpdatesPortlet.KEY)) {//operations if available
+ DashboardPortlet ops = new DashboardPortlet(GroupConfigurationUpdatesPortlet.NAME,
+ GroupConfigurationUpdatesPortlet.KEY, 220);
+ dashboard.addPortlet(ops, colRight, rowRight++);
+ groupKeyNameMap.remove(GroupConfigurationUpdatesPortlet.KEY);
+ }
//Fill out left column(typically smaller portlets) then alternate cols with remaining
displayLeft = false;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
index 4cec210..ca227e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
@@ -30,6 +30,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceAlertsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceConfigurationUpdatesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceMetricsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceOperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
@@ -199,6 +200,12 @@ public class ActivityView extends LocatableVLayout implements DashboardContainer
dashboard.addPortlet(ops, colRight, rowRight++);
resKeyNameMap.remove(ResourceOperationsPortlet.KEY);
}
+ if (resKeyNameMap.containsKey(ResourceConfigurationUpdatesPortlet.KEY)) {//configuration if available
+ DashboardPortlet ops = new DashboardPortlet(ResourceConfigurationUpdatesPortlet.NAME,
+ ResourceConfigurationUpdatesPortlet.KEY, 220);
+ dashboard.addPortlet(ops, colRight, rowRight++);
+ resKeyNameMap.remove(ResourceConfigurationUpdatesPortlet.KEY);
+ }
//Fill out left column(typically smaller portlets) then alternate cols with remaining
boolean displayLeft = false;
commit ede97db6398b087d3624b4736e24e531a685e85f
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sun Apr 3 13:21:38 2011 -0400
add resource configuration updates portlet.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 1bd51de..2ccb582 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -49,6 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operation
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems.ProblemResourcesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceAlertsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceBundleDeploymentsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceConfigurationUpdatesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceEventsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceMetricsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceOobsPortlet;
@@ -151,6 +152,8 @@ public class PortletFactory {
ResourcePkgHistoryPortlet.Factory.INSTANCE);
registeredResourcePortletFactoryMap.put(ResourceBundleDeploymentsPortlet.KEY,
ResourceBundleDeploymentsPortlet.Factory.INSTANCE);
+ registeredResourcePortletFactoryMap.put(ResourceConfigurationUpdatesPortlet.KEY,
+ ResourceConfigurationUpdatesPortlet.Factory.INSTANCE);
//register resource portlet names
registeredResourcePortletNameMap = new HashMap<String, String>(registeredResourcePortletFactoryMap.size());
@@ -162,6 +165,8 @@ public class PortletFactory {
registeredResourcePortletNameMap.put(ResourceAlertsPortlet.KEY, ResourceAlertsPortlet.NAME);
registeredResourcePortletNameMap.put(ResourceBundleDeploymentsPortlet.KEY,
ResourceBundleDeploymentsPortlet.NAME);
+ registeredResourcePortletNameMap.put(ResourceConfigurationUpdatesPortlet.KEY,
+ ResourceConfigurationUpdatesPortlet.NAME);
//############## Portlet icon mappings ############################################
//register portlet names
@@ -181,6 +186,7 @@ public class PortletFactory {
registeredPortletIconMap.put(GroupBundleDeploymentsPortlet.KEY, ImageManager.getBundleIcon());
registeredPortletIconMap.put(ResourceBundleDeploymentsPortlet.KEY, ImageManager.getBundleIcon());
registeredPortletIconMap.put(GroupConfigurationUpdatesPortlet.KEY, ImageManager.getConfigureIcon());
+ registeredPortletIconMap.put(ResourceConfigurationUpdatesPortlet.KEY, ImageManager.getConfigureIcon());
}
public static Portlet buildPortlet(String locatorId, PortletWindow portletWindow, DashboardPortlet storedPortlet) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
index 083c43b..f002795 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
@@ -124,11 +124,14 @@ public class GroupConfigurationUpdatesPortlet extends LocatableVLayout implement
//figure out which page we're loading
String currentPage = History.getToken();
String[] elements = currentPage.split("/");
- int currentGroupId = AbstractActivityView.groupIdLookup(currentPage);
- this.groupId = currentGroupId;
+ this.groupId = groupId;
baseViewPath = elements[0];
}
+ public GroupConfigurationUpdatesPortlet(String locatorId) {
+ super(locatorId);
+ }
+
/**Defines layout for the portlet page.
*/
protected void initializeUi() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceConfigurationUpdatesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceConfigurationUpdatesPortlet.java
new file mode 100644
index 0000000..a4a6e67
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceConfigurationUpdatesPortlet.java
@@ -0,0 +1,324 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource;
+
+import java.util.ArrayList;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
+import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupConfigurationUpdatesPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**This portlet allows the end user to customize the Package History display
+ *
+ * @author Simeon Pinder
+ */
+public class ResourceConfigurationUpdatesPortlet extends GroupConfigurationUpdatesPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "ResourceConfigurationUpdates";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_resource_config_updates();
+
+ private int resourceId = -1;
+ private ResourceComposite resourceComposite;
+
+ private ResourceConfigurationHistoryCriteriaView resourceHistoryTable;
+
+ public ResourceConfigurationUpdatesPortlet(String locatorId, int resourceId) {
+ super(locatorId);
+ this.resourceId = resourceId;
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ baseViewPath = elements[0];
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ initializeUi();
+ loadData();
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ /* (non-Javadoc)
+ * TODO: This factory ASSUMES the user is currently navigated to a group detail view, and generates a portlet
+ * for that group. It will fail in other scenarios. This mechanism should be improved such that the
+ * factory method can take an EntityContext explicitly indicating, in this case, the group.
+ * @see org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory#getInstance(java.lang.String)
+ */
+ public final Portlet getInstance(String locatorId) {
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ int currentResourceIdentifier = Integer.valueOf(elements[1]);
+ int resourceId = currentResourceIdentifier;
+
+ return new ResourceConfigurationUpdatesPortlet(locatorId, resourceId);
+ }
+ }
+
+ @Override
+ public void redraw() {
+ super.redraw();
+ loadData();
+ }
+
+ private void loadData() {
+ //populate composite data
+ //locate resourceRef
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.addFilterId(this.resourceId);
+ criteria.fetchResourceConfigurationUpdates(false);
+ criteria.fetchOperationHistories(false);
+
+ //locate the resource
+ GWTServiceLookup.getResourceService().findResourceCompositesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceComposite>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving resource composite for resource [" + resourceId + "]:"
+ + caught.getMessage());
+ currentlyLoading = false;
+ }
+
+ @Override
+ public void onSuccess(PageList<ResourceComposite> results) {
+ if (!results.isEmpty()) {
+ resourceComposite = results.get(0);
+ //instantiate view
+
+ PageControl lastFive = new PageControl(0, 5);
+ ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
+ criteria.setPageControl(lastFive);
+ //TODO: spinder: move this up into the pageControl.
+ criteria.addSortStatus(PageOrdering.DESC);
+ criteria.addFilterResourceIds(resourceId);
+
+ resourceHistoryTable = new ResourceConfigurationHistoryCriteriaView(extendLocatorId("Table"),
+ resourceComposite.getResourcePermission().isConfigureWrite(), resourceId);
+ } else {
+ resourceHistoryTable = new ResourceConfigurationHistoryCriteriaView(extendLocatorId("Table"),
+ resourceComposite.getResourcePermission().isConfigureWrite(), -1);
+ }
+ resourceHistoryTable.setDataSource(new ConfigurationUdpatesCriteriaDataSource(portletConfig));
+ resourceHistoryTable.setShowHeader(false);
+ resourceHistoryTable.setShowFooterRefresh(false);
+
+ //cleanup
+ for (Canvas child : recentConfigurationContent.getChildren()) {
+ child.destroy();
+ }
+ recentConfigurationContent.addChild(resourceHistoryTable);
+ recentConfigurationContent.markForRedraw();
+ currentlyLoading = false;
+ }
+ });
+ }
+
+ class ResourceConfigurationHistoryCriteriaView extends ConfigurationHistoryView {
+
+ public ResourceConfigurationHistoryCriteriaView(String locatorId, boolean hasWritePerm, int resourceId) {
+ super(locatorId, hasWritePerm, resourceId);
+ }
+
+ @Override
+ protected void refreshTableInfo() {
+ super.refreshTableInfo();
+ if (getTableInfo() != null) {
+ int count = getListGrid().getSelection().length;
+ getTableInfo().setContents(
+ MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
+ }
+ }
+
+ /**
+ * Override if you don't want the detailsLinkColumn to have the default link wrapper.
+ * @return the desired CellFormatter.
+ */
+ protected CellFormatter getDetailsLinkColumnCellFormatter() {
+ return new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
+ Integer recordId = getId(record);
+ String detailsUrl = "#" + getBasePath() + "/" + recordId;
+ return SeleniumUtility.getLocatableHref(detailsUrl, value.toString(), null);
+ }
+ };
+ }
+
+ @Override
+ protected String getBasePath() {
+ return "Resource/" + resourceComposite.getResource().getId() + "/Configuration/History";
+ }
+ }
+
+ class ConfigurationUdpatesCriteriaDataSource extends ConfigurationHistoryDataSource {
+
+ public ConfigurationUdpatesCriteriaDataSource(Configuration portletConfig) {
+ super();
+ this.portletConfig = portletConfig;
+ }
+
+ private Configuration portletConfig;
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final ResourceConfigurationUpdateCriteria criteria) {
+ ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
+
+ configurationService.findResourceConfigurationUpdatesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
+
+ @Override
+ public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
+ response.setData(buildRecords(result));
+ //adjust for portlets that restrict result size
+ response.setTotalRows(result.size());
+ processResponse(request.getRequestId(), response);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_group_resConfig_table_failFetch(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @Override
+ protected ResourceConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
+ //initialize criteria
+ ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
+ criteria.addFilterResourceIds(resourceId);
+
+ //initialize to only five for quick queries.
+ PageControl pageControl = new PageControl(0, 5);//default to displaying five
+ //customize query with latest configuration selections
+
+ //retrieve previous settings from portlet config
+ if (portletConfig != null) {
+ // //result sort order
+ // PropertySimple property = portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
+ // if (property != null) {
+ // String currentSetting = property.getStringValue();
+ // if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
+ // criteria.addSortStatus(PageOrdering.DESC);
+ // } else {
+ // criteria.addSortStatus(PageOrdering.ASC);
+ // }
+ // }
+ //result timeframe if enabled
+ PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
+ if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
+ if (property != null) {
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ criteria.addFilterStartTime(Long.valueOf(range[0]));
+ criteria.addFilterEndTime(Long.valueOf(range[1]));
+ }
+ } else {
+ //Simple time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_UNIT);
+ int lastUnits = property.getIntegerValue();
+ ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, Integer
+ .valueOf(lastUnits));
+ criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0)));
+ criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1)));
+ }
+ }
+ }
+
+ //result count
+ property = portletConfig.getSimple(Constant.RESULT_COUNT);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) {
+ pageControl.setPageSize(5);
+ } else {
+ pageControl = new PageControl(0, Integer.valueOf(currentSetting));
+ }
+ }
+ criteria.setPageControl(pageControl);
+
+ //detect operation status filter
+ property = portletConfig.getSimple(Constant.CONFIG_UPDATE_STATUS);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] parsedValues = currentSetting.trim().split(",");
+ if (currentSetting.trim().isEmpty()
+ || parsedValues.length == ConfigurationUpdateStatus.values().length) {
+ //all operation stati assumed
+ } else {
+ ConfigurationUpdateStatus[] updateStatus = new ConfigurationUpdateStatus[parsedValues.length];
+ int indx = 0;
+ for (String priority : parsedValues) {
+ ConfigurationUpdateStatus s = ConfigurationUpdateStatus.valueOf(priority);
+ updateStatus[indx++] = s;
+ }
+ criteria.addFilterStatuses(updateStatus);
+ }
+ }
+ }
+ return criteria;
+ }
+ }
+}
\ No newline at end of file
commit 815e140add7fc76d04157ee5349e560360ee3f68
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Apr 1 11:50:12 2011 -0400
fix invalid ConfigUpdate criteria values when querying on created/ctime.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AbstractConfigurationUpdateCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AbstractConfigurationUpdateCriteria.java
index d01b28a..14ebac6 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AbstractConfigurationUpdateCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AbstractConfigurationUpdateCriteria.java
@@ -38,7 +38,8 @@ import org.rhq.core.domain.util.PageOrdering;
public abstract class AbstractConfigurationUpdateCriteria extends Criteria {
private static final long serialVersionUID = 1L;
- public static final String SORT_FIELD_CTIME = "ctime";
+ public static final String SORT_FIELD_CTIME = "createdTime";
+
public static final String SORT_FIELD_STATUS = "status";
private Integer filterId;
@@ -54,8 +55,8 @@ public abstract class AbstractConfigurationUpdateCriteria extends Criteria {
public AbstractConfigurationUpdateCriteria() {
- filterOverrides.put("startTime", "ctime >= ?");
- filterOverrides.put("endTime", "ctime <= ?");
+ filterOverrides.put("startTime", "createdTime >= ?");
+ filterOverrides.put("endTime", "createdTime <= ?");
filterOverrides.put("statuses", "status IN ( ? )");
sortOverrides.put(SORT_FIELD_STATUS, "status");
commit b986579932d81b59f805c23e20c9038a0075da93
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Apr 1 09:06:38 2011 -0400
Adding missing ConfigUpdates portlet:
i)updating ConfigUpdateCriteria to support ConfigUpdateStatus[] as well
ii)ImageManager changes
iii)missing i18n messages
iv)ConfigUpdateStatus widget for shared portlets.
v)moved HistoryGroupResourceConfigurationTable.Datasource to top level class for better sharing.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AbstractConfigurationUpdateCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AbstractConfigurationUpdateCriteria.java
index bd454d5..d01b28a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AbstractConfigurationUpdateCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AbstractConfigurationUpdateCriteria.java
@@ -22,11 +22,14 @@
*/
package org.rhq.core.domain.criteria;
+import java.util.List;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.util.CriteriaUtils;
import org.rhq.core.domain.util.PageOrdering;
@XmlRootElement
@@ -42,6 +45,7 @@ public abstract class AbstractConfigurationUpdateCriteria extends Criteria {
private Long filterStartTime; // requires overrides
private Long filterEndTime; // requires overrides
private ConfigurationUpdateStatus filterStatus;
+ private List<ConfigurationUpdateStatus> filterStatuses; // requires overrides
private boolean fetchConfiguration;
@@ -52,6 +56,7 @@ public abstract class AbstractConfigurationUpdateCriteria extends Criteria {
filterOverrides.put("startTime", "ctime >= ?");
filterOverrides.put("endTime", "ctime <= ?");
+ filterOverrides.put("statuses", "status IN ( ? )");
sortOverrides.put(SORT_FIELD_STATUS, "status");
}
@@ -72,6 +77,10 @@ public abstract class AbstractConfigurationUpdateCriteria extends Criteria {
this.filterStatus = status;
}
+ public void addFilterStatuses(ConfigurationUpdateStatus... configUpdateStatus) {
+ this.filterStatuses = CriteriaUtils.getListIgnoringNulls(configUpdateStatus);
+ }
+
public void fetchConfiguration(boolean configuration) {
this.fetchConfiguration = configuration;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
index 58346f0..8be3976 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
@@ -485,4 +485,12 @@ public class ImageManager {
public static String getBundleIcon() {
return "subsystems/content/Content_16.png";
}
+
+ public static String getConfigureLargeIcon() {
+ return "subsystems/configure/Configure_24.png";
+ }
+
+ public static String getConfigureIcon() {
+ return "subsystems/configure/Configure_16.png";
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 520a948..1bd51de 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -32,6 +32,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupConfigurationUpdatesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupEventsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOobsPortlet;
@@ -123,6 +124,8 @@ public class PortletFactory {
registeredGroupPortletFactoryMap.put(GroupPkgHistoryPortlet.KEY, GroupPkgHistoryPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupBundleDeploymentsPortlet.KEY,
GroupBundleDeploymentsPortlet.Factory.INSTANCE);
+ registeredGroupPortletFactoryMap.put(GroupConfigurationUpdatesPortlet.KEY,
+ GroupConfigurationUpdatesPortlet.Factory.INSTANCE);
//register group portlet names
registeredGroupPortletNameMap = new HashMap<String, String>(registeredGroupPortletFactoryMap.size());
@@ -133,6 +136,7 @@ public class PortletFactory {
registeredGroupPortletNameMap.put(GroupOperationsPortlet.KEY, GroupOperationsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupPkgHistoryPortlet.KEY, GroupPkgHistoryPortlet.NAME);
registeredGroupPortletNameMap.put(GroupBundleDeploymentsPortlet.KEY, GroupBundleDeploymentsPortlet.NAME);
+ registeredGroupPortletNameMap.put(GroupConfigurationUpdatesPortlet.KEY, GroupConfigurationUpdatesPortlet.NAME);
//############## Resource Activity Dashboard ############################################
//defines mapping for Group Activity Dashboard
@@ -176,6 +180,7 @@ public class PortletFactory {
registeredPortletIconMap.put(ResourcePkgHistoryPortlet.KEY, ImageManager.getActivityPackageIcon());
registeredPortletIconMap.put(GroupBundleDeploymentsPortlet.KEY, ImageManager.getBundleIcon());
registeredPortletIconMap.put(ResourceBundleDeploymentsPortlet.KEY, ImageManager.getBundleIcon());
+ registeredPortletIconMap.put(GroupConfigurationUpdatesPortlet.KEY, ImageManager.getConfigureIcon());
}
public static Portlet buildPortlet(String locatorId, PortletWindow portletWindow, DashboardPortlet storedPortlet) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
index cea94a9..b7488da 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.widgets.form.fields.SelectItem;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
@@ -68,6 +69,8 @@ public class PortletConfigurationEditorComponent {
String CUSTOM_REFRESH = "CUSTOM_REFRESH";
String OPERATION_STATUS = "OPERATION_STATUS";
String OPERATION_STATUS_DEFAULT = "";//empty
+ String CONFIG_UPDATE_STATUS = "CONFIG_UPDATE_STATUS";
+ String CONFIG_UPDATE_STATUS_DEFAULT = "";
}
//configuration map initialization
@@ -90,6 +93,8 @@ public class PortletConfigurationEditorComponent {
CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_UNIT, Constant.METRIC_RANGE_UNIT_DEFAULT);
//operation status, if empty initialize to "" i.e. all stati
CONFIG_PROPERTY_INITIALIZATION.put(Constant.OPERATION_STATUS, Constant.OPERATION_STATUS_DEFAULT);
+ //config update status, if empty initialize to "" i.e. all stati
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.CONFIG_UPDATE_STATUS, Constant.CONFIG_UPDATE_STATUS_DEFAULT);
}
/* Single select combobox for number of items to display on the dashboard
@@ -99,9 +104,9 @@ public class PortletConfigurationEditorComponent {
public static SelectItem getResultCountEditor(Configuration portletConfig) {
final SelectItem maximumResultsComboBox = new SelectItem(Constant.RESULT_COUNT);
- maximumResultsComboBox.setTitle("Results Count");
+ maximumResultsComboBox.setTitle(MSG.common_title_results_count());
maximumResultsComboBox.setWrapTitle(false);
- maximumResultsComboBox.setTooltip("<nobr><b> " + "Displays N results with alerts" + "</b></nobr>");
+ maximumResultsComboBox.setTooltip("<nobr><b> " + MSG.common_title_results_count_tooltip() + "</b></nobr>");
//spinder 9/3/10: the following is required workaround to disable editability of combobox.
maximumResultsComboBox.setType("selection");
//set width of dropdown display region
@@ -176,9 +181,9 @@ public class PortletConfigurationEditorComponent {
* @return Populated selectItem instance.
*/
public static SelectItem getResulSortOrderEditor(Configuration portletConfig) {
- SelectItem sortPrioritySelection = new SelectItem(Constant.RESULT_SORT_PRIORITY, "Sort Order");
+ SelectItem sortPrioritySelection = new SelectItem(Constant.RESULT_SORT_PRIORITY, MSG.common_title_sort_order());
sortPrioritySelection.setWrapTitle(false);
- sortPrioritySelection.setTooltip("Sets sort order for results.");
+ sortPrioritySelection.setTooltip(MSG.common_title_sort_order_tooltip());
LinkedHashMap<String, String> priorities = new LinkedHashMap<String, String>(2);
priorities.put(PageOrdering.ASC.name(), "Ascending");
priorities.put(PageOrdering.DESC.name(), "Descending");
@@ -213,7 +218,7 @@ public class PortletConfigurationEditorComponent {
}
public static SelectItem getOperationStatusEditor(Configuration portletConfig) {
- SelectItem priorityFilter = new SelectItem(Constant.OPERATION_STATUS, "Operation Status");
+ SelectItem priorityFilter = new SelectItem(Constant.OPERATION_STATUS, MSG.common_title_operation_status());
priorityFilter.setWrapTitle(false);
priorityFilter.setWidth(325);
priorityFilter.setMultiple(true);
@@ -286,4 +291,82 @@ public class PortletConfigurationEditorComponent {
return priorityFilter;
}
+ public static SelectItem getConfigurationUpdateStatusEditor(Configuration portletConfig) {
+ SelectItem priorityFilter = new SelectItem(Constant.CONFIG_UPDATE_STATUS, MSG
+ .common_title_config_update_status());
+ priorityFilter.setWrapTitle(false);
+ priorityFilter.setWidth(335);
+ priorityFilter.setMultiple(true);
+ priorityFilter.setMultipleAppearance(MultipleAppearance.PICKLIST);
+
+ LinkedHashMap<String, String> stati = new LinkedHashMap<String, String>(4);
+ stati.put(ConfigurationUpdateStatus.SUCCESS.name(), MSG.common_status_success());
+ stati.put(ConfigurationUpdateStatus.INPROGRESS.name(), MSG.common_status_inprogress());
+ stati.put(ConfigurationUpdateStatus.NOCHANGE.name(), MSG.common_status_nochange());
+ stati.put(ConfigurationUpdateStatus.FAILURE.name(), MSG.common_status_failed());
+
+ LinkedHashMap<String, String> statusIcons = new LinkedHashMap<String, String>(3);
+ statusIcons.put(ConfigurationUpdateStatus.SUCCESS.name(), ImageManager
+ .getResourceConfigurationIcon(ConfigurationUpdateStatus.SUCCESS));
+ statusIcons.put(ConfigurationUpdateStatus.INPROGRESS.name(), ImageManager
+ .getResourceConfigurationIcon(ConfigurationUpdateStatus.INPROGRESS));
+ statusIcons.put(ConfigurationUpdateStatus.NOCHANGE.name(), ImageManager
+ .getResourceConfigurationIcon(ConfigurationUpdateStatus.NOCHANGE));
+ statusIcons.put(ConfigurationUpdateStatus.FAILURE.name(), ImageManager
+ .getResourceConfigurationIcon(ConfigurationUpdateStatus.FAILURE));
+ priorityFilter.setValueMap(stati);
+ priorityFilter.setValueIcons(statusIcons);
+ //reload current settings if they exist, otherwise enable all.
+ String currentValue = portletConfig.getSimple(Constant.CONFIG_UPDATE_STATUS).getStringValue();
+ if (currentValue.isEmpty() || currentValue.split(",").length == ConfigurationUpdateStatus.values().length) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.SUCCESS.name(), ConfigurationUpdateStatus.INPROGRESS
+ .name(), ConfigurationUpdateStatus.NOCHANGE.name(), ConfigurationUpdateStatus.FAILURE.name());
+ } else {
+ //spinder:3/4/11 doing this nonsense due to some weird smartgwt issue with SelectItem in VLayout.
+ if (currentValue.equalsIgnoreCase(ConfigurationUpdateStatus.SUCCESS.name())) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.SUCCESS.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,INPROGRESS,NOCHANGE,FAILURE")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.SUCCESS.name(), ConfigurationUpdateStatus.INPROGRESS
+ .name(), ConfigurationUpdateStatus.NOCHANGE.name(), ConfigurationUpdateStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,INPROGRESS,NOCHANGE")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.SUCCESS.name(), ConfigurationUpdateStatus.INPROGRESS
+ .name(), ConfigurationUpdateStatus.NOCHANGE.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,INPROGRESS,FAILURE")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.SUCCESS.name(), ConfigurationUpdateStatus.INPROGRESS
+ .name(), ConfigurationUpdateStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,INPROGRESS")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.SUCCESS.name(), ConfigurationUpdateStatus.INPROGRESS
+ .name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,NOCHANGE,FAILURE")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.SUCCESS.name(), ConfigurationUpdateStatus.NOCHANGE
+ .name(), ConfigurationUpdateStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,NOCHANGE")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.SUCCESS.name(), ConfigurationUpdateStatus.NOCHANGE
+ .name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,FAILURE")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.SUCCESS.name(), ConfigurationUpdateStatus.FAILURE
+ .name());
+ } else if (currentValue.equalsIgnoreCase("INPROGRESS")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.INPROGRESS.name());
+ } else if (currentValue.equalsIgnoreCase("INPROGRESS,NOCHANGE,FAILURE")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.INPROGRESS.name(),
+ ConfigurationUpdateStatus.NOCHANGE.name(), ConfigurationUpdateStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("INPROGRESS,NOCHANGE")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.INPROGRESS.name(),
+ ConfigurationUpdateStatus.NOCHANGE.name());
+ } else if (currentValue.equalsIgnoreCase("INPROGRESS,FAILURE")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.INPROGRESS.name(), ConfigurationUpdateStatus.FAILURE
+ .name());
+ } else if (currentValue.equalsIgnoreCase("NOCHANGE")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.NOCHANGE.name());
+ } else if (currentValue.equalsIgnoreCase("NOCHANGE,FAILURE")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.NOCHANGE.name(), ConfigurationUpdateStatus.FAILURE
+ .name());
+ } else if (currentValue.equalsIgnoreCase("FAILURE")) {
+ priorityFilter.setValues(ConfigurationUpdateStatus.FAILURE.name());
+ }
+ }
+ return priorityFilter;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
new file mode 100644
index 0000000..083c43b
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
@@ -0,0 +1,548 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
+import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate;
+import org.rhq.core.domain.criteria.GroupResourceConfigurationUpdateCriteria;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupDetailView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.configuration.GroupResourceConfigurationDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.configuration.HistoryGroupResourceConfigurationTable;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Simeon Pinder
+ */
+public class GroupConfigurationUpdatesPortlet extends LocatableVLayout implements CustomSettingsPortlet,
+ AutoRefreshPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupConfigurationUpdates";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_group_config_updates();
+
+ private int groupId = -1;
+ protected LocatableCanvas recentConfigurationContent = new LocatableCanvas(
+ extendLocatorId("RecentConfigurationUpdates"));
+
+ public static final String ID = "id";
+
+ //defines the list of configuration elements to load/persist for this portlet
+ protected static List<String> CONFIG_INCLUDE = new ArrayList<String>();
+ static {
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_BEGIN_END_FLAG);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_ENABLE);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_LASTN);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_UNIT);
+ CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
+ CONFIG_INCLUDE.add(Constant.CONFIG_UPDATE_STATUS);
+ // CONFIG_INCLUDE.add(Constant.RESULT_SORT_ORDER);
+ }
+
+ // set on initial configuration, the window for this portlet view.
+ protected PortletWindow portletWindow;
+
+ //instance ui widgets
+ protected Canvas containerCanvas;
+
+ protected Timer refreshTimer;
+ protected DashboardPortlet storedPortlet;
+ protected Configuration portletConfig;
+ private ResourceGroupComposite groupComposite;
+ protected boolean portletConfigInitialized = false;
+ protected boolean currentlyLoading = false;
+ protected String baseViewPath = "";
+ private HistoryGroupResourceConfigurationTable groupHistoryTable;
+
+ protected static HashMap<String, String> updatedMapping = new HashMap<String, String>();
+ static {
+ updatedMapping.putAll(PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION);
+ }
+
+ public GroupConfigurationUpdatesPortlet(String locatorId, int groupId) {
+ super(locatorId);
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ int currentGroupId = AbstractActivityView.groupIdLookup(currentPage);
+ this.groupId = currentGroupId;
+ baseViewPath = elements[0];
+ }
+
+ /**Defines layout for the portlet page.
+ */
+ protected void initializeUi() {
+ setHeight("*");
+ setWidth100();
+
+ //tell canvas to fill it's component
+ recentConfigurationContent.setHeight100();
+ addMember(recentConfigurationContent);
+ markForRedraw();
+ }
+
+ /** Responsible for initialization and lazy configuration of the portlet values
+ */
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ //populate portlet configuration details
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+ this.storedPortlet = storedPortlet;
+ portletConfig = storedPortlet.getConfiguration();
+
+ //lazy init any elements not yet configured.
+ for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
+ if ((portletConfig.getSimple(key) == null) && CONFIG_INCLUDE.contains(key)) {
+ portletConfig.put(new PropertySimple(key,
+ PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key)));
+ }
+ }
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_config_updates());
+ }
+
+ @Override
+ public DynamicForm getCustomSettingsForm() {
+ LocatableDynamicForm customSettings = new LocatableDynamicForm(extendLocatorId("customSettings"));
+ LocatableVLayout page = new LocatableVLayout(customSettings.extendLocatorId("page"));
+ //build editor form container
+ final LocatableDynamicForm form = new LocatableDynamicForm(page.extendLocatorId("alert-filter"));
+ form.setMargin(5);
+
+ //add sort priority selector
+ // final SelectItem resultSortSelector = PortletConfigurationEditorComponent
+ // .getResulSortOrderEditor(portletConfig);
+ //add result status selector
+ final SelectItem resultStatusSelector = PortletConfigurationEditorComponent
+ .getConfigurationUpdateStatusEditor(portletConfig);
+
+ //add result count selector
+ final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
+
+ //add range selector
+ final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent
+ .getMeasurementRangeEditor(portletConfig);
+
+ // form.setItems(alertPrioritySelector, resultCountSelector);
+ form.setItems(resultStatusSelector, resultCountSelector);
+
+ //submit handler
+ customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
+
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+ String selectedValue;
+
+ // //result sort order
+ // selectedValue = resultSortSelector.getValue().toString();
+ // if ((selectedValue.trim().isEmpty()) || (selectedValue.equalsIgnoreCase(PageOrdering.DESC.name()))) {//then desc
+ // portletConfig.put(new PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.DESC));
+ // } else {
+ // portletConfig.put(new PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.ASC));
+ // }
+ //config status
+ portletConfig = AbstractActivityView.saveConfigUpdateStatusSelectorSettings(resultStatusSelector,
+ portletConfig);
+
+ //result count
+ portletConfig = AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
+
+ //time range settings
+ portletConfig = AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
+ portletConfig);
+
+ //persist and reload portlet
+ storedPortlet.setConfiguration(portletConfig);
+ configure(portletWindow, storedPortlet);
+ // refresh();
+ redraw();
+ }
+ });
+ form.markForRedraw();
+ page.addMember(measurementRangeEditor);
+ page.addMember(form);
+ customSettings.addChild(page);
+ return customSettings;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ /* (non-Javadoc)
+ * TODO: This factory ASSUMES the user is currently navigated to a group detail view, and generates a portlet
+ * for that group. It will fail in other scenarios. This mechanism should be improved such that the
+ * factory method can take an EntityContext explicitly indicating, in this case, the group.
+ * @see org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory#getInstance(java.lang.String)
+ */
+ public final Portlet getInstance(String locatorId) {
+
+ String currentPage = History.getToken();
+ int groupId = -1;
+ String[] elements = currentPage.split("/");
+ // process for groups and auto groups Ex. ResourceGroup/10111 or ResourceGroup/AutoCluster/10321
+ try {
+ groupId = Integer.valueOf(elements[1]);
+ } catch (NumberFormatException nfe) {
+ groupId = Integer.valueOf(elements[2]);
+ }
+
+ return new GroupConfigurationUpdatesPortlet(locatorId, groupId);
+ }
+ }
+
+ @Override
+ public void startRefreshCycle() {
+ //current setting
+ final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+
+ //cancel any existing timer
+ if (refreshTimer != null) {
+ refreshTimer.cancel();
+ }
+
+ if (refreshInterval >= MeasurementUtility.MINUTES) {
+
+ refreshTimer = new Timer() {
+ public void run() {
+ redraw();
+ }
+ };
+
+ refreshTimer.scheduleRepeating(refreshInterval);
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ if (refreshTimer != null) {
+ refreshTimer.cancel();
+ }
+
+ super.onDestroy();
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ //disable the refresh timer for this run
+ currentlyLoading = true;
+ initializeUi();
+ loadData();
+ }
+
+ // @Override
+ // protected void refreshTableInfo() {
+ // super.refreshTableInfo();
+ // if (getTableInfo() != null) {
+ // int count = getListGrid().getSelection().length;
+ // getTableInfo().setContents(
+ // MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
+ // }
+ // }
+
+ @Override
+ public boolean isRefreshing() {
+ return this.currentlyLoading;
+ }
+
+ protected void setRefreshing(boolean currentlyRefreshing) {
+ this.currentlyLoading = currentlyRefreshing;
+ }
+
+ @Override
+ public void redraw() {
+ super.redraw();
+ loadData();
+ }
+
+ private void loadData() {
+ //populate composite data
+ //locate resourceGroupRef
+ ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.addFilterId(this.groupId);
+ criteria.fetchConfigurationUpdates(false);
+ criteria.fetchExplicitResources(false);
+ criteria.fetchGroupDefinition(false);
+ criteria.fetchOperationHistories(false);
+
+ // for autoclusters and autogroups we need to add more criteria
+ final boolean isAutoCluster = isAutoCluster();
+ final boolean isAutoGroup = isAutoGroup();
+ if (isAutoCluster) {
+ criteria.addFilterVisible(false);
+ } else if (isAutoGroup) {
+ criteria.addFilterVisible(false);
+ criteria.addFilterPrivate(true);
+ }
+
+ //locate the resource group
+ GWTServiceLookup.getResourceGroupService().findResourceGroupCompositesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceGroupComposite>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving resource group composite for group [" + groupId + "]:"
+ + caught.getMessage());
+ currentlyLoading = false;
+ }
+
+ @Override
+ public void onSuccess(PageList<ResourceGroupComposite> results) {
+ if (!results.isEmpty()) {
+ groupComposite = results.get(0);
+ //instantiate view
+
+ PageControl lastFive = new PageControl(0, 5);
+ GroupResourceConfigurationUpdateCriteria criteria = new GroupResourceConfigurationUpdateCriteria();
+ criteria.setPageControl(lastFive);
+ //TODO: spinder: move this up into the pageControl.
+ criteria.addSortStatus(PageOrdering.DESC);
+ List<Integer> filterResourceGroupIds = new ArrayList<Integer>();
+ filterResourceGroupIds.add(groupId);
+ criteria.addFilterResourceGroupIds(filterResourceGroupIds);
+
+ groupHistoryTable = new HistoryGroupResourceConfigurationTable(extendLocatorId("Table"),
+ groupComposite);
+ // groupHistoryTable.setDataSource(new GroupConfigurationUdpatesCriteriaDataSource(portletConfig,
+ // groupId));
+ // groupHistoryTable.setShowHeader(false);
+ // groupHistoryTable.setShowFooterRefresh(false);
+ } else {
+ //TODO: spinder fix for empties
+ // Criteria criteria = new Criteria();
+ ResourceGroup emptyGroup = new ResourceGroup("");
+ emptyGroup.setId(-1);
+ Long zero = new Long(0);
+ groupComposite = new ResourceGroupComposite(zero, zero, zero, zero, emptyGroup);
+ // groupOperations = new GroupOperationsCriteriaHistoryListView(locatorId,
+ // new GroupOperationsCriteriaDataSource(portletConfig), null, criteria, groupComposite);
+ groupHistoryTable = new HistoryGroupResourceConfigurationTable(extendLocatorId("Table"),
+ groupComposite);
+ // groupHistoryTable.setDataSource(new GroupConfigurationUdpatesCriteriaDataSource(portletConfig,
+ // groupId));
+ // groupHistoryTable.setShowHeader(false);
+ // groupHistoryTable.setShowFooterRefresh(false);
+ }
+
+ groupHistoryTable.setDataSource(new GroupConfigurationUdpatesCriteriaDataSource(portletConfig,
+ groupId));
+ groupHistoryTable.setShowHeader(false);
+ groupHistoryTable.setShowFooterRefresh(false);
+
+ //cleanup
+ for (Canvas child : recentConfigurationContent.getChildren()) {
+ child.destroy();
+ }
+ recentConfigurationContent.addChild(groupHistoryTable);
+ recentConfigurationContent.markForRedraw();
+ currentlyLoading = false;
+ }
+ });
+ }
+
+ private boolean isAutoGroup() {
+ return ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH.equals(getBaseViewPath());
+ }
+
+ private boolean isAutoCluster() {
+ return ResourceGroupDetailView.AUTO_CLUSTER_VIEW_PATH.equals(getBaseViewPath());
+ }
+
+ public String getBaseViewPath() {
+ return baseViewPath;
+ }
+
+ class GroupConfigurationUdpatesCriteriaDataSource extends GroupResourceConfigurationDataSource {
+
+ public GroupConfigurationUdpatesCriteriaDataSource(Configuration portletConfig, int groupId) {
+ super(groupId);
+ this.portletConfig = portletConfig;
+ this.groupId = groupId;
+ }
+
+ private int groupId;
+ private Configuration portletConfig;
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final GroupResourceConfigurationUpdateCriteria criteria) {
+ ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
+
+ configurationService.findGroupResourceConfigurationUpdatesByCriteria(criteria,
+ new AsyncCallback<PageList<GroupResourceConfigurationUpdate>>() {
+
+ @Override
+ public void onSuccess(PageList<GroupResourceConfigurationUpdate> result) {
+ response.setData(buildRecords(result));
+ //adjust for portlets that restrict result size
+ response.setTotalRows(result.size());
+ processResponse(request.getRequestId(), response);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_group_resConfig_table_failFetch(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @Override
+ protected GroupResourceConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
+ //initialize criteria
+ GroupResourceConfigurationUpdateCriteria criteria = new GroupResourceConfigurationUpdateCriteria();
+
+ criteria.addFilterResourceGroupIds(Arrays.asList(groupId));
+
+ //initialize to only five for quick queries.
+ PageControl pageControl = new PageControl(0, 5);//default to displaying five
+ //customize query with latest configuration selections
+
+ //retrieve previous settings from portlet config
+ if (portletConfig != null) {
+ // //result sort order
+ // PropertySimple property = portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
+ // if (property != null) {
+ // String currentSetting = property.getStringValue();
+ // if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
+ // criteria.addSortStatus(PageOrdering.DESC);
+ // } else {
+ // criteria.addSortStatus(PageOrdering.ASC);
+ // }
+ // }
+ //result timeframe if enabled
+ PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
+ if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
+ if (property != null) {
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ criteria.addFilterStartTime(Long.valueOf(range[0]));
+ criteria.addFilterEndTime(Long.valueOf(range[1]));
+ }
+ } else {
+ //Simple time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_UNIT);
+ int lastUnits = property.getIntegerValue();
+ ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, Integer
+ .valueOf(lastUnits));
+ criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0)));
+ criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1)));
+ }
+ }
+ }
+
+ //result count
+ property = portletConfig.getSimple(Constant.RESULT_COUNT);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) {
+ pageControl.setPageSize(5);
+ } else {
+ pageControl = new PageControl(0, Integer.valueOf(currentSetting));
+ }
+ }
+ criteria.setPageControl(pageControl);
+
+ //detect operation status filter
+ property = portletConfig.getSimple(Constant.CONFIG_UPDATE_STATUS);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] parsedValues = currentSetting.trim().split(",");
+ if (currentSetting.trim().isEmpty()
+ || parsedValues.length == ConfigurationUpdateStatus.values().length) {
+ //all operation stati assumed
+ } else {
+ ConfigurationUpdateStatus[] updateStatus = new ConfigurationUpdateStatus[parsedValues.length];
+ int indx = 0;
+ for (String priority : parsedValues) {
+ ConfigurationUpdateStatus s = ConfigurationUpdateStatus.valueOf(priority);
+ updateStatus[indx++] = s;
+ }
+ criteria.addFilterStatuses(updateStatus);
+ }
+ }
+ }
+ return criteria;
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
index 5fec813..0ee3647 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
@@ -41,6 +41,7 @@ import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.measurement.MeasurementDefinition;
@@ -507,6 +508,25 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
/** Takes the current value of the widget and persists it into the configuration object passed in.
*
+ * @param configUpdateStatusSelector
+ * @param portletConfig
+ * returns populated configuration object.
+ */
+ public static Configuration saveConfigUpdateStatusSelectorSettings(final SelectItem configStatusSelector,
+ final Configuration portletConfig) {
+ String selectedValue;
+ selectedValue = configStatusSelector.getValue().toString();
+ if ((selectedValue.trim().isEmpty())
+ || (selectedValue.split(",").length == ConfigurationUpdateStatus.values().length)) {//then no operation status specified
+ portletConfig.put(new PropertySimple(Constant.CONFIG_UPDATE_STATUS, Constant.CONFIG_UPDATE_STATUS_DEFAULT));
+ } else {//some subset of available configUpdate statuses will be used
+ portletConfig.put(new PropertySimple(Constant.CONFIG_UPDATE_STATUS, selectedValue));
+ }
+ return portletConfig;
+ }
+
+ /** Takes the current value of the widget and persists it into the configuration object passed in.
+ *
* @param measurementRangeEditor
* @param portletConfig
* returns populated configuration object.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationDataSource.java
new file mode 100644
index 0000000..770753a
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationDataSource.java
@@ -0,0 +1,97 @@
+package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.configuration;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate;
+import org.rhq.core.domain.criteria.GroupResourceConfigurationUpdateCriteria;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * DataSource implementation for HistoryGroupResourceConfigurationTable.
+ *
+ * @author John Mazzitelli
+ * @author Simeon Pinder
+ */
+public class GroupResourceConfigurationDataSource extends
+ RPCDataSource<GroupResourceConfigurationUpdate, GroupResourceConfigurationUpdateCriteria> {
+
+ private int groupId;
+
+ public class Field {
+ public static final String ID = "id";
+ public static final String DATECREATED = "dateCreated";
+ public static final String LASTUPDATED = "lastUpdated";
+ public static final String STATUS = "status";
+ public static final String USER = "user";
+ public static final String OBJECT = "object";
+ }
+
+ public GroupResourceConfigurationDataSource(int groupId) {
+ super();
+ this.groupId = groupId;
+ }
+
+ @Override
+ public GroupResourceConfigurationUpdate copyValues(Record from) {
+ return (GroupResourceConfigurationUpdate) from.getAttributeAsObject(Field.OBJECT);
+ }
+
+ @Override
+ public ListGridRecord copyValues(GroupResourceConfigurationUpdate from) {
+ ListGridRecord record = new ListGridRecord();
+
+ record.setAttribute(Field.ID, from.getId());
+ record.setAttribute(Field.DATECREATED, new Date(from.getCreatedTime()));
+ record.setAttribute(Field.LASTUPDATED, new Date(from.getModifiedTime()));
+ record.setAttribute(Field.STATUS, from.getStatus().name());
+ record.setAttribute(Field.USER, from.getSubjectName());
+
+ record.setAttribute(Field.OBJECT, from);
+
+ return record;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final GroupResourceConfigurationUpdateCriteria criteria) {
+ ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
+
+ configurationService.findGroupResourceConfigurationUpdatesByCriteria(criteria,
+ new AsyncCallback<PageList<GroupResourceConfigurationUpdate>>() {
+
+ @Override
+ public void onSuccess(PageList<GroupResourceConfigurationUpdate> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_group_resConfig_table_failFetch(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @Override
+ protected GroupResourceConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
+ GroupResourceConfigurationUpdateCriteria criteria = new GroupResourceConfigurationUpdateCriteria();
+ ArrayList<Integer> groupList = new ArrayList<Integer>(1);
+ groupList.add(this.groupId);
+ criteria.addFilterResourceGroupIds(groupList);
+ return criteria;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java
index 35be43c..ae52f4d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java
@@ -18,14 +18,10 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.configuration;
-import java.util.ArrayList;
-import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.grid.HoverCustomizer;
@@ -37,12 +33,9 @@ import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import org.rhq.core.domain.configuration.AbstractConfigurationUpdate;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate;
-import org.rhq.core.domain.criteria.GroupResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
-import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
@@ -53,7 +46,6 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablem
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
/**
@@ -61,7 +53,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
*
* @author John Mazzitelli
*/
-public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupResourceConfigurationTable.DataSource> {
+public class HistoryGroupResourceConfigurationTable extends Table<GroupResourceConfigurationDataSource> {
private final ResourceGroup group;
private final ResourcePermission groupPerms;
@@ -70,16 +62,21 @@ public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupRe
this.group = groupComposite.getResourceGroup();
this.groupPerms = groupComposite.getResourcePermission();
- setDataSource(new DataSource());
+ setDataSource(new GroupResourceConfigurationDataSource(this.group.getId()));
}
@Override
protected void configureTable() {
- ListGridField fieldId = new ListGridField(DataSource.Field.ID, MSG.common_title_version());
- ListGridField fieldDateCreated = new ListGridField(DataSource.Field.DATECREATED, MSG.common_title_dateCreated());
- ListGridField fieldLastUpdated = new ListGridField(DataSource.Field.LASTUPDATED, MSG.common_title_lastUpdated());
- ListGridField fieldStatus = new ListGridField(DataSource.Field.STATUS, MSG.common_title_status());
- ListGridField fieldUser = new ListGridField(DataSource.Field.USER, MSG.common_title_user());
+ ListGridField fieldId = new ListGridField(GroupResourceConfigurationDataSource.Field.ID, MSG
+ .common_title_version());
+ ListGridField fieldDateCreated = new ListGridField(GroupResourceConfigurationDataSource.Field.DATECREATED, MSG
+ .common_title_dateCreated());
+ ListGridField fieldLastUpdated = new ListGridField(GroupResourceConfigurationDataSource.Field.LASTUPDATED, MSG
+ .common_title_lastUpdated());
+ ListGridField fieldStatus = new ListGridField(GroupResourceConfigurationDataSource.Field.STATUS, MSG
+ .common_title_status());
+ ListGridField fieldUser = new ListGridField(GroupResourceConfigurationDataSource.Field.USER, MSG
+ .common_title_user());
TimestampCellFormatter.prepareDateField(fieldDateCreated);
TimestampCellFormatter.prepareDateField(fieldLastUpdated);
@@ -135,7 +132,7 @@ public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupRe
Integer[] updateIds = new Integer[selection.length];
int i = 0;
for (ListGridRecord record : selection) {
- updateIds[i++] = record.getAttributeAsInt(DataSource.Field.ID);
+ updateIds[i++] = record.getAttributeAsInt(GroupResourceConfigurationDataSource.Field.ID);
}
service.deleteGroupResourceConfigurationUpdate(groupId, updateIds, new AsyncCallback<Void>() {
@@ -163,7 +160,7 @@ public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupRe
public void executeAction(ListGridRecord[] selection, Object actionValue) {
CoreGUI.goToView(LinkManager.getGroupResourceConfigurationUpdateHistoryLink(
HistoryGroupResourceConfigurationTable.this.group.getId(), null)
- + "/" + selection[0].getAttribute(DataSource.Field.ID) + "/Settings");
+ + "/" + selection[0].getAttribute(GroupResourceConfigurationDataSource.Field.ID) + "/Settings");
}
});
@@ -173,7 +170,7 @@ public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupRe
public void executeAction(ListGridRecord[] selection, Object actionValue) {
CoreGUI.goToView(LinkManager.getGroupResourceConfigurationUpdateHistoryLink(
HistoryGroupResourceConfigurationTable.this.group.getId(), null)
- + "/" + selection[0].getAttribute(DataSource.Field.ID) + "/Members");
+ + "/" + selection[0].getAttribute(GroupResourceConfigurationDataSource.Field.ID) + "/Members");
}
});
@@ -182,7 +179,7 @@ public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupRe
private String getStatusHtmlString(Record record) {
String html = null;
AbstractConfigurationUpdate obj = (AbstractConfigurationUpdate) record
- .getAttributeAsObject(DataSource.Field.OBJECT);
+ .getAttributeAsObject(GroupResourceConfigurationDataSource.Field.OBJECT);
switch (obj.getStatus()) {
case SUCCESS: {
html = MSG.view_group_resConfig_table_statusSuccess();
@@ -217,69 +214,4 @@ public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupRe
}
return html;
}
-
- class DataSource extends RPCDataSource<GroupResourceConfigurationUpdate, GroupResourceConfigurationUpdateCriteria> {
-
- public class Field {
- public static final String ID = "id";
- public static final String DATECREATED = "dateCreated";
- public static final String LASTUPDATED = "lastUpdated";
- public static final String STATUS = "status";
- public static final String USER = "user";
- public static final String OBJECT = "object";
- }
-
- @Override
- public GroupResourceConfigurationUpdate copyValues(Record from) {
- return (GroupResourceConfigurationUpdate) from.getAttributeAsObject(DataSource.Field.OBJECT);
- }
-
- @Override
- public ListGridRecord copyValues(GroupResourceConfigurationUpdate from) {
- ListGridRecord record = new ListGridRecord();
-
- record.setAttribute(Field.ID, from.getId());
- record.setAttribute(Field.DATECREATED, new Date(from.getCreatedTime()));
- record.setAttribute(Field.LASTUPDATED, new Date(from.getModifiedTime()));
- record.setAttribute(Field.STATUS, from.getStatus().name());
- record.setAttribute(Field.USER, from.getSubjectName());
-
- record.setAttribute(Field.OBJECT, from);
-
- return record;
- }
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response,
- final GroupResourceConfigurationUpdateCriteria criteria) {
- ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
-
- configurationService.findGroupResourceConfigurationUpdatesByCriteria(criteria,
- new AsyncCallback<PageList<GroupResourceConfigurationUpdate>>() {
-
- @Override
- public void onSuccess(PageList<GroupResourceConfigurationUpdate> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_group_resConfig_table_failFetch(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- protected GroupResourceConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
- GroupResourceConfigurationUpdateCriteria criteria = new GroupResourceConfigurationUpdateCriteria();
- ArrayList<Integer> groupList = new ArrayList<Integer>(1);
- groupList.add(HistoryGroupResourceConfigurationTable.this.group.getId());
- criteria.addFilterResourceGroupIds(groupList);
- return criteria;
- }
- }
}
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 fd78426..0e5dadc 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
@@ -109,6 +109,7 @@ common_title_configuration = Configuration
common_title_compatibleGroups = Compatible Groups
common_title_compatibleGroups_total = Compatible Group Total
common_title_component_errors = Component Errors
+common_title_config_update_status = Update Status
common_title_count = Count
common_title_custom = Custom
common_title_dashboard_name = Dashboard Name
@@ -146,6 +147,7 @@ common_title_mixedGroups_total = Mixed Group Total
common_title_name = Name
common_title_new_dashboard = New Dashboard
common_title_numeric_type = Numeric Type
+common_title_operation_status = Operation Status
common_title_operations = Operations
common_title_operations_range = Operation Range
common_title_over = Over
@@ -177,6 +179,8 @@ common_title_resource_inventory = Resource Inventory
common_title_resource_id = Resource ID
common_title_resource_name = Resource Name
common_title_resource_type = Resource Type
+common_title_results_count = Results Count
+common_title_results_count_tooltip = Displays this number of results
common_title_role = Role
common_title_roles = Roles
common_title_search = Search
@@ -189,6 +193,8 @@ common_title_service_total = Service Total
common_title_settings = Settings
common_title_show = Show
common_title_show_more = Show more...
+common_title_sort_order = Sort Order
+common_title_sort_order_tooltip = Sets sort order for results.
common_title_start = Start
common_title_status = Status
common_title_stop= Stop
@@ -230,12 +236,14 @@ common_val_na = N/A
common_val_none = None
# Common Statuses
-common_status_success = Success
+common_status_canceled = Canceled
+common_status_deferred = Deferred
common_status_failed = Failed
common_status_inprogress = In Progress
-common_status_canceled = Canceled
+common_status_nochange = No Change
+common_status_success = Success
common_status_unknown = Unknown
-common_status_deferred = Deferred
+
common_status_partial = Partial
# 1st, 2nd, 3rd, 4th, etc.
@@ -1468,6 +1476,7 @@ view_portlet_defaultName_tagCloud = Tag Count
view_portlet_defaultName_group_alerts =Group: Alerts
view_portlet_defaultName_group_bundles = Group: Bundle Deployments
+view_portlet_defaultName_group_config_updates = Group: Configuration Updates
view_portlet_defaultName_group_events = Group: Event Counts
view_portlet_defaultName_group_metrics = Group: Metrics
view_portlet_defaultName_group_oobs = Group: OOB Conditions
@@ -1475,6 +1484,7 @@ view_portlet_defaultName_group_operations = Group: Operations
view_portlet_defaultName_group_pkg_hisory = Group: Package History
view_portlet_defaultName_resource_alerts = Resource: Alerts
view_portlet_defaultName_resource_bundles = Resource: Bundle Deployments
+view_portlet_defaultName_resource_config_updates = Resource: Configuration Updates
view_portlet_defaultName_resource_events = Resource: Event Counts
view_portlet_defaultName_resource_metrics = Resource: Measurements
view_portlet_defaultName_resource_oobs = Resource: OOB Metrics
@@ -1483,6 +1493,7 @@ view_portlet_defaultName_resource_pkg_hisory = Resource: Package History
view_portlet_help_autodiscovery = This portlet allows import or ignore of newly discovered resources. Imported resources are added to inventory for monitoring and management. Ignored resources are not imported and are hidden from view unless explicitly unignored.
view_portlet_help_bundle_deps = This portlet shows relevant bundle deployments based on display criteria configured.
+view_portlet_help_config_updates =This portlet displays recent configuration changes consistent with configuration settings.
view_portlet_help_eventcounts = This portlet displays Event counts consistent with display criteria configured.
view_portlet_help_favoriteResources = This portlet displays the current user''s favorite resources.
view_portlet_help_graph = This portlet displays the resource metric graph.
commit 12cdec5fb2943458bc5b4bcfd4ab6f2c9c3718c3
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Mar 31 11:40:18 2011 -0400
remove redundant header for recentAlerts, trim space around operations portlet widget.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
index 9a9a124..2ef5bd8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
@@ -198,8 +198,6 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
/**Defines layout for the portlet page.
*/
protected void initializeUi() {
- setPadding(5);
- setMembersMargin(5);
setHeight("*");
setWidth100();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
index 763ed79..93fd686 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
@@ -67,6 +67,7 @@ public abstract class AbstractRecentAlertsPortlet extends AlertHistoryView imple
setShowFilterForm(false); //disable filter form for portlet
setOverflow(Overflow.VISIBLE);
setShowFooterRefresh(false); //disable footer refresh button as redundant for portlets
+ setShowHeader(false);//disable header for portlets
}
public Timer getRefreshTimer() {
commit 1ae7fb4e0b0221b83d3173417a384c48dec5ef89
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 1 20:06:12 2011 -0400
Global Dash/Portlet work
- eliminate title from RecentAlertsPortlet. Was redundant with
window title and cost real estate.
- Fix issues with honoring max rows in ProblemResourcesPortlet and
OperationsPortlet
- Change default max-rows config for several portlets to speed up
default dash:
- max recent alerts to 5
- max recent ops to 5
- max scheduled ops to 5
- max problem resources to 20
- set sort for problem resources to alertCount,name (was just name)
- Changes to Default Dash for perf and monitoring focus
- Eliminate Discovery Queue from default dash. Relatively slow, not useful
for non-perm users, easily navigable to in Inventory
- Eliminate Recently imported from default dash. Not very useful and rarely
changing.
- Move Welcome to Left column. Did not need space and gives priority to
monitoring portlets. (When deleted it will put Inventory Summary at top
of Left Column)
- Move RHQ News Mashup to Left column to deprioritize and use less real estate
- resize a few portlets/row sizes for better presentation and space utilization
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
index 2746c41..0a64610 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
@@ -84,6 +84,10 @@ public class AlertHistoryView extends TableSection<AlertDataSource> {
this(locatorId, SUBSYSTEM_VIEW_ID.getTitle(), entityContext, false);
}
+ public AlertHistoryView(String locatorId, String tableTitle, EntityContext entityContext) {
+ this(locatorId, tableTitle, entityContext, false);
+ }
+
protected AlertHistoryView(String locatorId, String tableTitle, EntityContext context, boolean hasWriteAccess) {
super(locatorId, tableTitle, new SortSpecifier[] { DEFAULT_SORT_SPECIFIER });
this.context = context;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index f3d1c69..95780fd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -61,13 +61,10 @@ import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.tab.NamedTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.NamedTabSet;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported.RecentlyAddedResourcesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems.ProblemResourcesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.InventorySummaryPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.TagCloudPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MashupPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MessagePortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
@@ -294,6 +291,66 @@ public class DashboardsView extends LocatableVLayout implements DashboardContain
return dashboardName;
}
+ /*
+ protected Dashboard getDefaultDashboard() {
+
+ Dashboard dashboard = new Dashboard();
+ dashboard.setName(MSG.common_title_default());
+ dashboard.setCategory(DashboardCategory.INVENTORY);
+ dashboard.setColumns(2);
+ // only leftmost column width is currently settable, the rest are equally divided
+ dashboard.setColumnWidths("32%");
+ dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, "#F1F2F3"));
+
+ // Left Column
+ DashboardPortlet summary = new DashboardPortlet(InventorySummaryPortlet.NAME, InventorySummaryPortlet.KEY, 210);
+ dashboard.addPortlet(summary, 0, 0);
+
+ DashboardPortlet discoveryQueue = new DashboardPortlet(AutodiscoveryPortlet.NAME, AutodiscoveryPortlet.KEY, 230);
+ dashboard.addPortlet(discoveryQueue, 0, 1);
+
+ DashboardPortlet recentlyAdded = new DashboardPortlet(RecentlyAddedResourcesPortlet.NAME,
+ RecentlyAddedResourcesPortlet.KEY, 230);
+ dashboard.addPortlet(recentlyAdded, 0, 2);
+
+ DashboardPortlet tagCloud = new DashboardPortlet(TagCloudPortlet.NAME, TagCloudPortlet.KEY, 230);
+ dashboard.addPortlet(tagCloud, 0, 3);
+
+ // Right Column
+ DashboardPortlet welcome = new DashboardPortlet(MessagePortlet.NAME, MessagePortlet.KEY, 210);
+ welcome.getConfiguration().put(
+ new PropertySimple("message", MSG.view_dashboardsManager_message_title_details()));
+ dashboard.addPortlet(welcome, 1, 0);
+
+ DashboardPortlet recentAlerts = new DashboardPortlet(RecentAlertsPortlet.NAME, RecentAlertsPortlet.KEY, 230);
+ dashboard.addPortlet(recentAlerts, 1, 1);
+
+ DashboardPortlet problemResources = new DashboardPortlet(ProblemResourcesPortlet.NAME,
+ ProblemResourcesPortlet.KEY, 230);
+ //initialize config for the problemResources portlet.
+ problemResources.getConfiguration()
+ .put(
+ new PropertySimple(ProblemResourcesPortlet.PROBLEM_RESOURCE_SHOW_MAX,
+ ProblemResourcesPortlet.defaultValue));
+ problemResources.getConfiguration()
+ .put(
+ new PropertySimple(ProblemResourcesPortlet.PROBLEM_RESOURCE_SHOW_HRS,
+ ProblemResourcesPortlet.defaultValue));
+ dashboard.addPortlet(problemResources, 1, 2);
+
+ DashboardPortlet operations = new DashboardPortlet(OperationsPortlet.NAME, OperationsPortlet.KEY, 420);
+ dashboard.addPortlet(operations, 1, 3);
+
+ DashboardPortlet news = new DashboardPortlet(MashupPortlet.NAME, MashupPortlet.KEY, 350);
+ news.getConfiguration().put(
+ new PropertySimple("address", "http://rhq-project.org/display/RHQ/RHQ+News?decorator=popup"));
+ dashboard.addPortlet(news, 1, 4);
+
+ return dashboard;
+
+ }
+ */
+
protected Dashboard getDefaultDashboard() {
Dashboard dashboard = new Dashboard();
@@ -305,30 +362,25 @@ public class DashboardsView extends LocatableVLayout implements DashboardContain
dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, "#F1F2F3"));
// Left Column
- DashboardPortlet summary = new DashboardPortlet(InventorySummaryPortlet.NAME, InventorySummaryPortlet.KEY, 210);
- dashboard.addPortlet(summary, 0, 0);
-
- DashboardPortlet discoveryQueue = new DashboardPortlet(AutodiscoveryPortlet.NAME, AutodiscoveryPortlet.KEY, 230);
- dashboard.addPortlet(discoveryQueue, 0, 1);
+ DashboardPortlet welcome = new DashboardPortlet(MessagePortlet.NAME, MessagePortlet.KEY, 250);
+ welcome.getConfiguration().put(
+ new PropertySimple("message", MSG.view_dashboardsManager_message_title_details()));
+ dashboard.addPortlet(welcome, 0, 0);
- DashboardPortlet recentlyAdded = new DashboardPortlet(RecentlyAddedResourcesPortlet.NAME,
- RecentlyAddedResourcesPortlet.KEY, 230);
- dashboard.addPortlet(recentlyAdded, 0, 2);
+ DashboardPortlet summary = new DashboardPortlet(InventorySummaryPortlet.NAME, InventorySummaryPortlet.KEY, 250);
+ dashboard.addPortlet(summary, 0, 1);
- DashboardPortlet tagCloud = new DashboardPortlet(TagCloudPortlet.NAME, TagCloudPortlet.KEY, 230);
- dashboard.addPortlet(tagCloud, 0, 3);
+ DashboardPortlet news = new DashboardPortlet(MashupPortlet.NAME, MashupPortlet.KEY, 300);
+ news.getConfiguration().put(
+ new PropertySimple("address", "http://rhq-project.org/display/RHQ/RHQ+News?decorator=popup"));
+ dashboard.addPortlet(news, 0, 2);
// Right Column
- DashboardPortlet welcome = new DashboardPortlet(MessagePortlet.NAME, MessagePortlet.KEY, 210);
- welcome.getConfiguration().put(
- new PropertySimple("message", MSG.view_dashboardsManager_message_title_details()));
- dashboard.addPortlet(welcome, 1, 0);
-
- DashboardPortlet recentAlerts = new DashboardPortlet(RecentAlertsPortlet.NAME, RecentAlertsPortlet.KEY, 230);
- dashboard.addPortlet(recentAlerts, 1, 1);
+ DashboardPortlet recentAlerts = new DashboardPortlet(RecentAlertsPortlet.NAME, RecentAlertsPortlet.KEY, 250);
+ dashboard.addPortlet(recentAlerts, 1, 0);
DashboardPortlet problemResources = new DashboardPortlet(ProblemResourcesPortlet.NAME,
- ProblemResourcesPortlet.KEY, 230);
+ ProblemResourcesPortlet.KEY, 250);
//initialize config for the problemResources portlet.
problemResources.getConfiguration()
.put(
@@ -338,18 +390,17 @@ public class DashboardsView extends LocatableVLayout implements DashboardContain
.put(
new PropertySimple(ProblemResourcesPortlet.PROBLEM_RESOURCE_SHOW_HRS,
ProblemResourcesPortlet.defaultValue));
- dashboard.addPortlet(problemResources, 1, 2);
+ dashboard.addPortlet(problemResources, 1, 1);
- DashboardPortlet operations = new DashboardPortlet(OperationsPortlet.NAME, OperationsPortlet.KEY, 420);
- dashboard.addPortlet(operations, 1, 3);
-
- DashboardPortlet news = new DashboardPortlet(MashupPortlet.NAME, MashupPortlet.KEY, 350);
- news.getConfiguration().put(
- new PropertySimple("address", "http://rhq-project.org/display/RHQ/RHQ+News?decorator=popup"));
- dashboard.addPortlet(news, 1, 4);
+ DashboardPortlet operations = new DashboardPortlet(OperationsPortlet.NAME, OperationsPortlet.KEY, 350);
+ //initialize config for the operations portlet.
+ operations.getConfiguration().put(
+ new PropertySimple(OperationsPortlet.OPERATIONS_RANGE_COMPLETED, OperationsPortlet.defaultValue));
+ operations.getConfiguration().put(
+ new PropertySimple(OperationsPortlet.OPERATIONS_RANGE_SCHEDULED, OperationsPortlet.defaultValue));
+ dashboard.addPortlet(operations, 1, 2);
return dashboard;
-
}
public void addNewDashboard() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
index 388094a..763ed79 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
@@ -62,7 +62,7 @@ public abstract class AbstractRecentAlertsPortlet extends AlertHistoryView imple
private Timer refreshTimer;
public AbstractRecentAlertsPortlet(String locatorId, EntityContext entityContext) {
- super(locatorId, entityContext);
+ super(locatorId, null, entityContext);
setShowFilterForm(false); //disable filter form for portlet
setOverflow(Overflow.VISIBLE);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index dad4578..0b02c38 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -98,7 +98,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
private RecentOperationsDataSource dataSourceCompleted;
private ScheduledOperationsDataSource dataSourceScheduled;
public static String unlimited = MSG.common_label_unlimited();
- public static String defaultValue = unlimited;
+ public static String defaultValue = "5";
public static boolean defaultEnabled = true;
private Timer refreshTimer;
@@ -133,8 +133,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
recentOperationsGrid.setHeaderSpans(new HeaderSpan(RECENT_OPERATIONS, completedRows));
recentOperationsGrid.setHeaderSpanHeight(20);
recentOperationsGrid.setHeaderHeight(40);
- recentOperationsGrid.setResizeFieldsInRealTime(true);
- recentOperationsGrid.setCellHeight(50);
+ //recentOperationsGrid.setResizeFieldsInRealTime(true);
recentOperationsGrid.setWrapCells(true);
addMember(recentOperationsGrid);
@@ -154,8 +153,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
scheduledOperationsGrid.setHeaderHeight(40);
scheduledOperationsGrid.setTitle(SCHEDULED_OPERATIONS);
- scheduledOperationsGrid.setResizeFieldsInRealTime(true);
- scheduledOperationsGrid.setCellHeight(50);
+ //scheduledOperationsGrid.setResizeFieldsInRealTime(true);
scheduledOperationsGrid.setWrapCells(true);
addMember(scheduledOperationsGrid);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index f91c4cf..7eac876 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -92,7 +92,7 @@ public class ProblemResourcesPortlet extends Table<ProblemResourcesDataSource> i
//constants
public static final String unlimited = MSG.common_label_unlimited();
- public static final String defaultValue = unlimited;
+ public static final String defaultValue = "20";
private Timer refreshTimer;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
index cf93986..1af0364 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
@@ -219,7 +219,15 @@ public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationL
record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record));
}
response.setData(records);
- response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+
+ // for paging to work we have to specify size of full result set, but if a limit has been set,
+ // respect the limit
+ int resultSize = result.getTotalSize();
+ int limit = getOperationsRangeCompleted();
+ if (limit > 0 && limit < resultSize) {
+ resultSize = limit;
+ }
+ response.setTotalRows(resultSize);
processResponse(request.getRequestId(), response);
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index ac4318a..3926fc5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -131,7 +131,8 @@ public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceCom
@Override
protected Criteria getFetchCriteria(DSRequest request) {
- // we don't use criterias for this datasource, just return null
+ // we don't use criteria fetch for this datasource, just return null
+
return null;
}
@@ -207,7 +208,13 @@ public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceCom
record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record));
}
response.setData(records);
- response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+ // for paging to work we have to specify size of full result set, but if a limit has been set,
+ // respect the limit
+ int resultSize = result.getTotalSize();
+ if (maximumProblemResourcesToDisplay > 0 && maximumProblemResourcesToDisplay < resultSize) {
+ resultSize = maximumProblemResourcesToDisplay;
+ }
+ response.setTotalRows(resultSize);
processResponse(request.getRequestId(), response);
}
});
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementProblemManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementProblemManagerBean.java
index 8d9bd4c..d398141 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementProblemManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementProblemManagerBean.java
@@ -34,6 +34,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.core.server.PersistenceUtility;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
@@ -54,7 +55,8 @@ public class MeasurementProblemManagerBean implements MeasurementProblemManagerL
@SuppressWarnings("unchecked")
public PageList<ProblemResourceComposite> findProblemResources(Subject subject, long oldestDate, PageControl pc) {
- pc.initDefaultOrderingField("res.name");
+ pc.initDefaultOrderingField("COUNT(DISTINCT alert.id)", PageOrdering.DESC);
+ pc.addDefaultOrderingField("res.name");
Query queryCount;
Query query;
commit 2ba64f818ae263bec15d3b76e3aebd9ead8ce823
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Apr 1 16:24:00 2011 -0400
BZ 691504
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp
index 61a7505..673d08e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp
@@ -62,8 +62,8 @@
String icon = "/images/icons/Content_" + extra + "16.png";
- String link = "/rhq/resource/content/installed_package_details.xhtml?id=" + resourceId +
- "¤tPackageId=" + installedPackage.getId();
+ String link = "#Resource/" + resourceId + "/Content/Deployed";
+ // "/rhq/resource/content/installed_package_details.xhtml?id=" + resourceId + "¤tPackageId=" + installedPackage.getId();
%>
{ "start" : "<%=sdf.format(new Date(installedPackage.getTimestamp()))%>",
commit 78ac4ad74b991ed8f6b1a90df7cc31cba05e9620
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Apr 1 16:12:58 2011 -0400
BZ 691504 - timeline now links to the new GWT UI where appropriate
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp
index 173fe16..f4b9194 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp
@@ -62,7 +62,7 @@
buf.append("<b>Value:</b>" + log.getValue() + "</b>");
}
- String link = "/alerts/Alerts.do?mode=viewAlert&id=" + resourceId + "&a=" + alert.getId();
+ String link = "/coregui/CoreGUI.html#Resource/" + resourceId + "/Alerts/History/" + alert.getId();
%>
{ "start" : "<%=sdf.format(new Date(alert.getCtime()))%>",
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventConfigJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventConfigJSON.jsp
index 6bb34c4..34baadf 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventConfigJSON.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventConfigJSON.jsp
@@ -43,7 +43,7 @@
String icon = FunctionTagLibrary.getResourceConfigStatusURL(configUpdate.getStatus());
- String link = "/rhq/resource/configuration/history.xhtml?id=" + resourceId + "&configId=" + configUpdate.getId();
+ String link = "/coregui/CoreGUI.html#Resource/" + resourceId + "/Configuration/History/" + configUpdate.getId();
%>
{ "start" : "<%=sdf.format(configUpdate.getCreatedTime())%>",
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventCreateDeleteChildJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventCreateDeleteChildJSON.jsp
index 46f3480..463984e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventCreateDeleteChildJSON.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventCreateDeleteChildJSON.jsp
@@ -58,7 +58,7 @@
icon = "/images/icn_create_child.png"; // TODO
}
- String link = "/rhq/resource/inventory/view.xhtml?id=" + resourceId ;
+ String link = "/coregui/CoreGUI.html#Resource/" + resourceId ;
%>
@@ -95,7 +95,7 @@
icon = "/images/icn_delete_child.png"; // TODO
}
- String link = "/rhq/resource/inventory/view.xhtml?id=" + resourceId ;
+ String link = "/coregui/CoreGUI.html#Resource/" + resourceId ;
%>
{ "start" : "<%=sdf.format(entry.getCreatedTime())%>",
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp
index 5b4320e..bb6ced8 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp
@@ -157,13 +157,13 @@
String color = eventColor(event.getSeverity());
String icon = FunctionTagLibrary.getEventSeverityURL(event.getSeverity(), grouped);
- String link = "/rhq/resource/events/history.xhtml?id=" + resourceId + "&eventId=" + event.getEventId();
+ String link = "/coregui/CoreGUI.html#Resource/" + resourceId + "/Events/History/" + event.getEventId();
String detail = null;
if (grouped) {
StringBuilder buf = new StringBuilder();
for (EventComposite childEvent : ((GroupedEventComposite)event).events) {
- buf.append("<a href='/rhq/resource/events/history.xhtml?id=" + resourceId + "&eventId=" + childEvent.getEventId() + "'>");
+ buf.append("<a href='/coregui/CoreGUI.html#Resource/" + resourceId + "/Events/History/" + childEvent.getEventId() + "'>");
buf.append("<font size=\"-1\" color=\"" + color + "\">" + escapeBackslashes(trimLength(childEvent.getEventDetail(),80)) + "</font></a><br />");
}
detail = buf.toString();
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventOperationsJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventOperationsJSON.jsp
index 0846050..5e28985 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventOperationsJSON.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventOperationsJSON.jsp
@@ -45,7 +45,7 @@
String icon = FunctionTagLibrary.getOperationStatusURL(operation.getStatus());
- String link = "/rhq/resource/operation/resourceOperationHistoryDetails.xhtml?id=" + resourceId + "&opId=" + operation.getId();
+ String link = "/coregui/CoreGUI.html#Resource/" + resourceId + "/Operations/History/" + operation.getId();
// out.write(
// " <event start=\"" + sdf.format(new Date(operation.getCreatedTime())) + "\" " +
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventPluginConfigJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventPluginConfigJSON.jsp
index 06ff3aa..ed75a07 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventPluginConfigJSON.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventPluginConfigJSON.jsp
@@ -53,7 +53,7 @@
break;
}
- String link = "/rhq/resource/inventory/history.xhtml?id=" + resourceId + "&configId=" + configUpdate.getId();
+ String link = "/coregui/CoreGUI.html#Resource/" + resourceId + "/Inventory/PluginConfigurationHistoryView/" + configUpdate.getId();
%>
commit c30433b4d14efbeda2594b1f4a51ff74715793f8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Apr 1 16:12:13 2011 -0400
make the timestamp col a link to the details
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index 65ebb57..8456f2b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -50,6 +50,7 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellForma
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Joseph Marques
@@ -177,6 +178,20 @@ public class EventCompositeHistoryView extends TableSection<EventCompositeDataso
super.configureTable();
}
+ protected String getDetailsLinkColumnName() {
+ return "timestamp";
+ }
+
+ protected CellFormatter getDetailsLinkColumnCellFormatter() {
+ return new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ Integer recordId = getId(record);
+ String detailsUrl = "#" + getBasePath() + "/" + recordId;
+ return SeleniumUtility.getLocatableHref(detailsUrl, TimestampCellFormatter.format(value), null);
+ }
+ };
+ }
+
private void setupTableInteractions() {
TableActionEnablement singleTargetEnablement = hasWriteAccess ? TableActionEnablement.ANY
: TableActionEnablement.NEVER;
commit 24280444ac3904c3fe4e1d6a25334ff89d42ccfe
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Apr 1 15:45:33 2011 -0400
fix NPE that occurred when you edited an existing list-o-maps member map and then clicked the member map editor modal's OK button
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 4d4e358..69a3c52 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -952,8 +952,8 @@ public class ConfigurationEditor extends LocatableVLayout {
PropertyMapListGridRecord record = (PropertyMapListGridRecord) recordClickEvent.getRecord();
PropertyMap memberPropertyMap = (PropertyMap) record.getPropertyMap();
Log.debug("Editing property map: " + memberPropertyMap);
- displayMapEditor(summaryTable, record, memberPropertyDefinitionMap, propertyList, memberPropertyMap,
- mapReadOnly);
+ displayMapEditor(summaryTable, record, propertyDefinitionList, propertyList,
+ memberPropertyDefinitionMap, memberPropertyMap, mapReadOnly);
}
});
fieldsList.add(editField);
@@ -1005,8 +1005,8 @@ public class ConfigurationEditor extends LocatableVLayout {
addRowButton.setIcon(Window.getImgURL("[SKIN]/actions/add.png"));
addRowButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- displayMapEditor(summaryTable, null, memberPropertyDefinitionMap,
- propertyList, null, mapReadOnly);
+ displayMapEditor(summaryTable, null, propertyDefinitionList, propertyList,
+ memberPropertyDefinitionMap, null, mapReadOnly);
}
});
toolStrip.addMember(addRowButton);
@@ -1538,15 +1538,15 @@ public class ConfigurationEditor extends LocatableVLayout {
}
private void displayMapEditor(final ListGrid summaryTable, final PropertyMapListGridRecord existingRecord,
- PropertyDefinitionMap definition, final PropertyList list, final PropertyMap map,
+ final PropertyDefinitionList propertyDefinitionList, final PropertyList propertyList, PropertyDefinitionMap memberMapDefinition, final PropertyMap memberMap,
final boolean mapReadOnly) {
- final List<PropertyDefinition> memberDefinitions = new ArrayList<PropertyDefinition>(definition
+ final List<PropertyDefinition> memberDefinitions = new ArrayList<PropertyDefinition>(memberMapDefinition
.getPropertyDefinitions().values());
Collections.sort(memberDefinitions, new PropertyDefinitionComparator());
- final boolean newRow = (map == null);
- final PropertyMap workingMap = (newRow) ? new PropertyMap(definition.getName()) : map.deepCopy(true);
+ final boolean newRow = (memberMap == null);
+ final PropertyMap workingMap = (newRow) ? new PropertyMap(memberMapDefinition.getName()) : memberMap.deepCopy(true);
final LocatableWindow popup = new LocatableWindow(extendLocatorId("MapEditor"));
String title = (mapReadOnly) ? MSG.view_configEdit_viewRow() : MSG.view_configEdit_editRow();
@@ -1582,25 +1582,17 @@ public class ConfigurationEditor extends LocatableVLayout {
return;
}
if (newRow) {
- try {
- list.add(workingMap);
- int index = list.getList().size() - 1;
- PropertyMapListGridRecord record = new PropertyMapListGridRecord(workingMap, index,
- memberDefinitions);
- summaryTable.addData(record);
- } catch (Exception e) {
- e.printStackTrace();
- }
+ propertyList.add(workingMap);
+ int index = propertyList.getList().size() - 1;
+ PropertyMapListGridRecord record = new PropertyMapListGridRecord(workingMap, index,
+ memberDefinitions);
+ summaryTable.addData(record);
} else {
- try {
- mergePropertyMap(workingMap, map, memberDefinitions);
- existingRecord.refresh();
- summaryTable.updateData(existingRecord);
- } catch (Exception e) {
- e.printStackTrace();
- }
+ mergePropertyMap(workingMap, memberMap, memberDefinitions);
+ existingRecord.refresh();
+ summaryTable.updateData(existingRecord);
}
- firePropertyChangedEvent(list, null, true);
+ firePropertyChangedEvent(propertyList, propertyDefinitionList, true);
summaryTable.redraw();
}
commit 836344458731d5d3e20032589875775a5fef1910
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Apr 1 15:37:20 2011 -0400
format date col
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
index 40a342f..831408a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
@@ -36,6 +36,7 @@ import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -114,7 +115,8 @@ public class EventCompositeDetailsView extends LocatableVLayout implements Bookm
source.setValue(composite.getSourceLocation());
StaticTextItem timestamp = new StaticTextItem("timestamp", MSG.view_inventory_eventHistory_timestamp());
- timestamp.setValue(composite.getTimestamp());
+ timestamp.setValue(TimestampCellFormatter.format(composite.getTimestamp(),
+ TimestampCellFormatter.DATE_TIME_FORMAT_FULL));
TextAreaItem detail = new TextAreaItem("details", MSG.view_inventory_eventHistory_details());
detail.setValue(composite.getEventDetail());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index 0657f04..65ebb57 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -46,6 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.components.form.EnumSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
@@ -101,6 +102,7 @@ public class EventCompositeHistoryView extends TableSection<EventCompositeDataso
@Override
protected void configureTable() {
ListGridField timestampField = new ListGridField("timestamp", MSG.view_inventory_eventHistory_timestamp());
+ TimestampCellFormatter.prepareDateField(timestampField);
ListGridField severityField = new ListGridField("severity", MSG.view_inventory_eventHistory_severity());
severityField.setAlign(Alignment.CENTER);
commit 4efc5ad73f2a0c2c942174e56c42b87c76deb5eb
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Apr 1 15:14:08 2011 -0400
fix bug in config editor that was causing inputs for optional props to get disabled upon that input losing focus
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 35d61f2..4d4e358 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -1434,9 +1434,10 @@ public class ConfigurationEditor extends LocatableVLayout {
valueItem.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent event) {
- boolean isUnset = (event.getItem().getValue() == null);
- unsetItem.setValue(isUnset);
- valueItem.disable();
+ if (event.getItem().getValue() == null) {
+ unsetItem.setValue(true);
+ valueItem.disable();
+ }
}
});
commit 6fba3dbee8ced1cfd281d1edb27c973dec557ff3
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Apr 1 14:13:28 2011 -0400
BZ 689561 - have config description say that the units are in seconds
diff --git a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
index bf48dcd..b6169f0 100644
--- a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
@@ -350,23 +350,23 @@
<c:group name="plugincontainer" displayName="Plugin Container" hiddenByDefault="false">
<c:description>Plugin Container configuration properties</c:description>
<c:simple-property name="rhq.agent.plugins.directory" type="string" activationPolicy="restart" required="true" default="plugins" displayName="Plugins Directory" description="Location on the file system where the plugin jar files are stored"/>
- <c:simple-property name="rhq.agent.plugins.server-discovery.initial-delay-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="10" displayName="Server Discovery Initial Delay" description="Startup delay before the first server discovery is run" />
- <c:simple-property name="rhq.agent.plugins.server-discovery.period-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="900" displayName="Server Discovery Period" description="Time between server discoveries" />
- <c:simple-property name="rhq.agent.plugins.service-discovery.initial-delay-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="20" displayName="Service Discovery Initial Delay" description="Startup delay before the first service discovery is run" />
- <c:simple-property name="rhq.agent.plugins.service-discovery.period-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="86400" displayName="Service Discovery Period" description="Time between service discoveries" />
- <c:simple-property name="rhq.agent.plugins.availability-scan.initial-delay-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="30" displayName="Availability Scan Initial Delay" description="Startup delay before the first availability scan is run" />
- <c:simple-property name="rhq.agent.plugins.availability-scan.period-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="300" displayName="Availability Scan Period" description="Time between availability scans" />
- <c:simple-property name="rhq.agent.plugins.measurement-collection.initial-delay-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="30" displayName="Measurement Collection Initial Delay" description="Startup delay before the first measurement collection is run" />
+ <c:simple-property name="rhq.agent.plugins.server-discovery.initial-delay-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="10" displayName="Server Discovery Initial Delay" description="Startup delay before the first server discovery is run (in seconds)" />
+ <c:simple-property name="rhq.agent.plugins.server-discovery.period-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="900" displayName="Server Discovery Period" description="Time between server discoveries (in seconds)" />
+ <c:simple-property name="rhq.agent.plugins.service-discovery.initial-delay-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="20" displayName="Service Discovery Initial Delay" description="Startup delay before the first service discovery is run (in seconds)" />
+ <c:simple-property name="rhq.agent.plugins.service-discovery.period-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="86400" displayName="Service Discovery Period" description="Time between service discoveries (in seconds)" />
+ <c:simple-property name="rhq.agent.plugins.availability-scan.initial-delay-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="30" displayName="Availability Scan Initial Delay" description="Startup delay before the first availability scan is run (in seconds)" />
+ <c:simple-property name="rhq.agent.plugins.availability-scan.period-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="300" displayName="Availability Scan Period" description="Time between availability scans (in seconds)" />
+ <c:simple-property name="rhq.agent.plugins.measurement-collection.initial-delay-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="30" displayName="Measurement Collection Initial Delay" description="Startup delay before the first measurement collection is run (in seconds)" />
<c:simple-property name="rhq.agent.plugins.measurement-collection.threadpool-size" type="integer" activationPolicy="restart" required="false" default="5" displayName="Measurement Collection Threadpool Size" description="Number of concurrent measurement collections that can be run" />
- <c:simple-property name="rhq.agent.plugins.operation-invocation-timeout-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="600" displayName="Operation Invocation Timeout" description="Time before an operation invocation is aborted" />
+ <c:simple-property name="rhq.agent.plugins.operation-invocation-timeout-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="600" displayName="Operation Invocation Timeout" description="Time before an operation invocation is aborted (in seconds)" />
<c:simple-property name="rhq.agent.plugins.operation-invoker.threadpool-size" type="integer" activationPolicy="restart" required="false" default="5" displayName="Operation Invoker Threadpool Size" description="Number of concurrent operation invocations that can be run" />
- <c:simple-property name="rhq.agent.plugins.content-discovery.initial-delay-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="30" displayName="Content Discovery Initial Delay" description="Startup delay before the first content discovery is run" />
- <c:simple-property name="rhq.agent.plugins.content-discovery.period-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="10" displayName="Content Discovery Period" description="Time between content discoveries" />
+ <c:simple-property name="rhq.agent.plugins.content-discovery.initial-delay-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="30" displayName="Content Discovery Initial Delay" description="Startup delay before the first content discovery is run (in seconds)" />
+ <c:simple-property name="rhq.agent.plugins.content-discovery.period-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="10" displayName="Content Discovery Period" description="Time between content discoveries (in seconds)" />
<c:simple-property name="rhq.agent.plugins.content-discovery.threadpool-size" type="integer" activationPolicy="restart" required="false" default="10" displayName="Content Discovery Threadpool Size" description="Number of concurrent content discoveries that can be run" />
- <c:simple-property name="rhq.agent.plugins.configuration-discovery.initial-delay-secs" type="integer" activationPolicy="restart" required="false" default="300" displayName="Configuration Change Detection Startup Delay" description="Time before configuration change detection starts in seconds" />
- <c:simple-property name="rhq.agent.plugins.configuration-discovery.period-secs" type="integer" activationPolicy="restart" required="false" default="3600" displayName="Configuration Change Detection Interval" description="Time period for checking for configuration changes in seconds" />
- <c:simple-property name="rhq.agent.plugins.event-sender.initial-delay-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="30" displayName="Event Sender Initial Delay" description="Defines the delay before the first event report gets sent to the server" />
- <c:simple-property name="rhq.agent.plugins.event-sender.period-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="30" displayName="Event Sender Period" description="Defines how often event reports get sent to the server" />
+ <c:simple-property name="rhq.agent.plugins.configuration-discovery.initial-delay-secs" type="integer" activationPolicy="restart" required="false" default="300" displayName="Configuration Change Detection Startup Delay" description="Time before configuration change detection starts (in seconds)" />
+ <c:simple-property name="rhq.agent.plugins.configuration-discovery.period-secs" type="integer" activationPolicy="restart" required="false" default="3600" displayName="Configuration Change Detection Interval" description="Time period for checking for configuration changes (in seconds)" />
+ <c:simple-property name="rhq.agent.plugins.event-sender.initial-delay-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="30" displayName="Event Sender Initial Delay" description="Defines the delay before the first event report gets sent to the server (in seconds)" />
+ <c:simple-property name="rhq.agent.plugins.event-sender.period-secs" type="integer" units="seconds" activationPolicy="restart" required="false" default="30" displayName="Event Sender Period" description="Defines how often event reports get sent to the server (in seconds)" />
<c:simple-property name="rhq.agent.plugins.event-report.max-per-source" type="integer" activationPolicy="restart" required="false" default="200" displayName="Event Report Max Per Source" description="Defines the maximum number of events for any given event source that can be placed in a single event report that is sent up to the server. If this number is larger than the max-total setting, then this setting is ignored" />
<c:simple-property name="rhq.agent.plugins.event-report.max-total" type="integer" activationPolicy="restart" required="false" default="400" displayName="Event Report Max Total" description="Defines the total maximum number of events that can be placed in a single event report that is sent up to the server" />
<c:simple-property name="rhq.agent.plugins.disabled" type="string" activationPolicy="restart" required="false" default="" displayName="Disabled Plugins" description="Defines the plugins that should be disabled and not loaded by the plugin container. This is a comma-separated list of plugin names." />
commit fac70debb685e058f92ea918522e019d1cf76028
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Apr 1 12:57:55 2011 -0400
make consistent the name for the "platform summary", "cpu and memory utilization"
portlet and report page. now named "platform utilization"
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
index a58c909..a0171c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
@@ -61,7 +61,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
*/
public class PlatformSummaryPortlet extends LocatableListGrid implements Portlet {
- public static final ViewName VIEW_ID = new ViewName("CpuAndMemoryUtilization", MSG.view_reports_platforms());
+ public static final ViewName VIEW_ID = new ViewName("PlatformUtilization", MSG.view_reports_platforms());
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "PlatformSummary";
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 26b3bf0..fd78426 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
@@ -1460,7 +1460,7 @@ view_portlet_defaultName_inventorySummary = Inventory Summary
view_portlet_defaultName_mashup = Mashup
view_portlet_defaultName_message = Message
view_portlet_defaultName_operations = Operations
-view_portlet_defaultName_platformSummary = Platform Summary
+view_portlet_defaultName_platformSummary = Platform Utilization
view_portlet_defaultName_problemResources = Alerted or Unavailable Resources
view_portlet_defaultName_recentAlerts = Recent Alerts
view_portlet_defaultName_recentlyAddedResources = Recently Added Resources
@@ -1494,7 +1494,7 @@ view_portlet_help_oobs = This portlet displays OOB(Out of Bound) metric conditio
view_portlet_help_operations = This portlet displays executing, completed and scheduled operations for the current user''s inventory.
view_portlet_help_operations_criteria = This portlet displays Operations consistent with display criteria configured.
view_portlet_help_pkg_history = This portlet shows relevant package history based on display criteria configured.
-view_portlet_help_platformSummary = This portlet displays information about the current user''s platform resources.
+view_portlet_help_platformSummary = This portlet displays utilization data (such as current CPU and memory usage) for platform resources that are accessible by the current user.
view_portlet_help_problemResources = This portlet displays the current user''s alerted or unavailable resources.
view_portlet_help_recentAlerts = This portlet displays alerts recently fired on the current user''s viewable inventory.
view_portlet_help_recentlyAdded = This portlet displays resources that have recently been imported into inventory.
@@ -2016,7 +2016,7 @@ view_groupInventoryMembers_title_updateMembership = Update Membership
view_reportsTop_title = Reports
view_reportsTop_description = This section provides access to global reports.
-view_reports_platforms = CPU And Memory Utilization
+view_reports_platforms = Platform Utilization
view_reports_subsystems = Subsystems
view_reports_alertDefinitions = Alert Definitions
commit 981d97853714fb8c54e50fc608535c1b0fd27ebf
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Apr 1 12:40:35 2011 -0400
add some more HTML escaping to bundle views (includes fix for https://bugzilla.redhat.com/show_bug.cgi?id=676768)
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 c188a42..ca08fdb 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
@@ -46,6 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.components.upload.TextFileRetriever
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
@@ -231,7 +232,9 @@ public class BundleUploadDistroFileStep extends AbstractWizardStep {
}
public void onFailure(Throwable caught) {
- wizard.getView().showMessage(caught.getMessage());
+ // Escape it, since it contains the URL, which the user entered.
+ String message = StringUtility.escapeHtml(caught.getMessage());
+ wizard.getView().showMessage(message);
CoreGUI.getErrorHandler().handleError(MSG.view_bundle_createWizard_createFailure(), caught);
wizard.setBundleVersion(null);
setButtonsDisableMode(false);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
index 62bf4ed..e220cfc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.client.bundle.deployment;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.AnimationEffect;
@@ -347,9 +348,9 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
resource.setAutoFitWidth(true);
resource.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
resource.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ public String format(Object value, ListGridRecord listGridRecord, int i, int i1) {
return "<a href=\"" + LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("resourceId"))
- + "\">" + o + "</a>";
+ + "\">" + StringUtility.escapeHtml(String.valueOf(value)) + "</a>";
}
});
@@ -367,7 +368,7 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
status.setShowValueIconOnly(true);
status.setWidth("*");
- ArrayList<ListGridRecord> records = new ArrayList<ListGridRecord>();
+ List<ListGridRecord> records = new ArrayList<ListGridRecord>();
for (BundleResourceDeployment rd : deployment.getResourceDeployments()) {
ListGridRecord record = new ListGridRecord();
Resource rr = rd.getResource();
commit d4aa795ddb93453c4649ffb7f08b28f08240f5e1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Apr 1 12:16:51 2011 -0400
BZ 691526 - log the error properly when setting favorite fails
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
index d8020f3..6c7d628 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
@@ -316,7 +316,7 @@ public class ResourceGroupTitleBar extends LocatableVLayout {
} else {
m = MSG.view_titleBar_common_removedFavFailure(ResourceGroupTitleBar.this.group.getName());
}
- CoreGUI.getMessageCenter().notify(new Message(m, Message.Severity.Error));
+ CoreGUI.getErrorHandler().handleError(m, throwable);
// Revert back to our original favorite status, since the server update failed.
toggleFavoriteLocally();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
index dcdffd9..b3e801c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
@@ -356,7 +356,7 @@ public class ResourceTitleBar extends LocatableVLayout {
} else {
msg = MSG.view_titleBar_common_removedFavFailure(resource.getName());
}
- CoreGUI.getMessageCenter().notify(new Message(msg, Message.Severity.Info));
+ CoreGUI.getErrorHandler().handleError(msg, throwable);
// Revert back to our original favorite status, since the server update failed.
toggleFavoriteLocally();
commit aafb9f840be235a83767c5469038f2ebcef72182
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Apr 1 12:07:12 2011 -0400
more HTML escaping
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java
index dfe6bdb..4b85d4f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -16,7 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
import java.util.ArrayList;
@@ -163,6 +162,7 @@ public class OverviewForm extends EnhancedDynamicForm {
nameItem.setName("name");
nameItem.setTitle(MSG.view_summaryOverviewForm_field_name());
nameItem.setValue(resource.getName());
+ nameItem.setAttribute(OUTPUT_AS_HTML_ATTRIBUTE, true);
if (nameItem instanceof EditableFormItem) {
EditableFormItem togglableNameItem = (EditableFormItem) nameItem;
togglableNameItem.setValidators(notEmptyOrNullValidator);
@@ -202,6 +202,7 @@ public class OverviewForm extends EnhancedDynamicForm {
descriptionItem.setName("description");
descriptionItem.setTitle(MSG.view_summaryOverviewForm_field_description());
descriptionItem.setValue(resource.getDescription());
+ descriptionItem.setAttribute(OUTPUT_AS_HTML_ATTRIBUTE, true);
if (descriptionItem instanceof EditableFormItem) {
EditableFormItem togglableDescriptionItem = (EditableFormItem) descriptionItem;
togglableDescriptionItem.setValidators(notNullValidator);
@@ -242,6 +243,7 @@ public class OverviewForm extends EnhancedDynamicForm {
locationItem.setName("location");
locationItem.setTitle(MSG.view_summaryOverviewForm_field_location());
locationItem.setValue(resource.getLocation());
+ locationItem.setAttribute(OUTPUT_AS_HTML_ATTRIBUTE, true);
if (locationItem instanceof EditableFormItem) {
EditableFormItem togglableLocationItem = (EditableFormItem) locationItem;
togglableLocationItem.setValidators(notNullValidator);
commit 4e353c14ab0eb728ee8da5cfa165cb2185ae529d
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Apr 1 11:06:49 2011 -0400
make sure only users w/ group inventory perm can edit group general props (https://bugzilla.redhat.com/show_bug.cgi?id=692842); escape HTML resource/group props when they're displayed as static text
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EditableFormItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EditableFormItem.java
index 09c2273..86f87b3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EditableFormItem.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EditableFormItem.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -20,7 +20,6 @@
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-
package org.rhq.enterprise.gui.coregui.client.components.form;
import java.util.Date;
@@ -54,11 +53,9 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
* but can be toggled into an "editable" form that allows the user to enter a different value.
*
* This default implementation provides editing the value within a text field. However, this class
- * is designed to be extended, thus allowing the subclasses to edit values via
- * checkboxes, radio buttons, etc.
+ * is designed to be extended, thus allowing the subclasses to edit values via checkboxes, radio buttons, etc.
*
* @author John Mazzitelli
- *
*/
public class EditableFormItem extends CanvasItem {
@@ -103,7 +100,6 @@ public class EditableFormItem extends CanvasItem {
// if we are not in edit-mode, we want to show the edit icon, but only if the mouse hovers over us
this.innerForm.addMouseOutHandler(new MouseOutHandler() {
- @Override
public void onMouseOut(MouseOutEvent event) {
if (!isEditing()) {
EditableFormItem.this.staticItem.setIcons(blankIcon);
@@ -112,7 +108,6 @@ public class EditableFormItem extends CanvasItem {
}
});
this.innerForm.addMouseOverHandler(new MouseOverHandler() {
- @Override
public void onMouseOver(MouseOverEvent event) {
if (!isEditing() && !isReadOnly()) {
EditableFormItem.this.staticItem.setIcons(editIcon);
@@ -135,12 +130,14 @@ public class EditableFormItem extends CanvasItem {
item.setIconWidth(16);
item.setShowIcons(true);
item.setShowIfCondition(new FormItemIfFunction() {
- @Override
public boolean execute(FormItem item, Object value, DynamicForm form) {
return !isEditing();
}
});
item.setTextBoxStyle("editableText");
+ if (item instanceof StaticTextItem) {
+ ((StaticTextItem)item).setOutputAsHTML(true);
+ }
return item;
}
@@ -156,7 +153,6 @@ public class EditableFormItem extends CanvasItem {
item.setIconWidth(16);
item.setShowIcons(true);
item.setShowIfCondition(new FormItemIfFunction() {
- @Override
public boolean execute(FormItem item, Object value, DynamicForm form) {
return isEditing();
}
@@ -183,6 +179,7 @@ public class EditableFormItem extends CanvasItem {
* @return the form item used to show the static (read-only) value
*/
protected FormItem instantiateStaticFormItem() {
+ @SuppressWarnings({"UnnecessaryLocalVariable"})
StaticTextItem item = new StaticTextItem();
return item;
}
@@ -197,6 +194,7 @@ public class EditableFormItem extends CanvasItem {
* @return the form item used to edit the value
*/
protected FormItem instantiateEditFormItem() {
+ @SuppressWarnings({"UnnecessaryLocalVariable"})
TextItem item = new TextItem();
return item;
}
@@ -206,7 +204,6 @@ public class EditableFormItem extends CanvasItem {
editIcon.setSrc(ImageManager.getEditIcon());
editIcon.setPrompt(MSG.common_button_edit()); // TODO have better message?
editIcon.addFormItemClickHandler(new FormItemClickHandler() {
- @Override
public void onFormItemClick(FormItemIconClickEvent event) {
// should never get here if read-only (the icon is hidden) but just to be sure, check read-only status again
if (!isReadOnly()) {
@@ -222,7 +219,6 @@ public class EditableFormItem extends CanvasItem {
approveIcon.setSrc(ImageManager.getApproveIcon());
approveIcon.setPrompt(MSG.common_button_ok()); // TODO have better message?
approveIcon.addFormItemClickHandler(new FormItemClickHandler() {
- @Override
public void onFormItemClick(FormItemIconClickEvent event) {
if (EditableFormItem.this.innerForm.validate(false)) {
Object newValue = event.getItem().getValue();
@@ -239,7 +235,6 @@ public class EditableFormItem extends CanvasItem {
cancelIcon.setSrc(ImageManager.getCancelIcon());
cancelIcon.setPrompt(MSG.common_button_cancel()); // TODO have better message?
cancelIcon.addFormItemClickHandler(new FormItemClickHandler() {
- @Override
public void onFormItemClick(FormItemIconClickEvent event) {
switchToStaticMode();
}
@@ -434,4 +429,5 @@ public class EditableFormItem extends CanvasItem {
public static interface ValueEditedHandler {
public void editedValue(Object newValue);
}
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
index fde8d13..9d8eb61 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
@@ -42,6 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem.Va
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -76,20 +77,18 @@ public class GeneralProperties extends LocatableVLayout {
List<FormItem> formItems = new ArrayList<FormItem>();
- boolean dynamic = (group.getGroupDefinition() != null);
+ boolean isDynaGroup = (group.getGroupDefinition() != null);
+ boolean hasInventoryPermission = (this.groupComposite.getResourcePermission().isInventory());
+ boolean isEditable = (!isDynaGroup && hasInventoryPermission);
StringLengthValidator notEmptyOrNullValidator = new StringLengthValidator(1, null, false);
StringLengthValidator notNullValidator = new StringLengthValidator(null, null, false);
- final FormItem nameItem = (dynamic) ? new StaticTextItem() : new EditableFormItem();
- nameItem.setName("name");
- nameItem.setTitle(MSG.common_title_name());
- nameItem.setValue(group.getName());
- if (nameItem instanceof EditableFormItem) {
- final EditableFormItem togglableNameItem = (EditableFormItem) nameItem;
+ final FormItem nameItem;
+ if (isEditable) {
+ final EditableFormItem togglableNameItem = new EditableFormItem();
togglableNameItem.setValidators(notEmptyOrNullValidator);
togglableNameItem.setValueEditedHandler(new ValueEditedHandler() {
- @Override
public void editedValue(Object newValue) {
final String newName = newValue.toString();
final String oldName = group.getName();
@@ -106,7 +105,7 @@ public class GeneralProperties extends LocatableVLayout {
// We failed to update it on the Server, so change back the ResourceGroup and the form item
// to the original value.
group.setName(oldName);
- nameItem.setValue(oldName);
+ togglableNameItem.setValue(oldName);
}
public void onSuccess(Void result) {
@@ -119,16 +118,28 @@ public class GeneralProperties extends LocatableVLayout {
});
}
});
+ nameItem = togglableNameItem;
+ } else {
+ StaticTextItem staticNameItem = new StaticTextItem();
+ staticNameItem.setOutputAsHTML(true);
+ nameItem = staticNameItem;
}
+
+ nameItem.setName("name");
+ nameItem.setTitle(MSG.common_title_name());
+ nameItem.setValue(group.getName());
+
formItems.add(nameItem);
StaticTextItem typeItem = new StaticTextItem("memberType", MSG.view_group_summary_memberType());
ResourceType type = group.getResourceType();
if (type != null) {
+ // compatible group
typeItem.setTooltip(MSG.common_title_plugin() + ": " + type.getPlugin() + "\n<br>"
+ MSG.common_title_type() + ": " + type.getName());
typeItem.setValue(type.getName() + " (" + type.getPlugin() + ")");
} else {
+ // mixed group
typeItem.setValue("<i>" + MSG.view_group_summary_mixed() + "</i>");
}
formItems.add(typeItem);
@@ -138,15 +149,12 @@ public class GeneralProperties extends LocatableVLayout {
countItem.setValue(memberCount);
formItems.add(countItem);
- final FormItem descriptionItem = (dynamic) ? new StaticTextItem() : new EditableFormItem();
- descriptionItem.setName("description");
- descriptionItem.setTitle(MSG.common_title_description());
- descriptionItem.setValue(group.getDescription());
- if (descriptionItem instanceof EditableFormItem) {
- final EditableFormItem togglableDescriptionItem = (EditableFormItem) descriptionItem;
+ final FormItem descriptionItem;
+ String value;
+ if (isEditable) {
+ final EditableFormItem togglableDescriptionItem = new EditableFormItem();
togglableDescriptionItem.setValidators(notNullValidator);
togglableDescriptionItem.setValueEditedHandler(new ValueEditedHandler() {
- @Override
public void editedValue(Object newValue) {
final String newDescription = newValue.toString();
final String oldDescription = group.getDescription();
@@ -162,7 +170,7 @@ public class GeneralProperties extends LocatableVLayout {
// We failed to update it on the Server, so change back the ResourceGroup and the form item
// to the original value.
group.setDescription(oldDescription);
- descriptionItem.setValue(oldDescription);
+ togglableDescriptionItem.setValue(oldDescription);
}
public void onSuccess(Void result) {
@@ -172,33 +180,46 @@ public class GeneralProperties extends LocatableVLayout {
});
}
});
+ descriptionItem = togglableDescriptionItem;
+ value = group.getDescription();
+ } else {
+ descriptionItem = new StaticTextItem();
+ value = StringUtility.escapeHtml(group.getDescription());
}
+
+ descriptionItem.setName("description");
+ descriptionItem.setTitle(MSG.common_title_description());
+ descriptionItem.setValue(value);
+
formItems.add(descriptionItem);
StaticTextItem dynamicItem = new StaticTextItem("dynamic", MSG.view_group_summary_dynamic());
- dynamicItem.setValue(dynamic ? MSG.common_val_yes() : MSG.common_val_no());
+ dynamicItem.setValue(isDynaGroup ? MSG.common_val_yes() : MSG.common_val_no());
formItems.add(dynamicItem);
- EditableFormItem recursiveItem = new CheckboxEditableFormItem("recursive", MSG.view_group_summary_recursive());
- recursiveItem.setValueEditedHandler(new ValueEditedHandler() {
- @Override
- public void editedValue(Object newValue) {
- boolean isRecursive = (newValue != null) ? ((Boolean) newValue).booleanValue() : false;
- resourceGroupService.setRecursive(group.getId(), isRecursive, new AsyncCallback<Void>() {
- @Override
- public void onSuccess(Void result) {
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_group_detail_recursiveChange(group.getName())));
- }
+ FormItem recursiveItem;
+ if (isEditable) {
+ CheckboxEditableFormItem editableRecursiveItem = new CheckboxEditableFormItem("recursive", MSG.view_group_summary_recursive());
+ editableRecursiveItem.setValueEditedHandler(new ValueEditedHandler() {
+ public void editedValue(Object newValue) {
+ boolean isRecursive = ((newValue != null) && (Boolean)newValue);
+ resourceGroupService.setRecursive(group.getId(), isRecursive, new AsyncCallback<Void>() {
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_group_detail_recursiveChange(group.getName())));
+ }
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_group_detail_failRecursiveChange(String.valueOf(group.getName())));
- }
- });
- }
- });
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_group_detail_failRecursiveChange(String.valueOf(group.getName())));
+ }
+ });
+ }
+ });
+ recursiveItem = editableRecursiveItem;
+ } else {
+ recursiveItem = new StaticTextItem("recursive", MSG.view_group_summary_recursive());
+ }
recursiveItem.setValue((group.isRecursive()) ? MSG.common_val_yes() : MSG.common_val_no());
formItems.add(recursiveItem);
@@ -214,20 +235,21 @@ public class GeneralProperties extends LocatableVLayout {
lastModifiedByItem.setValue(group.getModifiedBy());
formItems.add(lastModifiedByItem);
- if (dynamic) {
+ if (isDynaGroup) {
StaticTextItem groupDefinitionItem = new StaticTextItem("groupDefinition", MSG
.view_group_summary_groupDefinition());
GroupDefinition groupDefinition = group.getGroupDefinition();
String groupDefinitionUrl = LinkManager.getGroupDefinitionLink(groupDefinition.getId());
+ String groupDefinitionName = StringUtility.escapeHtml(groupDefinition.getName());
groupDefinitionItem
- .setValue("<a href=\"" + groupDefinitionUrl + "\">" + groupDefinition.getName() + "</a>");
+ .setValue("<a href=\"" + groupDefinitionUrl + "\">" + groupDefinitionName + "</a>");
formItems.add(groupDefinitionItem);
}
generalPropsForm.setItems(formItems.toArray(new FormItem[formItems.size()]));
addMember(generalPropsForm);
- if (dynamic) {
+ if (isDynaGroup) {
spacer = new HLayout();
spacer.setHeight(10);
addMember(spacer);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java
index 7547339..dfe6bdb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java
@@ -277,8 +277,9 @@ public class OverviewForm extends EnhancedDynamicForm {
// Version
StaticTextItem versionItem = new StaticTextItem("version", MSG.view_summaryOverviewForm_field_version());
- versionItem.setValue((resource.getVersion() != null) ? resource.getVersion() : "<i>" + MSG.common_label_none()
- + "</i>");
+ String version = (resource.getVersion() != null) ? resource.getVersion() : "<i>" + MSG.common_label_none()
+ + "</i>";
+ versionItem.setValue(version);
versionItem.setEndRow(true);
formItems.add(versionItem);
commit ce940eefcecc42c3a4c545dc17010d7773725a6c
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Mar 31 17:28:25 2011 -0400
...
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java
index 0c93099..e14b9db 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010-2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -19,6 +19,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.util;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* A collection of utility methods for working with Strings.
*
@@ -27,6 +30,41 @@ package org.rhq.enterprise.gui.coregui.client.util;
public class StringUtility {
/**
+ * Split a string on delimiter boundaries, and place each element into a List.
+ *
+ * @param s String to split up
+ * @param delim Delimiting token, ala StringTokenizer
+ *
+ * @return a List comprised of elements split by the tokenizing
+ */
+ public static List<String> explode(String s, String delim) {
+ List<String> res = new ArrayList<String>();
+ if (s == null)
+ return res;
+
+ String[] tokens = s.split(delim);
+ for (String token : tokens) {
+ res.add(token);
+ }
+
+ return res;
+ }
+
+ // TODO: I18N. The logic here may need to be pluggable for different localizations.
+ public static String pluralize(String singularNoun) {
+ String pluralNoun;
+ if (singularNoun.endsWith("y") && !singularNoun.endsWith("ay") && !singularNoun.endsWith("ey")
+ && !singularNoun.endsWith("oy")) {
+ pluralNoun = singularNoun.substring(0, singularNoun.length() - 1) + "ies";
+ } else if (!singularNoun.endsWith("s")) {
+ pluralNoun = singularNoun + "s";
+ } else {
+ pluralNoun = singularNoun;
+ }
+ return pluralNoun;
+ }
+
+ /**
* Escapes HTML in a string to eliminate cross site scripting (XSS) vulnerabilities. Note, this impl is designed
* to be highly efficient to minimize the impact on performance.
*
commit 170b9a147fce855f8196a7e13803e5a0e3d2f7bb
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Mar 31 17:25:56 2011 -0400
escape or sanitize HTML in user-controlled text, which could be used for XSS attacks
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
index 58cde04..178acd0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
@@ -305,11 +305,13 @@ public class RoleEditView extends AbstractRecordEditor<RolesDataSource> implemen
TextItem nameItem = new TextItem(RolesDataSource.Field.NAME);
nameItem.setShowTitle(true);
+ nameItem.setAttribute(EnhancedDynamicForm.OUTPUT_AS_HTML_ATTRIBUTE, true);
items.add(nameItem);
TextItem descriptionItem = new TextItem(RolesDataSource.Field.DESCRIPTION);
descriptionItem.setShowTitle(true);
descriptionItem.setColSpan(form.getNumCols());
+ descriptionItem.setAttribute(EnhancedDynamicForm.OUTPUT_AS_HTML_ATTRIBUTE, true);
items.add(descriptionItem);
return items;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
index 46fa148..6aaf418 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
@@ -34,6 +34,7 @@ import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.admin.AdministrationView;
+import org.rhq.enterprise.gui.coregui.client.components.table.EscapedHtmlCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
@@ -62,6 +63,7 @@ public class RolesView extends TableSection<RolesDataSource> implements Bookmark
final RolesDataSource datasource = RolesDataSource.getInstance();
setDataSource(datasource);
setHeaderIcon(HEADER_ICON);
+ setEscapeHtmlInDetailsLinkColumn(true);
}
@Override
@@ -108,6 +110,7 @@ public class RolesView extends TableSection<RolesDataSource> implements Bookmark
fields.add(nameField);
ListGridField descriptionField = new ListGridField(RolesDataSource.Field.DESCRIPTION);
+ descriptionField.setCellFormatter(new EscapedHtmlCellFormatter());
fields.add(descriptionField);
return fields;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
index 4ce9950..ba10fef 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
@@ -137,6 +137,7 @@ public class UserEditView extends AbstractRecordEditor<UsersDataSource> {
nameItem = new TextItem(UsersDataSource.Field.NAME);
} else {
nameItem = new StaticTextItem(UsersDataSource.Field.NAME);
+ ((StaticTextItem)nameItem).setOutputAsHTML(true);
}
items.add(nameItem);
@@ -167,20 +168,25 @@ public class UserEditView extends AbstractRecordEditor<UsersDataSource> {
TextItem firstNameItem = new TextItem(UsersDataSource.Field.FIRST_NAME);
firstNameItem.setShowTitle(true);
+ firstNameItem.setAttribute(EnhancedDynamicForm.OUTPUT_AS_HTML_ATTRIBUTE, true);
items.add(firstNameItem);
TextItem lastNameItem = new TextItem(UsersDataSource.Field.LAST_NAME);
lastNameItem.setShowTitle(true);
+ lastNameItem.setAttribute(EnhancedDynamicForm.OUTPUT_AS_HTML_ATTRIBUTE, true);
items.add(lastNameItem);
TextItem emailAddressItem = new TextItem(UsersDataSource.Field.EMAIL_ADDRESS);
emailAddressItem.setShowTitle(true);
+ emailAddressItem.setAttribute(EnhancedDynamicForm.OUTPUT_AS_HTML_ATTRIBUTE, true);
items.add(emailAddressItem);
TextItem phoneNumberItem = new TextItem(UsersDataSource.Field.PHONE_NUMBER);
+ phoneNumberItem.setAttribute(EnhancedDynamicForm.OUTPUT_AS_HTML_ATTRIBUTE, true);
items.add(phoneNumberItem);
TextItem departmentItem = new TextItem(UsersDataSource.Field.DEPARTMENT);
+ departmentItem.setAttribute(EnhancedDynamicForm.OUTPUT_AS_HTML_ATTRIBUTE, true);
items.add(departmentItem);
boolean userBeingEditedIsRhqadmin = (getRecordId() == SUBJECT_ID_RHQADMIN);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
index d6f536b..6bdf6a5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
@@ -107,7 +107,9 @@ public class UsersDataSource extends RPCDataSource<Subject, SubjectCriteria> {
fields.add(idDataField);
DataSourceTextField usernameField = createTextField(Field.NAME, MSG.dataSource_users_field_name(), 3, 100, true);
-
+ // Don't allow characters that could be used in HTML intended for an XSS attack.
+ RegExpValidator regExpValidator = new RegExpValidator("[^&<]*");
+ usernameField.setValidators(regExpValidator);
fields.add(usernameField);
DataSourceTextField ldapField = createBooleanField(Field.LDAP, MSG.dataSource_users_field_ldap(), true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
index f124703..4fae91e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.authz.Permission;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.admin.AdministrationView;
+import org.rhq.enterprise.gui.coregui.client.components.table.EscapedHtmlCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
@@ -64,6 +65,7 @@ public class UsersView extends TableSection<UsersDataSource> {
setDataSource(dataSource);
setHeaderIcon(HEADER_ICON);
+ setEscapeHtmlInDetailsLinkColumn(true);
fetchManageSecurityPermissionAsync();
}
@@ -131,12 +133,15 @@ public class UsersView extends TableSection<UsersDataSource> {
fields.add(ldapField);
ListGridField firstNameField = new ListGridField(UsersDataSource.Field.FIRST_NAME, 150);
+ firstNameField.setCellFormatter(new EscapedHtmlCellFormatter());
fields.add(firstNameField);
ListGridField lastNameField = new ListGridField(UsersDataSource.Field.LAST_NAME, 150);
+ lastNameField.setCellFormatter(new EscapedHtmlCellFormatter());
fields.add(lastNameField);
ListGridField departmentField = new ListGridField(UsersDataSource.Field.DEPARTMENT, 150);
+ departmentField.setCellFormatter(new EscapedHtmlCellFormatter());
fields.add(departmentField);
// TODO: instead of fetching roles, use a composite object that will pull the role count across the wire.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index 376d659..4d8b846 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -34,9 +35,11 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.EscapedHtmlCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
/**
* Superclass to the different alert definition views. This should be subclassed
@@ -48,6 +51,8 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
public AbstractAlertDefinitionsView(String locatorId, String tableTitle) {
super(locatorId, tableTitle);
+
+ setEscapeHtmlInDetailsLinkColumn(true);
}
@Override
@@ -66,6 +71,12 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
listGrid.setFixedRecordHeights(false);
//listGrid.getField("id").setWidth(55);
+ // name and description are user-editable, so escape HTML to prevent XSS attacks
+ ListGridField nameField = listGrid.getField(AbstractAlertDefinitionsDataSource.FIELD_NAME);
+ nameField.setCellFormatter(new EscapedHtmlCellFormatter());
+ ListGridField descriptionField = listGrid.getField(AbstractAlertDefinitionsDataSource.FIELD_DESCRIPTION);
+ descriptionField.setCellFormatter(new EscapedHtmlCellFormatter());
+
boolean permitted = isAllowedToModifyAlertDefinitions();
TableActionEnablement enablement = (permitted) ? TableActionEnablement.ALWAYS : TableActionEnablement.NEVER;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
index 90f09f4..7d6b0d5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
@@ -209,11 +209,15 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
nameTextField.setWidth(300);
nameTextField.setDefaultValue("");
nameStatic = new StaticTextItem("nameStatic", MSG.common_title_name());
+ // name is user-editable, so escape HTML to prevent XSS attacks
+ nameStatic.setOutputAsHTML(true);
descriptionTextField = new TextAreaItem("description", MSG.common_title_description());
descriptionTextField.setWidth(300);
descriptionTextField.setDefaultValue("");
descriptionStatic = new StaticTextItem("descriptionStatic", MSG.common_title_description());
+ // description is user-editable, so escape HTML to prevent XSS attacks
+ descriptionStatic.setOutputAsHTML(true);
prioritySelection = new SelectItem("priority", MSG.view_alerts_field_priority());
LinkedHashMap<String, String> priorities = new LinkedHashMap<String, String>(3);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
index 42711b6..b2763d9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
@@ -40,8 +40,10 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.bundle.list.BundleVersionDataSource;
+import org.rhq.enterprise.gui.coregui.client.components.table.EscapedHtmlCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
/**
* @author Greg Hinkle
@@ -76,16 +78,21 @@ public class BundleDeploymentListView extends Table<BundleDeploymentDataSource>
// only users that are authorized can see deployments
if (canManageBundles) {
nameField.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord record, int i, int i1) {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
return "<a href=\""
+ LinkManager.getBundleDeploymentLink(record
.getAttributeAsInt(BundleDeploymentDataSource.FIELD_BUNDLE_ID), record
- .getAttributeAsInt(BundleDeploymentDataSource.FIELD_ID)) + "\">" + String.valueOf(o)
+ .getAttributeAsInt(BundleDeploymentDataSource.FIELD_ID)) + "\">"
+ + StringUtility.escapeHtml(String.valueOf(value))
+ "</a>";
}
});
+ } else {
+ nameField.setCellFormatter(new EscapedHtmlCellFormatter());
}
+ descriptionField.setCellFormatter(new EscapedHtmlCellFormatter());
+
bundleVersionField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord record, int i, int i1) {
return "<a href=\""
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
index c00a454..62bf4ed 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
@@ -77,6 +77,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tagging.TagEditorView;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagsChangedCallback;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
@@ -146,7 +147,7 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
LinkItem bundleName = new LinkItem("bundle");
bundleName.setTitle(MSG.view_bundle_bundle());
bundleName.setValue(LinkManager.getBundleLink(bundle.getId()));
- bundleName.setLinkTitle(bundle.getName());
+ bundleName.setLinkTitle(StringUtility.escapeHtml(bundle.getName()));
bundleName.setTarget("_self");
CanvasItem actionItem = new CanvasItem("actions");
@@ -172,14 +173,14 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
LinkItem destinationGroup = new LinkItem("group");
destinationGroup.setTitle(MSG.common_title_resource_group());
destinationGroup.setValue(LinkManager.getResourceGroupLink(deployment.getDestination().getGroup().getId()));
- destinationGroup.setLinkTitle(deployment.getDestination().getGroup().getName());
+ destinationGroup.setLinkTitle(StringUtility.escapeHtml((deployment.getDestination().getGroup().getName())));
destinationGroup.setTarget("_self");
StaticTextItem path = new StaticTextItem("path", MSG.view_bundle_deployDir());
path.setValue(deployment.getDestination().getDeployDir());
StaticTextItem description = new StaticTextItem("description", MSG.common_title_description());
- description.setValue(deployment.getDescription());
+ description.setValue(StringUtility.escapeHtml(deployment.getDescription()));
StaticTextItem status = new StaticTextItem("status", MSG.common_title_status());
status.setValue(deployment.getStatus().name());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
index d3ca12c..bbd20f6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
@@ -38,6 +38,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
/**
* @author Greg Hinkle
@@ -77,24 +78,27 @@ public class BundleDestinationListView extends Table<BundleDestinationDataSource
TimestampCellFormatter.prepareDateField(latestDeploymentDateField);
nameField.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ public String format(Object value, ListGridRecord listGridRecord, int i, int i1) {
Integer bundleId = listGridRecord.getAttributeAsInt(BundleDestinationDataSource.FIELD_BUNDLE_ID);
Integer bundleDestId = listGridRecord.getAttributeAsInt(BundleDestinationDataSource.FIELD_ID);
- return "<a href=\"" + LinkManager.getBundleDestinationLink(bundleId, bundleDestId) + "\">" + o + "</a>";
+ return "<a href=\"" + LinkManager.getBundleDestinationLink(bundleId, bundleDestId) + "\">"
+ + StringUtility.escapeHtml(value.toString()) + "</a>";
}
});
groupNameField.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ public String format(Object value, ListGridRecord listGridRecord, int i, int i1) {
Integer groupId = listGridRecord.getAttributeAsInt(BundleDestinationDataSource.FIELD_GROUP_ID);
- return "<a href=\"" + LinkManager.getResourceGroupLink(groupId) + "\">" + o + "</a>";
+ return "<a href=\"" + LinkManager.getResourceGroupLink(groupId) + "\">"
+ + StringUtility.escapeHtml(value.toString()) + "</a>";
}
});
bundleNameField.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ public String format(Object value, ListGridRecord listGridRecord, int i, int i1) {
Integer bid = listGridRecord.getAttributeAsInt(BundleDestinationDataSource.FIELD_BUNDLE_ID);
- return "<a href=\"" + LinkManager.getBundleLink(bid) + "\">" + o + "</a>";
+ return "<a href=\"" + LinkManager.getBundleLink(bid) + "\">"
+ + StringUtility.escapeHtml(value.toString()) + "</a>";
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
index da52896..0a805e0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
@@ -57,6 +57,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tagging.TagEditorView;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagsChangedCallback;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
@@ -89,10 +90,10 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
this.bundle = bundleDestination.getBundle();
BackButton backButton = new BackButton(extendLocatorId("BackButton"), MSG.view_bundle_dest_backToBundle()
- + ": " + bundle.getName(), "Bundles/Bundle/" + bundle.getId());
+ + ": " + StringUtility.escapeHtml(bundle.getName()), "Bundles/Bundle/" + bundle.getId());
HeaderLabel header = new HeaderLabel(Canvas.getImgURL("subsystems/bundle/BundleDestination_24.png"),
- destination.getName());
+ StringUtility.escapeHtml(destination.getName()));
detail = new Canvas();
detail.setHeight("50%");
@@ -121,7 +122,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
LinkItem bundleName = new LinkItem("bundle");
bundleName.setTitle(MSG.view_bundle_bundle());
bundleName.setValue(LinkManager.getBundleLink(bundle.getId()));
- bundleName.setLinkTitle(bundle.getName());
+ bundleName.setLinkTitle(StringUtility.escapeHtml(bundle.getName()));
bundleName.setTarget("_self");
CanvasItem actionItem = new CanvasItem("actions");
@@ -136,14 +137,14 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
LinkItem destinationGroup = new LinkItem("group");
destinationGroup.setTitle(MSG.view_bundle_dest_group());
destinationGroup.setValue(LinkManager.getResourceGroupLink(destination.getGroup().getId()));
- destinationGroup.setLinkTitle(destination.getGroup().getName());
+ destinationGroup.setLinkTitle(StringUtility.escapeHtml(destination.getGroup().getName()));
destinationGroup.setTarget("_self");
StaticTextItem path = new StaticTextItem("path", MSG.view_bundle_dest_deployDir());
path.setValue(destination.getDeployDir());
StaticTextItem description = new StaticTextItem("description", MSG.common_title_description());
- description.setValue(destination.getDescription());
+ description.setValue(StringUtility.escapeHtml(destination.getDescription()));
form.setFields(bundleName, actionItem, created, destinationGroup, path, description);
return form;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
index f4801ea..74eaa68 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
@@ -60,6 +60,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tagging.TagEditorView;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagsChangedCallback;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
@@ -98,7 +99,7 @@ public class BundleView extends LocatableVLayout implements BookmarkableView {
BackButton backButton = new BackButton(extendLocatorId("BackButton"), MSG.view_bundle_list_backToAll(),
BundleTopView.VIEW_ID.getTitle());
- headerLabel = new HeaderLabel("subsystems/bundle/Bundle_24.png", bundle.getName());
+ headerLabel = new HeaderLabel("subsystems/bundle/Bundle_24.png", StringUtility.escapeHtml(bundle.getName()));
tabs = new LocatableTabSet(getLocatorId());
versionsTab = createVersionsTab();
destinationsTab = createDestinationsTab();
@@ -188,7 +189,7 @@ public class BundleView extends LocatableVLayout implements BookmarkableView {
destinationsCountItem.setValue(bundle.getDestinations() != null ? bundle.getDestinations().size() : 0);
StaticTextItem descriptionItem = new StaticTextItem("description", MSG.common_title_description());
- descriptionItem.setValue(bundle.getDescription());
+ descriptionItem.setValue(StringUtility.escapeHtml(bundle.getDescription()));
form.setFields(versionCountItem, actionItem, destinationsCountItem, descriptionItem);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
index 023fd1f..ea25046 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
@@ -47,6 +47,7 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablem
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
@@ -80,7 +81,6 @@ public class BundlesListView extends Table<BundlesWithLatestVersionDataSource> {
@Override
protected void configureTable() {
-
ListGridField idField = new ListGridField(BundlesWithLatestVersionDataSource.FIELD_ID, MSG.common_title_id());
idField.setType(ListGridFieldType.INTEGER);
idField.setWidth("50");
@@ -89,15 +89,20 @@ public class BundlesListView extends Table<BundlesWithLatestVersionDataSource> {
.common_title_name());
nameField.setWidth("33%");
nameField.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord record, int i, int i1) {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
return "<a href=\"" + record.getAttribute(BundlesWithLatestVersionDataSource.FIELD_NAMELINK) + "\">"
- + String.valueOf(o) + "</a>";
+ + StringUtility.escapeHtml(String.valueOf(value)) + "</a>";
}
});
ListGridField descField = new ListGridField(BundlesWithLatestVersionDataSource.FIELD_DESCRIPTION, MSG
.common_title_description());
descField.setWidth("33%");
+ descField.setCellFormatter(new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
+ return StringUtility.escapeHtml(String.valueOf(value));
+ }
+ });
ListGridField latestVersionField = new ListGridField(BundlesWithLatestVersionDataSource.FIELD_LATEST_VERSION,
MSG.view_bundle_latestVersion());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/GetRevertInfoStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/GetRevertInfoStep.java
index 552ab4d..33d20e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/GetRevertInfoStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/GetRevertInfoStep.java
@@ -31,6 +31,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -68,24 +69,27 @@ public class GetRevertInfoStep extends AbstractWizardStep {
.getId(), //
new AsyncCallback<String>() {
- public void onSuccess(String result) {
+ public void onSuccess(String bundleDeploymentName) {
final StaticTextItem nameTextItem = new StaticTextItem("name", MSG
.view_bundle_revertWizard_getInfoStep_revertDeployName());
nameTextItem.setWidth(300);
- wizard.setSubtitle(result);
- nameTextItem.setValue(result);
+ String escapedBundleDeploymentName = StringUtility.escapeHtml(bundleDeploymentName);
+ wizard.setSubtitle(escapedBundleDeploymentName);
+ nameTextItem.setValue(escapedBundleDeploymentName);
final TextAreaItem descriptionTextAreaItem = new TextAreaItem("description", MSG
.view_bundle_revertWizard_getInfoStep_revertDeployDesc());
descriptionTextAreaItem.setWidth(300);
String liveDesc = wizard.getLiveDeployment().getDescription();
liveDesc = (null == liveDesc) ? wizard.getLiveDeployment().getName() : liveDesc;
+ String escapedLiveDesc = StringUtility.escapeHtml(liveDesc);
String prevDesc = wizard.getPreviousDeployment().getDescription();
prevDesc = (null == prevDesc) ? wizard.getPreviousDeployment().getName() : prevDesc;
- wizard.setDeploymentDescription("[REVERT From]\n" + liveDesc + "\n\n[REVERT To]\n" + prevDesc);
+ String escapedPrevDesc = StringUtility.escapeHtml(prevDesc);
+ wizard.setDeploymentDescription("[REVERT From]\n" + escapedLiveDesc + "\n\n[REVERT To]\n" + escapedPrevDesc);
wizard.setDeploymentDescription(MSG.view_bundle_revertWizard_getInfoStep_revertDeployDescFull(
- liveDesc, prevDesc));
- descriptionTextAreaItem.setValue(wizard.getDeploymentDescription());
+ escapedLiveDesc, escapedPrevDesc));
+ descriptionTextAreaItem.setValue(StringUtility.escapeHtml(wizard.getDeploymentDescription()));
descriptionTextAreaItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
Object value = event.getValue();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
index 039bc3e..39b84e7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
@@ -49,6 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
/**
* @author Greg Hinkle
@@ -244,7 +245,7 @@ public class BundleTreeDataSource extends RPCDataSource<Object, Criteria> {
node.setIsFolder(true);
node.setIcon("subsystems/bundle/Bundle_16.png");
node.setID(String.valueOf(bundle.getId()));
- node.setName(bundle.getName());
+ node.setName(StringUtility.escapeHtml(bundle.getName()));
} else if (from instanceof BundleVersion) {
BundleVersion version = (BundleVersion) from;
@@ -262,10 +263,11 @@ public class BundleTreeDataSource extends RPCDataSource<Object, Criteria> {
parentID = bundleId + "_destinations_" + deployment.getDestination().getId();
node.setParentID(parentID);
node.setID(bundleId + "_deployments_" + deployment.getId());
+ String name = StringUtility.escapeHtml(deployment.getName());
if (deployment.isLive()) {
- node.setName("<span style=\"color: green; font-weight: bold\">(live)</span> " + deployment.getName());
+ node.setName("<span style=\"color: green; font-weight: bold\">(live)</span> " + name);
} else {
- node.setName(deployment.getName());
+ node.setName(name);
}
} else if (from instanceof BundleDestination) {
@@ -275,7 +277,7 @@ public class BundleTreeDataSource extends RPCDataSource<Object, Criteria> {
parentID = destination.getBundle().getId() + "_destinations";
node.setParentID(parentID);
node.setID(parentID + '_' + destination.getId());
- node.setName(destination.getName());
+ node.setName(StringUtility.escapeHtml(destination.getName()));
}
return node;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index ac2d132..35d61f2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -1261,7 +1261,10 @@ public class ConfigurationEditor extends LocatableVLayout {
// TODO (ips, 03/25/11): We eventually want to use StaticTextItems for read-only PASSWORD props too, but we have
// to wait until we implement masking/unmasking of PASSWORD props at the SLSB layer first.
if (propertyIsReadOnly && propertyDefinitionSimple.getType() != PropertySimpleType.PASSWORD) {
- valueItem = new StaticTextItem();
+ StaticTextItem staticItem = new StaticTextItem();
+ // Property values are user-editable, so escape HTML to prevent an XSS attack.
+ staticItem.setOutputAsHTML(true);
+ valueItem = staticItem;
} else {
List<PropertyDefinitionEnumeration> enumeratedValues = propertyDefinitionSimple.getEnumeratedValues();
if (enumeratedValues != null && !enumeratedValues.isEmpty()) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java
index 59c8b9d..02c2752 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2010 Red Hat, Inc.
+ * Copyright (C) 2010-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -45,6 +45,8 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class EnhancedDynamicForm extends LocatableDynamicForm {
+ public static final String OUTPUT_AS_HTML_ATTRIBUTE = "outputAsHTML";
+
private static final String FIELD_ID = "id";
private boolean isReadOnly;
@@ -116,6 +118,10 @@ public class EnhancedDynamicForm extends LocatableDynamicForm {
staticItem.setTooltip(item.getTooltip());
staticItem.setValue(item.getDisplayValue());
staticItem.setColSpan(item.getAttribute("colSpan"));
+ Boolean outputAsHtml = item.getAttributeAsBoolean(OUTPUT_AS_HTML_ATTRIBUTE);
+ if (Boolean.TRUE.equals(outputAsHtml)) {
+ staticItem.setOutputAsHTML(true);
+ }
// TODO: Any other fields we should copy? icons?
if ((item instanceof BooleanItem) || (item instanceof CheckboxItem)) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/EscapedHtmlCellFormatter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/EscapedHtmlCellFormatter.java
new file mode 100644
index 0000000..c60236c
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/EscapedHtmlCellFormatter.java
@@ -0,0 +1,19 @@
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
+
+/**
+ * A cell formatter that escapes any HTML in the cell's value.
+ *
+ * @author Ian Springer
+ */
+public class EscapedHtmlCellFormatter implements CellFormatter {
+
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ return (value != null) ? StringUtility.escapeHtml(value.toString()) : "";
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/IconField.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/IconField.java
new file mode 100644
index 0000000..82d6071
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/IconField.java
@@ -0,0 +1,73 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.widgets.grid.ListGridField;
+
+/**
+ * @author Ian Springer
+ */
+public class IconField extends ListGridField {
+
+ private static final String DEFAULT_NAME = "icon";
+ private static final String DEFAULT_TITLE = " ";
+ private static final int DEFAULT_WIDTH = 25;
+
+ public IconField() {
+ super(DEFAULT_NAME, DEFAULT_TITLE, DEFAULT_WIDTH);
+ init();
+ }
+
+ public IconField(JavaScriptObject jsObj) {
+ super(DEFAULT_NAME, DEFAULT_TITLE, DEFAULT_WIDTH);
+ setJsObj(jsObj);
+ init();
+ }
+
+ public IconField(String name) {
+ super(name, DEFAULT_TITLE, DEFAULT_WIDTH);
+ init();
+ }
+
+ public IconField(String name, int width) {
+ super(name, DEFAULT_TITLE, width);
+ init();
+ }
+
+ public IconField(String name, String title) {
+ super(name, title, DEFAULT_WIDTH);
+ init();
+ }
+
+ public IconField(String name, String title, int width) {
+ super(name, title, width);
+ init();
+ }
+
+ private void init() {
+ setType(ListGridFieldType.IMAGE);
+ setAlign(Alignment.CENTER);
+ setShowDefaultContextMenu(false);
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
index e551deb..b19abfd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -44,6 +44,7 @@ import org.rhq.enterprise.gui.coregui.client.DetailsView;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
@@ -56,6 +57,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
private VLayout detailsHolder;
private Canvas detailsView;
private String basePath;
+ private boolean escapeHtmlInDetailsLinkColumn;
protected TableSection(String locatorId, String tableTitle) {
super(locatorId, tableTitle);
@@ -110,7 +112,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
/**
* The default implementation wraps the {@link getDetailsLinkColumnCellFormatter()} column with the
- * {@link getDetailsLinkColumnCellFormatter()}. This is typically the 'name' column linking to the detail
+ * {@link #getDetailsLinkColumnCellFormatter()}. This is typically the 'name' column linking to the detail
* view, given the 'id'. Also, establishes a double click handler for the row which invokes
* {@link showDetails()}</br>
* </br>
@@ -146,6 +148,10 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
return true;
}
+ public void setEscapeHtmlInDetailsLinkColumn(boolean escapeHtmlInDetailsLinkColumn) {
+ this.escapeHtmlInDetailsLinkColumn = escapeHtmlInDetailsLinkColumn;
+ }
+
/**
* Override if you don't want FIELD_NAME to be wrapped ina link.
* @return the name of the field to be wrapped, or null if no field should be wrapped.
@@ -161,9 +167,13 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
protected CellFormatter getDetailsLinkColumnCellFormatter() {
return new CellFormatter() {
public String format(Object value, ListGridRecord record, int i, int i1) {
+ if (value == null) {
+ return "";
+ }
Integer recordId = getId(record);
String detailsUrl = "#" + getBasePath() + "/" + recordId;
- return SeleniumUtility.getLocatableHref(detailsUrl, value.toString(), null);
+ String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString()) : value.toString();
+ return SeleniumUtility.getLocatableHref(detailsUrl, formattedValue, null);
}
};
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
index 15e13fa..1bae1e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2010 Red Hat, Inc.
+ * Copyright (C) 2010-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -24,6 +24,7 @@ import com.smartgwt.client.widgets.tree.TreeNode;
* @author Ian Springer
*/
public class EnhancedTreeNode extends TreeNode {
+
public EnhancedTreeNode() {
super();
}
@@ -55,7 +56,7 @@ public class EnhancedTreeNode extends TreeNode {
public void setName(String name) {
super.setName(name);
if (name != null && getTitle() == null) {
- setTitle(name);
+ super.setTitle(name);
}
}
@@ -110,4 +111,5 @@ public class EnhancedTreeNode extends TreeNode {
private Attributes() {
}
}
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 8fcaba0..f91c4cf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -49,6 +49,7 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.IconField;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableWidget;
import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
@@ -139,12 +140,9 @@ public class ProblemResourcesPortlet extends Table<ProblemResourcesDataSource> i
ListGridField alertsField = new ListGridField(ALERTS.propertyName(), ALERTS.title(), 70);
- ListGridField availabilityField = new ListGridField(AVAILABILITY.propertyName(), AVAILABILITY.title(), 70);
- availabilityField.setType(ListGridFieldType.IMAGE);
- availabilityField.setAlign(Alignment.CENTER);
+ IconField availabilityField = new IconField(AVAILABILITY.propertyName(), AVAILABILITY.title(), 70);
setListGridFields(resourceField, ancestryField, alertsField, availabilityField);
-
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/util/MessagePortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/util/MessagePortlet.java
index 8da6a8b..ead9cc2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/util/MessagePortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/util/MessagePortlet.java
@@ -34,6 +34,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.ConfigurablePortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
/**
@@ -46,15 +47,17 @@ public class MessagePortlet extends LocatableHTMLPane implements ConfigurablePor
// A default displayed, persisted name for the portlet
public static final String NAME = MSG.view_portlet_defaultName_message();
+ private static final String MESSAGE_PROPERTY = "message";
+
public MessagePortlet(String locatorId) {
super(locatorId);
setContentsType(ContentsType.PAGE);
}
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
- String contents = storedPortlet.getConfiguration().getSimpleValue("message", null);
+ String contents = storedPortlet.getConfiguration().getSimpleValue(MESSAGE_PROPERTY, null);
if (contents != null) {
- setContents(contents);
+ setContents(StringUtility.sanitizeHtml(contents));
} else {
setContents("<br/><i>" + MSG.view_portlet_configure_needed() + "</i>");
}
@@ -68,7 +71,7 @@ public class MessagePortlet extends LocatableHTMLPane implements ConfigurablePor
ConfigurationDefinition definition = new ConfigurationDefinition(MSG.view_portlet_configure_definitionTitle(),
MSG.view_portlet_configure_definitionDesc());
- definition.put(new PropertyDefinitionSimple("message", MSG.view_portlet_message_title(), true,
+ definition.put(new PropertyDefinitionSimple(MESSAGE_PROPERTY, MSG.view_portlet_message_title(), true,
PropertySimpleType.LONG_STRING));
return definition;
@@ -78,8 +81,8 @@ public class MessagePortlet extends LocatableHTMLPane implements ConfigurablePor
public static PortletViewFactory INSTANCE = new Factory();
public final Portlet getInstance(String locatorId) {
-
return new MessagePortlet(locatorId);
}
}
+
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDetailsView.java
index 27b1040..236e994 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDetailsView.java
@@ -167,6 +167,8 @@ public abstract class AbstractOperationHistoryDetailsView<T extends OperationHis
StaticTextItem requesterItem = new StaticTextItem(AbstractOperationHistoryDataSource.Field.SUBJECT, MSG
.view_operationHistoryDetails_requestor());
+
+ requesterItem.setOutputAsHTML(true);
requesterItem.setValue(operationHistory.getSubjectName());
items.add(requesterItem);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
index ff577d0..387c4d5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
@@ -263,7 +263,9 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
Integer integerValue = TypeConversionUtility.toInteger(value);
timeoutItem.setValue(integerValue, UnitType.TIME);
- FormItem notesItem = this.notesForm.getField(AbstractOperationScheduleDataSource.Field.DESCRIPTION);
+ StaticTextItem notesItem = (StaticTextItem) this.notesForm.getField(AbstractOperationScheduleDataSource.Field.DESCRIPTION);
+ // Notes field is user-editable, so escape HTML to prevent an XSS attack.
+ notesItem.setOutputAsHTML(true);
notesItem.setValue(getForm().getValue(AbstractOperationScheduleDataSource.Field.DESCRIPTION));
this.parameters = (Configuration) record.getAttributeAsObject(AbstractOperationScheduleDataSource.Field.PARAMETERS);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
index 82ac645..5fec813 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
@@ -401,7 +401,7 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
/** Create empty display row(LocatableDynamicForm) that is constently defined and displayed.
*
- * @param column Locatable parent colum.
+ * @param locatorId locator ID of Locatable parent column
* @param emptyMessage Contents of the empty region
* @return
*/
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
index 04fbfbd..a469fa9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -281,7 +281,9 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
ResourceGroupTreeView.this.rootResourceGroup = group;
ResourceGroupTreeView.this.rootGroupId = rootResourceGroup.getId();
ResourceGroupEnhancedTreeNode fakeRoot = new ResourceGroupEnhancedTreeNode("fakeRootNode");
- ResourceGroupEnhancedTreeNode rootNode = new ResourceGroupEnhancedTreeNode(group.getName());
+ String groupName = group.getName();
+ String escapedGroupName = StringUtility.escapeHtml(groupName);
+ ResourceGroupEnhancedTreeNode rootNode = new ResourceGroupEnhancedTreeNode(escapedGroupName);
String icon = ImageManager.getGroupIcon(GroupCategory.MIXED);
rootNode.setIcon(icon);
rootNode.setID(String.valueOf(rootResourceGroup.getId()));
@@ -387,7 +389,9 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
ResourceGroupEnhancedTreeNode fakeRoot = new ResourceGroupEnhancedTreeNode("fakeRootNode");
fakeRoot.setID(FAKE_ROOT_ID);
- ResourceGroupEnhancedTreeNode rootNode = new ResourceGroupEnhancedTreeNode(rootResourceGroup.getName());
+ String groupName = rootResourceGroup.getName();
+ String escapedGroupName = StringUtility.escapeHtml(groupName);
+ ResourceGroupEnhancedTreeNode rootNode = new ResourceGroupEnhancedTreeNode(escapedGroupName);
rootNode.setID(rootKey.getKey());
rootNode.setParentID(fakeRoot.getID());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
index 2393132..ba890d4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
@@ -34,6 +34,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
@@ -42,6 +43,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Jay Shaughnessy
*/
public abstract class AncestryUtil {
+
// ListGrid Record attribute names expected to be set on records processed by the utility
public static final String RESOURCE_ANCESTRY = "resourceAncestry";
public static final String RESOURCE_ANCESTRY_VALUE = "resourceAncestryDecoded";
@@ -115,8 +117,8 @@ public abstract class AncestryUtil {
continue;
}
String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM);
- for (int i = 0; i < ancestryEntries.length; ++i) {
- String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM);
+ for (String ancestryEntry : ancestryEntries) {
+ String[] entryTokens = ancestryEntry.split(Resource.ANCESTRY_ENTRY_DELIM);
int rtId = Integer.valueOf(entryTokens[0]);
result.add(rtId);
}
@@ -148,7 +150,7 @@ public abstract class AncestryUtil {
String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM);
int ancestorTypeId = Integer.valueOf(entryTokens[0]);
int ancestorResourceId = Integer.valueOf(entryTokens[1]);
- String ancestorName = entryTokens[2];
+ String ancestorName = StringUtility.escapeHtml(entryTokens[2]);
sbResources.append((i > 0) ? " < " : "");
//sbResources.append(" < ");
@@ -201,17 +203,15 @@ public abstract class AncestryUtil {
return "";
}
- Integer resourceId = record.getAttributeAsInt(RESOURCE_ID);
- // if not set assume the standard "id" attr is a resourceId
- resourceId = (null != resourceId) ? resourceId : record.getAttributeAsInt("id");
+ Integer resourceId = getResourceId(record);
StringBuilder sbResources = new StringBuilder();
String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM);
for (int i = 0; i < ancestryEntries.length; ++i) {
String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM);
int ancestorResourceId = Integer.valueOf(entryTokens[1]);
- String ancestorName = entryTokens[2];
+ String ancestorName = StringUtility.escapeHtml(entryTokens[2]);
- sbResources.append((i > 0) ? " < " : "");
+ sbResources.append((i > 0) ? " < " : "");
if (generateLinks) {
String url = LinkManager.getResourceLink(ancestorResourceId);
String suffix = resourceId + "_" + entryTokens[1];
@@ -231,18 +231,14 @@ public abstract class AncestryUtil {
return ancestryHover;
}
- Integer resourceId = listGridRecord.getAttributeAsInt(RESOURCE_ID);
- // if not set assume the standard "id" attr is a resourceId
- resourceId = (null != resourceId) ? resourceId : listGridRecord.getAttributeAsInt("id");
- String resourceName = listGridRecord.getAttribute(RESOURCE_NAME);
- // if not set assume the standard "name" attr is a resourceName
- resourceName = (null != resourceName) ? resourceName : listGridRecord.getAttribute("name");
+ String resourceName = getResourceName(listGridRecord);
+
Map<Integer, ResourceType> types = ((MapWrapper) listGridRecord.getAttributeAsObject(RESOURCE_ANCESTRY_TYPES))
.getMap();
Integer resourceTypeId = listGridRecord.getAttributeAsInt(RESOURCE_TYPE_ID);
String ancestry = listGridRecord.getAttributeAsString(RESOURCE_ANCESTRY);
- String result = getAncestryHoverHTMLString(resourceId, resourceName, ancestry, resourceTypeId, types, width);
+ String result = getAncestryHoverHTMLString(resourceName, ancestry, resourceTypeId, types, width);
listGridRecord.setAttribute(RESOURCE_ANCESTRY_HOVER, result);
return result;
@@ -250,12 +246,12 @@ public abstract class AncestryUtil {
public static String getAncestryHoverHTMLForResource(Resource resource, Map<Integer, ResourceType> types, int width) {
- return getAncestryHoverHTMLString(resource.getId(), resource.getName(), resource.getAncestry(), resource
+ return getAncestryHoverHTMLString(resource.getName(), resource.getAncestry(), resource
.getResourceType().getId(), types, width);
}
- private static String getAncestryHoverHTMLString(int resourceId, String resourceName, String ancestry,
- int resourceTypeId, Map<Integer, ResourceType> types, int width) {
+ private static String getAncestryHoverHTMLString(String resourceName, String ancestry,
+ int resourceTypeId, Map<Integer, ResourceType> types, int width) {
ResourceType type = types.get(resourceTypeId);
String resourceLongName = getResourceLongName(resourceName, type);
@@ -282,7 +278,7 @@ public abstract class AncestryUtil {
for (int i = ancestryEntries.length - 1, j = 0; i >= 0; --i, ++j) {
String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM);
int ancestorTypeId = Integer.valueOf(entryTokens[0]);
- String ancestorName = entryTokens[2];
+ String ancestorName = StringUtility.escapeHtml(entryTokens[2]);
// indent with spaces
if (j > 0) {
@@ -323,9 +319,10 @@ public abstract class AncestryUtil {
/**
* Get a resource name that combines type and resource information. This is useful for when we want to
- * use a single column for dispay of the resource "name". The name is wrapped in a navigable link.
+ * use a single column for display of the resource "name". The name is wrapped in a navigable link.
*
- * @param resource The resource
+ * @param record the resource record
+ * @param width the width, in pixels, of the returned HTML <code>p</code> tag
*
* @return the long name for the resource
*/
@@ -335,9 +332,7 @@ public abstract class AncestryUtil {
return resourceHover;
}
- String resourceName = record.getAttribute(RESOURCE_NAME);
- // if not set assume the standard "name" attr is a resourceName
- resourceName = (null != resourceName) ? resourceName : record.getAttribute("name");
+ String resourceName = getResourceName(record);
Map<Integer, ResourceType> types = ((MapWrapper) record.getAttributeAsObject(RESOURCE_ANCESTRY_TYPES)).getMap();
Integer resourceTypeId = record.getAttributeAsInt(RESOURCE_TYPE_ID);
ResourceType type = types.get(resourceTypeId);
@@ -365,6 +360,21 @@ public abstract class AncestryUtil {
return result;
}
+ private static Integer getResourceId(Record record) {
+ Integer resourceId = record.getAttributeAsInt(RESOURCE_ID);
+ // if not set assume the standard "id" attr is a resourceId
+ resourceId = (null != resourceId) ? resourceId : record.getAttributeAsInt("id");
+ return resourceId;
+ }
+
+ private static String getResourceName(Record record) {
+ String resourceName = record.getAttribute(RESOURCE_NAME);
+ // if not set assume the standard "name" attr is a resourceName
+ resourceName = (null != resourceName) ? resourceName : record.getAttribute("name");
+ resourceName = StringUtility.escapeHtml(resourceName);
+ return resourceName;
+ }
+
// We do not want smargwt to see we are storing our map into an attribute because it barfs on our key/value pairs
// so instead we have to wrap it in a non-Map POJO Object so smartgwt just handles it as a java.lang.Object.
public static class MapWrapper {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 32a6227..b53a127 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -33,8 +33,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.SortSpecifier;
-import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.events.DoubleClickEvent;
import com.smartgwt.client.widgets.events.DoubleClickHandler;
import com.smartgwt.client.widgets.grid.CellFormatter;
@@ -52,12 +50,14 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.table.RecordExtractor;
import org.rhq.enterprise.gui.coregui.client.components.table.ResourceAuthorizedTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.IconField;
import org.rhq.enterprise.gui.coregui.client.components.table.ResourceCategoryCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.TableUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
@@ -125,14 +125,9 @@ public class ResourceSearchView extends Table {
@Override
protected void configureTable() {
- ListGridField iconField = new ListGridField("icon", MSG.common_title_icon(), 25);
- iconField.setType(ListGridFieldType.IMAGE);
- iconField.setShowDefaultContextMenu(false);
- iconField.setCanSort(false);
- iconField.setTitle(" ");
+ IconField iconField = new IconField();
iconField.setShowHover(true);
iconField.setHoverCustomizer(new HoverCustomizer() {
- @Override
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
String resCat = record.getAttribute(CATEGORY.propertyName());
switch (ResourceCategory.valueOf(resCat)) {
@@ -149,14 +144,14 @@ public class ResourceSearchView extends Table {
ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
nameField.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("id"));
- return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String url = LinkManager.getResourceLink(record.getAttributeAsInt("id"));
+ String name = StringUtility.escapeHtml(value.toString());
+ return SeleniumUtility.getLocatableHref(url, name, null);
}
});
nameField.setShowHover(true);
nameField.setHoverCustomizer(new HoverCustomizer() {
-
public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
}
@@ -174,9 +169,7 @@ public class ResourceSearchView extends Table {
categoryField.setCellFormatter(new ResourceCategoryCellFormatter());
categoryField.setHidden(true); // the icon field already shows us this, no need to show it in another column
- ListGridField availabilityField = new ListGridField(AVAILABILITY.propertyName(), AVAILABILITY.title(), 70);
- availabilityField.setType(ListGridFieldType.IMAGE);
- availabilityField.setAlign(Alignment.CENTER);
+ IconField availabilityField = new IconField(AVAILABILITY.propertyName(), AVAILABILITY.title(), 70);
setListGridFields(iconField, nameField, ancestryField, descriptionField, typeNameField, pluginNameField,
categoryField, availabilityField);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
index bd86104..dcdffd9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
@@ -49,6 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagEditorView;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagsChangedCallback;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableImg;
@@ -310,7 +311,7 @@ public class ResourceTitleBar extends LocatableVLayout {
if (!resource.getName().equals(resourceName)) {
resource.setName(resourceName); // the name must have been changed by the user via the editable field
}
- this.title.setContents("<span class=\"SectionHeader\">" + resource.getName()
+ this.title.setContents("<span class=\"SectionHeader\">" + StringUtility.escapeHtml(resourceName)
+ "</span> <span class=\"subtitle\">" + resource.getResourceType().getName() + "</span>");
this.title.markForRedraw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
index 336e12e..6a38008 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
@@ -334,10 +334,14 @@ public class ResourceTreeDatasource extends DataSource {
}
this.setParentID(parentId);
+ // name and description are user-editable, so escape HTML to prevent XSS attacks
String name = resource.getName();
- setName(name);
+ String escapedName = StringUtility.escapeHtml(name);
+ setName(escapedName);
- setAttribute(Attributes.DESCRIPTION, resource.getDescription());
+ String description = resource.getDescription();
+ String escapedDescription = StringUtility.escapeHtml(description);
+ setAttribute(Attributes.DESCRIPTION, escapedDescription);
Set<ResourceType> childTypes = resource.getResourceType().getChildResourceTypes();
setIsFolder((childTypes != null && !childTypes.isEmpty()));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java
index 984ca22..0c93099 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/StringUtility.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -19,53 +19,72 @@
*/
package org.rhq.enterprise.gui.coregui.client.util;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* A collection of utility methods for working with Strings.
- *
- * TODO: I18N. The logic here may need to be pluggable for different localizations.
*
* @author Ian Springer
*/
public class StringUtility {
/**
- * Split a string on delimiter boundaries, and place each element into a List.
+ * Escapes HTML in a string to eliminate cross site scripting (XSS) vulnerabilities. Note, this impl is designed
+ * to be highly efficient to minimize the impact on performance.
*
- * @param s String to split up
- * @param delim Delimiting token, ala StringTokenizer
+ * @param string the string to be escaped
*
- * @return a List comprised of elements split by the tokenizing
+ * @return the escaped string
*/
-
- public static List<String> explode(String s, String delim) {
- List<String> res = new ArrayList<String>();
- if (s == null)
- return res;
-
- String[] tokens = s.split(delim);
- for (String token : tokens) {
- res.add(token);
+ public static String escapeHtml(String string) {
+ if (string == null) {
+ return null;
}
-
- return res;
+ StringBuilder buffer = null;
+ for (int i = 0; i < string.length(); i++) {
+ char c = string.charAt(i);
+ if (c == '&') {
+ if (buffer == null) {
+ buffer = new StringBuilder(string.substring(0, i));
+ }
+ buffer.append("&");
+ } else if (c == '<') {
+ if (buffer == null) {
+ buffer = new StringBuilder(string.substring(0, i));
+ }
+ buffer.append("<");
+ } else if (c == '>') {
+ if (buffer == null) {
+ buffer = new StringBuilder(string.substring(0, i));
+ }
+ buffer.append(">");
+ } else {
+ if (buffer != null) {
+ buffer.append(c);
+ }
+ }
+ }
+ return (buffer != null) ? buffer.toString() : string;
}
- public static String pluralize(String singularNoun) {
- String pluralNoun;
- if (singularNoun.endsWith("y") && !singularNoun.endsWith("ay") && !singularNoun.endsWith("ey")
- && !singularNoun.endsWith("oy")) {
- pluralNoun = singularNoun.substring(0, singularNoun.length() - 1) + "ies";
- } else if (!singularNoun.endsWith("s")) {
- pluralNoun = singularNoun + "s";
- } else {
- pluralNoun = singularNoun;
+ /**
+ * Sanitizes HTML (i.e. removes unsafe HTML such as SCRIPT tags) in a string to eliminate cross site scripting (XSS)
+ * vulnerabilities.
+ *
+ * @param string the string to be sanitized
+ *
+ * @return the sanitized string
+ */
+ // TODO (ips, 03/31/11): Replace this lame impl with a much more robust one - easiest way would be to upgrade to GWT
+ // 2.1 or later and use the new Safe HTML APIs. See also
+ // http://tomerdoron.blogspot.com/2011/03/less-simple-safe-html-sanitizer.html.
+ public static String sanitizeHtml(String string) {
+ if (string == null) {
+ return null;
}
- return pluralNoun;
+
+ return string.replaceAll("<script", "<script").replaceAll("<SCRIPT", "<SCRIPT");
}
private StringUtility() {
}
+
}
commit fec4fb5d697c886ca6ba8cb03b4686efedcb8815
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 31 16:55:59 2011 -0400
BZ 640396 - when you change the name of a resource or group, the title bar header name also changes now
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
index ba62aa4..fde8d13 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
@@ -54,10 +54,12 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
public class GeneralProperties extends LocatableVLayout {
private ResourceGroupGWTServiceAsync resourceGroupService = GWTServiceLookup.getResourceGroupService();
private ResourceGroupComposite groupComposite;
+ private final ResourceGroupTitleBar titleBar;
- public GeneralProperties(String locatorId, ResourceGroupComposite groupComposite) {
+ public GeneralProperties(String locatorId, ResourceGroupComposite groupComposite, ResourceGroupTitleBar titleBar) {
super(locatorId);
this.groupComposite = groupComposite;
+ this.titleBar = titleBar;
}
@Override
@@ -108,6 +110,8 @@ public class GeneralProperties extends LocatableVLayout {
}
public void onSuccess(Void result) {
+ titleBar.displayGroupName(newName);
+
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_group_summary_nameUpdateSuccessful(String.valueOf(group
.getId()), oldName, newName), Message.Severity.Info));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
index 26e826c..d8020f3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
@@ -137,7 +137,8 @@ public class ResourceGroupTitleBar extends LocatableVLayout {
ResourceGroupComposite resultComposite = result.get(0);
setGroupIcons(resultComposite);
- generalProperties = new GeneralProperties(extendLocatorId("genProps"), resultComposite);
+ generalProperties = new GeneralProperties(extendLocatorId("genProps"), resultComposite,
+ ResourceGroupTitleBar.this);
generalProperties.setVisible(false);
ResourceGroupTitleBar.this.addMember(generalProperties);
expandCollapseArrow.addClickHandler(new ClickHandler() {
@@ -234,6 +235,21 @@ public class ResourceGroupTitleBar extends LocatableVLayout {
this.group = groupComposite.getResourceGroup();
update();
+ displayGroupName(group.getName());
+
+ Set<Integer> favorites = UserSessionManager.getUserPreferences().getFavoriteResourceGroups();
+ this.favorite = favorites.contains(group.getId());
+ updateFavoriteButton();
+
+ setGroupIcons(groupComposite);
+ markForRedraw();
+ }
+
+ void displayGroupName(String groupName) {
+ if (!group.getName().equals(groupName)) {
+ group.setName(groupName); // the name must have been changed by the user via the editable field
+ }
+
String catName = null;
switch (group.getGroupCategory()) {
case COMPATIBLE: {
@@ -248,13 +264,7 @@ public class ResourceGroupTitleBar extends LocatableVLayout {
this.title.setContents("<span class=\"SectionHeader\">" + group.getName()
+ "</span> <span class=\"subtitle\">" + catName + "</span>");
-
- Set<Integer> favorites = UserSessionManager.getUserPreferences().getFavoriteResourceGroups();
- this.favorite = favorites.contains(group.getId());
- updateFavoriteButton();
-
- setGroupIcons(groupComposite);
- markForRedraw();
+ this.title.markForRedraw();
}
private void setGroupIcons(ResourceGroupComposite groupComposite) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java
new file mode 100644
index 0000000..7547339
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java
@@ -0,0 +1,336 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.EnumSet;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.HeaderItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.DisplayType;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem;
+import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.components.form.StringLengthValidator;
+import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem.ValueEditedHandler;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+
+/**
+ * The Resource Summary>Overview tab - Resource general properties + summary traits.
+ *
+ * @author Greg Hinkle
+ * @author Ian Springer
+ */
+public class OverviewForm extends EnhancedDynamicForm {
+
+ private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+ private ResourceComposite resourceComposite;
+ private boolean headerEnabled = true;
+ private boolean displayCondensed = false;
+ private final ResourceTitleBar titleBar;
+
+ public OverviewForm(String locatorId, ResourceComposite resourceComposite, ResourceTitleBar titleBar) {
+ super(locatorId);
+ this.resourceComposite = resourceComposite;
+ this.titleBar = titleBar;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ setLeft("10%");
+ setWidth("80%");
+ if (isDisplayCondensed()) {
+ setPadding(5);
+ setColWidths(150, 220, 150, 220);
+ setWidth("45%");
+ }
+
+ if (this.resourceComposite != null) {
+ setResource(this.resourceComposite);
+ }
+ }
+
+ public void setResource(ResourceComposite resourceComposite) {
+
+ this.resourceComposite = resourceComposite;
+ Resource resource = resourceComposite.getResource();
+
+ // Load metric defs.
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(),
+ EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+ public void onTypesLoaded(ResourceType type) {
+ buildForm(type);
+ loadTraitValues();
+ }
+ });
+ }
+
+ private void loadTraitValues() {
+ final Resource resource = resourceComposite.getResource();
+ GWTServiceLookup.getMeasurementDataService().findCurrentTraitsForResource(resource.getId(),
+ DisplayType.SUMMARY, new AsyncCallback<List<MeasurementDataTrait>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_summaryOverviewForm_error_traitsLoadFailure(resource.toString()), caught);
+ }
+
+ public void onSuccess(List<MeasurementDataTrait> result) {
+ for (MeasurementDataTrait trait : result) {
+ String formItemId = buildFormItemIdFromTraitDisplayName(trait.getName());
+ FormItem item = getItem(formItemId);
+ if (item != null) {
+ setValue(formItemId, trait.getValue());
+ }
+ }
+ markForRedraw();
+ }
+ });
+ }
+
+ private static String buildFormItemIdFromTraitDisplayName(String traitName) {
+ return traitName.replaceAll("\\.", "_").replaceAll(" ", "__");
+ }
+
+ private void buildForm(ResourceType type) {
+ List<MeasurementDefinition> traits = new ArrayList<MeasurementDefinition>();
+
+ for (MeasurementDefinition measurement : type.getMetricDefinitions()) {
+ if (measurement.getDataType() == DataType.TRAIT && measurement.getDisplayType() == DisplayType.SUMMARY) {
+ traits.add(measurement);
+ }
+ }
+
+ StringLengthValidator notEmptyOrNullValidator = new StringLengthValidator(1, null, false);
+ StringLengthValidator notNullValidator = new StringLengthValidator(null, null, false);
+
+ List<FormItem> formItems = new ArrayList<FormItem>();
+
+ if (isHeaderEnabled()) {//conditionally display header
+ HeaderItem headerItem = new HeaderItem("header", MSG.view_summaryOverviewForm_header_summary());
+ headerItem.setValue(MSG.view_summaryOverviewForm_header_summary());
+ formItems.add(headerItem);
+ }
+
+ // Type
+ StaticTextItem typeItem = new StaticTextItem("type", MSG.view_summaryOverviewForm_field_type());
+ typeItem.setTooltip(MSG.view_summaryOverviewForm_label_plugin() + type.getPlugin() + "\n<br>"
+ + MSG.view_summaryOverviewForm_label_type() + type.getName());
+ typeItem.setValue(AncestryUtil.getFormattedType(type));
+ formItems.add(typeItem);
+
+ final Resource resource = this.resourceComposite.getResource();
+ boolean modifiable = this.resourceComposite.getResourcePermission().isInventory();
+
+ // Name
+ final FormItem nameItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
+ nameItem.setName("name");
+ nameItem.setTitle(MSG.view_summaryOverviewForm_field_name());
+ nameItem.setValue(resource.getName());
+ if (nameItem instanceof EditableFormItem) {
+ EditableFormItem togglableNameItem = (EditableFormItem) nameItem;
+ togglableNameItem.setValidators(notEmptyOrNullValidator);
+ togglableNameItem.setValueEditedHandler(new ValueEditedHandler() {
+ public void editedValue(Object newValue) {
+ final String newName = newValue.toString();
+ final String oldName = resource.getName();
+ if (newName.equals(oldName)) {
+ return;
+ }
+ resource.setName(newName);
+ OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_summaryOverviewForm_error_nameChangeFailure(String.valueOf(resource.getId()),
+ oldName, newName), caught);
+ // We failed to update it on the Server, so change back the Resource and the form item to
+ // the original value.
+ resource.setName(oldName);
+ nameItem.setValue(oldName);
+ }
+
+ public void onSuccess(Void result) {
+ titleBar.displayResourceName(newName);
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(String
+ .valueOf(resource.getId()), oldName, newName), Message.Severity.Info));
+ }
+ });
+ }
+ });
+ }
+ formItems.add(nameItem);
+
+ // Description
+ final FormItem descriptionItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
+ descriptionItem.setName("description");
+ descriptionItem.setTitle(MSG.view_summaryOverviewForm_field_description());
+ descriptionItem.setValue(resource.getDescription());
+ if (descriptionItem instanceof EditableFormItem) {
+ EditableFormItem togglableDescriptionItem = (EditableFormItem) descriptionItem;
+ togglableDescriptionItem.setValidators(notNullValidator);
+ togglableDescriptionItem.setValueEditedHandler(new ValueEditedHandler() {
+ public void editedValue(Object newValue) {
+ final String newDescription = newValue.toString();
+ final String oldDescription = resource.getDescription();
+ if (newDescription.equals(oldDescription)) {
+ return;
+ }
+ resource.setDescription(newDescription);
+ OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_summaryOverviewForm_error_descriptionChangeFailure(String.valueOf(resource
+ .getId()), oldDescription, newDescription), caught);
+ // We failed to update it on the Server, so change back the Resource and the form item to
+ // the original value.
+ resource.setDescription(oldDescription);
+ descriptionItem.setValue(oldDescription);
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter()
+ .notify(
+ new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(String
+ .valueOf(resource.getId()), oldDescription, newDescription),
+ Message.Severity.Info));
+ }
+ });
+ }
+ });
+ }
+ formItems.add(descriptionItem);
+
+ // Location
+ final FormItem locationItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
+ locationItem.setName("location");
+ locationItem.setTitle(MSG.view_summaryOverviewForm_field_location());
+ locationItem.setValue(resource.getLocation());
+ if (locationItem instanceof EditableFormItem) {
+ EditableFormItem togglableLocationItem = (EditableFormItem) locationItem;
+ togglableLocationItem.setValidators(notNullValidator);
+ togglableLocationItem.setValueEditedHandler(new ValueEditedHandler() {
+ public void editedValue(Object newValue) {
+ final String newLocation = newValue.toString();
+ final String oldLocation = resource.getLocation();
+ if (newLocation.equals(oldLocation)) {
+ return;
+ }
+ resource.setLocation(newLocation);
+ OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_summaryOverviewForm_error_locationChangeFailure(String.valueOf(resource
+ .getId()), oldLocation, newLocation), caught);
+ // We failed to update it on the Server, so change back the Resource and the form item to
+ // the original value.
+ resource.setLocation(oldLocation);
+ locationItem.setValue(oldLocation);
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(String
+ .valueOf(resource.getId()), oldLocation, newLocation), Message.Severity.Info));
+ }
+ });
+ }
+ });
+ }
+ formItems.add(locationItem);
+
+ // Version
+ StaticTextItem versionItem = new StaticTextItem("version", MSG.view_summaryOverviewForm_field_version());
+ versionItem.setValue((resource.getVersion() != null) ? resource.getVersion() : "<i>" + MSG.common_label_none()
+ + "</i>");
+ versionItem.setEndRow(true);
+ formItems.add(versionItem);
+
+ // Traits
+ Collections.sort(traits, new Comparator<MeasurementDefinition>() {
+ public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
+ return new Integer(o1.getDisplayOrder()).compareTo(o2.getDisplayOrder());
+ }
+ });
+
+ for (MeasurementDefinition trait : traits) {
+ String formItemId = buildFormItemIdFromTraitDisplayName(trait.getDisplayName());
+ StaticTextItem formItem = new StaticTextItem(formItemId, trait.getDisplayName());
+ formItem.setTooltip(trait.getDescription());
+ formItems.add(formItem);
+ // item.setValue("?");
+ }
+
+ // SectionItem section = new SectionItem("Summary", "Summary");
+ // section.setTitle("Summary");
+ // section.setDefaultValue("Summary");
+ // section.setCanCollapse(true);
+ // section.setCellStyle("HidablePlainSectionHeader");
+ // section.setItemIds(itemIds.toArray(new String[itemIds.size()]));
+ // formItems.add(0, section);
+ if (!isDisplayCondensed()) {
+ formItems.add(new SpacerItem());
+ }
+
+ setItems(formItems.toArray(new FormItem[formItems.size()]));
+ }
+
+ public void loadData() {
+ // TODO: Reload the ResourceComposite too.
+ loadTraitValues();
+ markForRedraw();
+ }
+
+ public boolean isHeaderEnabled() {
+ return headerEnabled;
+ }
+
+ public void setHeaderEnabled(boolean headerEnabled) {
+ this.headerEnabled = headerEnabled;
+ }
+
+ public boolean isDisplayCondensed() {
+ return displayCondensed;
+ }
+
+ public void setDisplayCondensed(boolean displayCondensed) {
+ this.displayCondensed = displayCondensed;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsDataSource.java
new file mode 100644
index 0000000..0b8f830
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsDataSource.java
@@ -0,0 +1,106 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+
+import java.util.Date;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.rpc.RPCResponse;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.Criteria;
+import org.rhq.core.domain.resource.ResourceError;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author Lukas Krejci
+ * @author Simeon Pinder
+ * @author John Mazzitelli
+ */
+public class ResourceErrorsDataSource extends RPCDataSource<ResourceError, Criteria> {
+
+ public static abstract class Field {
+ public static final String ID = "id";
+ public static final String SUMMARY = "summary";
+ public static final String DETAIL = "detail";
+ public static final String ERROR_TYPE = "errorType";
+ public static final String TIME_OCCURED = "timeOccured";
+ }
+
+ ResourceGWTServiceAsync resourceService;
+ int resourceId;
+
+ public ResourceErrorsDataSource(int resourceId) {
+ resourceService = GWTServiceLookup.getResourceService();
+ this.resourceId = resourceId;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
+ resourceService.findResourceErrors(resourceId, new AsyncCallback<List<ResourceError>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.dataSource_resourceErrors_error_fetchFailure(String.valueOf(resourceId)), caught);
+ response.setStatus(RPCResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(List<ResourceError> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
+ public ResourceError copyValues(Record from) {
+ //This is read-only datasource, so no need to implement this.
+ return null;
+ }
+
+ @Override
+ public ListGridRecord copyValues(ResourceError from) {
+ ListGridRecord record = new ListGridRecord();
+
+ record.setAttribute(Field.ID, from.getId());
+ record.setAttribute(Field.DETAIL, from.getDetail());
+ record.setAttribute(Field.ERROR_TYPE, from.getErrorType().name());
+ record.setAttribute(Field.SUMMARY, from.getSummary());
+ record.setAttribute(Field.TIME_OCCURED, new Date(from.getTimeOccurred()));
+
+ return record;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsView.java
new file mode 100644
index 0000000..c881819
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsView.java
@@ -0,0 +1,189 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.AutoFitWidthApproach;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
+import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
+
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceErrorsDataSource.Field;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+
+public class ResourceErrorsView extends Table<ResourceErrorsDataSource> {
+ private static final String ERROR_ICON = "[SKIN]/Dialog/warn.png";
+
+ public ResourceErrorsView(String locatorId, String string, Criteria criteria, Object object, String[] strings) {
+ super(locatorId, MSG.common_title_component_errors(), criteria);
+ setWidth100();
+ setHeight100();
+ setShowHeader(false);
+ }
+
+ @Override
+ protected SelectionStyle getDefaultSelectionStyle() {
+ return SelectionStyle.MULTIPLE;
+ }
+
+ @Override
+ protected void configureTable() {
+ ListGridField errorTypeField = new ListGridField(Field.ERROR_TYPE, MSG
+ .dataSource_resourceErrors_field_errorType());
+ errorTypeField.setAlign(Alignment.CENTER);
+ errorTypeField.setAutoFitWidth(true);
+ errorTypeField.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
+
+ ListGridField timeField = new ListGridField(Field.TIME_OCCURED, MSG
+ .dataSource_resourceErrors_field_timeOccured());
+ timeField.setType(ListGridFieldType.DATE);
+ timeField.setAlign(Alignment.CENTER);
+ timeField.setWidth("20%");
+ TimestampCellFormatter.prepareDateField(timeField);
+
+ ListGridField summaryField = new ListGridField(Field.SUMMARY, MSG.dataSource_resourceErrors_field_summary());
+ summaryField.setAlign(Alignment.CENTER);
+ summaryField.setCellAlign(Alignment.LEFT);
+ summaryField.setWidth("*");
+
+ ListGridField iconField = new ListGridField("icon");
+ iconField.setType(ListGridFieldType.ICON);
+ iconField.setAlign(Alignment.CENTER);
+ iconField.setIcon(ERROR_ICON);
+ iconField.setCellIcon(ERROR_ICON);
+ iconField.setWidth("50");
+ iconField.setCanSort(false);
+ iconField.addRecordClickHandler(new RecordClickHandler() {
+ @Override
+ public void onRecordClick(RecordClickEvent event) {
+ String details = event.getRecord().getAttribute(Field.DETAIL);
+ popupDetails(details);
+ }
+ });
+ iconField.setShowHover(true);
+ iconField.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String html = record.getAttribute(Field.DETAIL);
+ if (html.length() > 80) {
+ // this was probably an error stack trace, snip it so the tooltip isn't too big
+ html = "<pre>" + html.substring(0, 80) + "...</pre><p>"
+ + MSG.dataSource_resourceErrors_clickStatusIcon() + "</p>";
+ }
+ return html;
+ }
+ });
+
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid listGrid = (ListGrid) event.getSource();
+ ListGridRecord[] selectedRows = listGrid.getSelection();
+ if (selectedRows != null && selectedRows.length > 0) {
+ String details = selectedRows[0].getAttribute(Field.DETAIL);
+ popupDetails(details);
+ }
+ }
+ });
+
+ setListGridFields(errorTypeField, timeField, summaryField, iconField);
+
+ addTableAction(extendLocatorId("delete"), MSG.common_button_delete(), MSG.common_msg_areYouSure(),
+ new AbstractTableAction(TableActionEnablement.ANY) {
+ @Override
+ public void executeAction(final ListGridRecord[] selection, Object actionValue) {
+ if (selection == null || selection.length == 0) {
+ return;
+ }
+ int[] resourceErrorIds = new int[selection.length];
+ int i = 0;
+ for (ListGridRecord record : selection) {
+ resourceErrorIds[i++] = record.getAttributeAsInt(Field.ID);
+ }
+ GWTServiceLookup.getResourceService().deleteResourceErrors(resourceErrorIds,
+ new AsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ Message msg = new Message(MSG.dataSource_resourceErrors_deleteSuccess(String
+ .valueOf(selection.length)), Severity.Info);
+ CoreGUI.getMessageCenter().notify(msg);
+ refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.dataSource_resourceErrors_deleteFailure(),
+ caught);
+ }
+ });
+ }
+ });
+ }
+
+ private void popupDetails(String details) {
+ final Window winModal = new LocatableWindow(extendLocatorId("errorDetailsWin"));
+ winModal.setTitle(MSG.common_title_component_errors());
+ winModal.setOverflow(Overflow.VISIBLE);
+ winModal.setShowMinimizeButton(false);
+ winModal.setShowMaximizeButton(true);
+ winModal.setIsModal(true);
+ winModal.setShowModalMask(true);
+ winModal.setAutoSize(true);
+ winModal.setAutoCenter(true);
+ winModal.setShowResizer(true);
+ winModal.setCanDragResize(true);
+ winModal.centerInPage();
+ winModal.addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ winModal.markForDestroy();
+ }
+ });
+
+ LocatableHTMLPane htmlPane = new LocatableHTMLPane(extendLocatorId("errorDetailsPane"));
+ htmlPane.setMargin(10);
+ htmlPane.setDefaultWidth(700);
+ htmlPane.setDefaultHeight(500);
+ htmlPane.setContents("<pre>" + details + "</pre>");
+ winModal.addItem(htmlPane);
+ winModal.show();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
index 7bc1cdd..bd86104 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
@@ -49,9 +49,6 @@ import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagEditorView;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagsChangedCallback;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.OverviewForm;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ResourceErrorsDataSource;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ResourceErrorsView;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableImg;
@@ -243,7 +240,7 @@ public class ResourceTitleBar extends LocatableVLayout {
detailsForm.setHeight(10);
detailsForm.setAlign(Alignment.LEFT);
- detailsFormSummary = new OverviewForm(extendLocatorId("Title_Optional_Summary"), resourceComposite);
+ detailsFormSummary = new OverviewForm(extendLocatorId("Title_Optional_Summary"), resourceComposite, this);
detailsFormSummary.setWidth100();
detailsFormSummary.setPadding(3);
detailsFormSummary.setMargin(3);
@@ -294,8 +291,7 @@ public class ResourceTitleBar extends LocatableVLayout {
this.resourceComposite = resourceComposite;
update();
- this.title.setContents("<span class=\"SectionHeader\">" + resource.getName()
- + "</span> <span class=\"subtitle\">" + resource.getResourceType().getName() + "</span>");
+ displayResourceName(resource.getName());
Set<Integer> favorites = UserSessionManager.getUserPreferences().getFavoriteResources();
this.favorite = favorites.contains(resource.getId());
@@ -310,6 +306,15 @@ public class ResourceTitleBar extends LocatableVLayout {
}
}
+ void displayResourceName(String resourceName) {
+ if (!resource.getName().equals(resourceName)) {
+ resource.setName(resourceName); // the name must have been changed by the user via the editable field
+ }
+ this.title.setContents("<span class=\"SectionHeader\">" + resource.getName()
+ + "</span> <span class=\"subtitle\">" + resource.getResourceType().getName() + "</span>");
+ this.title.markForRedraw();
+ }
+
private void updateFavoriteButton() {
this.favoriteButton.setSrc(favorite ? FAV_ICON : NOT_FAV_ICON);
if (favorite) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java
deleted file mode 100644
index 3cecbe9..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.EnumSet;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.HeaderItem;
-import com.smartgwt.client.widgets.form.fields.SpacerItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-
-import org.rhq.core.domain.measurement.DataType;
-import org.rhq.core.domain.measurement.DisplayType;
-import org.rhq.core.domain.measurement.MeasurementDataTrait;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem;
-import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.components.form.StringLengthValidator;
-import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem.ValueEditedHandler;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-
-/**
- * The Resource Summary>Overview tab - Resource general properties + summary traits.
- *
- * @author Greg Hinkle
- * @author Ian Springer
- */
-public class OverviewForm extends EnhancedDynamicForm {
-
- private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
- private ResourceComposite resourceComposite;
- private boolean headerEnabled = true;
- private boolean displayCondensed = false;
-
- public OverviewForm(String locatorId, ResourceComposite resourceComposite) {
- super(locatorId);
- this.resourceComposite = resourceComposite;
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
-
- setLeft("10%");
- setWidth("80%");
- if (isDisplayCondensed()) {
- setPadding(5);
- setColWidths(150, 220, 150, 220);
- setWidth("45%");
- }
-
- if (this.resourceComposite != null) {
- setResource(this.resourceComposite);
- }
- }
-
- public void setResource(ResourceComposite resourceComposite) {
-
- this.resourceComposite = resourceComposite;
- Resource resource = resourceComposite.getResource();
-
- // Load metric defs.
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
- new ResourceTypeRepository.TypeLoadedCallback() {
- public void onTypesLoaded(ResourceType type) {
- buildForm(type);
- loadTraitValues();
- }
- });
- }
-
- private void loadTraitValues() {
- final Resource resource = resourceComposite.getResource();
- GWTServiceLookup.getMeasurementDataService().findCurrentTraitsForResource(resource.getId(),
- DisplayType.SUMMARY, new AsyncCallback<List<MeasurementDataTrait>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_summaryOverviewForm_error_traitsLoadFailure(resource.toString()), caught);
- }
-
- public void onSuccess(List<MeasurementDataTrait> result) {
- for (MeasurementDataTrait trait : result) {
- String formItemId = buildFormItemIdFromTraitDisplayName(trait.getName());
- FormItem item = getItem(formItemId);
- if (item != null) {
- setValue(formItemId, trait.getValue());
- }
- }
- markForRedraw();
- }
- });
- }
-
- private static String buildFormItemIdFromTraitDisplayName(String traitName) {
- return traitName.replaceAll("\\.", "_").replaceAll(" ", "__");
- }
-
- private void buildForm(ResourceType type) {
- List<MeasurementDefinition> traits = new ArrayList<MeasurementDefinition>();
-
- for (MeasurementDefinition measurement : type.getMetricDefinitions()) {
- if (measurement.getDataType() == DataType.TRAIT && measurement.getDisplayType() == DisplayType.SUMMARY) {
- traits.add(measurement);
- }
- }
-
- StringLengthValidator notEmptyOrNullValidator = new StringLengthValidator(1, null, false);
- StringLengthValidator notNullValidator = new StringLengthValidator(null, null, false);
-
- List<FormItem> formItems = new ArrayList<FormItem>();
-
- if (isHeaderEnabled()) {//conditionally display header
- HeaderItem headerItem = new HeaderItem("header", MSG.view_summaryOverviewForm_header_summary());
- headerItem.setValue(MSG.view_summaryOverviewForm_header_summary());
- formItems.add(headerItem);
- }
-
- // Type
- StaticTextItem typeItem = new StaticTextItem("type", MSG.view_summaryOverviewForm_field_type());
- typeItem.setTooltip(MSG.view_summaryOverviewForm_label_plugin() + type.getPlugin() + "\n<br>"
- + MSG.view_summaryOverviewForm_label_type() + type.getName());
- typeItem.setValue(AncestryUtil.getFormattedType(type));
- formItems.add(typeItem);
-
- final Resource resource = this.resourceComposite.getResource();
- boolean modifiable = this.resourceComposite.getResourcePermission().isInventory();
-
- // Name
- final FormItem nameItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
- nameItem.setName("name");
- nameItem.setTitle(MSG.view_summaryOverviewForm_field_name());
- nameItem.setValue(resource.getName());
- if (nameItem instanceof EditableFormItem) {
- EditableFormItem togglableNameItem = (EditableFormItem) nameItem;
- togglableNameItem.setValidators(notEmptyOrNullValidator);
- togglableNameItem.setValueEditedHandler(new ValueEditedHandler() {
- public void editedValue(Object newValue) {
- final String newName = newValue.toString();
- final String oldName = resource.getName();
- if (newName.equals(oldName)) {
- return;
- }
- resource.setName(newName);
- OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_summaryOverviewForm_error_nameChangeFailure(String.valueOf(resource.getId()),
- oldName, newName), caught);
- // We failed to update it on the Server, so change back the Resource and the form item to
- // the original value.
- resource.setName(oldName);
- nameItem.setValue(oldName);
- }
-
- public void onSuccess(Void result) {
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(String
- .valueOf(resource.getId()), oldName, newName), Message.Severity.Info));
- }
- });
- }
- });
- }
- formItems.add(nameItem);
-
- // Description
- final FormItem descriptionItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
- descriptionItem.setName("description");
- descriptionItem.setTitle(MSG.view_summaryOverviewForm_field_description());
- descriptionItem.setValue(resource.getDescription());
- if (descriptionItem instanceof EditableFormItem) {
- EditableFormItem togglableDescriptionItem = (EditableFormItem) descriptionItem;
- togglableDescriptionItem.setValidators(notNullValidator);
- togglableDescriptionItem.setValueEditedHandler(new ValueEditedHandler() {
- public void editedValue(Object newValue) {
- final String newDescription = newValue.toString();
- final String oldDescription = resource.getDescription();
- if (newDescription.equals(oldDescription)) {
- return;
- }
- resource.setDescription(newDescription);
- OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_summaryOverviewForm_error_descriptionChangeFailure(String.valueOf(resource
- .getId()), oldDescription, newDescription), caught);
- // We failed to update it on the Server, so change back the Resource and the form item to
- // the original value.
- resource.setDescription(oldDescription);
- descriptionItem.setValue(oldDescription);
- }
-
- public void onSuccess(Void result) {
- CoreGUI.getMessageCenter()
- .notify(
- new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(String
- .valueOf(resource.getId()), oldDescription, newDescription),
- Message.Severity.Info));
- }
- });
- }
- });
- }
- formItems.add(descriptionItem);
-
- // Location
- final FormItem locationItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
- locationItem.setName("location");
- locationItem.setTitle(MSG.view_summaryOverviewForm_field_location());
- locationItem.setValue(resource.getLocation());
- if (locationItem instanceof EditableFormItem) {
- EditableFormItem togglableLocationItem = (EditableFormItem) locationItem;
- togglableLocationItem.setValidators(notNullValidator);
- togglableLocationItem.setValueEditedHandler(new ValueEditedHandler() {
- public void editedValue(Object newValue) {
- final String newLocation = newValue.toString();
- final String oldLocation = resource.getLocation();
- if (newLocation.equals(oldLocation)) {
- return;
- }
- resource.setLocation(newLocation);
- OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_summaryOverviewForm_error_locationChangeFailure(String.valueOf(resource
- .getId()), oldLocation, newLocation), caught);
- // We failed to update it on the Server, so change back the Resource and the form item to
- // the original value.
- resource.setLocation(oldLocation);
- locationItem.setValue(oldLocation);
- }
-
- public void onSuccess(Void result) {
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(String
- .valueOf(resource.getId()), oldLocation, newLocation), Message.Severity.Info));
- }
- });
- }
- });
- }
- formItems.add(locationItem);
-
- // Version
- StaticTextItem versionItem = new StaticTextItem("version", MSG.view_summaryOverviewForm_field_version());
- versionItem.setValue((resource.getVersion() != null) ? resource.getVersion() : "<i>" + MSG.common_label_none()
- + "</i>");
- versionItem.setEndRow(true);
- formItems.add(versionItem);
-
- // Traits
- Collections.sort(traits, new Comparator<MeasurementDefinition>() {
- public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
- return new Integer(o1.getDisplayOrder()).compareTo(o2.getDisplayOrder());
- }
- });
-
- for (MeasurementDefinition trait : traits) {
- String formItemId = buildFormItemIdFromTraitDisplayName(trait.getDisplayName());
- StaticTextItem formItem = new StaticTextItem(formItemId, trait.getDisplayName());
- formItem.setTooltip(trait.getDescription());
- formItems.add(formItem);
- // item.setValue("?");
- }
-
- // SectionItem section = new SectionItem("Summary", "Summary");
- // section.setTitle("Summary");
- // section.setDefaultValue("Summary");
- // section.setCanCollapse(true);
- // section.setCellStyle("HidablePlainSectionHeader");
- // section.setItemIds(itemIds.toArray(new String[itemIds.size()]));
- // formItems.add(0, section);
- if (!isDisplayCondensed()) {
- formItems.add(new SpacerItem());
- }
-
- setItems(formItems.toArray(new FormItem[formItems.size()]));
- }
-
- public void loadData() {
- // TODO: Reload the ResourceComposite too.
- loadTraitValues();
- markForRedraw();
- }
-
- public boolean isHeaderEnabled() {
- return headerEnabled;
- }
-
- public void setHeaderEnabled(boolean headerEnabled) {
- this.headerEnabled = headerEnabled;
- }
-
- public boolean isDisplayCondensed() {
- return displayCondensed;
- }
-
- public void setDisplayCondensed(boolean displayCondensed) {
- this.displayCondensed = displayCondensed;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
deleted file mode 100644
index be76956..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
-
-import java.util.Date;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.rpc.RPCResponse;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.criteria.Criteria;
-import org.rhq.core.domain.resource.ResourceError;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-
-/**
- * @author Lukas Krejci
- * @author Simeon Pinder
- * @author John Mazzitelli
- */
-public class ResourceErrorsDataSource extends RPCDataSource<ResourceError, Criteria> {
-
- public static abstract class Field {
- public static final String ID = "id";
- public static final String SUMMARY = "summary";
- public static final String DETAIL = "detail";
- public static final String ERROR_TYPE = "errorType";
- public static final String TIME_OCCURED = "timeOccured";
- }
-
- ResourceGWTServiceAsync resourceService;
- int resourceId;
-
- public ResourceErrorsDataSource(int resourceId) {
- resourceService = GWTServiceLookup.getResourceService();
- this.resourceId = resourceId;
- List<DataSourceField> fields = addDataSourceFields();
- addFields(fields);
- }
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
- resourceService.findResourceErrors(resourceId, new AsyncCallback<List<ResourceError>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.dataSource_resourceErrors_error_fetchFailure(String.valueOf(resourceId)), caught);
- response.setStatus(RPCResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(List<ResourceError> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- protected Criteria getFetchCriteria(DSRequest request) {
- // we don't use criterias for this datasource, just return null
- return null;
- }
-
- @Override
- public ResourceError copyValues(Record from) {
- //This is read-only datasource, so no need to implement this.
- return null;
- }
-
- @Override
- public ListGridRecord copyValues(ResourceError from) {
- ListGridRecord record = new ListGridRecord();
-
- record.setAttribute(Field.ID, from.getId());
- record.setAttribute(Field.DETAIL, from.getDetail());
- record.setAttribute(Field.ERROR_TYPE, from.getErrorType().name());
- record.setAttribute(Field.SUMMARY, from.getSummary());
- record.setAttribute(Field.TIME_OCCURED, new Date(from.getTimeOccurred()));
-
- return record;
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
deleted file mode 100644
index e4e62e8..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.types.AutoFitWidthApproach;
-import com.smartgwt.client.types.ListGridFieldType;
-import com.smartgwt.client.types.Overflow;
-import com.smartgwt.client.types.SelectionStyle;
-import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.events.CloseClickHandler;
-import com.smartgwt.client.widgets.events.CloseClientEvent;
-import com.smartgwt.client.widgets.events.DoubleClickEvent;
-import com.smartgwt.client.widgets.events.DoubleClickHandler;
-import com.smartgwt.client.widgets.grid.HoverCustomizer;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
-import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
-
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
-import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
-import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ResourceErrorsDataSource.Field;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-
-public class ResourceErrorsView extends Table<ResourceErrorsDataSource> {
- private static final String ERROR_ICON = "[SKIN]/Dialog/warn.png";
-
- public ResourceErrorsView(String locatorId, String string, Criteria criteria, Object object, String[] strings) {
- super(locatorId, MSG.common_title_component_errors(), criteria);
- setWidth100();
- setHeight100();
- setShowHeader(false);
- }
-
- @Override
- protected SelectionStyle getDefaultSelectionStyle() {
- return SelectionStyle.MULTIPLE;
- }
-
- @Override
- protected void configureTable() {
- ListGridField errorTypeField = new ListGridField(Field.ERROR_TYPE, MSG
- .dataSource_resourceErrors_field_errorType());
- errorTypeField.setAlign(Alignment.CENTER);
- errorTypeField.setAutoFitWidth(true);
- errorTypeField.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
-
- ListGridField timeField = new ListGridField(Field.TIME_OCCURED, MSG
- .dataSource_resourceErrors_field_timeOccured());
- timeField.setType(ListGridFieldType.DATE);
- timeField.setAlign(Alignment.CENTER);
- timeField.setWidth("20%");
- TimestampCellFormatter.prepareDateField(timeField);
-
- ListGridField summaryField = new ListGridField(Field.SUMMARY, MSG.dataSource_resourceErrors_field_summary());
- summaryField.setAlign(Alignment.CENTER);
- summaryField.setCellAlign(Alignment.LEFT);
- summaryField.setWidth("*");
-
- ListGridField iconField = new ListGridField("icon");
- iconField.setType(ListGridFieldType.ICON);
- iconField.setAlign(Alignment.CENTER);
- iconField.setIcon(ERROR_ICON);
- iconField.setCellIcon(ERROR_ICON);
- iconField.setWidth("50");
- iconField.setCanSort(false);
- iconField.addRecordClickHandler(new RecordClickHandler() {
- @Override
- public void onRecordClick(RecordClickEvent event) {
- String details = event.getRecord().getAttribute(Field.DETAIL);
- popupDetails(details);
- }
- });
- iconField.setShowHover(true);
- iconField.setHoverCustomizer(new HoverCustomizer() {
- @Override
- public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
- String html = record.getAttribute(Field.DETAIL);
- if (html.length() > 80) {
- // this was probably an error stack trace, snip it so the tooltip isn't too big
- html = "<pre>" + html.substring(0, 80) + "...</pre><p>"
- + MSG.dataSource_resourceErrors_clickStatusIcon() + "</p>";
- }
- return html;
- }
- });
-
- setListGridDoubleClickHandler(new DoubleClickHandler() {
- @Override
- public void onDoubleClick(DoubleClickEvent event) {
- ListGrid listGrid = (ListGrid) event.getSource();
- ListGridRecord[] selectedRows = listGrid.getSelection();
- if (selectedRows != null && selectedRows.length > 0) {
- String details = selectedRows[0].getAttribute(Field.DETAIL);
- popupDetails(details);
- }
- }
- });
-
- setListGridFields(errorTypeField, timeField, summaryField, iconField);
-
- addTableAction(extendLocatorId("delete"), MSG.common_button_delete(), MSG.common_msg_areYouSure(),
- new AbstractTableAction(TableActionEnablement.ANY) {
- @Override
- public void executeAction(final ListGridRecord[] selection, Object actionValue) {
- if (selection == null || selection.length == 0) {
- return;
- }
- int[] resourceErrorIds = new int[selection.length];
- int i = 0;
- for (ListGridRecord record : selection) {
- resourceErrorIds[i++] = record.getAttributeAsInt(Field.ID);
- }
- GWTServiceLookup.getResourceService().deleteResourceErrors(resourceErrorIds,
- new AsyncCallback<Void>() {
- @Override
- public void onSuccess(Void result) {
- Message msg = new Message(MSG.dataSource_resourceErrors_deleteSuccess(String
- .valueOf(selection.length)), Severity.Info);
- CoreGUI.getMessageCenter().notify(msg);
- refresh();
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.dataSource_resourceErrors_deleteFailure(),
- caught);
- }
- });
- }
- });
- }
-
- private void popupDetails(String details) {
- final Window winModal = new LocatableWindow(extendLocatorId("errorDetailsWin"));
- winModal.setTitle(MSG.common_title_component_errors());
- winModal.setOverflow(Overflow.VISIBLE);
- winModal.setShowMinimizeButton(false);
- winModal.setShowMaximizeButton(true);
- winModal.setIsModal(true);
- winModal.setShowModalMask(true);
- winModal.setAutoSize(true);
- winModal.setAutoCenter(true);
- winModal.setShowResizer(true);
- winModal.setCanDragResize(true);
- winModal.centerInPage();
- winModal.addCloseClickHandler(new CloseClickHandler() {
- @Override
- public void onCloseClick(CloseClientEvent event) {
- winModal.markForDestroy();
- }
- });
-
- LocatableHTMLPane htmlPane = new LocatableHTMLPane(extendLocatorId("errorDetailsPane"));
- htmlPane.setMargin(10);
- htmlPane.setDefaultWidth(700);
- htmlPane.setDefaultHeight(500);
- htmlPane.setContents("<pre>" + details + "</pre>");
- winModal.addItem(htmlPane);
- winModal.show();
- }
-}
commit 5422bf4365ea656d41399ec67a4c91cf573b9f0e
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Mar 31 16:50:13 2011 -0400
Button Enablement Work
- Disable group Delete and New buttons for non inv-managers
- Disable uninventory button for non-resource-delete users
- updated text for delete perm on role detail page
- Added some support for authorized button enablement
(see AuthorizedTableAction)
- Added an interface for record extraction (see RecordExtractor)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AuthorizedTableAction.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AuthorizedTableAction.java
new file mode 100644
index 0000000..710aa53
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AuthorizedTableAction.java
@@ -0,0 +1,95 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
+
+/**
+ * This class allows for TableAction (ie. Button) enablement based on row selection and global perm authorization.
+ *
+ * For Resource Perm authorization see {@link ResourceAuthorizedTableAction}.
+ *
+ * @author Jay Shaughnessy
+ */
+public abstract class AuthorizedTableAction extends AbstractTableAction {
+
+ Table<?> table;
+
+ HashSet<Permission> globalPermissions = new HashSet<Permission>();
+
+ Boolean isGlobalAuthorized;
+
+ protected AuthorizedTableAction(Table<?> table, Permission... permissions) {
+ this(table, TableActionEnablement.ALWAYS, permissions);
+ }
+
+ protected AuthorizedTableAction(Table<?> table, TableActionEnablement enablement, Permission... permissions) {
+ super(enablement);
+
+ this.table = table;
+
+ for (Permission p : permissions) {
+ switch (p.getTarget()) {
+ case GLOBAL:
+ globalPermissions.add(p);
+ break;
+ case RESOURCE:
+ throw new IllegalArgumentException("Does not support Resource permissions");
+ }
+ }
+
+ if (globalPermissions.isEmpty()) {
+ isGlobalAuthorized = Boolean.TRUE;
+ }
+ }
+
+ @Override
+ public boolean isEnabled(ListGridRecord[] selection) {
+ if (!super.isEnabled(selection)) {
+ return false;
+ }
+
+ if (null == isGlobalAuthorized) {
+ new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
+
+ public void onPermissionsLoaded(Set<Permission> grantedPermissions) {
+ for (Permission requiredPermission : globalPermissions) {
+ if (!grantedPermissions.contains(requiredPermission)) {
+ return;
+ }
+ }
+ isGlobalAuthorized = true;
+ table.refreshTableInfo();
+ }
+ });
+
+ return false;
+ }
+
+ return isGlobalAuthorized;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/RecordExtractor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/RecordExtractor.java
new file mode 100644
index 0000000..1fe84d0
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/RecordExtractor.java
@@ -0,0 +1,38 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import java.util.Collection;
+
+import com.smartgwt.client.data.Record;
+
+/**
+ * Typically used for anaonymous class definition for extracting any data from a set of Records, typically
+ * ListGridRecords. For example, a utility that needs the resource ids extracted from the record set's attributes
+ * but does not know what the attributes are, could be passed a RecordExtractor.
+ *
+ * @author Jay Shaughnessy
+ *
+ */
+public interface RecordExtractor<T extends Object> {
+
+ Collection<T> extract(Record[] records);
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/ResourceAuthorizedTableAction.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/ResourceAuthorizedTableAction.java
new file mode 100644
index 0000000..8931446
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/ResourceAuthorizedTableAction.java
@@ -0,0 +1,101 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import java.util.Collection;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.authz.Permission.Target;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+
+/**
+ * This class allows for TableAction (ie. Button) enablement based on row selection and resource perm authorization
+ * on the selected rows. If possible it is recommended that the table be built using composites that include the
+ * resource permission information already, as performance will be better. This approach will require an async
+ * authz call to the server on each refresh of the TableActions (i.e. each time selection changes in the Table).
+ *
+ * For Global Perm authorization see {@link AuthorizedTableAction}.
+ *
+ * TODO: This class has yet to be tested.
+ *
+ * @author Jay Shaughnessy
+ */
+public abstract class ResourceAuthorizedTableAction extends AbstractTableAction {
+
+ Table<?> table;
+ Permission requiredPermission;
+ RecordExtractor<Integer> extractor;
+
+ Boolean isAuthorized;
+
+ protected ResourceAuthorizedTableAction(Table<?> table, Permission requiredPermission,
+ RecordExtractor<Integer> extractor) {
+ this(table, TableActionEnablement.ALWAYS, requiredPermission, extractor);
+ }
+
+ protected ResourceAuthorizedTableAction(Table<?> table, TableActionEnablement enablement,
+ Permission requiredPermission, RecordExtractor<Integer> extractor) {
+ super(enablement);
+
+ this.table = table;
+ this.requiredPermission = requiredPermission;
+ this.extractor = extractor;
+
+ if (Target.RESOURCE != this.requiredPermission.getTarget()) {
+ throw new IllegalArgumentException("Does not support Global permission");
+ }
+ }
+
+ @Override
+ public boolean isEnabled(ListGridRecord[] selection) {
+ // first make sure row selection enablement passes
+ if (!super.isEnabled(selection)) {
+ return false;
+ }
+
+ // if we've performed the required auth check, return the result and reset.
+ if (null != isAuthorized) {
+ boolean result = isAuthorized;
+ isAuthorized = null;
+ return result;
+ }
+
+ // otherwise, kick off the async auth check. return false initially and update when the async call returns
+ Collection<Integer> resourceIds = extractor.extract(selection);
+ GWTServiceLookup.getAuthorizationService().hasResourcePermission(requiredPermission, resourceIds,
+ new AsyncCallback<Boolean>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("", caught);
+ }
+
+ public void onSuccess(Boolean result) {
+ isAuthorized = result;
+ table.refreshTableInfo();
+ }
+
+ });
+
+ return false;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AuthorizationGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AuthorizationGWTService.java
index 249a655..3d14c3a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AuthorizationGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AuthorizationGWTService.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.gwt;
+import java.util.Collection;
import java.util.Set;
import com.google.gwt.user.client.rpc.RemoteService;
@@ -72,4 +73,17 @@ public interface AuthorizationGWTService extends RemoteService {
*/
Set<Permission> getExplicitGlobalPermissions() throws RuntimeException;
+ /**
+ * Returns true if the current user possesses either: 1) the specified resource permission for *all* of the
+ * specified resources, or 2) the global MANAGE_INVENTORY permission which, by definition, gives full access to the
+ * inventory (all resources and all groups) NOTE: The size of the collection must be less than or equal to 1000 (due
+ * to an Oracle limitation).
+ *
+ * @param permission a resource permission (i.e. permission.getTarget() == Permission.Target.RESOURCE)
+ * @param resourceIds the ids of some Resources to check permissions against (size of collection must be <= 1000)
+ *
+ * @return true if the current user possesses the specified resource permission for the specified resource
+ */
+ boolean hasResourcePermission(Permission permission, Collection<Integer> resourceIds);
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
index 8ed410d..066b4a2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
@@ -40,12 +40,14 @@ import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.search.SearchSubsystem;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.AuthorizedTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -169,7 +171,8 @@ public class ResourceGroupListView extends Table<ResourceGroupCompositeDataSourc
if (this.showDeleteButton) {
addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), MSG.common_msg_areYouSure(),
- new AbstractTableAction(TableActionEnablement.ANY) {
+ new AuthorizedTableAction(this, TableActionEnablement.ANY, Permission.MANAGE_INVENTORY) {
+
public void executeAction(ListGridRecord[] selections, Object actionValue) {
int[] groupIds = new int[selections.length];
int index = 0;
@@ -195,7 +198,8 @@ public class ResourceGroupListView extends Table<ResourceGroupCompositeDataSourc
}
if (this.showNewButton) {
- addTableAction(extendLocatorId("New"), MSG.common_button_new(), new AbstractTableAction() {
+ addTableAction(extendLocatorId("New"), MSG.common_button_new(), new AuthorizedTableAction(this,
+ Permission.MANAGE_INVENTORY) {
public void executeAction(ListGridRecord[] selection, Object actionValue) {
new GroupCreateWizard(ResourceGroupListView.this).startWizard();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 27e67d7..32a6227 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -26,10 +26,12 @@ import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceD
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.ListGridFieldType;
@@ -41,13 +43,15 @@ import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.search.SearchSubsystem;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.RecordExtractor;
+import org.rhq.enterprise.gui.coregui.client.components.table.ResourceAuthorizedTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.ResourceCategoryCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
@@ -100,6 +104,7 @@ public class ResourceSearchView extends Table {
*
* @param headerIcons 24x24 icon(s) to be displayed in the header
*/
+ @SuppressWarnings("unchecked")
public ResourceSearchView(String locatorId, Criteria criteria, String title, SortSpecifier[] sortSpecifier,
String[] excludeFields, String... headerIcons) {
super(locatorId, title, criteria, sortSpecifier, excludeFields);
@@ -177,7 +182,19 @@ public class ResourceSearchView extends Table {
categoryField, availabilityField);
addTableAction(extendLocatorId("Uninventory"), MSG.common_button_uninventory(), MSG
- .view_inventory_resources_uninventoryConfirm(), new AbstractTableAction(TableActionEnablement.ANY) {
+ .view_inventory_resources_uninventoryConfirm(), new ResourceAuthorizedTableAction(ResourceSearchView.this,
+ TableActionEnablement.ANY, Permission.DELETE_RESOURCE, new RecordExtractor<Integer>() {
+
+ public Collection<Integer> extract(Record[] records) {
+ List<Integer> result = new ArrayList<Integer>(records.length);
+ for (Record record : records) {
+ result.add(record.getAttributeAsInt("id"));
+ }
+
+ return result;
+ }
+ }) {
+
public void executeAction(ListGridRecord[] selection, Object actionValue) {
int[] resourceIds = TableUtility.getIds(selection);
ResourceGWTServiceAsync resourceManager = GWTServiceLookup.getResourceService();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
index bf56c99..d31b5d8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
@@ -18,11 +18,11 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.AuthorizationGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
@@ -83,4 +83,13 @@ public class AuthorizationGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
+ public boolean hasResourcePermission(Permission permission, Collection<Integer> resourceIds) {
+ try {
+ boolean result = authorizationManager.hasResourcePermission(getSessionSubject(), permission, resourceIds);
+ return result;
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
}
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 1867bf7..26b3bf0 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
@@ -702,7 +702,7 @@ view_adminRoles_permissions_permReadDesc_createChildResources = (IMPLIED) view c
view_adminRoles_permissions_permWriteDesc_createChildResources = create new child Resources (for child Resources of types that are creatable)
view_adminRoles_permissions_perm_deleteChildResources = Delete Child Resources
view_adminRoles_permissions_permReadDesc_deleteChildResources = (IMPLIED) view child Resource deletion history
-view_adminRoles_permissions_permWriteDesc_deleteChildResources = delete child Resources (for child Resources of types that are deletable)
+view_adminRoles_permissions_permWriteDesc_deleteChildResources = uninventory resources; delete Resources (for Resources of types that are deletable)
# Administration/Topology/RemoteAgentInstall/#
#--------------------------------
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 30c2334..fdfb2d1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -267,6 +267,9 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
}
// make sure the user is authorized to delete this resource (which implies you can delete all its children)
+ // TODO: There is a pretty good argument for this being replaced with MANAGE_INVENTORY. It takes an
+ // inventory manager to import resources, so why not to remove them? But, since no one has complained
+ // we're timid about making a change that may hamstring existing setups.
if (!authorizationManager.hasResourcePermission(user, Permission.DELETE_RESOURCE, resourceId)) {
throw new PermissionException("You do not have permission to uninventory resource [" + resourceId + "]");
}
commit 0ac2a805a2ebdeb345a6058fb77695f3ec907ac1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 31 16:04:47 2011 -0400
BZ 692299 - correct the resource link
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
index b4e1257..87c8b14 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
@@ -47,7 +47,7 @@ public class GroupMemberResourceOperationHistoryListView extends
resourceField.setWidth("25%");
resourceField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("id"));
+ String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
return SeleniumUtility.getLocatableHref(url, o.toString(), null);
}
});
commit 8bd52cd028bd7fc6547c52c846de539fd46a21aa
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 31 15:39:49 2011 -0400
BZ 610791 - hide the event tracking bar in the monitor graphs jsf page since its broken. we'll fix this kind of display when we move the graph page to gwt
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java
index 5f9fb22..b7461c3 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java
@@ -47,8 +47,11 @@ public class EventsTimelineUIBean {
context = WebUtility.getEntityContext();
+ /* see BZ 610791
EventSeverity[] eventsCounts = eventManager.getSeverityBucketsByContext(user.getSubject(), context, begin, end,
numberOfBuckets);
+ */
+ EventSeverity[] eventsCounts = new EventSeverity[numberOfBuckets]; // dummy event counts, all nulls, for BZ 610791
data = new ArrayList<TimelineBean>();
long interval = TimeUtil.getInterval(begin, end, numberOfBuckets);
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/events/data-plain.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/events/data-plain.xhtml
index 068f97b..90b09cc 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/events/data-plain.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/monitor/events/data-plain.xhtml
@@ -55,6 +55,7 @@
<td colspan="62" style="height: 2px;"></td>
</tr>
+ <!-- BZ 610791
<tr style="height: 12px;">
<td></td>
<c:forEach var="timeTick" items="#{EventsTimelineUIBean.data}" varStatus="status">
@@ -84,7 +85,6 @@
</c:choose>
</c:if>
- <!-- put onmousedown in table data element not the div, which gives the user a larger clickable area -->
<c:if test="#{empty timeTick.severity}">
<td style="background-image: url(#{icon}); background-repeat:no-repeat;" align="center" valign="middle">
</td>
@@ -102,7 +102,7 @@
<h:outputFormat value="#{msg['resource.common.monitor.label.elc']}" />
</td>
</tr>
-
+ -->
<tr>
<td colspan="62" valign="top">
<a name="eventDetail"></a>
commit a3356e841e795aeaea76903e5b10bc0fef82c0fd
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Mar 31 10:07:12 2011 -0400
enable refresh for config changes and hide refresh button for portlets.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
index 013e5be..388094a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
@@ -66,6 +66,7 @@ public abstract class AbstractRecentAlertsPortlet extends AlertHistoryView imple
setShowFilterForm(false); //disable filter form for portlet
setOverflow(Overflow.VISIBLE);
+ setShowFooterRefresh(false); //disable footer refresh button as redundant for portlets
}
public Timer getRefreshTimer() {
@@ -171,6 +172,8 @@ public abstract class AbstractRecentAlertsPortlet extends AlertHistoryView imple
// persist and reload portlet
storedPortlet.setConfiguration(portletConfig);
configure(portletWindow, storedPortlet);
+ //apply latest settings to the visible result set
+ refresh();
}
});
commit 1756884b035d86857aba75d826fd19ef4a5a153b
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Mar 30 19:01:51 2011 -0400
BZ 689993: enable start/stop WAIT_MAX for AS4 and Tomcat server components.
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
index 8e967ae..f241200 100644
--- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
+++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
@@ -133,6 +133,8 @@ public class JBossASServerComponent implements MeasurementFacet, OperationFacet,
public static final String SCRIPT_PREFIX_CONFIG_PROP = "scriptPrefix";
public static final String CONFIGURATION_SET_CONFIG_PROP = "configurationSet";
public static final String START_SCRIPT_CONFIG_PROP = "startScript";
+ public static final String START_WAIT_MAX_PROP = "startWaitMax";
+ public static final String STOP_WAIT_MAX_PROP = "stopWaitMax";
public static final String SHUTDOWN_SCRIPT_CONFIG_PROP = "shutdownScript";
public static final String SHUTDOWN_MBEAN_CONFIG_PROP = "shutdownMbeanName";
public static final String SHUTDOWN_MBEAN_OPERATION_CONFIG_PROP = "shutdownMbeanOperation";
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerOperationsDelegate.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerOperationsDelegate.java
index 7bb941d..269f16c 100644
--- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerOperationsDelegate.java
+++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerOperationsDelegate.java
@@ -1,25 +1,25 @@
- /*
- * Jopr 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.
- */
+/*
+ * Jopr Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
package org.rhq.plugins.jbossas;
import java.io.File;
@@ -34,6 +34,7 @@ import org.mc4j.ems.connection.bean.operation.EmsOperation;
import org.mc4j.ems.connection.bean.parameter.EmsParameter;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.core.pluginapi.util.ProcessExecutionUtility;
@@ -51,7 +52,7 @@ import org.rhq.core.system.SystemInfo;
public class JBossASServerOperationsDelegate {
/** max amount of time to wait for server to show as unavailable after executing stop - in milliseconds */
- private static final long STOP_WAIT_MAX = 1000L * 150; // 2.5 minutes
+ private static long STOP_WAIT_MAX = 1000L * 150; // 2.5 minutes
/** amount of time to wait between availability checks when performing a stop - in milliseconds */
private static final long STOP_WAIT_INTERVAL = 1000L * 10; // 10 seconds
@@ -61,7 +62,7 @@ public class JBossASServerOperationsDelegate {
private static final long STOP_WAIT_FINAL = 1000L * 30; // 30 seconds
/** max amount of time to wait for start to complete - in milliseconds */
- private static final long START_WAIT_MAX = 1000L * 300; // 5 minutes
+ private static long START_WAIT_MAX = 1000L * 300; // 5 minutes
/** amount of time to wait between availability checks when performing a start - in milliseconds */
private static final long START_WAIT_INTERVAL = 1000L * 10; // 10 seconds
@@ -369,24 +370,34 @@ public class JBossASServerOperationsDelegate {
try {
shutdown();
} catch (Exception e) {
- throw new RuntimeException("Shutdown may have failed: " +e );
+ throw new RuntimeException("Shutdown may have failed: " + e);
}
-
try {
// Perform the restart.
start();
} catch (Exception e) {
- throw new RuntimeException("Re-Startup may have failed: " +e );
+ throw new RuntimeException("Re-Startup may have failed: " + e);
}
- return"Server has been restarted.";
+ return "Server has been restarted.";
}
private AvailabilityType waitForServerToStart(long start) throws InterruptedException {
AvailabilityType avail;
+ //detect whether startWaitMax property has been set.
+ Configuration pluginConfig = serverComponent.getPluginConfiguration();
+ PropertySimple property = pluginConfig.getSimple(JBossASServerComponent.START_WAIT_MAX_PROP);
+ //if set and valid, update startWaitMax value
+ if ((property != null) && (property.getIntegerValue() != null)) {
+ int newValue = property.getIntegerValue();
+ if (newValue >= 1) {
+ START_WAIT_MAX = 1000L * 60 * newValue;
+ }
+ }
+
while (((avail = this.serverComponent.getAvailability()) == AvailabilityType.DOWN)
&& (System.currentTimeMillis() < (start + START_WAIT_MAX))) {
try {
@@ -399,6 +410,17 @@ public class JBossASServerOperationsDelegate {
}
private AvailabilityType waitForServerToShutdown() {
+ //detect whether stopWaitMax property has been set.
+ Configuration pluginConfig = serverComponent.getPluginConfiguration();
+ PropertySimple property = pluginConfig.getSimple(JBossASServerComponent.STOP_WAIT_MAX_PROP);
+ //if set and valid, update startWaitMax value
+ if ((property != null) && (property.getIntegerValue() != null)) {
+ int newValue = property.getIntegerValue();
+ if (newValue >= 1) {
+ STOP_WAIT_MAX = 1000L * 60 * newValue;
+ }
+ }
+
for (long wait = 0L; (wait < STOP_WAIT_MAX) && (AvailabilityType.UP == this.serverComponent.getAvailability()); wait += STOP_WAIT_INTERVAL) {
try {
Thread.sleep(STOP_WAIT_INTERVAL);
diff --git a/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
index 28240ef..192c7f1 100644
--- a/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
@@ -74,6 +74,19 @@
description="The absolute path to a JRE or JDK installation directory containing
the JVM that should be used to start and shutdown the JBossAS instance;
defaults to the home directory of the RHQ agent JRE."/>
+
+ <c:simple-property name="startWaitMax" required="false"
+ description="The time, in minutes,(e.g. 1 or 8) that must elapse before the server is considered to have failed to start up. The default is 5 minutes.">
+ <c:constraint>
+ <c:integer-constraint minimum="1"/>
+ </c:constraint>
+ </c:simple-property>
+ <c:simple-property name="stopWaitMax" required="false"
+ description="The time, in minutes,(e.g. 1 or 8) that must elapse before the server is considered to have failed to stop. The default is 2.5 minutes.">
+ <c:constraint>
+ <c:integer-constraint minimum="1"/>
+ </c:constraint>
+ </c:simple-property>
</c:group>
<c:group name="event" displayName="Events">
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java
index 89cbd72..d67f072 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java
@@ -104,6 +104,8 @@ public class TomcatServerComponent implements JMXComponent, MeasurementFacet, Op
public static final String PLUGIN_CONFIG_SCRIPT_PREFIX = "scriptPrefix";
public static final String PLUGIN_CONFIG_SHUTDOWN_SCRIPT = "shutdownScript";
public static final String PLUGIN_CONFIG_START_SCRIPT = "startScript";
+ public static final String START_WAIT_MAX_PROP = "startWaitMax";
+ public static final String STOP_WAIT_MAX_PROP = "stopWaitMax";
private Log log = LogFactory.getLog(this.getClass());
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerOperationsDelegate.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerOperationsDelegate.java
index b0f3f7c..ce542a9 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerOperationsDelegate.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerOperationsDelegate.java
@@ -41,6 +41,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.core.pluginapi.util.ProcessExecutionUtility;
@@ -64,7 +65,7 @@ public class TomcatServerOperationsDelegate {
private static final String SERVER_MBEAN_NAME = "Catalina:type=Server";
/** max amount of time to wait for server to show as unavailable after executing stop - in milliseconds */
- private static final long STOP_WAIT_MAX = 1000L * 150; // 2.5 minutes
+ private static long STOP_WAIT_MAX = 1000L * 150; // 2.5 minutes
/** amount of time to wait between availability checks when performing a stop - in milliseconds */
private static final long STOP_WAIT_INTERVAL = 1000L * 10; // 10 seconds
@@ -74,7 +75,7 @@ public class TomcatServerOperationsDelegate {
private static final long STOP_WAIT_FINAL = 1000L * 30; // 30 seconds
/** max amount of time to wait for start to complete - in milliseconds */
- private static final long START_WAIT_MAX = 1000L * 300; // 5 minutes
+ private static long START_WAIT_MAX = 1000L * 300; // 5 minutes
/** amount of time to wait between availability checks when performing a start - in milliseconds */
private static final long START_WAIT_INTERVAL = 1000L * 10; // 10 seconds
@@ -466,6 +467,18 @@ public class TomcatServerOperationsDelegate {
private AvailabilityType waitForServerToStart(long start) throws InterruptedException {
AvailabilityType avail;
+
+ //detect whether startWaitMax property has been set.
+ Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration();
+ PropertySimple property = pluginConfig.getSimple(TomcatServerComponent.START_WAIT_MAX_PROP);
+ //if set and valid, update startWaitMax value
+ if ((property != null) && (property.getIntegerValue() != null)) {
+ int newValue = property.getIntegerValue();
+ if (newValue >= 1) {
+ START_WAIT_MAX = 1000L * 60 * newValue;
+ }
+ }
+
while (((avail = this.serverComponent.getAvailability()) == AvailabilityType.DOWN)
&& (System.currentTimeMillis() < (start + START_WAIT_MAX))) {
try {
@@ -478,6 +491,16 @@ public class TomcatServerOperationsDelegate {
}
private AvailabilityType waitForServerToShutdown() {
+ //detect whether stopWaitMax property has been set.
+ Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration();
+ PropertySimple property = pluginConfig.getSimple(TomcatServerComponent.STOP_WAIT_MAX_PROP);
+ //if set and valid, update startWaitMax value
+ if ((property != null) && (property.getIntegerValue() != null)) {
+ int newValue = property.getIntegerValue();
+ if (newValue >= 1) {
+ STOP_WAIT_MAX = 1000L * 60 * newValue;
+ }
+ }
for (long wait = 0L; (wait < STOP_WAIT_MAX) && (AvailabilityType.UP == this.serverComponent.getAvailability()); wait += STOP_WAIT_INTERVAL) {
try {
Thread.sleep(STOP_WAIT_INTERVAL);
diff --git a/modules/plugins/tomcat/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/tomcat/src/main/resources/META-INF/rhq-plugin.xml
index 5d511cc..24307ef 100644
--- a/modules/plugins/tomcat/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/tomcat/src/main/resources/META-INF/rhq-plugin.xml
@@ -96,6 +96,19 @@
description="The path to the script used by the 'Shutdown' operation to shutdown this Tomcat server;
if the path is not absolute it will be resolved relative to {installationPath}." />
+ <c:simple-property name="startWaitMax" required="false"
+ description="The time, in minutes,(e.g. 1 or 8) that must elapse before the server is considered to have failed to start up. The default is 5 minutes.">
+ <c:constraint>
+ <c:integer-constraint minimum="1"/>
+ </c:constraint>
+ </c:simple-property>
+ <c:simple-property name="stopWaitMax" required="false"
+ description="The time, in minutes,(e.g. 1 or 8) that must elapse before the server is considered to have failed to stop. The default is 2.5 minutes.">
+ <c:constraint>
+ <c:integer-constraint minimum="1"/>
+ </c:constraint>
+ </c:simple-property>
+
<c:list-property
name="startScriptEnvironment"
displayName="Start Script Environment Variables"
13 years, 1 month
[rhq] Branch 'as7plugin' - 2 commits - modules/plugins
by Heiko W. Rupp
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java | 144 ++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 4
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 27
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java | 7
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java | 289 ++++++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java | 113 +++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java | 51 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java | 7
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java | 37 +
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 99 ++-
10 files changed, 738 insertions(+), 40 deletions(-)
New commits:
commit 7bda199733e460362365e15793cc607b25acff48
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 6 21:49:39 2011 +0200
Improve detection of child resources
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 5dbd0b3..644fc24 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -52,6 +52,7 @@ import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -329,6 +330,9 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
protected List<PROPERTY_VALUE> pathToAddress(String path) {
+ if (path==null || path.isEmpty())
+ return Collections.emptyList();
+
if (path.endsWith("/"))
path = path.substring(0,path.length()-1);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
index a06a296..21005a9 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
@@ -114,8 +114,11 @@ public class DomainComponent extends BaseComponent implements OperationFacet{
} else if (what.equals("destination")) {
address.addAll(pathToAddress(getPath()));
String newName = parameters.getSimpleValue("name","");
- String type = parameters.getSimpleValue("type","Queue").toLowerCase();
- address.add(new PROPERTY_VALUE(type,newName));
+// String type = parameters.getSimpleValue("type","Queue").toLowerCase();
+// address.add(new PROPERTY_VALUE(type,newName));
+ String queueName = parameters.getSimpleValue("queue-address","");
+ Map<String,Object> props = new HashMap<String, Object>();
+ props.put("queue-address",queueName);
operation = new Operation(op,address);
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 1c498d1..9aea097 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -23,11 +23,13 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.modules.plugins.jbossas7.json.Subsystem;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Map;
+import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -35,7 +37,6 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
/**
* Discover subsystems
@@ -83,47 +84,63 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
System.out.println("total path: [" + path + "]");
- JsonNode json = connection.getLevelData(path,recursive, false);
+ JsonNode json ;
+ if (!recursive)
+ json = connection.getLevelData(path,recursive, false);
+ else {
+ List<PROPERTY_VALUE> addr ;
+ addr = parentComponent.pathToAddress(parentPath);
+ String childType = cpath.substring(0, cpath.length() - 2);
+ if (childType.startsWith("/"))
+ childType = childType.substring(1);
+ json = connection.execute(new ReadChildrenNames(addr, childType));
+ }
if (!connection.isErrorReply(json)) {
if (recursive) {
int i = path.lastIndexOf("/");
String subPath = path.substring(i+1);
- JsonNode subNode = json.findPath(subPath);
+ JsonNode subNode = json.findPath("result");
if (subNode==null || subNode.isNull())
subNode = json.get(subPath); // TODO clean this up. to get the 'key' in a path from the AS we need to use get()
- Map<String,Subsystem> subsystemMap = mapper.readValue(subNode,new TypeReference<Map<String,Subsystem>>() {});
+// Map<String,Subsystem> subsystemMap = mapper.readValue(subNode,new TypeReference<Map<String,Subsystem>>() {});
+ if (subNode.isArray()) {
- if (subsystemMap==null) {
- log.warn("SubsystemMap was null for path [" + path + "] and subPath ["+ subPath + "] and subNode [" + subNode + "]");
- return Collections.emptySet();
- }
+ Iterator<JsonNode> iter = subNode.getElements();
+// if (subsystemMap==null) {
+// log.warn("SubsystemMap was null for path [" + path + "] and subPath ["+ subPath + "] and subNode [" + subNode + "]");
+// return Collections.emptySet();
+// }
+ while (iter.hasNext()) {
+ JsonNode node = iter.next();
+ String val = node.getTextValue();
- for (Map.Entry<String,Subsystem> entry: subsystemMap.entrySet()) {
- String key = entry.getKey();
- Subsystem subsystem = entry.getValue();
- String newPath = cpath.replaceAll("\\*",key);
+ String newPath = cpath.replaceAll("\\*",val);
Configuration config2 = context.getDefaultPluginConfiguration();
PropertySimple pathProp = new PropertySimple("path",newPath);
config2.put(pathProp);
- String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
+ String resKey = context.getParentResourceContext().getResourceKey() + "/" + val;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
context.getResourceType(), // DataType
- path + "/" + key, // Key
+ path + "/" + val, // Key
name, // Name
null, // Version
- subsystem.description, // Description
+ "TODO", // subsystem.description, // Description
config2,
null);
details.add(detail);
}
+ }
+ else {
+ System.out.println("subnode was no array");
+ }
}
else {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java
index b2c8223..efe389b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java
@@ -59,4 +59,11 @@ public class PROPERTY_VALUE implements Serializable{
this.value = value;
}
+ @Override
+ public String toString() {
+ return "PROPERTY_VALUE{" +
+ "key='" + key + '\'' +
+ ", value='" + value + '\'' +
+ '}';
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java
new file mode 100644
index 0000000..8c5b37c
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java
@@ -0,0 +1,37 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.util.List;
+
+/**
+ * Operation that reads children of a given type from an address
+ * @author Heiko W. Rupp
+ */
+public class ReadChildrenNames extends Operation {
+
+ /**
+ * Reas children names of a given type below a given address
+ * @param address Address to look at e.g. /profile/default/subsystem/messaging
+ * @param childType e.g. queue
+ */
+ public ReadChildrenNames(List<PROPERTY_VALUE> address, String childType) {
+ super("read-children-names",address,"child-type",childType);
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 6741bb3..258da2c 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -51,7 +51,7 @@
version="4.0.0-SNAPSHOT"
>
- <depends plugin="JMX" useClasses="true"/>
+<!-- <depends plugin="JMX" useClasses="true"/> -->
<!-- TODO I think we should introduce an abstract AS7 plugin that contains some base functionality and then
@@ -284,6 +284,7 @@
<server name="Messaging"
discovery="SubsystemDiscovery"
class="DomainComponent"
+ description="The underlying HornetQ based messaging subsystem"
singleton="true"
>
<runs-inside>
@@ -298,12 +299,15 @@
<operation name="destination:add" displayName="Add destination" description="Add a Queue or Topic">
<parameters>
<c:simple-property name="name" description="Name of the Destination" required="true"/>
+ <c:simple-property name="queue-address" description="The queue address defines what address is used for routing messages." required="true"/>
<c:simple-property name="type" description="Type of Destination to create" default="Queue">
<c:property-options>
<c:option value="Queue"/>
<c:option value="Topic"/>
</c:property-options>
</c:simple-property>
+ <c:simple-property name="filter" description="The queue message filter definition."/>
+ <c:simple-property name="durable" description="Defines whether the queue is durable." type="boolean" default="false"/>
</parameters>
<results>
<c:simple-property name="operationResult"/>
@@ -329,7 +333,7 @@
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/acceptor"/>
+ <c:simple-property name="path" readOnly="true" default="acceptor"/>
</plugin-configuration>
</service>
<service name="MessagingConnector"
@@ -337,17 +341,65 @@
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/connector"/>
+ <c:simple-property name="path" readOnly="true" default="connector"/>
</plugin-configuration>
</service>
- <service name="Queue"
+ <service name="HQueue"
discovery="SubsystemDiscovery"
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/queue/*"/>
+ <c:simple-property name="path" readOnly="true" default="queue/*"/>
+ </plugin-configuration>
+ <resource-configuration>
+ <c:simple-property name="queue-address" required="true"/>
+ <c:simple-property name="filter" />
+ <c:simple-property name="durable" type="boolean"/>
+ </resource-configuration>
+
+ </service>
+ </server>
+
+ <server name="JMS"
+ discovery="SubsystemDiscovery"
+ class="DomainComponent"
+ description="The JMS messaging subsystem"
+ singleton="true"
+ >
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/jms"/>
+ </plugin-configuration>
+
+ <service name="Queue"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="queue/*"/>
</plugin-configuration>
</service>
+ <service name="Topic"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="topic/*"/>
+ </plugin-configuration>
+ </service>
+ <service name="Connection-Factory"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="connection-factory/*"/>
+ </plugin-configuration>
+ </service>
+
</server>
<server name="JBossWeb"
@@ -377,9 +429,9 @@
<metric property="bytesSent" measurementType="trendsup"/>
<metric property="bytesReceived" measurementType="trendsup"/>
<metric property="processingTime" measurementType="trendsup"/>
- <metric property="errorCount" measurementType="trendsup"/>
+ <metric property="errorCount" measurementType="trendsup" displayType="summary"/>
<metric property="maxTime" />
- <metric property="requestCount" measurementType="trendsup"/>
+ <metric property="requestCount" measurementType="trendsup" displayType="summary"/>
<resource-configuration>
<c:simple-property name="protocol" required="false" description="The web connector protocol."/>
@@ -431,7 +483,7 @@
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/data-source/*"/>
+ <c:simple-property name="path" readOnly="true" default="data-source/*"/>
</plugin-configuration>
</service>
@@ -442,7 +494,7 @@
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/xa-data-source/*"/>
+ <c:simple-property name="path" readOnly="true" default="xa-data-source/*"/>
</plugin-configuration>
</service>
@@ -453,7 +505,7 @@
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/jdbc-driver/*"/>
+ <c:simple-property name="path" readOnly="true" default="jdbc-driver/*"/>
</plugin-configuration>
</service>
commit f2dc89709b73b7506403f04ff36dc894a44232f5
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 6 12:28:18 2011 +0200
Detect Managed AS through hosts.xml , start with deployments.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
new file mode 100644
index 0000000..f3e9ee0
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
@@ -0,0 +1,144 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.org.apache.xerces.internal.impl.xpath.regex.REUtil;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+
+/**
+ * Connection for uploading of content.
+ * Partially taken from https://github.com/jbossas/jboss-as/blob/master/testsuite/smoke/src/test/...
+ *
+ * @author Jonathan Pearlin (of the original code)
+ * @author Heiko W. Rupp
+ */
+public class ASUploadConnection {
+
+ private static final String BOUNDARY = "-----------------------------261773107125236";
+
+ private static final String CRLF = "\r\n";
+
+ private static final String POST_REQUEST_METHOD = "POST";
+
+ private static final String UPLOAD_URL = "http://localhost:9990/domain-api/add-content";
+
+ private final Log log = LogFactory.getLog(ASUploadConnection.class);
+
+ BufferedOutputStream os = null;
+ BufferedInputStream is = null;
+ private HttpURLConnection connection;
+
+ public OutputStream getOutputStream(String fileName) {
+ try {
+ // Create the HTTP connection to the upload URL
+ connection = (HttpURLConnection) new URL(UPLOAD_URL).openConnection();
+ connection.setDoInput(true);
+ connection.setDoOutput(true);
+ connection.setRequestMethod(POST_REQUEST_METHOD);
+
+ // Grab the test WAR file and get a stream to its contents to be included in the POST.
+ os = new BufferedOutputStream(connection.getOutputStream());
+ os.write(buildPostRequestHeader(fileName));
+
+ return os;
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ public JsonNode finishUpload() {
+ try {
+ os.write(buildPostRequestFooter());
+ os.flush();
+
+ is = new BufferedInputStream(connection.getInputStream());
+ // TODO read from IN
+
+ } catch (IOException e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ }
+ finally {
+ closeQuietly(is);
+ closeQuietly(os);
+ }
+
+ return null;
+ }
+
+
+ private byte[] buildPostRequestHeader(String fileName) {
+ final StringBuilder builder = new StringBuilder();
+ builder.append(buildPostRequestHeaderSection("form-data; name=\"test1\"", "", "test1"));
+ builder.append(buildPostRequestHeaderSection("form-data; name=\"test2\"", "", "test2"));
+ builder.append(buildPostRequestHeaderSection("form-data; name=\"file\"; filename=\""+fileName+"\"", "application/octet-stream", ""));
+ return builder.toString().getBytes();
+ }
+
+ private String buildPostRequestHeaderSection(final String contentDisposition, final String contentType, final String content) {
+ final StringBuilder builder = new StringBuilder();
+ builder.append(BOUNDARY);
+ builder.append(CRLF);
+ if(contentDisposition != null && contentDisposition.length() > 0) {
+ builder.append(String.format("Content-Disposition: %s", contentDisposition));
+ }
+ builder.append(CRLF);
+ if(contentType != null && contentType.length() > 0) {
+ builder.append(String.format("Content-Type: %s", contentType));
+ }
+ builder.append(CRLF);
+ if(content != null && content.length() > 0) {
+ builder.append(content);
+ }
+ builder.append(CRLF);
+ return builder.toString();
+ }
+
+ private byte[] buildPostRequestFooter() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append(CRLF);
+ builder.append(BOUNDARY);
+ builder.append("--");
+ builder.append(CRLF);
+ return builder.toString().getBytes();
+ }
+
+
+ private void closeQuietly(final Closeable closeable) {
+ if(closeable != null) {
+ try {
+ closeable.close();
+ } catch (final IOException e) {}
+ }
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 5ea4bd7..8597d8f 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -1,3 +1,21 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
package org.rhq.modules.plugins.jbossas7;
import java.io.File;
@@ -58,12 +76,9 @@ public class BaseProcessDiscovery implements ResourceDiscoveryComponent
String serverNameFull;
String serverName;
String psName = psr.getProcessScan().getName();
- if (psName.equals("ProcessManager")) {
- serverNameFull = "ProcessManager";
- serverName = "ProcessManager";
- } else if (psName.equals("ASManager")) {
- serverName = "ASManager";
- serverNameFull = "ASManager";
+ if (psName.equals("ProcessController")) {
+ serverNameFull = "ProcessController";
+ serverName = "ProcessController";
} else if (psName.equals("HostController")) {
serverName = "HostController";
serverNameFull = "HostController";
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
new file mode 100644
index 0000000..86e3b99
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
@@ -0,0 +1,289 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ProcessScanResult;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.system.ProcessInfo;
+
+/**
+ * Discovery class for managed AS 7 instances.
+ *
+ * @author Heiko W. Rupp
+ */
+public class ManagedASDiscovery implements ResourceDiscoveryComponent
+
+{
+
+ static final String DJBOSS_SERVER_BASE_DIR = "-Djboss.server.base.dir=";
+ static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file=";
+ static final String DLOGGING_CONFIGURATION = "-Dlogging.configuration=";
+ static final int DEFAULT_MGMT_PORT = 9990;
+ private final Log log = LogFactory.getLog(this.getClass());
+ private Document hostXml;
+ private static final String DJBOSS_SERVER_HOME_DIR = "-Djboss.home.dir";
+
+ /**
+ * Run the auto-discovery
+ */
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext) throws Exception {
+ Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
+
+
+ List<ProcessScanResult> scans = discoveryContext.getAutoDiscoveredProcesses();
+
+ for (ProcessScanResult psr : scans) {
+
+ // get the HostController, as this is an indicator for managed AS
+ String psName = psr.getProcessScan().getName();
+ if (!psName.equals("HostController"))
+ continue;
+
+ // Now we have the host controller, lets get the host.xml file
+ // and obtain the servers from there.
+ ProcessInfo processInfo = psr.getProcessInfo();
+ readHostXml(processInfo);
+ String hostName = findHostName();
+ int port = getManagementPortFromHostXml();
+
+
+ List<ServerInfo> serverNames = getServersFromHostXml();
+ for (ServerInfo serverInfo : serverNames) {
+
+ Configuration config = discoveryContext.getDefaultPluginConfiguration();
+ config.put(new PropertySimple("domainHost",hostName));
+ config.put(new PropertySimple("group",serverInfo.group));
+ config.put(new PropertySimple("port",port));
+
+ // TODO this fails for the downed servers.
+ // get from the domain or other place as soon as the domain provides it.
+ initLogFile(scans, serverInfo.name, config, getHomeDirFromCommandLine(processInfo.getCommandLine()));
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ discoveryContext.getResourceType(), // ResourceType
+ hostName + "/" + serverInfo.name, // key
+ serverInfo.name, // Name
+ null, // TODO real version - get from Domain as soon as it is provided
+ "Managed AS 7 instance", // Description
+ config,
+ null
+ );
+
+ // Add to return values
+ discoveredResources.add(detail);
+ log.info("Discovered new ... " + discoveryContext.getResourceType() + ", " + serverInfo);
+ }
+ }
+ return discoveredResources;
+ }
+
+ /**
+ * Loop through the Process scans for ManagedAS and if found extract the logfile path.
+ * @param scans process scan results
+ * @param name server name to look for
+ * @param config config to put the info in
+ * @param basePath
+ */
+ private void initLogFile(List<ProcessScanResult> scans, String name, Configuration config, String basePath) {
+
+ for (ProcessScanResult psr : scans) {
+ if (!psr.getProcessScan().getName().equals("ManagedAS"))
+ continue;
+
+ String[] commandLine = psr.getProcessInfo().getCommandLine();
+
+ String logFile = basePath + File.separator + getLogFileFromCommandLine(commandLine);
+
+ if (logFile.contains(name))
+ initLogEventSourcesConfigProp(logFile,config);
+ }
+ }
+
+ private int getManagementPortFromHostXml() {
+ Element host = hostXml.getDocumentElement();
+ NodeList interfaceParent = host.getElementsByTagName("management-interfaces");
+ if (interfaceParent ==null || interfaceParent.getLength()==0) {
+ log.warn("No <management-interfaces> found in host.xml");
+ return DEFAULT_MGMT_PORT;
+ }
+ NodeList mgmtInterfaces = interfaceParent.item(0).getChildNodes();
+ if (mgmtInterfaces==null || mgmtInterfaces.getLength()==0) {
+ log.warn("No <*-interface> found in host.xml");
+ return DEFAULT_MGMT_PORT;
+ }
+ for (int i = 0 ; i < mgmtInterfaces.getLength(); i++) {
+ if (!(mgmtInterfaces.item(i) instanceof Element))
+ continue;
+
+ Element mgmtInterface = (Element) mgmtInterfaces.item(i);
+ if (mgmtInterface.getNodeName().equals("http-interface")) {
+ String tmp = mgmtInterface.getAttribute("port");
+ int port = Integer.valueOf(tmp);
+ return port;
+ }
+ }
+ return DEFAULT_MGMT_PORT;
+ }
+
+ private List<ServerInfo> getServersFromHostXml() {
+
+ Element host = hostXml.getDocumentElement();
+ NodeList serversElement = host.getElementsByTagName("servers");
+ if (serversElement ==null || serversElement.getLength()==0) {
+ log.warn("No <servers> found in host.xml");
+ return Collections.emptyList();
+ }
+ NodeList servers = serversElement.item(0).getChildNodes();
+ if (servers==null || servers.getLength()==0) {
+ log.warn("No <server> found in host.xml");
+ return Collections.emptyList();
+ }
+ List<ServerInfo> result = new ArrayList<ServerInfo>();
+ for (int i = 0 ; i < servers.getLength(); i++) {
+ if (!(servers.item(i) instanceof Element))
+ continue;
+
+ ServerInfo info = new ServerInfo();
+ Element server = (Element) servers.item(i);
+ info.name = server.getAttribute("name");
+ info.group = server.getAttribute("group");
+ String autoStart = server.getAttribute("autoStart");
+ if (autoStart==null || autoStart.isEmpty())
+ autoStart = "false";
+ info.autoStart = Boolean.getBoolean(autoStart);
+
+ result.add(info);
+ }
+
+ return result;
+ }
+
+
+ private String findHostName() {
+ String hostName = hostXml.getDocumentElement().getAttribute("name");
+ return hostName;
+ }
+
+ private void readHostXml(ProcessInfo processInfo) {
+ String hostXmlFile = getHostXmlFileLocation(processInfo);
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ try {
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ InputStream is = new FileInputStream(hostXmlFile);
+ hostXml = builder.parse(is);
+ is.close();
+ } catch (Exception e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ }
+ }
+
+ /**
+ * Get the location of the host definition file (host.xml in domain mode, standalone.xml
+ * in standalone mode.
+ *
+ * @param processInfo ProcessInfo structure containing the ENV variables
+ * @return The path to the definition file.
+ */
+ private String getHostXmlFileLocation(ProcessInfo processInfo) {
+
+ String home = getHomeDirFromCommandLine(processInfo.getCommandLine());
+ StringBuilder builder = new StringBuilder(home);
+ builder.append("/domain");
+ builder.append("/configuration");
+ builder.append("/host.xml");
+ return builder.toString();
+
+ }
+
+
+
+ String getHomeDirFromCommandLine(String[] commandLine) {
+ for (String line: commandLine) {
+ if (line.startsWith(DJBOSS_SERVER_HOME_DIR))
+ return line.substring(DJBOSS_SERVER_HOME_DIR.length()+1);
+ }
+ return "";
+ }
+
+//-Dorg.jboss.boot.log.file=/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/log/server-manager/boot.log
+//-Dlogging.configuration=file:/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/configuration/logging.properties
+
+ String getLogFileFromCommandLine(String[] commandLine) {
+
+ for (String line: commandLine) {
+ if (line.startsWith(DORG_JBOSS_BOOT_LOG_FILE))
+ return line.substring(DORG_JBOSS_BOOT_LOG_FILE.length());
+ }
+ return "";
+ }
+
+ private void initLogEventSourcesConfigProp(String fileName, Configuration pluginConfiguration) {
+
+ PropertyList logEventSources = pluginConfiguration
+ .getList(LogFileEventResourceComponentHelper.LOG_EVENT_SOURCES_CONFIG_PROP);
+
+ if (logEventSources==null)
+ return;
+
+ File serverLogFile = new File(fileName);
+
+ if (serverLogFile.exists() && !serverLogFile.isDirectory()) {
+ PropertyMap serverLogEventSource = new PropertyMap("logEventSource");
+ serverLogEventSource.put(new PropertySimple(
+ LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.LOG_FILE_PATH, serverLogFile));
+ serverLogEventSource.put(new PropertySimple(
+ LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.ENABLED, Boolean.FALSE));
+ logEventSources.add(serverLogEventSource);
+ }
+ }
+
+ private class ServerInfo {
+ String name;
+ String group;
+ boolean autoStart;
+
+
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
new file mode 100644
index 0000000..9650731
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
@@ -0,0 +1,113 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+
+import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.transfer.DeployPackageStep;
+import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
+import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.pluginapi.content.ContentContext;
+import org.rhq.core.pluginapi.content.ContentFacet;
+import org.rhq.core.pluginapi.content.ContentServices;
+import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+
+/**
+ * Component dealing with server group specific things
+ * @author Heiko W. Rupp
+ */
+public class ServerGroupComponent extends DomainComponent implements ContentFacet, CreateChildResourceFacet {
+
+ private final Log log = LogFactory.getLog(ServerGroupComponent.class);
+
+ @Override
+ public List<DeployPackageStep> generateInstallationSteps(ResourcePackageDetails packageDetails) {
+ return null; // TODO: Customise this generated block
+ }
+
+ @Override
+ public DeployPackagesResponse deployPackages(Set<ResourcePackageDetails> packages,
+ ContentServices contentServices) {
+
+ ContentContext cctx = context.getContentContext();
+
+ String uploadUrl = "http://localhost:9990/domain-api/add-content";
+
+ for (ResourcePackageDetails details : packages) {
+ ASUploadConnection uploadConnection = new ASUploadConnection();
+ OutputStream out = uploadConnection.getOutputStream(details.getFileName());
+ contentServices.downloadPackageBits(cctx, details.getKey(), out, false);
+ JsonNode result = uploadConnection.finishUpload();
+ }
+
+
+ return null; // TODO: Customise this generated block
+ }
+
+ @Override
+ public RemovePackagesResponse removePackages(Set<ResourcePackageDetails> packages) {
+ return null; // TODO: Customise this generated block
+ }
+
+ @Override
+ public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
+ return null; // TODO: Customise this generated block
+ }
+
+ @Override
+ public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
+ return null; // TODO: Customise this generated block
+ }
+
+ @Override
+ public CreateResourceReport createResource(CreateResourceReport report) {
+
+
+ ResourcePackageDetails details = report.getPackageDetails();
+
+ ContentContext cctx = context.getContentContext();
+ ContentServices contentServices = cctx.getContentServices();
+ String resourceTypeName = report.getResourceType().getName();
+
+ ASUploadConnection connection = new ASUploadConnection();
+ OutputStream out = connection.getOutputStream(details.getFileName());
+// contentServices.downloadPackageBits(cctx,details.getKey(),out,false);
+ contentServices.downloadPackageBitsForChildResource(cctx, resourceTypeName, details.getKey(), out);
+
+ JsonNode result = connection.finishUpload();
+ System.out.println(result);
+
+
+ report.setStatus(CreateResourceStatus.SUCCESS) ;
+
+ return report;
+
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 02b4bf8..6741bb3 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -71,7 +71,7 @@
&logSources;
</plugin-configuration>
- <process-scan name="ProcessManager" query="process|basename|match=^java.*,arg|org.jboss.as.process-controller|match=.*"/>
+ <process-scan name="ProcessController" query="process|basename|match=^java.*,arg|org.jboss.as.process-controller|match=.*"/>
<operation name="dummyOperation">
@@ -93,7 +93,7 @@
&logSources;
</plugin-configuration>
- <process-scan name="ProcessManager" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
+ <process-scan name="HostController" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
<operation name="dummyOperation">
@@ -132,16 +132,25 @@
<server name="ServerGroup"
description="Server groups on this domain"
discovery="SubsystemDiscovery"
- class="ServerGroupComponent">
+ class="ServerGroupComponent"
+ >
+ <!-- TODO move operation to createDeletePolicy="create-only" -->
+
<plugin-configuration>
<c:simple-property name="path" default="/server-group/*" readOnly="true"/>
</plugin-configuration>
+
+
+ <content name="deployment" category="deployable" isCreationType="true" description="Deployments on this domain">
+ </content>
+
<resource-configuration>
<c:simple-property name="profile" />
<c:simple-property name="socket-binding-group"/>
<c:simple-property name="jvm"/>
<c:simple-property name="deployment" required="false"/> <!-- TODO change structure. Or put below as resource? -->
</resource-configuration>
+ <service name="Deployment" class="BaseComponent" discovery="SubsystemDiscovery" createDeletePolicy="create-only"/>
</server>
<server name="Host"
description="Host involved in this domain"
@@ -171,9 +180,11 @@
</results>
</operation>
+<!--
<resource-configuration>
<c:list-property name="server-config" />
</resource-configuration>
+-->
</server>
@@ -216,16 +227,20 @@
</server>
<server name="JBossAS-Managed"
- discovery="BaseProcessDiscovery"
+ discovery="ManagedASDiscovery"
class="DomainComponent"
>
<plugin-configuration>
<c:simple-property name="hostname" default="localhost" required="true"/>
<c:simple-property name="port" default="9990" type="integer" required="true"/>
+ <c:simple-property name="domainHost" readOnly="true" description="Hostname in the domain"/>
+ <c:simple-property name="group" readOnly="true" displayName="Server Group" description="Server Group this instance belongs to."/>
&logSources;
</plugin-configuration>
+ <!-- Scan for host controller is intentional -->
+ <process-scan name="HostController" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
<process-scan name="ManagedAS" query="process|basename|match=^java.*,arg|org.jboss.as.server|match=.*"/>
<operation name="server:start" description="Start this server instance." displayName="Start">
@@ -330,7 +345,7 @@
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/queue/"/>
+ <c:simple-property name="path" readOnly="true" default="/queue/*"/>
</plugin-configuration>
</service>
</server>
@@ -383,7 +398,9 @@
<resource-configuration>
<c:simple-property name="access-log"/>
- <c:list-property name="alias" description="The virtual server aliases"/>
+ <c:list-property name="alias" description="The virtual server aliases">
+ <c:simple-property name="alias"/>
+ </c:list-property>
<c:simple-property name="rewrite"/>
</resource-configuration>
13 years, 1 month
[rhq] modules/enterprise
by ips
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java | 12 +++++-----
1 file changed, 6 insertions(+), 6 deletions(-)
New commits:
commit 7b91cb2e587aac2017094f313f89047cc89f275f
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Apr 6 12:21:38 2011 -0400
class i missed in a commit yesterday
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java
index eaca3b6..d92e7ba 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesBase.java
@@ -38,6 +38,7 @@ public abstract class SubjectPreferencesBase {
/** delimiter for preferences that are multi-valued and stringified */
protected static final String PREF_LIST_DELIM = ",";
protected static final String PREF_ITEM_DELIM = "|";
+ protected static final String PREF_ITEM_DELIM_REGEX = "\\|";
private int subjectId;
private Set<String> changed;
@@ -50,7 +51,6 @@ public abstract class SubjectPreferencesBase {
/**
* Get the value of a preference as a boolean.
* @param key the preference to get
- * @param ifNull if the pref is undefined, return this value instead
* @return the boolean value of 'key', or if key is null, returns the
* 'ifNull' value.
*/
@@ -204,11 +204,11 @@ public abstract class SubjectPreferencesBase {
protected List<Integer> getPreferenceAsIntegerList(String key, String delimiter) {
try {
- List<String> value = getPreferenceAsList(key, delimiter);
+ List<String> values = getPreferenceAsList(key, delimiter);
- List<Integer> result = new ArrayList<Integer>(value.size());
- for (int i = 0; i < value.size(); i++) {
- String trimmed = value.get(i).trim();
+ List<Integer> result = new ArrayList<Integer>(values.size());
+ for (String value : values) {
+ String trimmed = value.trim();
if (trimmed.length() > 0) {
result.add(Integer.valueOf(trimmed));
}
@@ -230,7 +230,7 @@ public abstract class SubjectPreferencesBase {
}
public void setPreference(String key, Object value) throws IllegalArgumentException {
- String val = null;
+ String val;
if (value == null) {
val = "";
} else if (value instanceof String) {
13 years, 1 month