modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
| 6
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java
| 25
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java
| 85 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
| 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigDataSource.java
| 293 ---------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java
| 299 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationEditView.java
| 178 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
| 232 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
| 131 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
| 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftConfigurationView.java
| 40 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
| 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
| 50 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
| 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
| 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
| 43 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
| 9
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
| 9
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
| 9
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
| 9
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
| 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
| 1
22 files changed, 1153 insertions(+), 321 deletions(-)
New commits:
commit 6b100b8eb5b0bfd672809991afe2bd517df546a4
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Jun 23 16:56:51 2011 -0400
More drift GUI hooks
- added drift -> configuration subtab
- a bunch of untested support for listing, displaying drift configs
but waiting now for some actual configs, and impl of add confog wizard
- added DriftConfigurationDefinition singleton class
-
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 9b3808a..f1e99bc 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3405,19 +3405,19 @@
<statement>
INSERT INTO rhq_config_prop_def (id, name, display_name,
description, required, simple_type,
default_value, order_index, dtype, config_def_id)
- VALUES (2, 'enabled', 'Enabled', 'Enables or
disables the drift configuration', true, 'boolean',
+ VALUES (2, 'enabled', 'Enabled', 'Enables or
disables drift detection for this configuration', true, 'boolean',
'false', 1, 'property', 1)
</statement>
<statement>
INSERT INTO rhq_config_prop_def (id, name, display_name,
description, required, simple_type,
order_index, dtype, config_def_id)
- VALUES (3, 'basedir', 'Base Directory', 'The
root directory from which snapshots will be generated during drift monitoring.',
+ VALUES (3, 'basedir', 'Base Directory', 'The
base directory from which files will be monitored for drift.',
true, 'string', 2, 'property', 1)
</statement>
<statement>
INSERT INTO rhq_config_prop_def (id, name, display_name,
description, required, simple_type,
order_index, dtype, default_value, config_def_id)
- VALUES (4, 'interval', 'Interval', 'The
frequency in seconds in which drift monitoring should run. Defaults to thirty
minutes.',
+ VALUES (4, 'interval', 'Interval', 'The
interval, in seconds, between drift detection scans for this configuration. Default is
thirty minutes.',
false, 'long', 3, 'property', '1800',
1)
</statement>
<statement>
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java
index 2f358e9..c09b473 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfiguration.java
@@ -1,3 +1,21 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
package org.rhq.core.domain.drift;
import static java.util.Collections.emptyList;
@@ -16,6 +34,9 @@ import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.resource.Resource;
+/**
+ * @author John Sanda
+ */
public class DriftConfiguration implements Serializable {
private static final long serialVersionUID = 1L;
@@ -101,6 +122,10 @@ public class DriftConfiguration implements Serializable {
return configuration;
}
+ public int getId() {
+ return configuration.getId();
+ }
+
public String getName() {
return configuration.getSimpleValue("name", "");
}
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java
new file mode 100644
index 0000000..4279049
--- /dev/null
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java
@@ -0,0 +1,85 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.core.domain.drift;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class DriftConfigurationDefinition {
+
+ static private final ConfigurationDefinition INSTANCE = new
ConfigurationDefinition("GLOBAL_DRIFT_CONFIG_DEF",
+ "The drift configuration definition");
+
+ static {
+ INSTANCE.setId(1);
+ Map<String, PropertyDefinition> propDefs = new HashMap<String,
PropertyDefinition>();
+ PropertyDefinitionSimple propDef;
+
+ propDef = new PropertyDefinitionSimple("name", "The drift
configuration name", true, PropertySimpleType.STRING);
+ propDefs.put("name", propDef);
+
+ propDef = new PropertyDefinitionSimple("name", "The drift
configuration name", true, PropertySimpleType.STRING);
+ propDef.setId(1);
+ propDef.setDisplayName("Drift Configuration Name");
+ propDef.setOrder(0);
+ propDef.setConfigurationDefinition(INSTANCE);
+ propDefs.put("name", propDef);
+
+ propDef = new PropertyDefinitionSimple("enabled", "Enabled",
true, PropertySimpleType.BOOLEAN);
+ propDef.setId(2);
+ propDef.setDisplayName("Enables or disables drift detection for this
configuration");
+ propDef.setOrder(1);
+ propDef.setDefaultValue("false");
+ propDef.setConfigurationDefinition(INSTANCE);
+ propDefs.put("enabled", propDef);
+
+ propDef = new PropertyDefinitionSimple("basedir", "Base
Directory", true, PropertySimpleType.STRING);
+ propDef.setId(3);
+ propDef.setDisplayName("The base directory from which files will be
monitored for drift.");
+ propDef.setOrder(2);
+ propDef.setConfigurationDefinition(INSTANCE);
+ propDefs.put("basedir", propDef);
+
+ propDef = new PropertyDefinitionSimple("interval",
"Interval", false, PropertySimpleType.LONG);
+ propDef.setId(4);
+ propDef
+ .setDisplayName("The interval, in seconds, between drift detection scans
for this configuration. Default is 30 minutes.");
+ propDef.setOrder(3);
+ propDef.setDefaultValue("1800");
+ propDef.setConfigurationDefinition(INSTANCE);
+ propDefs.put("interval", propDef);
+
+ //TODO, add the include/exclude list of maps
+
+ INSTANCE.setPropertyDefinitions(propDefs);
+ }
+
+ static public ConfigurationDefinition getInstance() {
+ return INSTANCE;
+
+ }
+}
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 c1bfb95..30523b3 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
@@ -222,6 +222,10 @@ public class LinkManager {
return "#Resource/" + resourceId + "/Drift/History/" +
driftId;
}
+ public static String getSubsystemDriftConfigLink(int resourceId, int driftConfigId)
{
+ return "#Resource/" + resourceId + "/Drift/Config/" +
driftConfigId;
+ }
+
public static String getAutodiscoveryQueueLink() {
if (GWT) {
return "#Administration/Security/Auto%20Discovery%20Queue";
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigDataSource.java
deleted file mode 100644
index d5cf5dd..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigDataSource.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.drift;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.google.gwt.user.client.Window;
-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.rpc.RPCResponse;
-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 org.rhq.core.domain.common.EntityContext;
-import org.rhq.core.domain.criteria.ResourceCriteria;
-import org.rhq.core.domain.drift.DriftConfiguration;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
-
-/**
- * @author Jay Shaughnessy
- */
-public class DriftConfigDataSource extends RPCDataSource<DriftConfiguration,
ResourceCriteria> {
-
- public static final String FILTER_CATEGORIES = "categories";
-
- private ResourceGWTServiceAsync resourceService =
GWTServiceLookup.getResourceService();
-
- private EntityContext entityContext;
-
- public DriftConfigDataSource() {
- this(EntityContext.forSubsystemView());
- }
-
- public DriftConfigDataSource(EntityContext context) {
- super();
- this.entityContext = context;
-
- addDataSourceFields();
- }
-
- /**
- * The view that contains the list grid which will display this datasource's data
will call this
- * method to get the field information which is used to control the display of the
data.
- *
- * @return list grid fields used to display the datasource data
- */
- public ArrayList<ListGridField> getListGridFields() {
- ArrayList<ListGridField> fields = new ArrayList<ListGridField>(6);
-
- ListGridField nameField = new ListGridField("name",
MSG.common_title_name());
- fields.add(nameField);
-
- ListGridField intervalField = new ListGridField("interval",
MSG.common_title_interval());
- fields.add(intervalField);
-
- ListGridField baseDirField = new ListGridField("baseDir",
MSG.view_drift_table_baseDir());
- fields.add(baseDirField);
-
- if (this.entityContext.type != EntityContext.Type.Resource) {
- ListGridField resourceNameField = new
ListGridField(AncestryUtil.RESOURCE_NAME, MSG.common_title_resource());
- resourceNameField.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int
i1) {
- String url = LinkManager
-
.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
- return SeleniumUtility.getLocatableHref(url, o.toString(), null);
- }
- });
- resourceNameField.setShowHover(true);
- resourceNameField.setHoverCustomizer(new HoverCustomizer() {
-
- public String hoverHTML(Object value, ListGridRecord listGridRecord, int
rowNum, int colNum) {
- return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
- }
- });
- fields.add(resourceNameField);
-
- ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
- fields.add(ancestryField);
-
- nameField.setWidth("15%");
- intervalField.setWidth(100);
- baseDirField.setWidth("20%");
- resourceNameField.setWidth("25%");
- ancestryField.setWidth("40%");
- } else {
- nameField.setWidth("15%");
- intervalField.setWidth(100);
- baseDirField.setWidth("85%");
- }
-
- return fields;
- }
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response, final
ResourceCriteria criteria) {
-
- final long start = System.currentTimeMillis();
-
- this.resourceService.findResourcesByCriteria(criteria, new
AsyncCallback<PageList<Resource>>() {
-
- public void onFailure(Throwable caught) {
-
CoreGUI.getErrorHandler().handleError(MSG.view_inventory_resources_loadFailed(), caught);
- response.setStatus(RPCResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(PageList<Resource> result) {
- if (Log.isDebugEnabled()) {
- long fetchTime = System.currentTimeMillis() - start;
- Log.debug(result.size() + " resources (with drift configs)
fetched in: " + fetchTime + "ms");
- }
-
- dataRetrieved(result, response, request);
- }
- });
- }
-
- /**
- * Additional processing to support entity-specific or cross-resource views, and
something that can be overidden.
- */
- protected void dataRetrieved(final PageList<Resource> result, final DSResponse
response, final DSRequest request) {
- switch (entityContext.type) {
-
- // no need to disambiguate, the dift configs are for a single resource
- case Resource:
- Set<DriftConfiguration> driftConfigs =
DriftConfiguration.valueOf(result.get(0));
- response.setData(buildRecords(driftConfigs));
- // for paging to work we have to specify size of full result set
- response.setTotalRows(getTotalRows(driftConfigs, response, request));
- processResponse(request.getRequestId(), response);
- break;
-
- // disambiguate as the results could be cross-resource
- default:
- Set<Integer> typesSet = new HashSet<Integer>();
- Set<String> ancestries = new HashSet<String>();
- for (Resource resource : result) {
- typesSet.add(resource.getResourceType().getId());
- ancestries.add(resource.getAncestry());
- }
-
- // In addition to the types of the result resources, get the types of their
ancestry
- typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
-
- ResourceTypeRepository typeRepo =
ResourceTypeRepository.Cache.getInstance();
- typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new
TypesLoadedCallback() {
- @Override
- public void onTypesLoaded(Map<Integer, ResourceType> types) {
- // Smartgwt has issues storing a Map as a ListGridRecord attribute.
Wrap it in a pojo.
- AncestryUtil.MapWrapper typesWrapper = new
AncestryUtil.MapWrapper(types);
-
- Set<DriftConfiguration> driftConfigs =
getDriftConfigs(result);
- Record[] records = buildRecords(driftConfigs);
- for (Record record : records) {
- // To avoid a lot of unnecessary String construction, be lazy
about building ancestry hover text.
- // Store the types map off the records so we can build a detailed
hover string as needed.
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES,
typesWrapper);
-
- // Build the decoded ancestry Strings now for display
- record
- .setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE,
AncestryUtil.getAncestryValue(record));
- }
- response.setData(records);
- // for paging to work we have to specify size of full result set
- response.setTotalRows(getTotalRows(driftConfigs, response,
request));
- processResponse(request.getRequestId(), response);
- }
- });
- }
- }
-
- private Set<DriftConfiguration> getDriftConfigs(PageList<Resource>
resources) {
- Set<DriftConfiguration> result = new HashSet<DriftConfiguration>();
- for (Resource resource : resources) {
-
result.addAll(DriftConfiguration.valueOf(resource.getDriftConfigurations()));
- }
- return result;
- }
-
- /**
- * Sub-classes can override this to add fine-grained control over the result set
size. By default the
- * total rows are set to the total result set for the query, allowing proper paging.
But some views (portlets)
- * may want to limit results to a small set (like most recent).
- * @param result
- * @param response
- * @param request
- *
- * @return should not exceed result.size().
- */
- protected int getTotalRows(final Set<DriftConfiguration> result, final
DSResponse response, final DSRequest request) {
-
- return result.size();
- }
-
- @Override
- protected ResourceCriteria getFetchCriteria(DSRequest request) {
-
- ResourceCriteria criteria = new ResourceCriteria();
- criteria.fetchDriftConfigurations(true);
- criteria.setPageControl(getPageControl(request));
-
- return criteria;
- }
-
- @Override
- protected String getSortFieldForColumn(String columnName) {
- if (AncestryUtil.RESOURCE_ANCESTRY.equals(columnName)) {
- return "ancestry";
- }
-
- return super.getSortFieldForColumn(columnName);
- }
-
- @Override
- public DriftConfiguration copyValues(Record from) {
- return null;
- }
-
- @Override
- public ListGridRecord copyValues(DriftConfiguration from) {
- return convert(from);
- }
-
- public static ListGridRecord convert(DriftConfiguration from) {
- ListGridRecord record = new ListGridRecord();
- record.setAttribute("name", from.getName());
- record.setAttribute("interval", from.getInterval());
- record.setAttribute("baseDir", from.getBasedir());
- record.setAttribute("enabled", from.getEnabled());
-
- Resource resource = from.getResource();
-
- // for ancestry handling
- record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId());
- record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
- record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID,
resource.getResourceType().getId());
-
- return record;
- }
-
- protected void executeRemove(Record recordToRemove, final DSRequest request, final
DSResponse response) {
- Window.alert(String.valueOf(recordToRemove.getAttributeAsInt("id")));
- }
-
- public ResourceGWTServiceAsync getResourceService() {
- return resourceService;
- }
-
- protected EntityContext getEntityContext() {
- return entityContext;
- }
-
- protected void setEntityContext(EntityContext entityContext) {
- this.entityContext = entityContext;
- }
-
-}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java
new file mode 100644
index 0000000..ba942b0
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationDataSource.java
@@ -0,0 +1,299 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.Window;
+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.rpc.RPCResponse;
+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 org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class DriftConfigurationDataSource extends RPCDataSource<DriftConfiguration,
ResourceCriteria> {
+
+ public static final String FILTER_CATEGORIES = "categories";
+
+ private ResourceGWTServiceAsync resourceService =
GWTServiceLookup.getResourceService();
+
+ private EntityContext entityContext;
+
+ public DriftConfigurationDataSource() {
+ this(EntityContext.forSubsystemView());
+ }
+
+ public DriftConfigurationDataSource(EntityContext context) {
+ super();
+ this.entityContext = context;
+
+ addDataSourceFields();
+ }
+
+ /**
+ * The view that contains the list grid which will display this datasource's data
will call this
+ * method to get the field information which is used to control the display of the
data.
+ *
+ * @return list grid fields used to display the datasource data
+ */
+ public ArrayList<ListGridField> getListGridFields() {
+ ArrayList<ListGridField> fields = new ArrayList<ListGridField>(6);
+
+ ListGridField nameField = new ListGridField("name",
MSG.common_title_name());
+ fields.add(nameField);
+
+ ListGridField intervalField = new ListGridField("interval",
MSG.common_title_interval());
+ fields.add(intervalField);
+
+ ListGridField baseDirField = new ListGridField("baseDir",
MSG.view_drift_table_baseDir());
+ fields.add(baseDirField);
+
+ ListGridField enabledField = new ListGridField("enabled",
MSG.common_title_enabled());
+ fields.add(enabledField);
+
+ if (this.entityContext.type != EntityContext.Type.Resource) {
+ ListGridField resourceNameField = new
ListGridField(AncestryUtil.RESOURCE_NAME, MSG.common_title_resource());
+ resourceNameField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int
i1) {
+ String url = LinkManager
+
.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ }
+ });
+ resourceNameField.setShowHover(true);
+ resourceNameField.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int
rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
+ fields.add(resourceNameField);
+
+ ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
+ fields.add(ancestryField);
+
+ nameField.setWidth("15%");
+ intervalField.setWidth(100);
+ enabledField.setWidth("5%");
+ baseDirField.setWidth("20%");
+ resourceNameField.setWidth("20%");
+ ancestryField.setWidth("40%");
+ } else {
+ nameField.setWidth("15%");
+ intervalField.setWidth(100);
+ enabledField.setWidth("5%");
+ baseDirField.setWidth("80%");
+ }
+
+ return fields;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final
ResourceCriteria criteria) {
+
+ final long start = System.currentTimeMillis();
+
+ this.resourceService.findResourcesByCriteria(criteria, new
AsyncCallback<PageList<Resource>>() {
+
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_inventory_resources_loadFailed(), caught);
+ response.setStatus(RPCResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<Resource> result) {
+ if (Log.isDebugEnabled()) {
+ long fetchTime = System.currentTimeMillis() - start;
+ Log.debug(result.size() + " resources (with drift configs)
fetched in: " + fetchTime + "ms");
+ }
+
+ dataRetrieved(result, response, request);
+ }
+ });
+ }
+
+ /**
+ * Additional processing to support entity-specific or cross-resource views, and
something that can be overidden.
+ */
+ protected void dataRetrieved(final PageList<Resource> result, final DSResponse
response, final DSRequest request) {
+ switch (entityContext.type) {
+
+ // no need to disambiguate, the dift configs are for a single resource
+ case Resource:
+ Set<DriftConfiguration> driftConfigs =
DriftConfiguration.valueOf(result.get(0));
+ response.setData(buildRecords(driftConfigs));
+ // for paging to work we have to specify size of full result set
+ response.setTotalRows(getTotalRows(driftConfigs, response, request));
+ processResponse(request.getRequestId(), response);
+ break;
+
+ // disambiguate as the results could be cross-resource
+ default:
+ Set<Integer> typesSet = new HashSet<Integer>();
+ Set<String> ancestries = new HashSet<String>();
+ for (Resource resource : result) {
+ typesSet.add(resource.getResourceType().getId());
+ ancestries.add(resource.getAncestry());
+ }
+
+ // In addition to the types of the result resources, get the types of their
ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo =
ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new
TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // Smartgwt has issues storing a Map as a ListGridRecord attribute.
Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new
AncestryUtil.MapWrapper(types);
+
+ Set<DriftConfiguration> driftConfigs =
getDriftConfigs(result);
+ Record[] records = buildRecords(driftConfigs);
+ for (Record record : records) {
+ // To avoid a lot of unnecessary String construction, be lazy
about building ancestry hover text.
+ // Store the types map off the records so we can build a detailed
hover string as needed.
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES,
typesWrapper);
+
+ // Build the decoded ancestry Strings now for display
+ record
+ .setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE,
AncestryUtil.getAncestryValue(record));
+ }
+ response.setData(records);
+ // for paging to work we have to specify size of full result set
+ response.setTotalRows(getTotalRows(driftConfigs, response,
request));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+ }
+
+ private Set<DriftConfiguration> getDriftConfigs(PageList<Resource>
resources) {
+ Set<DriftConfiguration> result = new HashSet<DriftConfiguration>();
+ for (Resource resource : resources) {
+
result.addAll(DriftConfiguration.valueOf(resource.getDriftConfigurations()));
+ }
+ return result;
+ }
+
+ /**
+ * Sub-classes can override this to add fine-grained control over the result set
size. By default the
+ * total rows are set to the total result set for the query, allowing proper paging.
But some views (portlets)
+ * may want to limit results to a small set (like most recent).
+ * @param result
+ * @param response
+ * @param request
+ *
+ * @return should not exceed result.size().
+ */
+ protected int getTotalRows(final Set<DriftConfiguration> result, final
DSResponse response, final DSRequest request) {
+
+ return result.size();
+ }
+
+ @Override
+ protected ResourceCriteria getFetchCriteria(DSRequest request) {
+
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.fetchDriftConfigurations(true);
+ criteria.setPageControl(getPageControl(request));
+
+ return criteria;
+ }
+
+ @Override
+ protected String getSortFieldForColumn(String columnName) {
+ if (AncestryUtil.RESOURCE_ANCESTRY.equals(columnName)) {
+ return "ancestry";
+ }
+
+ return super.getSortFieldForColumn(columnName);
+ }
+
+ @Override
+ public DriftConfiguration copyValues(Record from) {
+ return null;
+ }
+
+ @Override
+ public ListGridRecord copyValues(DriftConfiguration from) {
+ return convert(from);
+ }
+
+ public static ListGridRecord convert(DriftConfiguration from) {
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute("id", from.getId());
+ record.setAttribute("name", from.getName());
+ record.setAttribute("interval", from.getInterval());
+ record.setAttribute("baseDir", from.getBasedir());
+ record.setAttribute("enabled", from.getEnabled());
+
+ Resource resource = from.getResource();
+
+ // for ancestry handling
+ record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId());
+ record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID,
resource.getResourceType().getId());
+
+ return record;
+ }
+
+ protected void executeRemove(Record recordToRemove, final DSRequest request, final
DSResponse response) {
+ Window.alert(String.valueOf(recordToRemove.getAttributeAsInt("id")));
+ }
+
+ public ResourceGWTServiceAsync getResourceService() {
+ return resourceService;
+ }
+
+ protected EntityContext getEntityContext() {
+ return entityContext;
+ }
+
+ protected void setEntityContext(EntityContext entityContext) {
+ this.entityContext = entityContext;
+ }
+
+}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationEditView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationEditView.java
new file mode 100644
index 0000000..3b236c8
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationEditView.java
@@ -0,0 +1,178 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import java.util.EnumSet;
+import java.util.Map;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.drift.DriftConfigurationDefinition;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.RefreshableView;
+import
org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import
org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent;
+import
org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * A view for editing a Resource's configuration.
+ *
+ * @author Jay Shaughnessy
+ */
+public class DriftConfigurationEditView extends LocatableVLayout implements
PropertyValueChangeListener,
+ RefreshableView {
+
+ private EntityContext context;
+ private int driftConfigId;
+ private DriftConfiguration driftConfig;
+ private boolean hasWriteAccess;
+ private ConfigurationEditor editor;
+ private ToolStrip buttonbar;
+ private IButton saveButton;
+
+ private boolean refreshing = false;
+
+ public DriftConfigurationEditView(String locatorId, EntityContext context, int
driftConfigId, boolean hasWriteAccess) {
+ super(locatorId);
+
+ this.context = context;
+ this.driftConfigId = driftConfigId;
+ this.hasWriteAccess = hasWriteAccess;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ this.buttonbar = new ToolStrip();
+ buttonbar.setWidth100();
+ buttonbar.setExtraSpace(10);
+ buttonbar.setMembersMargin(5);
+ buttonbar.setLayoutMargin(5);
+
+ this.saveButton = new LocatableIButton(this.extendLocatorId("Save"),
MSG.common_button_save());
+ this.saveButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ save();
+ }
+ });
+ buttonbar.addMember(saveButton);
+ // The button bar will remain hidden until the configuration has been
successfully loaded.
+ buttonbar.setVisible(false);
+ addMember(buttonbar);
+
+ refresh();
+
+ if (!this.hasWriteAccess) {
+ Message message = new Message(MSG.view_configurationDetails_noPermission(),
Message.Severity.Info, EnumSet
+ .of(Message.Option.Transient, Message.Option.Sticky));
+ CoreGUI.getMessageCenter().notify(message);
+ }
+ }
+
+ @Override
+ public void refresh() {
+ if (this.refreshing) {
+ return; // we are already in the process of refreshing, don't do it
again
+ }
+
+ this.refreshing = true;
+ this.buttonbar.setVisible(false);
+
+ if (editor != null) {
+ editor.destroy();
+ removeMember(editor);
+ }
+
+ GWTServiceLookup.getConfigurationService().getConfiguration(driftConfigId, new
AsyncCallback<Configuration>() {
+ @Override
+ public void onSuccess(final Configuration result) {
+
+ editor = new ConfigurationEditor(extendLocatorId("Editor"),
DriftConfigurationDefinition.getInstance(),
+ result);
+ editor.setOverflow(Overflow.AUTO);
+ editor.addPropertyValueChangeListener(DriftConfigurationEditView.this);
+ editor.setReadOnly(!hasWriteAccess);
+ addMember(editor);
+
+ saveButton.disable();
+ buttonbar.setVisible(true);
+ markForRedraw();
+ refreshing = false;
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ refreshing = false;
+ CoreGUI.getErrorHandler().handleError("Failed to load
configuration.", caught);
+ }
+ });
+ }
+
+ private void save() {
+ Configuration updatedConfiguration = editor.getConfiguration();
+
+ GWTServiceLookup.getDriftService().updateDriftConfiguration(context,
+ new DriftConfiguration(updatedConfiguration), new AsyncCallback<Void>()
{
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_configurationDetails_error_updateFailure(),
caught);
+ }
+
+ public void onSuccess(Void result) {
+ Message message;
+ message = new Message(MSG.view_drift_success_configurationUpdated(),
Message.Severity.Info);
+ }
+ });
+ }
+
+ @Override
+ public void propertyValueChanged(PropertyValueChangeEvent event) {
+ MessageCenter messageCenter = CoreGUI.getMessageCenter();
+ Message message;
+ if (event.isInvalidPropertySetChanged()) {
+ Map<String, String> invalidPropertyNames =
event.getInvalidPropertyNames();
+ if (invalidPropertyNames.isEmpty()) {
+ this.saveButton.enable();
+ message = new Message(MSG.view_configurationDetails_allPropertiesValid(),
Message.Severity.Info,
+ EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ } else {
+ this.saveButton.disable();
+ message = new
Message(MSG.view_configurationDetails_somePropertiesInvalid(invalidPropertyNames.values()
+ .toString()), Message.Severity.Error,
EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ }
+ messageCenter.notify(message);
+ } else {
+ this.saveButton.enable();
+ }
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
new file mode 100644
index 0000000..13e5c73
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
@@ -0,0 +1,232 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.ResultSet;
+import com.smartgwt.client.data.SortSpecifier;
+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.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.drift.DriftCategory;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * A view that displays a paginated table of {@link
org.rhq.core.domain.drift.DriftConfiguration}s, along with the
+ * ability to filter (maybe) those drift configs, sort those drift configs, double-click
a row to view/edit the
+ * drift config, and perform various actionns: add/delete, etc.
+ * This view full respects the user's authorization, and will not allow actions on
the drifts unless the user is
+ * either the inventory manager or has MANAGE_DRIFT permission on every resource
corresponding to the drift configs
+ * being operated on.
+ *
+ * @author Jay Shaughnessy
+ */
+public class DriftConfigurationView extends
TableSection<DriftConfigurationDataSource> {
+
+ public static final ViewName SUBSYSTEM_VIEW_ID = new
ViewName("DriftConfigs", MSG.common_title_configuration());
+
+ private static SortSpecifier DEFAULT_SORT_SPECIFIER = new
SortSpecifier("name", SortDirection.ASCENDING);
+
+ private static final Criteria INITIAL_CRITERIA = new Criteria();
+
+ EntityContext context;
+ boolean hasWriteAccess;
+ DriftConfigurationDataSource dataSource;
+
+ static {
+ DriftCategory[] categoryValues = DriftCategory.values();
+ String[] categoryNames = new String[categoryValues.length];
+ int i = 0;
+ for (DriftCategory c : categoryValues) {
+ categoryNames[i++] = c.name();
+ }
+
+ // Add any INITIAL_CRITERIA here (non currently)
+ }
+
+ // for subsystem views
+ public DriftConfigurationView(String locatorId) {
+ this(locatorId, SUBSYSTEM_VIEW_ID.getTitle(), EntityContext.forSubsystemView(),
false);
+ }
+
+ public DriftConfigurationView(String locatorId, EntityContext entityContext) {
+ this(locatorId, SUBSYSTEM_VIEW_ID.getTitle(), entityContext, false);
+ }
+
+ public DriftConfigurationView(String locatorId, String tableTitle, EntityContext
entityContext) {
+ this(locatorId, tableTitle, entityContext, false);
+ }
+
+ protected DriftConfigurationView(String locatorId, String tableTitle, EntityContext
context, boolean hasWriteAccess) {
+ super(locatorId, tableTitle, INITIAL_CRITERIA, new SortSpecifier[] {
DEFAULT_SORT_SPECIFIER });
+ this.context = context;
+ this.hasWriteAccess = hasWriteAccess;
+
+ setInitialCriteriaFixed(false);
+ setDataSource(getDataSource());
+ }
+
+ @Override
+ public DriftConfigurationDataSource getDataSource() {
+ if (null == this.dataSource) {
+ this.dataSource = new DriftConfigurationDataSource(context);
+ }
+ return this.dataSource;
+ }
+
+ @Override
+ protected void configureTableFilters() {
+ // currently no table filters
+ }
+
+ @Override
+ protected void configureTable() {
+ ArrayList<ListGridField> dataSourceFields =
getDataSource().getListGridFields();
+ getListGrid().setFields(dataSourceFields.toArray(new
ListGridField[dataSourceFields.size()]));
+ setupTableInteractions(this.hasWriteAccess);
+
+ super.configureTable();
+ }
+
+ @Override
+ protected String getDetailsLinkColumnName() {
+ return "name";
+ }
+
+ @Override
+ protected CellFormatter getDetailsLinkColumnCellFormatter() {
+ return new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
+ Integer resourceId = record.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
+ Integer driftConfigId = getId(record);
+ String url = LinkManager.getSubsystemDriftConfigLink(resourceId,
driftConfigId);
+ String formattedValue = TimestampCellFormatter.format(value);
+ return SeleniumUtility.getLocatableHref(url, formattedValue, null);
+ }
+ };
+ }
+
+ protected void setupTableInteractions(final boolean hasWriteAccess) {
+ TableActionEnablement singleTargetEnablement = hasWriteAccess ?
TableActionEnablement.ANY
+ : TableActionEnablement.NEVER;
+
+ addTableAction("Add", MSG.common_button_add(), null, new TableAction()
{
+ public boolean isEnabled(ListGridRecord[] selection) {
+ ListGrid grid = getListGrid();
+ ResultSet resultSet = (null != grid) ? grid.getResultSet() : null;
+ return (hasWriteAccess && grid != null && resultSet !=
null && !resultSet.isEmpty());
+ }
+
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ add();
+ }
+ });
+
+ addTableAction("Delete", MSG.common_button_delete(),
MSG.view_drift_delete_confirm(), new AbstractTableAction(
+ singleTargetEnablement) {
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ delete(selection);
+ }
+ });
+
+ addTableAction("DeleteAll", MSG.common_button_delete_all(),
MSG.view_drift_delete_confirmAll(),
+ new TableAction() {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ ListGrid grid = getListGrid();
+ ResultSet resultSet = (null != grid) ? grid.getResultSet() : null;
+ return (hasWriteAccess && grid != null && resultSet
!= null && !resultSet.isEmpty());
+ }
+
+ public void executeAction(ListGridRecord[] selection, Object actionValue)
{
+ deleteAll();
+ }
+ });
+ }
+
+ void add() {
+ // TODO: kick off wizard to add new drift config
+ }
+
+ void delete(ListGridRecord[] records) {
+ final int[] driftConfigIds = new int[records.length];
+ for (int i = 0, selectionLength = records.length; i < selectionLength; i++) {
+ ListGridRecord record = records[i];
+ Integer driftConfigId = record.getAttributeAsInt("id");
+ driftConfigIds[i] = driftConfigId;
+ }
+
+ GWTServiceLookup.getDriftService().deleteDriftConfigurations(driftConfigIds, new
AsyncCallback<Integer>() {
+ public void onSuccess(Integer resultCount) {
+ CoreGUI.getMessageCenter().notify(
+ new
Message(MSG.view_drift_success_deleteConfigs(String.valueOf(resultCount)),
+ Message.Severity.Info));
+ refresh();
+ }
+
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_drift_failure_delete(Arrays.toString(driftConfigIds)),
+ caught);
+ }
+ });
+ }
+
+ void deleteAll() {
+ GWTServiceLookup.getDriftService().deleteDriftConfigurationsByContext(context,
new AsyncCallback<Integer>() {
+ public void onSuccess(Integer resultCount) {
+ CoreGUI.getMessageCenter().notify(
+ new
Message(MSG.view_drift_success_delete(String.valueOf(resultCount)),
Message.Severity.Info));
+ refresh();
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_failure_deleteAll(),
caught);
+ }
+ });
+ }
+
+ @Override
+ public Canvas getDetailsView(int driftConfigId) {
+ return new DriftConfigurationEditView(extendLocatorId("ConfigEdit"),
context, driftConfigId, hasWriteAccess);
+ }
+
+ public EntityContext getContext() {
+ return context;
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
new file mode 100644
index 0000000..79078fa
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -0,0 +1,131 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import static
org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter.DATE_TIME_FORMAT_FULL;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.drift.Drift;
+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.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class DriftDetailsView extends LocatableVLayout implements BookmarkableView {
+
+ private int driftId;
+
+ private static DriftDetailsView INSTANCE = new
DriftDetailsView("DriftDetailsView");
+
+ public static DriftDetailsView getInstance() {
+ return INSTANCE;
+ }
+
+ private DriftDetailsView(String id) {
+ // access through the static singleton only (see renderView)
+ super(id);
+ }
+
+ private void show(int driftId) {
+ DriftCriteria criteria = new DriftCriteria();
+ criteria.addFilterId(driftId);
+ criteria.fetchChangeSet(true);
+ GWTServiceLookup.getDriftService().findDriftsByCriteria(criteria, new
AsyncCallback<PageList<Drift>>() {
+ @Override
+ public void onSuccess(PageList<Drift> result) {
+ Drift drift = result.get(0);
+ show(drift);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_failure_load(),
caught);
+ }
+ });
+ }
+
+ private void show(Drift drift) {
+ for (Canvas child : getMembers()) {
+ removeChild(child);
+ }
+
+ DynamicForm form = new LocatableDynamicForm(extendLocatorId("form"));
+ form.setWidth100();
+ form.setHeight100();
+ form.setWrapItemTitles(false);
+
+ StaticTextItem id = new StaticTextItem("id", MSG.common_title_id());
+ id.setValue(drift.getId());
+
+ StaticTextItem path = new StaticTextItem("path",
MSG.common_title_path());
+ path.setValue(drift.getPath());
+
+ StaticTextItem timestamp = new StaticTextItem("timestamp",
MSG.common_title_timestamp());
+ timestamp.setValue(TimestampCellFormatter.format(drift.getCtime(),
DATE_TIME_FORMAT_FULL));
+
+ StaticTextItem category = new StaticTextItem("category",
MSG.common_title_category());
+ StaticTextItem oldFile = new StaticTextItem("oldFile",
MSG.view_drift_table_oldFile());
+ StaticTextItem newFile = new StaticTextItem("newFile",
MSG.view_drift_table_newFile());
+
+ switch (drift.getCategory()) {
+ case FILE_ADDED:
+ category.setValue(MSG.view_drift_category_fileAdded());
+ oldFile.setValue(MSG.common_label_none());
+ newFile.setValue(drift.getNewDriftFile().getHashId());
+ break;
+
+ case FILE_CHANGED:
+ category.setValue(MSG.view_drift_category_fileChanged());
+ oldFile.setValue(drift.getOldDriftFile().getHashId());
+ newFile.setValue(drift.getNewDriftFile().getHashId());
+ break;
+
+ case FILE_REMOVED:
+ category.setValue(MSG.view_drift_category_fileRemoved());
+ oldFile.setValue(drift.getOldDriftFile().getHashId());
+ newFile.setValue(MSG.common_label_none());
+ break;
+ }
+
+ form.setItems(id, path, category, timestamp, oldFile, newFile);
+
+ addMember(form);
+ }
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ driftId = viewPath.getCurrentAsInt();
+ show(driftId);
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
index c1dea6d..e0e874b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -39,7 +39,6 @@ import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.alert.AlertDetailsView;
import org.rhq.enterprise.gui.coregui.client.components.form.EnumSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
@@ -53,10 +52,10 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
- * A view that displays a paginated table of fired {@link
org.rhq.core.domain.drift.Drift}s, along with the
+ * A view that displays a paginated table of {@link org.rhq.core.domain.drift.Drift}s,
along with the
* ability to filter those drifts, sort those drifts, double-click a row to view full
details a drift, and perform
- * various operations on the the drifts: delete selected, delete all from source, etc.
- * This view full respects the user's authorization, and will not allow operations on
the drifts unless the user is
+ * various actions on the the drifts: delete selected, delete all from source, etc.
+ * This view full respects the user's authorization, and will not allow acttions on
the drifts unless the user is
* either the inventory manager or has MANAGE_DRIFT permission on every resource
corresponding to the drifts being
* operated on.
*
@@ -230,7 +229,7 @@ public class DriftHistoryView extends
TableSection<DriftDataSource> {
}
void deleteAll() {
- GWTServiceLookup.getAlertService().deleteAlertsByContext(context, new
AsyncCallback<Integer>() {
+ GWTServiceLookup.getDriftService().deleteDriftsByContext(context, new
AsyncCallback<Integer>() {
public void onSuccess(Integer resultCount) {
CoreGUI.getMessageCenter().notify(
new
Message(MSG.view_drift_success_delete(String.valueOf(resultCount)),
Message.Severity.Info));
@@ -280,8 +279,8 @@ public class DriftHistoryView extends
TableSection<DriftDataSource> {
// }
@Override
- public Canvas getDetailsView(int alertId) {
- return AlertDetailsView.getInstance();
+ public Canvas getDetailsView(int driftId) {
+ return DriftDetailsView.getInstance();
}
public EntityContext getContext() {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftConfigurationView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftConfigurationView.java
new file mode 100644
index 0000000..c68ea75
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftConfigurationView.java
@@ -0,0 +1,40 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class ResourceDriftConfigurationView extends DriftConfigurationView {
+ public static ResourceDriftConfigurationView get(String locatorId, ResourceComposite
composite) {
+ String tableTitle = MSG.view_drift_table_resourceConfig();
+ EntityContext context =
EntityContext.forResource(composite.getResource().getId());
+ boolean hasWriteAccess = composite.getResourcePermission().isDrift();
+ return new ResourceDriftConfigurationView(locatorId, tableTitle, context,
hasWriteAccess);
+ }
+
+ private ResourceDriftConfigurationView(String locatorId, String tableTitle,
EntityContext context,
+ boolean hasWriteAccess) {
+ super(locatorId, tableTitle, context, hasWriteAccess);
+ }
+}
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 bdb5a7d..0898a97 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,7 +21,8 @@ import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
/**
- * API for resource and plugin configurations for resources and groups.
+ * API for resource and plugin configurations for resources and groups, as well as any
other
+ * configuration related methods.
*/
@RemoteServiceRelativePath("ConfigurationGWTService")
public interface ConfigurationGWTService extends RemoteService {
@@ -86,4 +87,6 @@ public interface ConfigurationGWTService extends RemoteService {
void deleteGroupResourceConfigurationUpdate(Integer groupId, Integer[]
groupResourceConfigUpdateIds)
throws RuntimeException;
+
+ Configuration getConfiguration(int configurationId);
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
index 9100ce3..56f855f 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
@@ -20,10 +20,12 @@ package org.rhq.enterprise.gui.coregui.client.gwt;
import com.google.gwt.user.client.rpc.RemoteService;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.util.PageList;
/**
@@ -45,6 +47,45 @@ public interface DriftGWTService extends RemoteService {
int deleteDrifts(int[] driftIds) throws RuntimeException;
/**
+ * Delete all drifts for the specified context if the current user has permission to
do so (i.e. either
+ * the MANAGE_INVENTORY global permission, or the MANAGE_DRIFT permission for all
corresponding resources).
+ * If the user does not have permission for all of the specified drifts, then none of
the drifts will be deleted
+ * and a PermissionException will be thrown.
+ *
+ * If the entity does not correspond to an existing entity, it will be gracefully
ignored.
+ *
+ * @param entityContext the context for deletion
+ * @return the number of drifts deleted
+ */
+ int deleteDriftsByContext(EntityContext entityContext) throws RuntimeException;
+
+ /**
+ * Delete the drift configs with the specified ids if the current user has permission
to do so (i.e. either
+ * the MANAGE_INVENTORY global permission, or the MANAGE_DRIFT permission for all
corresponding resources).
+ * If the user does not have permission for all of the specified drift configs, then
none of them will be deleted
+ * and a PermissionException will be thrown.
+ *
+ * If any of the ids do not correspond to drift entities that exist, those ids will
be gracefully ignored.
+ *
+ * @param driftConfigIds the ids of the drift configs to be deleted
+ * @return the number of drift configs deleted
+ */
+ int deleteDriftConfigurations(int[] driftConfigIds) throws RuntimeException;
+
+ /**
+ * Delete all drift configurations for the specified context if the current user has
permission to do so (i.e. either
+ * the MANAGE_INVENTORY global permission, or the MANAGE_DRIFT permission for all
corresponding resources).
+ * If the user does not have permission for all of the specified drifts, then none of
the drifts will be deleted
+ * and a PermissionException will be thrown.
+ *
+ * If the entity does not correspond to an existing entity, it will be gracefully
ignored.
+ *
+ * @param entityContext the context for deletion
+ * @return the number of drift configs deleted
+ */
+ int deleteDriftConfigurationsByContext(EntityContext entityContext) throws
RuntimeException;
+
+ /**
* Find all drift changesets that match the specified criteria.
*
* @param criteria the criteria
@@ -62,4 +103,13 @@ public interface DriftGWTService extends RemoteService {
*/
PageList<Drift> findDriftsByCriteria(DriftCriteria criteria) throws
RuntimeException;
+ /**
+ * Update the provided driftConfig (identified by name) on the specified
EntityContext. If it exists it will be replaced. If not it will
+ * be added. Agents, if available, will be notified of the change.
+ *
+ * @param entityContext
+ * @param driftConfig
+ */
+ void updateDriftConfiguration(EntityContext entityContext, DriftConfiguration
driftConfig);
+
}
\ No newline at end of file
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 d5d9de4..d0ec4ee 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
@@ -50,6 +50,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import org.rhq.enterprise.gui.coregui.client.drift.ResourceDriftConfigurationView;
import org.rhq.enterprise.gui.coregui.client.drift.ResourceDriftHistoryView;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.InventoryView;
@@ -136,6 +137,7 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
private SubTab configHistory;
private SubTab eventHistory;
private SubTab driftHistory;
+ private SubTab driftConfig;
private SubTab contentDeployed;
private SubTab contentNew;
private SubTab contentSubscrip;
@@ -234,9 +236,9 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
.view_tabs_common_drift()),
"/images/icons/Configure_grey_16.png");
this.driftHistory = new SubTab(driftTab.extendLocatorId("History"), new
ViewName("History", MSG
.view_tabs_common_history()), null);
- //this.alertDef = new SubTab(driftTab.extendLocatorId("Definitions"),
new ViewName("Definitions", MSG
- // .view_tabs_common_definitions()), null);
- driftTab.registerSubTabs(driftHistory);
+ this.driftConfig = new SubTab(driftTab.extendLocatorId("Config"), new
ViewName("Config", MSG
+ .view_tabs_common_configuration()), null);
+ driftTab.registerSubTabs(driftHistory, driftConfig);
tabs.add(driftTab);
contentTab = new TwoLevelTab(getTabSet().extendLocatorId("Content"),
new ViewName("Content", MSG
@@ -513,10 +515,10 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
}
});
- updateSubTab(this.configurationTab, this.configHistory, true, true, new
ViewFactory() {
+ updateSubTab(this.driftTab, this.driftConfig, true, true, new ViewFactory()
{
@Override
public Canvas createView() {
- return
ResourceDriftHistoryView.get(driftHistory.extendLocatorId("View"),
resourceComposite);
+ return
ResourceDriftConfigurationView.get(driftConfig.extendLocatorId("View"),
resourceComposite);
}
});
}
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 7f7c31b..4850acf 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
@@ -365,4 +365,14 @@ public class ConfigurationGWTServiceImpl extends
AbstractGWTServiceImpl implemen
}
}
+ @Override
+ public Configuration getConfiguration(int configurationId) throws RuntimeException {
+ try {
+ Configuration configuration =
configurationManager.getConfiguration(getSessionSubject(), configurationId);
+ return SerialUtility.prepare(configuration,
"ConfigurationService.getConfiguration");
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
index 26a9734..714a68a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
@@ -18,10 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
@@ -48,6 +50,39 @@ public class DriftGWTServiceImpl extends AbstractGWTServiceImpl
implements Drift
}
@Override
+ public int deleteDriftsByContext(EntityContext entityContext) throws RuntimeException
{
+ try {
+ // TODO
+ //return this.driftManager.deleteDriftsByContext(getSessionSubject(),
entityContext);
+ return 0;
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
+ @Override
+ public int deleteDriftConfigurations(int[] driftConfigIds) throws RuntimeException {
+ try {
+ // TODO
+ //return this.driftManager.deleteDriftConfigurations(getSessionSubject(),
driftConfigIds);
+ return 0;
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
+ @Override
+ public int deleteDriftConfigurationsByContext(EntityContext entityContext) throws
RuntimeException {
+ try {
+ // TODO
+ //return
this.driftManager.deleteDriftConfigurationsByContext(getSessionSubject(), entityContext);
+ return 0;
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
+ @Override
public PageList<DriftChangeSet>
findDriftChangeSetsByCriteria(DriftChangeSetCriteria criteria)
throws RuntimeException {
try {
@@ -69,4 +104,12 @@ public class DriftGWTServiceImpl extends AbstractGWTServiceImpl
implements Drift
}
}
+ @Override
+ public void updateDriftConfiguration(EntityContext entityContext, DriftConfiguration
driftConfig) {
+ try {
+ this.driftManager.updateDriftConfiguration(getSessionSubject(),
entityContext, driftConfig);
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
}
\ No newline at end of file
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 24e6b81..d4b787f 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
@@ -1107,11 +1107,16 @@ view_drift_category_fileChanged = File Changed
view_drift_category_fileRemoved = File Removed
view_drift_delete_confirm = Delete the selected drift(s)?
view_drift_delete_confirmAll = Delete all drifts from this source?
-view_drift_failure_delete = Failed to delete drifts with id''s: {0}
-view_drift_failure_deleteAll = Failed to delete all drifts from this source
+view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
+view_drift_failure_deleteAll = Failed to delete all drift targets from this source
view_drift_failure_load = Failed to fetch drift data
+view_drift_success_configurationUpdated = Drift configuration updated. File coverage
will be updated on next detection scan.
view_drift_success_delete = Successfully deleted {0} drifts
+view_drift_success_deleteConfigs = Successfully deleted {0} drift configurations
view_drift_table_baseDir = Base Directory
+view_drift_table_newFile = New File
+view_drift_table_oldFile = Old File
+view_drift_table_resourceConfig = Resource Drift Configuration
view_drift_table_resourceHistory = Resource Drift History
view_dynagroup_children = DynaGroup Children
view_dynagroup_compatible = Compatible
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 792fa2a..5c08f99 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -931,11 +931,16 @@ view_dashboards_title = Dashboard
##view_drift_category_fileRemoved = File Removed
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
-##view_drift_failure_delete = Failed to delete drifts with id''s: {0}
-##view_drift_failure_deleteAll = Failed to delete all drifts from this source
+##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
+##view_drift_failure_deleteAll = Failed to delete all drift targets from this source
##view_drift_failure_load = Failed to fetch drift data
+##view_drift_success_configurationUpdated = Drift configuration updated. File coverage
will be updated on next detection scan.
##view_drift_success_delete = Successfully deleted {0} drifts
+##view_drift_success_deleteConfigs = Successfully deleted {0} drift configurations
##view_drift_table_baseDir = Base Directory
+##view_drift_table_newFile = New File
+##view_drift_table_oldFile = Old File
+view_drift_table_resourceConfig = Resource Drift Configuration
##view_drift_table_resourceHistory = Resource Drift History
view_dynagroup_children = DynaGroup Children~
view_dynagroup_compatible = Kompatible
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 856c5c9..56f7060 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -1108,11 +1108,16 @@ view_dashboards_title = ダッシュボード
##view_drift_category_fileRemoved = File Removed
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
-##view_drift_failure_delete = Failed to delete drifts with id''s: {0}
-##view_drift_failure_deleteAll = Failed to delete all drifts from this source
+##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
+##view_drift_failure_deleteAll = Failed to delete all drift targets from this source
##view_drift_failure_load = Failed to fetch drift data
+##view_drift_success_configurationUpdated = Drift configuration updated. File coverage
will be updated on next detection scan.
##view_drift_success_delete = Successfully deleted {0} drifts
+##view_drift_success_deleteConfigs = Successfully deleted {0} drift configurations
##view_drift_table_baseDir = Base Directory
+##view_drift_table_newFile = New File
+##view_drift_table_oldFile = Old File
+view_drift_table_resourceConfig = Resource Drift Configuration
##view_drift_table_resourceHistory = Resource Drift History
view_dynagroup_children = DynaGroup Children
view_dynagroup_compatible = Compatible
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index 60bc292..bc458a0 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -1131,11 +1131,16 @@ view_dashboards_title = Dashboard~
##view_drift_category_fileRemoved = File Removed
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
-##view_drift_failure_delete = Failed to delete drifts with id''s: {0}
-##view_drift_failure_deleteAll = Failed to delete all drifts from this source
+##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
+##view_drift_failure_deleteAll = Failed to delete all drift targets from this source
##view_drift_failure_load = Failed to fetch drift data
+##view_drift_success_configurationUpdated = Drift configuration updated. File coverage
will be updated on next detection scan.
##view_drift_success_delete = Successfully deleted {0} drifts
+##view_drift_success_deleteConfigs = Successfully deleted {0} drift configurations
##view_drift_table_baseDir = Base Directory
+##view_drift_table_newFile = New File
+##view_drift_table_oldFile = Old File
+view_drift_table_resourceConfig = Resource Drift Configuration
##view_drift_table_resourceHistory = Resource Drift History
view_dynagroup_children = DynaGroup Children~
view_dynagroup_compatible = Compatible
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 21dcd58..25ba044 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -1107,11 +1107,16 @@ view_dashboards_title = \u7EDF\u8BA1\u8868\u76D8
##view_drift_category_fileRemoved = File Removed
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
-##view_drift_failure_delete = Failed to delete drifts with id''s: {0}
-##view_drift_failure_deleteAll = Failed to delete all drifts from this source
+##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
+##view_drift_failure_deleteAll = Failed to delete all drift targets from this source
##view_drift_failure_load = Failed to fetch drift data
+##view_drift_success_configurationUpdated = Drift configuration updated. File coverage
will be updated on next detection scan.
##view_drift_success_delete = Successfully deleted {0} drifts
+##view_drift_success_deleteConfigs = Successfully deleted {0} drift configurations
##view_drift_table_baseDir = Base Directory
+##view_drift_table_newFile = New File
+##view_drift_table_oldFile = Old File
+view_drift_table_resourceConfig = Resource Drift Configuration
##view_drift_table_resourceHistory = Resource Drift History
view_dynagroup_children = \u5B50\u52A8\u6001\u7EC4
view_dynagroup_compatible = \u517C\u5BB9\u6027
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 c1222c1..ef94c51 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
@@ -44,7 +44,6 @@ import
org.rhq.core.domain.criteria.GroupResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.configuration.job.GroupPluginConfigurationUpdateJob;