modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdate.java
| 5
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractResourceConfigurationUpdate.java
| 9
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PluginConfigurationUpdate.java
| 7
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdate.java
| 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
| 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationComparisonView.java
| 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
| 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
| 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationSettings.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java
| 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
| 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java
| 290 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDetailView.java
| 91 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java
| 177 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
| 237 --------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDetailView.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
| 130 ----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDataSource.java
| 122 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDetailView.java
| 90 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java
| 103 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
| 53 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
| 16
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
| 29 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
| 44 +
26 files changed, 1101 insertions(+), 382 deletions(-)
New commits:
commit 9cf8a15457284b44deea1fc7f7bd5b095f3b7bdb
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Feb 24 17:19:34 2011 -0500
refactor the config history views to abstract out the parts that are reusable for
plugin config views
create plugin config views
we now have the plugin config history views and they look pretty much the same as the
config history views (due to the use of the abstracted classes for both)
still have some work to do to finish, mainly in the area of deleting/rolling back and
other operations like that
the data that you can view seems correct
still needs testing
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractResourceConfigurationUpdate.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractResourceConfigurationUpdate.java
index aa073a6..1e01f08 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractResourceConfigurationUpdate.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractResourceConfigurationUpdate.java
@@ -34,6 +34,7 @@ import javax.persistence.InheritanceType;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import org.rhq.core.domain.configuration.group.AbstractGroupConfigurationUpdate;
import org.rhq.core.domain.resource.Resource;
/**
@@ -61,6 +62,8 @@ public abstract class AbstractResourceConfigurationUpdate extends
AbstractConfig
public abstract Resource getResource();
+ public abstract AbstractGroupConfigurationUpdate
getAbstractGroupConfigurationUpdate();
+
protected AbstractResourceConfigurationUpdate() {
}
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PluginConfigurationUpdate.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PluginConfigurationUpdate.java
index d7e7af4..e7c5845 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PluginConfigurationUpdate.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PluginConfigurationUpdate.java
@@ -34,6 +34,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlTransient;
+import org.rhq.core.domain.configuration.group.AbstractGroupConfigurationUpdate;
import org.rhq.core.domain.configuration.group.GroupPluginConfigurationUpdate;
import org.rhq.core.domain.resource.Resource;
@@ -163,6 +164,11 @@ public class PluginConfigurationUpdate extends
AbstractResourceConfigurationUpda
this.resource = resource;
}
+ @Override
+ public AbstractGroupConfigurationUpdate getAbstractGroupConfigurationUpdate() {
+ return getGroupConfigurationUpdate();
+ }
+
public GroupPluginConfigurationUpdate getGroupConfigurationUpdate() {
return groupConfigurationUpdate;
}
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdate.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdate.java
index b814ea4..f7f4bee 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdate.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdate.java
@@ -32,6 +32,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlTransient;
+import org.rhq.core.domain.configuration.group.AbstractGroupConfigurationUpdate;
import org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate;
import org.rhq.core.domain.resource.Resource;
@@ -216,6 +217,11 @@ public class ResourceConfigurationUpdate extends
AbstractResourceConfigurationUp
this.resource = resource;
}
+ @Override
+ public AbstractGroupConfigurationUpdate getAbstractGroupConfigurationUpdate() {
+ return getGroupConfigurationUpdate();
+ }
+
public GroupResourceConfigurationUpdate getGroupConfigurationUpdate() {
return groupConfigurationUpdate;
}
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 d010c41..5770cd3 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
@@ -87,12 +87,21 @@ public class LinkManager {
return getResourceLink(groupId) +
"/Inventory/ConnectionSettingsHistory";
}
- public static String getGroupPluginConfigurationUpdateHistoryLink(int groupId) {
- return getResourceGroupLink(groupId) +
"/Inventory/ConnectionSettingsHistory";
+ public static String getGroupPluginConfigurationUpdateHistoryLink(int groupId,
Integer groupUpdateHistoryId) {
+ if (groupUpdateHistoryId != null) {
+ return getResourceGroupLink(groupId) +
"/Inventory/ConnectionSettingsHistory/" + groupUpdateHistoryId
+ + "/Members";
+ } else {
+ return getResourceGroupLink(groupId) +
"/Inventory/ConnectionSettingsHistory";
+ }
}
- public static String getGroupResourceConfigurationUpdateHistoryLink(int groupId, int
groupUpdateHistoryId) {
- return getResourceGroupLink(groupId) + "/Configuration/History/" +
groupUpdateHistoryId;
+ public static String getGroupResourceConfigurationUpdateHistoryLink(int groupId,
Integer groupUpdateHistoryId) {
+ if (groupUpdateHistoryId != null) {
+ return getResourceGroupLink(groupId) + "/Configuration/History/" +
groupUpdateHistoryId;
+ } else {
+ return getResourceGroupLink(groupId) + "/Configuration/History";
+ }
}
public static String getGroupOperationHistoryLink(int groupId, int
groupOperationHistoryId) {
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 c2403c6..18d5b60 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
@@ -93,7 +93,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Greg Hinkle
* @author Ian Springer
*/
-public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
RefreshableView {
+public class Table<DS extends RPCDataSource<?>> extends LocatableHLayout
implements RefreshableView {
protected static final String FIELD_ID = "id";
protected static final String FIELD_NAME = "name";
@@ -801,11 +801,11 @@ public class Table<DS extends RPCDataSource> extends
LocatableHLayout implements
private static class TableFilter extends DynamicForm implements KeyPressHandler,
ChangedHandler,
com.google.gwt.event.dom.client.KeyPressHandler {
- private Table table;
+ private Table<?> table;
private SearchBarItem searchBarItem;
private HiddenItem hiddenItem;
- public TableFilter(Table table) {
+ public TableFilter(Table<?> table) {
super();
setWidth100();
setPadding(5);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
index 171a28e..e1757b8 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
@@ -36,6 +36,8 @@ public interface ConfigurationGWTService extends RemoteService {
ResourceConfigurationUpdate getLatestResourceConfigurationUpdate(int resourceId)
throws RuntimeException;
+ PluginConfigurationUpdate getLatestPluginConfigurationUpdate(int resourceId) throws
RuntimeException;
+
Configuration getPluginConfiguration(int resourceId) throws RuntimeException;
ConfigurationDefinition getPluginConfigurationDefinition(int resourceTypeId) throws
RuntimeException;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java
index 7567f58..bd68f55 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java
@@ -75,7 +75,7 @@ public class HistoryGroupPluginConfigurationMembers extends
LocatableVLayout {
setMargin(5);
setMembersMargin(5);
- String backPath =
LinkManager.getGroupPluginConfigurationUpdateHistoryLink(this.group.getId());
+ String backPath =
LinkManager.getGroupPluginConfigurationUpdateHistoryLink(this.group.getId(), null);
BackButton backButton = new BackButton(extendLocatorId("BackButton"),
MSG.view_tableSection_backButton(),
backPath);
addMember(backButton);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationSettings.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationSettings.java
index fed4f63..b89f449 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationSettings.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationSettings.java
@@ -67,7 +67,7 @@ public class HistoryGroupPluginConfigurationSettings extends
LocatableVLayout {
setMargin(5);
setMembersMargin(5);
- String backPath =
LinkManager.getGroupPluginConfigurationUpdateHistoryLink(this.group.getId());
+ String backPath =
LinkManager.getGroupPluginConfigurationUpdateHistoryLink(this.group.getId(), null);
BackButton backButton = new BackButton(extendLocatorId("BackButton"),
MSG.view_tableSection_backButton(),
backPath);
addMember(backButton);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java
index df2c56f..e4d5c78 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java
@@ -188,9 +188,8 @@ public class HistoryGroupPluginConfigurationTable extends Table {
new AbstractTableAction(TableActionEnablement.SINGLE) {
@Override
public void executeAction(ListGridRecord[] selection, Object actionValue)
{
- CoreGUI.goToView(LinkManager
-
.getGroupPluginConfigurationUpdateHistoryLink(HistoryGroupPluginConfigurationTable.this.group
- .getId())
+
CoreGUI.goToView(LinkManager.getGroupPluginConfigurationUpdateHistoryLink(
+ HistoryGroupPluginConfigurationTable.this.group.getId(), null)
+ "/" + selection[0].getAttribute("id") +
"/Settings");
}
});
@@ -199,9 +198,8 @@ public class HistoryGroupPluginConfigurationTable extends Table {
.view_group_pluginConfig_table_viewMemberHistory(), new
AbstractTableAction(TableActionEnablement.SINGLE) {
@Override
public void executeAction(ListGridRecord[] selection, Object actionValue) {
- CoreGUI.goToView(LinkManager
-
.getGroupPluginConfigurationUpdateHistoryLink(HistoryGroupPluginConfigurationTable.this.group
- .getId())
+
CoreGUI.goToView(LinkManager.getGroupPluginConfigurationUpdateHistoryLink(
+ HistoryGroupPluginConfigurationTable.this.group.getId(), null)
+ "/" + selection[0].getAttribute("id") +
"/Members");
}
});
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 a1b2fc3..e0504d6 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
@@ -58,8 +58,8 @@ import
org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceComposit
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectListener;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ResourceConfigurationEditView;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.HistoryPluginConfigurationView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.PluginConfigurationEditView;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.PluginConfigurationHistoryView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.ResourceResourceAgentView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules.SchedulesView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.table.MeasurementTableView;
@@ -147,7 +147,7 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
inventoryConn = new
SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), new ViewName(
"ConnectionSettings", MSG.view_tabs_common_connectionSettings()),
null);
inventoryConnHistory = new
SubTab(inventoryTab.extendLocatorId("ConnSetHist"),
- HistoryPluginConfigurationView.VIEW_ID, null);
+ PluginConfigurationHistoryView.VIEW_ID, null);
inventoryGroups = new SubTab(inventoryTab.extendLocatorId("Groups"),
new ViewName("Groups", MSG
.view_tabs_common_groups()), null);
inventoryAgent = new SubTab(inventoryTab.extendLocatorId("Agent"), new
ViewName("Agent", MSG
@@ -281,8 +281,9 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.inventoryTab, this.inventoryConn, canvas, visible, true);
// same test, use above setting for 'visible'
- canvas = (visible) ? new
HistoryPluginConfigurationView(this.inventoryConnHistory.extendLocatorId("View"),
- this.resourceComposite) : null;
+ canvas = (visible) ? new
PluginConfigurationHistoryView(this.inventoryConnHistory.extendLocatorId("View"),
+ this.resourceComposite.getResourcePermission().isInventory(),
this.resourceComposite.getResource().getId())
+ : null;
updateSubTab(this.inventoryTab, this.inventoryConnHistory, canvas, visible,
true);
boolean canModifyMembership =
globalPermissions.contains(Permission.MANAGE_INVENTORY);
@@ -364,7 +365,7 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.configurationTab, this.configCurrent, new
ResourceConfigurationEditView(this
.extendLocatorId("ResourceConfigView"), resourceComposite),
true, true);
- updateSubTab(this.configurationTab, this.configHistory,
ConfigurationHistoryView.getHistoryOf(this
+ updateSubTab(this.configurationTab, this.configHistory, new
ConfigurationHistoryView(this
.extendLocatorId("ConfigHistView"),
this.resourceComposite.getResourcePermission().isConfigureWrite(),
resource.getId()), true, true);
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java
new file mode 100644
index 0000000..a50e8a8
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java
@@ -0,0 +1,290 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.DateDisplayFormat;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.widgets.Canvas;
+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.configuration.AbstractConfigurationUpdate;
+import org.rhq.core.domain.configuration.AbstractResourceConfigurationUpdate;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * A superclass data source that loads information about all the plugin/resource
configuration changes that happened
+ * for a resource or across all inventory.
+ *
+ * @author Greg Hinkle
+ * @author John Mazzitelli
+ */
+public abstract class AbstractConfigurationHistoryDataSource<T extends
AbstractResourceConfigurationUpdate> extends
+ RPCDataSource<T> {
+
+ public static abstract class Field {
+ public static final String ID = "id";
+ public static final String RESOURCE = "resource";
+ public static final String CREATED_TIME = "createdTime";
+ public static final String STATUS = "status";
+ public static final String SUBJECT = "subject";
+ public static final String RESOURCE_TYPE_ID = "resourceTypeId";
+ public static final String CONFIGURATION = "configuration";
+ public static final String GROUP_CONFIG_UPDATE_ID =
"groupConfigUpdateId";
+ public static final String GROUP_ID = "groupId"; // will only be
non-null if group config update id is non-null
+ public static final String DURATION = "duration";
+ public static final String ERROR_MESSAGE = "errorMessage";
+ public static final String MODIFIED_TIME = "modifiedTime";
+ public static final String CURRENT_CONFIG = "currentConfig"; // will be
true if the history item represents the current config
+ public static final String OBJECT = "object"; // the full entity object
is stored in this attribute
+ }
+
+ public static abstract class CriteriaField {
+ public static final String RESOURCE_ID = "resourceId";
+ }
+
+ private ConfigurationGWTServiceAsync configurationService =
GWTServiceLookup.getConfigurationService();
+
+ protected ConfigurationGWTServiceAsync getConfigurationService() {
+ return this.configurationService;
+ }
+
+ public AbstractConfigurationHistoryDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ protected String getStatusHtmlString(Record record) {
+ String html = null;
+ AbstractConfigurationUpdate obj = (AbstractConfigurationUpdate)
record.getAttributeAsObject(Field.OBJECT);
+ switch (obj.getStatus()) {
+ case SUCCESS: {
+ html = MSG.view_configurationHistoryList_table_statusSuccess();
+ break;
+ }
+ case INPROGRESS: {
+ html = "<p>" +
MSG.view_configurationHistoryList_table_statusInprogress() + "</p>";
+ break;
+ }
+ case NOCHANGE: {
+ html = MSG.view_configurationHistoryList_table_statusNochange();
+ break;
+ }
+ case FAILURE: {
+ html = obj.getErrorMessage();
+ if (html == null) {
+ html = "<p>" +
MSG.view_configurationHistoryList_table_statusFailure() + "</p>";
+ } else {
+ if (html.length() > 80) {
+ // this was probably an error stack trace, snip it so the tooltip
isn't too big
+ html = "<pre>" + html.substring(0, 80) +
"...</pre><p>"
+ + MSG.view_configurationHistoryList_table_clickStatusIcon() +
"</p>";
+ } else {
+ html = "<pre>" + html + "</pre>";
+ }
+ }
+ break;
+ }
+ }
+ return html;
+ }
+
+ /**
+ * Views that use this data source can call this method to get a list of fields
+ * that can be used in a list grid to show the data for this data source.
+ *
+ * @param includeResourceFields if true, the list of fields that are returned will
+ * include fields to show individual resource data.
+ * Pass in false if you are only collecting data on a
+ * single resource, since you don't need every row
to
+ * show the same data on the same resource.
+ * @return fields
+ */
+ public ArrayList<ListGridField> getListGridFields(boolean
includeResourceFields) {
+ ArrayList<ListGridField> fields = new ArrayList<ListGridField>();
+
+ ListGridField idField = new ListGridField(Field.ID, MSG.common_title_version());
+ idField.setShowHover(true);
+ idField.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int
colNum) {
+ if (Boolean.parseBoolean(record.getAttribute(Field.CURRENT_CONFIG))) {
+ return MSG.dataSource_configurationHistory_currentConfig();
+ }
+ return null;
+ }
+ });
+ fields.add(idField);
+
+ ListGridField submittedTimeField = new ListGridField(Field.CREATED_TIME, MSG
+ .dataSource_configurationHistory_dateSubmitted());
+ submittedTimeField.setType(ListGridFieldType.DATE);
+ submittedTimeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
+ fields.add(submittedTimeField);
+
+ ListGridField completedTimeField = new ListGridField(Field.MODIFIED_TIME, MSG
+ .dataSource_configurationHistory_dateCompleted());
+ completedTimeField.setType(ListGridFieldType.DATE);
+ completedTimeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
+ fields.add(completedTimeField);
+
+ ListGridField statusField = new ListGridField(Field.STATUS,
MSG.common_title_status());
+ statusField.setAlign(Alignment.CENTER);
+ statusField.setCellFormatter(new CellFormatter() {
+ public String format(Object value, ListGridRecord listGridRecord, int i, int
i1) {
+ ConfigurationUpdateStatus status =
ConfigurationUpdateStatus.valueOf(value.toString());
+ return Canvas.imgHTML(getConfigurationUpdateStatusIcon(status), 16, 16);
+ }
+ });
+ statusField.setShowHover(true);
+ statusField.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int
colNum) {
+ String html = getStatusHtmlString(record);
+ return html;
+ }
+ });
+ statusField.addRecordClickHandler(new RecordClickHandler() {
+ @Override
+ public void onRecordClick(RecordClickEvent event) {
+ String err = event.getRecord().getAttribute(Field.ERROR_MESSAGE);
+ if (err != null && err.length() > 0) {
+ err = "<pre>" + err + "</pre>";
+ new ErrorMessageWindow("errWin", MSG.common_title_error(),
err).show();
+ }
+ }
+ });
+ fields.add(statusField);
+
+ ListGridField subjectField = new ListGridField(Field.SUBJECT,
MSG.common_title_user());
+ fields.add(subjectField);
+
+ ListGridField updateTypeField = new ListGridField(Field.GROUP_CONFIG_UPDATE_ID,
MSG
+ .dataSource_configurationHistory_updateType());
+ updateTypeField.setCellFormatter(new CellFormatter() {
+ @Override
+ public String format(Object value, ListGridRecord record, int rowNum, int
colNum) {
+ if (value == null) {
+ return MSG.dataSource_configurationHistory_updateType_individual();
+ }
+ Integer groupId = record.getAttributeAsInt(Field.GROUP_ID);
+ return "<a href=\"" +
getGroupConfigurationUpdateHistoryLink(groupId, (Number) value) + "\">"
+ + MSG.dataSource_configurationHistory_updateType_group() +
"</a>";
+ }
+ });
+ fields.add(updateTypeField);
+
+ // determine the widths of our columns
+ if (includeResourceFields) {
+ 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) {
+ if (listGridRecord == null) {
+ return "unknown";
+ }
+ Resource res = (Resource)
listGridRecord.getAttributeAsObject(Field.RESOURCE);
+ String url = LinkManager.getResourceLink(res.getId());
+ // TODO disambiguate the resource name
+ return SeleniumUtility.getLocatableHref(url, res.getName(), null);
+ }
+ });
+ fields.add(resourceField);
+
+ idField.setWidth("10%");
+ submittedTimeField.setWidth("20%");
+ completedTimeField.setWidth("20%");
+ statusField.setWidth("10%");
+ subjectField.setWidth("10%");
+ updateTypeField.setWidth("10%");
+ resourceField.setWidth("*");
+ } else {
+ idField.setWidth("10%");
+ submittedTimeField.setWidth("20%");
+ completedTimeField.setWidth("20%");
+ statusField.setWidth("10%");
+ subjectField.setWidth("10%");
+ updateTypeField.setWidth("*");
+ }
+
+ return fields;
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+ DataSourceIntegerField idField = new DataSourceIntegerField(Field.ID,
MSG.common_title_version());
+ idField.setPrimaryKey(true);
+ fields.add(idField);
+ return fields;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T copyValues(Record from) {
+ return (T) from.getAttributeAsObject(Field.OBJECT);
+ }
+
+ @Override
+ public ListGridRecord copyValues(T from) {
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(Field.ID, from.getId());
+ record.setAttribute(Field.RESOURCE, from.getResource());
+ record.setAttribute(Field.RESOURCE_TYPE_ID,
from.getResource().getResourceType().getId());
+ record.setAttribute(Field.SUBJECT, from.getSubjectName());
+ record.setAttribute(Field.STATUS, from.getStatus().name());
+ record.setAttribute(Field.CONFIGURATION, from.getConfiguration());
+ record.setAttribute(Field.DURATION, from.getDuration());
+ record.setAttribute(Field.ERROR_MESSAGE, from.getErrorMessage());
+ record.setAttribute(Field.CREATED_TIME, new Date(from.getCreatedTime()));
+ // if it is still in progress, the modified time (which we label as "date
completed") is meaningless since it isn't completed yet
+ if (from.getStatus() != ConfigurationUpdateStatus.INPROGRESS) {
+ record.setAttribute(Field.MODIFIED_TIME, new Date(from.getModifiedTime()));
+ }
+ if (from.getAbstractGroupConfigurationUpdate() != null) {
+ record.setAttribute(Field.GROUP_CONFIG_UPDATE_ID,
from.getAbstractGroupConfigurationUpdate().getId());
+ record.setAttribute(Field.GROUP_ID,
from.getAbstractGroupConfigurationUpdate().getGroup().getId()); // note group must be
eagerly loaded here
+ }
+ record.setAttribute(Field.OBJECT, from);
+ return record;
+ }
+
+ protected abstract String getConfigurationUpdateStatusIcon(ConfigurationUpdateStatus
status);
+
+ protected abstract String getGroupConfigurationUpdateHistoryLink(Integer groupId,
Number value);
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDetailView.java
new file mode 100644
index 0000000..926fa76
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDetailView.java
@@ -0,0 +1,91 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration;
+
+import java.util.EnumSet;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import
org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Greg Hinkle
+ */
+public class AbstractConfigurationHistoryDetailView extends LocatableVLayout implements
BookmarkableView {
+
+ public AbstractConfigurationHistoryDetailView(String locatorId) {
+ super(locatorId);
+
+ setWidth100();
+ setHeight100();
+ }
+
+ private void displayHistory(final ResourceConfigurationUpdate update) {
+
+
ResourceTypeRepository.Cache.getInstance().getResourceTypes(update.getResource().getResourceType().getId(),
+
EnumSet.of(ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+
+ public void onTypesLoaded(ResourceType type) {
+ ConfigurationDefinition definition =
type.getResourceConfigurationDefinition();
+ ConfigurationEditor editor = new
ConfigurationEditor("ResConfigHist-"
+ + update.getResource().getName(), definition,
update.getConfiguration());
+ editor.setReadOnly(true);
+ addMember(editor);
+ markForRedraw();
+ }
+ });
+ }
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+
+ int updateId = viewPath.getCurrentAsInt();
+
+ ResourceConfigurationUpdateCriteria criteria = new
ResourceConfigurationUpdateCriteria();
+ criteria.fetchConfiguration(true);
+ criteria.fetchResource(true);
+ criteria.addFilterId(updateId);
+
+
GWTServiceLookup.getConfigurationService().findResourceConfigurationUpdatesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_configurationHistoryDetails_error_loadFailure(),
+ caught);
+ }
+
+ public void onSuccess(PageList<ResourceConfigurationUpdate> result)
{
+
+ ResourceConfigurationUpdate update = result.get(0);
+ displayHistory(update);
+ }
+ });
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java
new file mode 100644
index 0000000..d72af99
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java
@@ -0,0 +1,177 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.types.SortDirection;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.configuration.AbstractResourceConfigurationUpdate;
+import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import
org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationComparisonView;
+import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * The superclass to the main plugin/resource views that lists all configuration history
items.
+ *
+ * @author Greg Hinkle
+ * @author John Mazzitelli
+ */
+public abstract class AbstractConfigurationHistoryView<T extends
AbstractConfigurationHistoryDataSource<? extends
AbstractResourceConfigurationUpdate>>
+ extends TableSection<T> {
+
+ private Integer resourceId;
+ private boolean hasWritePerm; // can delete history or rollback to a previous config
+
+ /**
+ * Use this constructor to view config histories for all viewable Resources.
+ */
+ public AbstractConfigurationHistoryView(String locatorId, String title, boolean
hasWritePerm) {
+ super(locatorId, title);
+ this.hasWritePerm = hasWritePerm;
+ this.resourceId = null;
+ }
+
+ /**
+ * Use this constructor to view the config history for the Resource with the
specified ID.
+ *
+ * @param resourceId a Resource ID
+ */
+ public AbstractConfigurationHistoryView(String locatorId, String title, boolean
hasWritePerm, int resourceId) {
+ super(locatorId, title, createCriteria(resourceId));
+ this.hasWritePerm = hasWritePerm;
+ this.resourceId = resourceId;
+ }
+
+ private static Criteria createCriteria(int resourceId) {
+ Criteria criteria = new Criteria();
+
criteria.addCriteria(AbstractConfigurationHistoryDataSource.CriteriaField.RESOURCE_ID,
resourceId);
+ return criteria;
+ }
+
+ public Integer getResourceId() {
+ return resourceId;
+ }
+
+ public boolean hasWritePermission() {
+ return hasWritePerm;
+ }
+
+ @Override
+ protected void configureTable() {
+ List<ListGridField> fields =
getDataSource().getListGridFields(this.resourceId == null);
+ setListGridFields(true, fields.toArray(new ListGridField[fields.size()])); //
true = always show the ID field
+ getListGrid().sort(AbstractConfigurationHistoryDataSource.Field.ID,
SortDirection.DESCENDING);
+
+ addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(),
MSG.common_msg_areYouSure(),
+ new AbstractTableAction(hasWritePerm ? TableActionEnablement.ANY :
TableActionEnablement.NEVER) {
+ public void executeAction(ListGridRecord[] selection, Object actionValue)
{
+ if (selection != null && selection.length > 0) {
+ int[] doomedIds = new int[selection.length];
+ int i = 0;
+ for (ListGridRecord selected : selection) {
+ doomedIds[i] =
selected.getAttributeAsInt(AbstractConfigurationHistoryDataSource.Field.ID);
+ if (selected
+
.getAttribute(AbstractConfigurationHistoryDataSource.Field.GROUP_CONFIG_UPDATE_ID) !=
null) {
+ CoreGUI.getMessageCenter().notify(
+ new
Message(MSG.view_configurationHistoryList_cannotDeleteGroupItems(),
+ Severity.Warning));
+ return; // abort
+ }
+ if (Boolean.parseBoolean(selected
+
.getAttribute(AbstractConfigurationHistoryDataSource.Field.CURRENT_CONFIG))) {
+ CoreGUI.getMessageCenter().notify(
+ new
Message(MSG.view_configurationHistoryList_cannotDeleteCurrent(),
+ Severity.Warning));
+ return; // abort
+ }
+ }
+ delete(doomedIds);
+ }
+ }
+ });
+
+ addTableAction(extendLocatorId("Compare"), MSG.common_button_compare(),
null, new AbstractTableAction(
+ TableActionEnablement.MULTIPLE) {
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ ArrayList<ResourceConfigurationUpdate> configs = new
ArrayList<ResourceConfigurationUpdate>();
+ for (ListGridRecord record : selection) {
+ ResourceConfigurationUpdate update = (ResourceConfigurationUpdate)
record
+
.getAttributeAsObject(AbstractConfigurationHistoryDataSource.Field.OBJECT);
+ configs.add(update);
+ }
+ ConfigurationComparisonView.displayComparisonDialog(configs);
+ }
+ });
+
+ if (getResourceId() != null) {
+ addTableAction(extendLocatorId("Rollback"),
MSG.view_configurationHistoryList_rollback(), MSG
+ .common_msg_areYouSure(), new AbstractTableAction(hasWritePerm ?
TableActionEnablement.SINGLE
+ : TableActionEnablement.NEVER) {
+ public void executeAction(ListGridRecord[] selection, Object actionValue)
{
+ if (selection != null && selection.length == 1) {
+ ListGridRecord record = selection[0];
+
rollback(record.getAttributeAsInt(AbstractConfigurationHistoryDataSource.Field.ID).intValue());
+ }
+ }
+ });
+ }
+
+ super.configureTable();
+ }
+
+ @Override
+ protected String getDetailsLinkColumnName() {
+ return AbstractConfigurationHistoryDataSource.Field.ID;
+ }
+
+ @Override
+ protected CellFormatter getDetailsLinkColumnCellFormatter() {
+ return new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
+ Integer recordId = getId(record);
+ String detailsUrl = "#" + getBasePath() + "/" +
recordId;
+ String cellHtml = SeleniumUtility.getLocatableHref(detailsUrl,
value.toString(), null);
+ String isCurrentConfig = record
+
.getAttribute(AbstractConfigurationHistoryDataSource.Field.CURRENT_CONFIG);
+ if (Boolean.parseBoolean(isCurrentConfig)) {
+ cellHtml = Canvas.imgHTML(ImageManager.getApproveIcon()) + cellHtml;
+ }
+ return cellHtml;
+ }
+ };
+ }
+
+ protected abstract void rollback(int configHistoryIdToRollbackTo);
+
+ protected abstract void delete(int[] doomedIds);
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
index 579083e..a71c133 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
@@ -18,40 +18,18 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.fields.DataSourceIntegerField;
-import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.types.DateDisplayFormat;
-import com.smartgwt.client.types.ListGridFieldType;
-import com.smartgwt.client.widgets.Canvas;
-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.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
-import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* A data source that loads information about all the configuration changes that
happened
@@ -60,190 +38,20 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public class ConfigurationHistoryDataSource extends
RPCDataSource<ResourceConfigurationUpdate> {
-
- public static abstract class Field {
- public static final String ID = "id";
- public static final String RESOURCE = "resource";
- public static final String CREATED_TIME = "createdTime";
- public static final String STATUS = "status";
- public static final String SUBJECT = "subject";
- public static final String RESOURCE_TYPE_ID = "resourceTypeId";
- public static final String CONFIGURATION = "configuration";
- public static final String GROUP_CONFIG_UPDATE_ID =
"groupConfigUpdateId";
- public static final String GROUP_ID = "groupId"; // will only be
non-null if group config update id is non-null
- public static final String DURATION = "duration";
- public static final String ERROR_MESSAGE = "errorMessage";
- public static final String MODIFIED_TIME = "modifiedTime";
- public static final String CURRENT_CONFIG = "currentConfig"; // will be
true if the history item represents the current config
- public static final String OBJECT = "object"; // the full entity object
is stored in this attribute
- }
-
- public static abstract class CriteriaField {
- public static final String RESOURCE_ID = "resourceId";
- }
-
- private ConfigurationGWTServiceAsync configurationService =
GWTServiceLookup.getConfigurationService();
+public class ConfigurationHistoryDataSource extends
AbstractConfigurationHistoryDataSource<ResourceConfigurationUpdate> {
public ConfigurationHistoryDataSource() {
super();
- List<DataSourceField> fields = addDataSourceFields();
- addFields(fields);
}
- /**
- * Views that use this data source can call this method to get a list of fields
- * that can be used in a list grid to show the data for this data source.
- *
- * @param includeResourceFields if true, the list of fields that are returned will
- * include fields to show individual resource data.
- * Pass in false if you are only collecting data on a
- * single resource, since you don't need every row
to
- * show the same data on the same resource.
- * @return fields
- */
- public ArrayList<ListGridField> getListGridFields(boolean
includeResourceFields) {
- ArrayList<ListGridField> fields = new ArrayList<ListGridField>();
-
- ListGridField idField = new ListGridField(Field.ID, MSG.common_title_version());
- idField.setShowHover(true);
- idField.setHoverCustomizer(new HoverCustomizer() {
- @Override
- public String hoverHTML(Object value, ListGridRecord record, int rowNum, int
colNum) {
- if (Boolean.parseBoolean(record.getAttribute(Field.CURRENT_CONFIG))) {
- return MSG.dataSource_configurationHistory_currentConfig();
- }
- return null;
- }
- });
- fields.add(idField);
-
- ListGridField submittedTimeField = new ListGridField(Field.CREATED_TIME, MSG
- .dataSource_configurationHistory_dateSubmitted());
- submittedTimeField.setType(ListGridFieldType.DATE);
- submittedTimeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
- fields.add(submittedTimeField);
-
- ListGridField completedTimeField = new ListGridField(Field.MODIFIED_TIME, MSG
- .dataSource_configurationHistory_dateCompleted());
- completedTimeField.setType(ListGridFieldType.DATE);
- completedTimeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
- fields.add(completedTimeField);
-
- ListGridField statusField = new ListGridField(Field.STATUS,
MSG.common_title_status());
- statusField.setAlign(Alignment.CENTER);
- statusField.setCellFormatter(new CellFormatter() {
- public String format(Object value, ListGridRecord listGridRecord, int i, int
i1) {
- ConfigurationUpdateStatus status =
ConfigurationUpdateStatus.valueOf(value.toString());
- return Canvas.imgHTML(ImageManager.getResourceConfigurationIcon(status),
16, 16);
- }
- });
- statusField.setShowHover(true);
- statusField.setHoverCustomizer(new HoverCustomizer() {
- @Override
- public String hoverHTML(Object value, ListGridRecord record, int rowNum, int
colNum) {
- String html = null;
- String err = record.getAttribute(Field.ERROR_MESSAGE);
- if (err != null && err.length() > 0) {
- html = MSG.dataSource_configurationHistory_clickToSeeError();
- } else {
- ConfigurationUpdateStatus status =
ConfigurationUpdateStatus.valueOf(record
- .getAttribute(Field.STATUS));
- switch (status) {
- case SUCCESS: {
- html = MSG.common_status_success();
- break;
- }
- case FAILURE: {
- html = MSG.common_status_failed();
- break;
- }
- case INPROGRESS: {
- html = MSG.common_status_inprogress();
- break;
- }
- case NOCHANGE: {
- html = MSG.common_status_success();
- break;
- }
- }
- }
- return html;
- }
- });
- statusField.addRecordClickHandler(new RecordClickHandler() {
- @Override
- public void onRecordClick(RecordClickEvent event) {
- String err = event.getRecord().getAttribute(Field.ERROR_MESSAGE);
- if (err != null && err.length() > 0) {
- err = "<pre>" + err + "</pre>";
- new ErrorMessageWindow("errWin", MSG.common_title_error(),
err).show();
- }
- }
- });
- fields.add(statusField);
-
- ListGridField subjectField = new ListGridField(Field.SUBJECT,
MSG.common_title_user());
- fields.add(subjectField);
-
- ListGridField updateTypeField = new ListGridField(Field.GROUP_CONFIG_UPDATE_ID,
MSG
- .dataSource_configurationHistory_updateType());
- updateTypeField.setCellFormatter(new CellFormatter() {
- @Override
- public String format(Object value, ListGridRecord record, int rowNum, int
colNum) {
- if (value == null) {
- return MSG.dataSource_configurationHistory_updateType_individual();
- }
- Integer groupId = record.getAttributeAsInt(Field.GROUP_ID);
- return "<a href=\""
- + LinkManager.getGroupResourceConfigurationUpdateHistoryLink(groupId,
((Number) value).intValue())
- + "\">" +
MSG.dataSource_configurationHistory_updateType_group() + "</a>";
- }
- });
- fields.add(updateTypeField);
-
- // determine the widths of our columns
- if (includeResourceFields) {
- 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) {
- if (listGridRecord == null) {
- return "unknown";
- }
- Resource res = (Resource)
listGridRecord.getAttributeAsObject(Field.RESOURCE);
- String url = LinkManager.getResourceLink(res.getId());
- // TODO disambiguate the resource name
- return SeleniumUtility.getLocatableHref(url, res.getName(), null);
- }
- });
- fields.add(resourceField);
-
- idField.setWidth("10%");
- submittedTimeField.setWidth("20%");
- completedTimeField.setWidth("20%");
- statusField.setWidth("10%");
- subjectField.setWidth("10%");
- updateTypeField.setWidth("10%");
- resourceField.setWidth("*");
- } else {
- idField.setWidth("10%");
- submittedTimeField.setWidth("20%");
- completedTimeField.setWidth("20%");
- statusField.setWidth("10%");
- subjectField.setWidth("10%");
- updateTypeField.setWidth("*");
- }
-
- return fields;
+ @Override
+ protected String getConfigurationUpdateStatusIcon(ConfigurationUpdateStatus status)
{
+ return ImageManager.getResourceConfigurationIcon(status);
}
@Override
- protected List<DataSourceField> addDataSourceFields() {
- List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceIntegerField idField = new DataSourceIntegerField(Field.ID,
MSG.common_title_version());
- idField.setPrimaryKey(true);
- fields.add(idField);
- return fields;
+ protected String getGroupConfigurationUpdateHistoryLink(Integer groupId, Number
value) {
+ return LinkManager.getGroupResourceConfigurationUpdateHistoryLink(groupId,
value.intValue());
}
@Override
@@ -261,7 +69,7 @@ public class ConfigurationHistoryDataSource extends
RPCDataSource<ResourceConfig
criteria.addFilterResourceIds(resourceId);
}
- configurationService.findResourceConfigurationUpdatesByCriteria(criteria,
+ getConfigurationService().findResourceConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.dataSource_configurationHistory_error_fetchFailure(),
@@ -281,7 +89,7 @@ public class ConfigurationHistoryDataSource extends
RPCDataSource<ResourceConfig
// we are obtaining a single resource's history items. Let's
find out which is
// its latest, current config item so we can mark it as such
-
configurationService.getLatestResourceConfigurationUpdate(resourceId.intValue(),
+
getConfigurationService().getLatestResourceConfigurationUpdate(resourceId.intValue(),
new AsyncCallback<ResourceConfigurationUpdate>() {
@Override
public void onSuccess(ResourceConfigurationUpdate
latestResult) {
@@ -310,33 +118,4 @@ public class ConfigurationHistoryDataSource extends
RPCDataSource<ResourceConfig
}
});
}
-
- @Override
- public ResourceConfigurationUpdate copyValues(Record from) {
- return (ResourceConfigurationUpdate) from.getAttributeAsObject(Field.OBJECT);
- }
-
- @Override
- public ListGridRecord copyValues(ResourceConfigurationUpdate from) {
- ListGridRecord record = new ListGridRecord();
- record.setAttribute(Field.ID, from.getId());
- record.setAttribute(Field.RESOURCE, from.getResource());
- record.setAttribute(Field.RESOURCE_TYPE_ID,
from.getResource().getResourceType().getId());
- record.setAttribute(Field.SUBJECT, from.getSubjectName());
- record.setAttribute(Field.STATUS, from.getStatus().name());
- record.setAttribute(Field.CONFIGURATION, from.getConfiguration());
- record.setAttribute(Field.DURATION, from.getDuration());
- record.setAttribute(Field.ERROR_MESSAGE, from.getErrorMessage());
- record.setAttribute(Field.CREATED_TIME, new Date(from.getCreatedTime()));
- // if it is still in progress, the modified time (which we label as "date
completed") is meaningless since it isn't completed yet
- if (from.getStatus() != ConfigurationUpdateStatus.INPROGRESS) {
- record.setAttribute(Field.MODIFIED_TIME, new Date(from.getModifiedTime()));
- }
- if (from.getGroupConfigurationUpdate() != null) {
- record.setAttribute(Field.GROUP_CONFIG_UPDATE_ID,
from.getGroupConfigurationUpdate().getId());
- record.setAttribute(Field.GROUP_ID,
from.getGroupConfigurationUpdate().getGroup().getId()); // note group must be eagerly
loaded here
- }
- record.setAttribute(Field.OBJECT, from);
- return record;
- }
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDetailView.java
index 136ba94..2ea63c4 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDetailView.java
@@ -82,7 +82,6 @@ public class ConfigurationHistoryDetailView extends LocatableVLayout
implements
}
public void onSuccess(PageList<ResourceConfigurationUpdate> result)
{
-
ResourceConfigurationUpdate update = result.get(0);
displayHistory(update);
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
index cf83667..c445d32 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
@@ -18,30 +18,14 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration;
-import java.util.ArrayList;
-import java.util.List;
-
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import
org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationComparisonView;
-import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryDataSource.Field;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* The main view that lists all resource configuration history items.
@@ -49,20 +33,15 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public class ConfigurationHistoryView extends
TableSection<ConfigurationHistoryDataSource> {
- public static final ViewName VIEW_ID = new
ViewName("RecentConfigurationChanges", MSG
+public class ConfigurationHistoryView extends
AbstractConfigurationHistoryView<ConfigurationHistoryDataSource> {
+ public static final ViewName VIEW_ID = new
ViewName("ConfigurationHistoryView", MSG
.view_configurationHistoryList_title());
- private Integer resourceId;
- private boolean hasWritePerm; // can delete history or rollback to a previous config
-
/**
* Use this constructor to view config histories for all viewable Resources.
*/
public ConfigurationHistoryView(String locatorId, boolean hasWritePerm) {
- super(locatorId, VIEW_ID.getTitle());
- this.hasWritePerm = hasWritePerm;
- this.resourceId = null;
+ super(locatorId, VIEW_ID.getTitle(), hasWritePerm);
ConfigurationHistoryDataSource datasource = new
ConfigurationHistoryDataSource();
setDataSource(datasource);
}
@@ -73,101 +52,20 @@ public class ConfigurationHistoryView extends
TableSection<ConfigurationHistoryD
* @param resourceId a Resource ID
*/
public ConfigurationHistoryView(String locatorId, boolean hasWritePerm, int
resourceId) {
- super(locatorId, VIEW_ID.getTitle(), createCriteria(resourceId));
- this.hasWritePerm = hasWritePerm;
- this.resourceId = resourceId;
+ super(locatorId, VIEW_ID.getTitle(), hasWritePerm, resourceId);
ConfigurationHistoryDataSource datasource = new
ConfigurationHistoryDataSource();
setDataSource(datasource);
}
- private static Criteria createCriteria(int resourceId) {
- Criteria criteria = new Criteria();
- criteria.addCriteria(ConfigurationHistoryDataSource.CriteriaField.RESOURCE_ID,
resourceId);
- return criteria;
- }
-
- @Override
- protected void configureTable() {
- List<ListGridField> fields =
getDataSource().getListGridFields(this.resourceId == null);
- setListGridFields(true, fields.toArray(new ListGridField[fields.size()])); //
true = always show the ID field
- getListGrid().sort(Field.ID, SortDirection.DESCENDING);
-
- addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(),
MSG.common_msg_areYouSure(),
- new AbstractTableAction(hasWritePerm ? TableActionEnablement.ANY :
TableActionEnablement.NEVER) {
- public void executeAction(ListGridRecord[] selection, Object actionValue)
{
- if (selection != null && selection.length > 0) {
- int[] doomedIds = new int[selection.length];
- int i = 0;
- for (ListGridRecord selected : selection) {
- doomedIds[i] = selected.getAttributeAsInt(Field.ID);
- if (selected.getAttribute(Field.GROUP_CONFIG_UPDATE_ID) !=
null) {
- CoreGUI.getMessageCenter().notify(
- new
Message(MSG.view_configurationHistoryList_cannotDeleteGroupItems(),
- Severity.Warning));
- return; // abort
- }
- }
- delete(doomedIds);
- }
- }
- });
-
- addTableAction(extendLocatorId("Compare"), MSG.common_button_compare(),
null, new AbstractTableAction(
- TableActionEnablement.MULTIPLE) {
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ArrayList<ResourceConfigurationUpdate> configs = new
ArrayList<ResourceConfigurationUpdate>();
- for (ListGridRecord record : selection) {
- ResourceConfigurationUpdate update = (ResourceConfigurationUpdate)
record
-
.getAttributeAsObject(ConfigurationHistoryDataSource.Field.OBJECT);
- configs.add(update);
- }
- ConfigurationComparisonView.displayComparisonDialog(configs);
- }
- });
-
- addTableAction(extendLocatorId("Rollback"),
MSG.view_configurationHistoryList_rollback(), MSG
- .common_msg_areYouSure(), new AbstractTableAction(hasWritePerm ?
TableActionEnablement.SINGLE
- : TableActionEnablement.NEVER) {
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- if (selection != null && selection.length == 1) {
- ListGridRecord record = selection[0];
- rollback(record.getAttributeAsInt(Field.ID).intValue());
- }
- }
- });
-
- super.configureTable();
- }
-
- @Override
- protected String getDetailsLinkColumnName() {
- return Field.ID;
- }
-
- @Override
- protected CellFormatter getDetailsLinkColumnCellFormatter() {
- return new CellFormatter() {
- public String format(Object value, ListGridRecord record, int i, int i1) {
- Integer recordId = getId(record);
- String detailsUrl = "#" + getBasePath() + "/" +
recordId;
- String cellHtml = SeleniumUtility.getLocatableHref(detailsUrl,
value.toString(), null);
- String isCurrentConfig = record.getAttribute(Field.CURRENT_CONFIG);
- if (Boolean.parseBoolean(isCurrentConfig)) {
- cellHtml = Canvas.imgHTML(ImageManager.getApproveIcon()) + cellHtml;
- }
- return cellHtml;
- }
- };
- }
-
@Override
public Canvas getDetailsView(int id) {
ConfigurationHistoryDetailView detailView = new
ConfigurationHistoryDetailView(this.getLocatorId());
return detailView;
}
- private void rollback(int configHistoryIdToRollbackTo) {
-
GWTServiceLookup.getConfigurationService().rollbackResourceConfiguration(this.resourceId.intValue(),
+ @Override
+ protected void rollback(int configHistoryIdToRollbackTo) {
+
GWTServiceLookup.getConfigurationService().rollbackResourceConfiguration(getResourceId().intValue(),
configHistoryIdToRollbackTo, new AsyncCallback<Void>() {
@Override
public void onSuccess(Void result) {
@@ -183,7 +81,8 @@ public class ConfigurationHistoryView extends
TableSection<ConfigurationHistoryD
});
}
- private void delete(int[] doomedIds) {
+ @Override
+ protected void delete(int[] doomedIds) {
GWTServiceLookup.getConfigurationService().purgeResourceConfigurationUpdates(doomedIds,
true,
new AsyncCallback<Void>() {
@Override
@@ -199,11 +98,4 @@ public class ConfigurationHistoryView extends
TableSection<ConfigurationHistoryD
}
});
}
-
- // -------- Static Utility loaders ------------
-
- public static ConfigurationHistoryView getHistoryOf(String locatorId, boolean
hasWritePerm, int resourceId) {
- return new ConfigurationHistoryView(locatorId, hasWritePerm, resourceId);
- }
-
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationSettings.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationSettings.java
deleted file mode 100644
index 506e130..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationSettings.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
-
-import java.util.EnumSet;
-import java.util.Map;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.Overflow;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.core.domain.resource.composite.ResourcePermission;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
-import
org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-
-/**
- * Read only view that shows resource plugin configuration properties.
- *
- * @author John Mazzitelli
- */
-public class HistoryPluginConfigurationSettings extends LocatableVLayout {
- private final Resource resource;
- private final ResourcePermission resourcePerms;
- private final int resourceUpdateId;
- private ConfigurationDefinition configurationDefinition;
- private Configuration resourceConfiguration;
- private ConfigurationEditor editor;
-
- public HistoryPluginConfigurationSettings(String locatorId, ResourceComposite
composite, int updateId) {
- super(locatorId);
- this.resource = composite.getResource();
- this.resourcePerms = composite.getResourcePermission();
- this.resourceUpdateId = updateId;
-
- setMargin(5);
- setMembersMargin(5);
- String backPath =
LinkManager.getResourcePluginConfigurationUpdateHistoryLink(this.resource.getId());
- BackButton backButton = new BackButton(extendLocatorId("BackButton"),
MSG.view_tableSection_backButton(),
- backPath);
- addMember(backButton);
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
- if (this.resourcePerms.isInventory()) {
- loadConfigurationDefinition();
- loadConfiguration();
- } else {
- CoreGUI.getMessageCenter().notify(new
Message(MSG.view_connectionSettingsHistory_view_noperm()));
- }
- }
-
- private void initEditor() {
- if (this.configurationDefinition != null && this.resourceConfiguration !=
null) {
- this.editor = new
ConfigurationEditor(this.extendLocatorId("Editor"),
this.configurationDefinition,
- this.resourceConfiguration);
-
this.editor.setEditorTitle(MSG.view_connectionSettingsHistory_view_connProperties() +
" - "
- + this.resourceUpdateId);
- this.editor.setOverflow(Overflow.AUTO);
- this.editor.setReadOnly(true);
- addMember(this.editor);
- }
- }
-
- private void loadConfigurationDefinition() {
- if (this.configurationDefinition == null) {
- final ResourceType type = this.resource.getResourceType();
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(new Integer[] {
type.getId() },
-
EnumSet.of(ResourceTypeRepository.MetadataType.pluginConfigurationDefinition),
- new ResourceTypeRepository.TypesLoadedCallback() {
- public void onTypesLoaded(Map<Integer, ResourceType> types) {
- configurationDefinition =
types.get(type.getId()).getPluginConfigurationDefinition();
- if (configurationDefinition == null) {
- throw new IllegalStateException("Connection settings are
not supported by this group.");
- }
- initEditor();
- }
- });
- }
- }
-
- private void loadConfiguration() {
- this.resourceConfiguration = null;
-
- PluginConfigurationUpdateCriteria criteria = new
PluginConfigurationUpdateCriteria();
- criteria.addFilterId(resourceUpdateId);
- criteria.fetchConfiguration(true);
-
-
GWTServiceLookup.getConfigurationService().findPluginConfigurationUpdatesByCriteria(criteria,
- new AsyncCallback<PageList<PluginConfigurationUpdate>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
-
MSG.view_connectionSettingsHistory_settings_fetchFailure(resource.getName()), caught);
- }
-
- public void onSuccess(PageList<PluginConfigurationUpdate> results)
{
- if (results != null && results.size() > 0) {
- resourceConfiguration = results.get(0).getConfiguration();
- initEditor();
- } else {
- // should never really happen
- CoreGUI.getErrorHandler().handleError(
-
MSG.view_connectionSettingsHistory_settings_fetchFailure(resource.getName()),
- new Throwable("bad results"));
- }
- }
- });
- }
-}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
deleted file mode 100644
index 9a43379..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.HashMap;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.types.ListGridFieldType;
-import com.smartgwt.client.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.HoverCustomizer;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
-import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
-
-import org.rhq.core.domain.configuration.AbstractConfigurationUpdate;
-import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
-import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.core.domain.resource.composite.ResourcePermission;
-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.configuration.ConfigurationComparisonView;
-import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
-import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
-import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryDataSource.Field;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-
-/**
- * Table showing resource plugin configuration history.
- *
- * @author John Mazzitelli
- */
-public class HistoryPluginConfigurationView extends
TableSection<HistoryPluginConfigurationView.DataSource> {
- public static final ViewName VIEW_ID = new ViewName("ConnectionSettings",
MSG
- .view_tabs_common_connectionSettingsHistory());
-
- private final Resource resource;
- private final ResourcePermission resourcePerms;
-
- public HistoryPluginConfigurationView(String locatorId, ResourceComposite composite)
{
- super(locatorId, VIEW_ID.getTitle());
- this.resource = composite.getResource();
- this.resourcePerms = composite.getResourcePermission();
-
- setDataSource(new DataSource());
- }
-
- @Override
- protected String getDetailsLinkColumnName() {
- return DataSource.ID;
- }
-
- @Override
- protected void configureTable() {
- ListGridField fieldId = new ListGridField(DataSource.ID,
MSG.common_title_version());
- ListGridField fieldDateCreated = new ListGridField(DataSource.DATE_CREATED,
MSG.common_title_dateCreated());
- ListGridField fieldLastUpdated = new ListGridField(DataSource.LAST_UPDATED,
MSG.common_title_lastUpdated());
- ListGridField fieldStatus = new ListGridField(DataSource.STATUS,
MSG.common_title_status());
- ListGridField fieldUser = new ListGridField(DataSource.USER,
MSG.common_title_user());
-
- fieldId.setWidth("10%");
- fieldDateCreated.setWidth("35%");
- fieldLastUpdated.setWidth("35%");
- fieldStatus.setWidth("10%");
- fieldUser.setWidth("*");
-
- fieldStatus.setType(ListGridFieldType.ICON);
- HashMap<String, String> statusIcons = new HashMap<String,
String>(4);
- statusIcons.put(ConfigurationUpdateStatus.SUCCESS.name(), ImageManager
- .getPluginConfigurationIcon(ConfigurationUpdateStatus.SUCCESS));
- statusIcons.put(ConfigurationUpdateStatus.FAILURE.name(), ImageManager
- .getPluginConfigurationIcon(ConfigurationUpdateStatus.FAILURE));
- statusIcons.put(ConfigurationUpdateStatus.INPROGRESS.name(), ImageManager
- .getPluginConfigurationIcon(ConfigurationUpdateStatus.INPROGRESS));
- statusIcons.put(ConfigurationUpdateStatus.NOCHANGE.name(), ImageManager
- .getPluginConfigurationIcon(ConfigurationUpdateStatus.NOCHANGE));
- fieldStatus.setValueIcons(statusIcons);
- fieldStatus.addRecordClickHandler(new RecordClickHandler() {
- @Override
- public void onRecordClick(RecordClickEvent event) {
- final Window winModal = new
LocatableWindow(HistoryPluginConfigurationView.this
- .extendLocatorId("statusDetailsWin"));
-
winModal.setTitle(MSG.view_connectionSettingsHistory_table_statusDetails());
- 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(HistoryPluginConfigurationView.this
- .extendLocatorId("statusDetailsPane"));
- htmlPane.setMargin(10);
- htmlPane.setDefaultWidth(500);
- htmlPane.setDefaultHeight(400);
- htmlPane.setContents(getStatusHtmlString(event.getRecord()));
- winModal.addItem(htmlPane);
- winModal.show();
- }
- });
- fieldStatus.setShowHover(true);
- fieldStatus.setHoverCustomizer(new HoverCustomizer() {
- @Override
- public String hoverHTML(Object value, ListGridRecord record, int rowNum, int
colNum) {
- String html = getStatusHtmlString(record);
- return html;
- }
- });
-
- ListGrid listGrid = getListGrid();
- listGrid.setFields(fieldId, fieldDateCreated, fieldLastUpdated, fieldStatus,
fieldUser);
-
- addTableAction(extendLocatorId("deleteAction"),
MSG.common_button_delete(), MSG.common_msg_areYouSure(),
- new AbstractTableAction(this.resourcePerms.isInventory() ?
TableActionEnablement.ANY
- : TableActionEnablement.NEVER) {
-
- @Override
- public void executeAction(final ListGridRecord[] selection, Object
actionValue) {
- if (selection == null || selection.length == 0) {
- return;
- }
-
- ConfigurationGWTServiceAsync service =
GWTServiceLookup.getConfigurationService();
- int[] updateIds = new int[selection.length];
- int i = 0;
- for (ListGridRecord record : selection) {
- updateIds[i++] =
record.getAttributeAsInt(DataSource.ID).intValue();
- }
-
- service.purgePluginConfigurationUpdates(updateIds, true, new
AsyncCallback<Void>() {
- @Override
- public void onSuccess(Void result) {
- refresh();
- Message message = new Message(
-
MSG.view_connectionSettingsHistory_table_deleteSuccessful(String
- .valueOf(selection.length)), Message.Severity.Info,
EnumSet.of(
- Message.Option.Transient, Message.Option.Sticky));
- CoreGUI.getMessageCenter().notify(message);
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_connectionSettingsHistory_table_deleteFailure(),
caught);
- }
- });
- }
- });
-
- addTableAction(extendLocatorId("Compare"), MSG.common_button_compare(),
null, new AbstractTableAction(
- TableActionEnablement.MULTIPLE) {
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ArrayList<PluginConfigurationUpdate> configs = new
ArrayList<PluginConfigurationUpdate>();
- for (ListGridRecord record : selection) {
- PluginConfigurationUpdate update = (PluginConfigurationUpdate)
record
- .getAttributeAsObject(DataSource.OBJECT);
- configs.add(update);
- }
- ConfigurationComparisonView.displayComparisonDialog(configs);
- }
- });
-
- addTableAction(extendLocatorId("Rollback"),
MSG.view_connectionSettingsHistory_table_rollback(), MSG
- .common_msg_areYouSure(), new AbstractTableAction(
- this.resourcePerms.isInventory() ? TableActionEnablement.SINGLE :
TableActionEnablement.NEVER) {
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- if (selection != null && selection.length == 1) {
- ListGridRecord record = selection[0];
-
GWTServiceLookup.getConfigurationService().rollbackPluginConfiguration(resource.getId(),
- record.getAttributeAsInt(Field.ID).intValue(), new
AsyncCallback<Void>() {
- @Override
- public void onSuccess(Void result) {
- CoreGUI.getMessageCenter().notify(
- new
Message(MSG.view_connectionSettingsHistory_table_rollback_success(),
- Severity.Info));
- refresh();
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
-
MSG.view_connectionSettingsHistory_table_rollback_failure(), caught);
- }
- });
- }
- }
- });
-
- }
-
- private String getStatusHtmlString(Record record) {
- String html = null;
- AbstractConfigurationUpdate obj = (AbstractConfigurationUpdate)
record.getAttributeAsObject(DataSource.OBJECT);
- switch (obj.getStatus()) {
- case SUCCESS: {
- html = MSG.view_connectionSettingsHistory_table_statusSuccess();
- break;
- }
- case INPROGRESS: {
- html = "<p>" +
MSG.view_connectionSettingsHistory_table_statusInprogress() + "</p>";
- break;
- }
- case NOCHANGE: {
- html = MSG.view_connectionSettingsHistory_table_statusNochange();
- break;
- }
- case FAILURE: {
- html = obj.getErrorMessage();
- if (html == null) {
- html = "<p>" +
MSG.view_connectionSettingsHistory_table_statusFailure() + "</p>";
- } else {
- if (html.length() > 80) {
- // this was probably an error stack trace, snip it so the tooltip
isn't too big
- html = "<pre>" + html.substring(0, 80) +
"...</pre><p>"
- + MSG.view_connectionSettingsHistory_table_clickStatusIcon() +
"</p>";
- } else {
- html = "<pre>" + html + "</pre>";
- }
- }
- break;
- }
- }
- return html;
- }
-
- class DataSource extends RPCDataSource<PluginConfigurationUpdate> {
-
- public static final String ID = "id";
- public static final String DATE_CREATED = "dateCreated";
- public static final String LAST_UPDATED = "lastUpdated";
- public static final String USER = "user";
- public static final String STATUS = "status";
- public static final String OBJECT = "object";
-
- @Override
- public PluginConfigurationUpdate copyValues(Record from) {
- return (PluginConfigurationUpdate)
from.getAttributeAsObject(DataSource.OBJECT);
- }
-
- @Override
- public ListGridRecord copyValues(PluginConfigurationUpdate from) {
- ListGridRecord record = new ListGridRecord();
-
- record.setAttribute(DataSource.ID, from.getId());
- record.setAttribute(DataSource.DATE_CREATED, new
Date(from.getCreatedTime()));
- record.setAttribute(DataSource.LAST_UPDATED, new
Date(from.getModifiedTime()));
- record.setAttribute(DataSource.USER, from.getSubjectName());
- record.setAttribute(DataSource.STATUS, from.getStatus().name());
-
- record.setAttribute(DataSource.OBJECT, from);
-
- return record;
- }
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response)
{
- ConfigurationGWTServiceAsync configurationService =
GWTServiceLookup.getConfigurationService();
-
- PluginConfigurationUpdateCriteria criteria = new
PluginConfigurationUpdateCriteria();
-
criteria.addFilterResourceIds(HistoryPluginConfigurationView.this.resource.getId());
-
- configurationService.findPluginConfigurationUpdatesByCriteria(criteria,
- new AsyncCallback<PageList<PluginConfigurationUpdate>>() {
-
- @Override
- public void onSuccess(PageList<PluginConfigurationUpdate>
result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
-
- @Override
- public void onFailure(Throwable caught) {
-
CoreGUI.getErrorHandler().handleError(MSG.view_connectionSettingsHistory_table_failFetch(),
- caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
- });
- }
- }
-
- @Override
- public Canvas getDetailsView(int id) {
- // TODO Auto-generated method stub
- return null;
- }
-}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDataSource.java
new file mode 100644
index 0000000..77a3bcc
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDataSource.java
@@ -0,0 +1,122 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
+import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
+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.inventory.resource.detail.configuration.AbstractConfigurationHistoryDataSource;
+
+/**
+ * A data source that loads information about all the plugin configuration changes that
happened
+ * for a resource or across all inventory.
+ *
+ * @author John Mazzitelli
+ */
+public class PluginConfigurationHistoryDataSource extends
+ AbstractConfigurationHistoryDataSource<PluginConfigurationUpdate> {
+
+ public PluginConfigurationHistoryDataSource() {
+ super();
+ }
+
+ @Override
+ protected String getConfigurationUpdateStatusIcon(ConfigurationUpdateStatus status)
{
+ return ImageManager.getPluginConfigurationIcon(status);
+ }
+
+ @Override
+ protected String getGroupConfigurationUpdateHistoryLink(Integer groupId, Number
value) {
+ return LinkManager.getGroupPluginConfigurationUpdateHistoryLink(groupId,
value.intValue());
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+
+ PluginConfigurationUpdateCriteria criteria = new
PluginConfigurationUpdateCriteria();
+ criteria.fetchConfiguration(true);
+ criteria.fetchResource(true);
+ criteria.fetchGroupConfigurationUpdate(true);
+
+ criteria.setPageControl(getPageControl(request));
+
+ final Integer resourceId = (Integer)
request.getCriteria().getValues().get(CriteriaField.RESOURCE_ID);
+ if (resourceId != null) {
+ criteria.addFilterResourceIds(resourceId);
+ }
+
+ getConfigurationService().findPluginConfigurationUpdatesByCriteria(criteria,
+ new AsyncCallback<PageList<PluginConfigurationUpdate>>() {
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.dataSource_configurationHistory_error_fetchFailure(),
+ caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(final PageList<PluginConfigurationUpdate>
result) {
+ final ListGridRecord[] records = buildRecords(result);
+ if (resourceId == null) {
+ response.setData(records);
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ return; // we can finish now, we don't need any additional
information
+ }
+
+ // we are obtaining a single resource's history items. Let's
find out which is
+ // its latest, current config item so we can mark it as such
+
getConfigurationService().getLatestPluginConfigurationUpdate(resourceId.intValue(),
+ new AsyncCallback<PluginConfigurationUpdate>() {
+ @Override
+ public void onSuccess(PluginConfigurationUpdate latestResult)
{
+ if (latestResult != null) {
+ for (ListGridRecord record : records) {
+ boolean latest =
record.getAttributeAsInt(Field.ID).intValue() == latestResult
+ .getId();
+ record.setAttribute(Field.CURRENT_CONFIG,
latest);
+ }
+ }
+ finish();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ // should we show an error message? this just means we
can't show any item as the "current" one
+ finish();
+ }
+
+ private void finish() {
+ response.setData(records);
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+ });
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDetailView.java
new file mode 100644
index 0000000..f3d48f5
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDetailView.java
@@ -0,0 +1,90 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
+
+import java.util.EnumSet;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import
org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author John Mazzitelli
+ */
+public class PluginConfigurationHistoryDetailView extends LocatableVLayout implements
BookmarkableView {
+
+ public PluginConfigurationHistoryDetailView(String locatorId) {
+ super(locatorId);
+
+ setWidth100();
+ setHeight100();
+ }
+
+ private void displayHistory(final PluginConfigurationUpdate update) {
+
+
ResourceTypeRepository.Cache.getInstance().getResourceTypes(update.getResource().getResourceType().getId(),
+
EnumSet.of(ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+
+ public void onTypesLoaded(ResourceType type) {
+ ConfigurationDefinition definition =
type.getPluginConfigurationDefinition();
+ ConfigurationEditor editor = new
ConfigurationEditor("PluginConfigHist-"
+ + update.getResource().getName(), definition,
update.getConfiguration());
+ editor.setReadOnly(true);
+ addMember(editor);
+ markForRedraw();
+ }
+ });
+ }
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+
+ int updateId = viewPath.getCurrentAsInt();
+
+ PluginConfigurationUpdateCriteria criteria = new
PluginConfigurationUpdateCriteria();
+ criteria.fetchConfiguration(true);
+ criteria.fetchResource(true);
+ criteria.addFilterId(updateId);
+
+
GWTServiceLookup.getConfigurationService().findPluginConfigurationUpdatesByCriteria(criteria,
+ new AsyncCallback<PageList<PluginConfigurationUpdate>>() {
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_configurationHistoryDetails_error_loadFailure(),
+ caught);
+ }
+
+ public void onSuccess(PageList<PluginConfigurationUpdate> result)
{
+ PluginConfigurationUpdate update = result.get(0);
+ displayHistory(update);
+ }
+ });
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java
new file mode 100644
index 0000000..fdd6657
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java
@@ -0,0 +1,103 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Canvas;
+
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+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.inventory.resource.detail.configuration.AbstractConfigurationHistoryView;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
+
+/**
+ * The main view that lists all plugin configuration history items.
+ *
+ * @author Greg Hinkle
+ * @author John Mazzitelli
+ */
+public class PluginConfigurationHistoryView extends
+ AbstractConfigurationHistoryView<PluginConfigurationHistoryDataSource> {
+ public static final ViewName VIEW_ID = new
ViewName("PluginConfigurationHistoryView", MSG
+ .view_tabs_common_connectionSettingsHistory());
+
+ /**
+ * Use this constructor to view plugin config histories for all viewable Resources.
+ */
+ public PluginConfigurationHistoryView(String locatorId, boolean hasWritePerm) {
+ super(locatorId, VIEW_ID.getTitle(), hasWritePerm);
+ PluginConfigurationHistoryDataSource datasource = new
PluginConfigurationHistoryDataSource();
+ setDataSource(datasource);
+ }
+
+ /**
+ * Use this constructor to view the plugin config history for the Resource with the
specified ID.
+ *
+ * @param resourceId a Resource ID
+ */
+ public PluginConfigurationHistoryView(String locatorId, boolean hasWritePerm, int
resourceId) {
+ super(locatorId, VIEW_ID.getTitle(), hasWritePerm, resourceId);
+ PluginConfigurationHistoryDataSource datasource = new
PluginConfigurationHistoryDataSource();
+ setDataSource(datasource);
+ }
+
+ @Override
+ public Canvas getDetailsView(int id) {
+ PluginConfigurationHistoryDetailView detailView = new
PluginConfigurationHistoryDetailView(this.getLocatorId());
+ return detailView;
+ }
+
+ @Override
+ protected void rollback(int configHistoryIdToRollbackTo) {
+
GWTServiceLookup.getConfigurationService().rollbackPluginConfiguration(getResourceId().intValue(),
+ configHistoryIdToRollbackTo, new AsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_configurationHistoryList_rollback_success(),
Severity.Info));
+ refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_configurationHistoryList_rollback_failure(),
caught);
+ }
+ });
+ }
+
+ @Override
+ protected void delete(int[] doomedIds) {
+
GWTServiceLookup.getConfigurationService().purgePluginConfigurationUpdates(doomedIds,
true,
+ new AsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_configurationHistoryList_delete_success(),
Severity.Info));
+ refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_configurationHistoryList_delete_failure(),
caught);
+ }
+ });
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
index ff848de..e30b1f1 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
@@ -98,6 +98,17 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl
implemen
}
@Override
+ public PluginConfigurationUpdate getLatestPluginConfigurationUpdate(int resourceId)
throws RuntimeException {
+ try {
+ PluginConfigurationUpdate update =
configurationManager.getLatestPluginConfigurationUpdate(
+ getSessionSubject(), resourceId);
+ return SerialUtility.prepare(update,
"ConfigurationService.getLatestPluginConfigurationUpdate");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
+ }
+
+ @Override
public Configuration getPluginConfiguration(int resourceId) throws RuntimeException
{
try {
Configuration configuration =
configurationManager.getPluginConfiguration(getSessionSubject(), resourceId);
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 951f0b9..2caa83d 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
@@ -1727,24 +1727,6 @@ view_connectionSettingsDetails_messageDetailed_updateSuccess =
Connection settin
view_connectionSettingsDetails_allPropertiesValid = All connection settings have valid
values, so the settings can now be saved.
view_connectionSettingsDetails_somePropertiesInvalid = The following connection settings
have invalid values: {0}. The values must be corrected before the settings can be saved.
-# Connection History
-#-----------------------------------------
-view_connectionSettingsHistory_view_noperm = You do not have permissions to see the
connection settings
-view_connectionSettingsHistory_view_connProperties = Connection Properties
-view_connectionSettingsHistory_table_rollback = Rollback
-view_connectionSettingsHistory_table_rollback_success = You successfully rolled back the
resource configuration to the selected past configuration.
-view_connectionSettingsHistory_table_rollback_failure = Failed to rollback the
configuration. The original configuration is still in effect.
-view_connectionSettingsHistory_table_failFetch = Failed to get plugin config history
-view_connectionSettingsHistory_table_statusDetails = Status Details
-view_connectionSettingsHistory_table_deleteSuccessful = You have successfully deleted
[{0}] history items
-view_connectionSettingsHistory_table_deleteFailure = Failed to delete plugin
configuration history
-view_connectionSettingsHistory_table_statusSuccess = This configuration update was
successful
-view_connectionSettingsHistory_table_statusInprogress = This configuration update is
still in progress
-view_connectionSettingsHistory_table_statusNochange = No changes were made to this
configuration
-view_connectionSettingsHistory_table_statusFailure = This configuration update failed
-view_connectionSettingsHistory_table_clickStatusIcon = Click the status icon for full
details
-view_connectionSettingsHistory_settings_fetchFailure = Failed to retrieve connection
settings for [{0}]
-
# Resource Resource Groups
#-----------------------------------------
view_resourceResourceGroupList_error_fetchFailure = Failed to fetch Resource''s
groups.
@@ -1760,15 +1742,25 @@ view_configurationDetails_messageDetailed = Configuration updated
for Resource [
view_configurationDetails_allPropertiesValid = All configuration properties have valid
values, so the configuration can now be saved.
view_configurationDetails_somePropertiesInvalid = The following configuration properties
have invalid values: {0}. The values must be corrected before the configuration can be
saved.
-# Configuration History List
+# Resource Configuration History List
+#-------------------------------
view_configurationHistoryList_title = Configuration History
+
+# Abstract Configuration History List
+#-------------------------------
view_configurationHistoryList_rollback = Rollback
-view_configurationHistoryList_rollback_success = You successfully rolled back the
resource configuration to the selected past configuration.
+view_configurationHistoryList_rollback_success = You successfully rolled back the
configuration to the selected past configuration.
view_configurationHistoryList_rollback_failure = Failed to rollback the configuration.
The original configuration is still in effect.
view_configurationHistoryList_delete_success = You successfully deleted the selected
configuration history items.
view_configurationHistoryList_delete_failure = Failed to delete the configuration history
items.
view_configurationHistoryList_cannotDeleteGroupItems = One or more selected configuration
history items are part of a group configuration update. \
You must purge that parent group history item before you can delete its individual
resource history items.
+view_configurationHistoryList_cannotDeleteCurrent = One of the selected history items
represents the current configuration - you cannot delete it.
+view_configurationHistoryList_table_statusSuccess = This configuration update was
successful
+view_configurationHistoryList_table_statusInprogress = This configuration update is still
in progress
+view_configurationHistoryList_table_statusNochange = No changes were made to this
configuration
+view_configurationHistoryList_table_statusFailure = This configuration update failed
+view_configurationHistoryList_table_clickStatusIcon = Click the status icon for full
details
# Configuration History Details
#------------------------------------------
commit 9a45e868aa6db13ba0aa326d581a896205733dda
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Feb 24 15:02:10 2011 -0500
more code to support plugin configuration history pages
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractResourceConfigurationUpdate.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractResourceConfigurationUpdate.java
index 5f377cf..aa073a6 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractResourceConfigurationUpdate.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractResourceConfigurationUpdate.java
@@ -34,6 +34,8 @@ import javax.persistence.InheritanceType;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import org.rhq.core.domain.resource.Resource;
+
/**
* Provides a {@link Configuration configuration} that constitutes a configuration update
request. This allows you to
* maintain a history of a configuration update request - when it was made, who made it
and if it was successful or not.
@@ -57,6 +59,8 @@ public abstract class AbstractResourceConfigurationUpdate extends
AbstractConfig
@Id
private int id;
+ public abstract Resource getResource();
+
protected AbstractResourceConfigurationUpdate() {
}
@@ -70,7 +74,7 @@ public abstract class AbstractResourceConfigurationUpdate extends
AbstractConfig
protected AbstractResourceConfigurationUpdate(Configuration config, String
subjectName) {
super(subjectName);
//this.configuration = config.deepCopy(false);
- this.configuration = config.deepCopyWithoutProxies();
+ this.configuration = config.deepCopyWithoutProxies();
}
public int getId() {
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PluginConfigurationUpdate.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PluginConfigurationUpdate.java
index b07e884..d7e7af4 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PluginConfigurationUpdate.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PluginConfigurationUpdate.java
@@ -154,6 +154,7 @@ public class PluginConfigurationUpdate extends
AbstractResourceConfigurationUpda
this.resource = resource;
}
+ @Override
public Resource getResource() {
return resource;
}
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdate.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdate.java
index e0a2460..b814ea4 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdate.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdate.java
@@ -207,6 +207,7 @@ public class ResourceConfigurationUpdate extends
AbstractResourceConfigurationUp
this.resource = resource;
}
+ @Override
public Resource getResource() {
return resource;
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationComparisonView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationComparisonView.java
index f9e4970..3b462c2 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationComparisonView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationComparisonView.java
@@ -35,9 +35,9 @@ import com.smartgwt.client.widgets.tree.TreeGridField;
import com.smartgwt.client.widgets.tree.TreeNode;
import org.rhq.core.domain.configuration.AbstractPropertyMap;
+import org.rhq.core.domain.configuration.AbstractResourceConfigurationUpdate;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
@@ -172,7 +172,7 @@ public class ConfigurationComparisonView extends VLayout {
parent.setChildren(children.toArray(new TreeNode[children.size()]));
}
- public static void displayComparisonDialog(final
ArrayList<ResourceConfigurationUpdate> configs) {
+ public static void displayComparisonDialog(final ArrayList<? extends
AbstractResourceConfigurationUpdate> configs) {
int resourceId = configs.get(0).getResource().getResourceType().getId();
ResourceTypeRepository.Cache.getInstance().getResourceTypes(resourceId,
EnumSet.of(ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
@@ -184,7 +184,7 @@ public class ConfigurationComparisonView extends VLayout {
ArrayList<Configuration> configurations = new
ArrayList<Configuration>();
ArrayList<String> titles = new ArrayList<String>();
- for (ResourceConfigurationUpdate update : configs) {
+ for (AbstractResourceConfigurationUpdate update : configs) {
configurations.add(update.getConfiguration());
titles.add(String.valueOf(update.getId()));
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
index 45bd2c4..171a28e 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
@@ -30,6 +30,8 @@ public interface ConfigurationGWTService extends RemoteService {
void purgeResourceConfigurationUpdates(int[] configUpdateIds, boolean
purgeInProgress) throws RuntimeException;
+ void rollbackPluginConfiguration(int resourceId, int configHistoryId) throws
RuntimeException;
+
void rollbackResourceConfiguration(int resourceId, int configHistoryId) throws
RuntimeException;
ResourceConfigurationUpdate getLatestResourceConfigurationUpdate(int resourceId)
throws RuntimeException;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
index ea03013..9a43379 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
+import java.util.ArrayList;
import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
@@ -28,6 +29,7 @@ import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.ListGridFieldType;
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;
@@ -48,14 +50,17 @@ import org.rhq.core.domain.resource.composite.ResourcePermission;
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.configuration.ConfigurationComparisonView;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryDataSource.Field;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
@@ -190,6 +195,46 @@ public class HistoryPluginConfigurationView extends
TableSection<HistoryPluginCo
});
}
});
+
+ addTableAction(extendLocatorId("Compare"), MSG.common_button_compare(),
null, new AbstractTableAction(
+ TableActionEnablement.MULTIPLE) {
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ ArrayList<PluginConfigurationUpdate> configs = new
ArrayList<PluginConfigurationUpdate>();
+ for (ListGridRecord record : selection) {
+ PluginConfigurationUpdate update = (PluginConfigurationUpdate)
record
+ .getAttributeAsObject(DataSource.OBJECT);
+ configs.add(update);
+ }
+ ConfigurationComparisonView.displayComparisonDialog(configs);
+ }
+ });
+
+ addTableAction(extendLocatorId("Rollback"),
MSG.view_connectionSettingsHistory_table_rollback(), MSG
+ .common_msg_areYouSure(), new AbstractTableAction(
+ this.resourcePerms.isInventory() ? TableActionEnablement.SINGLE :
TableActionEnablement.NEVER) {
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ if (selection != null && selection.length == 1) {
+ ListGridRecord record = selection[0];
+
GWTServiceLookup.getConfigurationService().rollbackPluginConfiguration(resource.getId(),
+ record.getAttributeAsInt(Field.ID).intValue(), new
AsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new
Message(MSG.view_connectionSettingsHistory_table_rollback_success(),
+ Severity.Info));
+ refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+
MSG.view_connectionSettingsHistory_table_rollback_failure(), caught);
+ }
+ });
+ }
+ }
+ });
+
}
private String getStatusHtmlString(Record record) {
@@ -283,4 +328,10 @@ public class HistoryPluginConfigurationView extends
TableSection<HistoryPluginCo
});
}
}
+
+ @Override
+ public Canvas getDetailsView(int id) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
index a301b44..ff848de 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
@@ -78,6 +78,15 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl
implemen
}
@Override
+ public void rollbackPluginConfiguration(int resourceId, int configHistoryId) throws
RuntimeException {
+ try {
+ configurationManager.rollbackPluginConfiguration(getSessionSubject(),
resourceId, configHistoryId);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
+ }
+
+ @Override
public ResourceConfigurationUpdate getLatestResourceConfigurationUpdate(int
resourceId) throws RuntimeException {
try {
ResourceConfigurationUpdate update =
configurationManager.getLatestResourceConfigurationUpdate(
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 401359f..951f0b9 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
@@ -1731,9 +1731,12 @@ view_connectionSettingsDetails_somePropertiesInvalid = The
following connection
#-----------------------------------------
view_connectionSettingsHistory_view_noperm = You do not have permissions to see the
connection settings
view_connectionSettingsHistory_view_connProperties = Connection Properties
+view_connectionSettingsHistory_table_rollback = Rollback
+view_connectionSettingsHistory_table_rollback_success = You successfully rolled back the
resource configuration to the selected past configuration.
+view_connectionSettingsHistory_table_rollback_failure = Failed to rollback the
configuration. The original configuration is still in effect.
view_connectionSettingsHistory_table_failFetch = Failed to get plugin config history
view_connectionSettingsHistory_table_statusDetails = Status Details
-view_connectionSettingsHistory_table_deleteSuccessful = You have deleted [{0}] history
items
+view_connectionSettingsHistory_table_deleteSuccessful = You have successfully deleted
[{0}] history items
view_connectionSettingsHistory_table_deleteFailure = Failed to delete plugin
configuration history
view_connectionSettingsHistory_table_statusSuccess = This configuration update was
successful
view_connectionSettingsHistory_table_statusInprogress = This configuration update is
still in progress
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index 5c82990..1552162 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -1184,6 +1184,19 @@ public class ConfigurationManagerBean implements
ConfigurationManagerLocal, Conf
}
}
+ public void rollbackPluginConfiguration(Subject subject, int resourceId, int
configHistoryId)
+ throws ConfigurationUpdateException {
+ PluginConfigurationUpdate configurationUpdateHistory =
entityManager.find(PluginConfigurationUpdate.class,
+ configHistoryId);
+ Configuration configuration = configurationUpdateHistory.getConfiguration();
+ if (configuration == null) {
+ throw new ConfigurationUpdateException("No plugin configuration history
element exists with id = '"
+ + configHistoryId + "'");
+ }
+
+ updatePluginConfiguration(subject, resourceId, configuration);
+ }
+
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public ResourceConfigurationUpdate
persistNewResourceConfigurationUpdateHistory(Subject subject, int resourceId,
Configuration newConfiguration, ConfigurationUpdateStatus newStatus, String
newSubject,
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
index 37d8a06..018b6eb 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
@@ -165,6 +165,24 @@ public interface ConfigurationManagerLocal {
throws ConfigurationUpdateException;
/**
+ * This method is called when a user has requested to change the plugin configuration
for an existing resource to
+ * one of its previous values. If the user does not have the proper permissions to
change the resource's
+ * plugin configuration, an exception is thrown.
+ *
+ * <p>This will not wait for the agent to finish the configuration update. This
will return after the request is
+ * sent. Once the agent finishes with the request, it will send the completed request
information to
+ * {@link #completePluginConfigurationUpdate}.</p>
+ *
+ * @param subject the user who is requesting the update
+ * @param resourceId identifies the resource to be updated
+ * @param configHistoryId the id of the resource's previous configuration to
rollback to
+ *
+ * @throws ConfigurationUpdateException if the configHistoryId does not exist
+ */
+ void rollbackPluginConfiguration(Subject subject, int resourceId, int
configHistoryId)
+ throws ConfigurationUpdateException;
+
+ /**
* For internal use only - do not call this method. This is for
* {@link #updateResourceConfiguration(Subject, int, Configuration)} to call with
REQUIRES_NEW transaction scope so
* it can force the new request to be committed to the DB. Also used by
commit 2d043745134c1f4e35065e6197b18711156f5820
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Feb 24 15:01:51 2011 -0500
dont' refresh the entire ui, just the table
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
index 837206b..cf83667 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
@@ -173,7 +173,7 @@ public class ConfigurationHistoryView extends
TableSection<ConfigurationHistoryD
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_configurationHistoryList_rollback_success(),
Severity.Info));
- CoreGUI.refresh();
+ refresh();
}
@Override
@@ -190,7 +190,7 @@ public class ConfigurationHistoryView extends
TableSection<ConfigurationHistoryD
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_configurationHistoryList_delete_success(),
Severity.Info));
- CoreGUI.refresh();
+ refresh();
}
@Override
commit fd3ea15d142423479c30eacdcbeaecabbde0fe56
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Feb 24 14:33:16 2011 -0500
remove unused imports
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdate.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdate.java
index 79c0145..c6d5cbf 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdate.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdate.java
@@ -22,8 +22,6 @@
*/
package org.rhq.core.domain.configuration;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
import java.io.Serializable;
import javax.persistence.CascadeType;
@@ -244,7 +242,8 @@ public abstract class AbstractConfigurationUpdate implements
Serializable {
@Override
public String toString() {
- StringBuilder str = new
StringBuilder(this.getClass().getName().substring(this.getClass().getName().lastIndexOf(".")+1));
+ StringBuilder str = new StringBuilder(this.getClass().getName().substring(
+ this.getClass().getName().lastIndexOf(".") + 1));
str.append("[status=").append(this.status);
str.append(", configuration=").append(this.configuration);
str.append(", subjectName=").append(this.subjectName);
commit 7966ffef9b662085ad2ac066a5665d74ed3ef106
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Feb 24 14:32:57 2011 -0500
adding auth check to res config history views
more coding for plugin config history views (not done yet)
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 d5da970..a1b2fc3 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
@@ -146,8 +146,8 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
.view_tabs_common_child_history()), null);
inventoryConn = new
SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), new ViewName(
"ConnectionSettings", MSG.view_tabs_common_connectionSettings()),
null);
- inventoryConnHistory = new
SubTab(inventoryTab.extendLocatorId("ConnSetHist"), new ViewName(
- "ConnectionSettingsHistory",
MSG.view_tabs_common_connectionSettingsHistory()), null);
+ inventoryConnHistory = new
SubTab(inventoryTab.extendLocatorId("ConnSetHist"),
+ HistoryPluginConfigurationView.VIEW_ID, null);
inventoryGroups = new SubTab(inventoryTab.extendLocatorId("Groups"),
new ViewName("Groups", MSG
.view_tabs_common_groups()), null);
inventoryAgent = new SubTab(inventoryTab.extendLocatorId("Agent"), new
ViewName("Agent", MSG
@@ -365,7 +365,8 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
.extendLocatorId("ResourceConfigView"), resourceComposite),
true, true);
updateSubTab(this.configurationTab, this.configHistory,
ConfigurationHistoryView.getHistoryOf(this
- .extendLocatorId("ConfigHistView"), resource.getId()), true,
true);
+ .extendLocatorId("ConfigHistView"),
this.resourceComposite.getResourcePermission().isConfigureWrite(),
+ resource.getId()), true, true);
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
index 5e7bc9e..837206b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
@@ -54,12 +54,14 @@ public class ConfigurationHistoryView extends
TableSection<ConfigurationHistoryD
.view_configurationHistoryList_title());
private Integer resourceId;
+ private boolean hasWritePerm; // can delete history or rollback to a previous config
/**
* Use this constructor to view config histories for all viewable Resources.
*/
- public ConfigurationHistoryView(String locatorId) {
+ public ConfigurationHistoryView(String locatorId, boolean hasWritePerm) {
super(locatorId, VIEW_ID.getTitle());
+ this.hasWritePerm = hasWritePerm;
this.resourceId = null;
ConfigurationHistoryDataSource datasource = new
ConfigurationHistoryDataSource();
setDataSource(datasource);
@@ -70,8 +72,9 @@ public class ConfigurationHistoryView extends
TableSection<ConfigurationHistoryD
*
* @param resourceId a Resource ID
*/
- public ConfigurationHistoryView(String locatorId, int resourceId) {
+ public ConfigurationHistoryView(String locatorId, boolean hasWritePerm, int
resourceId) {
super(locatorId, VIEW_ID.getTitle(), createCriteria(resourceId));
+ this.hasWritePerm = hasWritePerm;
this.resourceId = resourceId;
ConfigurationHistoryDataSource datasource = new
ConfigurationHistoryDataSource();
setDataSource(datasource);
@@ -90,7 +93,7 @@ public class ConfigurationHistoryView extends
TableSection<ConfigurationHistoryD
getListGrid().sort(Field.ID, SortDirection.DESCENDING);
addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(),
MSG.common_msg_areYouSure(),
- new AbstractTableAction(TableActionEnablement.ANY) {
+ new AbstractTableAction(hasWritePerm ? TableActionEnablement.ANY :
TableActionEnablement.NEVER) {
public void executeAction(ListGridRecord[] selection, Object actionValue)
{
if (selection != null && selection.length > 0) {
int[] doomedIds = new int[selection.length];
@@ -123,7 +126,8 @@ public class ConfigurationHistoryView extends
TableSection<ConfigurationHistoryD
});
addTableAction(extendLocatorId("Rollback"),
MSG.view_configurationHistoryList_rollback(), MSG
- .common_msg_areYouSure(), new
AbstractTableAction(TableActionEnablement.SINGLE) {
+ .common_msg_areYouSure(), new AbstractTableAction(hasWritePerm ?
TableActionEnablement.SINGLE
+ : TableActionEnablement.NEVER) {
public void executeAction(ListGridRecord[] selection, Object actionValue) {
if (selection != null && selection.length == 1) {
ListGridRecord record = selection[0];
@@ -198,8 +202,8 @@ public class ConfigurationHistoryView extends
TableSection<ConfigurationHistoryD
// -------- Static Utility loaders ------------
- public static ConfigurationHistoryView getHistoryOf(String locatorId, int resourceId)
{
- return new ConfigurationHistoryView(locatorId, resourceId);
+ public static ConfigurationHistoryView getHistoryOf(String locatorId, boolean
hasWritePerm, int resourceId) {
+ return new ConfigurationHistoryView(locatorId, hasWritePerm, resourceId);
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationTable.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationTable.java
deleted file mode 100644
index 1e6ccb4..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationTable.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
-
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.HashMap;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.types.ListGridFieldType;
-import com.smartgwt.client.types.Overflow;
-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.HoverCustomizer;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
-import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
-
-import org.rhq.core.domain.configuration.AbstractConfigurationUpdate;
-import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
-import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.core.domain.resource.composite.ResourcePermission;
-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.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.gwt.ConfigurationGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-
-/**
- * Table showing resource plugin configuration history.
- *
- * @author John Mazzitelli
- */
-public class HistoryPluginConfigurationTable extends
Table<HistoryPluginConfigurationTable.DataSource> {
- private final Resource resource;
- private final ResourcePermission resourcePerms;
-
- public HistoryPluginConfigurationTable(String locatorId, ResourceComposite composite)
{
- super(locatorId, MSG.view_connectionSettingsHistory_table_title());
- this.resource = composite.getResource();
- this.resourcePerms = composite.getResourcePermission();
-
- setDataSource(new DataSource());
- }
-
- @Override
- protected void configureTable() {
- ListGridField fieldId = new ListGridField(DataSource.ID,
MSG.common_title_version());
- ListGridField fieldDateCreated = new ListGridField(DataSource.DATE_CREATED,
MSG.common_title_dateCreated());
- ListGridField fieldLastUpdated = new ListGridField(DataSource.LAST_UPDATED,
MSG.common_title_lastUpdated());
- ListGridField fieldUser = new ListGridField(DataSource.USER,
MSG.common_title_user());
- ListGridField fieldStatus = new ListGridField(DataSource.STATUS,
MSG.common_title_status());
-
- fieldId.setWidth("10%");
- fieldDateCreated.setWidth("35%");
- fieldLastUpdated.setWidth("35%");
- fieldUser.setWidth("*");
- fieldStatus.setWidth("10%");
-
- fieldStatus.setType(ListGridFieldType.ICON);
- HashMap<String, String> statusIcons = new HashMap<String,
String>(4);
- statusIcons.put(ConfigurationUpdateStatus.SUCCESS.name(), ImageManager
- .getPluginConfigurationIcon(ConfigurationUpdateStatus.SUCCESS));
- statusIcons.put(ConfigurationUpdateStatus.FAILURE.name(), ImageManager
- .getPluginConfigurationIcon(ConfigurationUpdateStatus.FAILURE));
- statusIcons.put(ConfigurationUpdateStatus.INPROGRESS.name(), ImageManager
- .getPluginConfigurationIcon(ConfigurationUpdateStatus.INPROGRESS));
- statusIcons.put(ConfigurationUpdateStatus.NOCHANGE.name(), ImageManager
- .getPluginConfigurationIcon(ConfigurationUpdateStatus.NOCHANGE));
- fieldStatus.setValueIcons(statusIcons);
- fieldStatus.addRecordClickHandler(new RecordClickHandler() {
- @Override
- public void onRecordClick(RecordClickEvent event) {
- final Window winModal = new
LocatableWindow(HistoryPluginConfigurationTable.this
- .extendLocatorId("statusDetailsWin"));
-
winModal.setTitle(MSG.view_connectionSettingsHistory_table_statusDetails());
- 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(HistoryPluginConfigurationTable.this
- .extendLocatorId("statusDetailsPane"));
- htmlPane.setMargin(10);
- htmlPane.setDefaultWidth(500);
- htmlPane.setDefaultHeight(400);
- htmlPane.setContents(getStatusHtmlString(event.getRecord()));
- winModal.addItem(htmlPane);
- winModal.show();
- }
- });
- fieldStatus.setShowHover(true);
- fieldStatus.setHoverCustomizer(new HoverCustomizer() {
- @Override
- public String hoverHTML(Object value, ListGridRecord record, int rowNum, int
colNum) {
- String html = getStatusHtmlString(record);
- return html;
- }
- });
-
- ListGrid listGrid = getListGrid();
- listGrid.setFields(fieldId, fieldDateCreated, fieldLastUpdated, fieldUser,
fieldStatus);
-
- addTableAction(extendLocatorId("deleteAction"),
MSG.common_button_delete(), MSG.common_msg_areYouSure(),
- new AbstractTableAction(this.resourcePerms.isInventory() ?
TableActionEnablement.ANY
- : TableActionEnablement.NEVER) {
-
- @Override
- public void executeAction(final ListGridRecord[] selection, Object
actionValue) {
- if (selection == null || selection.length == 0) {
- return;
- }
-
- ConfigurationGWTServiceAsync service =
GWTServiceLookup.getConfigurationService();
- int[] updateIds = new int[selection.length];
- int i = 0;
- for (ListGridRecord record : selection) {
- updateIds[i++] =
record.getAttributeAsInt(DataSource.ID).intValue();
- }
-
- service.purgePluginConfigurationUpdates(updateIds, true, new
AsyncCallback<Void>() {
- @Override
- public void onSuccess(Void result) {
- refresh();
- Message message = new Message(
-
MSG.view_connectionSettingsHistory_table_deleteSuccessful(String
- .valueOf(selection.length)), Message.Severity.Info,
EnumSet.of(
- Message.Option.Transient, Message.Option.Sticky));
- CoreGUI.getMessageCenter().notify(message);
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_connectionSettingsHistory_table_deleteFailure(),
caught);
- }
- });
- }
- });
- }
-
- private String getStatusHtmlString(Record record) {
- String html = null;
- AbstractConfigurationUpdate obj = (AbstractConfigurationUpdate)
record.getAttributeAsObject(DataSource.OBJECT);
- switch (obj.getStatus()) {
- case SUCCESS: {
- html = MSG.view_connectionSettingsHistory_table_statusSuccess();
- break;
- }
- case INPROGRESS: {
- html = "<p>" +
MSG.view_connectionSettingsHistory_table_statusInprogress() + "</p>";
- break;
- }
- case NOCHANGE: {
- html = MSG.view_connectionSettingsHistory_table_statusNochange();
- break;
- }
- case FAILURE: {
- html = obj.getErrorMessage();
- if (html == null) {
- html = "<p>" +
MSG.view_connectionSettingsHistory_table_statusFailure() + "</p>";
- } else {
- if (html.length() > 80) {
- // this was probably an error stack trace, snip it so the tooltip
isn't too big
- html = "<pre>" + html.substring(0, 80) +
"...</pre><p>"
- + MSG.view_connectionSettingsHistory_table_clickStatusIcon() +
"</p>";
- } else {
- html = "<pre>" + html + "</pre>";
- }
- }
- break;
- }
- }
- return html;
- }
-
- class DataSource extends RPCDataSource<PluginConfigurationUpdate> {
-
- public static final String ID = "id";
- public static final String DATE_CREATED = "dateCreated";
- public static final String LAST_UPDATED = "lastUpdated";
- public static final String USER = "user";
- public static final String STATUS = "status";
- public static final String OBJECT = "object";
-
- @Override
- public PluginConfigurationUpdate copyValues(Record from) {
- return (PluginConfigurationUpdate)
from.getAttributeAsObject(DataSource.OBJECT);
- }
-
- @Override
- public ListGridRecord copyValues(PluginConfigurationUpdate from) {
- ListGridRecord record = new ListGridRecord();
-
- record.setAttribute(DataSource.ID, from.getId());
- record.setAttribute(DataSource.DATE_CREATED, new
Date(from.getCreatedTime()));
- record.setAttribute(DataSource.LAST_UPDATED, new
Date(from.getModifiedTime()));
- record.setAttribute(DataSource.USER, from.getSubjectName());
- record.setAttribute(DataSource.STATUS, from.getStatus().name());
-
- record.setAttribute(DataSource.OBJECT, from);
-
- return record;
- }
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response)
{
- ConfigurationGWTServiceAsync configurationService =
GWTServiceLookup.getConfigurationService();
-
- PluginConfigurationUpdateCriteria criteria = new
PluginConfigurationUpdateCriteria();
-
criteria.addFilterResourceIds(HistoryPluginConfigurationTable.this.resource.getId());
-
- configurationService.findPluginConfigurationUpdatesByCriteria(criteria,
- new AsyncCallback<PageList<PluginConfigurationUpdate>>() {
-
- @Override
- public void onSuccess(PageList<PluginConfigurationUpdate>
result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
-
- @Override
- public void onFailure(Throwable caught) {
-
CoreGUI.getErrorHandler().handleError(MSG.view_connectionSettingsHistory_table_failFetch(),
- caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
- });
- }
- }
-}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
new file mode 100644
index 0000000..ea03013
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
@@ -0,0 +1,286 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
+
+import java.util.Date;
+import java.util.EnumSet;
+import java.util.HashMap;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.types.Overflow;
+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.HoverCustomizer;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
+import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
+
+import org.rhq.core.domain.configuration.AbstractConfigurationUpdate;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
+import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.resource.composite.ResourcePermission;
+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.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+
+/**
+ * Table showing resource plugin configuration history.
+ *
+ * @author John Mazzitelli
+ */
+public class HistoryPluginConfigurationView extends
TableSection<HistoryPluginConfigurationView.DataSource> {
+ public static final ViewName VIEW_ID = new ViewName("ConnectionSettings",
MSG
+ .view_tabs_common_connectionSettingsHistory());
+
+ private final Resource resource;
+ private final ResourcePermission resourcePerms;
+
+ public HistoryPluginConfigurationView(String locatorId, ResourceComposite composite)
{
+ super(locatorId, VIEW_ID.getTitle());
+ this.resource = composite.getResource();
+ this.resourcePerms = composite.getResourcePermission();
+
+ setDataSource(new DataSource());
+ }
+
+ @Override
+ protected String getDetailsLinkColumnName() {
+ return DataSource.ID;
+ }
+
+ @Override
+ protected void configureTable() {
+ ListGridField fieldId = new ListGridField(DataSource.ID,
MSG.common_title_version());
+ ListGridField fieldDateCreated = new ListGridField(DataSource.DATE_CREATED,
MSG.common_title_dateCreated());
+ ListGridField fieldLastUpdated = new ListGridField(DataSource.LAST_UPDATED,
MSG.common_title_lastUpdated());
+ ListGridField fieldStatus = new ListGridField(DataSource.STATUS,
MSG.common_title_status());
+ ListGridField fieldUser = new ListGridField(DataSource.USER,
MSG.common_title_user());
+
+ fieldId.setWidth("10%");
+ fieldDateCreated.setWidth("35%");
+ fieldLastUpdated.setWidth("35%");
+ fieldStatus.setWidth("10%");
+ fieldUser.setWidth("*");
+
+ fieldStatus.setType(ListGridFieldType.ICON);
+ HashMap<String, String> statusIcons = new HashMap<String,
String>(4);
+ statusIcons.put(ConfigurationUpdateStatus.SUCCESS.name(), ImageManager
+ .getPluginConfigurationIcon(ConfigurationUpdateStatus.SUCCESS));
+ statusIcons.put(ConfigurationUpdateStatus.FAILURE.name(), ImageManager
+ .getPluginConfigurationIcon(ConfigurationUpdateStatus.FAILURE));
+ statusIcons.put(ConfigurationUpdateStatus.INPROGRESS.name(), ImageManager
+ .getPluginConfigurationIcon(ConfigurationUpdateStatus.INPROGRESS));
+ statusIcons.put(ConfigurationUpdateStatus.NOCHANGE.name(), ImageManager
+ .getPluginConfigurationIcon(ConfigurationUpdateStatus.NOCHANGE));
+ fieldStatus.setValueIcons(statusIcons);
+ fieldStatus.addRecordClickHandler(new RecordClickHandler() {
+ @Override
+ public void onRecordClick(RecordClickEvent event) {
+ final Window winModal = new
LocatableWindow(HistoryPluginConfigurationView.this
+ .extendLocatorId("statusDetailsWin"));
+
winModal.setTitle(MSG.view_connectionSettingsHistory_table_statusDetails());
+ 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(HistoryPluginConfigurationView.this
+ .extendLocatorId("statusDetailsPane"));
+ htmlPane.setMargin(10);
+ htmlPane.setDefaultWidth(500);
+ htmlPane.setDefaultHeight(400);
+ htmlPane.setContents(getStatusHtmlString(event.getRecord()));
+ winModal.addItem(htmlPane);
+ winModal.show();
+ }
+ });
+ fieldStatus.setShowHover(true);
+ fieldStatus.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int
colNum) {
+ String html = getStatusHtmlString(record);
+ return html;
+ }
+ });
+
+ ListGrid listGrid = getListGrid();
+ listGrid.setFields(fieldId, fieldDateCreated, fieldLastUpdated, fieldStatus,
fieldUser);
+
+ addTableAction(extendLocatorId("deleteAction"),
MSG.common_button_delete(), MSG.common_msg_areYouSure(),
+ new AbstractTableAction(this.resourcePerms.isInventory() ?
TableActionEnablement.ANY
+ : TableActionEnablement.NEVER) {
+
+ @Override
+ public void executeAction(final ListGridRecord[] selection, Object
actionValue) {
+ if (selection == null || selection.length == 0) {
+ return;
+ }
+
+ ConfigurationGWTServiceAsync service =
GWTServiceLookup.getConfigurationService();
+ int[] updateIds = new int[selection.length];
+ int i = 0;
+ for (ListGridRecord record : selection) {
+ updateIds[i++] =
record.getAttributeAsInt(DataSource.ID).intValue();
+ }
+
+ service.purgePluginConfigurationUpdates(updateIds, true, new
AsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ refresh();
+ Message message = new Message(
+
MSG.view_connectionSettingsHistory_table_deleteSuccessful(String
+ .valueOf(selection.length)), Message.Severity.Info,
EnumSet.of(
+ Message.Option.Transient, Message.Option.Sticky));
+ CoreGUI.getMessageCenter().notify(message);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_connectionSettingsHistory_table_deleteFailure(),
caught);
+ }
+ });
+ }
+ });
+ }
+
+ private String getStatusHtmlString(Record record) {
+ String html = null;
+ AbstractConfigurationUpdate obj = (AbstractConfigurationUpdate)
record.getAttributeAsObject(DataSource.OBJECT);
+ switch (obj.getStatus()) {
+ case SUCCESS: {
+ html = MSG.view_connectionSettingsHistory_table_statusSuccess();
+ break;
+ }
+ case INPROGRESS: {
+ html = "<p>" +
MSG.view_connectionSettingsHistory_table_statusInprogress() + "</p>";
+ break;
+ }
+ case NOCHANGE: {
+ html = MSG.view_connectionSettingsHistory_table_statusNochange();
+ break;
+ }
+ case FAILURE: {
+ html = obj.getErrorMessage();
+ if (html == null) {
+ html = "<p>" +
MSG.view_connectionSettingsHistory_table_statusFailure() + "</p>";
+ } else {
+ if (html.length() > 80) {
+ // this was probably an error stack trace, snip it so the tooltip
isn't too big
+ html = "<pre>" + html.substring(0, 80) +
"...</pre><p>"
+ + MSG.view_connectionSettingsHistory_table_clickStatusIcon() +
"</p>";
+ } else {
+ html = "<pre>" + html + "</pre>";
+ }
+ }
+ break;
+ }
+ }
+ return html;
+ }
+
+ class DataSource extends RPCDataSource<PluginConfigurationUpdate> {
+
+ public static final String ID = "id";
+ public static final String DATE_CREATED = "dateCreated";
+ public static final String LAST_UPDATED = "lastUpdated";
+ public static final String USER = "user";
+ public static final String STATUS = "status";
+ public static final String OBJECT = "object";
+
+ @Override
+ public PluginConfigurationUpdate copyValues(Record from) {
+ return (PluginConfigurationUpdate)
from.getAttributeAsObject(DataSource.OBJECT);
+ }
+
+ @Override
+ public ListGridRecord copyValues(PluginConfigurationUpdate from) {
+ ListGridRecord record = new ListGridRecord();
+
+ record.setAttribute(DataSource.ID, from.getId());
+ record.setAttribute(DataSource.DATE_CREATED, new
Date(from.getCreatedTime()));
+ record.setAttribute(DataSource.LAST_UPDATED, new
Date(from.getModifiedTime()));
+ record.setAttribute(DataSource.USER, from.getSubjectName());
+ record.setAttribute(DataSource.STATUS, from.getStatus().name());
+
+ record.setAttribute(DataSource.OBJECT, from);
+
+ return record;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response)
{
+ ConfigurationGWTServiceAsync configurationService =
GWTServiceLookup.getConfigurationService();
+
+ PluginConfigurationUpdateCriteria criteria = new
PluginConfigurationUpdateCriteria();
+
criteria.addFilterResourceIds(HistoryPluginConfigurationView.this.resource.getId());
+
+ configurationService.findPluginConfigurationUpdatesByCriteria(criteria,
+ new AsyncCallback<PageList<PluginConfigurationUpdate>>() {
+
+ @Override
+ public void onSuccess(PageList<PluginConfigurationUpdate>
result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_connectionSettingsHistory_table_failFetch(),
+ caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+ }
+}
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 7a29da1..b82603f 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
@@ -113,7 +113,8 @@ public class ReportTopView extends AbstractSectionedLeftNavigationView
{
NavigationItem recentConfigurationChangesItem = new
NavigationItem(ConfigurationHistoryView.VIEW_ID,
"subsystems/configure/Configure_16.png", new ViewFactory() {
public Canvas createView() {
- return new
ConfigurationHistoryView(extendLocatorId(ConfigurationHistoryView.VIEW_ID.getName()));
+ return new
ConfigurationHistoryView(extendLocatorId(ConfigurationHistoryView.VIEW_ID.getName()),
+ getGlobalPermissions().contains(Permission.MANAGE_INVENTORY));
}
});
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 dbf48f4..401359f 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
@@ -1732,7 +1732,6 @@ view_connectionSettingsDetails_somePropertiesInvalid = The following
connection
view_connectionSettingsHistory_view_noperm = You do not have permissions to see the
connection settings
view_connectionSettingsHistory_view_connProperties = Connection Properties
view_connectionSettingsHistory_table_failFetch = Failed to get plugin config history
-view_connectionSettingsHistory_table_title = Connection Settings History
view_connectionSettingsHistory_table_statusDetails = Status Details
view_connectionSettingsHistory_table_deleteSuccessful = You have deleted [{0}] history
items
view_connectionSettingsHistory_table_deleteFailure = Failed to delete plugin
configuration history
commit f98ee8d204fb4a403bf14a266f7cf94295589a64
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Feb 24 13:52:12 2011 -0500
remove this file, the table will be the view now (will check that in separately)
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
deleted file mode 100644
index ff35b3e..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
-
-import com.smartgwt.client.widgets.Canvas;
-
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-
-/**
- * A view for resource plugin configuration history.
- *
- * @author John Mazzitelli
- */
-public class HistoryPluginConfigurationView extends LocatableVLayout implements
BookmarkableView {
- private final ResourceComposite resourceComposite;
- private HistoryPluginConfigurationTable historyTable;
- private Canvas detailsCanvas = null;
-
- public HistoryPluginConfigurationView(String locatorId, ResourceComposite composite)
{
- super(locatorId);
- this.resourceComposite = composite;
-
- historyTable = new
HistoryPluginConfigurationTable(extendLocatorId("Table"), composite);
- addMember(historyTable);
- }
-
- @Override
- public void renderView(ViewPath viewPath) {
- if (viewPath.isEnd()) {
- setVisibleMember(this.historyTable);
- } else {
- int historyId = viewPath.getCurrentAsInt();
-
- if (detailsCanvas != null) {
- removeMember(detailsCanvas);
- this.detailsCanvas.destroy();
- }
-
- detailsCanvas = new
HistoryPluginConfigurationSettings(extendLocatorId("SettingsView"),
- this.resourceComposite, historyId);
-
- addMember(detailsCanvas);
- setVisibleMember(detailsCanvas);
- }
- }
-}
commit bd5178f61a91718655ddd086a278810cdabe0422
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Feb 24 13:42:44 2011 -0500
the start of the resource plugin config history pages
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 5ea1c98..d010c41 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
@@ -83,6 +83,10 @@ public class LinkManager {
}
}
+ public static String getResourcePluginConfigurationUpdateHistoryLink(int groupId) {
+ return getResourceLink(groupId) +
"/Inventory/ConnectionSettingsHistory";
+ }
+
public static String getGroupPluginConfigurationUpdateHistoryLink(int groupId) {
return getResourceGroupLink(groupId) +
"/Inventory/ConnectionSettingsHistory";
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
index 25bc2dd..45bd2c4 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
@@ -21,11 +21,13 @@ import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
/**
- *
+ * API for resource and plugin configurations for resources and groups.
*/
@RemoteServiceRelativePath("ConfigurationGWTService")
public interface ConfigurationGWTService extends RemoteService {
+ void purgePluginConfigurationUpdates(int[] configUpdateIds, boolean purgeInProgress)
throws RuntimeException;
+
void purgeResourceConfigurationUpdates(int[] configUpdateIds, boolean
purgeInProgress) throws RuntimeException;
void rollbackResourceConfiguration(int resourceId, int configHistoryId) throws
RuntimeException;
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 8e6bc32..d5da970 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
@@ -58,6 +58,7 @@ import
org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceComposit
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectListener;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ResourceConfigurationEditView;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.HistoryPluginConfigurationView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.PluginConfigurationEditView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.ResourceResourceAgentView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules.SchedulesView;
@@ -280,7 +281,8 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.inventoryTab, this.inventoryConn, canvas, visible, true);
// same test, use above setting for 'visible'
- canvas = (visible) ? new Canvas() : null; // TODO: Add real canvas when visible
+ canvas = (visible) ? new
HistoryPluginConfigurationView(this.inventoryConnHistory.extendLocatorId("View"),
+ this.resourceComposite) : null;
updateSubTab(this.inventoryTab, this.inventoryConnHistory, canvas, visible,
true);
boolean canModifyMembership =
globalPermissions.contains(Permission.MANAGE_INVENTORY);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationSettings.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationSettings.java
new file mode 100644
index 0000000..506e130
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationSettings.java
@@ -0,0 +1,139 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
+
+import java.util.EnumSet;
+import java.util.Map;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Overflow;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.resource.composite.ResourcePermission;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
+import
org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * Read only view that shows resource plugin configuration properties.
+ *
+ * @author John Mazzitelli
+ */
+public class HistoryPluginConfigurationSettings extends LocatableVLayout {
+ private final Resource resource;
+ private final ResourcePermission resourcePerms;
+ private final int resourceUpdateId;
+ private ConfigurationDefinition configurationDefinition;
+ private Configuration resourceConfiguration;
+ private ConfigurationEditor editor;
+
+ public HistoryPluginConfigurationSettings(String locatorId, ResourceComposite
composite, int updateId) {
+ super(locatorId);
+ this.resource = composite.getResource();
+ this.resourcePerms = composite.getResourcePermission();
+ this.resourceUpdateId = updateId;
+
+ setMargin(5);
+ setMembersMargin(5);
+ String backPath =
LinkManager.getResourcePluginConfigurationUpdateHistoryLink(this.resource.getId());
+ BackButton backButton = new BackButton(extendLocatorId("BackButton"),
MSG.view_tableSection_backButton(),
+ backPath);
+ addMember(backButton);
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ if (this.resourcePerms.isInventory()) {
+ loadConfigurationDefinition();
+ loadConfiguration();
+ } else {
+ CoreGUI.getMessageCenter().notify(new
Message(MSG.view_connectionSettingsHistory_view_noperm()));
+ }
+ }
+
+ private void initEditor() {
+ if (this.configurationDefinition != null && this.resourceConfiguration !=
null) {
+ this.editor = new
ConfigurationEditor(this.extendLocatorId("Editor"),
this.configurationDefinition,
+ this.resourceConfiguration);
+
this.editor.setEditorTitle(MSG.view_connectionSettingsHistory_view_connProperties() +
" - "
+ + this.resourceUpdateId);
+ this.editor.setOverflow(Overflow.AUTO);
+ this.editor.setReadOnly(true);
+ addMember(this.editor);
+ }
+ }
+
+ private void loadConfigurationDefinition() {
+ if (this.configurationDefinition == null) {
+ final ResourceType type = this.resource.getResourceType();
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(new Integer[] {
type.getId() },
+
EnumSet.of(ResourceTypeRepository.MetadataType.pluginConfigurationDefinition),
+ new ResourceTypeRepository.TypesLoadedCallback() {
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ configurationDefinition =
types.get(type.getId()).getPluginConfigurationDefinition();
+ if (configurationDefinition == null) {
+ throw new IllegalStateException("Connection settings are
not supported by this group.");
+ }
+ initEditor();
+ }
+ });
+ }
+ }
+
+ private void loadConfiguration() {
+ this.resourceConfiguration = null;
+
+ PluginConfigurationUpdateCriteria criteria = new
PluginConfigurationUpdateCriteria();
+ criteria.addFilterId(resourceUpdateId);
+ criteria.fetchConfiguration(true);
+
+
GWTServiceLookup.getConfigurationService().findPluginConfigurationUpdatesByCriteria(criteria,
+ new AsyncCallback<PageList<PluginConfigurationUpdate>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+
MSG.view_connectionSettingsHistory_settings_fetchFailure(resource.getName()), caught);
+ }
+
+ public void onSuccess(PageList<PluginConfigurationUpdate> results)
{
+ if (results != null && results.size() > 0) {
+ resourceConfiguration = results.get(0).getConfiguration();
+ initEditor();
+ } else {
+ // should never really happen
+ CoreGUI.getErrorHandler().handleError(
+
MSG.view_connectionSettingsHistory_settings_fetchFailure(resource.getName()),
+ new Throwable("bad results"));
+ }
+ }
+ });
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationTable.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationTable.java
new file mode 100644
index 0000000..1e6ccb4
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationTable.java
@@ -0,0 +1,277 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
+
+import java.util.Date;
+import java.util.EnumSet;
+import java.util.HashMap;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.types.Overflow;
+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.HoverCustomizer;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
+import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
+
+import org.rhq.core.domain.configuration.AbstractConfigurationUpdate;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
+import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.resource.composite.ResourcePermission;
+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.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.gwt.ConfigurationGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+
+/**
+ * Table showing resource plugin configuration history.
+ *
+ * @author John Mazzitelli
+ */
+public class HistoryPluginConfigurationTable extends
Table<HistoryPluginConfigurationTable.DataSource> {
+ private final Resource resource;
+ private final ResourcePermission resourcePerms;
+
+ public HistoryPluginConfigurationTable(String locatorId, ResourceComposite composite)
{
+ super(locatorId, MSG.view_connectionSettingsHistory_table_title());
+ this.resource = composite.getResource();
+ this.resourcePerms = composite.getResourcePermission();
+
+ setDataSource(new DataSource());
+ }
+
+ @Override
+ protected void configureTable() {
+ ListGridField fieldId = new ListGridField(DataSource.ID,
MSG.common_title_version());
+ ListGridField fieldDateCreated = new ListGridField(DataSource.DATE_CREATED,
MSG.common_title_dateCreated());
+ ListGridField fieldLastUpdated = new ListGridField(DataSource.LAST_UPDATED,
MSG.common_title_lastUpdated());
+ ListGridField fieldUser = new ListGridField(DataSource.USER,
MSG.common_title_user());
+ ListGridField fieldStatus = new ListGridField(DataSource.STATUS,
MSG.common_title_status());
+
+ fieldId.setWidth("10%");
+ fieldDateCreated.setWidth("35%");
+ fieldLastUpdated.setWidth("35%");
+ fieldUser.setWidth("*");
+ fieldStatus.setWidth("10%");
+
+ fieldStatus.setType(ListGridFieldType.ICON);
+ HashMap<String, String> statusIcons = new HashMap<String,
String>(4);
+ statusIcons.put(ConfigurationUpdateStatus.SUCCESS.name(), ImageManager
+ .getPluginConfigurationIcon(ConfigurationUpdateStatus.SUCCESS));
+ statusIcons.put(ConfigurationUpdateStatus.FAILURE.name(), ImageManager
+ .getPluginConfigurationIcon(ConfigurationUpdateStatus.FAILURE));
+ statusIcons.put(ConfigurationUpdateStatus.INPROGRESS.name(), ImageManager
+ .getPluginConfigurationIcon(ConfigurationUpdateStatus.INPROGRESS));
+ statusIcons.put(ConfigurationUpdateStatus.NOCHANGE.name(), ImageManager
+ .getPluginConfigurationIcon(ConfigurationUpdateStatus.NOCHANGE));
+ fieldStatus.setValueIcons(statusIcons);
+ fieldStatus.addRecordClickHandler(new RecordClickHandler() {
+ @Override
+ public void onRecordClick(RecordClickEvent event) {
+ final Window winModal = new
LocatableWindow(HistoryPluginConfigurationTable.this
+ .extendLocatorId("statusDetailsWin"));
+
winModal.setTitle(MSG.view_connectionSettingsHistory_table_statusDetails());
+ 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(HistoryPluginConfigurationTable.this
+ .extendLocatorId("statusDetailsPane"));
+ htmlPane.setMargin(10);
+ htmlPane.setDefaultWidth(500);
+ htmlPane.setDefaultHeight(400);
+ htmlPane.setContents(getStatusHtmlString(event.getRecord()));
+ winModal.addItem(htmlPane);
+ winModal.show();
+ }
+ });
+ fieldStatus.setShowHover(true);
+ fieldStatus.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int
colNum) {
+ String html = getStatusHtmlString(record);
+ return html;
+ }
+ });
+
+ ListGrid listGrid = getListGrid();
+ listGrid.setFields(fieldId, fieldDateCreated, fieldLastUpdated, fieldUser,
fieldStatus);
+
+ addTableAction(extendLocatorId("deleteAction"),
MSG.common_button_delete(), MSG.common_msg_areYouSure(),
+ new AbstractTableAction(this.resourcePerms.isInventory() ?
TableActionEnablement.ANY
+ : TableActionEnablement.NEVER) {
+
+ @Override
+ public void executeAction(final ListGridRecord[] selection, Object
actionValue) {
+ if (selection == null || selection.length == 0) {
+ return;
+ }
+
+ ConfigurationGWTServiceAsync service =
GWTServiceLookup.getConfigurationService();
+ int[] updateIds = new int[selection.length];
+ int i = 0;
+ for (ListGridRecord record : selection) {
+ updateIds[i++] =
record.getAttributeAsInt(DataSource.ID).intValue();
+ }
+
+ service.purgePluginConfigurationUpdates(updateIds, true, new
AsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ refresh();
+ Message message = new Message(
+
MSG.view_connectionSettingsHistory_table_deleteSuccessful(String
+ .valueOf(selection.length)), Message.Severity.Info,
EnumSet.of(
+ Message.Option.Transient, Message.Option.Sticky));
+ CoreGUI.getMessageCenter().notify(message);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_connectionSettingsHistory_table_deleteFailure(),
caught);
+ }
+ });
+ }
+ });
+ }
+
+ private String getStatusHtmlString(Record record) {
+ String html = null;
+ AbstractConfigurationUpdate obj = (AbstractConfigurationUpdate)
record.getAttributeAsObject(DataSource.OBJECT);
+ switch (obj.getStatus()) {
+ case SUCCESS: {
+ html = MSG.view_connectionSettingsHistory_table_statusSuccess();
+ break;
+ }
+ case INPROGRESS: {
+ html = "<p>" +
MSG.view_connectionSettingsHistory_table_statusInprogress() + "</p>";
+ break;
+ }
+ case NOCHANGE: {
+ html = MSG.view_connectionSettingsHistory_table_statusNochange();
+ break;
+ }
+ case FAILURE: {
+ html = obj.getErrorMessage();
+ if (html == null) {
+ html = "<p>" +
MSG.view_connectionSettingsHistory_table_statusFailure() + "</p>";
+ } else {
+ if (html.length() > 80) {
+ // this was probably an error stack trace, snip it so the tooltip
isn't too big
+ html = "<pre>" + html.substring(0, 80) +
"...</pre><p>"
+ + MSG.view_connectionSettingsHistory_table_clickStatusIcon() +
"</p>";
+ } else {
+ html = "<pre>" + html + "</pre>";
+ }
+ }
+ break;
+ }
+ }
+ return html;
+ }
+
+ class DataSource extends RPCDataSource<PluginConfigurationUpdate> {
+
+ public static final String ID = "id";
+ public static final String DATE_CREATED = "dateCreated";
+ public static final String LAST_UPDATED = "lastUpdated";
+ public static final String USER = "user";
+ public static final String STATUS = "status";
+ public static final String OBJECT = "object";
+
+ @Override
+ public PluginConfigurationUpdate copyValues(Record from) {
+ return (PluginConfigurationUpdate)
from.getAttributeAsObject(DataSource.OBJECT);
+ }
+
+ @Override
+ public ListGridRecord copyValues(PluginConfigurationUpdate from) {
+ ListGridRecord record = new ListGridRecord();
+
+ record.setAttribute(DataSource.ID, from.getId());
+ record.setAttribute(DataSource.DATE_CREATED, new
Date(from.getCreatedTime()));
+ record.setAttribute(DataSource.LAST_UPDATED, new
Date(from.getModifiedTime()));
+ record.setAttribute(DataSource.USER, from.getSubjectName());
+ record.setAttribute(DataSource.STATUS, from.getStatus().name());
+
+ record.setAttribute(DataSource.OBJECT, from);
+
+ return record;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response)
{
+ ConfigurationGWTServiceAsync configurationService =
GWTServiceLookup.getConfigurationService();
+
+ PluginConfigurationUpdateCriteria criteria = new
PluginConfigurationUpdateCriteria();
+
criteria.addFilterResourceIds(HistoryPluginConfigurationTable.this.resource.getId());
+
+ configurationService.findPluginConfigurationUpdatesByCriteria(criteria,
+ new AsyncCallback<PageList<PluginConfigurationUpdate>>() {
+
+ @Override
+ public void onSuccess(PageList<PluginConfigurationUpdate>
result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_connectionSettingsHistory_table_failFetch(),
+ caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
new file mode 100644
index 0000000..ff35b3e
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/HistoryPluginConfigurationView.java
@@ -0,0 +1,65 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
+
+import com.smartgwt.client.widgets.Canvas;
+
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * A view for resource plugin configuration history.
+ *
+ * @author John Mazzitelli
+ */
+public class HistoryPluginConfigurationView extends LocatableVLayout implements
BookmarkableView {
+ private final ResourceComposite resourceComposite;
+ private HistoryPluginConfigurationTable historyTable;
+ private Canvas detailsCanvas = null;
+
+ public HistoryPluginConfigurationView(String locatorId, ResourceComposite composite)
{
+ super(locatorId);
+ this.resourceComposite = composite;
+
+ historyTable = new
HistoryPluginConfigurationTable(extendLocatorId("Table"), composite);
+ addMember(historyTable);
+ }
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ if (viewPath.isEnd()) {
+ setVisibleMember(this.historyTable);
+ } else {
+ int historyId = viewPath.getCurrentAsInt();
+
+ if (detailsCanvas != null) {
+ removeMember(detailsCanvas);
+ this.detailsCanvas.destroy();
+ }
+
+ detailsCanvas = new
HistoryPluginConfigurationSettings(extendLocatorId("SettingsView"),
+ this.resourceComposite, historyId);
+
+ addMember(detailsCanvas);
+ setVisibleMember(detailsCanvas);
+ }
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
index 9668517..a301b44 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
@@ -31,7 +31,7 @@ import
org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
/**
- *
+ * API for resource and plugin configurations for resources and groups.
*/
public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implements
ConfigurationGWTService {
@@ -47,6 +47,17 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl
implemen
private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
private ResourceGroupManagerLocal groupManager =
LookupUtil.getResourceGroupManager();
+ @Override
+ public void purgePluginConfigurationUpdates(int[] configUpdateIds, boolean
purgeInProgress) throws RuntimeException {
+ try {
+
this.configurationManager.purgePluginConfigurationUpdates(getSessionSubject(),
configUpdateIds,
+ purgeInProgress);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
+ }
+
+ @Override
public void purgeResourceConfigurationUpdates(int[] configUpdateIds, boolean
purgeInProgress)
throws RuntimeException {
try {
@@ -57,6 +68,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl
implemen
}
}
+ @Override
public void rollbackResourceConfiguration(int resourceId, int configHistoryId) throws
RuntimeException {
try {
configurationManager.rollbackResourceConfiguration(getSessionSubject(),
resourceId, configHistoryId);
@@ -65,6 +77,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl
implemen
}
}
+ @Override
public ResourceConfigurationUpdate getLatestResourceConfigurationUpdate(int
resourceId) throws RuntimeException {
try {
ResourceConfigurationUpdate update =
configurationManager.getLatestResourceConfigurationUpdate(
@@ -75,6 +88,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl
implemen
}
}
+ @Override
public Configuration getPluginConfiguration(int resourceId) throws RuntimeException
{
try {
Configuration configuration =
configurationManager.getPluginConfiguration(getSessionSubject(), resourceId);
@@ -84,6 +98,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl
implemen
}
}
+ @Override
public ConfigurationDefinition getPluginConfigurationDefinition(int resourceTypeId)
throws RuntimeException {
try {
ConfigurationDefinition definition =
configurationManager.getPluginConfigurationDefinitionForResourceType(
@@ -94,6 +109,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl
implemen
}
}
+ @Override
public Configuration getResourceConfiguration(int resourceId) throws RuntimeException
{
try {
Configuration configuration = configurationManager
@@ -104,6 +120,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public ConfigurationDefinition getResourceConfigurationDefinition(int resourceTypeId)
throws RuntimeException {
try {
ConfigurationDefinition definition = configurationManager
@@ -114,6 +131,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public PageList<ResourceConfigurationUpdate>
findResourceConfigurationUpdates(Integer resourceId, Long beginDate,
Long endDate, boolean suppressOldest, PageControl pc) throws RuntimeException {
try {
@@ -125,6 +143,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public ResourceConfigurationUpdate updateResourceConfiguration(int resourceId,
Configuration configuration)
throws RuntimeException {
try {
@@ -136,6 +155,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public PluginConfigurationUpdate updatePluginConfiguration(int resourceId,
Configuration configuration)
throws RuntimeException {
try {
@@ -147,6 +167,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public PageList<ResourceConfigurationUpdate>
findResourceConfigurationUpdatesByCriteria(
ResourceConfigurationUpdateCriteria criteria) throws RuntimeException {
try {
@@ -158,6 +179,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public PageList<PluginConfigurationUpdate>
findPluginConfigurationUpdatesByCriteria(
PluginConfigurationUpdateCriteria criteria) throws RuntimeException {
try {
@@ -169,6 +191,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public PageList<GroupResourceConfigurationUpdate>
findGroupResourceConfigurationUpdatesByCriteria(
GroupResourceConfigurationUpdateCriteria criteria) throws RuntimeException {
try {
@@ -181,6 +204,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public PageList<GroupPluginConfigurationUpdate>
findGroupPluginConfigurationUpdatesByCriteria(
GroupPluginConfigurationUpdateCriteria criteria) throws RuntimeException {
try {
@@ -192,6 +216,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public List<DisambiguationReport<ResourceConfigurationComposite>>
findResourceConfigurationsForGroup(int groupId)
throws RuntimeException {
try {
@@ -212,6 +237,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public List<DisambiguationReport<ResourceConfigurationComposite>>
findPluginConfigurationsForGroup(int groupId)
throws RuntimeException {
try {
@@ -231,6 +257,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public List<DisambiguationReport<ResourceConfigurationComposite>>
findPluginConfigurationsForGroupUpdate(
int groupUpdateId) throws RuntimeException {
try {
@@ -250,6 +277,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public void updateResourceConfigurationsForGroup(int groupId,
List<ResourceConfigurationComposite> resourceConfigurations) throws
RuntimeException {
try {
@@ -261,6 +289,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public void updatePluginConfigurationsForGroup(int groupId,
List<ResourceConfigurationComposite> pluginConfigurations) throws
RuntimeException {
try {
@@ -272,6 +301,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public void deleteGroupPluginConfigurationUpdate(Integer groupId, Integer[]
groupPluginConfigUpdateIds)
throws RuntimeException {
try {
@@ -282,6 +312,7 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
public void deleteGroupResourceConfigurationUpdate(Integer groupId, Integer[]
groupResourceConfigUpdateIds)
throws RuntimeException {
try {
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 d2ad927..dbf48f4 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
@@ -1674,7 +1674,7 @@ view_group_resConfig_edit_saveFailure = Failed to initiate group
configuration u
view_group_resConfig_edit_valid = All configuration properties have valid values, so the
configuration can now be saved
view_group_resConfig_edit_invalid = The following configuration properties have invalid
values and must be corrected before the configuration can be saved: [{0}]
view_group_pluginConfig_view_noperm = You do not have permissions to see the connection
settings
-view_group_pluginConfig_view_groupProperties = Group Properties
+view_group_pluginConfig_view_groupProperties = Group Properties
view_group_pluginConfig_table_failFetch = Failed to get group plugin config history
view_group_pluginConfig_table_title = Group Connection Settings History
view_group_pluginConfig_table_statusDetails = Status Details
@@ -1727,6 +1727,22 @@ view_connectionSettingsDetails_messageDetailed_updateSuccess =
Connection settin
view_connectionSettingsDetails_allPropertiesValid = All connection settings have valid
values, so the settings can now be saved.
view_connectionSettingsDetails_somePropertiesInvalid = The following connection settings
have invalid values: {0}. The values must be corrected before the settings can be saved.
+# Connection History
+#-----------------------------------------
+view_connectionSettingsHistory_view_noperm = You do not have permissions to see the
connection settings
+view_connectionSettingsHistory_view_connProperties = Connection Properties
+view_connectionSettingsHistory_table_failFetch = Failed to get plugin config history
+view_connectionSettingsHistory_table_title = Connection Settings History
+view_connectionSettingsHistory_table_statusDetails = Status Details
+view_connectionSettingsHistory_table_deleteSuccessful = You have deleted [{0}] history
items
+view_connectionSettingsHistory_table_deleteFailure = Failed to delete plugin
configuration history
+view_connectionSettingsHistory_table_statusSuccess = This configuration update was
successful
+view_connectionSettingsHistory_table_statusInprogress = This configuration update is
still in progress
+view_connectionSettingsHistory_table_statusNochange = No changes were made to this
configuration
+view_connectionSettingsHistory_table_statusFailure = This configuration update failed
+view_connectionSettingsHistory_table_clickStatusIcon = Click the status icon for full
details
+view_connectionSettingsHistory_settings_fetchFailure = Failed to retrieve connection
settings for [{0}]
+
# Resource Resource Groups
#-----------------------------------------
view_resourceResourceGroupList_error_fetchFailure = Failed to fetch Resource''s
groups.
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index 4b99c06..5c82990 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -808,8 +808,7 @@ public class ConfigurationManagerBean implements
ConfigurationManagerLocal, Conf
long duration = request.getDuration();
if (duration > timeout) {
- log.info("Group Resource configuration update request seems to
have been orphaned - timing it out: "
- + request);
+ log.info("Group Resource config update request seems to be
orphaned - timing it out: " + request);
request.setErrorMessage("Timed out - did not complete after
" + duration + " ms"
+ " (the timeout period was " + timeout + "
ms)");
@@ -979,6 +978,19 @@ public class ConfigurationManagerBean implements
ConfigurationManagerLocal, Conf
return;
}
+ public void purgePluginConfigurationUpdates(Subject subject, int[]
configurationUpdateIds, boolean purgeInProgress) {
+ if ((configurationUpdateIds == null) || (configurationUpdateIds.length == 0)) {
+ return;
+ }
+
+ // TODO [mazz]: ugly - let's make this more efficient, just getting this to
work first
+ for (int configurationUpdateId : configurationUpdateIds) {
+ purgePluginConfigurationUpdate(subject, configurationUpdateId,
purgeInProgress);
+ }
+
+ return;
+ }
+
public void purgeResourceConfigurationUpdate(Subject subject, int
configurationUpdateId, boolean purgeInProgress) {
ResourceConfigurationUpdate doomedRequest =
entityManager.find(ResourceConfigurationUpdate.class,
configurationUpdateId);
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
index f2cab8a..37d8a06 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
@@ -201,9 +201,35 @@ public interface ConfigurationManagerLocal {
ConfigurationUpdateResponse
executePluginConfigurationUpdate(PluginConfigurationUpdate update);
+ /**
+ * This deletes the update information belonging to the {@link
AbstractResourceConfigurationUpdate} object with the
+ * given ID. Once this returns, the complete audit trail for that update will be gone
and you will not be able to
+ * rollback to that configuration.
+ *
+ * <p>Under normal circumstances, you will not want to purge an update that is
currently in progress. However, there
+ * may be conditions in which an update request "gets stuck" in the
in-progress state, even though you know the
+ * agent will never report the completed request (typically caused by an unusual
crash of the agent). In this case,
+ * you should pass <code>true</code> in for the
<code>purgeInProgress</code> parameter to tell this method to delete
+ * the request even if it says it is in-progress.
+ *
+ * @param subject the user who is requesting the purge
+ * @param configurationUpdateId identifies the update record to be deleted
+ * @param purgeInProgress if <code>true</code>, delete it even if
its
+ * {@link ConfigurationUpdateStatus#INPROGRESS in
progress}
+ */
public void purgePluginConfigurationUpdate(Subject subject, int
configurationUpdateId, boolean purgeInProgress);
/**
+ * This deletes one or more plugin configuration updates from the resource's
plugin config history.
+ *
+ * @param subject the user who is requesting the purge
+ * @param configurationUpdateIds identifies the update records to be deleted
+ * @param purgeInProgress if <code>true</code>, delete those even
if
+ * {@link ConfigurationUpdateStatus#INPROGRESS in
progress}
+ */
+ void purgePluginConfigurationUpdates(Subject subject, int[] configurationUpdateIds,
boolean purgeInProgress);
+
+ /**
* This deletes the update information belonging to the {@link
AbstractResourceConfigurationUpdate} object with the
* given ID. Once this returns, the complete audit trail for that update will be gone
and you will not be able to
* rollback to that configuration.