[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
New commits:
commit 39096ad47535381425e25f67e1cd0ae8649123ab
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Apr 13 11:21:28 2011 -0400
move log stmt into else block where it should be
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 64a8749..6768fce 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
@@ -175,7 +175,8 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
}
Integer recordId = getId(record);
String detailsUrl = "#" + getBasePath() + "/" + recordId;
- String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString()) : value.toString();
+ String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString()) :
+ value.toString();
return SeleniumUtility.getLocatableHref(detailsUrl, formattedValue, null);
}
};
@@ -358,13 +359,12 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
protected void switchToTableView() {
final Canvas contents = getTableContents();
if (contents != null) {
- // First refresh the table's data.
- Log.debug("Refreshing data for [" + getClass().getName() + "]...");
- // If this is not the initial display of the table, refresh the table data . Otherwise, a refresh would be
+ // If this is not the initial display of the table, refresh the table's data. Otherwise, a refresh would be
// redundant, since the data was just loaded when the table was drawn.
if (this.initialDisplay) {
this.initialDisplay = false;
} else {
+ Log.debug("Refreshing data for Table [" + getClass().getName() + "]...");
refresh();
}
if (detailsHolder != null && detailsHolder.isVisible()) {
@@ -381,4 +381,5 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
}
}
}
+
}
13 years, 1 month
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java | 2 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java | 2 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java | 17 +++++++---
3 files changed, 15 insertions(+), 6 deletions(-)
New commits:
commit abc7cd665aa8a4129ad25f26371fe8409f995dc7
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Apr 13 10:35:36 2011 -0400
fix a bug in TableSection where a redundant refresh was done on the initial rendering of the Table
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 6aaf418..115d4a8 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
@@ -161,7 +161,7 @@ public class RolesView extends TableSection<RolesDataSource> implements Bookmark
public void onPermissionsLoaded(Set<Permission> permissions) {
if (permissions != null) {
hasManageSecurity = permissions.contains(Permission.MANAGE_SECURITY);
- refresh();
+ refreshTableInfo();
} else {
hasManageSecurity = false;
}
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 4fae91e..427b1c2 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
@@ -101,7 +101,7 @@ public class UsersView extends TableSection<UsersDataSource> {
public void onPermissionsLoaded(Set<Permission> permissions) {
if (permissions != null) {
hasManageSecurity = permissions.contains(Permission.MANAGE_SECURITY);
- refresh();
+ refreshTableInfo();
} else {
hasManageSecurity = 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 b19abfd..64a8749 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
@@ -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
@@ -58,6 +58,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
private Canvas detailsView;
private String basePath;
private boolean escapeHtmlInDetailsLinkColumn;
+ private boolean initialDisplay;
protected TableSection(String locatorId, String tableTitle) {
super(locatorId, tableTitle);
@@ -94,6 +95,8 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
protected void onInit() {
super.onInit();
+ this.initialDisplay = true;
+
detailsHolder = new LocatableVLayout(extendLocatorId("tableSection"));
detailsHolder.setAlign(VerticalAlignment.TOP);
//detailsHolder.setWidth100();
@@ -111,10 +114,10 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
}
/**
- * The default implementation wraps the {@link getDetailsLinkColumnCellFormatter()} column with the
+ * The default implementation wraps the {@link #getDetailsLinkColumnCellFormatter()} column with the
* {@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>
+ * {@link #showDetails(com.smartgwt.client.widgets.grid.ListGridRecord)}</br>
* </br>
* In general, in overrides, call super.configureTable *after* manipulating the ListGrid fields.
*
@@ -357,7 +360,13 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
if (contents != null) {
// First refresh the table's data.
Log.debug("Refreshing data for [" + getClass().getName() + "]...");
- refresh();
+ // If this is not the initial display of the table, refresh the table data . Otherwise, a refresh would be
+ // redundant, since the data was just loaded when the table was drawn.
+ if (this.initialDisplay) {
+ this.initialDisplay = false;
+ } else {
+ refresh();
+ }
if (detailsHolder != null && detailsHolder.isVisible()) {
detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
@Override
13 years, 1 month
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/preferences/UserPreferences.java | 24 +++++++---
1 file changed, 18 insertions(+), 6 deletions(-)
New commits:
commit 87b488f907b471667c40fe412baad5aecf8042a4
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Apr 13 09:54:52 2011 -0400
BZ 680167 - this doesn't fully fix the issue, but what this does is ensure we don't refresh CoreGUI if we are setting/storing recent resource/group preferences
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 9006bec..ce43aa4 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
@@ -58,6 +58,14 @@ public class UserPreferences {
private ArrayList<UserPreferenceChangeListener> changeListeners = new ArrayList<UserPreferenceChangeListener>();
+ // when these preferences change, they should not trigger a refresh.
+ private static ArrayList<String> preferencesThatShouldNotCauseRefresh;
+ static {
+ preferencesThatShouldNotCauseRefresh = new ArrayList<String>();
+ preferencesThatShouldNotCauseRefresh.add(UserPreferenceNames.RECENT_RESOURCES);
+ preferencesThatShouldNotCauseRefresh.add(UserPreferenceNames.RECENT_RESOURCE_GROUPS);
+ }
+
public UserPreferences(Subject subject) {
this.subject = subject;
this.userConfiguration = subject.getUserConfiguration();
@@ -77,20 +85,24 @@ public class UserPreferences {
this.autoPersister = new UserPreferenceChangeListener() {
@Override
public void onPreferenceChange(UserPreferenceChangeEvent event) {
- persist();
+ persist(event.name);
}
@Override
public void onPreferenceRemove(UserPreferenceChangeEvent event) {
- persist();
+ persist(event.name);
}
- private void persist() {
+ private void persist(final String preferenceThatChanged) {
store(new AsyncCallback<Subject>() {
@Override
public void onSuccess(Subject result) {
- // don't announce anything, should happen under the covers - just refresh the current page
- CoreGUI.refresh();
+ // Don't announce anything to message center, this should happen under the covers - just refresh the current page.
+ // But we should not blindly refresh - if we are changing preferences that should not affect the current
+ // page, don't refresh as this could cause additional and unnecessary server-side hits (BZ 680167)
+ if (!preferencesThatShouldNotCauseRefresh.contains(preferenceThatChanged)) {
+ CoreGUI.refresh();
+ }
}
@Override
@@ -207,7 +219,7 @@ public class UserPreferences {
}
return value;
}
-
+
protected void setPreference(String name, Collection<?> value) {
StringBuilder buffer = new StringBuilder();
boolean first = true;
13 years, 1 month
[rhq] Branch 'as7plugin' - 46 commits - modules/core modules/enterprise modules/plugins
by Heiko W. Rupp
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java | 34
modules/enterprise/gui/coregui/pom.xml | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 164 +--
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/PermissionsLoader.java | 42
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java | 15
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/admin/templates/ResourceTypeTreeView.java | 50
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.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 | 44
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java | 76 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 45
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 25
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java | 34
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/AuthorizedButton.java | 78 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EditableFormItem.java | 260 ----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableFormItem.java | 345 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableTextAreaFormItem.java | 53 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 10
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/DashboardView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java | 14
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/PortletConfigurationEditorComponent.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java | 7
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/ResourceBundleDeploymentsPortlet.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceConfigurationUpdatesPortlet.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java | 31
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java | 23
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOobsPortlet.java | 23
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/dashboard/portlets/resource/ResourcePkgHistoryPortlet.java | 23
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/util/MessagePortlet.java | 15
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/help/HelpView.java | 27
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java | 91 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 8
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/OverviewForm.java | 4
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/client/inventory/resource/detail/ResourceTopView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 33
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/inventory/resource/factory/AbstractResourceFactoryWizard.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java | 30
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryCreateWizard.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryImportWizard.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java | 3
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/AlertDefinitionReportView.java | 10
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/test/TestTopView.java | 92 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestUserPreferencesView.java | 171 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/async/TestAsyncView.java | 114 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java | 11
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/client/util/async/AbstractCompoundAsyncOperation.java | 120 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/AsyncOperation.java | 31
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/AsyncOperationCallback.java | 34
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/CompoundAsyncOperationException.java | 47
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/ParallelCompoundAsyncOperation.java | 40
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/SerialCompoundAsyncOperation.java | 73 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 15
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java | 2
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/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventCreateDeleteChildJSON.jsp | 6
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/error.xhtml | 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java | 18
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerBean.java | 20
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/system/SystemManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerLocal.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerRemote.java | 14
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 17
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java | 41
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java | 11
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 1
modules/plugins/apache/src/main/java/org/rhq/plugins/www/util/WWWUtils.java | 73 +
modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml | 9
113 files changed, 4121 insertions(+), 2170 deletions(-)
New commits:
commit f22bc3f1472bca5c05bab29319c02998048d0bcb
Merge: 7660aec e9639a9
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 13 13:22:16 2011 +0200
Merge branch 'master' into as7plugin
commit e9639a9b7f4cb834a5485fd66c8cd980d6c1fbe0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 13 13:18:32 2011 +0200
BZ 693700 - prevent NPE for empty <c:list-property/>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 8b9868a..fd2decc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -450,15 +450,23 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
* the member prop def for the list. If the member prop def is a nested structure the whole thing
* is replaced from the top.
*
- * @param exList the existing prop def list
+ * @param exList the existing prop def list
* @param newList the new prop def list
*/
private void replaceListProperty(PropertyDefinitionList exList, PropertyDefinitionList newList) {
PropertyDefinition doomedMemberDef = null;
+ if (newList.getMemberDefinition()==null) {
+ log.error("\n\n!! Member definition for new list property [" + newList.getName() + "] is null - check and fix the plugin descriptor\n");
+ return;
+ }
+
+ // We did not have a member definition before (which is wrong )
+ // we need to add it now
// only remove the existing member if it is a different entity
- if (exList.getMemberDefinition().getId() != newList.getMemberDefinition().getId()) {
- doomedMemberDef = exList.getMemberDefinition();
+ PropertyDefinition exListMemberDefinition = exList.getMemberDefinition();
+ if (exListMemberDefinition !=null && exListMemberDefinition.getId() != newList.getMemberDefinition().getId()) {
+ doomedMemberDef = exListMemberDefinition;
}
exList.setMemberDefinition(newList.getMemberDefinition());
commit 0a3b269072e34738482a5690325d11a83d82c58b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Apr 12 16:05:57 2011 -0400
add to our #Test page some iframes to the sql, hibernate and other test jsps useful to devs
add a new "user preferences" test page so you can see the current user's preferences
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 054974a..1844270 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.Label;
+
+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;
@@ -65,10 +66,19 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
private static final ViewName PAGE_GROUP_CONFIG_EDITOR = new ViewName("GroupConfigEditor");
private static final ViewName PAGE_READONLY_GROUP_CONFIG_EDITOR = new ViewName("ReadOnlyGroupConfigEditor");
+ // view IDs for Server Access section
+ private static final ViewName SERVERACCESS_SECTION_VIEW_ID = new ViewName("ServerAccess");
+ private static final ViewName PAGE_REMOTE_SERVICE_STATISTICS = new ViewName("RemoteServiceStatistics");
+ private static final ViewName PAGE_SQL = new ViewName("SQL");
+ private static final ViewName PAGE_HIBERNATE = new ViewName("Hibernate");
+ private static final ViewName PAGE_ENTITY_BROWSER = new ViewName("EntityBrowser");
+ private static final ViewName PAGE_EMAIL = new ViewName("EmailTest");
+ private static final ViewName PAGE_AGENT = new ViewName("AgentConnectivityTest");
+ private static final ViewName PAGE_USER_PREFERENCES = new ViewName("UserPreferences");
+
// view IDs for Misc section
private static final ViewName MISC_SECTION_VIEW_ID = new ViewName("Misc");
private static final ViewName PAGE_PLURALIZATION_TEST = new ViewName("PluralizationTest");
- private static final ViewName PAGE_REMOTE_SERVICE_STATISTICS = new ViewName("RemoteServiceStatistics");
private static final ViewName PAGE_ASYNC = new ViewName("Async");
public TestTopView() {
@@ -81,7 +91,7 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
vLayout.setWidth100();
// TODO: Help icon.
- TitleBar titleBar = new TitleBar(this, MSG.view_testTop_title());
+ TitleBar titleBar = new TitleBar(this, MSG.view_testTop_title());
vLayout.addMember(titleBar);
Label label = new Label(MSG.view_testTop_description());
@@ -101,6 +111,9 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
NavigationSection configurationSection = buildConfigurationSection();
sections.add(configurationSection);
+ NavigationSection serverAccessSection = buildServerAccessSection();
+ sections.add(serverAccessSection);
+
NavigationSection miscSection = buildMiscSection();
sections.add(miscSection);
@@ -161,10 +174,10 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
groupConfigEditorItem, readOnlyGroupConfigEditorItem);
}
- private NavigationSection buildMiscSection() {
- NavigationItem pluralizationItem = new NavigationItem(PAGE_PLURALIZATION_TEST, null, new ViewFactory() {
+ private NavigationSection buildServerAccessSection() {
+ NavigationItem userPrefsItem = new NavigationItem(PAGE_USER_PREFERENCES, null, new ViewFactory() {
public Canvas createView() {
- return new TestPluralizationView(extendLocatorId(PAGE_PLURALIZATION_TEST.getName()));
+ return new TestUserPreferencesView(extendLocatorId(PAGE_USER_PREFERENCES.getName()));
}
});
@@ -176,14 +189,54 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
}
});
- NavigationItem asyncItem = new NavigationItem(PAGE_ASYNC, null,
- new ViewFactory() {
- public Canvas createView() {
- return new TestAsyncView(extendLocatorId(PAGE_ASYNC.getName()));
- }
- });
+ NavigationItem sqlItem = new NavigationItem(PAGE_SQL, null, new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_SQL.getName()), "/admin/test/sql.jsp");
+ }
+ });
+
+ NavigationItem hibernateItem = new NavigationItem(PAGE_HIBERNATE, null, new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_HIBERNATE.getName()), "/admin/test/hibernate.jsp");
+ }
+ });
+
+ NavigationItem entityBrowserItem = new NavigationItem(PAGE_ENTITY_BROWSER, null, new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_ENTITY_BROWSER.getName()), "/admin/test/browser.jsp");
+ }
+ });
+
+ NavigationItem emailItem = new NavigationItem(PAGE_EMAIL, null, new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_EMAIL.getName()), "/admin/test/email.jsp");
+ }
+ });
+
+ NavigationItem agentItem = new NavigationItem(PAGE_AGENT, null, new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_AGENT.getName()), "/admin/test/agent.jsp");
+ }
+ });
+
+ return new NavigationSection(SERVERACCESS_SECTION_VIEW_ID, remoteServiceStatisticsItem, sqlItem, hibernateItem,
+ entityBrowserItem, emailItem, agentItem, userPrefsItem);
+ }
+
+ private NavigationSection buildMiscSection() {
+ NavigationItem pluralizationItem = new NavigationItem(PAGE_PLURALIZATION_TEST, null, new ViewFactory() {
+ public Canvas createView() {
+ return new TestPluralizationView(extendLocatorId(PAGE_PLURALIZATION_TEST.getName()));
+ }
+ });
+
+ NavigationItem asyncItem = new NavigationItem(PAGE_ASYNC, null, new ViewFactory() {
+ public Canvas createView() {
+ return new TestAsyncView(extendLocatorId(PAGE_ASYNC.getName()));
+ }
+ });
- return new NavigationSection(MISC_SECTION_VIEW_ID, pluralizationItem, remoteServiceStatisticsItem, asyncItem);
+ return new NavigationSection(MISC_SECTION_VIEW_ID, pluralizationItem, asyncItem);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestUserPreferencesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestUserPreferencesView.java
new file mode 100644
index 0000000..3c1e768
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestUserPreferencesView.java
@@ -0,0 +1,171 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.test;
+
+import java.util.Map;
+
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.RecordList;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.types.SortDirection;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+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.util.preferences.UserPreferences;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+
+public class TestUserPreferencesView extends Table {
+
+ // these are used both as the name of the fields, titles of the headers and the columns of the CSV output
+ private static final String FIELD_NAME = "Name";
+ private static final String FIELD_VALUE = "Value";
+
+ private static final SortSpecifier[] defaultSorts = new SortSpecifier[] { new SortSpecifier(FIELD_NAME,
+ SortDirection.DESCENDING) };
+
+ private final UserPreferences prefs;
+
+ private static String getTableTitle() {
+ return "User Preferences (" + UserSessionManager.getSessionSubject().getName() + ")";
+ }
+
+ public TestUserPreferencesView(String locatorId) {
+ super(locatorId, getTableTitle(), null, defaultSorts, null, false);
+ prefs = UserSessionManager.getUserPreferences();
+ }
+
+ @Override
+ protected void configureTable() {
+ ListGridField id = new ListGridField(FIELD_ID, "ID");
+ ListGridField name = new ListGridField(FIELD_NAME, "Name");
+ ListGridField value = new ListGridField(FIELD_VALUE, "Value");
+
+ id.setWidth("10%");
+ name.setWidth("45%");
+ name.setWidth("45%");
+
+ getListGrid().setFields(id, name, value);
+ refresh();
+
+ addTableAction(extendLocatorId("export"), "Export To CSV",
+ new AbstractTableAction(TableActionEnablement.ALWAYS) {
+ @Override
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ final String s = "~";
+ StringBuilder csv = new StringBuilder();
+ csv.append(FIELD_ID).append(s).append(FIELD_NAME).append(s).append(FIELD_VALUE).append('\n');
+
+ RecordList records = getListGrid().getDataAsRecordList();
+ int recordsSize = records.getLength();
+ for (int i = 0; i < recordsSize; i++) {
+ Record record = records.get(i);
+ csv.append(record.getAttribute(FIELD_ID)).append(s).append(record.getAttribute(FIELD_NAME))
+ .append(s).append(record.getAttribute(FIELD_VALUE)).append('\n');
+ }
+
+ new MessageWindow(extendLocatorId("csv"), "Export To CSV", "<pre>" + csv.toString() + "</pre>")
+ .show();
+ }
+ });
+ }
+
+ @Override
+ protected SelectionStyle getDefaultSelectionStyle() {
+ return SelectionStyle.NONE;
+ }
+
+ @Override
+ public void refresh() {
+ super.refresh();
+ getListGrid().setRecords(transform(this.prefs.getConfiguration()));
+ }
+
+ private ListGridRecord[] transform(Configuration configuration) {
+ ListGridRecord[] results = new ListGridRecord[configuration.getAllProperties().size()];
+ int i = 0;
+ for (Map.Entry<String, Property> entry : configuration.getAllProperties().entrySet()) {
+ results[i++] = transform(entry.getValue());
+ }
+ return results;
+ }
+
+ private ListGridRecord transform(Property prop) {
+ String value;
+ if (prop instanceof PropertySimple) {
+ value = ((PropertySimple) prop).getStringValue();
+ } else {
+ String classname = prop.getClass().getName();
+ value = "(value of type " + classname.substring(classname.lastIndexOf(".") + 1) + ")";
+ }
+
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(FIELD_ID, prop.getId());
+ record.setAttribute(FIELD_NAME, prop.getName());
+ record.setAttribute(FIELD_VALUE, value);
+ return record;
+ }
+
+ class MessageWindow extends LocatableWindow {
+ public MessageWindow(String locatorId, String title, String message) {
+ super(locatorId);
+
+ LocatableHTMLPane htmlPane = new LocatableHTMLPane(extendLocatorId("winDetailsPane"));
+ htmlPane.setMargin(10);
+ htmlPane.setDefaultWidth(600);
+ htmlPane.setDefaultHeight(400);
+ htmlPane.setContents(message);
+
+ setTitle(title);
+ setShowMinimizeButton(false);
+ setShowMaximizeButton(true);
+ setShowCloseButton(true);
+ setDismissOnEscape(false); // force close button to be pressed to ensure our close handler is called
+ setIsModal(true);
+ setShowModalMask(true);
+ setAutoSize(true);
+ setAutoCenter(true);
+ setShowResizer(true);
+ setCanDragResize(true);
+ centerInPage();
+ addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ markForDestroy();
+ }
+ });
+ addItem(htmlPane);
+ }
+ }
+}
commit 1b76728da8c05cb9efe2ea04a5e6a677e98166af
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 12 12:56:37 2011 -0400
Alert Definition Work
- Fix button enablement issues [BZ 694912 - Can't create new Alert Template, edit button is disabled]
This boiled down to an async issue where it was not guaranteed that
the global perms would be loaded prior to providing them for enablement
purposes. made template view like resource and group and now provides the
perms in the constructor, guranteeing existence.
-- Note, went down the wrong path for a while and ended up adding a
AuthorizedButton class. Not currently used but has built in global auth
check for a standalone button.
-- also made an analogous fix to metric template button enablement.
- Fixed issue where the escape character was presented as the value
for editable string fields with no value yet set. Factored out new base class
SimpleEditableFormItem from EditableFormItem to provide support for
a read/write field without the in-field editing/icons. This allowed
more central handling of being able to turn on/off HTML output for
text fields.
-- note, also fixed this in a few more places that don't use
the editable form item classes.
- Fix the fact that a non-perm user could nav to template view but then not
see any alert templates in the list. Then, furthermore add the ability to
inspect the detail.
-- this required an underlying fix to the alert def criteria search, which
was too aggresively filtering on resource authz. alert def templates and
group alert defs don't have a resource and therfore that authz
token will always force an empty result set.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
index e0b3d20..31f76a1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
@@ -47,6 +47,7 @@ public class AlertDefinitionCriteria extends Criteria {
private String filterName;
private String filterDescription;
private AlertPriority filterPriority;
+ private NonBindingOverrideFilter filterAlertTemplateOnly; // requires overrides - finds only alert templates
private Integer filterAlertTemplateParentId; // requires overrides
private Integer filterAlertTemplateResourceTypeId; // requires overrides
private String filterAlertTemplateResourceTypeName; // requires overrides
@@ -55,9 +56,8 @@ public class AlertDefinitionCriteria extends Criteria {
private Boolean filterEnabled;
private Boolean filterDeleted = false; // find enabled definitions by default
private NonBindingOverrideFilter filterResourceOnly; // requires overrides - finds only those associated with a resource
- private NonBindingOverrideFilter filterResourceTypeOnly; // requires overrides - finds only alert templates
private List<String> filterNotificationSenderNames;
-
+
private boolean fetchAlerts;
private boolean fetchGroupAlertDefinition;
private boolean fetchConditions;
@@ -68,17 +68,16 @@ public class AlertDefinitionCriteria extends Criteria {
private PageOrdering sortName;
private PageOrdering sortPriority;
- public AlertDefinitionCriteria() {
+ public AlertDefinitionCriteria() {
+ filterOverrides.put("alertTemplateOnly", "resourceType IS NOT NULL");
filterOverrides.put("alertTemplateParentId", "parentId = ?");
filterOverrides.put("alertTemplateResourceTypeId", "resourceType.id = ?");
filterOverrides.put("alertTemplateResourceTypeName", "resourceType.name like ?");
filterOverrides.put("resourceIds", "resource.id IN ( ? )");
filterOverrides.put("resourceGroupIds", "resourceGroup.id IN ( ? )");
filterOverrides.put("resourceOnly", "resource IS NOT NULL");
- filterOverrides.put("resourceTypeOnly", "resourceType IS NOT NULL");
- filterOverrides.put("notificationSenderNames", "id IN (" +
- "SELECT notif.alertDefinition.id FROM AlertNotification notif " +
- "WHERE notif.senderName IN ( ? ))");
+ filterOverrides.put("notificationSenderNames", "id IN ("
+ + "SELECT notif.alertDefinition.id FROM AlertNotification notif " + "WHERE notif.senderName IN ( ? ))");
filterOverrides.put("filterIds", "id IN ( ? )");
}
@@ -94,7 +93,7 @@ public class AlertDefinitionCriteria extends Criteria {
public void addFilterIds(Integer... filterIds) {
this.filterIds = Arrays.asList(filterIds);
}
-
+
public void addFilterName(String filterName) {
this.filterName = filterName;
}
@@ -139,8 +138,8 @@ public class AlertDefinitionCriteria extends Criteria {
this.filterResourceOnly = (filterResourceOnly ? NonBindingOverrideFilter.ON : NonBindingOverrideFilter.OFF);
}
- public void addFilterResourceTypeOnly(boolean filterResourceTypeOnly) {
- this.filterResourceTypeOnly = (filterResourceTypeOnly ? NonBindingOverrideFilter.ON
+ public void addFilterAlertTemplateOnly(boolean filterAlertTemplateOnly) {
+ this.filterAlertTemplateOnly = (filterAlertTemplateOnly ? NonBindingOverrideFilter.ON
: NonBindingOverrideFilter.OFF);
}
@@ -148,7 +147,7 @@ public class AlertDefinitionCriteria extends Criteria {
fetchAlertNotifications(true);
this.filterNotificationSenderNames = Arrays.asList(notificationNames);
}
-
+
public void fetchAlerts(boolean fetchAlerts) {
this.fetchAlerts = fetchAlerts;
}
@@ -182,4 +181,17 @@ public class AlertDefinitionCriteria extends Criteria {
addSortField("priority");
this.sortPriority = sortPriority;
}
+
+ public boolean isTemplateCriteria() {
+ return null != filterAlertTemplateOnly //
+ || null != filterAlertTemplateParentId //
+ || null != filterAlertTemplateResourceTypeId //
+ || null != filterAlertTemplateResourceTypeName;
+
+ }
+
+ public boolean isGroupCriteria() {
+ return null != filterResourceGroupIds;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
index 3daa669..fecac0b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.admin.templates;
import java.util.Map;
+import java.util.Set;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.Alignment;
@@ -39,12 +40,15 @@ import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeGridField;
import com.smartgwt.client.widgets.tree.TreeNode;
+import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
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.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.admin.AdministrationView;
@@ -215,25 +219,35 @@ public class ResourceTypeTreeView extends LocatableVLayout implements Bookmarkab
private void editAlertTemplate(int resourceTypeId, final ViewPath viewPath) {
final Integer[] idArray = new Integer[] { resourceTypeId };
ResourceTypeRepository.Cache.getInstance().getResourceTypes(idArray, new TypesLoadedCallback() {
- @Override
- public void onTypesLoaded(Map<Integer, ResourceType> types) {
- ResourceType rt = types.get(idArray[0]);
- Layout alertCanvas = getAlertTemplateCanvas();
- String locatorId = extendLocatorId("alertTemplateDef");
- TemplateAlertDefinitionsView def = new TemplateAlertDefinitionsView(locatorId, rt);
- def.renderView(viewPath.next());
- prepareSubCanvas(alertCanvas, def, viewPath.isEnd()); // don't show our back button if we are going to a template details pane which has its own back button
- switchToCanvas(ResourceTypeTreeView.this, alertCanvas);
+
+ public void onTypesLoaded(final Map<Integer, ResourceType> types) {
+ new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
+
+ public void onPermissionsLoaded(Set<Permission> permissions) {
+ ResourceType rt = types.get(idArray[0]);
+ Layout alertCanvas = getAlertTemplateCanvas();
+ String locatorId = extendLocatorId("alertTemplateDef");
+ TemplateAlertDefinitionsView def = new TemplateAlertDefinitionsView(locatorId, rt, permissions);
+ def.renderView(viewPath.next());
+ prepareSubCanvas(alertCanvas, def, viewPath.isEnd()); // don't show our back button if we are going to a template details pane which has its own back button
+ switchToCanvas(ResourceTypeTreeView.this, alertCanvas);
+ }
+ });
}
});
}
- private void editMetricTemplate(int resourceTypeId) {
- Layout metricCanvas = getMetricTemplateCanvas();
- TemplateSchedulesView templateSchedulesView = new TemplateSchedulesView(extendLocatorId("MetricTemplate"),
- resourceTypeId);
- prepareSubCanvas(metricCanvas, templateSchedulesView, true);
- switchToCanvas(ResourceTypeTreeView.this, metricCanvas);
+ private void editMetricTemplate(final int resourceTypeId) {
+ new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
+
+ public void onPermissionsLoaded(Set<Permission> permissions) {
+ Layout metricCanvas = getMetricTemplateCanvas();
+ TemplateSchedulesView templateSchedulesView = new TemplateSchedulesView(
+ extendLocatorId("MetricTemplate"), resourceTypeId, permissions);
+ prepareSubCanvas(metricCanvas, templateSchedulesView, true);
+ switchToCanvas(ResourceTypeTreeView.this, metricCanvas);
+ }
+ });
}
public class CustomResourceTypeListGrid extends LocatableListGrid {
@@ -287,8 +301,8 @@ public class ResourceTypeTreeView extends LocatableVLayout implements Bookmarkab
enabledMetricTemplatesField.setPrompt(MSG.view_adminTemplates_prompt_enabledMetricTemplates());
disabledMetricTemplatesField.setPrompt(MSG.view_adminTemplates_prompt_disabledMetricTemplates());
- setFields(nameField, pluginField, categoryField, enabledAlertTemplatesField, disabledAlertTemplatesField, enabledMetricTemplatesField,
- disabledMetricTemplatesField);
+ setFields(nameField, pluginField, categoryField, enabledAlertTemplatesField, disabledAlertTemplatesField,
+ enabledMetricTemplatesField, disabledMetricTemplatesField);
}
@Override
@@ -401,7 +415,7 @@ public class ResourceTypeTreeView extends LocatableVLayout implements Bookmarkab
disabledMetricTemplatesField.setPrompt(MSG.view_adminTemplates_prompt_disabledMetricTemplates());
setFields(nameField, pluginField, categoryField, enabledAlertTemplatesField, disabledAlertTemplatesField,
- enabledMetricTemplatesField, disabledMetricTemplatesField);
+ enabledMetricTemplatesField, disabledMetricTemplatesField);
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java
index c9a4226..4e21fa9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java
@@ -18,17 +18,14 @@
*/
package org.rhq.enterprise.gui.coregui.client.admin.templates;
+import java.util.Set;
+
import com.smartgwt.client.data.Criteria;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.criteria.MeasurementScheduleCriteria;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView;
-import java.util.EnumSet;
-import java.util.Set;
-
/**
* A view for viewing and updating the default metric schedules ("metric templates") for a particular ResourceType.
*
@@ -42,27 +39,17 @@ public class TemplateSchedulesView extends AbstractMeasurementScheduleListView {
private boolean updateExistingSchedules = true;
private Set<Permission> globalPermissions;
- public TemplateSchedulesView(String locatorId, int resourceTypeId) {
+ public TemplateSchedulesView(String locatorId, int resourceTypeId, Set<Permission> globalPermissions) {
super(locatorId, TITLE, new TemplateSchedulesDataSource(resourceTypeId), createCriteria(resourceTypeId),
EXCLUDED_FIELD_NAMES);
- this.globalPermissions = EnumSet.noneOf(Permission.class);
- loadGlobalPermissions();
+ this.globalPermissions = globalPermissions;
}
public boolean hasManageMeasurementsPermission() {
- loadGlobalPermissions();
return globalPermissions.contains(Permission.MANAGE_INVENTORY);
}
- private void loadGlobalPermissions() {
- new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
- public void onPermissionsLoaded(Set<Permission> permissions) {
- globalPermissions = permissions;
- }
- });
- }
-
private static Criteria createCriteria(int resourceTypeId) {
Criteria criteria = new Criteria();
criteria.addCriteria(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID, resourceTypeId);
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 c3f817b..aac1626 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
@@ -75,11 +75,11 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
ListGridField descriptionField = listGrid.getField(AbstractAlertDefinitionsDataSource.FIELD_DESCRIPTION);
descriptionField.setCellFormatter(new EscapedHtmlCellFormatter());
- boolean permitted = isAllowedToModifyAlertDefinitions();
+ final boolean isAuthorized = isAuthorizedToModifyAlertDefinitions();
addTableAction(extendLocatorId("New"), MSG.common_button_new(), null, new AbstractTableAction() {
public boolean isEnabled(ListGridRecord[] selection) {
- return super.isEnabled(selection) && isAllowedToModifyAlertDefinitions();
+ return super.isEnabled(selection) && isAuthorized;
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -90,7 +90,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
addTableAction(extendLocatorId("Enable"), MSG.common_button_enable(), MSG
.view_alert_definitions_enable_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
public boolean isEnabled(ListGridRecord[] selection) {
- return super.isEnabled(selection) && isAllowedToModifyAlertDefinitions();
+ return super.isEnabled(selection) && isAuthorized;
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -101,7 +101,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
addTableAction(extendLocatorId("Disable"), MSG.common_button_disable(), MSG
.view_alert_definitions_disable_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
public boolean isEnabled(ListGridRecord[] selection) {
- return super.isEnabled(selection) && isAllowedToModifyAlertDefinitions();
+ return super.isEnabled(selection) && isAuthorized;
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -112,7 +112,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), MSG
.view_alert_definitions_delete_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
public boolean isEnabled(ListGridRecord[] selection) {
- return super.isEnabled(selection) && isAllowedToModifyAlertDefinitions();
+ return super.isEnabled(selection) && isAuthorized;
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -156,7 +156,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
singleAlertDefinitionView.setAlertDefinition(newAlertDef);
singleAlertDefinitionView.makeEditable();
} else {
- final AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
+ final AlertDefinitionCriteria criteria = getDetailCriteria();
criteria.addFilterId(id);
criteria.fetchGroupAlertDefinition(true);
criteria.fetchConditions(true);
@@ -179,13 +179,21 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
return singleAlertDefinitionView;
}
+ /**
+ * Override to add any criteria that must be present when fetching the alert definition detail.
+ * @return
+ */
+ protected AlertDefinitionCriteria getDetailCriteria() {
+ return new AlertDefinitionCriteria();
+ }
+
protected abstract ResourceType getResourceType();
protected abstract Criteria getCriteria();
protected abstract AbstractAlertDefinitionsDataSource getAlertDefinitionDataSource();
- protected abstract boolean isAllowedToModifyAlertDefinitions();
+ protected abstract boolean isAuthorizedToModifyAlertDefinitions();
protected abstract void newButtonPressed(ListGridRecord[] selection);
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 7d6b0d5..f154b26 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
@@ -28,12 +28,13 @@ import java.util.LinkedHashMap;
import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.form.fields.TextAreaItem;
-import com.smartgwt.client.widgets.form.fields.TextItem;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.components.form.SimpleEditableTextAreaFormItem;
+import org.rhq.enterprise.gui.coregui.client.components.form.SimpleEditableFormItem;
+import org.rhq.enterprise.gui.coregui.client.components.form.StringLengthValidator;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -43,14 +44,12 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
private AlertDefinition alertDefinition;
- private TextItem nameTextField;
- private TextAreaItem descriptionTextField;
+ private SimpleEditableFormItem nameField;
+ private SimpleEditableTextAreaFormItem descriptionField;
private SelectItem prioritySelection;
private RadioGroupItem enabledSelection;
private RadioGroupItem readOnlySelection;
- private StaticTextItem nameStatic;
- private StaticTextItem descriptionStatic;
private StaticTextItem priorityStatic;
private StaticTextItem enabledStatic;
private StaticTextItem readOnlyStatic;
@@ -91,11 +90,9 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
if (alertDef == null) {
clearFormValues();
} else {
- nameTextField.setValue(alertDef.getName());
- nameStatic.setValue(alertDef.getName());
+ nameField.setValue(alertDef.getName());
- descriptionTextField.setValue(alertDef.getDescription());
- descriptionStatic.setValue(alertDef.getDescription());
+ descriptionField.setValue(alertDef.getDescription());
prioritySelection.setValue(alertDef.getPriority().name());
priorityStatic.setValue(alertDef.getPriority().name());
@@ -112,11 +109,9 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
@Override
public void makeEditable() {
- nameTextField.show();
- nameStatic.hide();
+ nameField.switchToEditMode();
- descriptionTextField.show();
- descriptionStatic.hide();
+ descriptionField.switchToEditMode();
prioritySelection.show();
priorityStatic.hide();
@@ -144,11 +139,9 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
@Override
public void makeViewOnly() {
- nameTextField.hide();
- nameStatic.show();
+ nameField.switchToStaticMode();
- descriptionTextField.hide();
- descriptionStatic.show();
+ descriptionField.switchToStaticMode();
prioritySelection.hide();
priorityStatic.show();
@@ -176,8 +169,11 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
@Override
public void saveAlertDefinition() {
- alertDefinition.setName(nameTextField.getValue().toString());
- alertDefinition.setDescription(descriptionTextField.getValue().toString());
+ alertDefinition.setName(nameField.getValue().toString());
+ Object description = descriptionField.getValue();
+ if (null != description) {
+ alertDefinition.setDescription(description.toString());
+ }
String prioritySelected = prioritySelection.getValue().toString();
alertDefinition.setPriority(AlertPriority.valueOf(prioritySelected));
@@ -188,14 +184,12 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
@Override
public void clearFormValues() {
- nameTextField.clearValue();
- descriptionTextField.clearValue();
+ nameField.clearValue();
+ descriptionField.clearValue();
prioritySelection.clearValue();
enabledSelection.clearValue();
readOnlySelection.clearValue();
- nameStatic.clearValue();
- descriptionStatic.clearValue();
priorityStatic.clearValue();
enabledStatic.clearValue();
readOnlyStatic.clearValue();
@@ -205,19 +199,15 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
private void buildForm() {
if (!formBuilt) {
- nameTextField = new TextItem("name", MSG.common_title_name());
- 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);
+ nameField = new SimpleEditableFormItem("name", MSG.common_title_name());
+ nameField.setWidth(300);
+ StringLengthValidator notEmptyValidator = new StringLengthValidator(1, null, false);
+ // ensure these are executed in a validate() override
+ nameField.setValidators(notEmptyValidator);
+
+ descriptionField = new SimpleEditableTextAreaFormItem("description", MSG.common_title_description());
+ descriptionField.setWidth(300);
+ descriptionField.setDefaultValue("");
prioritySelection = new SelectItem("priority", MSG.view_alerts_field_priority());
LinkedHashMap<String, String> priorities = new LinkedHashMap<String, String>(3);
@@ -251,11 +241,19 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
readOnlySelection.setPrompt(MSG.view_alerts_field_protected_tooltip());
readOnlyStatic = new StaticTextItem("readOnlyStatic", MSG.view_alerts_field_protected());
- setFields(nameTextField, nameStatic, descriptionTextField, descriptionStatic, prioritySelection,
- priorityStatic, enabledSelection, enabledStatic, readOnlySelection, readOnlyStatic);
+ setFields(nameField, descriptionField, prioritySelection, priorityStatic, enabledSelection, enabledStatic,
+ readOnlySelection, readOnlyStatic);
formBuilt = true;
}
+ }
+ /**
+ * Must explicitly force outer-form validatation of EditibleFormItems.
+ */
+ @Override
+ public boolean validate() {
+ return super.validate() && nameField.validate();
}
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
index 5a68af8..dc75308 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -104,7 +104,7 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- protected boolean isAllowedToModifyAlertDefinitions() {
+ protected boolean isAuthorizedToModifyAlertDefinitions() {
return this.permissions.isAlert();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index 6ad4392..a6673e3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -104,7 +104,7 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- protected boolean isAllowedToModifyAlertDefinitions() {
+ protected boolean isAuthorizedToModifyAlertDefinitions() {
return this.permissions.isAlert();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index 2bacf3d..f276937 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -28,6 +28,8 @@ import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.tab.Tab;
+import com.smartgwt.client.widgets.tab.events.TabDeselectedEvent;
+import com.smartgwt.client.widgets.tab.events.TabDeselectedHandler;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton;
@@ -52,7 +54,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
private Button saveButton;
private Button cancelButton;
- private boolean allowedToModifyAlertDefinitions;
+ private boolean isAuthorizedToModifyAlertDefinitions;
public SingleAlertDefinitionView(String locatorId, AbstractAlertDefinitionsView alertDefView) {
this(locatorId, alertDefView, null);
@@ -63,15 +65,24 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
super(locatorId);
this.alertDefinition = alertDefinition;
- this.allowedToModifyAlertDefinitions = alertDefView.isAllowedToModifyAlertDefinitions();
+ this.isAuthorizedToModifyAlertDefinitions = alertDefView.isAuthorizedToModifyAlertDefinitions();
- LocatableTabSet tabSet = new LocatableTabSet(this.getLocatorId());
+ final LocatableTabSet tabSet = new LocatableTabSet(this.getLocatorId());
tabSet.setHeight100();
- Tab generalPropertiesTab = new LocatableTab(tabSet.extendLocatorId("General"), MSG
+ final Tab generalPropertiesTab = new LocatableTab(tabSet.extendLocatorId("General"), MSG
.view_alert_common_tab_general());
generalProperties = new GeneralPropertiesAlertDefinitionForm(this.getLocatorId(), alertDefinition);
generalPropertiesTab.setPane(generalProperties);
+ generalPropertiesTab.addTabDeselectedHandler(new TabDeselectedHandler() {
+
+ @Override
+ public void onTabDeselected(TabDeselectedEvent event) {
+ if (!generalProperties.validate()) {
+ event.cancel();
+ }
+ }
+ });
Tab conditionsTab = new LocatableTab(tabSet.extendLocatorId("Conditions"), MSG
.view_alert_common_tab_conditions());
@@ -110,7 +121,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
buttons.addMember(saveButton);
buttons.addMember(cancelButton);
- editButton.setDisabled(!allowedToModifyAlertDefinitions);
+ editButton.setDisabled(!isAuthorizedToModifyAlertDefinitions);
editButton.addClickHandler(new ClickHandler() {
@Override
@@ -122,11 +133,15 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
saveButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- saveAlertDefinition();
- setAlertDefinition(getAlertDefinition()); // loads data into static fields
- makeViewOnly();
-
- alertDefView.commitAlertDefinition(getAlertDefinition());
+ if (generalProperties.validate()) {
+ saveAlertDefinition();
+ setAlertDefinition(getAlertDefinition()); // loads data into static fields
+ makeViewOnly();
+
+ alertDefView.commitAlertDefinition(getAlertDefinition());
+ } else {
+ tabSet.selectTab(generalPropertiesTab);
+ }
}
});
@@ -160,11 +175,11 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
}
public void makeEditable() {
- if (!this.allowedToModifyAlertDefinitions) {
- // this is just a safety measure - we should never get here if we don't have perms, but just in case,
- // don't do anything to allow the def to be editable. Should we notify the message center?
- return;
- }
+ // if (!this.allowedToModifyAlertDefinitions) {
+ // this is just a safety measure - we should never get here if we don't have perms, but just in case,
+ // don't do anything to allow the def to be editable. Should we notify the message center?
+ // return;
+ // }
saveButton.show();
cancelButton.show();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
index 9e5590e..8599225 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
@@ -49,13 +49,15 @@ public class TemplateAlertDefinitionsDataSource extends AbstractAlertDefinitions
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
Criteria requestCriteria = request.getCriteria();
+ criteria.addFilterAlertTemplateOnly(true);
+
if (requestCriteria != null) {
Map values = requestCriteria.getValues();
for (Object key : values.keySet()) {
String fieldName = (String) key;
if (fieldName.equals(TemplateAlertDefinitionsView.CRITERIA_RESOURCE_TYPE_ID)) {
- Integer resourceId = (Integer) values.get(fieldName);
- criteria.addFilterAlertTemplateResourceTypeId(resourceId);
+ Integer resourceTypeId = (Integer) values.get(fieldName);
+ criteria.addFilterAlertTemplateResourceTypeId(resourceTypeId);
}
}
}
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 01f813f..337341a 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,7 +23,6 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
-import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;
@@ -33,10 +32,9 @@ 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.criteria.AlertDefinitionCriteria;
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;
@@ -53,9 +51,10 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
private ResourceType resourceType;
private Set<Permission> globalPermissions;
- public TemplateAlertDefinitionsView(String locatorId, ResourceType resourceType) {
+ public TemplateAlertDefinitionsView(String locatorId, ResourceType resourceType, Set<Permission> globalPermissions) {
super(locatorId, "Alert Templates");
this.resourceType = resourceType;
+ this.globalPermissions = globalPermissions;
// make sure we loaded all the type info we'll need. if one of these is null, either the type
// doesn't have it or we haven't loaded it yet. since we can't know for sure if it was loaded, we have to ask.
@@ -77,14 +76,11 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
});
}
+ }
- this.globalPermissions = Collections.emptySet();
- new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
- public void onPermissionsLoaded(Set<Permission> globalPermissions) {
- TemplateAlertDefinitionsView.this.globalPermissions = globalPermissions;
- refreshTableInfo();
- }
- });
+ @Override
+ protected boolean isAuthorizedToModifyAlertDefinitions() {
+ return globalPermissions.contains(Permission.MANAGE_SETTINGS);
}
@Override
@@ -115,11 +111,6 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- protected boolean isAllowedToModifyAlertDefinitions() {
- return globalPermissions.contains(Permission.MANAGE_SETTINGS);
- }
-
- @Override
protected void newButtonPressed(ListGridRecord[] selection) {
newDetails();
}
@@ -246,4 +237,11 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
});
}
}
+
+ protected AlertDefinitionCriteria getDetailCriteria() {
+ AlertDefinitionCriteria criteria = super.getDetailCriteria();
+ criteria.addFilterAlertTemplateOnly(true);
+ return criteria;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/AuthorizedButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/AuthorizedButton.java
new file mode 100644
index 0000000..ff68562
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/AuthorizedButton.java
@@ -0,0 +1,78 @@
+/*
+ * 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.buttons;
+
+import java.util.HashSet;
+import java.util.Set;
+
+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.table.AuthorizedTableAction;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton;
+
+// TODO: This utility isCurrently unused. Candidate for removal.
+
+/**
+ * This class allows for a standalone Button enablement based on global perm authorization.
+ *
+ * For buttons embedded in Table views see {@link AuthorizedTableAction}.
+ *
+ * @author Jay Shaughnessy
+ */
+public class AuthorizedButton extends LocatableButton {
+
+ HashSet<Permission> globalPermissions = new HashSet<Permission>();
+
+ Boolean isGlobalAuthorized;
+
+ public AuthorizedButton(String locatorId, String title, Permission... permissions) {
+ super(locatorId, title);
+
+ if (permissions.length == 0) {
+ throw new IllegalArgumentException("Must provide at least one Permission");
+ }
+
+ for (Permission p : permissions) {
+ switch (p.getTarget()) {
+ case GLOBAL:
+ globalPermissions.add(p);
+ break;
+ case RESOURCE:
+ throw new IllegalArgumentException("Does not support Resource permissions");
+ }
+ }
+
+ setDisabled(true);
+
+ new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
+
+ public void onPermissionsLoaded(Set<Permission> grantedPermissions) {
+ for (Permission requiredPermission : globalPermissions) {
+ if (!grantedPermissions.contains(requiredPermission)) {
+ return;
+ }
+ }
+ setDisabled(false);
+ markForRedraw();
+ }
+ });
+ }
+}
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 86f87b3..8ff3d91 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
@@ -22,8 +22,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.components.form;
-import java.util.Date;
-
import com.google.gwt.event.dom.client.KeyCodes;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.events.MouseOutEvent;
@@ -32,21 +30,14 @@ import com.smartgwt.client.widgets.events.MouseOverEvent;
import com.smartgwt.client.widgets.events.MouseOverHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.FormItemIfFunction;
-import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.FormItemIcon;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.FormItemClickHandler;
import com.smartgwt.client.widgets.form.fields.events.FormItemIconClickEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
-import com.smartgwt.client.widgets.form.validator.Validator;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.Messages;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* This form item can be used to display a value normally in "read-only" form (i.e. as a StaticTextItem),
@@ -57,47 +48,25 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*
* @author John Mazzitelli
*/
-public class EditableFormItem extends CanvasItem {
-
- protected static Messages MSG = CoreGUI.getMessages();
-
- private boolean readOnly = false;
- private boolean editing = false;
- private FormItem staticItem;
- private FormItem editItem;
- private DynamicForm innerForm;
-
- private ValueEditedHandler valueEditedHandler;
+public class EditableFormItem extends SimpleEditableFormItem {
public EditableFormItem() {
- this(null, null);
+ super();
}
public EditableFormItem(String name, String title) {
- this(name, title, null);
+ super(name, title);
}
public EditableFormItem(String name, String title, ValueEditedHandler handler) {
- if (name != null) {
- setName(name);
- }
- if (title != null) {
- setTitle(title);
- }
- if (handler != null) {
- setValueEditedHandler(handler);
- }
+ super(name, title, handler);
+ }
+
+ protected void addHandlers() {
final FormItemIcon blankIcon = createBlankIcon();
final FormItemIcon editIcon = createEditIcon();
- this.innerForm = new LocatableDynamicForm(getName() + "_innerForm");
- this.staticItem = prepareStaticFormItem();
- this.editItem = prepareEditFormItem();
- this.innerForm.setItems(staticItem, editItem);
- this.innerForm.setCanFocus(true);
- this.innerForm.setNumCols(1);
-
// 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() {
public void onMouseOut(MouseOutEvent event) {
@@ -115,9 +84,6 @@ public class EditableFormItem extends CanvasItem {
}
}
});
-
- setCanvas(this.innerForm);
- setCanFocus(true);
}
protected FormItem prepareStaticFormItem() {
@@ -135,9 +101,6 @@ public class EditableFormItem extends CanvasItem {
}
});
item.setTextBoxStyle("editableText");
- if (item instanceof StaticTextItem) {
- ((StaticTextItem)item).setOutputAsHTML(true);
- }
return item;
}
@@ -172,33 +135,6 @@ public class EditableFormItem extends CanvasItem {
return item;
}
- /**
- * This instantiates the static item. The form item created by this method will
- * be further customized by {@link #prepareStaticFormItem()}.
- *
- * @return the form item used to show the static (read-only) value
- */
- protected FormItem instantiateStaticFormItem() {
- @SuppressWarnings({"UnnecessaryLocalVariable"})
- StaticTextItem item = new StaticTextItem();
- return item;
- }
-
- /**
- * This instantiates the edit item. The form item created by this method will
- * be further customized by {@link #prepareEditFormItem()}.
- *
- * Subclasses will usually override this method to provide a different form
- * item such as a checkbox, radio buttons, etc.
- *
- * @return the form item used to edit the value
- */
- protected FormItem instantiateEditFormItem() {
- @SuppressWarnings({"UnnecessaryLocalVariable"})
- TextItem item = new TextItem();
- return item;
- }
-
protected FormItemIcon createEditIcon() {
FormItemIcon editIcon = new FormItemIcon();
editIcon.setSrc(ImageManager.getEditIcon());
@@ -248,186 +184,4 @@ public class EditableFormItem extends CanvasItem {
return blankIcon;
}
- /**
- * This sets the {@link #setEditing(boolean) edit flag} to false and ensures
- * the component switches to the static, read-only mode.
- */
- protected void switchToStaticMode() {
- if (isEditing()) {
- setEditing(false);
- markForRedraw();
- }
- }
-
- /**
- * This sets the {@link #setEditing(boolean) edit flag} to true and ensures
- * the component switches to the edit, read-write mode.
- */
- protected void switchToEditMode() {
- if (!isEditing()) {
- setEditing(true);
- setEditItemValue(this.editItem, this.staticItem.getValue());
- markForRedraw();
- }
- }
-
- protected boolean isEditing() {
- return this.editing;
- }
-
- /**
- * This just sets the internal flag indicating if the form is in editing mode.
- * To switch modes, you use {@link #switchToEditMode()} and {@link #switchToStaticMode()}.
- *
- * @param editing the new editing flag
- */
- protected void setEditing(boolean editing) {
- this.editing = editing;
- }
-
- /**
- * When the user has accepted a new edited value for this form item, this method is called.
- * This method is responsible for invoking the {@link #getValueEditedHandler() handler}.
- *
- * @param newValue the new value just accepted by the user and validated by the system
- */
- protected void setApprovedNewValue(Object newValue) {
- setStaticItemValue(this.staticItem, newValue);
- if (this.valueEditedHandler != null) {
- this.valueEditedHandler.editedValue(newValue);
- }
- }
-
- /**
- * When a user first elects to edit a value (i.e. switches from static, read-only mode
- * to edit mode), the static value needs to be converted to an object that is appropriate
- * for the edit form item value. This method performs that necessary conversion and
- * sets the edit item's value to that converted value. The converted value is also returned.
- *
- * @param editItem the edit form item whose value needs to be set
- * @param value the static value that needs to be converted and set in the given edit item
- *
- * @return the converted value that was set in the edit item
- */
- protected Object setEditItemValue(FormItem editItem, Object value) {
- String convertedValue = (value != null) ? value.toString() : null;
- editItem.setValue(convertedValue);
- return convertedValue;
- }
-
- /**
- * When a user enters and accepts a new value, the new value needs to be converted
- * to an appropriate value for display in the static, read-only item.
- * This method performs that necessary conversion and sets the static item's value
- * to that converted value. The converted value is also returned.
- *
- * @param staticItem the static form item whose value needs to be set
- * @param value the value that needs to be converted for display in the static item
- *
- * @return the converted value that was set in the static item
- */
- protected Object setStaticItemValue(FormItem staticItem, Object value) {
- String convertedValue = (value != null) ? value.toString() : null;
- staticItem.setValue(convertedValue);
- return convertedValue;
- }
-
- //
- // Below are delegating methods to setValue().
- // When setting this form item's value, we are really setting the static item's value.
- //
-
- @Override
- public void setValue(boolean value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public void setValue(Date value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public void setValue(double value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public void setValue(float value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public void setValue(int value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public void setValue(Object value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public void setValue(String value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public Object getValue() {
- return this.staticItem.getValue();
- }
-
- //
- // this delegates to the edit item allowing custom validators to be added
- //
-
- @Override
- public void setValidators(Validator... validators) {
- this.editItem.setValidators(validators);
- }
-
- /**
- * If the user is not allowed to edit this form item, <code>true</code> is returned.
- * @return flag to indicate if the user is allowed to change the value or not
- */
- public boolean isReadOnly() {
- return readOnly;
- }
-
- public void setReadOnly(boolean readOnly) {
- this.readOnly = readOnly;
- this.staticItem.setTextBoxStyle((!readOnly) ? "editableText" : null);
- markForRedraw();
- }
-
- /**
- * Returns the handler that will be called when a user edits the current value.
- * This is only called after the user accepts the new value and it passes validation.
- *
- * @return the callback handler that is invoked when the old value is edited resulting in a new value
- */
- public ValueEditedHandler getValueEditedHandler() {
- return this.valueEditedHandler;
- }
-
- public void setValueEditedHandler(ValueEditedHandler handler) {
- this.valueEditedHandler = handler;
- }
-
- /**
- * Marks the canvas item for redraw, which enables both the static and edit items to redraw themselves.
- */
- private void markForRedraw() {
- getForm().markForRedraw();
- this.innerForm.markForRedraw();
- }
-
- /**
- * When a user has changed the value of the editable field item, this
- * is the type of callback that is called to be informed of the change.
- */
- 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/components/form/EnhancedDynamicForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java
index 02c2752..586642a 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
@@ -116,10 +116,11 @@ public class EnhancedDynamicForm extends LocatableDynamicForm {
Boolean showTitle = (item.getShowTitle() != null) ? item.getShowTitle() : true;
staticItem.setShowTitle(showTitle);
staticItem.setTooltip(item.getTooltip());
- staticItem.setValue(item.getDisplayValue());
+ String displayValue = item.getDisplayValue();
+ staticItem.setValue(displayValue);
staticItem.setColSpan(item.getAttribute("colSpan"));
Boolean outputAsHtml = item.getAttributeAsBoolean(OUTPUT_AS_HTML_ATTRIBUTE);
- if (Boolean.TRUE.equals(outputAsHtml)) {
+ if (Boolean.TRUE.equals(outputAsHtml) && null != displayValue && !displayValue.isEmpty()) {
staticItem.setOutputAsHTML(true);
}
// TODO: Any other fields we should copy? icons?
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableFormItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableFormItem.java
new file mode 100644
index 0000000..6bb9933
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableFormItem.java
@@ -0,0 +1,345 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.components.form;
+
+import java.util.Date;
+
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.FormItemIfFunction;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
+import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
+import com.smartgwt.client.widgets.form.validator.Validator;
+
+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.LocatableDynamicForm;
+
+/**
+ * This form item can be used to display a value normally in "read-only" form (i.e. as a StaticTextItem),
+ * 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.
+ *
+ * @author John Mazzitelli
+ */
+public class SimpleEditableFormItem extends CanvasItem {
+
+ protected static Messages MSG = CoreGUI.getMessages();
+
+ protected FormItem staticItem;
+ protected FormItem editItem;
+ protected DynamicForm innerForm;
+
+ private boolean readOnly = false;
+ private boolean editing = false;
+
+ private ValueEditedHandler valueEditedHandler;
+
+ public SimpleEditableFormItem() {
+ this(null, null, null);
+ }
+
+ public SimpleEditableFormItem(String name, String title) {
+ this(name, title, null);
+ }
+
+ public SimpleEditableFormItem(String name, String title, ValueEditedHandler handler) {
+ if (name != null) {
+ setName(name);
+ }
+ if (title != null) {
+ setTitle(title);
+ }
+ if (handler != null) {
+ setValueEditedHandler(handler);
+ }
+
+ this.innerForm = new LocatableDynamicForm(getName() + "_innerForm");
+ this.staticItem = prepareStaticFormItem();
+ this.editItem = prepareEditFormItem();
+ this.innerForm.setCanFocus(true);
+ this.innerForm.setNumCols(1);
+
+ addHandlers();
+
+ this.innerForm.setItems(staticItem, editItem);
+ setCanvas(this.innerForm);
+ setCanFocus(true);
+ }
+
+ protected void addHandlers() {
+
+ this.editItem.addBlurHandler(new BlurHandler() {
+ public void onBlur(BlurEvent event) {
+ if (SimpleEditableFormItem.this.innerForm.validate(false)) {
+ Object newValue = event.getItem().getValue();
+ setApprovedNewValue(newValue);
+ }
+ }
+ });
+ }
+
+ protected FormItem prepareStaticFormItem() {
+ FormItem item = instantiateStaticFormItem();
+ item.setShowTitle(false);
+ item.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem item, Object value, DynamicForm form) {
+ return !isEditing();
+ }
+ });
+
+ return item;
+ }
+
+ protected FormItem prepareEditFormItem() {
+ FormItem item = instantiateEditFormItem();
+ item.setShowTitle(false);
+ item.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem item, Object value, DynamicForm form) {
+ return isEditing();
+ }
+ });
+
+ return item;
+ }
+
+ /**
+ * This instantiates the static item. The form item created by this method will
+ * be further customized by {@link #prepareStaticFormItem()}.
+ *
+ * @return the form item used to show the static (read-only) value
+ */
+ protected FormItem instantiateStaticFormItem() {
+ StaticTextItem item = new StaticTextItem();
+ return item;
+ }
+
+ /**
+ * This instantiates the edit item. The form item created by this method will
+ * be further customized by {@link #prepareEditFormItem()}.
+ *
+ * Subclasses will usually override this method to provide a different form
+ * item such as a checkbox, radio buttons, etc.
+ *
+ * @return the form item used to edit the value
+ */
+ protected FormItem instantiateEditFormItem() {
+ TextItem item = new TextItem();
+ return item;
+ }
+
+ /**
+ * This sets the {@link #setEditing(boolean) edit flag} to false and ensures
+ * the component switches to the static, read-only mode.
+ */
+ public void switchToStaticMode() {
+ if (isEditing()) {
+ setEditing(false);
+ markForRedraw();
+ }
+ }
+
+ /**
+ * This sets the {@link #setEditing(boolean) edit flag} to true and ensures
+ * the component switches to the edit, read-write mode.
+ */
+ public void switchToEditMode() {
+ if (!isEditing()) {
+ setEditing(true);
+ setEditItemValue(this.editItem, this.staticItem.getValue());
+ markForRedraw();
+ }
+ }
+
+ public boolean isEditing() {
+ return this.editing;
+ }
+
+ /**
+ * This just sets the internal flag indicating if the form is in editing mode.
+ * To switch modes, you use {@link #switchToEditMode()} and {@link #switchToStaticMode()}.
+ *
+ * @param editing the new editing flag
+ */
+ protected void setEditing(boolean editing) {
+ this.editing = editing;
+ }
+
+ /**
+ * When the user has accepted a new edited value for this form item, this method is called.
+ * This method is responsible for invoking the {@link #getValueEditedHandler() handler}.
+ *
+ * @param newValue the new value just accepted by the user and validated by the system
+ */
+ protected void setApprovedNewValue(Object newValue) {
+ setStaticItemValue(this.staticItem, newValue);
+ if (this.valueEditedHandler != null) {
+ this.valueEditedHandler.editedValue(newValue);
+ }
+ }
+
+ /**
+ * When a user first elects to edit a value (i.e. switches from static, read-only mode
+ * to edit mode), the static value needs to be converted to an object that is appropriate
+ * for the edit form item value. This method performs that necessary conversion and
+ * sets the edit item's value to that converted value. The converted value is also returned.
+ *
+ * @param editItem the edit form item whose value needs to be set
+ * @param value the static value that needs to be converted and set in the given edit item
+ *
+ * @return the converted value that was set in the edit item
+ */
+ protected Object setEditItemValue(FormItem editItem, Object value) {
+ String convertedValue = (value != null) ? value.toString() : null;
+ editItem.setValue(convertedValue);
+ return convertedValue;
+ }
+
+ /**
+ * When a user enters and accepts a new value, the new value needs to be converted
+ * to an appropriate value for display in the static, read-only item.
+ * This method performs that necessary conversion and sets the static item's value
+ * to that converted value. The converted value is also returned.
+ *
+ * @param staticItem the static form item whose value needs to be set
+ * @param value the value that needs to be converted for display in the static item
+ *
+ * @return the converted value that was set in the static item
+ */
+ protected Object setStaticItemValue(FormItem staticItem, Object value) {
+ String convertedValue = (value != null) ? value.toString() : null;
+ staticItem.setValue(convertedValue);
+ return convertedValue;
+ }
+
+ //
+ // Below are delegating methods to setValue().
+ // When setting this form item's value, we are really setting the static item's value.
+ //
+
+ @Override
+ public void setValue(boolean value) {
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public void setValue(Date value) {
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public void setValue(double value) {
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public void setValue(float value) {
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public void setValue(int value) {
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public void setValue(Object value) {
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public void setValue(String value) {
+ if (this.staticItem instanceof StaticTextItem) {
+ ((StaticTextItem) this.staticItem).setOutputAsHTML(!(null == value || value.isEmpty()));
+ }
+
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public Object getValue() {
+ return this.staticItem.getValue();
+ }
+
+ // this delegates to the edit item allowing custom validators to be added
+ @Override
+ public void setValidators(Validator... validators) {
+ this.editItem.setValidators(validators);
+ }
+
+ // direct outer-form validation to the edit item, which would have any set validators
+ @Override
+ public Boolean validate() {
+ return !editing || editItem.validate();
+ }
+
+ /**
+ * If the user is not allowed to edit this form item, <code>true</code> is returned.
+ * @return flag to indicate if the user is allowed to change the value or not
+ */
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ public void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ this.staticItem.setTextBoxStyle((!readOnly) ? "editableText" : null);
+ markForRedraw();
+ }
+
+ /**
+ * Returns the handler that will be called when a user edits the current value.
+ * This is only called after the user accepts the new value and it passes validation.
+ *
+ * @return the callback handler that is invoked when the old value is edited resulting in a new value
+ */
+ public ValueEditedHandler getValueEditedHandler() {
+ return this.valueEditedHandler;
+ }
+
+ public void setValueEditedHandler(ValueEditedHandler handler) {
+ this.valueEditedHandler = handler;
+ }
+
+ /**
+ * Marks the canvas item for redraw, which enables both the static and edit items to redraw themselves.
+ */
+ protected void markForRedraw() {
+ getForm().markForRedraw();
+ this.innerForm.markForRedraw();
+ }
+
+ /**
+ * When a user has changed the value of the editable field item, this
+ * is the type of callback that is called to be informed of the change.
+ */
+ 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/components/form/SimpleEditableTextAreaFormItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableTextAreaFormItem.java
new file mode 100644
index 0000000..556348c
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableTextAreaFormItem.java
@@ -0,0 +1,53 @@
+/*
+ * 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.form;
+
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.TextAreaItem;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class SimpleEditableTextAreaFormItem extends SimpleEditableFormItem {
+
+ public SimpleEditableTextAreaFormItem() {
+ super();
+ }
+
+ public SimpleEditableTextAreaFormItem(String name, String title) {
+ super(name, title);
+ }
+
+ public SimpleEditableTextAreaFormItem(String name, String title, boolean required) {
+ super(name, title);
+ }
+
+ public SimpleEditableTextAreaFormItem(String name, String title, ValueEditedHandler handler) {
+ super(name, title, handler);
+ }
+
+ @Override
+ protected FormItem instantiateEditFormItem() {
+
+ TextAreaItem item = new TextAreaItem();
+ return item;
+ }
+
+}
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 0cb1411..9a7c87e 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
@@ -277,9 +277,13 @@ public abstract class AbstractOperationScheduleDetailsView extends
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));
+ // Notes field is user-editable, so escape HTML to prevent an XSS attack. Unless empty, then don't to prevent
+ // displaying as the value.
+ String notesValue = getForm().getValue(AbstractOperationScheduleDataSource.Field.DESCRIPTION).toString();
+ if (null != notesValue && !notesValue.isEmpty()) {
+ notesItem.setOutputAsHTML(true);
+ }
+ notesItem.setValue(notesValue);
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/groups/detail/GeneralProperties.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
index 9d8eb61..045c1ef 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
@@ -38,7 +38,7 @@ import org.rhq.enterprise.gui.coregui.client.components.form.CheckboxEditableFor
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.components.form.SimpleEditableFormItem.ValueEditedHandler;
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;
@@ -199,10 +199,11 @@ public class GeneralProperties extends LocatableVLayout {
FormItem recursiveItem;
if (isEditable) {
- CheckboxEditableFormItem editableRecursiveItem = new CheckboxEditableFormItem("recursive", MSG.view_group_summary_recursive());
+ 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);
+ boolean isRecursive = ((newValue != null) && (Boolean) newValue);
resourceGroupService.setRecursive(group.getId(), isRecursive, new AsyncCallback<Void>() {
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
@@ -241,8 +242,7 @@ public class GeneralProperties extends LocatableVLayout {
GroupDefinition groupDefinition = group.getGroupDefinition();
String groupDefinitionUrl = LinkManager.getGroupDefinitionLink(groupDefinition.getId());
String groupDefinitionName = StringUtility.escapeHtml(groupDefinition.getName());
- groupDefinitionItem
- .setValue("<a href=\"" + groupDefinitionUrl + "\">" + groupDefinitionName + "</a>");
+ groupDefinitionItem.setValue("<a href=\"" + groupDefinitionUrl + "\">" + groupDefinitionName + "</a>");
formItems.add(groupDefinitionItem);
}
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 4b85d4f..31b7c95 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
@@ -41,7 +41,7 @@ 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.components.form.SimpleEditableFormItem.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;
@@ -280,7 +280,7 @@ public class OverviewForm extends EnhancedDynamicForm {
// Version
StaticTextItem versionItem = new StaticTextItem("version", MSG.view_summaryOverviewForm_field_version());
String version = (resource.getVersion() != null) ? resource.getVersion() : "<i>" + MSG.common_label_none()
- + "</i>";
+ + "</i>";
versionItem.setValue(version);
versionItem.setEndRow(true);
formItems.add(versionItem);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
index c633ed5..1cd2a71 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
@@ -61,6 +61,7 @@ import org.rhq.enterprise.server.plugin.pc.alert.AlertSender;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
+import org.rhq.enterprise.server.util.CriteriaQueryGenerator.AuthorizationTokenType;
/**
* @author Joseph Marques
@@ -484,7 +485,8 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
* is not currently deleted
*/
boolean isResourceLevel = (oldAlertDefinition.getResource() != null);
- checkAlertDefinition(subject, alertDefinition, isResourceLevel ? oldAlertDefinition.getResource().getId() : null);
+ checkAlertDefinition(subject, alertDefinition, isResourceLevel ? oldAlertDefinition.getResource().getId()
+ : null);
/*
* Should not be able to update an alert definition if the old alert definition is in an invalid state
@@ -600,7 +602,7 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
private void checkAlertDefinition(Subject subject, AlertDefinition alertDefinition, Integer resourceId)
throws InvalidAlertDefinitionException {
// if someone enters a really long description, we need to truncate it - the column is only 250 chars
- if (alertDefinition.getDescription()!=null && alertDefinition.getDescription().length() > 250) {
+ if (alertDefinition.getDescription() != null && alertDefinition.getDescription().length() > 250) {
alertDefinition.setDescription(alertDefinition.getDescription().substring(0, 250));
}
@@ -712,9 +714,15 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
@SuppressWarnings("unchecked")
public PageList<AlertDefinition> findAlertDefinitionsByCriteria(Subject subject, AlertDefinitionCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- if (authorizationManager.isInventoryManager(subject) == false) {
- generator.setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType.RESOURCE, subject
- .getId());
+
+ // Inv managers can do anything and anyone can inspect templates
+ if (!authorizationManager.isInventoryManager(subject) && !criteria.isTemplateCriteria()) {
+
+ // otherwise, for group alert defs ensure group view authz and for everything else, assume resource view authz
+ AuthorizationTokenType tokenType = criteria.isGroupCriteria() ? AuthorizationTokenType.GROUP
+ : AuthorizationTokenType.RESOURCE;
+
+ generator.setAuthorizationResourceFragment(tokenType, subject.getId());
}
CriteriaQueryRunner<AlertDefinition> queryRunner = new CriteriaQueryRunner(criteria, generator, entityManager);
commit 005aa08988d1ca721b6b2ce50ceb0c6cb8c3713c
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Apr 12 11:08:33 2011 -0400
fix config editor bug causing boolean props w/ null values to be rendered as false rather than unset; use setValue(), rather than setDefaultValue(), when initializing FormItems for simple props in config editor; add ctrl-alt-t hot key for going to #Test view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index 0aa06c8..17b9a00 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -149,6 +149,16 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
});
+ KeyIdentifier testTopViewKey = new KeyIdentifier();
+ testTopViewKey.setCtrlKey(true);
+ testTopViewKey.setAltKey(true);
+ testTopViewKey.setKeyName("t");
+ Page.registerKey(testTopViewKey, new KeyCallback() {
+ public void execute(String keyName) {
+ goToView("Test");
+ }
+ });
+
GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
public void onUncaughtException(Throwable e) {
getErrorHandler().handleError(MSG.view_core_uncaught(), e);
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 2a83fbd..01f813f 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
@@ -82,6 +82,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
public void onPermissionsLoaded(Set<Permission> globalPermissions) {
TemplateAlertDefinitionsView.this.globalPermissions = globalPermissions;
+ refreshTableInfo();
}
});
}
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 b7f1adf..5ff37bb 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
@@ -146,6 +146,13 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
//
public class ConfigurationEditor extends LocatableVLayout {
+ private static final LinkedHashMap<String, String> BOOLEAN_PROPERTY_ITEM_VALUE_MAP =
+ new LinkedHashMap<String, String>();
+ static {
+ BOOLEAN_PROPERTY_ITEM_VALUE_MAP.put(Boolean.TRUE.toString(), MSG.common_val_yes());
+ BOOLEAN_PROPERTY_ITEM_VALUE_MAP.put(Boolean.FALSE.toString(), MSG.common_val_no());
+ }
+
private ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
private LocatableToolStrip toolStrip;
@@ -1296,11 +1303,8 @@ public class ConfigurationEditor extends LocatableVLayout {
case BOOLEAN:
RadioGroupItem radioGroupItem = new RadioGroupItem();
radioGroupItem.setVertical(false);
+ radioGroupItem.setValueMap(BOOLEAN_PROPERTY_ITEM_VALUE_MAP);
valueItem = radioGroupItem;
- LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
- valueMap.put("true", MSG.common_val_yes());
- valueMap.put("false", MSG.common_val_no());
- valueItem.setValueMap(valueMap);
break;
case INTEGER:
case LONG:
@@ -1344,9 +1348,7 @@ public class ConfigurationEditor extends LocatableVLayout {
// 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(value);
+ valueItem.setValue(value);
valueItem.setRequired(propertyDefinitionSimple.isRequired());
valueItem.setWidth(220);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
index b689133..3f784b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -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.inventory.resource;
import com.smartgwt.client.widgets.grid.ListGridField;
@@ -37,6 +36,8 @@ public enum ResourceDataSourceField {
PLUGIN("pluginName", CoreGUI.getMessages().common_title_plugin()),
+ VERSION("version", CoreGUI.getMessages().common_title_version()),
+
CATEGORY("resourceType.category", CoreGUI.getMessages().common_title_category()),
AVAILABILITY("currentAvailability", CoreGUI.getMessages().common_title_availability());
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 b53a127..6e639c5 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
@@ -24,6 +24,7 @@ import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceD
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.VERSION;
import java.util.ArrayList;
import java.util.Collection;
@@ -48,6 +49,7 @@ 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.EscapedHtmlCellFormatter;
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;
@@ -160,11 +162,15 @@ public class ResourceSearchView extends Table {
ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
ListGridField descriptionField = new ListGridField(DESCRIPTION.propertyName(), DESCRIPTION.title());
+ descriptionField.setCellFormatter(new EscapedHtmlCellFormatter());
ListGridField typeNameField = new ListGridField(TYPE.propertyName(), TYPE.title(), 130);
ListGridField pluginNameField = new ListGridField(PLUGIN.propertyName(), PLUGIN.title(), 100);
+ ListGridField versionField = new ListGridField(VERSION.propertyName(), VERSION.title(), 60);
+ versionField.setHidden(true);
+
ListGridField categoryField = new ListGridField(CATEGORY.propertyName(), CATEGORY.title(), 60);
categoryField.setCellFormatter(new ResourceCategoryCellFormatter());
categoryField.setHidden(true); // the icon field already shows us this, no need to show it in another column
@@ -172,7 +178,7 @@ public class ResourceSearchView extends Table {
IconField availabilityField = new IconField(AVAILABILITY.propertyName(), AVAILABILITY.title(), 70);
setListGridFields(iconField, nameField, ancestryField, descriptionField, typeNameField, pluginNameField,
- categoryField, availabilityField);
+ versionField, categoryField, availabilityField);
addTableAction(extendLocatorId("Uninventory"), MSG.common_button_uninventory(), MSG
.view_inventory_resources_uninventoryConfirm(), new ResourceAuthorizedTableAction(ResourceSearchView.this,
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
index a080f13..b736151 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright 2010, 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.
*
@@ -78,7 +78,6 @@ public abstract class TestConfigurationFactory {
simplePropDef = createBooleanPropDef();
addPropertyDefinition(configDef, simplePropDef, orderIndex++);
- simplePropDef.setRequired(true);
simplePropDef = createIntegerPropDef();
addPropertyDefinition(configDef, simplePropDef, orderIndex++);
@@ -294,7 +293,7 @@ public abstract class TestConfigurationFactory {
private static PropertyDefinitionSimple createStringPropDef1() {
PropertyDefinitionSimple stringPropDef1;
stringPropDef1 = new PropertyDefinitionSimple("String1",
- "an optional String simple prop", false, PropertySimpleType.STRING);
+ "a String simple prop", false, PropertySimpleType.STRING);
stringPropDef1.setDisplayName(stringPropDef1.getName());
return stringPropDef1;
}
@@ -302,7 +301,7 @@ public abstract class TestConfigurationFactory {
private static PropertyDefinitionSimple createStringPropDef2() {
PropertyDefinitionSimple stringPropDef2;
stringPropDef2 = new PropertyDefinitionSimple("String2",
- "a read-only String simple prop", false, PropertySimpleType.STRING);
+ "a read-only required String simple prop", true, PropertySimpleType.STRING);
stringPropDef2.setDisplayName(stringPropDef2.getName());
stringPropDef2.setReadOnly(true);
return stringPropDef2;
@@ -311,7 +310,7 @@ public abstract class TestConfigurationFactory {
private static PropertyDefinitionSimple createBooleanPropDef() {
PropertyDefinitionSimple propDef;
propDef = new PropertyDefinitionSimple("Boolean",
- "a Boolean simple prop", false, PropertySimpleType.BOOLEAN);
+ "a summary Boolean simple prop", false, PropertySimpleType.BOOLEAN);
propDef.setDisplayName(propDef.getName());
propDef.setSummary(true);
return propDef;
@@ -320,7 +319,7 @@ public abstract class TestConfigurationFactory {
private static PropertyDefinitionSimple createIntegerPropDef() {
PropertyDefinitionSimple integerPropDef;
integerPropDef = new PropertyDefinitionSimple("Integer",
- "a required summary Integer simple prop", true, PropertySimpleType.INTEGER);
+ "a summary Integer simple prop", false, PropertySimpleType.INTEGER);
integerPropDef.setDisplayName(integerPropDef.getName());
integerPropDef.setSummary(true);
return integerPropDef;
commit 50f58a4f68ad08fb564201a35378bbcda54b969a
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Apr 12 09:02:34 2011 -0400
Locator id fixes i)Auto refresh locator was too restrictive as included parent ids like 10071
ii)Portlet config settings locator still mentioned alert when it's not generic.
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 f087202..8deac66 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
@@ -393,7 +393,7 @@ public class DashboardView extends LocatableVLayout {
});
//refresh interval
- LocatableMenu refreshMenu = new LocatableMenu(editForm.extendLocatorId("AutoRefreshMenu"));
+ LocatableMenu refreshMenu = new LocatableMenu("AutoRefreshMenu");
refreshMenu.setShowShadow(true);
refreshMenu.setShadowDepth(10);
refreshMenu.setAutoWidth();
@@ -440,8 +440,8 @@ public class DashboardView extends LocatableVLayout {
}
refreshMenu.setItems(refreshMenuItems);
- refreshMenuButton = new LocatableIMenuButton(editForm.extendLocatorId("AutoRefreshButton"), MSG
- .common_title_change_refresh_time(), refreshMenu);
+ refreshMenuButton = new LocatableIMenuButton("AutoRefreshButton", MSG.common_title_change_refresh_time(),
+ refreshMenu);
refreshMenu.setAutoHeight();
refreshMenuButton.getMenu().setItems(refreshMenuItems);
refreshMenuButton.setWidth(140);
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 b7488da..06c8a05 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
@@ -214,7 +214,7 @@ public class PortletConfigurationEditorComponent {
* @return
*/
public static CustomConfigMeasurementRangeEditor getMeasurementRangeEditor(Configuration portletConfig) {
- return new CustomConfigMeasurementRangeEditor("alertTimeFrame", portletConfig);
+ return new CustomConfigMeasurementRangeEditor("timeFrame", portletConfig);
}
public static SelectItem getOperationStatusEditor(Configuration portletConfig) {
commit 6ec59cf1710699a29022e5bec34ccdad4b2b5ac6
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Apr 8 13:04:20 2011 -0400
fix locator issue with Group/Res events portlets.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
index d054102..731ac31 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
@@ -32,7 +32,6 @@ 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.StaticTextItem;
-import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -249,7 +248,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
}
}
//build display
- VLayout column = new VLayout();
+ LocatableVLayout column = new LocatableVLayout(recentEventsContent.extendLocatorId("canvas"));
column.setHeight(10);
if (!results.isEmpty()) {
@@ -258,7 +257,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
// event history records do not have a usable locatorId, we'll use rownum, which is unique and
// may be repeatable.
LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent
- .extendLocatorId(String.valueOf(rowNum)));
+ .extendLocatorId(String.valueOf(rowNum++)));
row.setNumCols(2);
row.setWidth(10);//pack.
@@ -274,7 +273,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
column.markForRedraw();
//insert see more link
LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent.extendLocatorId(String
- .valueOf(rowNum)));
+ .valueOf(rowNum++)));
AbstractActivityView.addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId
+ "/Events/History/", column);
} else {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
index f382ea7..dfde6d9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
@@ -27,7 +27,6 @@ import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.event.EventSeverity;
@@ -42,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecor
import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
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;
/**This portlet allows the end user to customize the Events display
*
@@ -133,7 +133,7 @@ public class ResourceEventsPortlet extends GroupEventsPortlet {
}
}
//build display
- VLayout column = new VLayout();
+ LocatableVLayout column = new LocatableVLayout(recentEventsContent.extendLocatorId("canvas"));
column.setHeight(10);
if (!results.isEmpty()) {
@@ -142,7 +142,7 @@ public class ResourceEventsPortlet extends GroupEventsPortlet {
// event history records do not have a usable locatorId, we'll use rownum, which is unique and
// may be repeatable.
LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent
- .extendLocatorId(String.valueOf(rowNum)));
+ .extendLocatorId(String.valueOf(rowNum++)));
row.setNumCols(2);
row.setWidth(10);//pack.
@@ -157,7 +157,7 @@ public class ResourceEventsPortlet extends GroupEventsPortlet {
}
//insert see more link
LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent.extendLocatorId(String
- .valueOf(rowNum)));
+ .valueOf(rowNum++)));
AbstractActivityView.addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId
+ "/Events/History/", column);
} else {
commit 90254fb1bd8ca5d491b6107670f39adc67558caa
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 11 13:19:40 2011 -0400
fix typo in dependsOnGroup name
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java
index 75ed400..c539a44 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java
@@ -18,6 +18,29 @@
*/
package org.rhq.enterprise.server.core.plugin;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import javax.transaction.TransactionManager;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
import org.rhq.core.domain.plugin.Plugin;
@@ -27,23 +50,10 @@ import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.resource.metadata.PluginManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
-import org.testng.annotations.*;
-
-import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import javax.transaction.TransactionManager;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.util.*;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
//make sure we run this after the plugins.metadata tests are done so that
//the db contents don't interfere
-@Test(dependsOnGroups = "plugins.metadata")
+@Test(dependsOnGroups = "plugin.metadata")
public class DatabaseAndFilePluginDeploymentTest extends AbstractEJB3Test {
private static final String PLUGIN_NAME = "DeployTest"; // as defined in our test descriptors
@@ -493,8 +503,7 @@ public class DatabaseAndFilePluginDeploymentTest extends AbstractEJB3Test {
pluginDup.setVersion(plugin.getVersion());
PluginDescriptor pluginDescriptor = this.testPluginDescriptors.get(pluginId);
File localPluginFile = this.testPluginFiles.get(pluginId);
- pluginMgr.registerPlugin(subjectManager.getOverlord(), pluginDup, pluginDescriptor, localPluginFile,
- false);
+ pluginMgr.registerPlugin(subjectManager.getOverlord(), pluginDup, pluginDescriptor, localPluginFile, false);
}
return;
}
commit f969d77b1fde23911c544fff01768048cc76c02c
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Apr 11 11:17:34 2011 -0400
[BZ 690430] Removing plugin config for disabling cert validation
Removing the plugin configuration property that disables SSL cert
validation for the URL used in availability checks. Cert validation is
automatically disabled if the URL is HTTPS.
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 053be8a..a9e3949 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
@@ -231,12 +231,10 @@ 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, disableCertValidation.getBooleanValue());
+ available = WWWUtils.isAvailable(this.url);
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 898a9b3..b43e156 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,9 +130,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
}
public AvailabilityType getAvailability() {
- Configuration pluginConfig = resourceContext.getPluginConfiguration();
- PropertySimple disableCertValidation = pluginConfig.getSimple("disableCertificateValidation");
- return (this.url != null && WWWUtils.isAvailable(this.url, disableCertValidation.getBooleanValue())) ? AvailabilityType.UP : AvailabilityType.DOWN;
+ return (this.url != null && WWWUtils.isAvailable(this.url)) ? 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 2b226be..5afb34a 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
@@ -49,14 +49,14 @@ public abstract class WWWUtils {
* @return true if connecting to the URL succeeds, or false otherwise
*/
- public static boolean isAvailable(URL httpURL, boolean disableCertValidation) {
+ public static boolean isAvailable(URL httpURL) {
String failMsg = "URL [" + httpURL + "] returned unavailable";
try {
HttpURLConnection connection = (HttpURLConnection) httpURL.openConnection();
connection.setRequestMethod("HEAD");
connection.setConnectTimeout(3000);
- if ((connection instanceof HttpsURLConnection) && disableCertValidation) {
+ if (connection instanceof HttpsURLConnection) {
disableCertificateVerification((HttpsURLConnection) connection);
}
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 674b2fb..f6ab6eb 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
@@ -273,21 +273,16 @@
<c:simple-property name="configFile" required="true" readOnly="true"
description="the path to the httpd.conf file - if the path is not absolute, it will be resolved relative to the server root directory; if unset, default will be 'conf/httpd.conf' on UNIX"/>
<c:simple-property name="url" displayName="URL" required="false"
- description="the http or https URL that will be used to check availability for this Apache server; if not set, availablity will be determined based on whether plugin can connect to the Apache server's SNMP agent"/>
+ description="The http or https URL that will be used to check availability for this Apache
+ server; if not set, availablity will be determined based on whether plugin can connect
+ to the Apache server's SNMP agent. Note that SSL certificate validation is disabled
+ during availability checks if this is an HTTPS URL."/>
<c:simple-property name="snmpAgentHost" displayName="SNMP Agent Host" default="127.0.0.1"
description="the host name or IP address of the Apache SNMP agent (typically '127.0.0.1')"/>
<c:simple-property name="snmpAgentPort" displayName="SNMP Agent Port" type="integer" default="1610"
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>
@@ -500,15 +495,9 @@
<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."/>
+ description="The http or https URL that will be used to check availability for this
+ virtual host. Note that SSL certificate validation is disabled during availability
+ checks if this is an HTTPS URL."/>
<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"/>
commit 335e422d64018f4bee42f163e9dc6bc54f9d433f
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Apr 8 17:14:27 2011 -0400
since the two action buttons for create/import children are at the botto fo the screen, popup the context menu above the buttons, not below, to avoid them getting clipped
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index b22a79a..eb4d04a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -437,12 +437,12 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
menu.addItem(item);
}
- IMenuButton menuButton = new LocatableIMenuButton(tableAction.getLocatorId(), tableAction.getTitle(),
- menu);
+ IMenuButton menuButton = new LocatableIMenuButton(tableAction.getLocatorId(), tableAction.getTitle());
+ menuButton.setMenu(menu);
menuButton.setDisabled(true);
- // this makes it pretty tight, but maybe better than the default, which is pretty wide
- menuButton.setAutoFit(true);
+ menuButton.setAutoFit(true); // this makes it pretty tight, but maybe better than the default, which is pretty wide
menuButton.setOverflow(Overflow.VISIBLE);
+ menuButton.setShowMenuBelow(false);
tableAction.actionCanvas = menuButton;
footer.addMember(menuButton);
@@ -757,7 +757,7 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
unqualifiedLocatorId = locatorId;
}
TableActionInfo info = new TableActionInfo(this.footer.extendLocatorId(unqualifiedLocatorId), title,
- confirmation, valueMap, tableAction);
+ confirmation, valueMap, tableAction);
tableActions.add(info);
}
commit d501f6a28cfa4b74edbd320a398c77af5076d5a2
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Apr 8 17:13:35 2011 -0400
BZ 680312 - do not null out parent resource in the delete history item so the child history ui can see what was deleted
also has a separate fix - code to support creating resource that doesn't have resource config.
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 6ddfa87..c7c1fdb 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
@@ -186,7 +186,7 @@ public class ResourceFactoryManagerBean implements ResourceFactoryManagerLocal,
// set the resource deleted and update the db in case it matters to the child operations
resource.setInventoryStatus(InventoryStatus.DELETED);
- resource.setParentResource(null);
+ //resource.setParentResource(null); can't null this out since the query DeleteResourceHistory.QUERY_FIND_BY_PARENT_RESOURCE_ID needs it
resource.setItime(System.currentTimeMillis());
entityManager.merge(resource);
@@ -262,7 +262,7 @@ public class ResourceFactoryManagerBean implements ResourceFactoryManagerLocal,
ResourceType resourceType = entityManager.getReference(ResourceType.class, resourceTypeId);
// CreateResourceHistory.configuration is one-to-one, so make sure to clone the config, zeroing out all id's.
- Configuration configurationClone = configuration.deepCopy(false);
+ Configuration configurationClone = (configuration != null) ? configuration.deepCopy(false) : null;
// Persist and establish relationships
CreateResourceHistory history = new CreateResourceHistory(parentResource, resourceType, user.getName(),
commit a69cd5dda87fc06b56fc625b43bcc23cf231b281
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Apr 8 17:12:18 2011 -0400
support creating child resources that do not have resource config definition
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/AbstractResourceFactoryWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/AbstractResourceFactoryWizard.java
index a78a4ef..cc2f7c4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/AbstractResourceFactoryWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/AbstractResourceFactoryWizard.java
@@ -102,8 +102,10 @@ public abstract class AbstractResourceFactoryWizard extends AbstractWizard {
if (null == this.newResourceConfigurationDefinition
|| !this.newResourceConfigurationDefinition.equals(newResourceConfigurationDefinition)) {
this.newResourceConfigurationDefinition = newResourceConfigurationDefinition;
- this.newResourceStartingConfiguration = this.newResourceConfigurationDefinition.getDefaultTemplate()
- .createConfiguration();
+ if (newResourceConfigurationDefinition != null) {
+ this.newResourceStartingConfiguration = this.newResourceConfigurationDefinition.getDefaultTemplate()
+ .createConfiguration();
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java
index efa297c..a21a78a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java
@@ -22,9 +22,11 @@ import com.smartgwt.client.widgets.Canvas;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Jay Shaughnessy
@@ -32,6 +34,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
*/
public class ResourceFactoryConfigurationStep extends AbstractWizardStep {
+ private boolean noConfigurationNeeded = false; // if true, it has been determined the user doesn't have to set any config
private ConfigurationEditor editor;
AbstractResourceFactoryWizard wizard;
@@ -43,20 +46,33 @@ public class ResourceFactoryConfigurationStep extends AbstractWizardStep {
if (editor == null) {
ConfigurationDefinition def = wizard.getNewResourceConfigurationDefinition();
- Configuration startingConfig = wizard.getNewResourceStartingConfiguration();
-
- if (parent != null) {
- editor = new ConfigurationEditor(parent.extendLocatorId("ResourceFactoryConfig"), def, startingConfig);
+ if (def != null) {
+ Configuration startingConfig = wizard.getNewResourceStartingConfiguration();
+ if (parent != null) {
+ editor = new ConfigurationEditor(parent.extendLocatorId("ResourceFactoryConfig"), def,
+ startingConfig);
+ } else {
+ editor = new ConfigurationEditor("ResourceFactoryConfig", def, startingConfig);
+ }
} else {
- editor = new ConfigurationEditor("ResourceFactoryConfig", def, startingConfig);
+ // there is no configuration to edit, just return a static message indicating that there is nothing to do
+ noConfigurationNeeded = true;
+ LocatableVLayout layout = new LocatableVLayout("noConfigMsgLayout");
+ layout.setMargin(Integer.valueOf(20));
+ layout.setWidth100();
+ layout.setHeight(10);
+ HeaderLabel label = new HeaderLabel(MSG.widget_resourceFactoryWizard_editConfigStep_nothingToDo());
+ label.setWidth100();
+ layout.addMember(label);
+ return layout;
}
}
return editor;
}
public boolean nextPage() {
- if (editor.validate()) {
- wizard.setNewResourceConfiguration(editor.getConfiguration());
+ if (noConfigurationNeeded == true || (editor != null && editor.validate())) {
+ wizard.setNewResourceConfiguration((noConfigurationNeeded) ? null : editor.getConfiguration());
wizard.execute();
return true;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryCreateWizard.java
index 33982e9..81d08aa 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryCreateWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryCreateWizard.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.factory;
import java.util.ArrayList;
import java.util.EnumSet;
+import java.util.LinkedHashMap;
import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -79,7 +80,12 @@ public class ResourceFactoryCreateWizard extends AbstractResourceFactoryWizard {
ConfigurationDefinition resourceConfigDef = getChildType().getResourceConfigurationDefinition();
this.setNewResourceConfigurationDefinition(resourceConfigDef);
- Map<String, ConfigurationTemplate> templates = resourceConfigDef.getTemplates();
+ Map<String, ConfigurationTemplate> templates;
+ if (resourceConfigDef == null) {
+ templates = new LinkedHashMap<String, ConfigurationTemplate>();
+ } else {
+ templates = resourceConfigDef.getTemplates();
+ }
steps.add(new ResourceFactoryInfoStep(ResourceFactoryCreateWizard.this, MSG
.widget_resourceFactoryWizard_namePrompt(), MSG.widget_resourceFactoryWizard_configTemplatePrompt(),
templates));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryImportWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryImportWizard.java
index 8e45760..225a933 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryImportWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryImportWizard.java
@@ -25,6 +25,7 @@ import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
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.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
@@ -46,16 +47,21 @@ public class ResourceFactoryImportWizard extends AbstractResourceFactoryWizard {
public ResourceFactoryImportWizard(Resource parentResource, ResourceType childType) {
super(parentResource, childType);
- this.setNewResourceConfigurationDefinition(getChildType().getPluginConfigurationDefinition());
+
+ ConfigurationDefinition childTypePluginConfigDef = getChildType().getPluginConfigurationDefinition();
+
+ this.setNewResourceConfigurationDefinition(childTypePluginConfigDef);
ArrayList<WizardStep> steps = new ArrayList<WizardStep>();
- // skip the info step if the type has only the default template to offer for user selection.
- Map<String, ConfigurationTemplate> templates = childType.getPluginConfigurationDefinition().getTemplates();
- if (templates.size() > 1) {
- this.infoStep = new ResourceFactoryInfoStep(this, null, MSG.widget_resourceFactoryWizard_templatePrompt(),
- templates);
- steps.add(infoStep);
+ // skip the info step if the type has only the default template to offer for user selection or no plugin config
+ if (childTypePluginConfigDef != null) {
+ Map<String, ConfigurationTemplate> templates = childTypePluginConfigDef.getTemplates();
+ if (templates.size() > 1) {
+ this.infoStep = new ResourceFactoryInfoStep(this, null, MSG
+ .widget_resourceFactoryWizard_templatePrompt(), templates);
+ steps.add(infoStep);
+ }
}
configurationStep = new ResourceFactoryConfigurationStep(this);
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 36a9b95..7f028ee 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
@@ -322,6 +322,7 @@ widget_resourceFactoryWizard_uploadInProgress = The upload is in progress... Thi
widget_resourceFactoryWizard_uploadFileStepName = Upload Resource Content File
widget_resourceFactoryWizard_uploadFailure = Failed to upload file
widget_resourceFactoryWizard_editConfigStepName = Edit Configuration
+widget_resourceFactoryWizard_editConfigStep_nothingToDo = There is no configuration that you need to define for this resource.
widget_resourceFactoryWizard_infoStepName = Resource Information
widget_resourceFactoryWizard_infoStep_loadFail = Failed to get available Architectures
widget_resourceFactoryWizard_namePrompt = New Resource Name
commit 0589b9ee8488bd16132b6a1bd761880b81fec5d0
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 8 15:22:24 2011 -0400
[BZ 694892 - Non-Perm user error loading about box]
Added SystemManagerRemote call for getProductInfo. This call does not
require perms, as opposed to getServerDetails, which validly requires
MANAGE_SETTINGS and was previously used.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
index bb94c66..7127eb0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
@@ -50,7 +50,7 @@ public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements Syst
@Override
public ProductInfo getProductInfo() throws RuntimeException {
try {
- return systemManager.getServerDetails(getSessionSubject()).getProductInfo();
+ return systemManager.getProductInfo(getSessionSubject());
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
index 1d4cb36..19a454a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
@@ -576,7 +576,7 @@ public class SystemManagerBean implements SystemManagerLocal, SystemManagerRemot
return serverDetails;
}
- private ProductInfo getProductInfo(Subject subject) {
+ public ProductInfo getProductInfo(Subject subject) {
CoreServerMBean coreServer = LookupUtil.getCoreServer();
ProductInfo productInfo = coreServer.getProductInfo();
return productInfo;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerLocal.java
index 3db7b08..e023f48 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerLocal.java
@@ -24,6 +24,7 @@ import javax.ejb.Local;
import org.rhq.core.db.DatabaseType;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.ProductInfo;
import org.rhq.core.domain.common.ServerDetails;
/**
@@ -141,6 +142,8 @@ public interface SystemManagerLocal {
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ ProductInfo getProductInfo(Subject subject);
+
ServerDetails getServerDetails(Subject subject);
Properties getSystemConfiguration(Subject subject);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerRemote.java
index d1bafbc..deb6216 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerRemote.java
@@ -26,6 +26,7 @@ import javax.jws.WebParam;
import javax.jws.WebService;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.ProductInfo;
import org.rhq.core.domain.common.ServerDetails;
/**
@@ -35,7 +36,18 @@ import org.rhq.core.domain.common.ServerDetails;
@Remote
public interface SystemManagerRemote {
/**
- * Provides details (such as product version) of the server processing the request.
+ * Provides product information suitable for "About" details.
+ *
+ * @param subject user making the request
+ *
+ * @return the product info
+ */
+ @WebMethod
+ ProductInfo getProductInfo( //
+ @WebParam(name = "subject") Subject subject);
+
+ /**
+ * Provides details (such as product version) of the server processing the request. Requires MANAGE_SETTINGS.
*
* @param subject user making the request
*
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 7a161ea..5530987 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
@@ -49,6 +49,7 @@ import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.bundle.composite.BundleWithLatestVersionComposite;
import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.common.ProductInfo;
import org.rhq.core.domain.common.ServerDetails;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
@@ -1127,6 +1128,10 @@ public class WebservicesManagerBean implements WebservicesRemote {
//SYSTEMMANAGER: BEGIN ------------------------------------
+ public ProductInfo getProductInfo(Subject subject) {
+ return systemManager.getProductInfo(subject);
+ }
+
public ServerDetails getServerDetails(Subject subject) {
return systemManager.getServerDetails(subject);
}
commit 9a590b9d71a34f884c9843880278762277028eac
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 8 15:19:01 2011 -0400
[BZ 694641 - Able to perform url navigation after logout]
A user-initiated logout had various issues:
- the logged out user's last view remained on screen (potential security issue)
- the back button could be utilized to navigate to the user's past pages (potential security issue)
- subsequent login could navigate to the wrong view
- in certain situations the previous session could be refreshed (just plain bad)
Now on a user-initiated logout the entire background is greyed out to hide
previous state. The back button will maintain the LogOut view. Subsequent
logins will start at the default view.
Note that session-expirations also pop up the login box but do still
show the background view, on the assumption that the user may want to
log in again and pick up where he left off.
Also
- cleaned up some of the terminolgy around View/ViewPath/ViewId in
CoreGui, for better code clarity.
- fixed some jdoc in UserSessionManager
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index f276417..0aa06c8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -66,35 +66,32 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
*/
public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
+ public static final String CONTENT_CANVAS_ID = "BaseContent";
+
// This must come first to ensure proper I18N class loading for dev mode
private static final Messages MSG = GWT.create(Messages.class);
private static final MessageConstants MSGCONST = GWT.create(MessageConstants.class);
- private static final String DEFAULT_VIEW_PATH = DashboardsView.VIEW_ID.getName();
+ private static final String DEFAULT_VIEW = DashboardsView.VIEW_ID.getName();
+ private static final String LOGOUT_VIEW = "LogOut";
+
+ private static String currentView;
+ private static ViewPath currentViewPath;
// just to avoid constructing this over and over. the ordering is important, more complex viewPaths first,
// javascript will greedily match "Resource" and give up trying after that, missing "Resource/AutoGroup" for
// example.
private static final String TREE_NAV_VIEW_PATTERN = "(" //
- + ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH + "|" //
- + ResourceGroupDetailView.AUTO_CLUSTER_VIEW_PATH //
+ + ResourceGroupDetailView.AUTO_GROUP_VIEW + "|" //
+ + ResourceGroupDetailView.AUTO_CLUSTER_VIEW //
+ ResourceGroupTopView.VIEW_ID + "|" //
+ ResourceTopView.VIEW_ID + "|" //
+ ")/[^/]*";
- public static final String CONTENT_CANVAS_ID = "BaseContent";
-
private static ErrorHandler errorHandler = new ErrorHandler();
private static MessageCenter messageCenter;
- private static String currentPath;
-
- // @SuppressWarnings("unused")
- // private static Canvas content;
-
- private static ViewPath currentViewPath;
-
private static CoreGUI coreGUI;
// store a message to be posted in the message center during the next renderView processing.
@@ -158,10 +155,11 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
});
- /* after having this enabled for a while, the majority opinion is that this is more annoying than helpful
+ /* after having this enabled for a while, the majority opinion is that this is more annoying than helpful
+ *
Window.addWindowClosingHandler(new Window.ClosingHandler() {
public void onWindowClosing(Window.ClosingEvent event) {
- event.setMessage("Are you sure you want to leave RHQ?");
+ event.setMessage("Are you sure you want to leave RHQ?");
}
});
*/
@@ -202,7 +200,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
History.addValueChangeHandler(this);
}
- if (History.getToken().equals("") || History.getToken().equals("LogOut")) {
+ if (History.getToken().equals("") || History.getToken().equals(LOGOUT_VIEW)) {
// init the rootCanvas to ensure a clean slate for a new user
rootCanvas.initCanvas();
@@ -214,51 +212,57 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
// otherwise just fire an event for the bookmarked URL they are returning to
History.fireCurrentHistoryState();
}
+
+ // The root canvas is hidden by user log out, show again if necessary
+ if (!rootCanvas.isVisible()) {
+ rootCanvas.show();
+ }
}
public void onValueChange(ValueChangeEvent<String> stringValueChangeEvent) {
- currentPath = URL.decodeComponent(stringValueChangeEvent.getValue());
- Log.debug("Handling history event for path: " + currentPath);
+ currentView = URL.decodeComponent(stringValueChangeEvent.getValue());
+ Log.debug("Handling history event for view: " + currentView);
- currentViewPath = new ViewPath(currentPath);
+ currentViewPath = new ViewPath(currentView);
coreGUI.rootCanvas.renderView(currentViewPath);
}
public static void refresh() {
- currentViewPath = new ViewPath(currentPath, true);
+ currentViewPath = new ViewPath(currentView, true);
coreGUI.rootCanvas.renderView(currentViewPath);
}
- public Canvas createContent(String breadcrumbName) {
+ public Canvas createContent(String viewName) {
Canvas canvas;
- if (breadcrumbName.equals(DashboardsView.VIEW_ID.getName())) {
- canvas = new DashboardsView(breadcrumbName);
- } else if (breadcrumbName.equals(InventoryView.VIEW_ID.getName())) {
+ if (viewName.equals(DashboardsView.VIEW_ID.getName())) {
+ canvas = new DashboardsView(viewName);
+ } else if (viewName.equals(InventoryView.VIEW_ID.getName())) {
canvas = new InventoryView();
- } else if (breadcrumbName.equals(ResourceTopView.VIEW_ID.getName())) {
- canvas = new ResourceTopView(breadcrumbName);
- } else if (breadcrumbName.equals(ResourceGroupTopView.VIEW_ID.getName())) {
- canvas = new ResourceGroupTopView(breadcrumbName);
- } else if (breadcrumbName.equals(ReportTopView.VIEW_ID.getName())) {
+ } else if (viewName.equals(ResourceTopView.VIEW_ID.getName())) {
+ canvas = new ResourceTopView(viewName);
+ } else if (viewName.equals(ResourceGroupTopView.VIEW_ID.getName())) {
+ canvas = new ResourceGroupTopView(viewName);
+ } else if (viewName.equals(ReportTopView.VIEW_ID.getName())) {
canvas = new ReportTopView();
- } else if (breadcrumbName.equals(BundleTopView.VIEW_ID.getName())) {
- canvas = new BundleTopView(breadcrumbName);
- } else if (breadcrumbName.equals(AdministrationView.VIEW_ID.getName())) {
+ } else if (viewName.equals(BundleTopView.VIEW_ID.getName())) {
+ canvas = new BundleTopView(viewName);
+ } else if (viewName.equals(AdministrationView.VIEW_ID.getName())) {
canvas = new AdministrationView();
- } else if (breadcrumbName.equals(HelpView.VIEW_ID.getName())) {
+ } else if (viewName.equals(HelpView.VIEW_ID.getName())) {
canvas = new HelpView();
- } else if (breadcrumbName.equals("LogOut")) {
- // TODO: don't make LogOut a history event, just perform the logout action by responding to click event
+ } else if (viewName.equals(LOGOUT_VIEW)) {
+ UserSessionManager.logout();
+ rootCanvas.hide();
+
LoginView logoutView = new LoginView("Login");
canvas = logoutView;
- UserSessionManager.logout();
logoutView.showLoginDialog();
- } else if (breadcrumbName.equals(TaggedView.VIEW_ID.getName())) {
- canvas = new TaggedView(breadcrumbName);
- } else if (breadcrumbName.equals("Subsystems")) {
+ } else if (viewName.equals(TaggedView.VIEW_ID.getName())) {
+ canvas = new TaggedView(viewName);
+ } else if (viewName.equals("Subsystems")) {
canvas = new AlertHistoryView("Alert");
- } else if (breadcrumbName.equals(TestTopView.VIEW_ID.getName())) {
+ } else if (viewName.equals(TestTopView.VIEW_ID.getName())) {
canvas = new TestTopView();
} else {
canvas = null;
@@ -282,38 +286,38 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
private static String getDefaultView() {
// TODO: should this be Dashboard or a User Preference?
- return DEFAULT_VIEW_PATH;
+ return DEFAULT_VIEW;
}
- public static void goToView(String viewPath) {
- goToView(viewPath, null, false);
+ public static void goToView(String view) {
+ goToView(view, null, false);
}
- public static void goToView(String viewPath, Message message) {
- goToView(viewPath, message, false);
+ public static void goToView(String view, Message message) {
+ goToView(view, message, false);
}
- public static void goToView(String viewPath, boolean refresh) {
- goToView(viewPath, null, refresh);
+ public static void goToView(String view, boolean refresh) {
+ goToView(view, null, refresh);
}
- public static void goToView(String viewPath, Message message, boolean refresh) {
+ public static void goToView(String view, Message message, boolean refresh) {
pendingMessage = message;
pendingRefresh = refresh;
// if path starts with "#" (e.g. if caller used LinkManager to obtain some of the path), strip it off
- if (viewPath.charAt(0) == '#') {
- viewPath = viewPath.substring(1);
+ if (view.charAt(0) == '#') {
+ view = view.substring(1);
}
String currentViewPath = History.getToken();
- if (currentViewPath.equals(viewPath)) {
+ if (currentViewPath.equals(view)) {
// We're already there - just refresh the view.
refresh();
} else {
- if (viewPath.matches(TREE_NAV_VIEW_PATTERN)) {
+ if (view.matches(TREE_NAV_VIEW_PATTERN)) {
// e.g. "Resource/10001" or "Resource/AutoGroup/10003"
- if (!currentViewPath.startsWith(viewPath)) {
+ if (!currentViewPath.startsWith(view)) {
// The Node that was selected is not the same Node that was previously selected - it
// may not even be the same node type. For example, the user could have moved from a
// resource to an autogroup in the same tree. Try to keep the tab selection sticky as best as
@@ -325,10 +329,10 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
// trying to render non-applicable detail views. We'll do this by chopping at the start
// of any other numeric in the path
suffix = suffix.replaceFirst("\\d.*", "");
- viewPath += suffix;
+ view += suffix;
}
}
- History.newItem(viewPath);
+ History.newItem(view);
}
}
@@ -351,35 +355,43 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
private String getViewPathTitle(ViewPath viewPath) {
// default title is the path minus any IDs we find. That should give a least some nice default title.
- StringBuilder path = new StringBuilder();
- for (ViewId view : viewPath.getViewPath()) {
+ StringBuilder viewPathTitle = new StringBuilder();
+ for (ViewId viewId : viewPath.getViewPath()) {
// none of our path elements start with a digit that is NOT an ID; if we see an ID, skip it
- if (!Character.isDigit(view.getPath().charAt(0))) {
- if (path.length() > 0) {
- path.append(" | ");
+ if (!Character.isDigit(viewId.getPath().charAt(0))) {
+ if (viewPathTitle.length() > 0) {
+ viewPathTitle.append(" | ");
}
- path.append(view.getPath());
+ viewPathTitle.append(viewId.getPath());
}
}
- if (path.length() == 0) {
- path.append("Core Application");
+ if (viewPathTitle.length() == 0) {
+ viewPathTitle.append("Core Application");
}
- return "RHQ: " + path.toString();
+ return "RHQ: " + viewPathTitle.toString();
}
public void initCanvas() {
// request a redraw of the MenuBarItem to ensure the correct session info is displayed
getMember(0).markForRedraw();
- // remove any current viewId so the next requested path generates new content
+ // remove any current viewId so the next requested view generates new content
this.currentViewId = null;
}
- public void renderView(final ViewPath viewPath) {
- Window.setTitle(getViewPathTitle(viewPath));
+ public void renderView(ViewPath viewPath) {
+ // If the session is logged out ensure that we only navigate to the log out view, otherwise keep
+ // our CoreGUI session alive by refreshing the session timer each time the user performs navigation
+ if (UserSessionManager.isLoggedOut()) {
+ if (!LOGOUT_VIEW.equals(viewPath.getCurrent().getPath())) {
+ History.newItem(LOGOUT_VIEW);
+ }
+ return;
+ } else {
+ UserSessionManager.refresh();
+ }
- // keep our CoreGUI session alive by refreshing the session timer each time the user performs navigation
- UserSessionManager.refresh();
+ Window.setTitle(getViewPathTitle(viewPath));
// clear any message when navigating to a new view (not refreshing), the user is probably no longer interested
if (!viewPath.isRefresh()) {
@@ -388,7 +400,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
if (viewPath.isEnd()) {
// default view
- History.newItem(DEFAULT_VIEW_PATH);
+ History.newItem(DEFAULT_VIEW);
} else {
if (pendingMessage != null) {
getMessageCenter().notify(pendingMessage);
@@ -425,13 +437,15 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
if (this.currentCanvas instanceof InitializableView) {
final InitializableView initializableView = (InitializableView) this.currentCanvas;
+ final ViewPath initializableViewPath = viewPath;
new Timer() {
final long startTime = System.currentTimeMillis();
public void run() {
if (initializableView.isInitialized()) {
if (RootCanvas.this.currentCanvas instanceof BookmarkableView) {
- ((BookmarkableView) RootCanvas.this.currentCanvas).renderView(viewPath.next());
+ ((BookmarkableView) RootCanvas.this.currentCanvas).renderView(initializableViewPath
+ .next());
} else {
RootCanvas.this.currentCanvas.markForRedraw();
}
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 07ec01f..b00d8a0 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
@@ -77,7 +77,7 @@ public class UserSessionManager {
// Currently: 1 hour
private static int SESSION_TIMEOUT = 60 * 60 * 1000;
- // After CoreGUI logiut, the delay before the server-side logout. Thisis the period in which we allow in-flight
+ // After CoreGUI logout, the delay before the server-side logout. This is the period in which we allow in-flight
// async requests to complete.
// Currently: 5 seconds
private static int LOGOUT_DELAY = 5 * 1000; // 5 seconds
@@ -192,12 +192,12 @@ public class UserSessionManager {
Log.info("sessionAccess-savingSessionId: " + sessionId);
saveSessionId(sessionId);
- // new sessions get the full 29 minutes to expire
+ // new sessions get the full SESSION_TIMEOUT period prior to expire
Log.info("sessionAccess-schedulingSessionTimeout: " + SESSION_TIMEOUT);
coreGuiSessionTimer.schedule(SESSION_TIMEOUT);
} else {
- // existing sessions should expire 29 minutes from the previous access time
+ // existing sessions should expire SESSION_TIMEOUT minutes from the previous access time
long expiryTime = lastAccess + SESSION_TIMEOUT;
long expiryMillis = expiryTime - System.currentTimeMillis();
@@ -205,7 +205,7 @@ public class UserSessionManager {
if (expiryMillis < 1) {
expiryMillis = 1; // expire VERY quickly
} else if (expiryMillis > SESSION_TIMEOUT) {
- expiryMillis = SESSION_TIMEOUT; // guarantees maximum is 29 minutes
+ expiryMillis = SESSION_TIMEOUT; // guarantees maximum
}
Log.info("sessionAccess-reschedulingSessionTimeout: " + expiryMillis);
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 5b909a9..7a21081 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
@@ -390,11 +390,11 @@ public class GroupConfigurationUpdatesPortlet extends LocatableVLayout implement
}
private boolean isAutoGroup() {
- return ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH.equals(getBaseViewPath());
+ return ResourceGroupDetailView.AUTO_GROUP_VIEW.equals(getBaseViewPath());
}
private boolean isAutoCluster() {
- return ResourceGroupDetailView.AUTO_CLUSTER_VIEW_PATH.equals(getBaseViewPath());
+ return ResourceGroupDetailView.AUTO_CLUSTER_VIEW.equals(getBaseViewPath());
}
public String getBaseViewPath() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
index a1d0d1b..700de52 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
@@ -487,11 +487,11 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
}
private boolean isAutoGroup() {
- return ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH.equals(getBaseViewPath());
+ return ResourceGroupDetailView.AUTO_GROUP_VIEW.equals(getBaseViewPath());
}
private boolean isAutoCluster() {
- return ResourceGroupDetailView.AUTO_CLUSTER_VIEW_PATH.equals(getBaseViewPath());
+ return ResourceGroupDetailView.AUTO_CLUSTER_VIEW.equals(getBaseViewPath());
}
public String getBaseViewPath() {
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 949371f..211f459 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
@@ -315,11 +315,11 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
}
private boolean isAutoGroup() {
- return ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH.equals(getBaseViewPath());
+ return ResourceGroupDetailView.AUTO_GROUP_VIEW.equals(getBaseViewPath());
}
private boolean isAutoCluster() {
- return ResourceGroupDetailView.AUTO_CLUSTER_VIEW_PATH.equals(getBaseViewPath());
+ return ResourceGroupDetailView.AUTO_CLUSTER_VIEW.equals(getBaseViewPath());
}
public String getBaseViewPath() {
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 8e8eca7..8cb6a1d 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
@@ -73,8 +73,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
* @author Ian Springer
*/
public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> {
- public static final String AUTO_CLUSTER_VIEW_PATH = "ResourceGroup/AutoCluster";
- public static final String AUTO_GROUP_VIEW_PATH = "Resource/AutoGroup";
+ public static final String AUTO_CLUSTER_VIEW = "ResourceGroup/AutoCluster";
+ public static final String AUTO_GROUP_VIEW = "Resource/AutoGroup";
private Integer groupId;
private ResourceGroupComposite groupComposite;
@@ -476,11 +476,11 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
}
private boolean isAutoGroup() {
- return AUTO_GROUP_VIEW_PATH.equals(getBaseViewPath());
+ return AUTO_GROUP_VIEW.equals(getBaseViewPath());
}
private boolean isAutoCluster() {
- return AUTO_CLUSTER_VIEW_PATH.equals(getBaseViewPath());
+ return AUTO_CLUSTER_VIEW.equals(getBaseViewPath());
}
private void loadResourceType(final ResourceGroupComposite groupComposite, final ViewPath viewPath) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
index 32d8110..d00f0a6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
@@ -71,7 +71,7 @@ public class ResourceGroupTopView extends LocatableHLayout implements Bookmarkab
if (null == detailView) {
if (isAutoClusterPath) {
detailView = new ResourceGroupDetailView(this.extendLocatorId("AutoClusterDetail"),
- ResourceGroupDetailView.AUTO_CLUSTER_VIEW_PATH);
+ ResourceGroupDetailView.AUTO_CLUSTER_VIEW);
} else {
detailView = new ResourceGroupDetailView(this.extendLocatorId("groupDetail"), this.VIEW_ID.getName());
}
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 a469fa9..38d0fa5 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
@@ -377,7 +377,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka
}
private void renderAutoCluster(ResourceGroup backingGroup) {
- String viewPath = ResourceGroupDetailView.AUTO_CLUSTER_VIEW_PATH + "/" + backingGroup.getId();
+ String viewPath = ResourceGroupDetailView.AUTO_CLUSTER_VIEW + "/" + backingGroup.getId();
String currentViewPath = History.getToken();
if (!currentViewPath.startsWith(viewPath)) {
CoreGUI.goToView(viewPath);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
index 09c75e6..a1a80ee 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
@@ -64,7 +64,7 @@ public class ResourceTopView extends LocatableHLayout implements BookmarkableVie
if ("AutoGroup".equals(viewPath.getCurrent().getPath())) {
if (null == autoGroupDetailView) {
this.autoGroupDetailView = new ResourceGroupDetailView(this.extendLocatorId("AutoGroupDetail"),
- ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH);
+ ResourceGroupDetailView.AUTO_GROUP_VIEW);
this.setContent(this.autoGroupDetailView);
this.detailView = null;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 5a5a7d1..a94ca04 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -299,7 +299,7 @@ public class ResourceTreeView extends LocatableVLayout {
}
private void renderAutoGroup(ResourceGroup backingGroup) {
- String viewPath = ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH + "/" + backingGroup.getId();
+ String viewPath = ResourceGroupDetailView.AUTO_GROUP_VIEW + "/" + backingGroup.getId();
String currentViewPath = History.getToken();
if (!currentViewPath.startsWith(viewPath)) {
CoreGUI.goToView(viewPath);
commit cb25817a7462904ef449ffdf8b8c65e4124ede34
Merge: 9c257c5 c6bbaa5
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Apr 8 12:57:46 2011 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 9c257c5733307f8fc05d50b5f28b3186b35978f2
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Apr 8 12:57:06 2011 -0400
Fixing typo/spelling error
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java
index 10fc861..20dbeee 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java
@@ -392,7 +392,7 @@ public class InstalledPluginsUIBean {
Subject subject = EnterpriseFacesContextUtility.getSubject();
pluginMgr.markPluginsForPurge(subject, getIds(getSelectedAgentPlugins()));
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Preparing to purge agent plugins: " +
- pluginNames + ". This make take a few minutes since all type definitions from the plugins must " +
+ pluginNames + ". This may take a few minutes since all type definitions from the plugins must " +
"first be purged from the system. The plugins will still be visible on this page until they have " +
"been purged.");
} catch (Exception e) {
commit c6bbaa53d10eb0b0db5af8c651468169b2564ef0
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Apr 8 09:55:20 2011 -0400
fix two compile errors caused by API changes in ResourceFactoryManagerLocal
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 463984e..c72cc59 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
@@ -24,8 +24,8 @@
long begin = Long.parseLong(WebUtility.getRequiredRequestParameter(request, "begin"));
ResourceFactoryManagerLocal resourceFactoryManager = LookupUtil.getResourceFactoryManager();
- PageList<CreateResourceHistory> creates = resourceFactoryManager.findCreateChildResourceHistory(resourceId, begin, end, new PageControl(0,100));
- PageList<DeleteResourceHistory> deletes = resourceFactoryManager.findDeleteChildResourceHistory(resourceId, begin, end, new PageControl(0,100));
+ PageList<CreateResourceHistory> creates = resourceFactoryManager.findCreateChildResourceHistory(subject, resourceId, begin, end, new PageControl(0, 100));
+ PageList<DeleteResourceHistory> deletes = resourceFactoryManager.findDeleteChildResourceHistory(subject, resourceId, begin, end, new PageControl(0, 100));
%>
@@ -108,4 +108,4 @@
<%
}
%>
-]}
\ No newline at end of file
+]}
commit ce01d4eec5e57d844d81339524ba044c5c213bd4
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Apr 7 22:23:15 2011 -0400
trim queries from GroupOperationsPortlet.
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 2ef5bd8..949371f 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
@@ -329,7 +329,11 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
@Override
public void redraw() {
super.redraw();
- loadData();
+ if (!isRefreshing()) {
+ if (groupOperations != null) {
+ groupOperations.refresh();
+ }
+ }
}
protected void setCurrentlyRefreshing(boolean currentlyRefreshing) {
commit 9967221cab0b7aafe7361e2f4d24f2b725a79ac0
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Apr 7 17:30:05 2011 -0400
make About box locatable; fix issue where in Help section where once the About box was closed, clicking on the About left menu item would not redisplay the About box
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
index 7912863..5687c75 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
@@ -25,6 +25,7 @@ import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Button;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
@@ -35,6 +36,10 @@ import org.rhq.core.domain.common.ProductInfo;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Messages;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+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;
/**
* The "About RHQ" modal window.
@@ -42,12 +47,22 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
* @author Ian Springer
* @author Joseph Marques
*/
-public class AboutModalWindow extends Window {
+public class AboutModalWindow extends LocatableWindow {
+
private static final Messages MSG = CoreGUI.getMessages();
private static ProductInfo PRODUCT_INFO;
- public AboutModalWindow() {
+ /**
+ * <pre>
+ * ID Format: "simpleClassname_locatorId"
+ * </pre>
+ *
+ * @param locatorId not null or empty.
+ */
+ public AboutModalWindow(String locatorId) {
+ super(locatorId);
+
setWidth(300);
setHeight(300);
setOverflow(Overflow.VISIBLE);
@@ -83,7 +98,7 @@ public class AboutModalWindow extends Window {
}
private void finishOnInit() {
- VLayout contentPane = new VLayout();
+ LocatableVLayout contentPane = new LocatableVLayout(extendLocatorId("Content"));
contentPane.setPadding(15);
contentPane.setMembersMargin(25);
@@ -103,15 +118,16 @@ public class AboutModalWindow extends Window {
htmlFlow.setContents(html);
contentPane.addMember(htmlFlow);
- HLayout bottomPanel = new HLayout();
- bottomPanel.setAlign(VerticalAlignment.BOTTOM);
- contentPane.addMember(bottomPanel);
+ LocatableHLayout buttonBar = new LocatableHLayout(contentPane.extendLocatorId("ButtonBar"));
+ buttonBar.setAlign(VerticalAlignment.BOTTOM);
+ contentPane.addMember(buttonBar);
Canvas spacer = new Canvas();
spacer.setWidth("*");
- bottomPanel.addMember(spacer);
+ buttonBar.addMember(spacer);
- Button closeButton = new Button(MSG.common_button_close());
+ LocatableIButton closeButton = new LocatableIButton(buttonBar.extendLocatorId("Close"),
+ MSG.common_button_close());
closeButton.setShowRollOver(true);
closeButton.setShowDown(true);
closeButton.setWidth("60");
@@ -120,7 +136,7 @@ public class AboutModalWindow extends Window {
hide();
}
});
- bottomPanel.addMember(closeButton);
+ buttonBar.addMember(closeButton);
// NOTE: Since this is a subclass of Window, we MUST use addItem(), rather than addMember() from the
// Layout class.
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 1488e5d..22a0c13 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
@@ -95,7 +95,7 @@ public class HelpView extends AbstractSectionedLeftNavigationView {
NavigationItem aboutItem = new NavigationItem(new ViewName("AboutBox", MSG.view_help_section_product_about()),
"[SKIN]/../actions/help.png", new ViewFactory() {
public Canvas createView() {
- final AboutModalWindow aboutModalWindow = new AboutModalWindow();
+ final AboutModalWindow aboutModalWindow = new AboutModalWindow(extendLocatorId("AboutModalWindow"));
if (PRODUCT_INFO == null) {
GWTServiceLookup.getSystemService().getProductInfo(new AsyncCallback<ProductInfo>() {
public void onFailure(Throwable caught) {
@@ -114,6 +114,7 @@ public class HelpView extends AbstractSectionedLeftNavigationView {
return aboutModalWindow;
}
});
+ aboutItem.setRefreshRequired(true);
return new NavigationSection(SECTION_PRODUCT_VIEW_ID, aboutItem);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
index 2c9e761..70b0285 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
@@ -93,7 +93,7 @@ public class MenuBarView extends LocatableVLayout {
}
private Canvas getLogoSection() {
- final AboutModalWindow aboutModalWindow = new AboutModalWindow();
+ final AboutModalWindow aboutModalWindow = new AboutModalWindow(extendLocatorId("AboutModalWindow"));
Img logo = new Img("header/rhq_logo_28px.png", 80, 28);
logo.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
@@ -171,4 +171,5 @@ public class MenuBarView extends LocatableVLayout {
return layout;
}
+
}
commit ebbc3638f902a4ae012d5b7db57041f1db5b7a8e
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Apr 7 16:56:22 2011 -0400
return implicit, not explicit, resource and grou perms in PermissionsLoader
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PermissionsLoader.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PermissionsLoader.java
index 6160158..6d1114c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PermissionsLoader.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PermissionsLoader.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;
import java.util.EnumSet;
@@ -46,7 +45,8 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
*/
public class PermissionsLoader {
- private static Messages MSG = CoreGUI.getMessages();
+ private static final Messages MSG = CoreGUI.getMessages();
+
private Throwable lastError;
/**
@@ -59,31 +59,28 @@ public class PermissionsLoader {
}
public void loadExplicitGlobalPermissions(final PermissionsLoadedListener callback) {
- GWTServiceLookup.getAuthorizationService().getExplicitGlobalPermissions(new AsyncCallback<Set<Permission>>() {
-
- @Override
- public void onSuccess(Set<Permission> result) {
- callback.onPermissionsLoaded(result);
- }
-
- @Override
- public void onFailure(Throwable caught) {
- processFailure(MSG.util_userPerm_loadFailGlobal(), caught);
- callback.onPermissionsLoaded(null); // indicate an error by passing in null
- }
+ GWTServiceLookup.getAuthorizationService().getExplicitGlobalPermissions(
+ new AsyncCallback<Set<Permission>>() {
+
+ public void onSuccess(Set<Permission> result) {
+ callback.onPermissionsLoaded(result);
+ }
+
+ public void onFailure(Throwable caught) {
+ processFailure(MSG.util_userPerm_loadFailGlobal(), caught);
+ callback.onPermissionsLoaded(null); // indicate an error by passing in null
+ }
});
}
- public void loadExplicitGroupPermissions(final int groupId, final PermissionsLoadedListener callback) {
- GWTServiceLookup.getAuthorizationService().getExplicitGroupPermissions(groupId,
+ public void loadGroupPermissions(final int groupId, final PermissionsLoadedListener callback) {
+ GWTServiceLookup.getAuthorizationService().getImplicitGroupPermissions(groupId,
new AsyncCallback<Set<Permission>>() {
- @Override
public void onSuccess(Set<Permission> result) {
callback.onPermissionsLoaded(result);
}
- @Override
public void onFailure(Throwable caught) {
processFailure(MSG.util_userPerm_loadFailGroup(String.valueOf(groupId)), caught);
callback.onPermissionsLoaded(null); // indicate an error by passing in null
@@ -91,16 +88,14 @@ public class PermissionsLoader {
});
}
- public void loadExplicitResourcePermissions(final int resourceId, final PermissionsLoadedListener callback) {
- GWTServiceLookup.getAuthorizationService().getExplicitResourcePermissions(resourceId,
+ public void loadResourcePermissions(final int resourceId, final PermissionsLoadedListener callback) {
+ GWTServiceLookup.getAuthorizationService().getImplicitResourcePermissions(resourceId,
new AsyncCallback<Set<Permission>>() {
- @Override
public void onSuccess(Set<Permission> result) {
callback.onPermissionsLoaded(result);
}
- @Override
public void onFailure(Throwable caught) {
processFailure(MSG.util_userPerm_loadFailResource(String.valueOf(resourceId)), caught);
callback.onPermissionsLoaded(null); // indicate an error by passing in null
@@ -114,4 +109,5 @@ public class PermissionsLoader {
Severity severity = Message.Severity.Error;
CoreGUI.getMessageCenter().notify(new Message(msg, caught, severity, options));
}
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/async/TestAsyncView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/async/TestAsyncView.java
index beeede4..b914680 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/async/TestAsyncView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/async/TestAsyncView.java
@@ -55,7 +55,7 @@ public class TestAsyncView extends LocatableVLayout implements AsyncOperationCal
this.resourcePermsAsyncOperation = new AsyncOperation() {
public void execute(final AsyncOperationCallback callback, Object... params) {
- new PermissionsLoader().loadExplicitResourcePermissions(10001, new PermissionsLoadedListener() {
+ new PermissionsLoader().loadResourcePermissions(10001, new PermissionsLoadedListener() {
public void onPermissionsLoaded(Set<Permission> permissions) {
resourcePerms = permissions;
Timer timer = new Timer() {
commit e403d9febb53979b0e564550016915d988253aab
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Apr 7 08:57:34 2011 -0400
i)Cleanup of Group/Resource* portlets.
ii)Removed several redundant queries from Res/Grp portlets. Still redundant query in Group/Res Operations portlet.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java
index 6ef8a59..7c4a68b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java
@@ -100,7 +100,6 @@ public class GroupBundleDeploymentsPortlet extends LocatableVLayout implements C
@Override
protected void onInit() {
- super.onInit();
initializeUi();
loadData();
}
@@ -282,7 +281,9 @@ public class GroupBundleDeploymentsPortlet extends LocatableVLayout implements C
@Override
public void redraw() {
super.redraw();
- loadData();
+ if (!isRefreshing()) {
+ loadData();
+ }
}
}
\ No newline at end of file
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 256f9c1..5b909a9 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
@@ -293,7 +293,6 @@ public class GroupConfigurationUpdatesPortlet extends LocatableVLayout implement
@Override
protected void onInit() {
- super.onInit();
//disable the refresh timer for this run
currentlyLoading = true;
initializeUi();
@@ -312,10 +311,12 @@ public class GroupConfigurationUpdatesPortlet extends LocatableVLayout implement
@Override
public void redraw() {
super.redraw();
- loadData();
+ if (!isRefreshing()) {
+ loadData();
+ }
}
- private void loadData() {
+ protected void loadData() {
//populate composite data
//locate resourceGroupRef
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
index b4761e9..d054102 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
@@ -102,7 +102,6 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
@Override
protected void onInit() {
- super.onInit();
//disable the refresh timer for this run
currentlyLoading = true;
initializeUi();
@@ -190,7 +189,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
/** Fetches recent events and updates the DynamicForm instance with the latest
* event information over last 24hrs.
*/
- private void getRecentEventUpdates() {
+ protected void getRecentEventUpdates() {
final int groupId = this.groupId;
long end = System.currentTimeMillis();
long start = end - (24 * 60 * 60 * 1000);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
index d6dbf19..a1d0d1b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
@@ -120,7 +120,6 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
@Override
protected void onInit() {
- super.onInit();
setRefreshing(true);
initializeUi();
loadData();
@@ -208,7 +207,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
* ii) link to recent metric graph for more details and iii) last metric value formatted to show significant
* digits.
*/
- private void getRecentMetrics() {
+ protected void getRecentMetrics() {
//display container
final VLayout column = new VLayout();
column.setHeight(10);//pack
@@ -482,7 +481,9 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
@Override
public void redraw() {
super.redraw();
- loadData();
+ if (!isRefreshing()) {
+ loadData();
+ }
}
private boolean isAutoGroup() {
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 b06c9a4..d19a301 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
@@ -95,7 +95,6 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings
@Override
protected void onInit() {
- super.onInit();
initializeUi();
loadData();
}
@@ -183,7 +182,7 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings
/** Fetches OOB measurements and updates the DynamicForm instance with the latest N
* oob change details.
*/
- private void getRecentOobs() {
+ protected void getRecentOobs() {
final int groupId = this.groupId;
int resultCount = 5;//default to
@@ -266,7 +265,8 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings
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();
+ if (!isRefreshing()) {
+ loadData();
+ }
}
-
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java
index da5a0ee..36258fb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java
@@ -98,7 +98,6 @@ public class GroupPkgHistoryPortlet extends LocatableVLayout implements CustomSe
@Override
protected void onInit() {
- super.onInit();
initializeUi();
loadData();
}
@@ -185,7 +184,7 @@ public class GroupPkgHistoryPortlet extends LocatableVLayout implements CustomSe
/** Fetches recent package history information and updates the DynamicForm instance with details.
*/
- private void getRecentPkgHistory() {
+ protected void getRecentPkgHistory() {
final int groupId = this.groupId;
InstalledPackageHistoryCriteria criteria = new InstalledPackageHistoryCriteria();
@@ -279,7 +278,9 @@ public class GroupPkgHistoryPortlet extends LocatableVLayout implements CustomSe
@Override
public void redraw() {
super.redraw();
- loadData();
+ if (!isRefreshing()) {
+ loadData();
+ }
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceBundleDeploymentsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceBundleDeploymentsPortlet.java
index 3cb8256..763b8fc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceBundleDeploymentsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceBundleDeploymentsPortlet.java
@@ -64,21 +64,6 @@ public class ResourceBundleDeploymentsPortlet extends GroupBundleDeploymentsPort
this.resourceId = currentResourceIdentifier;
}
- @Override
- protected void onInit() {
- super.onInit();
- initializeUi();
- loadData();
- }
-
- /**Defines layout for the portlet page.
- */
- protected void initializeUi() {
- setPadding(5);
- setMembersMargin(5);
- addMember(recentBundleDeployContent);
- }
-
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
@@ -87,13 +72,9 @@ public class ResourceBundleDeploymentsPortlet extends GroupBundleDeploymentsPort
}
}
- protected void loadData() {
- currentlyLoading = true;
- getRecentBundleDeployments();
- }
-
/** Fetches recent bundle deployment information and updates the DynamicForm instance with details.
*/
+ @Override
protected void getRecentBundleDeployments() {
final int resourceId = this.resourceId;
ResourceBundleDeploymentCriteria criteria = new ResourceBundleDeploymentCriteria();
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 bd5c4ac..4ab8396 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
@@ -76,13 +76,6 @@ public class ResourceConfigurationUpdatesPortlet extends GroupConfigurationUpdat
baseViewPath = elements[0];
}
- @Override
- protected void onInit() {
- super.onInit();
- initializeUi();
- loadData();
- }
-
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
@@ -104,12 +97,7 @@ public class ResourceConfigurationUpdatesPortlet extends GroupConfigurationUpdat
}
@Override
- public void redraw() {
- super.redraw();
- loadData();
- }
-
- private void loadData() {
+ protected void loadData() {
//populate composite data
//locate resourceRef
ResourceCriteria criteria = new ResourceCriteria();
@@ -216,7 +204,6 @@ public class ResourceConfigurationUpdatesPortlet extends GroupConfigurationUpdat
protected void executeFetch(final DSRequest request, final DSResponse response,
final ResourceConfigurationUpdateCriteria criteria) {
ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
-
configurationService.findResourceConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
index a2a2bda..f382ea7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
@@ -64,21 +64,6 @@ public class ResourceEventsPortlet extends GroupEventsPortlet {
this.resourceId = Integer.valueOf(elements[1]);
}
- @Override
- protected void onInit() {
- super.onInit();
- initializeUi();
- loadData();
- }
-
- /**Defines layout for the portlet page.
- */
- protected void initializeUi() {
- setPadding(5);
- setMembersMargin(5);
- addMember(recentEventsContent);
- }
-
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
@@ -87,15 +72,11 @@ public class ResourceEventsPortlet extends GroupEventsPortlet {
}
}
- protected void loadData() {
- currentlyLoading = true;
- getRecentEventUpdates();
- }
-
/** Fetches recent events and updates the DynamicForm instance with the latest
* event information over last 24hrs.
*/
- private void getRecentEventUpdates() {
+ @Override
+ protected void getRecentEventUpdates() {
final int resourceId = this.resourceId;
long end = System.currentTimeMillis();
long start = end - (24 * 60 * 60 * 1000);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
index a77796f..735fba8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
@@ -79,21 +79,6 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet {
baseViewPath = elements[0];
}
- @Override
- protected void onInit() {
- super.onInit();
- initializeUi();
- loadData();
- }
-
- /**Defines layout for the portlet page.
- */
- protected void initializeUi() {
- setPadding(5);
- setMembersMargin(5);
- addMember(recentMeasurementsContent);
- }
-
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
@@ -102,16 +87,12 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet {
}
}
- protected void loadData() {
- currentlyLoading = true;
- getRecentMetrics();
- }
-
/** Fetches recent metric information and updates the DynamicForm instance with i)sparkline information,
* ii) link to recent metric graph for more details and iii) last metric value formatted to show significant
* digits.
*/
- private void getRecentMetrics() {
+ @Override
+ protected void getRecentMetrics() {
//display container
final VLayout column = new VLayout();
column.setHeight(10);//pack
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOobsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOobsPortlet.java
index b0e9d37..a1d0301 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOobsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOobsPortlet.java
@@ -59,21 +59,6 @@ public class ResourceOobsPortlet extends GroupOobsPortlet {
this.resourceId = Integer.valueOf(elements[1]);
}
- @Override
- protected void onInit() {
- super.onInit();
- initializeUi();
- loadData();
- }
-
- /**Defines layout for the portlet page.
- */
- protected void initializeUi() {
- setPadding(5);
- setMembersMargin(5);
- addMember(recentOobContent);
- }
-
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
@@ -82,15 +67,11 @@ public class ResourceOobsPortlet extends GroupOobsPortlet {
}
}
- protected void loadData() {
- currentlyLoading = true;
- getRecentOobs();
- }
-
/** Fetches OOB measurements and updates the DynamicForm instance with the latest N
* oob change details.
*/
- private void getRecentOobs() {
+ @Override
+ protected void getRecentOobs() {
final int resourceId = this.resourceId;
int resultCount = 5;//default to
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourcePkgHistoryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourcePkgHistoryPortlet.java
index 41ce660..3ead00a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourcePkgHistoryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourcePkgHistoryPortlet.java
@@ -63,21 +63,6 @@ public class ResourcePkgHistoryPortlet extends GroupPkgHistoryPortlet {
this.resourceId = currentResourceIdentifier;
}
- @Override
- protected void onInit() {
- super.onInit();
- initializeUi();
- loadData();
- }
-
- /**Defines layout for the portlet page.
- */
- protected void initializeUi() {
- setPadding(5);
- setMembersMargin(5);
- addMember(recentPkgHistoryContent);
- }
-
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
@@ -86,14 +71,10 @@ public class ResourcePkgHistoryPortlet extends GroupPkgHistoryPortlet {
}
}
- protected void loadData() {
- currentlyLoading = true;
- getRecentPkgHistory();
- }
-
/** Fetches recent package history information and updates the DynamicForm instance with details.
*/
- private void getRecentPkgHistory() {
+ @Override
+ protected void getRecentPkgHistory() {
final int resourceId = this.resourceId;
InstalledPackageHistoryCriteria criteria = new InstalledPackageHistoryCriteria();
commit 6b40d5292eec2feecf0f0d65dec3599e8d913511
Merge: 4dce488 8152dac
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Apr 7 16:29:01 2011 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 4dce488060dcf08592daad2571560b16ba20241c
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Apr 7 16:27:02 2011 -0400
[BZ 690430,690412] Adding additional logging for SSL exceptions
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 c1ff6eb..2b226be 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
@@ -28,9 +28,11 @@ import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
+import javax.xml.ws.handler.LogicalHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -41,8 +43,6 @@ import org.apache.commons.logging.LogFactory;
*/
public abstract class WWWUtils {
- 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
@@ -50,6 +50,7 @@ public abstract class WWWUtils {
*/
public static boolean isAvailable(URL httpURL, boolean disableCertValidation) {
+ String failMsg = "URL [" + httpURL + "] returned unavailable";
try {
HttpURLConnection connection = (HttpURLConnection) httpURL.openConnection();
connection.setRequestMethod("HEAD");
@@ -62,7 +63,13 @@ public abstract class WWWUtils {
connection.connect();
// get the respone code to actually trigger sending the Request.
connection.getResponseCode();
+ } catch (SSLException e) {
+ Log log = LogFactory.getLog(WWWUtils.class);
+ log.warn(failMsg + " due to: " + e.getLocalizedMessage(), e);
+ return false;
} catch (IOException e) {
+ Log log = LogFactory.getLog(WWWUtils.class);
+ log.debug(failMsg + " due to: " + e.getLocalizedMessage(), e);
return false;
}
@@ -118,8 +125,10 @@ public abstract class WWWUtils {
}
});
} catch (NoSuchAlgorithmException e) {
+ Log log = LogFactory.getLog(WWWUtils.class);
log.warn("Failed to disable certificate validation.", e);
} catch (KeyManagementException e) {
+ Log log = LogFactory.getLog(WWWUtils.class);
log.warn("Failed to disable certificate validation.", e);
}
}
commit 8152dacaa244f1776b0d24707aca5627e4e5e19b
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Apr 7 15:43:41 2011 -0400
Fix an issue with direct autogroup navigation [BZ 694628]
- eliminate an incorrect tree node selection.
- also, prevent an unnecessary resource node navigation when navigating
directly to an autogroup node.
This fix should also speed up some tree renderings.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 4658996..5a5a7d1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -629,13 +629,16 @@ public class ResourceTreeView extends LocatableVLayout {
} else {
// This is for cases where we have to load the tree fresh including down to the currently visible node
- loadTree(selectedResourceId, null);
+ loadTree(selectedResourceId, true, null);
}
}
- private void loadTree(final int selectedResourceId, final AsyncCallback<Void> callback) {
- selectedNodeId = ResourceTreeNode.idOf(selectedResourceId);
+ private void loadTree(final int selectedResourceId, final boolean updateSelection,
+ final AsyncCallback<Void> callback) {
+ if (updateSelection) {
+ selectedNodeId = ResourceTreeNode.idOf(selectedResourceId);
+ }
final ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
@@ -679,7 +682,10 @@ public class ResourceTreeView extends LocatableVLayout {
public void execute(DSResponse response, Object rawData, DSRequest request) {
Log.info("Done fetching data for tree.");
- updateSelection();
+
+ if (updateSelection) {
+ updateSelection();
+ }
if (null != callback) {
callback.onSuccess(null);
@@ -687,8 +693,6 @@ public class ResourceTreeView extends LocatableVLayout {
}
});
- updateSelection();
-
} else {
ResourceTypeRepository.Cache.getInstance().loadResourceTypes(lineage,
EnumSet.of(ResourceTypeRepository.MetadataType.subCategory),
@@ -699,7 +703,7 @@ public class ResourceTreeView extends LocatableVLayout {
.linkNodes(ResourceTreeDatasource.buildNodes(lineage, lockedData));
TreeNode selectedNode = treeGrid.getTree().findById(selectedNodeId);
- if (selectedNode != null) {
+ if (selectedNode != null && updateSelection) {
updateSelection();
} else {
@@ -741,8 +745,10 @@ public class ResourceTreeView extends LocatableVLayout {
public void onSuccess(PageList<ResourceGroup> result) {
final ResourceGroup backingGroup = result.get(0);
- // load the tree up to the autogroup's parent resource
- loadTree(backingGroup.getAutoGroupParentResource().getId(), new AsyncCallback<Void>() {
+ // load the tree up to the autogroup's parent resource. Don't select the resource node
+ // to avoid an unnecessary navigation to the resource, we just need the tree in place so
+ // we can navigate to the autogroup node.
+ loadTree(backingGroup.getAutoGroupParentResource().getId(), false, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_loadFailed_children(), caught);
commit d30dd30a3be0c48fa622423a718b92077e1be904
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Apr 7 15:13:50 2011 -0400
a new async execution framework providing a simple API for parallel or serial execution of a set of async ops + a new test view that demonstrates its usage
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 11e4f9e..054974a 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
@@ -32,6 +32,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.inventory.resource.selection.ResourceSelector;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeTreeView;
+import org.rhq.enterprise.gui.coregui.client.test.async.TestAsyncView;
import org.rhq.enterprise.gui.coregui.client.test.configuration.TestConfigurationView;
import org.rhq.enterprise.gui.coregui.client.test.configuration.TestGroupConfigurationView;
import org.rhq.enterprise.gui.coregui.client.test.configuration.TestReadOnlyConfigurationView;
@@ -68,6 +69,7 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
private static final ViewName MISC_SECTION_VIEW_ID = new ViewName("Misc");
private static final ViewName PAGE_PLURALIZATION_TEST = new ViewName("PluralizationTest");
private static final ViewName PAGE_REMOTE_SERVICE_STATISTICS = new ViewName("RemoteServiceStatistics");
+ private static final ViewName PAGE_ASYNC = new ViewName("Async");
public TestTopView() {
// This is a top level view, so our locator id can simply be our view id.
@@ -174,7 +176,14 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
}
});
- return new NavigationSection(MISC_SECTION_VIEW_ID, pluralizationItem, remoteServiceStatisticsItem);
+ NavigationItem asyncItem = new NavigationItem(PAGE_ASYNC, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new TestAsyncView(extendLocatorId(PAGE_ASYNC.getName()));
+ }
+ });
+
+ return new NavigationSection(MISC_SECTION_VIEW_ID, pluralizationItem, remoteServiceStatisticsItem, asyncItem);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/async/TestAsyncView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/async/TestAsyncView.java
new file mode 100644
index 0000000..beeede4
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/async/TestAsyncView.java
@@ -0,0 +1,114 @@
+package org.rhq.enterprise.gui.coregui.client.test.async;
+
+import com.google.gwt.user.client.Timer;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.layout.HLayout;
+import org.rhq.core.domain.authz.Permission;
+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.util.async.AsyncOperation;
+import org.rhq.enterprise.gui.coregui.client.util.async.AsyncOperationCallback;
+import org.rhq.enterprise.gui.coregui.client.util.async.ParallelCompoundAsyncOperation;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Ian Springer
+ */
+public class TestAsyncView extends LocatableVLayout implements AsyncOperationCallback<Map<AsyncOperation, Object>> {
+
+ private AsyncOperation globalPermsAsyncOperation;
+ private AsyncOperation resourcePermsAsyncOperation;
+ private Set<Permission> globalPerms;
+ private Set<Permission> resourcePerms;
+ private Label label;
+ private HLayout buttonBar;
+ private IButton button1;
+ private IButton button2;
+
+ public TestAsyncView(String locatorId) {
+ super(locatorId);
+ setMargin(10);
+
+ final ParallelCompoundAsyncOperation compoundAsyncOperation = new ParallelCompoundAsyncOperation();
+
+ this.globalPermsAsyncOperation = new AsyncOperation() {
+ public void execute(final AsyncOperationCallback callback, Object... params) {
+ new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
+ public void onPermissionsLoaded(Set<Permission> permissions) {
+ globalPerms = permissions;
+ Timer timer = new Timer() {
+ public void run() {
+ callback.onSuccess(globalPermsAsyncOperation, globalPerms);
+ }
+ };
+ timer.schedule(1000);
+ }
+ });
+ }
+ };
+ compoundAsyncOperation.addOperation(this.globalPermsAsyncOperation);
+
+ this.resourcePermsAsyncOperation = new AsyncOperation() {
+ public void execute(final AsyncOperationCallback callback, Object... params) {
+ new PermissionsLoader().loadExplicitResourcePermissions(10001, new PermissionsLoadedListener() {
+ public void onPermissionsLoaded(Set<Permission> permissions) {
+ resourcePerms = permissions;
+ Timer timer = new Timer() {
+ public void run() {
+ callback.onSuccess(resourcePermsAsyncOperation, resourcePerms);
+ }
+ };
+ timer.schedule(2000);
+ }
+ });
+ }
+ };
+ compoundAsyncOperation.addOperation(this.resourcePermsAsyncOperation);
+
+ compoundAsyncOperation.execute(this);
+
+ this.label = new Label("Loading...");
+ addMember(this.label);
+
+ this.buttonBar = new HLayout();
+ this.buttonBar.setMargin(15);
+ this.buttonBar.setMembersMargin(5);
+ this.buttonBar.setVisible(false);
+
+ this.button1 = new IButton("Do Action requiring MANAGE_SECURITY");
+ this.button1.setWidth(220);
+ this.button1.setDisabled(true);
+ this.buttonBar.addMember(this.button1);
+
+ this.button2 = new IButton("Do Action requiring CONFIGURE_WRITE on platform Resource");
+ this.button2.setWidth(320);
+ this.button2.setDisabled(true);
+ this.buttonBar.addMember(this.button2);
+
+ addMember(this.buttonBar);
+ }
+
+ public void onSuccess(AsyncOperation operation, Map<AsyncOperation, Object> result) {
+ this.label.hide();
+
+ if (this.globalPerms.contains(Permission.MANAGE_SECURITY)) {
+ this.button1.enable();
+ }
+
+ if (this.resourcePerms.contains(Permission.CONFIGURE_WRITE)) {
+ this.button2.enable();
+ }
+
+ this.buttonBar.show();
+ }
+
+ public void onFailure(AsyncOperation operation, Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Async init failed.", caught);
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/AbstractCompoundAsyncOperation.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/AbstractCompoundAsyncOperation.java
new file mode 100644
index 0000000..45f0645
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/AbstractCompoundAsyncOperation.java
@@ -0,0 +1,120 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 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.util.async;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Ian Springer
+ */
+public abstract class AbstractCompoundAsyncOperation implements AsyncOperation,
+ AsyncOperationCallback {
+
+ private List<AsyncOperation> operations = new ArrayList<AsyncOperation>();
+ private Map<AsyncOperation, Object[]> params = new LinkedHashMap<AsyncOperation, Object[]>();
+ private AsyncOperationCallback<Map<AsyncOperation, Object>> callback;
+ private Map<AsyncOperation, Object> successResults = new LinkedHashMap<AsyncOperation, Object>();
+ private Map<AsyncOperation, Throwable> failureThrowables = new LinkedHashMap<AsyncOperation, Throwable>();
+
+ public void addOperation(AsyncOperation operation) {
+ if (this.callback != null) {
+ throw new IllegalStateException("Child operations cannot be added once the compound operation has been executed.");
+ }
+ this.operations.add(operation);
+ }
+
+ @Override
+ public void execute(AsyncOperationCallback callback, Object... params) {
+ if (this.callback != null) {
+ throw new IllegalStateException("This executor can only be executed once and has already been executed.");
+ }
+ this.callback = callback;
+
+ List<AsyncOperation> operations1 = this.operations;
+ for (int i = 0, operations1Size = operations1.size(); i < operations1Size; i++) {
+ AsyncOperation operation = operations1.get(i);
+ Object[] paramArray;
+ if (i < this.params.size()) {
+ Object param = params[i];
+ paramArray = (param.getClass().isArray()) ? (Object[]) param : new Object[] { param };
+ } else {
+ // no params
+ paramArray = new Object[0];
+ }
+ this.params.put(operation, paramArray);
+ }
+ }
+
+ @Override
+ public void onFailure(AsyncOperation operation, Throwable caught) {
+ //noinspection ThrowableResultOfMethodCallIgnored
+ this.failureThrowables.put(operation, caught);
+ processCompletedOperation();
+ }
+
+ @Override
+ public void onSuccess(AsyncOperation operation, Object result) {
+ this.successResults.put(operation, result);
+ processCompletedOperation();
+ }
+
+ public List<AsyncOperation> getOperations() {
+ return operations;
+ }
+
+ public AsyncOperationCallback<Map<AsyncOperation, Object>> getCallback() {
+ return callback;
+ }
+
+ public Map<AsyncOperation, Object> getSuccessResults() {
+ return successResults;
+ }
+
+ public Map<AsyncOperation, Throwable> getFailureThrowables() {
+ return failureThrowables;
+ }
+
+ public Object[] getParameters(AsyncOperation operation) {
+ return this.params.get(operation);
+ }
+
+ protected boolean isComplete() {
+ int completedOperationsCount = this.successResults.size() + this.failureThrowables.size();
+ return (completedOperationsCount == this.operations.size());
+ }
+
+ protected boolean processCompletedOperation() {
+ if (isComplete()) {
+ if (this.failureThrowables.isEmpty()) {
+ this.callback.onSuccess(this, this.successResults);
+ } else {
+ CompoundAsyncOperationException exception = new CompoundAsyncOperationException(this.successResults,
+ this.failureThrowables);
+ this.callback.onFailure(this, exception);
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/AsyncOperation.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/AsyncOperation.java
new file mode 100644
index 0000000..5db7748
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/AsyncOperation.java
@@ -0,0 +1,31 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 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.util.async;
+
+/**
+ * An operation that is executed asynchronously and is responsible for calling either onSuccess() or onFailure() on
+ * the specified callback upon completion.
+ *
+ * @author Ian Springer
+ */
+public interface AsyncOperation {
+
+ void execute(AsyncOperationCallback callback, Object... params);
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/AsyncOperationCallback.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/AsyncOperationCallback.java
new file mode 100644
index 0000000..62432a3
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/AsyncOperationCallback.java
@@ -0,0 +1,34 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 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.util.async;
+
+/**
+ * A callback that one or more {@link AsyncOperation async operation}s should call upon completion.
+ *
+ * @param <T> the type of results the callback supports
+ *
+ * @author Ian Springer
+ */
+public interface AsyncOperationCallback<T> {
+
+ void onFailure(AsyncOperation operation, Throwable caught);
+
+ void onSuccess(AsyncOperation operation, T result);
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/CompoundAsyncOperationException.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/CompoundAsyncOperationException.java
new file mode 100644
index 0000000..ef7dfd3
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/CompoundAsyncOperationException.java
@@ -0,0 +1,47 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 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.util.async;
+
+import java.util.Map;
+
+/**
+ *
+ * @author Ian Springer
+ */
+public class CompoundAsyncOperationException extends Exception {
+
+ private Map<AsyncOperation,Object> successResults;
+ private Map<AsyncOperation,Throwable> failureThrowables;
+
+ public CompoundAsyncOperationException(Map<AsyncOperation, Object> successResults,
+ Map<AsyncOperation, Throwable> failureThrowables) {
+ super("One or more child operations failed.");
+ this.successResults = successResults;
+ this.failureThrowables = failureThrowables;
+ }
+
+ public Map<AsyncOperation, Object> getSuccessResults() {
+ return successResults;
+ }
+
+ public Map<AsyncOperation, Throwable> getFailureThrowables() {
+ return failureThrowables;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/ParallelCompoundAsyncOperation.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/ParallelCompoundAsyncOperation.java
new file mode 100644
index 0000000..b06ff2e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/ParallelCompoundAsyncOperation.java
@@ -0,0 +1,40 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 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.util.async;
+
+/**
+ * A compound {@link AsyncOperation async operation}, which executes a set of child async operations in parallel. Its
+ * {@link #execute(AsyncOperationCallback, Object...)} method invokes its callback once all child operations have
+ * completed (i.e. invoked their own callbacks).
+ *
+ * @author Ian Springer
+ */
+public class ParallelCompoundAsyncOperation extends AbstractCompoundAsyncOperation {
+
+ @Override
+ public void execute(AsyncOperationCallback callback, Object... params) {
+ super.execute(callback, params);
+
+ for (AsyncOperation operation : getOperations()) {
+ Object[] paramArray = getParameters(operation);
+ operation.execute(this, paramArray);
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/SerialCompoundAsyncOperation.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/SerialCompoundAsyncOperation.java
new file mode 100644
index 0000000..c83b7da
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/async/SerialCompoundAsyncOperation.java
@@ -0,0 +1,73 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 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.util.async;
+
+/**
+ * A compound {@link AsyncOperation async operation}, which executes a set of child async operations serially. Its
+ * {@link #execute(AsyncOperationCallback, Object...)} method invokes its callback either when all child operations have
+ * completed (i.e. invoked their own callbacks), or when a child operation fails and abortOnFailure is set to true.
+ *
+ * @author Ian Springer
+ */
+public class SerialCompoundAsyncOperation extends AbstractCompoundAsyncOperation {
+
+ private boolean abortOnFailure;
+ private int executionIndex= -1;
+
+ public void setAbortOnFailure(boolean abortOnFailure) {
+ this.abortOnFailure = abortOnFailure;
+ }
+
+ @Override
+ public void execute(AsyncOperationCallback callback, Object... params) {
+ super.execute(callback, params);
+
+ if (getOperations().isEmpty()) {
+ processCompletedOperation();
+ } else {
+ // Execute the first child operation. processCompletedOperation() will kick off the rest of the child
+ // operations.
+ executeNextOperation();
+ }
+ }
+
+ @Override
+ protected boolean isComplete() {
+ return (super.isComplete() || (this.abortOnFailure && !getFailureThrowables().isEmpty()));
+ }
+
+ @Override
+ protected boolean processCompletedOperation() {
+ boolean isLastCompletedOperation = super.processCompletedOperation();
+ if (!isLastCompletedOperation) {
+ if (this.executionIndex < (getOperations().size() - 1)) {
+ // Execute the next operation.
+ executeNextOperation();
+ }
+ }
+ return (isLastCompletedOperation);
+ }
+
+ private void executeNextOperation() {
+ AsyncOperation operation = getOperations().get(++this.executionIndex);
+ Object[] paramArray = getParameters(operation);
+ operation.execute(this, paramArray);
+ }
+
+}
commit 588f87ff0a29d28cfeff205cbf6f0a172371a689
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Apr 7 13:33:16 2011 -0400
Remove unnecessary fetch of resource type children in the
resource tree build. This speeds up the slowest individual call in
tree construction, the fetch of types, when types have not previously
been fetched (typically the first tree build, when the selected
resource is deep in a tree).
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index f1f349b..4658996 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -690,10 +690,8 @@ public class ResourceTreeView extends LocatableVLayout {
updateSelection();
} else {
- ResourceTypeRepository.Cache.getInstance().loadResourceTypes(
- lineage,
- EnumSet.of(ResourceTypeRepository.MetadataType.children,
- ResourceTypeRepository.MetadataType.subCategory),
+ ResourceTypeRepository.Cache.getInstance().loadResourceTypes(lineage,
+ EnumSet.of(ResourceTypeRepository.MetadataType.subCategory),
new ResourceTypeRepository.ResourceTypeLoadedCallback() {
public void onResourceTypeLoaded(List<Resource> result) {
commit 06b68f9718bdddea1c4c81f513b4d995dc10bbff
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Apr 7 11:48:38 2011 -0400
BZ 694537, 693886 - do not double load
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 4e47c0a..07ec01f 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
@@ -359,9 +359,6 @@ public class UserSessionManager {
return;
}
});
-
- //indicate success to 'login' Callback
- callback.onSuccess(validSessionSubject);
}
});
}//end of server side session check;
commit b417e7916a48cd7ac72c34283bb07145e1ae2d72
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Apr 7 11:48:12 2011 -0400
no need for the tree load to pull in operation data
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 455f414..f1f349b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -692,8 +692,7 @@ public class ResourceTreeView extends LocatableVLayout {
} else {
ResourceTypeRepository.Cache.getInstance().loadResourceTypes(
lineage,
- EnumSet.of(ResourceTypeRepository.MetadataType.operations,
- ResourceTypeRepository.MetadataType.children,
+ EnumSet.of(ResourceTypeRepository.MetadataType.children,
ResourceTypeRepository.MetadataType.subCategory),
new ResourceTypeRepository.ResourceTypeLoadedCallback() {
commit 4e5866feb065eb74b57482e4bbe316bc153df6d2
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Apr 7 11:47:39 2011 -0400
public opinion says remove this question box before exit
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index 3fe259e..f276417 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -158,11 +158,13 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
});
+ /* after having this enabled for a while, the majority opinion is that this is more annoying than helpful
Window.addWindowClosingHandler(new Window.ClosingHandler() {
public void onWindowClosing(Window.ClosingEvent event) {
event.setMessage("Are you sure you want to leave RHQ?");
}
});
+ */
messageCenter = new MessageCenter();
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"/>
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();
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
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">
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());
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] modules/enterprise
by Heiko W. Rupp
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java | 14 +++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
New commits:
commit e9639a9b7f4cb834a5485fd66c8cd980d6c1fbe0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 13 13:18:32 2011 +0200
BZ 693700 - prevent NPE for empty <c:list-property/>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 8b9868a..fd2decc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -450,15 +450,23 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
* the member prop def for the list. If the member prop def is a nested structure the whole thing
* is replaced from the top.
*
- * @param exList the existing prop def list
+ * @param exList the existing prop def list
* @param newList the new prop def list
*/
private void replaceListProperty(PropertyDefinitionList exList, PropertyDefinitionList newList) {
PropertyDefinition doomedMemberDef = null;
+ if (newList.getMemberDefinition()==null) {
+ log.error("\n\n!! Member definition for new list property [" + newList.getName() + "] is null - check and fix the plugin descriptor\n");
+ return;
+ }
+
+ // We did not have a member definition before (which is wrong )
+ // we need to add it now
// only remove the existing member if it is a different entity
- if (exList.getMemberDefinition().getId() != newList.getMemberDefinition().getId()) {
- doomedMemberDef = exList.getMemberDefinition();
+ PropertyDefinition exListMemberDefinition = exList.getMemberDefinition();
+ if (exListMemberDefinition !=null && exListMemberDefinition.getId() != newList.getMemberDefinition().getId()) {
+ doomedMemberDef = exListMemberDefinition;
}
exList.setMemberDefinition(newList.getMemberDefinition());
13 years, 1 month
[rhq] Branch 'as7plugin' - 3 commits - modules/enterprise modules/plugins
by Heiko W. Rupp
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java | 14
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 2
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java | 230 ++++++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 1
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java | 86 +--
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java | 137 +----
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java | 42 +
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 15
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java | 37 +
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java | 2
10 files changed, 403 insertions(+), 163 deletions(-)
New commits:
commit 7660aec86b71f0c90945bfacf8f9831af4de11dd
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 13 13:18:32 2011 +0200
BZ 693700 - prevent NPE for empty <c:list-property/>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 8b9868a..fd2decc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -450,15 +450,23 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
* the member prop def for the list. If the member prop def is a nested structure the whole thing
* is replaced from the top.
*
- * @param exList the existing prop def list
+ * @param exList the existing prop def list
* @param newList the new prop def list
*/
private void replaceListProperty(PropertyDefinitionList exList, PropertyDefinitionList newList) {
PropertyDefinition doomedMemberDef = null;
+ if (newList.getMemberDefinition()==null) {
+ log.error("\n\n!! Member definition for new list property [" + newList.getName() + "] is null - check and fix the plugin descriptor\n");
+ return;
+ }
+
+ // We did not have a member definition before (which is wrong )
+ // we need to add it now
// only remove the existing member if it is a different entity
- if (exList.getMemberDefinition().getId() != newList.getMemberDefinition().getId()) {
- doomedMemberDef = exList.getMemberDefinition();
+ PropertyDefinition exListMemberDefinition = exList.getMemberDefinition();
+ if (exListMemberDefinition !=null && exListMemberDefinition.getId() != newList.getMemberDefinition().getId()) {
+ doomedMemberDef = exListMemberDefinition;
}
exList.setMemberDefinition(newList.getMemberDefinition());
commit 71fef20671e86e28c40c4ac5cf923d5a32971bcb
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 13 13:10:13 2011 +0200
Improve handling and detection of Domain and managed servers.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index cdf7edb..d58f0c9 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -226,7 +226,7 @@ public class ASConnection {
} catch (IOException e) {
- e.printStackTrace(); // TODO: Customise this generated block
+ log.error("Failed to get data: " + e.getMessage() );
}
return null;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
new file mode 100644
index 0000000..7a648c9
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
@@ -0,0 +1,230 @@
+/*
+ * 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.FileInputStream;
+import java.io.InputStream;
+
+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.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.system.ProcessInfo;
+
+/**
+ * Abstract base class for some discovery related functionality - especially
+ * in the area of processes and host.xml
+ * @author Heiko W. Rupp
+ */
+public abstract class AbstractBaseDiscovery<T extends ResourceComponent> implements ResourceDiscoveryComponent<T> {
+ static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file=";
+ private static final String DJBOSS_SERVER_HOME_DIR = "-Djboss.home.dir";
+ static final int DEFAULT_MGMT_PORT = 9990;
+ protected Document hostXml;
+ protected final Log log = LogFactory.getLog(this.getClass());
+
+// private final Log log = LogFactory.getLog(AbstractBaseDiscovery.class);
+
+ protected 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 "";
+ }
+
+ 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 "";
+ }
+
+ protected HostPort 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 new HostPort();
+ }
+ NodeList mgmtInterfaces = interfaceParent.item(0).getChildNodes();
+ if (mgmtInterfaces==null || mgmtInterfaces.getLength()==0) {
+ log.warn("No <*-interface> found in host.xml");
+ return new HostPort();
+ }
+ 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);
+ HostPort hp = new HostPort();
+ hp.isLocal=true;
+ hp.port = port;
+
+ String nIf = mgmtInterface.getAttribute("interface");
+ String hostName = getInterface(nIf);
+ hp.host = hostName;
+ return hp;
+ }
+ }
+ return new HostPort();
+ }
+
+ private String getInterface(String nIf) {
+ Element host = hostXml.getDocumentElement();
+ NodeList interfaceParent = host.getElementsByTagName("interfaces");
+ if (interfaceParent ==null || interfaceParent.getLength()==0) {
+ log.warn("No <interfaces> found in host.xml");
+ return null;
+ }
+ NodeList mgmtInterfaces = interfaceParent.item(0).getChildNodes();
+ if (mgmtInterfaces==null || mgmtInterfaces.getLength()==0) {
+ log.warn("No <*-interface> found in host.xml");
+ return null;
+ }
+ 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("interface")) {
+ String name = mgmtInterface.getAttribute("name");
+ if (!name.equals(nIf))
+ continue;
+
+ NodeList nl = mgmtInterface.getChildNodes();
+ if (nl!=null) {
+ for (int j = 0 ; j < nl.getLength(); j++) {
+ if (!(nl.item(j) instanceof Element))
+ continue;
+
+ String nodeName = nl.item(j).getNodeName();
+ if (nodeName.equals("any-ipv4-address"))
+ return "0.0.0.0";
+
+ String x = ((Element) nl.item(j)).getAttribute("value");
+ return x;
+
+ // TODO check for <any> and so on
+ }
+ }
+ }
+
+ }
+ return null; // TODO: Customise this generated block
+ }
+
+ protected String findHostName() {
+ String hostName = hostXml.getDocumentElement().getAttribute("name");
+ return hostName;
+ }
+
+ protected HostPort getDomainControllerFromHostXml() {
+
+ Element host = hostXml.getDocumentElement();
+ NodeList dcParent = host.getElementsByTagName("domain-controller");
+ if (dcParent==null || dcParent.getLength()==0)
+ return new HostPort(false);
+ NodeList interfs = dcParent.item(0).getChildNodes();
+ for (int i = 0; i < interfs.getLength(); i++) {
+ if (!(interfs.item(i)instanceof Element))
+ continue;
+
+ Element interf = (Element) interfs.item(i);
+ if (interf.getNodeName().equals("local"))
+ return new HostPort();
+
+ // not local, so get the remote
+ HostPort hp = new HostPort(false);
+ hp.host = interf.getAttribute("host");
+ hp.port = Integer.parseInt(interf.getAttribute("port"));
+ return hp;
+ }
+
+ return new HostPort(false);
+ }
+
+ protected static class HostPort {
+ String host;
+ int port;
+ boolean isLocal = true;
+
+ public HostPort() {
+ host = "localhost";
+ port = DEFAULT_MGMT_PORT;
+ isLocal = true;
+ }
+
+ public HostPort(boolean local) {
+ this();
+ isLocal = local;
+ }
+
+ @Override
+ public String toString() {
+ return "HostPort{" +
+ "host='" + host + '\'' +
+ ", port=" + port +
+ ", isLocal=" + isLocal +
+ '}';
+ }
+ }
+}
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 43509b8..26e2b4a 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
@@ -101,7 +101,6 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
-// Object o = connection.getLevelData("", false); // BASE entries
myServerName = context.getResourceKey().substring(context.getResourceKey().lastIndexOf("/")+1);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
index 07c1522..667b3ee 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
@@ -18,29 +18,28 @@
*/
package org.rhq.modules.plugins.jbossas7;
-import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
+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.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.ObjectMapper;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.system.ProcessInfo;
/**
- * Discover the domain
+ * Discover the domain. This is done by scanning for host controllers.
+ * If they are also DC, the domain-controller element points to local.
*
* @author Heiko W. Rupp
*/
@SuppressWarnings("unused")
-public class DomainDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+public class DomainDiscovery extends AbstractBaseDiscovery<BaseComponent> {
private final Log log = LogFactory.getLog(this.getClass());
@@ -49,50 +48,45 @@ public class DomainDiscovery implements ResourceDiscoveryComponent<BaseComponent
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
- mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
- // TODO get next from some host.xml file
- String host = "localhost";
- String portString = "9990";
- int port = Integer.parseInt(portString);
- ASConnection connection = new ASConnection(host,port);
+ List<ProcessScanResult> scans = context.getAutoDiscoveredProcesses();
+ for (ProcessScanResult psr : scans) {
- Configuration config = context.getDefaultPluginConfiguration();
+ // get the HostController, to find host.xml
+ 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 domain controller info from there
+ ProcessInfo processInfo = psr.getProcessInfo();
+ readHostXml(processInfo);
+ HostPort dcHp = getDomainControllerFromHostXml();
- // A domain has a server group so check for it.
- boolean found = false;
- JsonNode json = connection.getLevelData(null,null);
- if (!ASConnection.isErrorReply(json)) {
-
- Iterator<String> fields = json.getFieldNames();
- while (fields.hasNext()) {
- String field = fields.next();
- if (field.equals("server-group"))
- found=true;
-
- }
-
- if (found) {
-
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // DataType
- "Domain", // Key
- "Domain", // Name
- null, // Version
- context.getResourceType().getDescription(), // Description
- config,
- null);
- details.add(detail);
+ if (!dcHp.isLocal) {
+ log.info("Domain controller is not local, but at " + dcHp);
+ continue;
}
- return details;
+ // Ok, this is a domain controller, so we can return a Domain resource.
+
+ // Get the management port and save for later use
+ HostPort managementHostPort = getManagementPortFromHostXml();
+ Configuration config = context.getDefaultPluginConfiguration();
+ config.put(new PropertySimple("port",managementHostPort.port));
+ config.put(new PropertySimple("hostname",managementHostPort.host));
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ "Domain", // Key
+ "Domain", // Name
+ null, // Version
+ context.getResourceType().getDescription(), // Description
+ config,
+ null);
+ details.add(detail);
}
-
- return Collections.emptySet();
+ return details;
}
-
-}
+}
\ No newline at end of file
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
index 86e3b99..2fa711c 100644
--- 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
@@ -19,20 +19,12 @@
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;
@@ -43,7 +35,6 @@ 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;
@@ -52,18 +43,10 @@ import org.rhq.core.system.ProcessInfo;
*
* @author Heiko W. Rupp
*/
-public class ManagedASDiscovery implements ResourceDiscoveryComponent
+public class ManagedASDiscovery extends AbstractBaseDiscovery
{
- 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
*/
@@ -85,7 +68,7 @@ public class ManagedASDiscovery implements ResourceDiscoveryComponent
ProcessInfo processInfo = psr.getProcessInfo();
readHostXml(processInfo);
String hostName = findHostName();
- int port = getManagementPortFromHostXml();
+ HostPort managementHostPort = getManagementPortFromHostXml();
List<ServerInfo> serverNames = getServersFromHostXml();
@@ -94,7 +77,15 @@ public class ManagedASDiscovery implements ResourceDiscoveryComponent
Configuration config = discoveryContext.getDefaultPluginConfiguration();
config.put(new PropertySimple("domainHost",hostName));
config.put(new PropertySimple("group",serverInfo.group));
- config.put(new PropertySimple("port",port));
+ config.put(new PropertySimple("port",managementHostPort.port));
+ config.put(new PropertySimple("hostname",managementHostPort.host));
+ if (serverInfo.bindingGroup!=null)
+ config.put(new PropertySimple("socket-binding-group",serverInfo.bindingGroup));
+ else
+ config.put(new PropertySimple("socket-binding-group", "standard-sockets")); // TODO remove when AS has no more "undefined"
+ config.put(new PropertySimple("socket-binding-port-offset",serverInfo.portOffset));
+
+
// TODO this fails for the downed servers.
// get from the domain or other place as soon as the domain provides it.
@@ -140,32 +131,6 @@ public class ManagedASDiscovery implements ResourceDiscoveryComponent
}
}
- 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();
@@ -193,70 +158,30 @@ public class ManagedASDiscovery implements ResourceDiscoveryComponent
autoStart = "false";
info.autoStart = Boolean.getBoolean(autoStart);
- result.add(info);
- }
-
- return result;
- }
+ // Look for <socket-binding-group ref="standard-sockets" port-offset="250"/>
+ NodeList sbgs = server.getChildNodes();
+ if (sbgs!=null) {
+ for (int j = 0 ; j < sbgs.getLength(); j++) {
+ if (!(sbgs.item(j) instanceof Element))
+ continue;
+ Element sbg = (Element) sbgs.item(j);
+ if (!sbg.getNodeName().equals("socket-binding-group"))
+ continue;
- private String findHostName() {
- String hostName = hostXml.getDocumentElement().getAttribute("name");
- return hostName;
- }
+ info.bindingGroup = sbg.getAttribute("ref");
+ String portOffset = sbg.getAttribute("port-offset");
+ if (portOffset!=null && !portOffset.isEmpty())
+ info.portOffset = Integer.parseInt(portOffset);
- 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
+ }
+ }
+ result.add(info);
}
- }
-
- /**
- * 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 "";
+ return result;
}
-//-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) {
@@ -278,12 +203,12 @@ public class ManagedASDiscovery implements ResourceDiscoveryComponent
}
}
- private class ServerInfo {
+ private static class ServerInfo {
String name;
String group;
boolean autoStart;
-
-
+ int portOffset;
+ String bindingGroup;
}
}
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 099d1b9..e75507a 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
@@ -114,6 +114,15 @@
<subcategory name="Web"/>
</subcategories>
+ <plugin-configuration>
+ <c:simple-property name="hostname" default="localhost" displayName="Management host" required="true"/>
+ <c:simple-property name="port" default="9990" type="integer" displayName="Management port" required="true"/>
+ </plugin-configuration>
+
+ <!-- Scan for host controller is intentional -->
+ <process-scan name="HostController" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
+
+
<operation name="server-group:add" displayName="Add ServerGroup" description="Add a server group to the Domain.">
<parameters>
<c:simple-property name="name" description="Name of Group to add"/>
@@ -251,10 +260,12 @@
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="hostname" default="localhost" displayName="Management host" required="true"/>
+ <c:simple-property name="port" default="9990" type="integer" displayName="Management port" 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."/>
+ <c:simple-property name="socket-binding-group" readOnly="true" displayName="Socket binding group" description="Socket bindngs to use"/>
+ <c:simple-property name="socket-binding-port-offset" readOnly="true" displayName="Port Offset" type="integer" default="0" description="Offset to the base ports"/>
&logSources;
</plugin-configuration>
commit c629ea66985a1d2f161ba625f8622024e121a23e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 13 13:09:23 2011 +0200
Improve Result handling.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
index 2d011fd..a87a6f8 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
@@ -18,11 +18,15 @@
*/
package org.rhq.modules.plugins.jbossas7.json;
+import java.util.List;
+import java.util.Map;
+
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/**
- * {"outcome" : "success", "result" : "no metrics available", "compensating-operation" : null}
+ * Counterpart of a result JSON object like e.g.:
+ * <pre>{"outcome" : "success", "result" : "no metrics available", "compensating-operation" : null}</pre>
* @author Heiko W. Rupp
*/
public class Result {
@@ -30,7 +34,13 @@ public class Result {
private String outcome;
private Object result;
@JsonProperty("compensating-operation")
- private Object compensatingOperation;
+ private Operation compensatingOperation;
+ @JsonProperty("failure-description")
+ private List<Map<String, String>> failureDescription;
+ @JsonProperty("host-failure-description") // TODO JBAS-9182
+ private List<Map<String, String>> hostFailureDescription;
+ @JsonProperty("domain-failure-description") // TODO JBAS-9182
+ private List<Map<String, String>> domainFailureDescription;
@JsonIgnore
private boolean success = false;
@@ -60,11 +70,35 @@ public class Result {
this.result = result;
}
- public Object getCompensatingOperation() {
+ public Operation getCompensatingOperation() {
return compensatingOperation;
}
- public void setCompensatingOperation(Object compensatingOperation) {
+ public void setCompensatingOperation(Operation compensatingOperation) {
this.compensatingOperation = compensatingOperation;
}
+
+ public List<Map<String, String>> getFailureDescription() {
+ return failureDescription;
+ }
+
+ public void setFailureDescription(List<Map<String, String>> failureDescription) {
+ this.failureDescription = failureDescription;
+ }
+
+ public List<Map<String, String>> getHostFailureDescription() {
+ return hostFailureDescription;
+ }
+
+ public void setHostFailureDescription(List<Map<String, String>> hostFailureDescription) {
+ this.hostFailureDescription = hostFailureDescription;
+ }
+
+ public List<Map<String, String>> getDomainFailureDescription() {
+ return domainFailureDescription;
+ }
+
+ public void setDomainFailureDescription(List<Map<String, String>> domainFailureDescription) {
+ this.domainFailureDescription = domainFailureDescription;
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 64d9d30..34d722c 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -141,6 +141,23 @@ public class OperationJsonTest {
assert result != null;
assert result.getOutcome().equals("success");
assert result.isSuccess();
+ assert result.getFailureDescription() == null;
+ }
+ public void simpleResultWithFailure() throws Exception {
+
+ String resultString = "{\"outcome\" : \"failed\", \"failure-description\" : [{ \"java.util.NoSuchElementException\" : \"No child 'profile' exists\" }]}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ Result result = mapper.readValue(resultString,Result.class);
+
+ assert result != null;
+ assert result.getOutcome().equals("failed");
+ assert !result.isSuccess();
+
+ assert result.getResult() == null;
+ assert result.getCompensatingOperation() == null;
+ assert result.getFailureDescription() != null;
+ assert result.getFailureDescription().size() == 1;
}
public void complexResult1() throws Exception {
@@ -162,4 +179,24 @@ public class OperationJsonTest {
assert aliases.size()==1;
assert aliases.get(0).equals("example.com");
}
+
+ public void compensatingOp() throws Exception {
+
+ String resultString = "{\"outcome\" : \"success\", \"result\" : null, \"compensating-operation\" : {\"operation\" : \"remove\", \"address\" : [{\"deployment\" : \"test.war\"}]}}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ Result result = mapper.readValue(resultString,Result.class);
+
+ assert result != null;
+ assert result.getOutcome().equals("success");
+ assert result.isSuccess();
+
+ assert result.getCompensatingOperation()!=null;
+
+ Operation op = result.getCompensatingOperation();
+
+ assert op.getOperation().equals("remove");
+
+ }
+
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index 11e25ad..a519e97 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -43,6 +43,7 @@ public class UploadAndDeployTest {
static final String TEST_WAR = "test.war";
private static final String UPLOAD_FILE = "test-simple.war";
+ @Test(timeOut = 60*1000L)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -101,6 +102,7 @@ public class UploadAndDeployTest {
}
+ @Test(timeOut = 60*1000L)
public void testUploadComposite() throws Exception {
String bytes_value = prepare();
13 years, 1 month
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java | 79 +++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestUserPreferencesView.java | 171 ++++++++++
2 files changed, 237 insertions(+), 13 deletions(-)
New commits:
commit 0a3b269072e34738482a5690325d11a83d82c58b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Apr 12 16:05:57 2011 -0400
add to our #Test page some iframes to the sql, hibernate and other test jsps useful to devs
add a new "user preferences" test page so you can see the current user's preferences
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 054974a..1844270 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.Label;
+
+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;
@@ -65,10 +66,19 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
private static final ViewName PAGE_GROUP_CONFIG_EDITOR = new ViewName("GroupConfigEditor");
private static final ViewName PAGE_READONLY_GROUP_CONFIG_EDITOR = new ViewName("ReadOnlyGroupConfigEditor");
+ // view IDs for Server Access section
+ private static final ViewName SERVERACCESS_SECTION_VIEW_ID = new ViewName("ServerAccess");
+ private static final ViewName PAGE_REMOTE_SERVICE_STATISTICS = new ViewName("RemoteServiceStatistics");
+ private static final ViewName PAGE_SQL = new ViewName("SQL");
+ private static final ViewName PAGE_HIBERNATE = new ViewName("Hibernate");
+ private static final ViewName PAGE_ENTITY_BROWSER = new ViewName("EntityBrowser");
+ private static final ViewName PAGE_EMAIL = new ViewName("EmailTest");
+ private static final ViewName PAGE_AGENT = new ViewName("AgentConnectivityTest");
+ private static final ViewName PAGE_USER_PREFERENCES = new ViewName("UserPreferences");
+
// view IDs for Misc section
private static final ViewName MISC_SECTION_VIEW_ID = new ViewName("Misc");
private static final ViewName PAGE_PLURALIZATION_TEST = new ViewName("PluralizationTest");
- private static final ViewName PAGE_REMOTE_SERVICE_STATISTICS = new ViewName("RemoteServiceStatistics");
private static final ViewName PAGE_ASYNC = new ViewName("Async");
public TestTopView() {
@@ -81,7 +91,7 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
vLayout.setWidth100();
// TODO: Help icon.
- TitleBar titleBar = new TitleBar(this, MSG.view_testTop_title());
+ TitleBar titleBar = new TitleBar(this, MSG.view_testTop_title());
vLayout.addMember(titleBar);
Label label = new Label(MSG.view_testTop_description());
@@ -101,6 +111,9 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
NavigationSection configurationSection = buildConfigurationSection();
sections.add(configurationSection);
+ NavigationSection serverAccessSection = buildServerAccessSection();
+ sections.add(serverAccessSection);
+
NavigationSection miscSection = buildMiscSection();
sections.add(miscSection);
@@ -161,10 +174,10 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
groupConfigEditorItem, readOnlyGroupConfigEditorItem);
}
- private NavigationSection buildMiscSection() {
- NavigationItem pluralizationItem = new NavigationItem(PAGE_PLURALIZATION_TEST, null, new ViewFactory() {
+ private NavigationSection buildServerAccessSection() {
+ NavigationItem userPrefsItem = new NavigationItem(PAGE_USER_PREFERENCES, null, new ViewFactory() {
public Canvas createView() {
- return new TestPluralizationView(extendLocatorId(PAGE_PLURALIZATION_TEST.getName()));
+ return new TestUserPreferencesView(extendLocatorId(PAGE_USER_PREFERENCES.getName()));
}
});
@@ -176,14 +189,54 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
}
});
- NavigationItem asyncItem = new NavigationItem(PAGE_ASYNC, null,
- new ViewFactory() {
- public Canvas createView() {
- return new TestAsyncView(extendLocatorId(PAGE_ASYNC.getName()));
- }
- });
+ NavigationItem sqlItem = new NavigationItem(PAGE_SQL, null, new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_SQL.getName()), "/admin/test/sql.jsp");
+ }
+ });
+
+ NavigationItem hibernateItem = new NavigationItem(PAGE_HIBERNATE, null, new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_HIBERNATE.getName()), "/admin/test/hibernate.jsp");
+ }
+ });
+
+ NavigationItem entityBrowserItem = new NavigationItem(PAGE_ENTITY_BROWSER, null, new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_ENTITY_BROWSER.getName()), "/admin/test/browser.jsp");
+ }
+ });
+
+ NavigationItem emailItem = new NavigationItem(PAGE_EMAIL, null, new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_EMAIL.getName()), "/admin/test/email.jsp");
+ }
+ });
+
+ NavigationItem agentItem = new NavigationItem(PAGE_AGENT, null, new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_AGENT.getName()), "/admin/test/agent.jsp");
+ }
+ });
+
+ return new NavigationSection(SERVERACCESS_SECTION_VIEW_ID, remoteServiceStatisticsItem, sqlItem, hibernateItem,
+ entityBrowserItem, emailItem, agentItem, userPrefsItem);
+ }
+
+ private NavigationSection buildMiscSection() {
+ NavigationItem pluralizationItem = new NavigationItem(PAGE_PLURALIZATION_TEST, null, new ViewFactory() {
+ public Canvas createView() {
+ return new TestPluralizationView(extendLocatorId(PAGE_PLURALIZATION_TEST.getName()));
+ }
+ });
+
+ NavigationItem asyncItem = new NavigationItem(PAGE_ASYNC, null, new ViewFactory() {
+ public Canvas createView() {
+ return new TestAsyncView(extendLocatorId(PAGE_ASYNC.getName()));
+ }
+ });
- return new NavigationSection(MISC_SECTION_VIEW_ID, pluralizationItem, remoteServiceStatisticsItem, asyncItem);
+ return new NavigationSection(MISC_SECTION_VIEW_ID, pluralizationItem, asyncItem);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestUserPreferencesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestUserPreferencesView.java
new file mode 100644
index 0000000..3c1e768
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestUserPreferencesView.java
@@ -0,0 +1,171 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.test;
+
+import java.util.Map;
+
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.RecordList;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.types.SortDirection;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+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.util.preferences.UserPreferences;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+
+public class TestUserPreferencesView extends Table {
+
+ // these are used both as the name of the fields, titles of the headers and the columns of the CSV output
+ private static final String FIELD_NAME = "Name";
+ private static final String FIELD_VALUE = "Value";
+
+ private static final SortSpecifier[] defaultSorts = new SortSpecifier[] { new SortSpecifier(FIELD_NAME,
+ SortDirection.DESCENDING) };
+
+ private final UserPreferences prefs;
+
+ private static String getTableTitle() {
+ return "User Preferences (" + UserSessionManager.getSessionSubject().getName() + ")";
+ }
+
+ public TestUserPreferencesView(String locatorId) {
+ super(locatorId, getTableTitle(), null, defaultSorts, null, false);
+ prefs = UserSessionManager.getUserPreferences();
+ }
+
+ @Override
+ protected void configureTable() {
+ ListGridField id = new ListGridField(FIELD_ID, "ID");
+ ListGridField name = new ListGridField(FIELD_NAME, "Name");
+ ListGridField value = new ListGridField(FIELD_VALUE, "Value");
+
+ id.setWidth("10%");
+ name.setWidth("45%");
+ name.setWidth("45%");
+
+ getListGrid().setFields(id, name, value);
+ refresh();
+
+ addTableAction(extendLocatorId("export"), "Export To CSV",
+ new AbstractTableAction(TableActionEnablement.ALWAYS) {
+ @Override
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ final String s = "~";
+ StringBuilder csv = new StringBuilder();
+ csv.append(FIELD_ID).append(s).append(FIELD_NAME).append(s).append(FIELD_VALUE).append('\n');
+
+ RecordList records = getListGrid().getDataAsRecordList();
+ int recordsSize = records.getLength();
+ for (int i = 0; i < recordsSize; i++) {
+ Record record = records.get(i);
+ csv.append(record.getAttribute(FIELD_ID)).append(s).append(record.getAttribute(FIELD_NAME))
+ .append(s).append(record.getAttribute(FIELD_VALUE)).append('\n');
+ }
+
+ new MessageWindow(extendLocatorId("csv"), "Export To CSV", "<pre>" + csv.toString() + "</pre>")
+ .show();
+ }
+ });
+ }
+
+ @Override
+ protected SelectionStyle getDefaultSelectionStyle() {
+ return SelectionStyle.NONE;
+ }
+
+ @Override
+ public void refresh() {
+ super.refresh();
+ getListGrid().setRecords(transform(this.prefs.getConfiguration()));
+ }
+
+ private ListGridRecord[] transform(Configuration configuration) {
+ ListGridRecord[] results = new ListGridRecord[configuration.getAllProperties().size()];
+ int i = 0;
+ for (Map.Entry<String, Property> entry : configuration.getAllProperties().entrySet()) {
+ results[i++] = transform(entry.getValue());
+ }
+ return results;
+ }
+
+ private ListGridRecord transform(Property prop) {
+ String value;
+ if (prop instanceof PropertySimple) {
+ value = ((PropertySimple) prop).getStringValue();
+ } else {
+ String classname = prop.getClass().getName();
+ value = "(value of type " + classname.substring(classname.lastIndexOf(".") + 1) + ")";
+ }
+
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(FIELD_ID, prop.getId());
+ record.setAttribute(FIELD_NAME, prop.getName());
+ record.setAttribute(FIELD_VALUE, value);
+ return record;
+ }
+
+ class MessageWindow extends LocatableWindow {
+ public MessageWindow(String locatorId, String title, String message) {
+ super(locatorId);
+
+ LocatableHTMLPane htmlPane = new LocatableHTMLPane(extendLocatorId("winDetailsPane"));
+ htmlPane.setMargin(10);
+ htmlPane.setDefaultWidth(600);
+ htmlPane.setDefaultHeight(400);
+ htmlPane.setContents(message);
+
+ setTitle(title);
+ setShowMinimizeButton(false);
+ setShowMaximizeButton(true);
+ setShowCloseButton(true);
+ setDismissOnEscape(false); // force close button to be pressed to ensure our close handler is called
+ setIsModal(true);
+ setShowModalMask(true);
+ setAutoSize(true);
+ setAutoCenter(true);
+ setShowResizer(true);
+ setCanDragResize(true);
+ centerInPage();
+ addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ markForDestroy();
+ }
+ });
+ addItem(htmlPane);
+ }
+ }
+}
13 years, 1 month
[rhq] modules/core modules/enterprise
by Jay Shaughnessy
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java | 34
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java | 50 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java | 22
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java | 76 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 45 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 30
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/AuthorizedButton.java | 78 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EditableFormItem.java | 260 -------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableFormItem.java | 345 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableTextAreaFormItem.java | 53 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java | 18
19 files changed, 674 insertions(+), 397 deletions(-)
New commits:
commit 1b76728da8c05cb9efe2ea04a5e6a677e98166af
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 12 12:56:37 2011 -0400
Alert Definition Work
- Fix button enablement issues [BZ 694912 - Can't create new Alert Template, edit button is disabled]
This boiled down to an async issue where it was not guaranteed that
the global perms would be loaded prior to providing them for enablement
purposes. made template view like resource and group and now provides the
perms in the constructor, guranteeing existence.
-- Note, went down the wrong path for a while and ended up adding a
AuthorizedButton class. Not currently used but has built in global auth
check for a standalone button.
-- also made an analogous fix to metric template button enablement.
- Fixed issue where the escape character was presented as the value
for editable string fields with no value yet set. Factored out new base class
SimpleEditableFormItem from EditableFormItem to provide support for
a read/write field without the in-field editing/icons. This allowed
more central handling of being able to turn on/off HTML output for
text fields.
-- note, also fixed this in a few more places that don't use
the editable form item classes.
- Fix the fact that a non-perm user could nav to template view but then not
see any alert templates in the list. Then, furthermore add the ability to
inspect the detail.
-- this required an underlying fix to the alert def criteria search, which
was too aggresively filtering on resource authz. alert def templates and
group alert defs don't have a resource and therfore that authz
token will always force an empty result set.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
index e0b3d20..31f76a1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
@@ -47,6 +47,7 @@ public class AlertDefinitionCriteria extends Criteria {
private String filterName;
private String filterDescription;
private AlertPriority filterPriority;
+ private NonBindingOverrideFilter filterAlertTemplateOnly; // requires overrides - finds only alert templates
private Integer filterAlertTemplateParentId; // requires overrides
private Integer filterAlertTemplateResourceTypeId; // requires overrides
private String filterAlertTemplateResourceTypeName; // requires overrides
@@ -55,9 +56,8 @@ public class AlertDefinitionCriteria extends Criteria {
private Boolean filterEnabled;
private Boolean filterDeleted = false; // find enabled definitions by default
private NonBindingOverrideFilter filterResourceOnly; // requires overrides - finds only those associated with a resource
- private NonBindingOverrideFilter filterResourceTypeOnly; // requires overrides - finds only alert templates
private List<String> filterNotificationSenderNames;
-
+
private boolean fetchAlerts;
private boolean fetchGroupAlertDefinition;
private boolean fetchConditions;
@@ -68,17 +68,16 @@ public class AlertDefinitionCriteria extends Criteria {
private PageOrdering sortName;
private PageOrdering sortPriority;
- public AlertDefinitionCriteria() {
+ public AlertDefinitionCriteria() {
+ filterOverrides.put("alertTemplateOnly", "resourceType IS NOT NULL");
filterOverrides.put("alertTemplateParentId", "parentId = ?");
filterOverrides.put("alertTemplateResourceTypeId", "resourceType.id = ?");
filterOverrides.put("alertTemplateResourceTypeName", "resourceType.name like ?");
filterOverrides.put("resourceIds", "resource.id IN ( ? )");
filterOverrides.put("resourceGroupIds", "resourceGroup.id IN ( ? )");
filterOverrides.put("resourceOnly", "resource IS NOT NULL");
- filterOverrides.put("resourceTypeOnly", "resourceType IS NOT NULL");
- filterOverrides.put("notificationSenderNames", "id IN (" +
- "SELECT notif.alertDefinition.id FROM AlertNotification notif " +
- "WHERE notif.senderName IN ( ? ))");
+ filterOverrides.put("notificationSenderNames", "id IN ("
+ + "SELECT notif.alertDefinition.id FROM AlertNotification notif " + "WHERE notif.senderName IN ( ? ))");
filterOverrides.put("filterIds", "id IN ( ? )");
}
@@ -94,7 +93,7 @@ public class AlertDefinitionCriteria extends Criteria {
public void addFilterIds(Integer... filterIds) {
this.filterIds = Arrays.asList(filterIds);
}
-
+
public void addFilterName(String filterName) {
this.filterName = filterName;
}
@@ -139,8 +138,8 @@ public class AlertDefinitionCriteria extends Criteria {
this.filterResourceOnly = (filterResourceOnly ? NonBindingOverrideFilter.ON : NonBindingOverrideFilter.OFF);
}
- public void addFilterResourceTypeOnly(boolean filterResourceTypeOnly) {
- this.filterResourceTypeOnly = (filterResourceTypeOnly ? NonBindingOverrideFilter.ON
+ public void addFilterAlertTemplateOnly(boolean filterAlertTemplateOnly) {
+ this.filterAlertTemplateOnly = (filterAlertTemplateOnly ? NonBindingOverrideFilter.ON
: NonBindingOverrideFilter.OFF);
}
@@ -148,7 +147,7 @@ public class AlertDefinitionCriteria extends Criteria {
fetchAlertNotifications(true);
this.filterNotificationSenderNames = Arrays.asList(notificationNames);
}
-
+
public void fetchAlerts(boolean fetchAlerts) {
this.fetchAlerts = fetchAlerts;
}
@@ -182,4 +181,17 @@ public class AlertDefinitionCriteria extends Criteria {
addSortField("priority");
this.sortPriority = sortPriority;
}
+
+ public boolean isTemplateCriteria() {
+ return null != filterAlertTemplateOnly //
+ || null != filterAlertTemplateParentId //
+ || null != filterAlertTemplateResourceTypeId //
+ || null != filterAlertTemplateResourceTypeName;
+
+ }
+
+ public boolean isGroupCriteria() {
+ return null != filterResourceGroupIds;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
index 3daa669..fecac0b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.admin.templates;
import java.util.Map;
+import java.util.Set;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.Alignment;
@@ -39,12 +40,15 @@ import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeGridField;
import com.smartgwt.client.widgets.tree.TreeNode;
+import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
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.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.admin.AdministrationView;
@@ -215,25 +219,35 @@ public class ResourceTypeTreeView extends LocatableVLayout implements Bookmarkab
private void editAlertTemplate(int resourceTypeId, final ViewPath viewPath) {
final Integer[] idArray = new Integer[] { resourceTypeId };
ResourceTypeRepository.Cache.getInstance().getResourceTypes(idArray, new TypesLoadedCallback() {
- @Override
- public void onTypesLoaded(Map<Integer, ResourceType> types) {
- ResourceType rt = types.get(idArray[0]);
- Layout alertCanvas = getAlertTemplateCanvas();
- String locatorId = extendLocatorId("alertTemplateDef");
- TemplateAlertDefinitionsView def = new TemplateAlertDefinitionsView(locatorId, rt);
- def.renderView(viewPath.next());
- prepareSubCanvas(alertCanvas, def, viewPath.isEnd()); // don't show our back button if we are going to a template details pane which has its own back button
- switchToCanvas(ResourceTypeTreeView.this, alertCanvas);
+
+ public void onTypesLoaded(final Map<Integer, ResourceType> types) {
+ new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
+
+ public void onPermissionsLoaded(Set<Permission> permissions) {
+ ResourceType rt = types.get(idArray[0]);
+ Layout alertCanvas = getAlertTemplateCanvas();
+ String locatorId = extendLocatorId("alertTemplateDef");
+ TemplateAlertDefinitionsView def = new TemplateAlertDefinitionsView(locatorId, rt, permissions);
+ def.renderView(viewPath.next());
+ prepareSubCanvas(alertCanvas, def, viewPath.isEnd()); // don't show our back button if we are going to a template details pane which has its own back button
+ switchToCanvas(ResourceTypeTreeView.this, alertCanvas);
+ }
+ });
}
});
}
- private void editMetricTemplate(int resourceTypeId) {
- Layout metricCanvas = getMetricTemplateCanvas();
- TemplateSchedulesView templateSchedulesView = new TemplateSchedulesView(extendLocatorId("MetricTemplate"),
- resourceTypeId);
- prepareSubCanvas(metricCanvas, templateSchedulesView, true);
- switchToCanvas(ResourceTypeTreeView.this, metricCanvas);
+ private void editMetricTemplate(final int resourceTypeId) {
+ new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
+
+ public void onPermissionsLoaded(Set<Permission> permissions) {
+ Layout metricCanvas = getMetricTemplateCanvas();
+ TemplateSchedulesView templateSchedulesView = new TemplateSchedulesView(
+ extendLocatorId("MetricTemplate"), resourceTypeId, permissions);
+ prepareSubCanvas(metricCanvas, templateSchedulesView, true);
+ switchToCanvas(ResourceTypeTreeView.this, metricCanvas);
+ }
+ });
}
public class CustomResourceTypeListGrid extends LocatableListGrid {
@@ -287,8 +301,8 @@ public class ResourceTypeTreeView extends LocatableVLayout implements Bookmarkab
enabledMetricTemplatesField.setPrompt(MSG.view_adminTemplates_prompt_enabledMetricTemplates());
disabledMetricTemplatesField.setPrompt(MSG.view_adminTemplates_prompt_disabledMetricTemplates());
- setFields(nameField, pluginField, categoryField, enabledAlertTemplatesField, disabledAlertTemplatesField, enabledMetricTemplatesField,
- disabledMetricTemplatesField);
+ setFields(nameField, pluginField, categoryField, enabledAlertTemplatesField, disabledAlertTemplatesField,
+ enabledMetricTemplatesField, disabledMetricTemplatesField);
}
@Override
@@ -401,7 +415,7 @@ public class ResourceTypeTreeView extends LocatableVLayout implements Bookmarkab
disabledMetricTemplatesField.setPrompt(MSG.view_adminTemplates_prompt_disabledMetricTemplates());
setFields(nameField, pluginField, categoryField, enabledAlertTemplatesField, disabledAlertTemplatesField,
- enabledMetricTemplatesField, disabledMetricTemplatesField);
+ enabledMetricTemplatesField, disabledMetricTemplatesField);
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java
index c9a4226..4e21fa9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java
@@ -18,17 +18,14 @@
*/
package org.rhq.enterprise.gui.coregui.client.admin.templates;
+import java.util.Set;
+
import com.smartgwt.client.data.Criteria;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.criteria.MeasurementScheduleCriteria;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView;
-import java.util.EnumSet;
-import java.util.Set;
-
/**
* A view for viewing and updating the default metric schedules ("metric templates") for a particular ResourceType.
*
@@ -42,27 +39,17 @@ public class TemplateSchedulesView extends AbstractMeasurementScheduleListView {
private boolean updateExistingSchedules = true;
private Set<Permission> globalPermissions;
- public TemplateSchedulesView(String locatorId, int resourceTypeId) {
+ public TemplateSchedulesView(String locatorId, int resourceTypeId, Set<Permission> globalPermissions) {
super(locatorId, TITLE, new TemplateSchedulesDataSource(resourceTypeId), createCriteria(resourceTypeId),
EXCLUDED_FIELD_NAMES);
- this.globalPermissions = EnumSet.noneOf(Permission.class);
- loadGlobalPermissions();
+ this.globalPermissions = globalPermissions;
}
public boolean hasManageMeasurementsPermission() {
- loadGlobalPermissions();
return globalPermissions.contains(Permission.MANAGE_INVENTORY);
}
- private void loadGlobalPermissions() {
- new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
- public void onPermissionsLoaded(Set<Permission> permissions) {
- globalPermissions = permissions;
- }
- });
- }
-
private static Criteria createCriteria(int resourceTypeId) {
Criteria criteria = new Criteria();
criteria.addCriteria(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID, resourceTypeId);
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 c3f817b..aac1626 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
@@ -75,11 +75,11 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
ListGridField descriptionField = listGrid.getField(AbstractAlertDefinitionsDataSource.FIELD_DESCRIPTION);
descriptionField.setCellFormatter(new EscapedHtmlCellFormatter());
- boolean permitted = isAllowedToModifyAlertDefinitions();
+ final boolean isAuthorized = isAuthorizedToModifyAlertDefinitions();
addTableAction(extendLocatorId("New"), MSG.common_button_new(), null, new AbstractTableAction() {
public boolean isEnabled(ListGridRecord[] selection) {
- return super.isEnabled(selection) && isAllowedToModifyAlertDefinitions();
+ return super.isEnabled(selection) && isAuthorized;
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -90,7 +90,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
addTableAction(extendLocatorId("Enable"), MSG.common_button_enable(), MSG
.view_alert_definitions_enable_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
public boolean isEnabled(ListGridRecord[] selection) {
- return super.isEnabled(selection) && isAllowedToModifyAlertDefinitions();
+ return super.isEnabled(selection) && isAuthorized;
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -101,7 +101,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
addTableAction(extendLocatorId("Disable"), MSG.common_button_disable(), MSG
.view_alert_definitions_disable_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
public boolean isEnabled(ListGridRecord[] selection) {
- return super.isEnabled(selection) && isAllowedToModifyAlertDefinitions();
+ return super.isEnabled(selection) && isAuthorized;
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -112,7 +112,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), MSG
.view_alert_definitions_delete_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
public boolean isEnabled(ListGridRecord[] selection) {
- return super.isEnabled(selection) && isAllowedToModifyAlertDefinitions();
+ return super.isEnabled(selection) && isAuthorized;
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -156,7 +156,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
singleAlertDefinitionView.setAlertDefinition(newAlertDef);
singleAlertDefinitionView.makeEditable();
} else {
- final AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
+ final AlertDefinitionCriteria criteria = getDetailCriteria();
criteria.addFilterId(id);
criteria.fetchGroupAlertDefinition(true);
criteria.fetchConditions(true);
@@ -179,13 +179,21 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
return singleAlertDefinitionView;
}
+ /**
+ * Override to add any criteria that must be present when fetching the alert definition detail.
+ * @return
+ */
+ protected AlertDefinitionCriteria getDetailCriteria() {
+ return new AlertDefinitionCriteria();
+ }
+
protected abstract ResourceType getResourceType();
protected abstract Criteria getCriteria();
protected abstract AbstractAlertDefinitionsDataSource getAlertDefinitionDataSource();
- protected abstract boolean isAllowedToModifyAlertDefinitions();
+ protected abstract boolean isAuthorizedToModifyAlertDefinitions();
protected abstract void newButtonPressed(ListGridRecord[] selection);
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 7d6b0d5..f154b26 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
@@ -28,12 +28,13 @@ import java.util.LinkedHashMap;
import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.form.fields.TextAreaItem;
-import com.smartgwt.client.widgets.form.fields.TextItem;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.components.form.SimpleEditableTextAreaFormItem;
+import org.rhq.enterprise.gui.coregui.client.components.form.SimpleEditableFormItem;
+import org.rhq.enterprise.gui.coregui.client.components.form.StringLengthValidator;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -43,14 +44,12 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
private AlertDefinition alertDefinition;
- private TextItem nameTextField;
- private TextAreaItem descriptionTextField;
+ private SimpleEditableFormItem nameField;
+ private SimpleEditableTextAreaFormItem descriptionField;
private SelectItem prioritySelection;
private RadioGroupItem enabledSelection;
private RadioGroupItem readOnlySelection;
- private StaticTextItem nameStatic;
- private StaticTextItem descriptionStatic;
private StaticTextItem priorityStatic;
private StaticTextItem enabledStatic;
private StaticTextItem readOnlyStatic;
@@ -91,11 +90,9 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
if (alertDef == null) {
clearFormValues();
} else {
- nameTextField.setValue(alertDef.getName());
- nameStatic.setValue(alertDef.getName());
+ nameField.setValue(alertDef.getName());
- descriptionTextField.setValue(alertDef.getDescription());
- descriptionStatic.setValue(alertDef.getDescription());
+ descriptionField.setValue(alertDef.getDescription());
prioritySelection.setValue(alertDef.getPriority().name());
priorityStatic.setValue(alertDef.getPriority().name());
@@ -112,11 +109,9 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
@Override
public void makeEditable() {
- nameTextField.show();
- nameStatic.hide();
+ nameField.switchToEditMode();
- descriptionTextField.show();
- descriptionStatic.hide();
+ descriptionField.switchToEditMode();
prioritySelection.show();
priorityStatic.hide();
@@ -144,11 +139,9 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
@Override
public void makeViewOnly() {
- nameTextField.hide();
- nameStatic.show();
+ nameField.switchToStaticMode();
- descriptionTextField.hide();
- descriptionStatic.show();
+ descriptionField.switchToStaticMode();
prioritySelection.hide();
priorityStatic.show();
@@ -176,8 +169,11 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
@Override
public void saveAlertDefinition() {
- alertDefinition.setName(nameTextField.getValue().toString());
- alertDefinition.setDescription(descriptionTextField.getValue().toString());
+ alertDefinition.setName(nameField.getValue().toString());
+ Object description = descriptionField.getValue();
+ if (null != description) {
+ alertDefinition.setDescription(description.toString());
+ }
String prioritySelected = prioritySelection.getValue().toString();
alertDefinition.setPriority(AlertPriority.valueOf(prioritySelected));
@@ -188,14 +184,12 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
@Override
public void clearFormValues() {
- nameTextField.clearValue();
- descriptionTextField.clearValue();
+ nameField.clearValue();
+ descriptionField.clearValue();
prioritySelection.clearValue();
enabledSelection.clearValue();
readOnlySelection.clearValue();
- nameStatic.clearValue();
- descriptionStatic.clearValue();
priorityStatic.clearValue();
enabledStatic.clearValue();
readOnlyStatic.clearValue();
@@ -205,19 +199,15 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
private void buildForm() {
if (!formBuilt) {
- nameTextField = new TextItem("name", MSG.common_title_name());
- 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);
+ nameField = new SimpleEditableFormItem("name", MSG.common_title_name());
+ nameField.setWidth(300);
+ StringLengthValidator notEmptyValidator = new StringLengthValidator(1, null, false);
+ // ensure these are executed in a validate() override
+ nameField.setValidators(notEmptyValidator);
+
+ descriptionField = new SimpleEditableTextAreaFormItem("description", MSG.common_title_description());
+ descriptionField.setWidth(300);
+ descriptionField.setDefaultValue("");
prioritySelection = new SelectItem("priority", MSG.view_alerts_field_priority());
LinkedHashMap<String, String> priorities = new LinkedHashMap<String, String>(3);
@@ -251,11 +241,19 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
readOnlySelection.setPrompt(MSG.view_alerts_field_protected_tooltip());
readOnlyStatic = new StaticTextItem("readOnlyStatic", MSG.view_alerts_field_protected());
- setFields(nameTextField, nameStatic, descriptionTextField, descriptionStatic, prioritySelection,
- priorityStatic, enabledSelection, enabledStatic, readOnlySelection, readOnlyStatic);
+ setFields(nameField, descriptionField, prioritySelection, priorityStatic, enabledSelection, enabledStatic,
+ readOnlySelection, readOnlyStatic);
formBuilt = true;
}
+ }
+ /**
+ * Must explicitly force outer-form validatation of EditibleFormItems.
+ */
+ @Override
+ public boolean validate() {
+ return super.validate() && nameField.validate();
}
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
index 5a68af8..dc75308 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -104,7 +104,7 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- protected boolean isAllowedToModifyAlertDefinitions() {
+ protected boolean isAuthorizedToModifyAlertDefinitions() {
return this.permissions.isAlert();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index 6ad4392..a6673e3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -104,7 +104,7 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- protected boolean isAllowedToModifyAlertDefinitions() {
+ protected boolean isAuthorizedToModifyAlertDefinitions() {
return this.permissions.isAlert();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index 2bacf3d..f276937 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -28,6 +28,8 @@ import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.tab.Tab;
+import com.smartgwt.client.widgets.tab.events.TabDeselectedEvent;
+import com.smartgwt.client.widgets.tab.events.TabDeselectedHandler;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton;
@@ -52,7 +54,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
private Button saveButton;
private Button cancelButton;
- private boolean allowedToModifyAlertDefinitions;
+ private boolean isAuthorizedToModifyAlertDefinitions;
public SingleAlertDefinitionView(String locatorId, AbstractAlertDefinitionsView alertDefView) {
this(locatorId, alertDefView, null);
@@ -63,15 +65,24 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
super(locatorId);
this.alertDefinition = alertDefinition;
- this.allowedToModifyAlertDefinitions = alertDefView.isAllowedToModifyAlertDefinitions();
+ this.isAuthorizedToModifyAlertDefinitions = alertDefView.isAuthorizedToModifyAlertDefinitions();
- LocatableTabSet tabSet = new LocatableTabSet(this.getLocatorId());
+ final LocatableTabSet tabSet = new LocatableTabSet(this.getLocatorId());
tabSet.setHeight100();
- Tab generalPropertiesTab = new LocatableTab(tabSet.extendLocatorId("General"), MSG
+ final Tab generalPropertiesTab = new LocatableTab(tabSet.extendLocatorId("General"), MSG
.view_alert_common_tab_general());
generalProperties = new GeneralPropertiesAlertDefinitionForm(this.getLocatorId(), alertDefinition);
generalPropertiesTab.setPane(generalProperties);
+ generalPropertiesTab.addTabDeselectedHandler(new TabDeselectedHandler() {
+
+ @Override
+ public void onTabDeselected(TabDeselectedEvent event) {
+ if (!generalProperties.validate()) {
+ event.cancel();
+ }
+ }
+ });
Tab conditionsTab = new LocatableTab(tabSet.extendLocatorId("Conditions"), MSG
.view_alert_common_tab_conditions());
@@ -110,7 +121,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
buttons.addMember(saveButton);
buttons.addMember(cancelButton);
- editButton.setDisabled(!allowedToModifyAlertDefinitions);
+ editButton.setDisabled(!isAuthorizedToModifyAlertDefinitions);
editButton.addClickHandler(new ClickHandler() {
@Override
@@ -122,11 +133,15 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
saveButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- saveAlertDefinition();
- setAlertDefinition(getAlertDefinition()); // loads data into static fields
- makeViewOnly();
-
- alertDefView.commitAlertDefinition(getAlertDefinition());
+ if (generalProperties.validate()) {
+ saveAlertDefinition();
+ setAlertDefinition(getAlertDefinition()); // loads data into static fields
+ makeViewOnly();
+
+ alertDefView.commitAlertDefinition(getAlertDefinition());
+ } else {
+ tabSet.selectTab(generalPropertiesTab);
+ }
}
});
@@ -160,11 +175,11 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
}
public void makeEditable() {
- if (!this.allowedToModifyAlertDefinitions) {
- // this is just a safety measure - we should never get here if we don't have perms, but just in case,
- // don't do anything to allow the def to be editable. Should we notify the message center?
- return;
- }
+ // if (!this.allowedToModifyAlertDefinitions) {
+ // this is just a safety measure - we should never get here if we don't have perms, but just in case,
+ // don't do anything to allow the def to be editable. Should we notify the message center?
+ // return;
+ // }
saveButton.show();
cancelButton.show();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
index 9e5590e..8599225 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
@@ -49,13 +49,15 @@ public class TemplateAlertDefinitionsDataSource extends AbstractAlertDefinitions
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
Criteria requestCriteria = request.getCriteria();
+ criteria.addFilterAlertTemplateOnly(true);
+
if (requestCriteria != null) {
Map values = requestCriteria.getValues();
for (Object key : values.keySet()) {
String fieldName = (String) key;
if (fieldName.equals(TemplateAlertDefinitionsView.CRITERIA_RESOURCE_TYPE_ID)) {
- Integer resourceId = (Integer) values.get(fieldName);
- criteria.addFilterAlertTemplateResourceTypeId(resourceId);
+ Integer resourceTypeId = (Integer) values.get(fieldName);
+ criteria.addFilterAlertTemplateResourceTypeId(resourceTypeId);
}
}
}
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 01f813f..337341a 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,7 +23,6 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
-import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;
@@ -33,10 +32,9 @@ 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.criteria.AlertDefinitionCriteria;
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;
@@ -53,9 +51,10 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
private ResourceType resourceType;
private Set<Permission> globalPermissions;
- public TemplateAlertDefinitionsView(String locatorId, ResourceType resourceType) {
+ public TemplateAlertDefinitionsView(String locatorId, ResourceType resourceType, Set<Permission> globalPermissions) {
super(locatorId, "Alert Templates");
this.resourceType = resourceType;
+ this.globalPermissions = globalPermissions;
// make sure we loaded all the type info we'll need. if one of these is null, either the type
// doesn't have it or we haven't loaded it yet. since we can't know for sure if it was loaded, we have to ask.
@@ -77,14 +76,11 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
});
}
+ }
- this.globalPermissions = Collections.emptySet();
- new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
- public void onPermissionsLoaded(Set<Permission> globalPermissions) {
- TemplateAlertDefinitionsView.this.globalPermissions = globalPermissions;
- refreshTableInfo();
- }
- });
+ @Override
+ protected boolean isAuthorizedToModifyAlertDefinitions() {
+ return globalPermissions.contains(Permission.MANAGE_SETTINGS);
}
@Override
@@ -115,11 +111,6 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- protected boolean isAllowedToModifyAlertDefinitions() {
- return globalPermissions.contains(Permission.MANAGE_SETTINGS);
- }
-
- @Override
protected void newButtonPressed(ListGridRecord[] selection) {
newDetails();
}
@@ -246,4 +237,11 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
});
}
}
+
+ protected AlertDefinitionCriteria getDetailCriteria() {
+ AlertDefinitionCriteria criteria = super.getDetailCriteria();
+ criteria.addFilterAlertTemplateOnly(true);
+ return criteria;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/AuthorizedButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/AuthorizedButton.java
new file mode 100644
index 0000000..ff68562
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/AuthorizedButton.java
@@ -0,0 +1,78 @@
+/*
+ * 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.buttons;
+
+import java.util.HashSet;
+import java.util.Set;
+
+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.table.AuthorizedTableAction;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton;
+
+// TODO: This utility isCurrently unused. Candidate for removal.
+
+/**
+ * This class allows for a standalone Button enablement based on global perm authorization.
+ *
+ * For buttons embedded in Table views see {@link AuthorizedTableAction}.
+ *
+ * @author Jay Shaughnessy
+ */
+public class AuthorizedButton extends LocatableButton {
+
+ HashSet<Permission> globalPermissions = new HashSet<Permission>();
+
+ Boolean isGlobalAuthorized;
+
+ public AuthorizedButton(String locatorId, String title, Permission... permissions) {
+ super(locatorId, title);
+
+ if (permissions.length == 0) {
+ throw new IllegalArgumentException("Must provide at least one Permission");
+ }
+
+ for (Permission p : permissions) {
+ switch (p.getTarget()) {
+ case GLOBAL:
+ globalPermissions.add(p);
+ break;
+ case RESOURCE:
+ throw new IllegalArgumentException("Does not support Resource permissions");
+ }
+ }
+
+ setDisabled(true);
+
+ new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
+
+ public void onPermissionsLoaded(Set<Permission> grantedPermissions) {
+ for (Permission requiredPermission : globalPermissions) {
+ if (!grantedPermissions.contains(requiredPermission)) {
+ return;
+ }
+ }
+ setDisabled(false);
+ markForRedraw();
+ }
+ });
+ }
+}
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 86f87b3..8ff3d91 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
@@ -22,8 +22,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.components.form;
-import java.util.Date;
-
import com.google.gwt.event.dom.client.KeyCodes;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.events.MouseOutEvent;
@@ -32,21 +30,14 @@ import com.smartgwt.client.widgets.events.MouseOverEvent;
import com.smartgwt.client.widgets.events.MouseOverHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.FormItemIfFunction;
-import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.FormItemIcon;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.FormItemClickHandler;
import com.smartgwt.client.widgets.form.fields.events.FormItemIconClickEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
-import com.smartgwt.client.widgets.form.validator.Validator;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.Messages;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* This form item can be used to display a value normally in "read-only" form (i.e. as a StaticTextItem),
@@ -57,47 +48,25 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*
* @author John Mazzitelli
*/
-public class EditableFormItem extends CanvasItem {
-
- protected static Messages MSG = CoreGUI.getMessages();
-
- private boolean readOnly = false;
- private boolean editing = false;
- private FormItem staticItem;
- private FormItem editItem;
- private DynamicForm innerForm;
-
- private ValueEditedHandler valueEditedHandler;
+public class EditableFormItem extends SimpleEditableFormItem {
public EditableFormItem() {
- this(null, null);
+ super();
}
public EditableFormItem(String name, String title) {
- this(name, title, null);
+ super(name, title);
}
public EditableFormItem(String name, String title, ValueEditedHandler handler) {
- if (name != null) {
- setName(name);
- }
- if (title != null) {
- setTitle(title);
- }
- if (handler != null) {
- setValueEditedHandler(handler);
- }
+ super(name, title, handler);
+ }
+
+ protected void addHandlers() {
final FormItemIcon blankIcon = createBlankIcon();
final FormItemIcon editIcon = createEditIcon();
- this.innerForm = new LocatableDynamicForm(getName() + "_innerForm");
- this.staticItem = prepareStaticFormItem();
- this.editItem = prepareEditFormItem();
- this.innerForm.setItems(staticItem, editItem);
- this.innerForm.setCanFocus(true);
- this.innerForm.setNumCols(1);
-
// 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() {
public void onMouseOut(MouseOutEvent event) {
@@ -115,9 +84,6 @@ public class EditableFormItem extends CanvasItem {
}
}
});
-
- setCanvas(this.innerForm);
- setCanFocus(true);
}
protected FormItem prepareStaticFormItem() {
@@ -135,9 +101,6 @@ public class EditableFormItem extends CanvasItem {
}
});
item.setTextBoxStyle("editableText");
- if (item instanceof StaticTextItem) {
- ((StaticTextItem)item).setOutputAsHTML(true);
- }
return item;
}
@@ -172,33 +135,6 @@ public class EditableFormItem extends CanvasItem {
return item;
}
- /**
- * This instantiates the static item. The form item created by this method will
- * be further customized by {@link #prepareStaticFormItem()}.
- *
- * @return the form item used to show the static (read-only) value
- */
- protected FormItem instantiateStaticFormItem() {
- @SuppressWarnings({"UnnecessaryLocalVariable"})
- StaticTextItem item = new StaticTextItem();
- return item;
- }
-
- /**
- * This instantiates the edit item. The form item created by this method will
- * be further customized by {@link #prepareEditFormItem()}.
- *
- * Subclasses will usually override this method to provide a different form
- * item such as a checkbox, radio buttons, etc.
- *
- * @return the form item used to edit the value
- */
- protected FormItem instantiateEditFormItem() {
- @SuppressWarnings({"UnnecessaryLocalVariable"})
- TextItem item = new TextItem();
- return item;
- }
-
protected FormItemIcon createEditIcon() {
FormItemIcon editIcon = new FormItemIcon();
editIcon.setSrc(ImageManager.getEditIcon());
@@ -248,186 +184,4 @@ public class EditableFormItem extends CanvasItem {
return blankIcon;
}
- /**
- * This sets the {@link #setEditing(boolean) edit flag} to false and ensures
- * the component switches to the static, read-only mode.
- */
- protected void switchToStaticMode() {
- if (isEditing()) {
- setEditing(false);
- markForRedraw();
- }
- }
-
- /**
- * This sets the {@link #setEditing(boolean) edit flag} to true and ensures
- * the component switches to the edit, read-write mode.
- */
- protected void switchToEditMode() {
- if (!isEditing()) {
- setEditing(true);
- setEditItemValue(this.editItem, this.staticItem.getValue());
- markForRedraw();
- }
- }
-
- protected boolean isEditing() {
- return this.editing;
- }
-
- /**
- * This just sets the internal flag indicating if the form is in editing mode.
- * To switch modes, you use {@link #switchToEditMode()} and {@link #switchToStaticMode()}.
- *
- * @param editing the new editing flag
- */
- protected void setEditing(boolean editing) {
- this.editing = editing;
- }
-
- /**
- * When the user has accepted a new edited value for this form item, this method is called.
- * This method is responsible for invoking the {@link #getValueEditedHandler() handler}.
- *
- * @param newValue the new value just accepted by the user and validated by the system
- */
- protected void setApprovedNewValue(Object newValue) {
- setStaticItemValue(this.staticItem, newValue);
- if (this.valueEditedHandler != null) {
- this.valueEditedHandler.editedValue(newValue);
- }
- }
-
- /**
- * When a user first elects to edit a value (i.e. switches from static, read-only mode
- * to edit mode), the static value needs to be converted to an object that is appropriate
- * for the edit form item value. This method performs that necessary conversion and
- * sets the edit item's value to that converted value. The converted value is also returned.
- *
- * @param editItem the edit form item whose value needs to be set
- * @param value the static value that needs to be converted and set in the given edit item
- *
- * @return the converted value that was set in the edit item
- */
- protected Object setEditItemValue(FormItem editItem, Object value) {
- String convertedValue = (value != null) ? value.toString() : null;
- editItem.setValue(convertedValue);
- return convertedValue;
- }
-
- /**
- * When a user enters and accepts a new value, the new value needs to be converted
- * to an appropriate value for display in the static, read-only item.
- * This method performs that necessary conversion and sets the static item's value
- * to that converted value. The converted value is also returned.
- *
- * @param staticItem the static form item whose value needs to be set
- * @param value the value that needs to be converted for display in the static item
- *
- * @return the converted value that was set in the static item
- */
- protected Object setStaticItemValue(FormItem staticItem, Object value) {
- String convertedValue = (value != null) ? value.toString() : null;
- staticItem.setValue(convertedValue);
- return convertedValue;
- }
-
- //
- // Below are delegating methods to setValue().
- // When setting this form item's value, we are really setting the static item's value.
- //
-
- @Override
- public void setValue(boolean value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public void setValue(Date value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public void setValue(double value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public void setValue(float value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public void setValue(int value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public void setValue(Object value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public void setValue(String value) {
- this.staticItem.setValue(value);
- }
-
- @Override
- public Object getValue() {
- return this.staticItem.getValue();
- }
-
- //
- // this delegates to the edit item allowing custom validators to be added
- //
-
- @Override
- public void setValidators(Validator... validators) {
- this.editItem.setValidators(validators);
- }
-
- /**
- * If the user is not allowed to edit this form item, <code>true</code> is returned.
- * @return flag to indicate if the user is allowed to change the value or not
- */
- public boolean isReadOnly() {
- return readOnly;
- }
-
- public void setReadOnly(boolean readOnly) {
- this.readOnly = readOnly;
- this.staticItem.setTextBoxStyle((!readOnly) ? "editableText" : null);
- markForRedraw();
- }
-
- /**
- * Returns the handler that will be called when a user edits the current value.
- * This is only called after the user accepts the new value and it passes validation.
- *
- * @return the callback handler that is invoked when the old value is edited resulting in a new value
- */
- public ValueEditedHandler getValueEditedHandler() {
- return this.valueEditedHandler;
- }
-
- public void setValueEditedHandler(ValueEditedHandler handler) {
- this.valueEditedHandler = handler;
- }
-
- /**
- * Marks the canvas item for redraw, which enables both the static and edit items to redraw themselves.
- */
- private void markForRedraw() {
- getForm().markForRedraw();
- this.innerForm.markForRedraw();
- }
-
- /**
- * When a user has changed the value of the editable field item, this
- * is the type of callback that is called to be informed of the change.
- */
- 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/components/form/EnhancedDynamicForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java
index 02c2752..586642a 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
@@ -116,10 +116,11 @@ public class EnhancedDynamicForm extends LocatableDynamicForm {
Boolean showTitle = (item.getShowTitle() != null) ? item.getShowTitle() : true;
staticItem.setShowTitle(showTitle);
staticItem.setTooltip(item.getTooltip());
- staticItem.setValue(item.getDisplayValue());
+ String displayValue = item.getDisplayValue();
+ staticItem.setValue(displayValue);
staticItem.setColSpan(item.getAttribute("colSpan"));
Boolean outputAsHtml = item.getAttributeAsBoolean(OUTPUT_AS_HTML_ATTRIBUTE);
- if (Boolean.TRUE.equals(outputAsHtml)) {
+ if (Boolean.TRUE.equals(outputAsHtml) && null != displayValue && !displayValue.isEmpty()) {
staticItem.setOutputAsHTML(true);
}
// TODO: Any other fields we should copy? icons?
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableFormItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableFormItem.java
new file mode 100644
index 0000000..6bb9933
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableFormItem.java
@@ -0,0 +1,345 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.components.form;
+
+import java.util.Date;
+
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.FormItemIfFunction;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
+import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
+import com.smartgwt.client.widgets.form.validator.Validator;
+
+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.LocatableDynamicForm;
+
+/**
+ * This form item can be used to display a value normally in "read-only" form (i.e. as a StaticTextItem),
+ * 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.
+ *
+ * @author John Mazzitelli
+ */
+public class SimpleEditableFormItem extends CanvasItem {
+
+ protected static Messages MSG = CoreGUI.getMessages();
+
+ protected FormItem staticItem;
+ protected FormItem editItem;
+ protected DynamicForm innerForm;
+
+ private boolean readOnly = false;
+ private boolean editing = false;
+
+ private ValueEditedHandler valueEditedHandler;
+
+ public SimpleEditableFormItem() {
+ this(null, null, null);
+ }
+
+ public SimpleEditableFormItem(String name, String title) {
+ this(name, title, null);
+ }
+
+ public SimpleEditableFormItem(String name, String title, ValueEditedHandler handler) {
+ if (name != null) {
+ setName(name);
+ }
+ if (title != null) {
+ setTitle(title);
+ }
+ if (handler != null) {
+ setValueEditedHandler(handler);
+ }
+
+ this.innerForm = new LocatableDynamicForm(getName() + "_innerForm");
+ this.staticItem = prepareStaticFormItem();
+ this.editItem = prepareEditFormItem();
+ this.innerForm.setCanFocus(true);
+ this.innerForm.setNumCols(1);
+
+ addHandlers();
+
+ this.innerForm.setItems(staticItem, editItem);
+ setCanvas(this.innerForm);
+ setCanFocus(true);
+ }
+
+ protected void addHandlers() {
+
+ this.editItem.addBlurHandler(new BlurHandler() {
+ public void onBlur(BlurEvent event) {
+ if (SimpleEditableFormItem.this.innerForm.validate(false)) {
+ Object newValue = event.getItem().getValue();
+ setApprovedNewValue(newValue);
+ }
+ }
+ });
+ }
+
+ protected FormItem prepareStaticFormItem() {
+ FormItem item = instantiateStaticFormItem();
+ item.setShowTitle(false);
+ item.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem item, Object value, DynamicForm form) {
+ return !isEditing();
+ }
+ });
+
+ return item;
+ }
+
+ protected FormItem prepareEditFormItem() {
+ FormItem item = instantiateEditFormItem();
+ item.setShowTitle(false);
+ item.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem item, Object value, DynamicForm form) {
+ return isEditing();
+ }
+ });
+
+ return item;
+ }
+
+ /**
+ * This instantiates the static item. The form item created by this method will
+ * be further customized by {@link #prepareStaticFormItem()}.
+ *
+ * @return the form item used to show the static (read-only) value
+ */
+ protected FormItem instantiateStaticFormItem() {
+ StaticTextItem item = new StaticTextItem();
+ return item;
+ }
+
+ /**
+ * This instantiates the edit item. The form item created by this method will
+ * be further customized by {@link #prepareEditFormItem()}.
+ *
+ * Subclasses will usually override this method to provide a different form
+ * item such as a checkbox, radio buttons, etc.
+ *
+ * @return the form item used to edit the value
+ */
+ protected FormItem instantiateEditFormItem() {
+ TextItem item = new TextItem();
+ return item;
+ }
+
+ /**
+ * This sets the {@link #setEditing(boolean) edit flag} to false and ensures
+ * the component switches to the static, read-only mode.
+ */
+ public void switchToStaticMode() {
+ if (isEditing()) {
+ setEditing(false);
+ markForRedraw();
+ }
+ }
+
+ /**
+ * This sets the {@link #setEditing(boolean) edit flag} to true and ensures
+ * the component switches to the edit, read-write mode.
+ */
+ public void switchToEditMode() {
+ if (!isEditing()) {
+ setEditing(true);
+ setEditItemValue(this.editItem, this.staticItem.getValue());
+ markForRedraw();
+ }
+ }
+
+ public boolean isEditing() {
+ return this.editing;
+ }
+
+ /**
+ * This just sets the internal flag indicating if the form is in editing mode.
+ * To switch modes, you use {@link #switchToEditMode()} and {@link #switchToStaticMode()}.
+ *
+ * @param editing the new editing flag
+ */
+ protected void setEditing(boolean editing) {
+ this.editing = editing;
+ }
+
+ /**
+ * When the user has accepted a new edited value for this form item, this method is called.
+ * This method is responsible for invoking the {@link #getValueEditedHandler() handler}.
+ *
+ * @param newValue the new value just accepted by the user and validated by the system
+ */
+ protected void setApprovedNewValue(Object newValue) {
+ setStaticItemValue(this.staticItem, newValue);
+ if (this.valueEditedHandler != null) {
+ this.valueEditedHandler.editedValue(newValue);
+ }
+ }
+
+ /**
+ * When a user first elects to edit a value (i.e. switches from static, read-only mode
+ * to edit mode), the static value needs to be converted to an object that is appropriate
+ * for the edit form item value. This method performs that necessary conversion and
+ * sets the edit item's value to that converted value. The converted value is also returned.
+ *
+ * @param editItem the edit form item whose value needs to be set
+ * @param value the static value that needs to be converted and set in the given edit item
+ *
+ * @return the converted value that was set in the edit item
+ */
+ protected Object setEditItemValue(FormItem editItem, Object value) {
+ String convertedValue = (value != null) ? value.toString() : null;
+ editItem.setValue(convertedValue);
+ return convertedValue;
+ }
+
+ /**
+ * When a user enters and accepts a new value, the new value needs to be converted
+ * to an appropriate value for display in the static, read-only item.
+ * This method performs that necessary conversion and sets the static item's value
+ * to that converted value. The converted value is also returned.
+ *
+ * @param staticItem the static form item whose value needs to be set
+ * @param value the value that needs to be converted for display in the static item
+ *
+ * @return the converted value that was set in the static item
+ */
+ protected Object setStaticItemValue(FormItem staticItem, Object value) {
+ String convertedValue = (value != null) ? value.toString() : null;
+ staticItem.setValue(convertedValue);
+ return convertedValue;
+ }
+
+ //
+ // Below are delegating methods to setValue().
+ // When setting this form item's value, we are really setting the static item's value.
+ //
+
+ @Override
+ public void setValue(boolean value) {
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public void setValue(Date value) {
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public void setValue(double value) {
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public void setValue(float value) {
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public void setValue(int value) {
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public void setValue(Object value) {
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public void setValue(String value) {
+ if (this.staticItem instanceof StaticTextItem) {
+ ((StaticTextItem) this.staticItem).setOutputAsHTML(!(null == value || value.isEmpty()));
+ }
+
+ this.staticItem.setValue(value);
+ }
+
+ @Override
+ public Object getValue() {
+ return this.staticItem.getValue();
+ }
+
+ // this delegates to the edit item allowing custom validators to be added
+ @Override
+ public void setValidators(Validator... validators) {
+ this.editItem.setValidators(validators);
+ }
+
+ // direct outer-form validation to the edit item, which would have any set validators
+ @Override
+ public Boolean validate() {
+ return !editing || editItem.validate();
+ }
+
+ /**
+ * If the user is not allowed to edit this form item, <code>true</code> is returned.
+ * @return flag to indicate if the user is allowed to change the value or not
+ */
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ public void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ this.staticItem.setTextBoxStyle((!readOnly) ? "editableText" : null);
+ markForRedraw();
+ }
+
+ /**
+ * Returns the handler that will be called when a user edits the current value.
+ * This is only called after the user accepts the new value and it passes validation.
+ *
+ * @return the callback handler that is invoked when the old value is edited resulting in a new value
+ */
+ public ValueEditedHandler getValueEditedHandler() {
+ return this.valueEditedHandler;
+ }
+
+ public void setValueEditedHandler(ValueEditedHandler handler) {
+ this.valueEditedHandler = handler;
+ }
+
+ /**
+ * Marks the canvas item for redraw, which enables both the static and edit items to redraw themselves.
+ */
+ protected void markForRedraw() {
+ getForm().markForRedraw();
+ this.innerForm.markForRedraw();
+ }
+
+ /**
+ * When a user has changed the value of the editable field item, this
+ * is the type of callback that is called to be informed of the change.
+ */
+ 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/components/form/SimpleEditableTextAreaFormItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableTextAreaFormItem.java
new file mode 100644
index 0000000..556348c
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/SimpleEditableTextAreaFormItem.java
@@ -0,0 +1,53 @@
+/*
+ * 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.form;
+
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.TextAreaItem;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class SimpleEditableTextAreaFormItem extends SimpleEditableFormItem {
+
+ public SimpleEditableTextAreaFormItem() {
+ super();
+ }
+
+ public SimpleEditableTextAreaFormItem(String name, String title) {
+ super(name, title);
+ }
+
+ public SimpleEditableTextAreaFormItem(String name, String title, boolean required) {
+ super(name, title);
+ }
+
+ public SimpleEditableTextAreaFormItem(String name, String title, ValueEditedHandler handler) {
+ super(name, title, handler);
+ }
+
+ @Override
+ protected FormItem instantiateEditFormItem() {
+
+ TextAreaItem item = new TextAreaItem();
+ return item;
+ }
+
+}
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 0cb1411..9a7c87e 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
@@ -277,9 +277,13 @@ public abstract class AbstractOperationScheduleDetailsView extends
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));
+ // Notes field is user-editable, so escape HTML to prevent an XSS attack. Unless empty, then don't to prevent
+ // displaying as the value.
+ String notesValue = getForm().getValue(AbstractOperationScheduleDataSource.Field.DESCRIPTION).toString();
+ if (null != notesValue && !notesValue.isEmpty()) {
+ notesItem.setOutputAsHTML(true);
+ }
+ notesItem.setValue(notesValue);
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/groups/detail/GeneralProperties.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
index 9d8eb61..045c1ef 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
@@ -38,7 +38,7 @@ import org.rhq.enterprise.gui.coregui.client.components.form.CheckboxEditableFor
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.components.form.SimpleEditableFormItem.ValueEditedHandler;
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;
@@ -199,10 +199,11 @@ public class GeneralProperties extends LocatableVLayout {
FormItem recursiveItem;
if (isEditable) {
- CheckboxEditableFormItem editableRecursiveItem = new CheckboxEditableFormItem("recursive", MSG.view_group_summary_recursive());
+ 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);
+ boolean isRecursive = ((newValue != null) && (Boolean) newValue);
resourceGroupService.setRecursive(group.getId(), isRecursive, new AsyncCallback<Void>() {
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
@@ -241,8 +242,7 @@ public class GeneralProperties extends LocatableVLayout {
GroupDefinition groupDefinition = group.getGroupDefinition();
String groupDefinitionUrl = LinkManager.getGroupDefinitionLink(groupDefinition.getId());
String groupDefinitionName = StringUtility.escapeHtml(groupDefinition.getName());
- groupDefinitionItem
- .setValue("<a href=\"" + groupDefinitionUrl + "\">" + groupDefinitionName + "</a>");
+ groupDefinitionItem.setValue("<a href=\"" + groupDefinitionUrl + "\">" + groupDefinitionName + "</a>");
formItems.add(groupDefinitionItem);
}
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 4b85d4f..31b7c95 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
@@ -41,7 +41,7 @@ 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.components.form.SimpleEditableFormItem.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;
@@ -280,7 +280,7 @@ public class OverviewForm extends EnhancedDynamicForm {
// Version
StaticTextItem versionItem = new StaticTextItem("version", MSG.view_summaryOverviewForm_field_version());
String version = (resource.getVersion() != null) ? resource.getVersion() : "<i>" + MSG.common_label_none()
- + "</i>";
+ + "</i>";
versionItem.setValue(version);
versionItem.setEndRow(true);
formItems.add(versionItem);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
index c633ed5..1cd2a71 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
@@ -61,6 +61,7 @@ import org.rhq.enterprise.server.plugin.pc.alert.AlertSender;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
+import org.rhq.enterprise.server.util.CriteriaQueryGenerator.AuthorizationTokenType;
/**
* @author Joseph Marques
@@ -484,7 +485,8 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
* is not currently deleted
*/
boolean isResourceLevel = (oldAlertDefinition.getResource() != null);
- checkAlertDefinition(subject, alertDefinition, isResourceLevel ? oldAlertDefinition.getResource().getId() : null);
+ checkAlertDefinition(subject, alertDefinition, isResourceLevel ? oldAlertDefinition.getResource().getId()
+ : null);
/*
* Should not be able to update an alert definition if the old alert definition is in an invalid state
@@ -600,7 +602,7 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
private void checkAlertDefinition(Subject subject, AlertDefinition alertDefinition, Integer resourceId)
throws InvalidAlertDefinitionException {
// if someone enters a really long description, we need to truncate it - the column is only 250 chars
- if (alertDefinition.getDescription()!=null && alertDefinition.getDescription().length() > 250) {
+ if (alertDefinition.getDescription() != null && alertDefinition.getDescription().length() > 250) {
alertDefinition.setDescription(alertDefinition.getDescription().substring(0, 250));
}
@@ -712,9 +714,15 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
@SuppressWarnings("unchecked")
public PageList<AlertDefinition> findAlertDefinitionsByCriteria(Subject subject, AlertDefinitionCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- if (authorizationManager.isInventoryManager(subject) == false) {
- generator.setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType.RESOURCE, subject
- .getId());
+
+ // Inv managers can do anything and anyone can inspect templates
+ if (!authorizationManager.isInventoryManager(subject) && !criteria.isTemplateCriteria()) {
+
+ // otherwise, for group alert defs ensure group view authz and for everything else, assume resource view authz
+ AuthorizationTokenType tokenType = criteria.isGroupCriteria() ? AuthorizationTokenType.GROUP
+ : AuthorizationTokenType.RESOURCE;
+
+ generator.setAuthorizationResourceFragment(tokenType, subject.getId());
}
CriteriaQueryRunner<AlertDefinition> queryRunner = new CriteriaQueryRunner(criteria, generator, entityManager);
13 years, 1 month
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 10 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 16 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java | 5 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 8 ++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java | 11 +++---
6 files changed, 35 insertions(+), 16 deletions(-)
New commits:
commit 005aa08988d1ca721b6b2ce50ceb0c6cb8c3713c
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Apr 12 11:08:33 2011 -0400
fix config editor bug causing boolean props w/ null values to be rendered as false rather than unset; use setValue(), rather than setDefaultValue(), when initializing FormItems for simple props in config editor; add ctrl-alt-t hot key for going to #Test view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index 0aa06c8..17b9a00 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -149,6 +149,16 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
});
+ KeyIdentifier testTopViewKey = new KeyIdentifier();
+ testTopViewKey.setCtrlKey(true);
+ testTopViewKey.setAltKey(true);
+ testTopViewKey.setKeyName("t");
+ Page.registerKey(testTopViewKey, new KeyCallback() {
+ public void execute(String keyName) {
+ goToView("Test");
+ }
+ });
+
GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
public void onUncaughtException(Throwable e) {
getErrorHandler().handleError(MSG.view_core_uncaught(), e);
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 2a83fbd..01f813f 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
@@ -82,6 +82,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
public void onPermissionsLoaded(Set<Permission> globalPermissions) {
TemplateAlertDefinitionsView.this.globalPermissions = globalPermissions;
+ refreshTableInfo();
}
});
}
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 b7f1adf..5ff37bb 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
@@ -146,6 +146,13 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
//
public class ConfigurationEditor extends LocatableVLayout {
+ private static final LinkedHashMap<String, String> BOOLEAN_PROPERTY_ITEM_VALUE_MAP =
+ new LinkedHashMap<String, String>();
+ static {
+ BOOLEAN_PROPERTY_ITEM_VALUE_MAP.put(Boolean.TRUE.toString(), MSG.common_val_yes());
+ BOOLEAN_PROPERTY_ITEM_VALUE_MAP.put(Boolean.FALSE.toString(), MSG.common_val_no());
+ }
+
private ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
private LocatableToolStrip toolStrip;
@@ -1296,11 +1303,8 @@ public class ConfigurationEditor extends LocatableVLayout {
case BOOLEAN:
RadioGroupItem radioGroupItem = new RadioGroupItem();
radioGroupItem.setVertical(false);
+ radioGroupItem.setValueMap(BOOLEAN_PROPERTY_ITEM_VALUE_MAP);
valueItem = radioGroupItem;
- LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
- valueMap.put("true", MSG.common_val_yes());
- valueMap.put("false", MSG.common_val_no());
- valueItem.setValueMap(valueMap);
break;
case INTEGER:
case LONG:
@@ -1344,9 +1348,7 @@ public class ConfigurationEditor extends LocatableVLayout {
// 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(value);
+ valueItem.setValue(value);
valueItem.setRequired(propertyDefinitionSimple.isRequired());
valueItem.setWidth(220);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
index b689133..3f784b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -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.inventory.resource;
import com.smartgwt.client.widgets.grid.ListGridField;
@@ -37,6 +36,8 @@ public enum ResourceDataSourceField {
PLUGIN("pluginName", CoreGUI.getMessages().common_title_plugin()),
+ VERSION("version", CoreGUI.getMessages().common_title_version()),
+
CATEGORY("resourceType.category", CoreGUI.getMessages().common_title_category()),
AVAILABILITY("currentAvailability", CoreGUI.getMessages().common_title_availability());
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 b53a127..6e639c5 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
@@ -24,6 +24,7 @@ import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceD
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.VERSION;
import java.util.ArrayList;
import java.util.Collection;
@@ -48,6 +49,7 @@ 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.EscapedHtmlCellFormatter;
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;
@@ -160,11 +162,15 @@ public class ResourceSearchView extends Table {
ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
ListGridField descriptionField = new ListGridField(DESCRIPTION.propertyName(), DESCRIPTION.title());
+ descriptionField.setCellFormatter(new EscapedHtmlCellFormatter());
ListGridField typeNameField = new ListGridField(TYPE.propertyName(), TYPE.title(), 130);
ListGridField pluginNameField = new ListGridField(PLUGIN.propertyName(), PLUGIN.title(), 100);
+ ListGridField versionField = new ListGridField(VERSION.propertyName(), VERSION.title(), 60);
+ versionField.setHidden(true);
+
ListGridField categoryField = new ListGridField(CATEGORY.propertyName(), CATEGORY.title(), 60);
categoryField.setCellFormatter(new ResourceCategoryCellFormatter());
categoryField.setHidden(true); // the icon field already shows us this, no need to show it in another column
@@ -172,7 +178,7 @@ public class ResourceSearchView extends Table {
IconField availabilityField = new IconField(AVAILABILITY.propertyName(), AVAILABILITY.title(), 70);
setListGridFields(iconField, nameField, ancestryField, descriptionField, typeNameField, pluginNameField,
- categoryField, availabilityField);
+ versionField, categoryField, availabilityField);
addTableAction(extendLocatorId("Uninventory"), MSG.common_button_uninventory(), MSG
.view_inventory_resources_uninventoryConfirm(), new ResourceAuthorizedTableAction(ResourceSearchView.this,
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
index a080f13..b736151 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright 2010, 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.
*
@@ -78,7 +78,6 @@ public abstract class TestConfigurationFactory {
simplePropDef = createBooleanPropDef();
addPropertyDefinition(configDef, simplePropDef, orderIndex++);
- simplePropDef.setRequired(true);
simplePropDef = createIntegerPropDef();
addPropertyDefinition(configDef, simplePropDef, orderIndex++);
@@ -294,7 +293,7 @@ public abstract class TestConfigurationFactory {
private static PropertyDefinitionSimple createStringPropDef1() {
PropertyDefinitionSimple stringPropDef1;
stringPropDef1 = new PropertyDefinitionSimple("String1",
- "an optional String simple prop", false, PropertySimpleType.STRING);
+ "a String simple prop", false, PropertySimpleType.STRING);
stringPropDef1.setDisplayName(stringPropDef1.getName());
return stringPropDef1;
}
@@ -302,7 +301,7 @@ public abstract class TestConfigurationFactory {
private static PropertyDefinitionSimple createStringPropDef2() {
PropertyDefinitionSimple stringPropDef2;
stringPropDef2 = new PropertyDefinitionSimple("String2",
- "a read-only String simple prop", false, PropertySimpleType.STRING);
+ "a read-only required String simple prop", true, PropertySimpleType.STRING);
stringPropDef2.setDisplayName(stringPropDef2.getName());
stringPropDef2.setReadOnly(true);
return stringPropDef2;
@@ -311,7 +310,7 @@ public abstract class TestConfigurationFactory {
private static PropertyDefinitionSimple createBooleanPropDef() {
PropertyDefinitionSimple propDef;
propDef = new PropertyDefinitionSimple("Boolean",
- "a Boolean simple prop", false, PropertySimpleType.BOOLEAN);
+ "a summary Boolean simple prop", false, PropertySimpleType.BOOLEAN);
propDef.setDisplayName(propDef.getName());
propDef.setSummary(true);
return propDef;
@@ -320,7 +319,7 @@ public abstract class TestConfigurationFactory {
private static PropertyDefinitionSimple createIntegerPropDef() {
PropertyDefinitionSimple integerPropDef;
integerPropDef = new PropertyDefinitionSimple("Integer",
- "a required summary Integer simple prop", true, PropertySimpleType.INTEGER);
+ "a summary Integer simple prop", false, PropertySimpleType.INTEGER);
integerPropDef.setDisplayName(integerPropDef.getName());
integerPropDef.setSummary(true);
return integerPropDef;
13 years, 1 month
[rhq] 2 commits - modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 6 +++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java | 2 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java | 7 +++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java | 8 ++++----
4 files changed, 11 insertions(+), 12 deletions(-)
New commits:
commit 50f58a4f68ad08fb564201a35378bbcda54b969a
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Apr 12 09:02:34 2011 -0400
Locator id fixes i)Auto refresh locator was too restrictive as included parent ids like 10071
ii)Portlet config settings locator still mentioned alert when it's not generic.
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 f087202..8deac66 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
@@ -393,7 +393,7 @@ public class DashboardView extends LocatableVLayout {
});
//refresh interval
- LocatableMenu refreshMenu = new LocatableMenu(editForm.extendLocatorId("AutoRefreshMenu"));
+ LocatableMenu refreshMenu = new LocatableMenu("AutoRefreshMenu");
refreshMenu.setShowShadow(true);
refreshMenu.setShadowDepth(10);
refreshMenu.setAutoWidth();
@@ -440,8 +440,8 @@ public class DashboardView extends LocatableVLayout {
}
refreshMenu.setItems(refreshMenuItems);
- refreshMenuButton = new LocatableIMenuButton(editForm.extendLocatorId("AutoRefreshButton"), MSG
- .common_title_change_refresh_time(), refreshMenu);
+ refreshMenuButton = new LocatableIMenuButton("AutoRefreshButton", MSG.common_title_change_refresh_time(),
+ refreshMenu);
refreshMenu.setAutoHeight();
refreshMenuButton.getMenu().setItems(refreshMenuItems);
refreshMenuButton.setWidth(140);
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 b7488da..06c8a05 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
@@ -214,7 +214,7 @@ public class PortletConfigurationEditorComponent {
* @return
*/
public static CustomConfigMeasurementRangeEditor getMeasurementRangeEditor(Configuration portletConfig) {
- return new CustomConfigMeasurementRangeEditor("alertTimeFrame", portletConfig);
+ return new CustomConfigMeasurementRangeEditor("timeFrame", portletConfig);
}
public static SelectItem getOperationStatusEditor(Configuration portletConfig) {
commit 6ec59cf1710699a29022e5bec34ccdad4b2b5ac6
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Apr 8 13:04:20 2011 -0400
fix locator issue with Group/Res events portlets.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
index d054102..731ac31 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
@@ -32,7 +32,6 @@ 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.StaticTextItem;
-import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -249,7 +248,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
}
}
//build display
- VLayout column = new VLayout();
+ LocatableVLayout column = new LocatableVLayout(recentEventsContent.extendLocatorId("canvas"));
column.setHeight(10);
if (!results.isEmpty()) {
@@ -258,7 +257,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
// event history records do not have a usable locatorId, we'll use rownum, which is unique and
// may be repeatable.
LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent
- .extendLocatorId(String.valueOf(rowNum)));
+ .extendLocatorId(String.valueOf(rowNum++)));
row.setNumCols(2);
row.setWidth(10);//pack.
@@ -274,7 +273,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
column.markForRedraw();
//insert see more link
LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent.extendLocatorId(String
- .valueOf(rowNum)));
+ .valueOf(rowNum++)));
AbstractActivityView.addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId
+ "/Events/History/", column);
} else {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
index f382ea7..dfde6d9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
@@ -27,7 +27,6 @@ import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.event.EventSeverity;
@@ -42,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecor
import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
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;
/**This portlet allows the end user to customize the Events display
*
@@ -133,7 +133,7 @@ public class ResourceEventsPortlet extends GroupEventsPortlet {
}
}
//build display
- VLayout column = new VLayout();
+ LocatableVLayout column = new LocatableVLayout(recentEventsContent.extendLocatorId("canvas"));
column.setHeight(10);
if (!results.isEmpty()) {
@@ -142,7 +142,7 @@ public class ResourceEventsPortlet extends GroupEventsPortlet {
// event history records do not have a usable locatorId, we'll use rownum, which is unique and
// may be repeatable.
LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent
- .extendLocatorId(String.valueOf(rowNum)));
+ .extendLocatorId(String.valueOf(rowNum++)));
row.setNumCols(2);
row.setWidth(10);//pack.
@@ -157,7 +157,7 @@ public class ResourceEventsPortlet extends GroupEventsPortlet {
}
//insert see more link
LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent.extendLocatorId(String
- .valueOf(rowNum)));
+ .valueOf(rowNum++)));
AbstractActivityView.addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId
+ "/Events/History/", column);
} else {
13 years, 1 month