[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PermissionsLoader.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/SubjectRecordCellFormatter.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java | 134 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java | 55 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java | 109 ----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java | 256 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleListView.java | 88 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java | 254 ---------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java | 88 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java | 34 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java | 29 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java | 28 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java | 11
26 files changed, 667 insertions(+), 522 deletions(-)
New commits:
commit 09b2f640e9eda9b96ac37c1d44891c18da5e48e9
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Jan 26 16:45:47 2011 -0500
partial impl of resource and group op history delete, as well as group op schedule/unschedule
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PermissionsLoader.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PermissionsLoader.java
index 42cb182..6160158 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PermissionsLoader.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PermissionsLoader.java
@@ -35,7 +35,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Option;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/**
- * Provides convienence methods that loads permissions and notifies you via a callback when done.
+ * Provides convenience methods that loads permissions and notifies you via a callback when done.
* If an error occurs, the error will be logged in the message center.
* This stores the last error received, in case a caller wants more information on failures.
*
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/SubjectRecordCellFormatter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/SubjectRecordCellFormatter.java
index 7a45f5a..dc3b8f5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/SubjectRecordCellFormatter.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/SubjectRecordCellFormatter.java
@@ -5,11 +5,9 @@ import com.smartgwt.client.data.Record;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.auth.Subject;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
/**
- * Formats a {@link org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource.SubjectRecord}
+ * Formats a {@link org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDataSource.SubjectRecord}
* (the SmartGWT {@link Record} representation of a {@link Subject}).
*
* @author Ian Springer
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 7cfb393..071bff3 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
@@ -686,6 +686,10 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
}
protected void deleteSelectedRecords() {
+ deleteSelectedRecords(null);
+ }
+
+ protected void deleteSelectedRecords(DSRequest requestProperties) {
ListGrid listGrid = getListGrid();
final int selectedRecordCount = listGrid.getSelection().length;
final List<String> deletedRecordNames = new ArrayList<String>(selectedRecordCount);
@@ -704,11 +708,12 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
.widget_recordEditor_info_recordsDeletedDetailed(String.valueOf(deletedRecordNames.size()),
getDataTypeNamePlural(), deletedRecordNames.toString()));
CoreGUI.getMessageCenter().notify(message);
+ refresh();
}
}
// TODO: Print error messages for failures or partial failures.
}
- }, null);
+ }, requestProperties);
}
protected String getDataTypeName() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
index a23a8d1..194c921 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
@@ -46,6 +46,8 @@ public interface OperationGWTService extends RemoteService {
PageList<GroupOperationHistory> findGroupOperationHistoriesByCriteria(GroupOperationHistoryCriteria criteria)
throws RuntimeException;
+ void deleteOperationHistory(int operationHistoryId, boolean deleteEvenIfInProgress) throws RuntimeException;
+
List<DisambiguationReport<ResourceOperationLastCompletedComposite>> findRecentCompletedOperations(int resourceId,
PageControl pageControl) throws RuntimeException;
@@ -57,8 +59,12 @@ public interface OperationGWTService extends RemoteService {
int scheduleResourceOperation(ResourceOperationSchedule resourceOperationSchedule) throws RuntimeException;
+ int scheduleGroupOperation(GroupOperationSchedule groupOperationSchedule) throws RuntimeException;
+
void unscheduleResourceOperation(ResourceOperationSchedule resourceOperationSchedule) throws RuntimeException;
+ void unscheduleGroupOperation(GroupOperationSchedule groupOperationSchedule) throws RuntimeException;
+
void scheduleResourceOperation(int resourceId, String operationName, Configuration parameters, String description,
int timeout, String cronString) throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java
new file mode 100644
index 0000000..5ddebb5
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java
@@ -0,0 +1,134 @@
+/*
+ * 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.common.detail.operation.history;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.operation.OperationHistory;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author Greg Hinkle
+ * @author Ian Springer
+ */
+public abstract class AbstractOperationHistoryDataSource<T extends OperationHistory> extends RPCDataSource<T> {
+
+ private T currentOperationHistory;
+
+ public static abstract class Field {
+ public static final String ID = "id";
+ public static final String OPERATION_NAME = "operationName";
+ public static final String RESOURCE = "resource";
+ public static final String STATUS = "status";
+ public static final String STARTED_TIME = "startedTime";
+ public static final String CREATED_TIME = "createdTime";
+ public static final String DURATION = "duration";
+ public static final String SUBJECT = "subject";
+ public static final String OPERATION_DEFINITION = "operationDefinition";
+ public static final String ERROR_MESSAGE = "errorMessage";
+ public static final String PARAMETERS = "parameters";
+ }
+
+ protected OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
+
+ public AbstractOperationHistoryDataSource() {
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected void executeRemove(Record recordToRemove, DSRequest request, DSResponse response) {
+ final OperationHistory operationHistoryToRemove = copyValues(recordToRemove);
+ Boolean forceValue = request.getAttributeAsBoolean("force");
+ boolean force = ((forceValue != null) && forceValue);
+ operationService.deleteOperationHistory(operationHistoryToRemove.getId(), force, new AsyncCallback<Void>() {
+ public void onSuccess(Void result) {
+ return;
+ }
+
+ public void onFailure(Throwable caught) {
+ throw new RuntimeException("Failed to delete " + operationHistoryToRemove + ".", caught);
+ }
+ });
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ /*
+ DataSourceIntegerField idField = new DataSourceIntegerField(Field.ID);
+ idField.setPrimaryKey(true);
+ fields.add(idField);
+ */
+
+ DataSourceTextField nameField = new DataSourceTextField(Field.OPERATION_NAME);
+ fields.add(nameField);
+
+ /*
+ DataSourceTextField resourceField = new DataSourceTextField(Field.RESOURCE);
+ fields.add(resourceField);
+
+ DataSourceTextField statusField = new DataSourceTextField(Field.STATUS);
+ fields.add(statusField);
+
+ DataSourceTextField startedField = new DataSourceTextField(Field.STARTED_TIME);
+ startedField.setType(FieldType.DATETIME);
+ fields.add(startedField);
+ */
+
+ return fields;
+ }
+
+ @Override
+ public T copyValues(Record from) {
+ return this.currentOperationHistory;
+ }
+
+ @Override
+ public ListGridRecord copyValues(T from) {
+ this.currentOperationHistory = from;
+
+ ListGridRecord record = new ListGridRecord();
+
+ record.setAttribute(Field.ID, from.getId());
+ record.setAttribute(Field.CREATED_TIME, from.getCreatedTime());
+ record.setAttribute(Field.STARTED_TIME, new Date(from.getStartedTime()));
+ record.setAttribute(Field.DURATION, from.getDuration());
+ record.setAttribute(Field.SUBJECT, from.getSubjectName());
+ record.setAttribute(Field.OPERATION_DEFINITION, from.getOperationDefinition());
+ record.setAttribute(Field.OPERATION_NAME, from.getOperationDefinition().getDisplayName());
+ record.setAttribute(Field.ERROR_MESSAGE, from.getErrorMessage());
+ record.setAttribute(Field.STATUS, from.getStatus().name());
+ record.setAttribute(Field.PARAMETERS, from.getParameters());
+
+ return record;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java
index bc22921..a010a23 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.DateDisplayFormat;
@@ -40,6 +41,7 @@ import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
@@ -48,48 +50,77 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public abstract class AbstractOperationHistoryListView extends TableSection<OperationHistoryDataSource> {
+public abstract class AbstractOperationHistoryListView extends TableSection<AbstractOperationHistoryDataSource> {
private static final String HEADER_ICON = "subsystems/control/Operation_24.png";
- public AbstractOperationHistoryListView(String locatorId, OperationHistoryDataSource dataSource, String title) {
+ public AbstractOperationHistoryListView(String locatorId, AbstractOperationHistoryDataSource dataSource, String title) {
super(locatorId, title);
setDataSource(dataSource);
setHeaderIcon(HEADER_ICON);
}
- public AbstractOperationHistoryListView(String locatorId, OperationHistoryDataSource dataSource, String title,
+ public AbstractOperationHistoryListView(String locatorId, AbstractOperationHistoryDataSource dataSource, String title,
Criteria criteria) {
super(locatorId, title, criteria);
setDataSource(dataSource);
}
+ protected abstract boolean hasControlPermission();
+
@Override
protected void configureTable() {
super.configureTable();
List<ListGridField> fields = createFields();
setListGridFields(fields.toArray(new ListGridField[fields.size()]));
+
+ addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), getDeleteConfirmMessage(),
+ new TableAction() {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ int count = selection.length;
+ return (count >= 1 && hasControlPermission());
+ }
+
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ deleteSelectedRecords();
+ }
+ });
+
+ // TODO: i18n
+ addTableAction(extendLocatorId("ForceDelete"), "Force Delete", getDeleteConfirmMessage(),
+ new TableAction() {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ int count = selection.length;
+ return (count >= 1 && hasControlPermission());
+ }
+
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ DSRequest requestProperties = new DSRequest();
+ requestProperties.setAttribute("force", true);
+ deleteSelectedRecords(requestProperties);
+ }
+ });
}
protected List<ListGridField> createFields() {
List<ListGridField> fields = new ArrayList<ListGridField>();
- ListGridField idField = new ListGridField(OperationHistoryDataSource.Field.ID, MSG.common_title_id());
+ ListGridField idField = new ListGridField(AbstractOperationHistoryDataSource.Field.ID, MSG.common_title_id());
idField.setWidth(38);
fields.add(idField);
- ListGridField opNameField = new ListGridField(OperationHistoryDataSource.Field.OPERATION_NAME,
+ ListGridField opNameField = new ListGridField(AbstractOperationHistoryDataSource.Field.OPERATION_NAME,
MSG.dataSource_operationHistory_operationName());
opNameField.setWidth("34%");
fields.add(opNameField);
- ListGridField subjectField = new ListGridField(OperationHistoryDataSource.Field.SUBJECT,
+ ListGridField subjectField = new ListGridField(AbstractOperationHistoryDataSource.Field.SUBJECT,
MSG.common_title_user());
subjectField.setWidth("33%");
fields.add(subjectField);
- ListGridField statusField = new ListGridField(OperationHistoryDataSource.Field.STATUS,
+ ListGridField statusField = new ListGridField(AbstractOperationHistoryDataSource.Field.STATUS,
MSG.common_title_status());
statusField.setAlign(Alignment.CENTER);
statusField.setCellAlign(Alignment.CENTER);
@@ -97,7 +128,7 @@ public abstract class AbstractOperationHistoryListView extends TableSection<Oper
statusField.setHoverCustomizer(new HoverCustomizer() {
@Override
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
- String statusStr = record.getAttribute(OperationHistoryDataSource.Field.STATUS);
+ String statusStr = record.getAttribute(AbstractOperationHistoryDataSource.Field.STATUS);
OperationRequestStatus status = OperationRequestStatus.valueOf(statusStr);
switch (status) {
case SUCCESS: {
@@ -127,7 +158,7 @@ public abstract class AbstractOperationHistoryListView extends TableSection<Oper
@Override
public void onRecordClick(RecordClickEvent event) {
Record record = event.getRecord();
- String statusStr = record.getAttribute(OperationHistoryDataSource.Field.STATUS);
+ String statusStr = record.getAttribute(AbstractOperationHistoryDataSource.Field.STATUS);
OperationRequestStatus status = OperationRequestStatus.valueOf(statusStr);
if (status == OperationRequestStatus.FAILURE) {
final Window winModal = new LocatableWindow(AbstractOperationHistoryListView.this
@@ -155,7 +186,7 @@ public abstract class AbstractOperationHistoryListView extends TableSection<Oper
htmlPane.setMargin(10);
htmlPane.setDefaultWidth(500);
htmlPane.setDefaultHeight(400);
- String errorMsg = record.getAttribute(OperationHistoryDataSource.Field.ERROR_MESSAGE);
+ String errorMsg = record.getAttribute(AbstractOperationHistoryDataSource.Field.ERROR_MESSAGE);
if (errorMsg == null) {
errorMsg = MSG.common_status_failed();
}
@@ -168,7 +199,7 @@ public abstract class AbstractOperationHistoryListView extends TableSection<Oper
statusField.setWidth(44);
fields.add(statusField);
- ListGridField startedTimeField = new ListGridField(OperationHistoryDataSource.Field.STARTED_TIME,
+ ListGridField startedTimeField = new ListGridField(AbstractOperationHistoryDataSource.Field.STARTED_TIME,
MSG.dataSource_operationHistory_startedTime());
startedTimeField.setType(ListGridFieldType.DATE);
startedTimeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
@@ -182,7 +213,7 @@ public abstract class AbstractOperationHistoryListView extends TableSection<Oper
@Override
protected String getDetailsLinkColumnName() {
- return OperationHistoryDataSource.Field.OPERATION_NAME;
+ return AbstractOperationHistoryDataSource.Field.OPERATION_NAME;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java
deleted file mode 100644
index c320d10..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java
+++ /dev/null
@@ -1,109 +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.common.detail.operation.history;
-
-import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.operation.OperationHistory;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author Greg Hinkle
- */
-public abstract class OperationHistoryDataSource<T extends OperationHistory> extends RPCDataSource<T> {
-
- public static abstract class Field {
- public static final String ID = "id";
- public static final String OPERATION_NAME = "operationName";
- public static final String RESOURCE = "resource";
- public static final String STATUS = "status";
- public static final String STARTED_TIME = "startedTime";
- public static final String CREATED_TIME = "createdTime";
- public static final String DURATION = "duration";
- public static final String SUBJECT = "subject";
- public static final String OPERATION_DEFINITION = "operationDefinition";
- public static final String ERROR_MESSAGE = "errorMessage";
- public static final String PARAMETERS = "parameters";
- }
-
- protected OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
-
- public OperationHistoryDataSource() {
- List<DataSourceField> fields = addDataSourceFields();
- addFields(fields);
- }
-
- @Override
- protected List<DataSourceField> addDataSourceFields() {
- List<DataSourceField> fields = super.addDataSourceFields();
-
- /*
- DataSourceIntegerField idField = new DataSourceIntegerField(Field.ID);
- idField.setPrimaryKey(true);
- fields.add(idField);
- */
-
- DataSourceTextField nameField = new DataSourceTextField(Field.OPERATION_NAME);
- fields.add(nameField);
-
- /*
- DataSourceTextField resourceField = new DataSourceTextField(Field.RESOURCE);
- fields.add(resourceField);
-
- DataSourceTextField statusField = new DataSourceTextField(Field.STATUS);
- fields.add(statusField);
-
- DataSourceTextField startedField = new DataSourceTextField(Field.STARTED_TIME);
- startedField.setType(FieldType.DATETIME);
- fields.add(startedField);
- */
-
- return fields;
- }
-
- @Override
- public T copyValues(Record from) {
- throw new UnsupportedOperationException("OperationHistory is read only.");
- }
-
- @Override
- public ListGridRecord copyValues(T from) {
- ListGridRecord record = new ListGridRecord();
- record.setAttribute(Field.ID, from.getId());
- record.setAttribute(Field.CREATED_TIME, from.getCreatedTime());
- record.setAttribute(Field.STARTED_TIME, new Date(from.getStartedTime()));
- record.setAttribute(Field.DURATION, from.getDuration());
- record.setAttribute(Field.SUBJECT, from.getSubjectName());
- record.setAttribute(Field.OPERATION_DEFINITION, from.getOperationDefinition());
- record.setAttribute(Field.OPERATION_NAME, from.getOperationDefinition().getDisplayName());
- record.setAttribute(Field.ERROR_MESSAGE, from.getErrorMessage());
- record.setAttribute(Field.STATUS, from.getStatus().name());
- record.setAttribute(Field.PARAMETERS, from.getParameters());
-
- return record;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java
index 9d5c382..09fc8d2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java
@@ -98,11 +98,11 @@ public class ResourceOperationHistoryDetailsView extends LocatableVLayout implem
OperationRequestStatus status = operationHistory.getStatus();
- StaticTextItem operationItem = new StaticTextItem(OperationHistoryDataSource.Field.OPERATION_NAME, MSG
+ StaticTextItem operationItem = new StaticTextItem(AbstractOperationHistoryDataSource.Field.OPERATION_NAME, MSG
.view_operationHistoryDetails_operation());
operationItem.setValue(definition.getDisplayName());
- StaticTextItem submittedItem = new StaticTextItem(OperationHistoryDataSource.Field.STARTED_TIME, MSG
+ StaticTextItem submittedItem = new StaticTextItem(AbstractOperationHistoryDataSource.Field.STARTED_TIME, MSG
.view_operationHistoryDetails_dateSubmitted());
submittedItem.setValue(new Date(operationHistory.getStartedTime()));
@@ -115,13 +115,13 @@ public class ResourceOperationHistoryDetailsView extends LocatableVLayout implem
completedItem.setValue(new Date(operationHistory.getStartedTime() + operationHistory.getDuration()));
}
- StaticTextItem requesterItem = new StaticTextItem(OperationHistoryDataSource.Field.SUBJECT, MSG
+ StaticTextItem requesterItem = new StaticTextItem(AbstractOperationHistoryDataSource.Field.SUBJECT, MSG
.view_operationHistoryDetails_requestor());
requesterItem.setValue(operationHistory.getSubjectName());
LinkItem errorLinkItem = null;
- StaticTextItem statusItem = new StaticTextItem(OperationHistoryDataSource.Field.STATUS, MSG
+ StaticTextItem statusItem = new StaticTextItem(AbstractOperationHistoryDataSource.Field.STATUS, MSG
.view_operationHistoryDetails_status());
String icon = ImageManager.getFullImagePath(ImageManager.getOperationResultsIcon(status));
statusItem.setValue("<img src='" + icon + "'/>");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java
new file mode 100644
index 0000000..20b84fa
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java
@@ -0,0 +1,256 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, 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.inventory.common.detail.operation.schedule;
+
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Set;
+
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceDateTimeField;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.types.FieldType;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.JobTrigger;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.operation.bean.OperationSchedule;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author Ian Springer
+ */
+public abstract class AbstractOperationScheduleDataSource<T extends OperationSchedule> extends RPCDataSource<T> {
+
+ public static abstract class Field {
+ public static final String ID = "id";
+ public static final String JOB_NAME = "jobName";
+ public static final String JOB_GROUP = "jobGroup";
+ public static final String OPERATION_NAME = "operationName";
+ public static final String OPERATION_DISPLAY_NAME = "operationDisplayName";
+ public static final String PARAMETERS = "parameters";
+ public static final String SUBJECT = "subject";
+ public static final String DESCRIPTION = "description";
+ public static final String NEXT_FIRE_TIME = "nextFireTime";
+ public static final String TIMEOUT = "timeout";
+
+ // job trigger fields
+ public static final String START_TIME = "startTime";
+ public static final String REPEAT_INTERVAL = "repeatInterval";
+ public static final String REPEAT_COUNT = "repeatCount";
+ public static final String END_TIME = "endTime";
+ public static final String CRON_EXPRESSION = "cronExpression";
+ }
+
+ protected OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
+
+ private ResourceType resourceType;
+
+ public AbstractOperationScheduleDataSource(ResourceType resourceType) {
+ super();
+ this.resourceType = resourceType;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ // TODO: i18n
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceIntegerField idField = new DataSourceIntegerField(Field.ID, "ID");
+ idField.setPrimaryKey(true);
+ idField.setCanEdit(false);
+ fields.add(idField);
+
+ DataSourceTextField operationNameField = createTextField(Field.OPERATION_NAME, "Operation Name", null, 100,
+ true);
+ fields.add(operationNameField);
+
+ DataSourceTextField operationDisplayNameField = createTextField(Field.OPERATION_DISPLAY_NAME, "Operation", null,
+ 100, true);
+ fields.add(operationDisplayNameField);
+
+ Set<OperationDefinition> operationDefinitions = this.resourceType.getOperationDefinitions();
+ LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
+ for (OperationDefinition operationDefinition : operationDefinitions) {
+ valueMap.put(operationDefinition.getName(), operationDefinition.getDisplayName());
+ }
+ operationNameField.setValueMap(valueMap);
+
+ DataSourceField subjectField = new DataSourceField(Field.SUBJECT, FieldType.ANY, "Owner");
+ subjectField.setCanEdit(false);
+ fields.add(subjectField);
+
+ DataSourceTextField descriptionField = createTextField(Field.DESCRIPTION, "Notes", null, 100, false);
+ fields.add(descriptionField);
+
+ DataSourceDateTimeField nextFireTimeField = new DataSourceDateTimeField(Field.NEXT_FIRE_TIME,
+ "Next Scheduled Execution");
+ nextFireTimeField.setCanEdit(false);
+ fields.add(nextFireTimeField);
+
+ DataSourceIntegerField timeoutField = createIntegerField(Field.TIMEOUT, "Timeout (in seconds)", 30, null, false);
+ fields.add(timeoutField);
+
+ return fields;
+ }
+
+ protected abstract T createOperationSchedule();
+
+ @Override
+ public T copyValues(Record from) {
+ T to = createOperationSchedule();
+
+ to.setId(from.getAttributeAsInt(Field.ID));
+ to.setJobName(from.getAttribute(Field.JOB_NAME));
+ to.setJobGroup(from.getAttribute(Field.JOB_GROUP));
+ SubjectRecord subjectRecord = (SubjectRecord) from.getAttributeAsRecord(Field.SUBJECT);
+ to.setSubject(subjectRecord.toSubject());
+ Configuration parameters = (Configuration) from.getAttributeAsObject(Field.PARAMETERS);
+ to.setParameters(parameters);
+ to.setOperationName(from.getAttribute(Field.OPERATION_NAME));
+ to.setOperationDisplayName(from.getAttribute(Field.OPERATION_DISPLAY_NAME));
+ to.setDescription(from.getAttribute(Field.DESCRIPTION));
+ to.setNextFireTime(from.getAttributeAsDate(Field.NEXT_FIRE_TIME));
+ if (parameters != null) {
+ parameters.put(new PropertySimple(OperationDefinition.TIMEOUT_PARAM_NAME, from.getAttributeAsInt(Field.TIMEOUT)));
+ }
+
+ to.setJobTrigger(createJobTrigger(from.getAttributeAsRecord("jobTrigger")));
+
+ return to;
+ }
+
+ @Override
+ public ListGridRecord copyValues(T from) {
+ ListGridRecord to = new ListGridRecord();
+
+ to.setAttribute(Field.ID, from.getId());
+ to.setAttribute(Field.JOB_NAME, from.getJobName());
+ to.setAttribute(Field.JOB_GROUP, from.getJobGroup());
+ SubjectRecord subjectRecord = new SubjectRecord(from.getSubject());
+ to.setAttribute(Field.SUBJECT, subjectRecord);
+ Configuration parameters = from.getParameters();
+ to.setAttribute(Field.PARAMETERS, parameters);
+ to.setAttribute(Field.OPERATION_NAME, from.getOperationName());
+ to.setAttribute(Field.OPERATION_DISPLAY_NAME, from.getOperationDisplayName());
+ to.setAttribute(Field.DESCRIPTION, from.getDescription());
+ to.setAttribute(Field.NEXT_FIRE_TIME, from.getNextFireTime());
+ to.setAttribute(Field.TIMEOUT, (parameters != null) ?
+ parameters.getSimpleValue(OperationDefinition.TIMEOUT_PARAM_NAME, null) : null);
+
+ JobTrigger jobTrigger = from.getJobTrigger();
+ Record jobTriggerRecord = new ListGridRecord();
+ jobTriggerRecord.setAttribute(Field.START_TIME, jobTrigger.getStartDate());
+ jobTriggerRecord.setAttribute(Field.REPEAT_INTERVAL, jobTrigger.getRepeatInterval());
+ jobTriggerRecord.setAttribute(Field.REPEAT_COUNT, jobTrigger.getRepeatCount());
+ jobTriggerRecord.setAttribute(Field.END_TIME, jobTrigger.getEndDate());
+ jobTriggerRecord.setAttribute(Field.CRON_EXPRESSION, jobTrigger.getCronExpression());
+ to.setAttribute("jobTrigger", jobTriggerRecord);
+
+ return to;
+ }
+
+ public JobTrigger createJobTrigger(Record jobTriggerRecord) {
+ JobTrigger jobTrigger;
+
+ String cronExpression = jobTriggerRecord.getAttribute(Field.CRON_EXPRESSION);
+ if (cronExpression != null) {
+ jobTrigger = JobTrigger.createCronTrigger(cronExpression);
+ } else {
+ // calendar mode
+ Date startTime = jobTriggerRecord.getAttributeAsDate(Field.START_TIME);
+ Long repeatInterval = (Long)jobTriggerRecord.getAttributeAsObject(Field.REPEAT_INTERVAL);
+ Integer repeatCount = jobTriggerRecord.getAttributeAsInt(Field.REPEAT_COUNT);
+ Date endTime = jobTriggerRecord.getAttributeAsDate(Field.END_TIME);
+
+ if (startTime != null) {
+ // LATER
+
+ if (repeatInterval != null) {
+ // LATER AND REPEAT
+
+ if (repeatCount != null) {
+ jobTrigger = JobTrigger.createLaterAndRepeatTrigger(startTime, repeatInterval, repeatCount);
+ } else {
+ jobTrigger = JobTrigger.createLaterAndRepeatTrigger(startTime, repeatInterval, endTime);
+ }
+ } else {
+ // LATER ONCE
+
+ jobTrigger = JobTrigger.createLaterTrigger(startTime);
+ }
+ } else {
+ // NOW
+ if (repeatInterval != null) {
+ // NOW AND REPEAT
+
+ if (repeatCount != null) {
+ jobTrigger = JobTrigger.createNowAndRepeatTrigger(repeatInterval, repeatCount);
+ } else {
+ jobTrigger = JobTrigger.createNowAndRepeatTrigger(repeatInterval, endTime);
+ }
+ } else {
+ // NOW ONCE
+
+ jobTrigger = JobTrigger.createNowTrigger();
+ }
+ }
+ }
+
+ return jobTrigger;
+ }
+
+ public static class SubjectRecord extends ListGridRecord {
+ static final String FIELD_ID = "id";
+ static final String FIELD_NAME = "name";
+
+ public SubjectRecord(Subject subject) {
+ setAttribute(FIELD_ID, subject.getId());
+ setAttribute(FIELD_NAME, subject.getName());
+ }
+
+ public int getId() {
+ return getAttributeAsInt(FIELD_ID);
+ }
+
+ public String getName() {
+ return getAttribute(FIELD_NAME);
+ }
+
+ public Subject toSubject() {
+ Subject subject = new Subject();
+ subject.setId(getId());
+ subject.setName(getName());
+ return subject;
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
index db32a81..bc27926 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
@@ -72,7 +72,7 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
private Configuration parameters;
private EnhancedDynamicForm notesForm;
- public AbstractOperationScheduleDetailsView(String locatorId, OperationScheduleDataSource dataSource,
+ public AbstractOperationScheduleDetailsView(String locatorId, AbstractOperationScheduleDataSource dataSource,
ResourceType resourceType, int scheduleId) {
super(locatorId, dataSource, scheduleId, "Scheduled Operation", null);
@@ -140,11 +140,11 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
List<FormItem> notesFields = new ArrayList<FormItem>();
if (!isNewRecord()) {
- StaticTextItem nextFireTimeItem = new StaticTextItem(OperationScheduleDataSource.Field.NEXT_FIRE_TIME);
+ StaticTextItem nextFireTimeItem = new StaticTextItem(AbstractOperationScheduleDataSource.Field.NEXT_FIRE_TIME);
notesFields.add(nextFireTimeItem);
}
- TextItem timeoutItem = new TextItem(OperationScheduleDataSource.Field.TIMEOUT, "Timeout (in seconds)");
+ TextItem timeoutItem = new TextItem(AbstractOperationScheduleDataSource.Field.TIMEOUT, "Timeout (in seconds)");
notesFields.add(timeoutItem);
TextAreaItem notesItem = new TextAreaItem(ResourceOperationScheduleDataSource.Field.DESCRIPTION, "Notes");
@@ -175,8 +175,8 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
protected Record createNewRecord() {
Record record = super.createNewRecord();
Subject sessionSubject = UserSessionManager.getSessionSubject();
- OperationScheduleDataSource.SubjectRecord subjectRecord =
- new OperationScheduleDataSource.SubjectRecord(sessionSubject);
+ AbstractOperationScheduleDataSource.SubjectRecord subjectRecord =
+ new AbstractOperationScheduleDataSource.SubjectRecord(sessionSubject);
record.setAttribute(ResourceOperationScheduleDataSource.Field.SUBJECT, subjectRecord);
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleListView.java
new file mode 100644
index 0000000..3819b4a
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleListView.java
@@ -0,0 +1,88 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, 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.inventory.common.detail.operation.schedule;
+
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.enterprise.gui.coregui.client.components.table.SubjectRecordCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+
+/**
+ * @author Ian Springer
+ */
+public abstract class AbstractOperationScheduleListView extends TableSection<AbstractOperationScheduleDataSource> {
+
+ public AbstractOperationScheduleListView(String locatorId, AbstractOperationScheduleDataSource dataSource, String title) {
+ super(locatorId, title);
+
+ setDataSource(dataSource);
+ }
+
+ protected abstract boolean hasControlPermission();
+
+ @Override
+ protected void configureTable() {
+ super.configureTable();
+
+ ListGridField operationField = new ListGridField(AbstractOperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME, 180);
+
+ ListGridField subjectField = new ListGridField(AbstractOperationScheduleDataSource.Field.SUBJECT, 110);
+ subjectField.setCellFormatter(new SubjectRecordCellFormatter());
+
+ //ListGridField jobTriggerField = new ListGridField(OperationScheduleDataSource.Field.JOB_TRIGGER, 300);
+
+ ListGridField nextFireTimeField = new ListGridField(AbstractOperationScheduleDataSource.Field.NEXT_FIRE_TIME,
+ "Next Scheduled Execution", 190);
+
+ ListGridField descriptionField = new ListGridField(AbstractOperationScheduleDataSource.Field.DESCRIPTION);
+
+ setListGridFields(operationField, subjectField, nextFireTimeField, descriptionField);
+
+ addTableAction(extendLocatorId("New"), MSG.common_button_new(), new TableAction() {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ return hasControlPermission();
+ }
+
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ newDetails();
+ }
+ });
+
+ addTableAction(extendLocatorId("Unschedule"), MSG.common_button_delete(), getDeleteConfirmMessage(),
+ new TableAction() {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ int count = selection.length;
+ return ((count >= 1) && hasControlPermission());
+ }
+
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ deleteSelectedRecords();
+ }
+ });
+ }
+
+ @Override
+ protected String getDetailsLinkColumnName() {
+ return AbstractOperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
deleted file mode 100644
index 3813b98..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2010, 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.inventory.common.detail.operation.schedule;
-
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Set;
-
-import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.fields.DataSourceDateTimeField;
-import com.smartgwt.client.data.fields.DataSourceIntegerField;
-import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.types.FieldType;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.common.JobTrigger;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.operation.bean.OperationSchedule;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-
-/**
- * @author Ian Springer
- */
-public abstract class OperationScheduleDataSource<T extends OperationSchedule> extends RPCDataSource<T> {
-
- public static abstract class Field {
- public static final String ID = "id";
- public static final String JOB_NAME = "jobName";
- public static final String JOB_GROUP = "jobGroup";
- public static final String OPERATION_NAME = "operationName";
- public static final String OPERATION_DISPLAY_NAME = "operationDisplayName";
- public static final String PARAMETERS = "parameters";
- public static final String SUBJECT = "subject";
- public static final String DESCRIPTION = "description";
- public static final String NEXT_FIRE_TIME = "nextFireTime";
- public static final String TIMEOUT = "timeout";
-
- // job trigger fields
- public static final String START_TIME = "startTime";
- public static final String REPEAT_INTERVAL = "repeatInterval";
- public static final String REPEAT_COUNT = "repeatCount";
- public static final String END_TIME = "endTime";
- public static final String CRON_EXPRESSION = "cronExpression";
- }
-
- protected OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
-
- private ResourceType resourceType;
-
- public OperationScheduleDataSource(ResourceType resourceType) {
- super();
- this.resourceType = resourceType;
- List<DataSourceField> fields = addDataSourceFields();
- addFields(fields);
- }
-
- // TODO: i18n
- @Override
- protected List<DataSourceField> addDataSourceFields() {
- List<DataSourceField> fields = super.addDataSourceFields();
-
- DataSourceIntegerField idField = new DataSourceIntegerField(Field.ID, "ID");
- idField.setPrimaryKey(true);
- idField.setCanEdit(false);
- fields.add(idField);
-
- DataSourceTextField operationNameField = createTextField(Field.OPERATION_NAME, "Operation Name", null, 100,
- true);
- fields.add(operationNameField);
-
- DataSourceTextField operationDisplayNameField = createTextField(Field.OPERATION_DISPLAY_NAME, "Operation", null,
- 100, true);
- fields.add(operationDisplayNameField);
-
- Set<OperationDefinition> operationDefinitions = this.resourceType.getOperationDefinitions();
- LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
- for (OperationDefinition operationDefinition : operationDefinitions) {
- valueMap.put(operationDefinition.getName(), operationDefinition.getDisplayName());
- }
- operationNameField.setValueMap(valueMap);
-
- DataSourceField subjectField = new DataSourceField(Field.SUBJECT, FieldType.ANY, "Owner");
- subjectField.setCanEdit(false);
- fields.add(subjectField);
-
- DataSourceTextField descriptionField = createTextField(Field.DESCRIPTION, "Notes", null, 100, false);
- fields.add(descriptionField);
-
- DataSourceDateTimeField nextFireTimeField = new DataSourceDateTimeField(Field.NEXT_FIRE_TIME,
- "Next Scheduled Execution");
- nextFireTimeField.setCanEdit(false);
- fields.add(nextFireTimeField);
-
- DataSourceIntegerField timeoutField = createIntegerField(Field.TIMEOUT, "Timeout (in seconds)", 30, null, false);
- fields.add(timeoutField);
-
- return fields;
- }
-
- protected abstract T createOperationSchedule();
-
- @Override
- public T copyValues(Record from) {
- T to = createOperationSchedule();
-
- to.setId(from.getAttributeAsInt(Field.ID));
- to.setJobName(from.getAttribute(Field.JOB_NAME));
- to.setJobGroup(from.getAttribute(Field.JOB_GROUP));
- SubjectRecord subjectRecord = (SubjectRecord) from.getAttributeAsRecord(Field.SUBJECT);
- to.setSubject(subjectRecord.toSubject());
- Configuration parameters = (Configuration) from.getAttributeAsObject(Field.PARAMETERS);
- to.setParameters(parameters);
- to.setOperationName(from.getAttribute(Field.OPERATION_NAME));
- to.setOperationDisplayName(from.getAttribute(Field.OPERATION_DISPLAY_NAME));
- to.setDescription(from.getAttribute(Field.DESCRIPTION));
- to.setNextFireTime(from.getAttributeAsDate(Field.NEXT_FIRE_TIME));
- if (parameters != null) {
- parameters.put(new PropertySimple(OperationDefinition.TIMEOUT_PARAM_NAME, from.getAttributeAsInt(Field.TIMEOUT)));
- }
-
- to.setJobTrigger(createJobTrigger(from.getAttributeAsRecord("jobTrigger")));
-
- return to;
- }
-
- @Override
- public ListGridRecord copyValues(T from) {
- ListGridRecord to = new ListGridRecord();
-
- to.setAttribute(Field.ID, from.getId());
- to.setAttribute(Field.JOB_NAME, from.getJobName());
- to.setAttribute(Field.JOB_GROUP, from.getJobGroup());
- SubjectRecord subjectRecord = new SubjectRecord(from.getSubject());
- to.setAttribute(Field.SUBJECT, subjectRecord);
- to.setAttribute(Field.PARAMETERS, from.getParameters());
- to.setAttribute(Field.OPERATION_NAME, from.getOperationName());
- to.setAttribute(Field.OPERATION_DISPLAY_NAME, from.getOperationDisplayName());
- to.setAttribute(Field.DESCRIPTION, from.getDescription());
- to.setAttribute(Field.NEXT_FIRE_TIME, from.getNextFireTime());
- to.setAttribute(Field.TIMEOUT, from.getParameters().getSimpleValue(OperationDefinition.TIMEOUT_PARAM_NAME, null));
-
- JobTrigger jobTrigger = from.getJobTrigger();
- Record jobTriggerRecord = new ListGridRecord();
- jobTriggerRecord.setAttribute(Field.START_TIME, jobTrigger.getStartDate());
- jobTriggerRecord.setAttribute(Field.REPEAT_INTERVAL, jobTrigger.getRepeatInterval());
- jobTriggerRecord.setAttribute(Field.REPEAT_COUNT, jobTrigger.getRepeatCount());
- jobTriggerRecord.setAttribute(Field.END_TIME, jobTrigger.getEndDate());
- jobTriggerRecord.setAttribute(Field.CRON_EXPRESSION, jobTrigger.getCronExpression());
- to.setAttribute("jobTrigger", jobTriggerRecord);
-
- return to;
- }
-
- public JobTrigger createJobTrigger(Record jobTriggerRecord) {
- JobTrigger jobTrigger;
-
- String cronExpression = jobTriggerRecord.getAttribute(Field.CRON_EXPRESSION);
- if (cronExpression != null) {
- jobTrigger = JobTrigger.createCronTrigger(cronExpression);
- } else {
- // calendar mode
- Date startTime = jobTriggerRecord.getAttributeAsDate(Field.START_TIME);
- Long repeatInterval = (Long)jobTriggerRecord.getAttributeAsObject(Field.REPEAT_INTERVAL);
- Integer repeatCount = jobTriggerRecord.getAttributeAsInt(Field.REPEAT_COUNT);
- Date endTime = jobTriggerRecord.getAttributeAsDate(Field.END_TIME);
-
- if (startTime != null) {
- // LATER
-
- if (repeatInterval != null) {
- // LATER AND REPEAT
-
- if (repeatCount != null) {
- jobTrigger = JobTrigger.createLaterAndRepeatTrigger(startTime, repeatInterval, repeatCount);
- } else {
- jobTrigger = JobTrigger.createLaterAndRepeatTrigger(startTime, repeatInterval, endTime);
- }
- } else {
- // LATER ONCE
-
- jobTrigger = JobTrigger.createLaterTrigger(startTime);
- }
- } else {
- // NOW
- if (repeatInterval != null) {
- // NOW AND REPEAT
-
- if (repeatCount != null) {
- jobTrigger = JobTrigger.createNowAndRepeatTrigger(repeatInterval, repeatCount);
- } else {
- jobTrigger = JobTrigger.createNowAndRepeatTrigger(repeatInterval, endTime);
- }
- } else {
- // NOW ONCE
-
- jobTrigger = JobTrigger.createNowTrigger();
- }
- }
- }
-
- return jobTrigger;
- }
-
- public static class SubjectRecord extends ListGridRecord {
- static final String FIELD_ID = "id";
- static final String FIELD_NAME = "name";
-
- public SubjectRecord(Subject subject) {
- setAttribute(FIELD_ID, subject.getId());
- setAttribute(FIELD_NAME, subject.getName());
- }
-
- public int getId() {
- return getAttributeAsInt(FIELD_ID);
- }
-
- public String getName() {
- return getAttribute(FIELD_NAME);
- }
-
- public Subject toSubject() {
- Subject subject = new Subject();
- subject.setId(getId());
- subject.setName(getName());
- return subject;
- }
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java
deleted file mode 100644
index 3d8fd6d..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2010, 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.inventory.common.detail.operation.schedule;
-
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.enterprise.gui.coregui.client.components.table.SubjectRecordCellFormatter;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
-
-/**
- * @author Ian Springer
- */
-public abstract class OperationScheduleListView extends TableSection<OperationScheduleDataSource> {
-
- public OperationScheduleListView(String locatorId, OperationScheduleDataSource dataSource, String title) {
- super(locatorId, title);
-
- setDataSource(dataSource);
- }
-
- protected abstract boolean hasControlPermission();
-
- @Override
- protected void configureTable() {
- super.configureTable();
-
- ListGridField operationField = new ListGridField(OperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME, 180);
-
- ListGridField subjectField = new ListGridField(OperationScheduleDataSource.Field.SUBJECT, 110);
- subjectField.setCellFormatter(new SubjectRecordCellFormatter());
-
- //ListGridField jobTriggerField = new ListGridField(OperationScheduleDataSource.Field.JOB_TRIGGER, 300);
-
- ListGridField nextFireTimeField = new ListGridField(OperationScheduleDataSource.Field.NEXT_FIRE_TIME,
- "Next Scheduled Execution", 190);
-
- ListGridField descriptionField = new ListGridField(OperationScheduleDataSource.Field.DESCRIPTION);
-
- setListGridFields(operationField, subjectField, nextFireTimeField, descriptionField);
-
- addTableAction(extendLocatorId("New"), MSG.common_button_new(), new TableAction() {
- public boolean isEnabled(ListGridRecord[] selection) {
- return hasControlPermission();
- }
-
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- newDetails();
- }
- });
-
- addTableAction(extendLocatorId("Unschedule"), MSG.common_button_delete(), getDeleteConfirmMessage(),
- new TableAction() {
- public boolean isEnabled(ListGridRecord[] selection) {
- int count = selection.length;
- return ((count >= 1) && hasControlPermission());
- }
-
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- deleteSelectedRecords();
- }
- });
- }
-
- @Override
- protected String getDetailsLinkColumnName() {
- return OperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java
index d02949a..ff90336 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java
@@ -27,16 +27,16 @@ import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
import org.rhq.core.domain.operation.GroupOperationHistory;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.OperationHistoryDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource;
import java.util.Arrays;
/**
* @author Ian Springer
*/
-public class GroupOperationHistoryDataSource extends OperationHistoryDataSource<GroupOperationHistory> {
+public class GroupOperationHistoryDataSource extends AbstractOperationHistoryDataSource<GroupOperationHistory> {
- public static abstract class Field extends OperationHistoryDataSource.Field {
+ public static abstract class Field extends AbstractOperationHistoryDataSource.Field {
public static final String GROUP = "group";
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
index 9206e4f..887e313 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
@@ -23,7 +23,6 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.widgets.Canvas;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource;
/**
* @author Ian Springer
@@ -33,17 +32,15 @@ public class GroupOperationHistoryListView extends AbstractOperationHistoryListV
private ResourceGroupComposite groupComposite;
public GroupOperationHistoryListView(String locatorId, ResourceGroupComposite groupComposite) {
- super(locatorId, new ResourceOperationHistoryDataSource(), null,
+ super(locatorId, new GroupOperationHistoryDataSource(), null,
new Criteria(GroupOperationHistoryDataSource.CriteriaField.GROUP_ID,
String.valueOf(groupComposite.getResourceGroup().getId())));
this.groupComposite = groupComposite;
}
@Override
- protected void configureTable() {
- super.configureTable();
-
- // TODO: Add Delete button.
+ protected boolean hasControlPermission() {
+ return this.groupComposite.getResourcePermission().isControl();
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
index d104eb2..7603a45 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
@@ -26,7 +26,7 @@ import com.smartgwt.client.data.Record;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.operation.bean.GroupOperationSchedule;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDataSource;
import java.util.List;
@@ -36,7 +36,7 @@ import java.util.List;
*
* @author Ian Springer
*/
-public class GroupOperationScheduleDataSource extends OperationScheduleDataSource<GroupOperationSchedule> {
+public class GroupOperationScheduleDataSource extends AbstractOperationScheduleDataSource<GroupOperationSchedule> {
private ResourceGroupComposite groupComposite;
@@ -74,8 +74,8 @@ public class GroupOperationScheduleDataSource extends OperationScheduleDataSourc
Configuration parameters = (Configuration) request.getAttributeAsObject("parameters");
recordToAdd.setAttribute(Field.PARAMETERS, parameters);
final GroupOperationSchedule scheduleToAdd = copyValues(recordToAdd);
- // TODO
- /*operationService.scheduleResourceOperation(scheduleToAdd, new AsyncCallback<Integer>() {
+
+ operationService.scheduleGroupOperation(scheduleToAdd, new AsyncCallback<Integer>() {
public void onSuccess(Integer scheduleId) {
scheduleToAdd.setId(scheduleId);
sendSuccessResponse(request, response, scheduleToAdd);
@@ -84,22 +84,22 @@ public class GroupOperationScheduleDataSource extends OperationScheduleDataSourc
public void onFailure(Throwable caught) {
throw new RuntimeException("Failed to add " + scheduleToAdd, caught);
}
- });*/
+ });
}
@Override
protected void executeRemove(Record recordToRemove, final DSRequest request, final DSResponse response) {
final GroupOperationSchedule scheduleToRemove = copyValues(recordToRemove);
- // TODO
- /*operationService.unscheduleResourceOperation(scheduleToRemove, new AsyncCallback<Void>() {
+
+ operationService.unscheduleGroupOperation(scheduleToRemove, new AsyncCallback<Void>() {
public void onSuccess(Void result) {
sendSuccessResponse(request, response, scheduleToRemove);
}
public void onFailure(Throwable caught) {
- throw new RuntimeException(caught);
+ throw new RuntimeException("Failed to remove " + scheduleToRemove, caught);
}
- });*/
+ });
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
index f3b376b..f2183af 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
@@ -21,15 +21,12 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.
import com.smartgwt.client.widgets.Canvas;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleListView;
/**
* @author Ian Springer
*/
-public class GroupOperationScheduleListView extends OperationScheduleListView {
+public class GroupOperationScheduleListView extends AbstractOperationScheduleListView {
private static final String TITLE = null;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
index 447ec17..ca53ba0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
@@ -23,22 +23,19 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.Record;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
-import org.rhq.core.domain.operation.OperationHistory;
import org.rhq.core.domain.operation.ResourceOperationHistory;
-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.inventory.common.detail.operation.history.OperationHistoryDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource;
/**
* @author Ian Springer
*/
-public class ResourceOperationHistoryDataSource extends OperationHistoryDataSource<ResourceOperationHistory> {
+public class ResourceOperationHistoryDataSource extends AbstractOperationHistoryDataSource<ResourceOperationHistory> {
- public static abstract class Field extends OperationHistoryDataSource.Field {
+ public static abstract class Field extends AbstractOperationHistoryDataSource.Field {
public static final String RESOURCE = "resource";
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
index 086b39d..3b0f747 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
@@ -40,10 +40,8 @@ public class ResourceOperationHistoryListView extends AbstractOperationHistoryLi
}
@Override
- protected void configureTable() {
- super.configureTable();
-
- // TODO: Add Delete button.
+ protected boolean hasControlPermission() {
+ return this.resourceComposite.getResourcePermission().isControl();
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
index c122bfb..0950a70 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
@@ -30,14 +30,14 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDataSource;
/**
* A DataSource for {@link ResourceOperationSchedule}s for a given {@link Resource}.
*
* @author Ian Springer
*/
-public class ResourceOperationScheduleDataSource extends OperationScheduleDataSource<ResourceOperationSchedule> {
+public class ResourceOperationScheduleDataSource extends AbstractOperationScheduleDataSource<ResourceOperationSchedule> {
private ResourceComposite resourceComposite;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
index 70f2c18..483f97d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
@@ -1,9 +1,7 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
/**
*
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
index 0e362f0..1f37161 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
@@ -22,13 +22,12 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operatio
import com.smartgwt.client.widgets.Canvas;
import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleListView;
/**
* @author Ian Springer
*/
-public class ResourceOperationScheduleListView extends OperationScheduleListView {
+public class ResourceOperationScheduleListView extends AbstractOperationScheduleListView {
private static final String TITLE = null;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
index af46041..81ebb94 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
@@ -19,7 +19,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.report.operation;
+import java.util.EnumSet;
import java.util.List;
+import java.util.Set;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.Canvas;
@@ -27,11 +29,14 @@ 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.authz.Permission;
import org.rhq.core.domain.resource.Resource;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.OperationHistoryDataSource;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.ResourceOperationHistoryDetailsView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource;
@@ -42,8 +47,27 @@ public class SubsystemOperationHistoryListView extends AbstractOperationHistoryL
public static final ViewName VIEW_ID = new ViewName("RecentOperations", MSG.common_title_recent_operations());
+ private Set<Permission> globalPermissions;
+
public SubsystemOperationHistoryListView(String locatorId) {
super(locatorId, new ResourceOperationHistoryDataSource(), VIEW_ID.getTitle());
+
+ this.globalPermissions = EnumSet.noneOf(Permission.class);
+ loadGlobalPermissions();
+ }
+
+ @Override
+ protected boolean hasControlPermission() {
+ loadGlobalPermissions();
+ return this.globalPermissions.contains(Permission.MANAGE_INVENTORY);
+ }
+
+ private void loadGlobalPermissions() {
+ new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
+ public void onPermissionsLoaded(Set<Permission> permissions) {
+ globalPermissions = permissions;
+ }
+ });
}
@Override
@@ -52,14 +76,14 @@ public class SubsystemOperationHistoryListView extends AbstractOperationHistoryL
for (ListGridField field : fields) {
String fieldName = field.getName();
- if (fieldName.equals(OperationHistoryDataSource.Field.OPERATION_NAME) ||
- fieldName.equals(OperationHistoryDataSource.Field.SUBJECT) ||
- fieldName.equals(OperationHistoryDataSource.Field.STARTED_TIME)) {
+ if (fieldName.equals(AbstractOperationHistoryDataSource.Field.OPERATION_NAME) ||
+ fieldName.equals(AbstractOperationHistoryDataSource.Field.SUBJECT) ||
+ fieldName.equals(AbstractOperationHistoryDataSource.Field.STARTED_TIME)) {
field.setWidth("25%");
}
}
- ListGridField resourceField = new ListGridField(OperationHistoryDataSource.Field.RESOURCE,
+ ListGridField resourceField = new ListGridField(AbstractOperationHistoryDataSource.Field.RESOURCE,
MSG.common_title_resource());
resourceField.setAlign(Alignment.LEFT);
resourceField.setCellAlign(Alignment.LEFT);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
index 5fc3c0d..7a9b1a9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
@@ -45,6 +45,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
/**
* @author Greg Hinkle
+ * @author Ian Springer
*/
public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements OperationGWTService {
@@ -71,6 +72,14 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
}
}
+ public void deleteOperationHistory(int operationHistoryId, boolean deleteEvenIfInProgress) {
+ try {
+ operationManager.deleteOperationHistory(getSessionSubject(), operationHistoryId, deleteEvenIfInProgress);
+ } catch (RuntimeException e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
public void invokeResourceOperation(int resourceId, String operationName, Configuration parameters,
String description, int timeout) throws RuntimeException {
try {
@@ -101,6 +110,15 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
}
}
+ public int scheduleGroupOperation(GroupOperationSchedule groupOperationSchedule) throws RuntimeException {
+ try {
+ return operationManager.scheduleGroupOperation(getSessionSubject(), groupOperationSchedule);
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
public void unscheduleResourceOperation(ResourceOperationSchedule resourceOperationSchedule)
throws RuntimeException {
try {
@@ -112,6 +130,17 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
}
}
+ public void unscheduleGroupOperation(GroupOperationSchedule groupOperationSchedule)
+ throws RuntimeException {
+ try {
+ operationManager.unscheduleGroupOperation(getSessionSubject(), groupOperationSchedule.getJobId()
+ .toString(), groupOperationSchedule.getGroup().getId());
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
/** Find recently completed operations, disambiguate them and return that list.
*
*/
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
index 45f7832..efe8cc4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
@@ -66,6 +66,7 @@ import org.rhq.core.domain.operation.ResourceOperationHistory;
import org.rhq.core.domain.operation.ResourceOperationScheduleEntity;
import org.rhq.core.domain.operation.ScheduleJobId;
import org.rhq.core.domain.operation.bean.GroupOperationSchedule;
+import org.rhq.core.domain.operation.bean.OperationSchedule;
import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
import org.rhq.core.domain.operation.composite.GroupOperationLastCompletedComposite;
import org.rhq.core.domain.operation.composite.GroupOperationScheduleComposite;
@@ -179,6 +180,30 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
}
}
+ public int scheduleGroupOperation(Subject subject, GroupOperationSchedule schedule) throws ScheduleException {
+ JobTrigger jobTrigger = schedule.getJobTrigger();
+ Trigger trigger = convertToTrigger(jobTrigger);
+ try {
+ List<Resource> executionOrderResources = schedule.getExecutionOrder();
+ int[] executionOrderResourceIds;
+ if (executionOrderResources == null) {
+ executionOrderResourceIds = null;
+ } else {
+ executionOrderResourceIds = new int[executionOrderResources.size()];
+ for (int i = 0, executionOrderResourcesSize = executionOrderResources.size(); i < executionOrderResourcesSize; i++) {
+ Resource executionOrderResource = executionOrderResources.get(i);
+ executionOrderResourceIds[i] = executionOrderResource.getId();
+ }
+ }
+ GroupOperationSchedule groupOperationSchedule = scheduleGroupOperation(subject, schedule
+ .getGroup().getId(), executionOrderResourceIds, schedule.getHaltOnFailure(),
+ schedule.getOperationName(), schedule.getParameters(), trigger, schedule.getDescription());
+ return groupOperationSchedule.getId();
+ } catch (SchedulerException e) {
+ throw new ScheduleException(e);
+ }
+ }
+
public ResourceOperationSchedule scheduleResourceOperation(Subject subject, int resourceId, String operationName,
Configuration parameters, Trigger trigger, String notes) throws SchedulerException {
Resource resource = getResourceIfAuthorized(subject, resourceId);
@@ -557,7 +582,10 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
}
}
+ Integer entityId = getOperationScheduleEntityId(jobDetail);
+
GroupOperationSchedule sched = new GroupOperationSchedule();
+ sched.setId(entityId);
sched.setJobName(jobDetail.getName());
sched.setJobGroup(jobDetail.getGroup());
sched.setGroup(group);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java
index a48a385..846b54d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java
@@ -74,6 +74,17 @@ public interface OperationManagerLocal {
int scheduleResourceOperation(Subject subject, ResourceOperationSchedule schedule);
/**
+ * Schedules a Resource group operation for execution.
+ *
+ * @param subject the user who is asking to schedule the job
+ * @param schedule the information describing the operation to be scheduled along with the schedule to be used
+ *
+ * @return the id of the {@link org.rhq.core.domain.operation.GroupOperationScheduleEntity} created to track the
+ * scheduled operation
+ */
+ int scheduleGroupOperation(Subject subject, GroupOperationSchedule schedule) throws ScheduleException;
+
+ /**
* Schedules an operation for execution on the given resource.
*
* @param subject the user who is asking to schedule the job
13 years, 3 months
[rhq] Branch 'release-3.0.0-test-build' - 2 commits - pom.xml
by Simeon Pinder
pom.xml | 1 +
1 file changed, 1 insertion(+)
New commits:
commit 6f54c915ef7499d989af977d3e167b080788b2e2
Merge: 4efbdc8... 1d1ffc0...
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Jan 26 16:36:57 2011 -0500
Merge branch 'release-3.0.0-test-build' of ssh://spinder@git.fedorahosted.org/git/rhq/rhq into release-3.0.0-test-build
commit 4efbdc827922f2501030c264a4c42ff90523363e
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Jan 26 16:24:50 2011 -0500
activating brew-generate-build-number profile on presence and value of mead property.
diff --git a/pom.xml b/pom.xml
index 46ae63b..15dc32f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1139,6 +1139,7 @@ version is changed the versions of each of these should be validated and updated
<activation>
<property>
<name>brew</name>
+ <value>true</value>
</property>
</activation>
<build>
13 years, 3 months
[rhq] Branch 'release-3.0.0' - pom.xml
by Simeon Pinder
pom.xml | 1 +
1 file changed, 1 insertion(+)
New commits:
commit 4efbdc827922f2501030c264a4c42ff90523363e
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Jan 26 16:24:50 2011 -0500
activating brew-generate-build-number profile on presence and value of mead property.
diff --git a/pom.xml b/pom.xml
index 46ae63b..15dc32f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1139,6 +1139,7 @@ version is changed the versions of each of these should be validated and updated
<activation>
<property>
<name>brew</name>
+ <value>true</value>
</property>
</activation>
<build>
13 years, 3 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java | 4 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java | 15 ----------
2 files changed, 3 insertions(+), 16 deletions(-)
New commits:
commit 4b9236698335f78b081e313040c725d459a9d06d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jan 26 16:18:30 2011 -0500
Fix LogOut menu option to have non-localized html id. Remove related
selenium utility that assigned potentially localized ids for Hyperlink
widgets.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
index 1b3bc8c..2c9e761 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
@@ -52,6 +52,7 @@ public class MenuBarView extends LocatableVLayout {
public static final ViewName[] SECTIONS = { DashboardsView.VIEW_ID, InventoryView.VIEW_ID, ReportTopView.VIEW_ID,
BundleTopView.VIEW_ID, AdministrationView.VIEW_ID, HelpView.VIEW_ID };
+ public static final ViewName LOGOUT_VIEW_ID = new ViewName("LogOut", MSG.view_menuBar_logout());
private String currentlySelectedSection = DashboardsView.VIEW_ID.getName();
private LocatableLabel userLabel;
@@ -160,7 +161,8 @@ public class MenuBarView extends LocatableVLayout {
lineLabel.setWidth("10px");
lineLabel.setAlign(Alignment.CENTER);
- Hyperlink logoutLink = SeleniumUtility.setHtmlId(new Hyperlink(MSG.view_menuBar_logout(), "LogOut"));
+ Hyperlink logoutLink = SeleniumUtility.setHtmlId(new Hyperlink(LOGOUT_VIEW_ID.getTitle(), LOGOUT_VIEW_ID
+ .getName()), LOGOUT_VIEW_ID.getName());
logoutLink.setWidth("50px");
layout.addMember(userLabel);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
index 43893a6..60291bc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
@@ -1,6 +1,5 @@
package org.rhq.enterprise.gui.coregui.client.util.selenium;
-import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.UIObject;
import com.smartgwt.client.widgets.BaseWidget;
import com.smartgwt.client.widgets.Canvas;
@@ -99,20 +98,6 @@ public class SeleniumUtility {
}
/**
- * A utility for assigning an ID to a gwt Hyperlink. For a smartgwt widget
- * use {@link setId(BaseWidget)}. Any current ID will be overwritten. The algorithm is:
- * <pre>
- * Equivalent to setHtmlId(hyperlink, hyperlink.getText());
- * </pre>
- *
- * @param hyperlink
- * @return the updated hyperlink
- */
- static public <T extends Hyperlink> T setHtmlId(final T hyperlink) {
- return setHtmlId(hyperlink, hyperlink.getText());
- }
-
- /**
* Use only if you are sure the unsafeId is not null or empty, or if DEFAULT_ID is acceptable.
* <pre>
* Equivalent to:
13 years, 3 months
[rhq] Branch 'cli-alert-notifs' - 44 commits - modules/common modules/core modules/enterprise modules/plugins
by lkrejci
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java | 14
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml | 2
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 4
modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageVersion.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java | 11
modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java | 21
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java | 36
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java | 24
modules/core/domain/src/main/java/org/rhq/core/domain/util/DisambiguationReportRenderer.java | 683 ++++++++++
modules/core/domain/src/main/java/org/rhq/core/domain/util/OSGiVersionComparator.java | 94 +
modules/core/domain/src/test/java/org/rhq/core/domain/util/DisambiguationReportRendererTest.java | 184 ++
modules/core/domain/src/test/java/org/rhq/core/domain/util/OSGiVersionComparatorTest.java | 82 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java | 2
modules/core/util/src/main/java/org/rhq/core/util/OSGiVersionComparator.java | 94 -
modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentProperties.java | 20
modules/core/util/src/test/java/org/rhq/core/util/OSGiVersionComparatorTest.java | 80 -
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java | 32
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java | 30
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ListOrderChangedEvent.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ListOrderChangedHandler.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ReorderableList.java | 177 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java | 24
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceBossGWTService.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java | 24
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java | 284 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java | 284 ----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java | 79 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java | 54
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java | 105 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java | 107 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java | 54
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java | 41
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java | 542 +++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/GwtTuple.java | 83 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java | 11
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 4
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/recentlyApproved/ViewAction.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java | 13
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java | 70 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java | 23
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationValidationException.java | 49
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java | 12
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 16
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java | 53
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java | 48
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/ResourceOperationJob.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSender.java | 18
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderValidationResults.java | 46
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderPackageDetailsKey.java | 11
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceBossBean.java | 19
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 36
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java | 10
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java | 47
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java | 30
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/support/SupportManagerBean.java | 6
modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliComponent.java | 195 ++
modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliSender.java | 49
modules/enterprise/server/plugins/alert-cli/src/main/resources/META-INF/rhq-serverplugin.xml | 38
modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java | 123 +
modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java | 148 ++
modules/plugins/ant-bundle/src/test/resources/test-bundle-no-manage-root-dir.xml | 16
104 files changed, 3595 insertions(+), 1150 deletions(-)
New commits:
commit 7fcb68a9781b9119705cd994683fa54b871ccbd5
Merge: 8e5793c... bb15343...
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Jan 26 18:54:20 2011 +0100
Merge remote branch 'origin/master' into cli-alert-notifs
commit 8e5793cffc1fb68049a0065aaad9d9e19cbd6529
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Jan 26 18:53:37 2011 +0100
starting to implement the CLI alert plugin controls to support re-enabling of corrupted alerts after user deletion.
Note that there already is a hook for the in the form of AlertNotificationManagerLocal.cleanse* methods but I'm not sure
what state they leave the notifications in (not to mention that the cleanse methods are a hack).
diff --git a/modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliComponent.java b/modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliComponent.java
new file mode 100644
index 0000000..584d8cd
--- /dev/null
+++ b/modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliComponent.java
@@ -0,0 +1,195 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.server.plugins.alertCli;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.alert.notification.AlertNotification;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+import org.rhq.core.domain.resource.composite.DisambiguationReport;
+import org.rhq.core.domain.util.DisambiguationReportRenderer;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.util.IntExtractor;
+import org.rhq.enterprise.server.alert.AlertDefinitionManagerLocal;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.plugin.pc.ControlFacet;
+import org.rhq.enterprise.server.plugin.pc.ControlResults;
+import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
+import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.resource.disambiguation.DefaultDisambiguationUpdateStrategies;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * The plugin component for controlling the CLI alerts.
+ *
+ * @author Lukas Krejci
+ */
+public class CliComponent implements ServerPluginComponent, ControlFacet {
+
+ private static final String CONTROL_CHECK_ALERTS_VALIDITY = "checkAlertsValidity";
+ private static final String CONTROL_REASSIGN_ALERTS = "reassignAlerts";
+
+ private static final String PROP_PACKAGE_TYPES = "packageTypes";
+ private static final String PROP_ALERT_DEFINITION_NAME = "alertDefinitionName";
+ private static final String PROP_RESOURCE_PATH = "resourcePath";
+ private static final String PROP_RESOURCE_ID = "resourceId";
+ private static final String PROP_MISCONFIGURED_ALERT_DEFS = "misconfiguredAlertDefs";
+ private static final String PROP_ALERT_DEFINITION = "alertDefinition";
+
+ private Set<String> scriptPackageTypes;
+ private String pluginName;
+
+ public void initialize(ServerPluginContext context) throws Exception {
+ scriptPackageTypes = new HashSet<String>();
+ pluginName = context.getPluginEnvironment().getPluginDescriptor().getName();
+ PropertyList packageTypesList = context.getPluginConfiguration().getList(PROP_PACKAGE_TYPES);
+ for(Property p : packageTypesList.getList()) {
+ PropertySimple value = (PropertySimple) p;
+
+ scriptPackageTypes.add(value.getStringValue());
+ }
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public void shutdown() {
+ }
+
+ public ControlResults invoke(String name, Configuration parameters) {
+ ControlResults results = new ControlResults();
+
+ try {
+ if (CONTROL_CHECK_ALERTS_VALIDITY.equals(name)) {
+ checkAlertsValidity(results, parameters);
+ } else if (CONTROL_REASSIGN_ALERTS.equals(name)) {
+ reassignAlerts(results, parameters);
+ }
+ } catch (Exception e) {
+ results.setError(e);
+ }
+
+ return results;
+ }
+
+ private void checkAlertsValidity(ControlResults results, Configuration parameters) {
+ AlertDefinitionManagerLocal manager = LookupUtil.getAlertDefinitionManager();
+ SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
+
+ Subject overlord = subjectManager.getOverlord();
+
+ AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
+ criteria.addFilterNotificationNames(pluginName);
+ criteria.setPageControl(PageControl.getUnlimitedInstance());
+
+ List<AlertDefinition> defs = manager.findAlertDefinitionsByCriteria(overlord, criteria);
+
+ for(AlertDefinition def : defs) {
+ List<AlertNotification> notifications = def.getAlertNotifications();
+
+ AlertNotification cliNotification = getCliNotification(notifications);
+
+ if (cliNotification == null) {
+ //we alway should find this but a little bit of paranoia never hurt anyone
+ continue;
+ }
+
+ PropertySimple subjectIdProperty = cliNotification.getConfiguration().getSimple(CliSender.PROP_USER_ID);
+ if (subjectIdProperty == null) {
+ continue;
+ }
+
+ int subjectId = subjectIdProperty.getIntegerValue();
+
+ Subject checkSubject = subjectManager.getSubjectById(subjectId);
+
+ if (checkSubject == null) {
+ //TODO this is the invalid user we're after.. let's store the info about the alert
+ Configuration resConfig = results.getComplexResults();
+
+ PropertyList misconfigured = resConfig.getList(PROP_MISCONFIGURED_ALERT_DEFS);
+ if (misconfigured == null) {
+ misconfigured = new PropertyList(PROP_MISCONFIGURED_ALERT_DEFS);
+ resConfig.put(misconfigured);
+ }
+
+ PropertyMap alertDefinitionMap = new PropertyMap(PROP_ALERT_DEFINITION);
+
+ alertDefinitionMap.put(new PropertySimple(PROP_ALERT_DEFINITION_NAME, def.getName()));
+ alertDefinitionMap.put(new PropertySimple(PROP_RESOURCE_ID, def.getResource().getId()));
+
+ misconfigured.add(alertDefinitionMap);
+ }
+ }
+
+ //ok, now we have to obtain the resource paths. doing it out of the above loop reduces the number
+ //of server roundtrips
+ ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
+ PropertyList misconfigured = results.getComplexResults().getList(PROP_MISCONFIGURED_ALERT_DEFS);
+ if (misconfigured != null) {
+ List<DisambiguationReport<Property>> disambiguated = resourceManager.disambiguate(misconfigured.getList(),
+ new IntExtractor<Property>() {
+ public int extract(Property object) {
+ PropertyMap map = (PropertyMap) object;
+ return map.getSimple(PROP_RESOURCE_ID).getIntegerValue();
+ };
+ },
+ DefaultDisambiguationUpdateStrategies.getDefault());
+
+ DisambiguationReportRenderer renderer = new DisambiguationReportRenderer();
+
+ for(DisambiguationReport<Property> r : disambiguated) {
+ PropertyMap map = (PropertyMap) r.getOriginal();
+
+ String resourcePath = renderer.render(r);
+
+ map.put(new PropertySimple(PROP_RESOURCE_PATH, resourcePath));
+ }
+ }
+
+ }
+
+ private void reassignAlerts(ControlResults results, Configuration parameters) {
+ //TODO implement
+ }
+
+ AlertNotification getCliNotification(List<AlertNotification> notifications) {
+ for(AlertNotification n : notifications) {
+ if (pluginName.equals(n.getSenderName())) {
+ return n;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/modules/enterprise/server/plugins/alert-cli/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/alert-cli/src/main/resources/META-INF/rhq-serverplugin.xml
index 6408c88..cb3ed60 100644
--- a/modules/enterprise/server/plugins/alert-cli/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/alert-cli/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -14,6 +14,43 @@
Used to execute a CLI script.
</serverplugin:help>
+ <serverplugin:plugin-component class="CliComponent">
+ <serverplugin:control name="checkAlertsValidity">
+ <serverplugin:results>
+ <c:list-property name="misconfiguredAlertDefs" displayName="Misconfigured Alert Definitions">
+ <c:description>
+ Alert scripts run authenticated as a user specified in their definitions. If a user is deleted,
+ the alert definition will contain invalid reference to that user and needs to be update manually.
+ This operation returns a list of such misconfigured alert definitions.
+ </c:description>
+ <c:map-property name="alertDefinition">
+ <c:simple-property name="resourceId" />
+ <c:simple-property name="resourcePath" />
+ <c:simple-property name="alertDefinitionName" />
+ </c:map-property>
+ </c:list-property>
+ </serverplugin:results>
+ </serverplugin:control>
+
+ <!-- TODO define the args and results of this operation -->
+ <serverplugin:control name="reassignAlerts" description="Re-assign alerts to run as different users" />
+ </serverplugin:plugin-component>
+
+ <serverplugin:plugin-configuration>
+ <c:simple-property name="uploadRepoName" displayName="Repo to manually upload scripts to" required="true" default="Uploaded Scripts">
+ <c:description>
+ When manually uploading a script while defining an alert notification, the script will be stored in this repo.
+ </c:description>
+ </c:simple-property>
+ <c:list-property name="packageTypes" displayName="Package Types" required="true">
+ <c:description>
+ The list of package types that will be considered scripts. Any package of those types in any repo will be
+ considered a script and will be available for choosing as an alert script.
+ </c:description>
+ <c:simple-property name="packageType" displayName="Package Type" type="string" required="true"/>
+ </c:list-property>
+ </serverplugin:plugin-configuration>
+
<!-- How does this sender show up in drop downs etc -->
<short-name>CLI Script</short-name>
commit 55a3aaaae7364761f895fe4e261660cb6f1be427
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Jan 26 18:51:16 2011 +0100
Adding support for finalization and validation of the alert parameters and extra parameters by the alert senders.
The default impl does nothing but the facility will be used by the CliSender to actually validate the user credentials
provided by the GUI and store just a userId in the configuration stored in the DB.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
index c5507cb..5537c48 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
@@ -78,6 +78,7 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
private AuthorizationManagerLocal authorizationManager;
@EJB
private AlertDefinitionManagerLocal alertDefinitionManager;
+
@EJB
@IgnoreDependency
private AlertManagerLocal alertManager;
@@ -85,6 +86,10 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
@EJB
private StatusManagerLocal agentStatusManager;
+ @EJB
+ @IgnoreDependency
+ private AlertNotificationManagerLocal alertNotificationManager;
+
private boolean checkViewPermission(Subject subject, AlertDefinition alertDefinition) {
if (alertDefinition.getResourceType() != null) { // an alert template
return authorizationManager.hasGlobalPermission(subject, Permission.MANAGE_SETTINGS);
@@ -530,6 +535,7 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
}
fixRecoveryId(oldAlertDefinition);
+
AlertDefinition newAlertDefinition = entityManager.merge(oldAlertDefinition);
if (isResourceLevel
@@ -611,9 +617,9 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
+ "' is a trending metric, and thus will never have baselines calculated for it.");
}
}
- }
-
- return;
+ }
+
+ alertNotificationManager.finalizeNotifications(alertDefinition.getAlertNotifications());
}
private void notifyAlertConditionCacheManager(Subject subject, String methodName, AlertDefinition alertDefinition,
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
index 1a1ae19..030b586 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
@@ -20,8 +20,10 @@ package org.rhq.enterprise.server.alert;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.ejb.EJB;
@@ -40,13 +42,20 @@ import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertDefinitionContext;
import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.configuration.AbstractPropertyMap;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.plugin.PluginKey;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.plugin.ServerPluginsLocal;
+import org.rhq.enterprise.server.plugin.pc.alert.AlertSender;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderInfo;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager;
+import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderValidationResults;
import org.rhq.enterprise.server.plugin.pc.alert.CustomAlertSenderBackingBean;
import org.rhq.enterprise.server.xmlschema.generated.serverplugin.alert.AlertPluginDescriptorType;
@@ -296,6 +305,26 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
return notification;
}
+ public boolean finalizeNotifications(List<AlertNotification> notifications) {
+ boolean hasErrors = false;
+
+ AlertSenderPluginManager pluginManager = alertManager.getAlertPluginManager();
+
+ for(AlertNotification notification : notifications) {
+ AlertSender<?> sender = pluginManager.getAlertSenderForNotification(notification);
+
+ AlertSenderValidationResults validation = sender.validateAndFinalizeConfiguration();
+
+ notification.setConfiguration(validation.getAlertParameters());
+ notification.setExtraConfiguration(validation.getExtraParameters());
+
+ hasErrors = hasErrors || hasErrors(validation.getAlertParameters()) ||
+ hasErrors(validation.getExtraParameters());
+ }
+
+ return hasErrors;
+ }
+
public int cleanseAlertNotificationBySubject(int subjectId) {
return cleanseParmaeterValueForAlertSender("System Users", "subjectId", String.valueOf(subjectId));
}
@@ -313,4 +342,45 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
return affectedRows;
}
+ private boolean hasErrors(AbstractPropertyMap configuration) {
+ if (configuration instanceof PropertyMap) {
+ if (((PropertyMap)configuration).getErrorMessage() != null) {
+ return true;
+ }
+ }
+
+ for(Map.Entry<String, Property> entry : configuration.getMap().entrySet()) {
+ if (hasErrors(entry.getValue())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private boolean hasErrors(PropertyList list) {
+ if (list.getErrorMessage() != null) {
+ return true;
+ }
+
+ for(Property p : list.getList()) {
+ if (hasErrors(p)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private boolean hasErrors(Property property) {
+ if (property instanceof PropertySimple) {
+ return property.getErrorMessage() != null;
+ } else if (property instanceof PropertyList) {
+ return hasErrors((PropertyList) property);
+ } else if (property instanceof PropertyMap) {
+ return hasErrors((AbstractPropertyMap)property);
+ } else {
+ return false;
+ }
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
index 8a137e0..ff222fc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
@@ -31,8 +31,8 @@ import org.rhq.enterprise.server.plugin.pc.alert.CustomAlertSenderBackingBean;
/**
* @author Joseph Marques
+ * @author Lukas Krejci
*/
-
@Local
public interface AlertNotificationManagerLocal {
@@ -42,15 +42,17 @@ public interface AlertNotificationManagerLocal {
* @param alertDefinitionId Id of the alert definition
* @param senderName shortName of the {@link AlertSender}
* @param configuration Properties for this alert sender.
+ * @throws AlertNotificationValidationException if the alert sender of the notification failed to finalize and validate the provided notification's configuration
*/
- AlertNotification addAlertNotification(Subject user, int alertDefinitionId, AlertNotification notification);
+ AlertNotification addAlertNotification(Subject user, int alertDefinitionId, AlertNotification notification) throws AlertDefinitionUpdateException, AlertNotificationValidationException;
/**
* Persist changes to the passed {@link AlertNotification}
*
* @param notification
+ * @throws AlertNotificationValidationException if the alert sender of the notification failed to finalize and validate the notification's configuration
*/
- void updateAlertNotification(Subject subject, int alertDefinitionId, AlertNotification notification);
+ void updateAlertNotification(Subject subject, int alertDefinitionId, AlertNotification notification) throws AlertDefinitionUpdateException, AlertNotificationValidationException;
/**
* Remove the passed notifications from the passed alert definition (all identified by their id)
@@ -61,6 +63,21 @@ public interface AlertNotificationManagerLocal {
*/
int removeNotifications(Subject subject, Integer alertDefinitionId, Integer[] notificationIds);
+ /**
+ * This method calls out to the alert senders responsible to individual notifications and ask
+ * them to finalize and validate the notifications before they are processed further.
+ * This gives the alert senders the chance to transform their configurations from what's being
+ * input by the user to what needs to be persisted and to perform validation of the configurations.
+ * <p>
+ * The notifications can be modified during this call. New properties can be added to their configurations, etc.
+ *
+ * @param notifications the notifications to process
+ * @return true if everything went ok, false if the validation fails. In this case one or more properties
+ * in the configuration or extra configuration of one or more of the notifications contains an error message
+ * describing the error.
+ */
+ boolean finalizeNotifications(List<AlertNotification> notifications);
+
int purgeOrphanedAlertNotifications();
/**
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationValidationException.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationValidationException.java
new file mode 100644
index 0000000..636c45f
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationValidationException.java
@@ -0,0 +1,49 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.server.alert;
+
+
+/**
+ * Thrown when alert definition notifications validation fails during creation or update of
+ * alert definition.
+ *
+ * @author Lukas Krejci
+ */
+public class AlertNotificationValidationException extends AlertDefinitionException {
+
+ private static final long serialVersionUID = 1L;
+
+ public AlertNotificationValidationException() {
+ super();
+ }
+
+ public AlertNotificationValidationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public AlertNotificationValidationException(String message) {
+ super(message);
+ }
+
+ public AlertNotificationValidationException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java
index 76c196c..d8ce44e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertTemplateManagerBean.java
@@ -232,7 +232,7 @@ public class AlertTemplateManagerBean implements AlertTemplateManagerLocal {
@RequiredPermission(Permission.MANAGE_SETTINGS)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public AlertDefinition updateAlertTemplate(Subject user, AlertDefinition alertTemplate, boolean purgeInternals)
- throws InvalidAlertDefinitionException, AlertDefinitionUpdateException {
+ throws InvalidAlertDefinitionException, AlertDefinitionUpdateException, AlertNotificationValidationException {
if (LOG.isDebugEnabled()) {
LOG.debug("updateAlertTemplate: " + alertTemplate);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSender.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSender.java
index de35d54..f204106 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSender.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSender.java
@@ -29,6 +29,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.enterprise.server.plugin.pc.ControlResults;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment;
@@ -99,6 +100,23 @@ public abstract class AlertSender<T extends ServerPluginComponent> {
return builder.toString();
}
+ /**
+ * Validates the alert and extra parameters. The results should be initialized with the current
+ * parameters of this alert sender and the erroneous properties should have their
+ * {@link Property#getErrorMessage() error messages} set.
+ * <p>
+ * The implementation is free to change (add/update/delete) properties in either of the configurations
+ * (i.e. finalize them). This is to support scenarios where the user inputs values that need to be
+ * further processed in an alert sender specific way before they get stored into the database.
+ * <p>
+ * The default implementation makes no changes to the configurations.
+ *
+ * @return the validation results
+ */
+ public AlertSenderValidationResults validateAndFinalizeConfiguration() {
+ return new AlertSenderValidationResults(alertParameters, extraParameters);
+ }
+
private String printProperty(Property property) {
if (property instanceof PropertySimple) {
return ((PropertySimple) property).getStringValue();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderValidationResults.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderValidationResults.java
new file mode 100644
index 0000000..f235835
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/AlertSenderValidationResults.java
@@ -0,0 +1,46 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.server.plugin.pc.alert;
+
+import org.rhq.core.domain.configuration.Configuration;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+public class AlertSenderValidationResults {
+
+ private Configuration alertParameters;
+ private Configuration extraParameters;
+
+ public AlertSenderValidationResults(Configuration alertParameters, Configuration extraParameters) {
+ this.alertParameters = alertParameters == null ? null : alertParameters.deepCopy();
+ this.extraParameters = extraParameters == null ? null : extraParameters.deepCopy();
+ }
+
+ public Configuration getAlertParameters() {
+ return alertParameters;
+ }
+
+ public Configuration getExtraParameters() {
+ return extraParameters;
+ }
+}
commit 54200aea1f94cdb2af93d5792006c3e9dfadb13d
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Jan 26 18:47:03 2011 +0100
exposing slightly more data from the disambiguation report by exposing the full "resource" (i.e. id, name and type) also for the resource representing the "original".
This enables us to provide a generic disambiguated path renderer which is also included in this commit.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
index 717721b..dd8e6ad 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
@@ -35,8 +35,7 @@ public class DisambiguationReport<T> implements Serializable {
private T original;
private List<Resource> parents;
- private ResourceType resourceType;
- private String name;
+ private Resource resource;
public static class ResourceType implements Serializable {
@@ -124,18 +123,21 @@ public class DisambiguationReport<T> implements Serializable {
}
}
- public DisambiguationReport() {
+ //GWT needs this
+ protected DisambiguationReport() {
}
- public DisambiguationReport(T original, List<Resource> parents, ResourceType resourceType, String name) {
+ public DisambiguationReport(T original, List<Resource> parents, Resource resource) {
this.original = original;
// this.parents = Collections.unmodifiableList(parents);
//spinder: the returned type is not Serializable and causes GWT serialization errors.
this.parents = parents;
- this.resourceType = resourceType;
- this.name = name;
+ this.resource = resource;
}
+ /**
+ * @return an object from the original result list that this disambiguation report represents.
+ */
public T getOriginal() {
return original;
}
@@ -149,23 +151,37 @@ public class DisambiguationReport<T> implements Serializable {
}
/**
+ * @return the resource that the {@link #getOriginal() original} represents.
+ */
+ public Resource getResource() {
+ return resource;
+ }
+
+ /**
* @return the ResourceType of the resource represented by the {@link #getOriginal()}
* or null if type disambiguation isn't needed.
+ *
+ * @deprecated use {@link #getResource()}.{@link Resource#getType() getType()}
*/
+ @Deprecated
public ResourceType getResourceType() {
- return resourceType;
+ return resource.getType();
}
/**
*
* @return the Resource name
+ *
+ * @deprecated use {@link #getResource()}.{@link Resource#getName() getName()}
*/
+ @Deprecated
public String getName() {
- return name;
+ return resource.getName();
}
public String toString() {
- return "DisambiguationReport(type=" + resourceType + ", parents=" + parents + ", original=" + original
- + ", name=" + name + ")";
+ return "DisambiguationReport(resource=" + resource + ", parents=" + parents + ", original=" + original
+ + ")";
}
+
}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/DisambiguationReportRenderer.java b/modules/core/domain/src/main/java/org/rhq/core/domain/util/DisambiguationReportRenderer.java
new file mode 100644
index 0000000..c110f4b
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/DisambiguationReportRenderer.java
@@ -0,0 +1,683 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.domain.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.rhq.core.domain.resource.composite.DisambiguationReport;
+import org.rhq.core.domain.resource.composite.DisambiguationReport.Resource;
+import org.rhq.core.domain.resource.composite.DisambiguationReport.ResourceType;
+
+/**
+ * This class can be used to produce a "pretty" textual representation of a {@link DisambiguationReport}.
+ * It supports a simple templating mechanism to configure the representation's format.
+ * <p>
+ * In the {@link DisambiguationReport}, a resource (either the resource being disambiguated or one of its parents)
+ * is represented by an instance of {@link DisambiguationReport.Resource}. The template uses this instance and its
+ * properties:
+ * <ul>
+ * <li>id - the resource id
+ * <li>name - the name of the resource
+ * <li>type - the type of the resource
+ * <ul>
+ * <li>name - the name of the resource type
+ * <li>plugin - the name of the plugin defining the resource type
+ * <li>singleton - a boolean whether the resource type is a singleton type or not
+ * </ul>
+ * </li>
+ * </ul>
+ * <p>
+ * The template has the following format:<br/>
+ * <code>...text...%([..text...])?<identifier>([...text...])?...text...</code>
+ * <p>
+ * It is best explained by an example. The {@link #DEFAULT_SEGMENT_TEMPLATE default segment template} looks like this:<br/>
+ * <code>%type.name[ ]%[(]type.plugin[) ]%name</code>
+ * <p>
+ * The <code>%type.name[ ]</code> is rendered as the name of the resource type followed by a space <b>IF</b> the
+ * resource type and the name are not null. If either of them is null <code>%type.name[ ]</code> renders as an
+ * empty string.
+ * <p>
+ * <code>%[(]type.plugin[) ]</code> renders as a bracket followed by the name of the plugin followed by a bracket and
+ * a space if both resource type and plugin are not null. If either of them is null, again the whole <code>%...</code> is
+ * rendered as an empty string.
+ * <p>
+ * The escape character is \.
+ *
+ * @author Lukas Krejci
+ */
+public class DisambiguationReportRenderer {
+
+ public enum RenderingOrder {
+ ASCENDING, DESCENDING
+ }
+
+ public static final String DEFAULT_SEGMENT_TEMPLATE = "%type.name[ ]%[(]type.plugin[) ]%name";
+ public static final String DEFALUT_SEGMENT_SEPARATOR = " > ";
+
+ private boolean includeResource = true;
+ private boolean includeParents = true;
+ private RenderingOrder renderingOrder = RenderingOrder.ASCENDING;
+ private String segmentTemplate = DEFAULT_SEGMENT_TEMPLATE;
+ private String singletonSegmentTemplate = DEFAULT_SEGMENT_TEMPLATE;
+ private String segmentSeparator = DEFALUT_SEGMENT_SEPARATOR;
+ private List<Segment> parsedTemplate = null;
+ private List<Segment> parsedSingletonTemplate = null;
+
+ /*
+ * The Field, ResourceField and ResourceTypeField constructs are here to
+ * prevent the usage of java reflection. This class is exposed (and probably
+ * used) in the GWT javascript user interface which does not support reflection.
+ *
+ * The below 3 classes are therefore here to mimic what we'd need from reflection
+ * at the cost of lost flexibility and additional verbosity.
+ *
+ * If the DisambiguationReport.Resource or DisambiguationReport.ResourceType classes
+ * change, the below enums will have to accomodate for that change. If we could use
+ * reflection, it would work generically..
+ */
+
+ private interface Field {
+ Object getValue(Object object);
+
+ Field getRepresentation();
+
+ Field getSiblingField(String name);
+ }
+
+ private enum ResourceField implements Field {
+ ANY("") {
+ public Object getValue(Object object) {
+ return null;
+ }
+
+ public Field getRepresentation() {
+ return null;
+ }
+ },
+ ID("id") {
+ public Object getValue(Object object) {
+ return ((Resource)object).getId();
+ }
+
+ public Field getRepresentation() {
+ return null;
+ }
+ },
+ NAME("name") {
+ public Object getValue(Object object) {
+ return ((Resource)object).getName();
+ }
+
+ public Field getRepresentation() {
+ return null;
+ }
+
+ },
+ TYPE("type") {
+ public Object getValue(Object object) {
+ return ((Resource)object).getType();
+ }
+
+ public Field getRepresentation() {
+ return ResourceTypeField.ANY;
+ }
+ };
+
+ private String name;
+
+ private ResourceField(String name) {
+ this.name = name;
+ }
+
+ public Field getSiblingField(String name) {
+ return getByName(name);
+ }
+
+ public static ResourceField getByName(String name) {
+ for(ResourceField f : ResourceField.values()) {
+ if (f.name.equals(name)) {
+ return f;
+ }
+ }
+
+ return null;
+ }
+ }
+
+ private enum ResourceTypeField implements Field {
+ ANY("") {
+ public Field getRepresentation() {
+ return null;
+ }
+
+ public Object getValue(Object object) {
+ return null;
+ }
+ },
+ NAME("name") {
+ public Field getRepresentation() {
+ return null;
+ }
+
+ public Object getValue(Object object) {
+ return ((ResourceType)object).getName();
+ }
+ },
+ PLUGIN("plugin") {
+ public Field getRepresentation() {
+ return null;
+ }
+
+ public Object getValue(Object object) {
+ return ((ResourceType)object).getPlugin();
+ }
+ },
+ SINGLETON("singleton") {
+ public Field getRepresentation() {
+ return null;
+ }
+
+ public Object getValue(Object object) {
+ return ((ResourceType)object).isSingleton();
+ }
+ };
+
+ private String name;
+
+ private ResourceTypeField(String name) {
+ this.name = name;
+ }
+
+ public Field getSiblingField(String name) {
+ return getByName(name);
+ }
+
+ public static ResourceTypeField getByName(String name) {
+ for(ResourceTypeField f : ResourceTypeField.values()) {
+ if (f.name.equals(name)) {
+ return f;
+ }
+ }
+
+ return null;
+ }
+ }
+
+ /**
+ * Segment represents a part of the template with some semantics.
+ * A segment is able to render itself using data from a resource.
+ *
+ * @author Lukas Krejci
+ */
+ private interface Segment {
+ void render(DisambiguationReport.Resource resource, StringBuilder bld);
+
+ /**
+ * Each segment holds an internal string builder to build up the data
+ * from the template it will later need to render itself.
+ *
+ * @return the internal string builder.
+ */
+ StringBuilder getCurrentString();
+ }
+
+ private static class TextSegment implements Segment {
+ public StringBuilder text = new StringBuilder();
+
+ public void render(DisambiguationReport.Resource resource, StringBuilder bld) {
+ if (text != null) {
+ bld.append(text);
+ }
+ }
+
+ public StringBuilder getCurrentString() {
+ return text;
+ }
+ }
+ private static class ResourceSegment implements Segment {
+ public String prefix;
+ public List<Field> fields = new ArrayList<Field>();
+ public String suffix;
+
+ public StringBuilder currentString = new StringBuilder();
+ public Field currentField = ResourceField.ANY;
+
+ public StringBuilder getCurrentString() {
+ return currentString;
+ }
+
+ public void render(DisambiguationReport.Resource resource, StringBuilder bld) {
+ String value = null;
+ if (fields != null && fields.size() > 0) {
+ Object object = resource;
+ for(Field f : fields) {
+ if (object == null) {
+ break;
+ }
+ object = f.getValue(object);
+ }
+
+ if (object != null) {
+ value = object.toString();
+ }
+ }
+
+ if (value != null) {
+ if (prefix != null) {
+ bld.append(prefix);
+ }
+
+ bld.append(value.toString());
+
+ if (suffix != null) {
+ bld.append(suffix);
+ }
+ }
+ }
+ }
+
+ private static class SegmentAndState {
+ public Segment segment;
+ public ParserState state;
+ public ParserState lastState;
+ }
+
+ /**
+ * The guts of the template parser. Each state can process a single character and modify the state for the next
+ * char.
+ */
+ private enum ParserState {
+ START {
+ public SegmentAndState process(SegmentAndState seg, Character c) {
+ if (c == null) {
+ return null;
+ }
+
+ seg.lastState = null;
+
+ switch(c) {
+ case '%':
+ seg.segment = new ResourceSegment();
+ seg.state = ParserState.IN_RESOURCE_START;
+ break;
+ case '\\':
+ seg.segment = new TextSegment();
+ seg.lastState = ParserState.IN_TEXT;
+ seg.state = ParserState.ESCAPING;
+ break;
+ default:
+ seg.segment = new TextSegment();
+ seg.segment.getCurrentString().append(c);
+ seg.state = ParserState.IN_TEXT;
+ break;
+ }
+
+ return seg;
+ }
+ }, IN_TEXT {
+ public SegmentAndState process(SegmentAndState seg, Character c) {
+ if (c == null) {
+ return null;
+ }
+
+ seg.lastState = null;
+
+ switch(c) {
+ case '%':
+ seg.segment = new ResourceSegment();
+ seg.state = ParserState.IN_RESOURCE_START;
+ break;
+ case '\\':
+ seg.lastState = seg.state;
+ seg.state = ParserState.ESCAPING;
+ break;
+ default:
+ seg.segment.getCurrentString().append(c);
+ break;
+ }
+
+ return seg;
+ }
+ }, IN_RESOURCE_START {
+ public SegmentAndState process(SegmentAndState seg, Character c) {
+ if (c == null) {
+ return null;
+ }
+
+ seg.lastState = null;
+
+ switch(c) {
+ case '[':
+ seg.state = ParserState.IN_RESOURCE_PREFIX;
+ break;
+ default:
+ seg.segment.getCurrentString().append(c);
+ seg.state = ParserState.IN_RESOURCE_DEF;
+ break;
+ }
+
+ return seg;
+ }
+ }, IN_RESOURCE_PREFIX {
+ public SegmentAndState process(SegmentAndState seg, Character c) {
+ if (c == null) {
+ return null;
+ }
+
+ seg.lastState = null;
+
+ switch(c) {
+ case '\\':
+ seg.lastState = seg.state;
+ seg.state = ParserState.ESCAPING;
+ break;
+ case ']':
+ ((ResourceSegment)seg.segment).prefix = seg.segment.getCurrentString().toString();
+ ((ResourceSegment)seg.segment).currentString = new StringBuilder();
+ seg.state = ParserState.IN_RESOURCE_DEF;
+ break;
+ default:
+ seg.segment.getCurrentString().append(c);
+ break;
+ }
+
+ return seg;
+ }
+ }, IN_RESOURCE_DEF {
+ public SegmentAndState process(SegmentAndState seg, Character c) {
+ if (c == null) {
+ processField(seg);
+ return null;
+ }
+
+ seg.lastState = null;
+
+ switch(c) {
+ case '\\':
+ seg.lastState = seg.state;
+ seg.state = ParserState.ESCAPING;
+ break;
+ case '.':
+ processField(seg);
+ break;
+ case '%':
+ processField(seg);
+ seg.segment = new ResourceSegment();
+ seg.state = ParserState.IN_RESOURCE_START;
+ break;
+ case '[':
+ processField(seg);
+ seg.state = ParserState.IN_RESOURCE_SUFFIX;
+ break;
+ default:
+ if (isWhitespace(c)) {
+ processField(seg);
+ seg.segment = new TextSegment();
+ seg.segment.getCurrentString().append(c);
+ seg.state = ParserState.IN_TEXT;
+ } else {
+ seg.segment.getCurrentString().append(c);
+ }
+ break;
+ }
+
+ return seg;
+ }
+
+ //this would have been better implemented if we had reflection in GWT.
+ private void processField(SegmentAndState seg) {
+ ResourceSegment s = (ResourceSegment)seg.segment;
+ String fieldName = s.getCurrentString().toString();
+ try {
+ Field field = s.currentField.getSiblingField(fieldName);
+ s.fields.add(field);
+ s.currentField = field.getRepresentation();
+ s.currentString = new StringBuilder();
+ } catch(Exception e) {
+ s.fields = null;
+ seg.state = ParserState.START;
+ }
+ }
+
+ private boolean isWhitespace(char c) {
+ //if we had the Character class in GWT...
+ //return Character.isWhitespace(c)
+
+ return c == ' ' || c == '\n' || c == '\t';
+ }
+ }, IN_RESOURCE_SUFFIX {
+ public SegmentAndState process(SegmentAndState seg, Character c) {
+ if (c == null) {
+ return null;
+ }
+
+ seg.lastState = null;
+
+ switch(c) {
+ case '\\':
+ seg.lastState = seg.state;
+ seg.state = ParserState.ESCAPING;
+ break;
+ case ']':
+ ((ResourceSegment)seg.segment).suffix = seg.segment.getCurrentString().toString();
+ ((ResourceSegment)seg.segment).currentString = new StringBuilder();
+ seg.state = ParserState.START;
+ break;
+ default:
+ seg.segment.getCurrentString().append(c);
+ break;
+ }
+
+ return seg;
+ }
+ }, ESCAPING {
+ public SegmentAndState process(SegmentAndState seg, Character c) {
+ if (c == null) {
+ return null;
+ }
+
+ seg.segment.getCurrentString().append(c);
+ seg.state = seg.lastState;
+ seg.lastState = null;
+
+ return seg;
+ }
+
+ };
+
+ public abstract SegmentAndState process(SegmentAndState currentSegment, Character c);
+ }
+
+ public DisambiguationReportRenderer() {
+ parsedTemplate = parse(segmentTemplate);
+ parsedSingletonTemplate = parse(singletonSegmentTemplate);
+ }
+
+ /**
+ * @return the includeResource
+ */
+ public boolean isIncludeResource() {
+ return includeResource;
+ }
+
+ /**
+ * @param includeResource the includeResource to set
+ */
+ public void setIncludeResource(boolean includeResource) {
+ this.includeResource = includeResource;
+ }
+
+ /**
+ * @return the includeParents
+ */
+ public boolean isIncludeParents() {
+ return includeParents;
+ }
+
+ /**
+ * @param includeParents the includeParents to set
+ */
+ public void setIncludeParents(boolean includeParents) {
+ this.includeParents = includeParents;
+ }
+
+ /**
+ * @return the renderingOrder
+ */
+ public RenderingOrder getRenderingOrder() {
+ return renderingOrder;
+ }
+
+ /**
+ * @param renderingOrder the renderingOrder to set
+ */
+ public void setRenderingOrder(RenderingOrder renderingOrder) {
+ this.renderingOrder = renderingOrder;
+ }
+
+ /**
+ * @return the segmentTemplate
+ */
+ public String getSegmentTemplate() {
+ return segmentTemplate;
+ }
+
+ /**
+ * @param segmentTemplate the segmentTemplate to set
+ */
+ public void setSegmentTemplate(String segmentTemplate) {
+ this.segmentTemplate = segmentTemplate;
+ parsedTemplate = parse(segmentTemplate);
+ }
+
+ /**
+ * @return the singletonSegmentTemplate
+ */
+ public String getSingletonSegmentTemplate() {
+ return singletonSegmentTemplate;
+ }
+
+ /**
+ * @param singletonSegmentTemplate the singletonSegmentTemplate to set
+ */
+ public void setSingletonSegmentTemplate(String singletonSegmentTemplate) {
+ this.singletonSegmentTemplate = singletonSegmentTemplate;
+ parsedSingletonTemplate = parse(singletonSegmentTemplate);
+ }
+
+ /**
+ * @return the segmentSeparator
+ */
+ public String getSegmentSeparator() {
+ return segmentSeparator;
+ }
+
+ /**
+ * @param segmentSeparator the segmentSeparator to set
+ */
+ public void setSegmentSeparator(String segmentSeparator) {
+ this.segmentSeparator = segmentSeparator;
+ }
+
+ public String render(DisambiguationReport<?> report) {
+ if (parsedTemplate != null) {
+ StringBuilder bld = new StringBuilder();
+
+ List<DisambiguationReport.Resource> resources = new ArrayList<DisambiguationReport.Resource>();
+
+ switch(renderingOrder) {
+ case ASCENDING:
+ if (includeResource) {
+ resources.add(report.getResource());
+ }
+ if (includeParents) {
+ resources.addAll(report.getParents());
+ }
+ break;
+ case DESCENDING:
+ if (includeParents) {
+ ArrayList<DisambiguationReport.Resource> reverseCopy = new ArrayList<DisambiguationReport.Resource>(report.getParents());
+ Collections.reverse(reverseCopy);
+ resources.addAll(reverseCopy);
+ }
+
+ if (includeResource) {
+ resources.add(report.getResource());
+ }
+ break;
+ default:;
+ }
+
+ String separator = getSegmentSeparator();
+ for(DisambiguationReport.Resource r : resources) {
+ renderResource(r, bld);
+ bld.append(separator);
+ }
+
+ if (resources.size() > 0) {
+ bld.replace(bld.length() - separator.length(), bld.length(), "");
+ }
+
+ return bld.toString();
+ } else {
+ return null;
+ }
+ }
+
+ private List<Segment> parse(String template) {
+ List<Segment> ret = new ArrayList<Segment>();
+
+ int idx = 0;
+
+ SegmentAndState currentState = new SegmentAndState();
+ currentState.state = ParserState.START;
+
+ while(idx < template.length()) {
+ char c = template.charAt(idx);
+ Segment lastSegment = currentState.segment;
+ currentState = currentState.state.process(currentState, c);
+
+ //if the state created a new segment, store it in the results and
+ //continue with it. yes, the reference equality is what we want here
+ if (lastSegment != currentState.segment) {
+ ret.add(currentState.segment);
+ }
+
+ ++idx;
+ }
+
+ currentState.state.process(currentState, null);
+
+ return ret;
+ }
+
+ private void renderResource(DisambiguationReport.Resource resource, StringBuilder bld) {
+ List<Segment> template = parsedTemplate;
+ if (resource.getType() != null && resource.getType().isSingleton()) {
+ template = parsedSingletonTemplate;
+ }
+
+ for(Segment seg : template) {
+ seg.render(resource, bld);
+ }
+ }
+}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/util/DisambiguationReportRendererTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/util/DisambiguationReportRendererTest.java
new file mode 100644
index 0000000..0fc4782
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/util/DisambiguationReportRendererTest.java
@@ -0,0 +1,184 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.domain.util;
+
+import static org.testng.Assert.assertEquals;
+import static org.rhq.core.domain.resource.composite.DisambiguationReport.*;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.resource.composite.DisambiguationReport;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+public class DisambiguationReportRendererTest {
+
+ private static final String RESOURCE_NAME = "testResource";
+ private static final String RESOURCE_TYPE_NAME = "testResourceType";
+ private static final String RESOURCE_TYPE_PLUGIN_NAME = "testPlugin";
+ private static final int RESOURCE_ID = 0;
+ private static final String PARENT_RESOURCE_NAME = "testResourceParent";
+ private static final String PARENT_RESOURCE_TYPE_NAME = "testResourceTypeParent";
+ private static final String PARENT_RESOURCE_TYPE_PLUGIN_NAME = "testPluginParent";
+
+ private static final String TEST_NO_PARENTS_TEMPLATE = "seeing %[a resource called ]name[ ]%[with an id of ]id%[ in a type ]type.name%[ in a plugin ]type.plugin[].";
+ private static final String EXPECTED_NO_PARENTS_RENDERING_FULL = "seeing a resource called " + RESOURCE_NAME
+ + " with an id of " + RESOURCE_ID + " in a type " + RESOURCE_TYPE_NAME + " in a plugin "
+ + RESOURCE_TYPE_PLUGIN_NAME + ".";
+ private static final String EXPECTED_NO_PARENTS_RENDERING_NO_PLUGIN = "seeing a resource called " + RESOURCE_NAME
+ + " with an id of " + RESOURCE_ID + " in a type " + RESOURCE_TYPE_NAME + ".";
+ private static final String EXPECTED_NO_PARENTS_RENDERING_NO_TYPE = "seeing a resource called " + RESOURCE_NAME
+ + " with an id of " + RESOURCE_ID + ".";
+
+ private static final String TEST_PARENTS_TEMPLATE = "%type.name[ ]%[(]type.plugin[) ]%name";
+ private static final String TEST_PARENTS_SINGLETON_TEMPLATE = "%name (\\%singleton)";
+ private static final String ASCENDING_SEPARATOR = " -> ";
+ private static final String DESCENDING_SEPARATOR = " <- ";
+ private static final int NOF_PARENTS = 2;
+
+ private static final String EXPECTED_PARENTS_RENDERING_FULL_NO_SINGLETON_ASCENDING = RESOURCE_TYPE_NAME + " (" + RESOURCE_TYPE_PLUGIN_NAME + ") " + RESOURCE_NAME +
+ ASCENDING_SEPARATOR + PARENT_RESOURCE_TYPE_NAME + " (" + PARENT_RESOURCE_TYPE_PLUGIN_NAME + ") " + PARENT_RESOURCE_NAME + "1" +
+ ASCENDING_SEPARATOR + PARENT_RESOURCE_TYPE_NAME + " (" + PARENT_RESOURCE_TYPE_PLUGIN_NAME + ") " + PARENT_RESOURCE_NAME + "2";
+
+ private static final String EXPECTED_PARENTS_RENDERING_FULL_WITH_SINGLETON_ASCENDING = RESOURCE_TYPE_NAME + " (" + RESOURCE_TYPE_PLUGIN_NAME + ") " + RESOURCE_NAME +
+ ASCENDING_SEPARATOR + PARENT_RESOURCE_NAME + "1 (%singleton)" +
+ ASCENDING_SEPARATOR + PARENT_RESOURCE_TYPE_NAME + " (" + PARENT_RESOURCE_TYPE_PLUGIN_NAME + ") " + PARENT_RESOURCE_NAME + "2";
+
+ private static final String EXPECTED_PARENTS_RENDERING_FULL_NO_SINGLETON_DESCENDING =
+ PARENT_RESOURCE_TYPE_NAME + " (" + PARENT_RESOURCE_TYPE_PLUGIN_NAME + ") " + PARENT_RESOURCE_NAME + "2" +
+ DESCENDING_SEPARATOR + PARENT_RESOURCE_TYPE_NAME + " (" + PARENT_RESOURCE_TYPE_PLUGIN_NAME + ") " + PARENT_RESOURCE_NAME + "1" +
+ DESCENDING_SEPARATOR + RESOURCE_TYPE_NAME + " (" + RESOURCE_TYPE_PLUGIN_NAME + ") " + RESOURCE_NAME;
+
+ private static final String EXPECTED_PARENTS_RENDERING_FULL_WITH_SINGLETON_DESCENDING =
+ PARENT_RESOURCE_TYPE_NAME + " (" + PARENT_RESOURCE_TYPE_PLUGIN_NAME + ") " + PARENT_RESOURCE_NAME + "2" +
+ DESCENDING_SEPARATOR + PARENT_RESOURCE_NAME + "1 (%singleton)" +
+ DESCENDING_SEPARATOR + RESOURCE_TYPE_NAME + " (" + RESOURCE_TYPE_PLUGIN_NAME + ") " + RESOURCE_NAME;
+
+ private static final String EXPECTED_PARENTS_RENDERING_MINIMAL_WITH_SINGLETON_ASCENDING = RESOURCE_NAME +
+ ASCENDING_SEPARATOR + PARENT_RESOURCE_NAME + "1 (%singleton)" +
+ ASCENDING_SEPARATOR + PARENT_RESOURCE_NAME + "2";
+
+ @Test
+ public void testNoParents() {
+ DisambiguationReport<?> report = getNoParentsTestReport(true, true);
+
+ DisambiguationReportRenderer renderer = new DisambiguationReportRenderer();
+
+ renderer.setIncludeParents(false);
+ renderer.setSegmentTemplate(TEST_NO_PARENTS_TEMPLATE);
+ renderer.setSingletonSegmentTemplate(TEST_NO_PARENTS_TEMPLATE);
+
+ String rendering = renderer.render(report);
+ assertEquals(rendering, EXPECTED_NO_PARENTS_RENDERING_FULL);
+
+ report = getNoParentsTestReport(true, false);
+ rendering = renderer.render(report);
+ assertEquals(rendering, EXPECTED_NO_PARENTS_RENDERING_NO_PLUGIN);
+
+ report = getNoParentsTestReport(false, false);
+ rendering = renderer.render(report);
+ assertEquals(rendering, EXPECTED_NO_PARENTS_RENDERING_NO_TYPE);
+ }
+
+ @Test
+ public void testParents() {
+ DisambiguationReport<?> report = getParentsTestReport(true, true, true, true, false);
+
+ DisambiguationReportRenderer renderer = new DisambiguationReportRenderer();
+ renderer.setSegmentTemplate(TEST_PARENTS_TEMPLATE);
+ renderer.setSingletonSegmentTemplate(TEST_PARENTS_SINGLETON_TEMPLATE);
+ renderer.setSegmentSeparator(ASCENDING_SEPARATOR);
+
+ String rendering = renderer.render(report);
+ assertEquals(rendering, EXPECTED_PARENTS_RENDERING_FULL_NO_SINGLETON_ASCENDING);
+
+ renderer.setSegmentSeparator(DESCENDING_SEPARATOR);
+ renderer.setRenderingOrder(DisambiguationReportRenderer.RenderingOrder.DESCENDING);
+ rendering = renderer.render(report);
+ assertEquals(rendering, EXPECTED_PARENTS_RENDERING_FULL_NO_SINGLETON_DESCENDING);
+
+ report = getParentsTestReport(true, true, true, true, true);
+
+ renderer.setSegmentSeparator(ASCENDING_SEPARATOR);
+ renderer.setRenderingOrder(DisambiguationReportRenderer.RenderingOrder.ASCENDING);
+ rendering = renderer.render(report);
+ assertEquals(rendering, EXPECTED_PARENTS_RENDERING_FULL_WITH_SINGLETON_ASCENDING);
+
+ renderer.setSegmentSeparator(DESCENDING_SEPARATOR);
+ renderer.setRenderingOrder(DisambiguationReportRenderer.RenderingOrder.DESCENDING);
+ rendering = renderer.render(report);
+ assertEquals(rendering, EXPECTED_PARENTS_RENDERING_FULL_WITH_SINGLETON_DESCENDING);
+
+ report = getParentsTestReport(false, false, false, false, true);
+
+ renderer.setSegmentSeparator(ASCENDING_SEPARATOR);
+ renderer.setRenderingOrder(DisambiguationReportRenderer.RenderingOrder.ASCENDING);
+ rendering = renderer.render(report);
+ assertEquals(rendering, EXPECTED_PARENTS_RENDERING_MINIMAL_WITH_SINGLETON_ASCENDING);
+ }
+
+ private <T> DisambiguationReport<T> getNoParentsTestReport(boolean includeType, boolean includePlugin) {
+ return new DisambiguationReport<T>(null, Collections.<Resource> emptyList(),
+ createResource(0, includeType, includePlugin, false));
+ }
+
+ private <T> DisambiguationReport<T> getParentsTestReport(boolean includeType, boolean includePlugin, boolean includeParentsType, boolean includeParentsPlugin, boolean firstParentSingleton) {
+ Resource resource = createResource(0, includeType, includePlugin, false);
+ Resource firstParent = createResource(1, includeParentsType, includeParentsPlugin, firstParentSingleton);
+
+ ArrayList<Resource> parents = new ArrayList<Resource>();
+ parents.add(firstParent);
+
+ for(int i = 2; i <= NOF_PARENTS; ++i) {
+ Resource parent = createResource(i, includeParentsType, includeParentsPlugin, false);
+ parents.add(parent);
+ }
+
+ return new DisambiguationReport<T>(null, parents, resource);
+ }
+
+ private static Resource createResource(int parentage, boolean includeType, boolean includePlugin, boolean singleton) {
+ ResourceType type = null;
+
+ String resourceTypeName = parentage > 0 ? PARENT_RESOURCE_TYPE_NAME : RESOURCE_TYPE_NAME;
+ String pluginName = parentage > 0 ? PARENT_RESOURCE_TYPE_PLUGIN_NAME : RESOURCE_TYPE_PLUGIN_NAME;
+
+ if (includeType || singleton) {
+ type = new ResourceType(resourceTypeName, includePlugin ? pluginName
+ : null, singleton);
+ }
+
+ String name;
+
+ if (parentage == 0) {
+ name = RESOURCE_NAME;
+ } else {
+ name = PARENT_RESOURCE_NAME + parentage;
+ }
+
+ return new Resource(parentage, name, type);
+ }
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/recentlyApproved/ViewAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/recentlyApproved/ViewAction.java
index e3d4723..9c167cd 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/recentlyApproved/ViewAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/recentlyApproved/ViewAction.java
@@ -154,7 +154,7 @@ public class ViewAction extends TilesAction {
}
public DisambiguatedRecentlyAddedResourceComposite(DisambiguationReport<RecentlyAddedResourceComposite> report) {
- super(report.getOriginal(), report.getParents(), report.getResourceType(), report.getName());
+ super(report.getOriginal(), report.getParents(), report.getResource());
children = new ArrayList<DisambiguatedRecentlyAddedResourceComposite>();
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java
index 8c4f78b..de0141f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java
@@ -99,7 +99,8 @@ public class MutableDisambiguationReport<T> {
realParents.add(p.getResource());
}
}
- return new DisambiguationReport<T>(original, realParents, resource.resourceType.getResourceType(), resource.name);
+
+ return new DisambiguationReport<T>(original, realParents, resource.getResource());
}
@Override
commit bb15343956a366d077ef1d2707688678b6c7d77f
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jan 25 17:33:58 2011 -0500
Fix a selenium locator id issue in Dash update
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index dbe0505..f652874 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -163,6 +163,10 @@ public class DashboardsView extends LocatableVLayout implements BookmarkableView
Canvas[] members = getMembers();
removeMembers(members);
+ if (null != tabSet) {
+ tabSet.destroy();
+ }
+
this.dashboardsByName = new HashMap<String, Dashboard>(dashboards.size());
for (Dashboard dashboard : dashboards) {
this.dashboardsByName.put(dashboard.getName(), dashboard);
commit a27efb2e62c8e579c7cb33756f5f1e8a2172fb03
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jan 25 17:33:23 2011 -0500
Where we were destroying a Layout's members with explicit code I replaced
it with a call to the existing SeleniumUtility.destroyMembers(). This
ensures that the member is both removed from the parent layout and
destroyed.
There are several remnaining places in the code where we call removeMembers()
without any destroy(). This is very possible fine but may also be a spot
where we could run into Id conflict.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
index 22417ce..01a5571 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
@@ -55,6 +55,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* A tree view of all known ResourceTypes, which includes summaries of metric schedule and alert definition templates
@@ -185,30 +186,21 @@ public class ResourceTypeTreeView extends LocatableVLayout implements Bookmarkab
* @param canvasToShow the canvas to show in the parent
*/
private void switchToCanvas(Layout parentCanvas, Canvas canvasToShow) {
- Canvas[] members = getMembers();
- if (members != null) {
- for (Canvas c : members) {
- parentCanvas.removeMember(c);
- }
- }
+ SeleniumUtility.destroyMembers(parentCanvas);
+
parentCanvas.addMember(canvasToShow);
parentCanvas.markForRedraw();
}
private void prepareSubCanvas(Layout parentCanvas, Canvas canvasToShow, boolean showBackButton) {
- Canvas[] members = getMembers();
- if (members != null) {
- for (Canvas c : members) {
- parentCanvas.removeMember(c);
- c.destroy();
- }
- }
+ SeleniumUtility.destroyMembers(parentCanvas);
if (showBackButton) {
String backLink = LinkManager.getAdminTemplatesLink().substring(1); // strip the #
BackButton backButton = new BackButton(extendLocatorId("BackButton"), "Back to List", backLink);
parentCanvas.addMember(backButton);
}
+
parentCanvas.addMember(canvasToShow);
parentCanvas.markForRedraw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
index 594cbb4..265167a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
@@ -29,7 +29,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.core.DataClass;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
@@ -87,9 +86,7 @@ public class AlertDetailsView extends LocatableVLayout implements BookmarkableVi
}
private void show(Alert alert) {
- for (Canvas child : getMembers()) {
- removeChild(child);
- }
+ destroyMembers();
Log.info("AlertDetailsView-Alert: " + alert);
ListGridRecord record = AlertDataSource.convert(alert);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
index 22f5569..6d2f8f6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
@@ -64,6 +64,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.Single
import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourcePicker.OkHandler;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* This notification form will be used for the Resource Operation sender. This form lets
@@ -521,22 +522,12 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
}
private void hideOperationArguments() {
- Canvas[] canvii = operationArgumentsCanvasItem.getMembers();
- if (canvii != null) {
- for (Canvas canvas : canvii) {
- canvas.destroy();
- }
- }
+ SeleniumUtility.destroyMembers(operationArgumentsCanvasItem);
markForRedraw();
}
private void showOperationArguments(ConfigurationDefinition def, Configuration config) {
- Canvas[] canvii = operationArgumentsCanvasItem.getMembers();
- if (canvii != null) {
- for (Canvas canvas : canvii) {
- canvas.destroy();
- }
- }
+ SeleniumUtility.destroyMembers(operationArgumentsCanvasItem);
if (def != null) {
ConfigurationEditor configEditor = new ConfigurationEditor(extendLocatorId("opArgs"), def, config);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java
index b66a340..2aab6e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java
@@ -40,6 +40,7 @@ import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.content.repository.tree.ContentRepositoryTreeView;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableSectionStack;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* This is the main bundle view with left hand side trees and right hand side list/details view.
@@ -136,9 +137,8 @@ public class BundleTopView extends LocatableHLayout implements BookmarkableView
}
private void setContent(Canvas newContent) {
- for (Canvas c : contentCanvas.getMembers()) {
- c.destroy();
- }
+ SeleniumUtility.destroyMembers(contentCanvas);
+
contentCanvas.addMember(newContent);
contentCanvas.markForRedraw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
index cd25235..682b3d8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -293,9 +293,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* therefore, we need to explicitly destroy what's already there (presumably the detailsView
* in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
*/
- for (Canvas child : detailsHolder.getMembers()) {
- child.destroy();
- }
+ SeleniumUtility.destroyMembers(detailsHolder);
buildDetailsView();
}
@@ -335,9 +333,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
@Override
public void execute(boolean b) {
- for (Canvas child : detailsHolder.getMembers()) {
- child.destroy();
- }
+ SeleniumUtility.destroyMembers(detailsHolder);
contents.animateShow(AnimationEffect.WIPE);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java
index a964f0f..522c9cd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java
@@ -30,7 +30,6 @@ import java.util.Set;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.TextMatchStyle;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.events.ClickEvent;
@@ -110,9 +109,7 @@ public class TagEditorView extends LocatableLayout {
}
private void setup() {
- for (Canvas child : getMembers()) {
- child.destroy();
- }
+ destroyMembers();
Layout layout = vertical ? new LocatableVLayout(getLocatorId()) : new LocatableHLayout(getLocatorId());
if (!vertical)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java
index b3e869a..9d5c382 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java
@@ -74,9 +74,7 @@ public class ResourceOperationHistoryDetailsView extends LocatableVLayout implem
protected void onDraw() {
super.onDraw();
- for (Canvas child : getMembers()) {
- child.destroy();
- }
+ destroyMembers();
if (this.operationHistory != null) {
displayDetails(operationHistory);
@@ -139,7 +137,8 @@ public class ResourceOperationHistoryDetailsView extends LocatableVLayout implem
errorLinkItem.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- final Window winModal = new LocatableWindow(ResourceOperationHistoryDetailsView.this.extendLocatorId("errorWin"));
+ final Window winModal = new LocatableWindow(ResourceOperationHistoryDetailsView.this
+ .extendLocatorId("errorWin"));
winModal.setTitle(MSG.common_title_details());
winModal.setOverflow(Overflow.VISIBLE);
winModal.setShowMinimizeButton(false);
@@ -260,5 +259,5 @@ public class ResourceOperationHistoryDetailsView extends LocatableVLayout implem
}
return errMsg;
}
-
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
index becbd02..6f27e8f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
@@ -26,7 +26,6 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Label;
import org.rhq.core.domain.measurement.DataType;
@@ -62,9 +61,7 @@ public class GraphListView extends LocatableVLayout implements ResourceSelectLis
protected void onDraw() {
super.onDraw();
- for (Canvas c : getMembers()) {
- c.destroy();
- }
+ destroyMembers();
addMember(new AvailabilityBarView(resource));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java
index 8fb1e41..5064527 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java
@@ -46,4 +46,9 @@ public class LocatableHLayout extends HLayout implements Locatable {
public String extendLocatorId(String extension) {
return this.locatorId + "_" + extension;
}
+
+ public void destroyMembers() {
+ SeleniumUtility.destroyMembers(this);
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java
index 7a2e99b..17c1f9c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java
@@ -31,4 +31,8 @@ public class LocatableLayout extends Layout implements Locatable {
return this.locatorId + "_" + extension;
}
+ public void destroyMembers() {
+ SeleniumUtility.destroyMembers(this);
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
index 160cf18..43893a6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
@@ -156,7 +156,16 @@ public class SeleniumUtility {
* @param layout
*/
static public <T extends Layout> void destroyMembers(T layout) {
- for (Canvas currentMember : layout.getMembers()) {
+ if (null == layout) {
+ return;
+ }
+
+ Canvas[] members = layout.getMembers();
+ if (null == members) {
+ return;
+ }
+
+ for (Canvas currentMember : members) {
layout.removeMember(currentMember);
currentMember.destroy();
}
commit 8ffdb1319a0a610e1222eb6b453b95a8d6965643
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jan 25 17:17:56 2011 -0500
Selenium Locator Work - Activity2 subtab
This class suffered from two main issues with its locator impl.
1) You don't need locators on "inaccessible" widgets. Often H/V/Layouts
are used purely for formatting and are not really part of any widget
parent-child identification scheme. In this case just use non-Locatable
widgets to keep things as simple as possible. I made these conversions in
a few places.
2) You can't use static locatorIds on multiple widgets. Basically, avoid
re-using the same locatorId for widgets created inside of a loop. There
were a few places like this where result rows are being looped through.
Note that not all data is conducive to unique identifiers. In several places
the best that we can do is to use unique rowNums in the locators.
In general tried to shorten up he locator id strings as possible. They need
to be unique and descriptive, but as short as needed is good.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
index 9930108..442dfce 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
@@ -36,6 +36,8 @@ import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.FormItemIcon;
import com.smartgwt.client.widgets.form.fields.LinkItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
@@ -59,11 +61,9 @@ import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecor
import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
import org.rhq.enterprise.gui.coregui.client.util.measurement.GwtMonitorUtils;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* The content pane of the Resource Summary>Activity tab.
@@ -73,19 +73,15 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
public class ActivityView2 extends LocatableHLayout implements RefreshableView {
//Locatable ui references
- private LocatableVLayout leftPane = new LocatableVLayout(extendLocatorId("Left"));;
- private LocatableVLayout rightPane = new LocatableVLayout(extendLocatorId("Right"));;
- private LocatableCanvas recentMeasurementsContent = new LocatableCanvas(leftPane
- .extendLocatorId("RecentMetricsContent"));
- private LocatableCanvas recentAlertsContent = new LocatableCanvas(leftPane.extendLocatorId("RecentAlertsContent"));
- private LocatableCanvas recentOobContent = new LocatableCanvas(leftPane.extendLocatorId("RecentOobsContent"));
- private LocatableCanvas recentConfigurationContent = new LocatableCanvas(rightPane
- .extendLocatorId("RecentConfigContent"));
- private LocatableCanvas recentOperationsContent = new LocatableCanvas(rightPane
- .extendLocatorId("RecentOperationsContent"));
- private LocatableCanvas recentEventsContent = new LocatableCanvas(rightPane.extendLocatorId("RecentEventsContent"));
- private LocatableCanvas recentPkgHistoryContent = new LocatableCanvas(rightPane
- .extendLocatorId("RecentPkgHistoryContent"));
+ private VLayout leftPane = new VLayout();;
+ private VLayout rightPane = new VLayout();;
+ private LocatableCanvas recentMeasurementsContent = new LocatableCanvas(extendLocatorId("RecentMetrics"));
+ private LocatableCanvas recentAlertsContent = new LocatableCanvas(extendLocatorId("RecentAlerts"));
+ private LocatableCanvas recentOobContent = new LocatableCanvas(extendLocatorId("RecentOobs"));
+ private LocatableCanvas recentConfigurationContent = new LocatableCanvas(extendLocatorId("RecentConfig"));
+ private LocatableCanvas recentOperationsContent = new LocatableCanvas(extendLocatorId("RecentOperations"));
+ private LocatableCanvas recentEventsContent = new LocatableCanvas(extendLocatorId("RecentEvents"));
+ private LocatableCanvas recentPkgHistoryContent = new LocatableCanvas(extendLocatorId("RecentPkgHistory"));
//retrieve localized text
private String RECENT_MEASUREMENTS = MSG.common_title_recent_measurements();
@@ -137,22 +133,19 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
leftPane.setAutoHeight();
//recentMetrics.xhtml
- LocatableHLayout recentMetricsTitle = new TitleWithIcon(leftPane, "RecentMetrics",
- "subsystems/monitor/Monitor_24.png", RECENT_MEASUREMENTS);
+ HLayout recentMetricsTitle = new TitleWithIcon("subsystems/monitor/Monitor_24.png", RECENT_MEASUREMENTS);
leftPane.addMember(recentMetricsTitle);
leftPane.addMember(recentMeasurementsContent);
recentMeasurementsContent.setHeight(20);
leftPane.addMember(divider1);
//recentAlerts.xhtml
- LocatableHLayout recentAlertsTitle = new TitleWithIcon(leftPane, "RecentAlerts",
- "subsystems/alert/Flag_blue_24.png", RECENT_ALERTS);
+ HLayout recentAlertsTitle = new TitleWithIcon("subsystems/alert/Flag_blue_24.png", RECENT_ALERTS);
leftPane.addMember(recentAlertsTitle);
leftPane.addMember(recentAlertsContent);
recentAlertsContent.setHeight(20);
leftPane.addMember(divider2);
//recentOOBs.xhtml
- LocatableHLayout recentOobsTitle = new TitleWithIcon(leftPane, "RecentOobs",
- "subsystems/monitor/Monitor_failed_24.png", RECENT_OOB);
+ HLayout recentOobsTitle = new TitleWithIcon("subsystems/monitor/Monitor_failed_24.png", RECENT_OOB);
leftPane.addMember(recentOobsTitle);
leftPane.addMember(recentOobContent);
recentOobContent.setHeight(20);
@@ -163,29 +156,26 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
rightPane.setMembersMargin(5);
rightPane.setAutoHeight();
//recentConfigUpdates.xhtml
- LocatableHLayout recentConfigUpdatesTitle = new TitleWithIcon(leftPane, "RecentConfigUpdates",
- "subsystems/configure/Configure_24.png", RECENT_CONFIGURATIONS);
+ HLayout recentConfigUpdatesTitle = new TitleWithIcon("subsystems/configure/Configure_24.png",
+ RECENT_CONFIGURATIONS);
rightPane.addMember(recentConfigUpdatesTitle);
rightPane.addMember(recentConfigurationContent);
recentConfigurationContent.setHeight(20);
rightPane.addMember(divider3);
//recentOperations.xhtml
- LocatableHLayout recentOperationsTitle = new TitleWithIcon(leftPane, "RecentOperations",
- "subsystems/control/Operation_24.png", RECENT_OPERATIONS);
+ HLayout recentOperationsTitle = new TitleWithIcon("subsystems/control/Operation_24.png", RECENT_OPERATIONS);
rightPane.addMember(recentOperationsTitle);
rightPane.addMember(recentOperationsContent);
recentOperationsContent.setHeight(20);
rightPane.addMember(divider4);
//recentEventCounts.xhtml
- LocatableHLayout recentEventsTitle = new TitleWithIcon(leftPane, "RecentEvent",
- "subsystems/event/Events_24.png", RECENT_EVENTS);
+ HLayout recentEventsTitle = new TitleWithIcon("subsystems/event/Events_24.png", RECENT_EVENTS);
rightPane.addMember(recentEventsTitle);
rightPane.addMember(recentEventsContent);
recentEventsContent.setHeight(20);
rightPane.addMember(divider5);
//recentPackageHistory.xhtml
- LocatableHLayout recentPkgHistoryTitle = new TitleWithIcon(leftPane, "RecentPkgHistory",
- "subsystems/content/Content_24.png", RECENT_PKG_HISTORY);
+ HLayout recentPkgHistoryTitle = new TitleWithIcon("subsystems/content/Content_24.png", RECENT_PKG_HISTORY);
rightPane.addMember(recentPkgHistoryTitle);
rightPane.addMember(recentPkgHistoryContent);
recentPkgHistoryContent.setHeight(20);
@@ -225,14 +215,10 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
/**Creates the section top titles with icon for regions of Activity page.
*/
- class TitleWithIcon extends LocatableHLayout {
+ class TitleWithIcon extends HLayout {
- public TitleWithIcon(String locatorId) {
- super(locatorId);
- }
-
- public TitleWithIcon(Locatable parentContainer, String locatorIdentifier, String imageUrl, String title) {
- super(parentContainer.extendLocatorId(locatorIdentifier));
+ public TitleWithIcon(String imageUrl, String title) {
+ super();
Img titleImage = new Img(imageUrl, 24, 24);
HTMLFlow titleElement = new HTMLFlow();
titleElement.setWidth("*");
@@ -258,11 +244,15 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
GWTServiceLookup.getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
@Override
public void onSuccess(PageList<Alert> result) {
- LocatableVLayout column = new LocatableVLayout(recentAlertsContent.extendLocatorId("Content"));
+ VLayout column = new VLayout();
column.setHeight(10);
if (!result.isEmpty()) {
+ int rowNum = 0;
for (Alert alert : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ // alert history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
row.setNumCols(3);
StaticTextItem iconItem = newTextItemIcon(ImageManager.getAlertIcon(alert.getAlertDefinition()
@@ -275,7 +265,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_ALERTS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentAlertsContent.extendLocatorId("None"),
+ RECENT_ALERTS_NONE);
column.addMember(row);
}
for (Canvas child : recentAlertsContent.getChildren()) {
@@ -311,11 +302,15 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
@Override
public void onSuccess(List<DisambiguationReport<ResourceOperationLastCompletedComposite>> result) {
- LocatableVLayout column = new LocatableVLayout(recentOperationsContent.extendLocatorId("Content"));
+ VLayout column = new VLayout();
column.setHeight(10);
if (!result.isEmpty()) {
+ int rowNum = 0;
for (DisambiguationReport<ResourceOperationLastCompletedComposite> report : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ // operation history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
+ .extendLocatorId(String.valueOf(rowNum)));
row.setNumCols(3);
StaticTextItem iconItem = newTextItemIcon(ImageManager.getOperationResultsIcon(report
@@ -331,7 +326,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_OPERATIONS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentOperationsContent
+ .extendLocatorId("None"), RECENT_OPERATIONS_NONE);
column.addMember(row);
}
for (Canvas child : recentOperationsContent.getChildren()) {
@@ -363,12 +359,15 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
@Override
public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
- LocatableVLayout column = new LocatableVLayout(recentConfigurationContent
- .extendLocatorId("Content"));
+ VLayout column = new VLayout();
column.setHeight(10);
if (!result.isEmpty()) {
+ int rowNum = 0;
for (ResourceConfigurationUpdate update : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ // config update history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
+ .extendLocatorId(String.valueOf(rowNum)));
row.setNumCols(3);
StaticTextItem iconItem = newTextItemIcon(ImageManager.getResourceConfigurationIcon(update
@@ -387,7 +386,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_CONFIGURATIONS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentConfigurationContent
+ .extendLocatorId("None"), RECENT_CONFIGURATIONS_NONE);
column.addMember(row);
}
//cleanup
@@ -429,12 +429,16 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
}
}
//build display
- LocatableVLayout column = new LocatableVLayout(recentEventsContent.extendLocatorId("Content"));
+ VLayout column = new VLayout();
column.setHeight(10);
if (!results.isEmpty()) {
+ int rowNum = 0;
for (GwtTuple<EventSeverity, Integer> tuple : results) {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ // event history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent
+ .extendLocatorId(String.valueOf(rowNum)));
row.setNumCols(2);
row.setWidth(10);//pack.
@@ -448,7 +452,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_EVENTS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentEventsContent.extendLocatorId("None"),
+ RECENT_EVENTS_NONE);
column.addMember(row);
}
//cleanup
@@ -476,11 +481,12 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
@Override
public void onSuccess(PageList<MeasurementOOBComposite> result) {
- LocatableVLayout column = new LocatableVLayout(recentAlertsContent.extendLocatorId("Content"));
+ VLayout column = new VLayout();
column.setHeight(10);
if (!result.isEmpty()) {
for (MeasurementOOBComposite oob : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(recentOobContent.extendLocatorId(oob
+ .getScheduleName()));
row.setNumCols(2);
String title = oob.getScheduleName() + ":";
@@ -493,7 +499,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_OOB_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentOobContent.extendLocatorId("None"),
+ RECENT_OOB_NONE);
column.addMember(row);
}
recentOobContent.setContents("");
@@ -525,11 +532,13 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
@Override
public void onSuccess(PageList<InstalledPackageHistory> result) {
- LocatableVLayout column = new LocatableVLayout(recentPkgHistoryContent.extendLocatorId("Content"));
+ VLayout column = new VLayout();
column.setHeight(10);
if (!result.isEmpty()) {
for (InstalledPackageHistory history : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(recentPkgHistoryContent
+ .extendLocatorId(history.getPackageVersion().getFileName()
+ + history.getPackageVersion().getVersion()));
row.setNumCols(3);
StaticTextItem iconItem = newTextItemIcon("subsystems/content/Content_16.png", null);
@@ -544,7 +553,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_PKG_HISTORY_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentPkgHistoryContent
+ .extendLocatorId("None"), RECENT_PKG_HISTORY_NONE);
column.addMember(row);
}
//cleanup
@@ -563,7 +573,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
*/
private void getRecentMetrics() {
//display container
- final LocatableVLayout column = new LocatableVLayout(recentMeasurementsContent.extendLocatorId("Content"));
+ final VLayout column = new VLayout();
column.setHeight(10);//pack
final int resourceId = this.resourceComposite.getResource().getId();
@@ -635,7 +645,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
commaDelimitedList += d.getValue() + ",";
}
}
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(recentMeasurementsContent
+ .extendLocatorId(md.getName()));
row.setNumCols(3);
HTMLFlow graph = new HTMLFlow();
// String contents = "<span id='sparkline_" + index + "' class='dynamicsparkline' width='0'>"
@@ -673,13 +684,15 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
}
}
if (!someChartedData) {// when there are results but no chartable entries.
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_MEASUREMENTS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"), RECENT_MEASUREMENTS_NONE);
column.addMember(row);
}
//call out to 3rd party javascript lib
graphSparkLines();
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_MEASUREMENTS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"), RECENT_MEASUREMENTS_NONE);
column.addMember(row);
}
}
@@ -725,13 +738,9 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
* @param emptyMessage Contents of the empty region
* @return
*/
- private LocatableDynamicForm createEmptyDisplayRow(Locatable column, String emptyMessage) {
+ private LocatableDynamicForm createEmptyDisplayRow(String locatorId, String emptyMessage) {
LocatableDynamicForm row = null;
- if (column != null) {
- row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
- } else {
- row = new LocatableDynamicForm(extendLocatorId("ContentForm"));
- }
+ row = new LocatableDynamicForm(locatorId);
row.setNumCols(3);
StaticTextItem none = new StaticTextItem();
commit 9208c64bbd017abca809113633547dbb18fdea85
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jan 25 17:09:32 2011 -0500
Selenium Locator Work - Fix a problem in AbstractSelector.onDestroy().
We have to be careful of destroying things manually that are also destroyed
automatically by SmartGwt. In general, destroying a parent will destroy
it's children automatically. For example, destroying a SectionStack as a
whole, destroying a Layout, Window, etc.
We are still usually on the hook for member canvas's.
Calling destroy() on a widget that has already been destroyed will
force an unwanted reinitialization (onInit) of the widget (just so it can
be properly destroyed immediately following). This behavior isn't great in
smartgwt, I wonder if they could change this...
This instance of the issue was in the Alert Notification Sender definition
call chain. I'm sure it would have cropped up in other places as well.
Also, in general we don't use markForDestroy() but rather destroy() for
immediate removal from the DOM. This protectes against selenium ID
conflict.
- there is still one onInit() reinvocation I'm not able to explain. I
protected against it.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
index 0b8bfbd..7d2ae83 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
@@ -35,8 +35,8 @@ public class ResourceOperationLastCompletedComposite extends OperationLastComple
//no args constructor. Not to be used. java bean/serialization requirement
private ResourceOperationLastCompletedComposite() {
super();
- this.resourceTypeName = "(unitialized type)";
- this.resourceName = "(unitialized)";
+ this.resourceTypeName = "(uninitialized type)";
+ this.resourceName = "(uninitialized)";
this.resourceId = 0;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
index c36e7c2..bcea118 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
@@ -29,7 +29,6 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
@@ -39,6 +38,7 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+import com.smartgwt.client.widgets.layout.Layout;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
@@ -47,6 +47,7 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
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.SeleniumUtility;
/**
* @author John Mazzitelli
@@ -60,9 +61,10 @@ public class NewNotificationEditor extends LocatableDynamicForm {
private SelectItem notificationSenderSelectItem;
private CanvasItem senderCanvasItem;
+ private boolean senderCanvasInitialized = false;
- public NewNotificationEditor(String locatorId, AlertDefinition alertDefinition,
- List<AlertNotification> notifs, AlertNotification notifToEdit, Runnable closeFunc) {
+ public NewNotificationEditor(String locatorId, AlertDefinition alertDefinition, List<AlertNotification> notifs,
+ AlertNotification notifToEdit, Runnable closeFunc) {
super(locatorId);
this.alertDefinition = alertDefinition;
@@ -114,6 +116,7 @@ public class NewNotificationEditor extends LocatableDynamicForm {
notificationSenderSelectItem.setValueMap(senders);
notificationSenderSelectItem.setDisabled(false);
notificationSenderSelectItem.redraw();
+
switchToAlertSender(result[0]);
senderCanvasItem.show();
} else {
@@ -203,11 +206,15 @@ public class NewNotificationEditor extends LocatableDynamicForm {
}
private void switchToAlertSender(String newAlertSender) {
- Canvas oldCanvas = senderCanvasItem.getCanvas();
- if (oldCanvas != null) {
- oldCanvas.markForDestroy();
- }
AbstractNotificationSenderForm newCanvas = createNotificationSenderForm(newAlertSender);
+ // wipe existing DOM to avoid id conflicts. Use this flag to avoid having getCanvas() general a default
+ // Canvas on the first "switch".
+ if (senderCanvasInitialized) {
+ Layout senderLayout = (Layout) senderCanvasItem.getCanvas();
+ SeleniumUtility.destroyMembers(senderLayout);
+ senderLayout.destroy();
+ }
+ senderCanvasInitialized = true;
senderCanvasItem.setCanvas(newCanvas);
markForRedraw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
index d63159b..970fb66 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -258,8 +258,7 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
ListGrid listGrid = (ListGrid) event.getSource();
ListGridRecord[] selectedRows = listGrid.getSelection();
if (selectedRows != null && selectedRows.length == 1) {
- AlertNotification notif = (getDataSource())
- .copyValues(selectedRows[0]);
+ AlertNotification notif = (getDataSource()).copyValues(selectedRows[0]);
popupNotificationEditor(notif);
}
}
@@ -306,7 +305,7 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
winModal.addCloseClickHandler(new CloseClickHandler() {
@Override
public void onCloseClick(CloseClientEvent event) {
- winModal.markForDestroy();
+ winModal.destroy();
}
});
@@ -314,7 +313,7 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
alertDefinition, notifications, notifToEdit, new Runnable() {
@Override
public void run() {
- winModal.markForDestroy();
+ winModal.destroy();
table.refresh();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java
index 726bdc5..7e45d52 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java
@@ -56,12 +56,22 @@ public class SystemUsersNotificationSenderForm extends AbstractNotificationSende
private SubjectSelector selector;
+ private boolean isInitialized = false;
+
public SystemUsersNotificationSenderForm(String locatorId, AlertNotification notif, String sender) {
super(locatorId, notif, sender);
}
@Override
protected void onInit() {
+ // for reasons I'm not sure about, perhaps due to the way NewNotificationEditor destroys its own parent
+ // via callback, this onInit may be called a second time, during the destroy() call chain. Prevent
+ // it from re-executing.
+ if (isInitialized) {
+ return;
+ }
+ isInitialized = true;
+
super.onInit();
String subjectIds = getConfiguration().getSimpleValue(PROPNAME, ""); // we know the subject plugin defines this
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
index e23c0f1..062a47f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
@@ -65,6 +65,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTransferImgButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
@@ -202,6 +203,11 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
addMember(this.hlayout);
}
+ @Override
+ protected void onDestroy() {
+ SeleniumUtility.destroyMembers(hlayout);
+ }
+
private SectionStack buildAvailableItemsStack() {
SectionStack availableSectionStack = new SectionStack();
availableSectionStack.setWidth(300);
@@ -265,7 +271,7 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
}
// Add event handlers.
-
+
this.availableGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
updateButtonEnablement();
@@ -311,7 +317,7 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
}
} else {
availableRecords.addAll(Arrays.asList(allRecords));
- }
+ }
availableGrid.setData(availableRecords.toArray(new Record[availableRecords.size()]));
} finally {
updateButtonEnablement();
@@ -507,26 +513,6 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
return MSG.view_selector_assigned(itemTitle);
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
-
- assignedGrid.destroy();
-
- if (!isReadOnly) {
- if (availableFilterForm != null) {
- availableFilterForm.destroy();
- }
-
- availableGrid.destroy();
-
- addButton.destroy();
- removeButton.destroy();
- addAllButton.destroy();
- removeAllButton.destroy();
- }
- }
-
protected void updateButtonEnablement() {
if (!isReadOnly) {
addButton.setDisabled(!availableGrid.anySelected());
commit bf649fa1066cd6d7b261c942f6527ba1ca7e4872
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Jan 25 19:25:29 2011 -0500
implement group Operations>History subtab; remove ability to schedule new operations off Resource Operations>History subtab (may add back later depending on feedback from UXD team)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java
index 1152459..c320d10 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java
@@ -18,29 +18,22 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history;
-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.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
-import org.rhq.core.domain.operation.ResourceOperationHistory;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.core.domain.operation.OperationHistory;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import java.util.Date;
+import java.util.List;
+
/**
* @author Greg Hinkle
*/
-public abstract class OperationHistoryDataSource extends RPCDataSource<ResourceOperationHistory> {
+public abstract class OperationHistoryDataSource<T extends OperationHistory> extends RPCDataSource<T> {
public static abstract class Field {
public static final String ID = "id";
@@ -92,18 +85,17 @@ public abstract class OperationHistoryDataSource extends RPCDataSource<ResourceO
}
@Override
- public ResourceOperationHistory copyValues(Record from) {
- throw new UnsupportedOperationException("ResourceOperationHistory is read only.");
+ public T copyValues(Record from) {
+ throw new UnsupportedOperationException("OperationHistory is read only.");
}
@Override
- public ListGridRecord copyValues(ResourceOperationHistory from) {
+ public ListGridRecord copyValues(T from) {
ListGridRecord record = new ListGridRecord();
record.setAttribute(Field.ID, from.getId());
record.setAttribute(Field.CREATED_TIME, from.getCreatedTime());
record.setAttribute(Field.STARTED_TIME, new Date(from.getStartedTime()));
record.setAttribute(Field.DURATION, from.getDuration());
- record.setAttribute(Field.RESOURCE, from.getResource());
record.setAttribute(Field.SUBJECT, from.getSubjectName());
record.setAttribute(Field.OPERATION_DEFINITION, from.getOperationDefinition());
record.setAttribute(Field.OPERATION_NAME, from.getOperationDefinition().getDisplayName());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 9b18b47..cca83f5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -57,6 +57,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.H
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.MembersView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule.GroupOperationScheduleListView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.ActivityView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
@@ -233,7 +234,7 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
updateSummaryTab();
updateMonitoringTab(groupId, groupCategory, facets);
updateInventoryTab(groupId, facets);
- updateOperationsTab(groupId, groupCategory, facets);
+ updateOperationsTab(groupCategory, facets);
updateAlertsTab(groupComposite, groupCategory);
updateConfigurationTab(groupId, groupCategory, facets);
updateEventsTab(groupComposite, groupCategory, facets);
@@ -293,14 +294,14 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION), true);
}
- private void updateOperationsTab(int groupId, GroupCategory groupCategory, Set<ResourceTypeFacet> facets) {
+ private void updateOperationsTab(GroupCategory groupCategory, Set<ResourceTypeFacet> facets) {
if (updateTab(this.operationsTab, groupCategory == GroupCategory.COMPATIBLE
&& facets.contains(ResourceTypeFacet.OPERATION), true)) {
updateSubTab(this.operationsTab, this.operationsSchedule,
new GroupOperationScheduleListView(this.operationsSchedule.extendLocatorId("View"),
this.groupComposite), true, true);
- updateSubTab(this.operationsTab, this.operationsHistory, new FullHTMLPane(this.operationsHistory.extendLocatorId("View"),
- "/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId), true, true);
+ updateSubTab(this.operationsTab, this.operationsHistory, new GroupOperationHistoryListView(
+ this.operationsHistory.extendLocatorId("View"), this.groupComposite), true, true);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java
new file mode 100644
index 0000000..d02949a
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java
@@ -0,0 +1,79 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, 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.inventory.groups.detail.operation.history;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
+import org.rhq.core.domain.operation.GroupOperationHistory;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.OperationHistoryDataSource;
+
+import java.util.Arrays;
+
+/**
+ * @author Ian Springer
+ */
+public class GroupOperationHistoryDataSource extends OperationHistoryDataSource<GroupOperationHistory> {
+
+ public static abstract class Field extends OperationHistoryDataSource.Field {
+ public static final String GROUP = "group";
+ }
+
+ public static abstract class CriteriaField {
+ public static final String GROUP_ID = "groupId";
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+ GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
+
+ if (request.getCriteria().getValues().containsKey(CriteriaField.GROUP_ID)) {
+ int groupId = Integer.parseInt((String)request.getCriteria().getValues().get(
+ CriteriaField.GROUP_ID));
+ criteria.addFilterResourceGroupIds(Arrays.asList(groupId));
+ }
+
+ criteria.setPageControl(getPageControl(request));
+
+ operationService.findGroupOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<GroupOperationHistory>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.dataSource_operationHistory_error_fetchFailure(), caught);
+ }
+
+ public void onSuccess(PageList<GroupOperationHistory> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @Override
+ public ListGridRecord copyValues(GroupOperationHistory from) {
+ ListGridRecord record = super.copyValues(from);
+ record.setAttribute(Field.GROUP, from.getGroup());
+ return record;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
new file mode 100644
index 0000000..9206e4f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
@@ -0,0 +1,54 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, 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.inventory.groups.detail.operation.history;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.widgets.Canvas;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource;
+
+/**
+ * @author Ian Springer
+ */
+public class GroupOperationHistoryListView extends AbstractOperationHistoryListView {
+
+ private ResourceGroupComposite groupComposite;
+
+ public GroupOperationHistoryListView(String locatorId, ResourceGroupComposite groupComposite) {
+ super(locatorId, new ResourceOperationHistoryDataSource(), null,
+ new Criteria(GroupOperationHistoryDataSource.CriteriaField.GROUP_ID,
+ String.valueOf(groupComposite.getResourceGroup().getId())));
+ this.groupComposite = groupComposite;
+ }
+
+ @Override
+ protected void configureTable() {
+ super.configureTable();
+
+ // TODO: Add Delete button.
+ }
+
+ @Override
+ public Canvas getDetailsView(int id) {
+ return new Canvas();
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
index e350042..447ec17 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
@@ -23,8 +23,12 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
+import org.rhq.core.domain.operation.OperationHistory;
import org.rhq.core.domain.operation.ResourceOperationHistory;
+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.inventory.common.detail.operation.history.OperationHistoryDataSource;
@@ -32,7 +36,11 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.h
/**
* @author Ian Springer
*/
-public class ResourceOperationHistoryDataSource extends OperationHistoryDataSource {
+public class ResourceOperationHistoryDataSource extends OperationHistoryDataSource<ResourceOperationHistory> {
+
+ public static abstract class Field extends OperationHistoryDataSource.Field {
+ public static final String RESOURCE = "resource";
+ }
public static abstract class CriteriaField {
public static final String RESOURCE_ID = "resourceId";
@@ -63,5 +71,11 @@ public class ResourceOperationHistoryDataSource extends OperationHistoryDataSour
});
}
+ @Override
+ public ListGridRecord copyValues(ResourceOperationHistory from) {
+ ListGridRecord record = super.copyValues(from);
+ record.setAttribute(Field.RESOURCE, from.getResource());
+ return record;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
index 172da98..086b39d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
@@ -19,26 +19,11 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history;
-import java.util.EnumSet;
-
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.menu.IMenuButton;
-import com.smartgwt.client.widgets.menu.Menu;
-import com.smartgwt.client.widgets.menu.MenuItem;
-import com.smartgwt.client.widgets.menu.events.ClickHandler;
-import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
-
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.ResourceOperationHistoryDetailsView;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationCreateWizard;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableMenu;
/**
* @author Ian Springer
@@ -58,31 +43,7 @@ public class ResourceOperationHistoryListView extends AbstractOperationHistoryLi
protected void configureTable() {
super.configureTable();
- if (this.resourceComposite.getResourcePermission().isControl()) {
- final Resource resource = this.resourceComposite.getResource();
- final Menu operationMenu = new LocatableMenu(this.extendLocatorId("Operation"));
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.operations),
- new ResourceTypeRepository.TypeLoadedCallback() {
- public void onTypesLoaded(ResourceType type) {
- for (final OperationDefinition operationDefinition : type.getOperationDefinitions()) {
- MenuItem menuItem = new MenuItem(operationDefinition.getDisplayName());
- operationMenu.addItem(menuItem);
- menuItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- new OperationCreateWizard(resource, operationDefinition).startOperationWizard();
- }
- });
- }
- }
- });
-
- IMenuButton operationsButton = new LocatableIMenuButton(this.extendLocatorId("Run"),
- MSG.view_operationHistoryList_button_runOperation(), operationMenu);
- operationsButton.setShowMenuBelow(false);
- operationsButton.setAutoFit(true);
- addExtraWidget(operationsButton);
- }
+ // TODO: Add Delete button.
}
@Override
commit 20771d028323aba36aafd18837a029a53d16e081
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Jan 25 18:33:09 2011 -0500
BZ-672705: adding missing upgrade to overlord for getAgentClient().
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
index 8bfa5cd..45f7832 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
@@ -166,17 +166,15 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
}
}
- public int scheduleResourceOperation(Subject subject, ResourceOperationSchedule schedule)
- throws ScheduleException {
+ public int scheduleResourceOperation(Subject subject, ResourceOperationSchedule schedule) throws ScheduleException {
JobTrigger jobTrigger = schedule.getJobTrigger();
Trigger trigger = convertToTrigger(jobTrigger);
try {
- ResourceOperationSchedule resourceOperationSchedule = scheduleResourceOperation(subject,
- schedule.getResource().getId(), schedule.getOperationName(), schedule.getParameters(), trigger,
- schedule.getDescription());
+ ResourceOperationSchedule resourceOperationSchedule = scheduleResourceOperation(subject, schedule
+ .getResource().getId(), schedule.getOperationName(), schedule.getParameters(), trigger, schedule
+ .getDescription());
return resourceOperationSchedule.getId();
- }
- catch (SchedulerException e) {
+ } catch (SchedulerException e) {
throw new ScheduleException(e);
}
}
@@ -496,7 +494,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
int entityId;
if (entityIdObj != null) {
// for jobs created using RHQ 4.0 or later, the map will contain an entityId entry
- entityId = Integer.valueOf((String)entityIdObj);
+ entityId = Integer.valueOf((String) entityIdObj);
} else {
// for jobs created prior to upgrading to RHQ 4.0, the map will not contain an entityId entry,
// so we'll need to lookup the entity id from the DB.
@@ -915,7 +913,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
boolean canceled = false;
try {
- agent = agentManager.getAgentClient(subject, resourceId);
+ agent = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
// since this method is usually called by the UI, we want to quickly determine if we can even talk to the agent
if (agent.ping(5000L)) {
@@ -1477,8 +1475,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
Subject overlord = subjectManager.getOverlord();
for (ResourceOperationScheduleComposite composite : results) {
try {
- ResourceOperationSchedule sched = getResourceOperationSchedule(subject, composite.getJobId()
- .toString());
+ ResourceOperationSchedule sched = getResourceOperationSchedule(subject, composite.getJobId().toString());
OperationDefinition def = getSupportedResourceOperation(overlord, composite.getResourceId(), sched
.getOperationName(), false);
composite.setOperationName((def.getDisplayName() != null) ? def.getDisplayName() : sched
@@ -1531,8 +1528,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
Subject overlord = subjectManager.getOverlord();
for (GroupOperationScheduleComposite composite : results) {
try {
- GroupOperationSchedule sched = getGroupOperationSchedule(subject, composite.getJobId()
- .toString());
+ GroupOperationSchedule sched = getGroupOperationSchedule(subject, composite.getJobId().toString());
OperationDefinition def = getSupportedGroupOperation(overlord, composite.getGroupId(), sched
.getOperationName(), false);
composite.setOperationName((def.getDisplayName() != null) ? def.getDisplayName() : sched
@@ -1816,7 +1812,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
query.setParameter("jobName", jobName);
String jobGroup = jobId.getJobGroup();
query.setParameter("jobGroup", jobGroup);
- OperationScheduleEntity operationScheduleEntity = (OperationScheduleEntity)query.getSingleResult();
+ OperationScheduleEntity operationScheduleEntity = (OperationScheduleEntity) query.getSingleResult();
return operationScheduleEntity;
}
@@ -1892,8 +1888,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
Trigger[] triggers;
try {
triggers = scheduler.getTriggersOfJob(jobDetail.getName(), jobDetail.getGroup());
- }
- catch (SchedulerException e) {
+ } catch (SchedulerException e) {
throw new RuntimeException("Failed to lookup trigger for job [" + jobDetail.getFullName() + "].", e);
}
if (triggers.length == 0) {
@@ -1909,7 +1904,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
private static JobTrigger convertToJobTrigger(Trigger trigger) {
JobTrigger schedule;
if (trigger instanceof SimpleTrigger) {
- SimpleTrigger simpleTrigger = (SimpleTrigger)trigger;
+ SimpleTrigger simpleTrigger = (SimpleTrigger) trigger;
Date startTime = simpleTrigger.getStartTime();
if (startTime != null) {
// later
@@ -1953,7 +1948,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
}
}
} else if (trigger instanceof CronTrigger) {
- CronTrigger cronTrigger = (CronTrigger)trigger;
+ CronTrigger cronTrigger = (CronTrigger) trigger;
schedule = JobTrigger.createCronTrigger(cronTrigger.getCronExpression());
} else {
throw new IllegalStateException("Unsupported Quartz trigger type: " + trigger.getClass().getName());
@@ -1967,8 +1962,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
CronTrigger cronTrigger = new CronTrigger();
try {
cronTrigger.setCronExpression(jobTrigger.getCronExpression());
- }
- catch (ParseException e) {
+ } catch (ParseException e) {
throw new RuntimeException(e);
}
trigger = cronTrigger;
@@ -1976,18 +1970,18 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
SimpleTrigger simpleTrigger = new SimpleTrigger();
Date startTime = null;
switch (jobTrigger.getStartType()) {
- case NOW:
- startTime = new Date();
- break;
- case DATETIME:
- startTime = jobTrigger.getStartDate();
- break;
+ case NOW:
+ startTime = new Date();
+ break;
+ case DATETIME:
+ startTime = jobTrigger.getStartDate();
+ break;
}
simpleTrigger.setStartTime(startTime);
// TODO (ips): Finish implementing this.
- trigger= simpleTrigger;
+ trigger = simpleTrigger;
}
return trigger;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/ResourceOperationJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/ResourceOperationJob.java
index e0ac109..d85c323 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/ResourceOperationJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/ResourceOperationJob.java
@@ -177,7 +177,7 @@ public class ResourceOperationJob extends OperationJob {
}
AgentManagerLocal agentManager = LookupUtil.getAgentManager();
- AgentClient agentClient = agentManager.getAgentClient(schedule.getSubject(), resource.getId());
+ AgentClient agentClient = agentManager.getAgentClient(getOverlord(), resource.getId());
agentClient.getOperationAgentService().invokeOperation(resourceHistory.getJobId().toString(),
resource.getId(), schedule.getOperationName(), schedule.getParameters());
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index e9d3b30..770a69c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -279,7 +279,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
AgentClient agentClient = null;
try {
// The test code does not always generate agents for the resources. Catch and log any problem but continue
- agentClient = agentManager.getAgentClient(user, resourceId);
+ agentClient = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
} catch (Throwable t) {
log.warn("No AgentClient found for resource [" + resource
+ "]. Unable to inform agent of inventory removal (this may be ok): " + t);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/support/SupportManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/support/SupportManagerBean.java
index b81b0a8..8ef6dc4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/support/SupportManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/support/SupportManagerBean.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.cloud.Server;
import org.rhq.core.util.stream.StreamUtil;
import org.rhq.enterprise.server.agentclient.AgentClient;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.cloud.instance.ServerManagerLocal;
import org.rhq.enterprise.server.core.AgentManagerLocal;
@@ -60,11 +61,14 @@ public class SupportManagerBean implements SupportManagerLocal, SupportManagerRe
@EJB
private ServerManagerLocal serverManager;
+ @EJB
+ private SubjectManagerLocal subjectManager;
+
@RequiredPermission(Permission.MANAGE_INVENTORY)
public InputStream getSnapshotReportStream(Subject subject, int resourceId, String name, String description)
throws Exception {
- AgentClient agentClient = this.agentManager.getAgentClient(subject, resourceId);
+ AgentClient agentClient = this.agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
SupportAgentService supportService = agentClient.getSupportAgentService();
InputStream snapshotStream = supportService.getSnapshotReport(resourceId, name, description);
commit 0715ed6e2d1d6d21cfea0e4064fdeb506f91da59
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Jan 25 18:34:34 2011 -0500
username is no longer editable on user edit page (fixes https://bugzilla.redhat.com/show_bug.cgi?id=672684)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
index e1f1042..314d279 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
@@ -138,13 +138,13 @@ public class UserEditView extends AbstractRecordEditor<UsersDataSource> {
List<FormItem> items = new ArrayList<FormItem>();
// Username field should be editable when creating a new user, but should be read-only for existing users.
- if (form.isNewRecord()) {
- TextItem nameItem = new TextItem(UsersDataSource.Field.NAME);
- items.add(nameItem);
+ FormItem nameItem;
+ if (isNewRecord()) {
+ nameItem = new TextItem(UsersDataSource.Field.NAME);
} else {
- StaticTextItem nameItem = new StaticTextItem(UsersDataSource.Field.NAME);
- items.add(nameItem);
+ nameItem = new StaticTextItem(UsersDataSource.Field.NAME);
}
+ items.add(nameItem);
StaticTextItem isLdapItem = new StaticTextItem(UsersDataSource.Field.LDAP);
items.add(isLdapItem);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
index ff2568f..1941085 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
@@ -213,6 +213,14 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
throw new PermissionException("You cannot disable the system user [" + subjectToModify.getName() + "].");
}
+ Subject attachedSubject = getSubjectById(subjectToModify.getId());
+ if (attachedSubject == null) {
+ throw new IllegalArgumentException("No user exists with id [" + subjectToModify.getId() + "].");
+ }
+ if (!attachedSubject.getName().equals(subjectToModify.getName())) {
+ throw new IllegalArgumentException("You cannot change a user's username.");
+ }
+
Set<Role> newRoles = subjectToModify.getRoles();
if (newRoles != null) {
Set<Role> currentRoles = new HashSet<Role>(roleManager.findRolesBySubject(subjectToModify.getId(),
commit e99b4de787ff039b342610aa7fa85e7689a84c54
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jan 25 18:15:06 2011 -0500
allow 10m for the bundle to download from a URL
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java
index 4678bbe..3ed578a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java
@@ -214,7 +214,7 @@ public class BundleUploadDistroFileStep extends AbstractWizardStep {
return;
}
- BundleGWTServiceAsync bundleServer = GWTServiceLookup.getBundleService();
+ BundleGWTServiceAsync bundleServer = GWTServiceLookup.getBundleService(10 * 60 * 1000); // if upload takes more than 10m, you have other things to worry about
bundleServer.createBundleVersionViaURL(urlString, new AsyncCallback<BundleVersion>() {
public void onSuccess(BundleVersion result) {
CoreGUI.getMessageCenter().notify(
commit 2482cface3242f76a6bda12506b26f926ea67fea
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jan 25 17:50:59 2011 -0500
use overlord to get the agent client
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index a81ded5..157a55d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -1016,7 +1016,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
Resource platform, boolean isCleanDeployment, boolean isRevert) throws Exception {
int platformId = platform.getId();
- AgentClient agentClient = agentManager.getAgentClient(subject, platformId);
+ AgentClient agentClient = agentManager.getAgentClient(subjectManager.getOverlord(), platformId);
BundleAgentService bundleAgentService = agentClient.getBundleAgentService();
// The BundleResourceDeployment record must exist in the db before the agent request because the agent may try
commit 1ef99fb331b3754bec5c6114948997c02b7421f9
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Jan 25 15:55:49 2011 -0500
more work on group ops
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ListOrderChangedEvent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ListOrderChangedEvent.java
new file mode 100644
index 0000000..aeb8e66
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ListOrderChangedEvent.java
@@ -0,0 +1,20 @@
+package org.rhq.enterprise.gui.coregui.client.components.sorter;
+
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+/**
+ *
+ */
+public class ListOrderChangedEvent {
+
+ private ListGridRecord[] items;
+
+ public ListOrderChangedEvent(ListGridRecord[] items) {
+ this.items = items;
+ }
+
+ public ListGridRecord[] getItems() {
+ return this.items;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ListOrderChangedHandler.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ListOrderChangedHandler.java
new file mode 100644
index 0000000..cad63cf
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ListOrderChangedHandler.java
@@ -0,0 +1,10 @@
+package org.rhq.enterprise.gui.coregui.client.components.sorter;
+
+/**
+ *
+ */
+public interface ListOrderChangedHandler {
+
+ void onListOrderChanged(ListOrderChangedEvent event);
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ReorderableList.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ReorderableList.java
new file mode 100644
index 0000000..b0b1214
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ReorderableList.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.components.sorter;
+
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.RecordDropEvent;
+import com.smartgwt.client.widgets.grid.events.RecordDropHandler;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.SectionStack;
+import com.smartgwt.client.widgets.layout.SectionStackSection;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Ian Springer
+ */
+public class ReorderableList extends LocatableVLayout {
+
+ protected ListGridRecord[] initialSelection;
+ protected HLayout hlayout;
+ protected LocatableListGrid listGrid;
+ /** an icon displayed next to each item in the list grids, or null if no icon should be displayed */
+ private String itemIcon;
+ /** the item title (i.e. display name), which should be plural and capitalized, e.g. "Resource Groups", "Roles". */
+ private String itemTitle;
+
+ private Set<ListOrderChangedHandler> listOrderChangedHandlers = new HashSet<ListOrderChangedHandler>();
+
+ private boolean isReadOnly;
+
+ public ReorderableList(String locatorId, ListGridRecord[] records, String itemTitle, String itemIcon) {
+ this(locatorId, false, records, itemTitle, itemIcon);
+ }
+
+ public ReorderableList(String locatorId, boolean isReadOnly, ListGridRecord[] records, String itemTitle, String itemIcon) {
+ super(locatorId);
+
+ this.isReadOnly = isReadOnly;
+
+ setWidth100();
+ setMargin(7);
+
+ this.hlayout = new HLayout();
+ this.listGrid = new LocatableListGrid(extendLocatorId("listGrid"));
+ this.initialSelection = records;
+ this.listGrid.setRecords(records);
+
+ if (this.isReadOnly) {
+ this.listGrid.setSelectionType(SelectionStyle.NONE);
+ }
+
+ this.itemTitle = itemTitle;
+ this.itemIcon = itemIcon;
+ }
+
+ /**
+ * Returns the {@link com.smartgwt.client.data.Record record}s in the order currently specified by the user.
+ *
+ * @return the {@link com.smartgwt.client.data.Record record}s in the order currently specified by the user
+ */
+ public ListGridRecord[] getRecords() {
+ return this.listGrid.getRecords();
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ SectionStack itemsStack = buildItemsSectionStack();
+ hlayout.addMember(itemsStack);
+
+ addMember(this.hlayout);
+ }
+
+ private SectionStack buildItemsSectionStack() {
+ SectionStack itemsSectionStack = new SectionStack();
+ itemsSectionStack.setWidth(300);
+ itemsSectionStack.setHeight(250);
+
+ SectionStackSection itemsSection = new SectionStackSection(getItemTitle());
+ itemsSection.setCanCollapse(false);
+ itemsSection.setExpanded(true);
+
+ this.listGrid.setCanReorderRecords(true);
+ this.listGrid.setLoadingMessage(MSG.common_msg_loading());
+ this.listGrid.setEmptyMessage(MSG.common_msg_noItemsToShow());
+ this.listGrid.addRecordDropHandler(new RecordDropHandler() {
+ @Override
+ public void onRecordDrop(RecordDropEvent event) {
+ notifyListOrderChangedHandlers();
+ }
+ });
+
+ List<ListGridField> fields = new ArrayList<ListGridField>();
+ String itemIcon = getItemIcon();
+ if (itemIcon != null) {
+ ListGridField iconField = new ListGridField("icon", 25);
+ iconField.setType(ListGridFieldType.ICON);
+ iconField.setCellIcon(itemIcon);
+ iconField.setShowDefaultContextMenu(false);
+ fields.add(iconField);
+ }
+ ListGridField nameField = new ListGridField(getNameField(), MSG.common_title_name());
+ fields.add(nameField);
+ this.listGrid.setFields(fields.toArray(new ListGridField[fields.size()]));
+
+ itemsSection.setItems(this.listGrid);
+ itemsSectionStack.addSection(itemsSection);
+
+ return itemsSectionStack;
+ }
+
+ private void notifyListOrderChangedHandlers() {
+ for (ListOrderChangedHandler handler : this.listOrderChangedHandlers) {
+ handler.onListOrderChanged(new ListOrderChangedEvent(this.listGrid.getSelection()));
+ }
+ }
+
+ public void reset() {
+ this.listGrid.setData(this.initialSelection);
+ }
+
+ public HandlerRegistration addListOrderChangedHandler(final ListOrderChangedHandler handler) {
+ this.listOrderChangedHandlers.add(handler);
+ return new HandlerRegistration() {
+ @Override
+ public void removeHandler() {
+ listOrderChangedHandlers.remove(handler);
+ }
+ };
+ }
+
+ protected String getNameField() {
+ return "name";
+ }
+
+ public String getItemTitle() {
+ return itemTitle;
+ }
+
+ protected String getItemIcon() {
+ return itemIcon;
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+
+ this.listGrid.destroy();
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java
index 086d7be..b08c0ee 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java
@@ -23,7 +23,8 @@ public class TimestampCellFormatter implements CellFormatter {
* even if the caller doesn't have data from a cell or list grid. This can keep date formatting
* consistent across the app, whether the data is in a cell or not.
*
- * @param date the date to format as a Date, Long, Integer or a String
+ * @param value the date to format as a Date, Long, Integer or a String
+ *
* @return the formatted date string
*/
public static String format(Object value) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
index b6a37bf..59cb90c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
@@ -1,16 +1,107 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.DSCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.components.sorter.ReorderableList;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+import java.util.LinkedHashMap;
/**
- *
+ * @author Ian Springer
*/
public class GroupOperationScheduleDetailsView extends AbstractOperationScheduleDetailsView {
+ private ResourceGroupComposite groupComposite;
+ private ListGridRecord[] memberResourceRecords;
+
public GroupOperationScheduleDetailsView(String locatorId, ResourceGroupComposite groupComposite, int scheduleId) {
super(locatorId, new GroupOperationScheduleDataSource(groupComposite),
groupComposite.getResourceGroup().getResourceType(), scheduleId);
+ this.groupComposite = groupComposite;
+ }
+
+ @Override
+ protected void init(final boolean isReadOnly) {
+ if (isNewRecord()) {
+ ResourceDatasource resourceDatasource = new ResourceDatasource();
+ Criteria criteria = new Criteria(ResourceDatasource.FILTER_GROUP_ID,
+ String.valueOf(this.groupComposite.getResourceGroup().getId()));
+ resourceDatasource.fetchData(criteria, new DSCallback() {
+ public void execute(DSResponse response, Object rawData, DSRequest request) {
+ if (response.getStatus() != DSResponse.STATUS_SUCCESS) {
+ throw new RuntimeException("Failed to load group member Resources.");
+ }
+ Record[] data = response.getData();
+ memberResourceRecords = new ListGridRecord[data.length];
+ for (int i = 0, dataLength = data.length; i < dataLength; i++) {
+ Record record = data[i];
+ ListGridRecord listGridRecord = (ListGridRecord) record;
+ memberResourceRecords[i] = listGridRecord;
+ }
+ GroupOperationScheduleDetailsView.super.init(isReadOnly);
+ }
+ });
+ }
}
+ @Override
+ protected LocatableVLayout buildContentPane() {
+ LocatableVLayout contentPane = super.buildContentPane();
+
+ HTMLFlow hr = new HTMLFlow("<p/><hr/><p/>");
+ contentPane.addMember(hr);
+
+ DynamicForm executionModeForm = new DynamicForm();
+ executionModeForm.setColWidths("250", "*");
+
+ RadioGroupItem executionModeItem = new RadioGroupItem("executionMode", "Member Resource Execution Order");
+ LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>(2);
+ valueMap.put("parallel", "Execute in parallel");
+ valueMap.put("sequential", "Execute in the order specified below");
+ executionModeItem.setValueMap(valueMap);
+ executionModeItem.setDefaultValue("parallel");
+
+ final CheckboxItem haltOnFailureItem = new CheckboxItem("haltOnFailure", "Halt on Failure?");
+ haltOnFailureItem.setDefaultValue(false);
+ haltOnFailureItem.setVisible(false);
+ haltOnFailureItem.setLabelAsTitle(true);
+
+ executionModeItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ if (event.getValue().equals("parallel")) {
+ haltOnFailureItem.hide();
+ } else {
+ haltOnFailureItem.show();
+ }
+ }
+ });
+
+ executionModeForm.setFields(executionModeItem, haltOnFailureItem);
+
+ contentPane.addMember(executionModeForm);
+
+ ResourceCategory resourceCategory = this.groupComposite.getResourceGroup().getResourceType().getCategory();
+ String memberIcon = ImageManager.getResourceIcon(resourceCategory);
+ ReorderableList memberExecutionOrderer = new ReorderableList(extendLocatorId("MemberExecutionOrderer"),
+ this.memberResourceRecords, "Member Resources", memberIcon);
+ contentPane.addMember(memberExecutionOrderer);
+
+ return contentPane;
+ }
}
commit 6cd53e7d6a9d96ea540a7061a653956c00b21f5e
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Jan 25 15:54:34 2011 -0500
fix bug where existing roles associated with a new role's subjects were removed from those subjects (https://bugzilla.redhat.com/show_bug.cgi?id=672684)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
index 93b1ca8..eba8968 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -155,13 +156,22 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
// Now we must merge subjects and resource groups, since those fields in Role do not have persist cascade
// enabled.
+ int[] subjectIds = new int[newRole.getSubjects().size()];
+ int i = 0;
for (Subject subject : newRole.getSubjects()) {
- entityManager.merge(subject);
+ subjectIds[i++] = subject.getId();
}
+ addSubjectsToRole(whoami, newRole.getId(), subjectIds);
for (ResourceGroup resourceGroup : newRole.getResourceGroups()) {
entityManager.merge(resourceGroup);
}
+ int[] resourceGroupIds = new int[newRole.getResourceGroups().size()];
+ i = 0;
+ for (ResourceGroup resourceGroup : newRole.getResourceGroups()) {
+ resourceGroupIds[i++] = resourceGroup.getId();
+ }
+ addResourceGroupsToRole(whoami, newRole.getId(), resourceGroupIds);
return newRole;
}
commit c52bdcd299b21043ad1c8ef70174053bc372b265
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jan 25 14:55:14 2011 -0500
forgot to add "g" to the short options so "-g" is valid cmd line option to the agent
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
index fc2b8f3..955832c 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
@@ -1668,8 +1668,8 @@ public class AgentMain {
try {
shutdown();
} catch (Throwable t) {
- LOG.error(t, "The plugin container has requested the agent be restarted but the shutdown " +
- "operation failed.");
+ LOG.error(t, "The plugin container has requested the agent be restarted but the shutdown "
+ + "operation failed.");
}
if (isStarted()) {
// Pause for a few seconds and try to shut down one more time.
@@ -1677,44 +1677,44 @@ public class AgentMain {
Thread.sleep(3000);
shutdown();
} catch (Throwable t) {
- LOG.error(t, "The plugin container has requested the agent be restarted but the shutdown " +
- "operation failed again.");
+ LOG.error(t, "The plugin container has requested the agent be restarted but the shutdown "
+ + "operation failed again.");
}
}
if (isStarted()) {
// At this point agent shut down failed twice. We can get by with rebooting the plugin container
// so we will try that as last ditch effort.
- LOG.warn("The agent shut down operation has failed twice. Attempting to reboot the plugin " +
- "container so that stale resource types and deleted plugins are removed.");
+ LOG.warn("The agent shut down operation has failed twice. Attempting to reboot the plugin "
+ + "container so that stale resource types and deleted plugins are removed.");
try {
rebootPluginContainer();
} catch (Throwable t) {
// If rebooting the plugin container fails as well, there is not much else we can do besides
// reporting the failures. Manual intervention is needed.
- LOG.error("The agent could not be shut down and rebooting the plugin container failed. " +
- "Please check the logs for errors and manually restart the agent as soon as " +
- "possible.");
+ LOG.error("The agent could not be shut down and rebooting the plugin container failed. "
+ + "Please check the logs for errors and manually restart the agent as soon as "
+ + "possible.");
return;
}
} else {
try {
cleanDataDirectory();
} catch (Throwable t) {
- LOG.warn(t, "The plugin container has requested the agent be restarted but purging the " +
- "data directory failed.");
+ LOG.warn(t, "The plugin container has requested the agent be restarted but purging the "
+ + "data directory failed.");
}
try {
start();
} catch (Throwable t) {
- LOG.warn(t, "An error occurred while trying to restart the agent. Attempting restart " +
- "one more time");
+ LOG.warn(t, "An error occurred while trying to restart the agent. Attempting restart "
+ + "one more time");
try {
shutdown();
start();
} catch (Throwable t1) {
- LOG.error(t1, "Restarting the agent has failed. Please check the logs for errors and " +
- "manually restart the agent as soon as possible.");
+ LOG.error(t1, "Restarting the agent has failed. Please check the logs for errors and "
+ + "manually restart the agent as soon as possible.");
return;
}
}
@@ -2887,7 +2887,7 @@ public class AgentMain {
* @throws HelpException if help was requested and the agent should not be created
*/
private void processArguments(String[] args) throws Exception {
- String sopts = "-:hdlasntuD:i:o:c:p:e:";
+ String sopts = "-:hdlasntguD:i:o:c:p:e:";
LongOpt[] lopts = { new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
new LongOpt("input", LongOpt.REQUIRED_ARGUMENT, null, 'i'),
new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'),
commit efa84c45d1c5dc485d288662ec1e32f1e3a86d22
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jan 25 13:51:54 2011 -0500
test both purge and the "unmanaged root dir" feature.
diff --git a/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java b/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
index a969164..9f2c846 100644
--- a/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
+++ b/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
@@ -55,6 +55,8 @@ import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.pluginapi.bundle.BundleDeployRequest;
import org.rhq.core.pluginapi.bundle.BundleDeployResult;
import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
+import org.rhq.core.pluginapi.bundle.BundlePurgeRequest;
+import org.rhq.core.pluginapi.bundle.BundlePurgeResult;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.system.SystemInfoFactory;
import org.rhq.core.util.file.FileUtil;
@@ -165,7 +167,7 @@ public class AntBundlePluginComponentTest {
// test that the prop was replaced in raw file test.properties
Properties realizedProps = new Properties();
- realizedProps.load(new FileInputStream(new File(this.destDir, "config/test.properties")));
+ loadProperties(realizedProps, new FileInputStream(new File(this.destDir, "config/test.properties")));
assert customPropValue.equals(realizedProps.getProperty(customPropName)) : "didn't replace prop";
// test that the archive was extracted properly. These are the files in the archive:
@@ -279,7 +281,7 @@ public class AntBundlePluginComponentTest {
// test that the prop was replaced in raw file test.properties
Properties realizedProps = new Properties();
- realizedProps.load(new FileInputStream(new File(this.destDir, "config/test.properties")));
+ loadProperties(realizedProps, new FileInputStream(new File(this.destDir, "config/test.properties")));
assert customPropValue.equals(realizedProps.getProperty(customPropName)) : "didn't replace prop";
// test that the archive was extracted properly. These are the files in the archive:
@@ -364,15 +366,134 @@ public class AntBundlePluginComponentTest {
// test that the prop was replaced in test.properties
Properties realizedProps = new Properties();
- realizedProps.load(new FileInputStream(new File(this.destDir, "config/test.properties")));
+ loadProperties(realizedProps, new FileInputStream(new File(this.destDir, "config/test.properties")));
assert realPropValue.equals(realizedProps.getProperty("custom.prop1")) : "didn't replace prop";
// test that the prop was not replaced in noreplace.properties
Properties notrealizedProps = new Properties();
- notrealizedProps.load(new FileInputStream(new File(this.destDir, "config/noreplace.properties")));
+ loadProperties(notrealizedProps, new FileInputStream(new File(this.destDir, "config/noreplace.properties")));
assert "@@custom.prop1(a)@".equals(notrealizedProps.getProperty("custom.prop1")) : "replaced prop when it shouldn't";
}
+ /**
+ * Test deployment of an RHQ bundle recipe where the deploy directory is not to be fully managed.
+ */
+ @Test(enabled = true)
+ public void testAntBundleNoManageRootDir() throws Exception {
+ ResourceType resourceType = new ResourceType("testNoManageRootDirBundle", "plugin", ResourceCategory.SERVER,
+ null);
+ BundleType bundleType = new BundleType("testNoManageRootDirBundle", resourceType);
+ Repo repo = new Repo("testNoManageRootDirBundle");
+ PackageType packageType = new PackageType("testNoManageRootDirBundle", resourceType);
+ Bundle bundle = new Bundle("testNoManageRootDirBundle", bundleType, repo, packageType);
+ BundleVersion bundleVersion = new BundleVersion("testNoManageRootDirBundle", "1.0", bundle,
+ getRecipeFromFile("test-bundle-no-manage-root-dir.xml"));
+ BundleDestination destination = new BundleDestination(bundle, "testNoManageRootDirBundle", new ResourceGroup(
+ "testNoManageRootDirBundle"), this.destDir.getAbsolutePath());
+ Configuration config = new Configuration();
+
+ BundleDeployment deployment = new BundleDeployment();
+ deployment.setName("test bundle deployment name");
+ deployment.setBundleVersion(bundleVersion);
+ deployment.setConfiguration(config);
+ deployment.setDestination(destination);
+
+ // create bundle test files
+ File file0 = new File(this.bundleFilesDir, "zero.properties");
+ Properties props = new Properties();
+ props.setProperty("zero", "0");
+ FileOutputStream outputStream = new FileOutputStream(file0);
+ props.store(outputStream, "zero file");
+ outputStream.close();
+
+ File file1 = new File(this.bundleFilesDir, "one.properties");
+ props.clear();
+ props.setProperty("one", "1");
+ outputStream = new FileOutputStream(file1);
+ props.store(outputStream, "one file");
+ outputStream.close();
+
+ File file2 = new File(this.bundleFilesDir, "two.properties");
+ props.clear();
+ props.setProperty("two", "2");
+ outputStream = new FileOutputStream(file2);
+ props.store(outputStream, "two file");
+ outputStream.close();
+
+ // create some external test files that don't belong to the bundle but are in the dest dir (which is not fully managed by the bundle)
+ this.destDir.mkdirs();
+ File external1 = new File(this.destDir, "external1.properties");
+ props.clear();
+ props.setProperty("external1", "1");
+ outputStream = new FileOutputStream(external1);
+ props.store(outputStream, "external1 file");
+ outputStream.close();
+
+ File external2 = new File(this.destDir, "extdir/external2.properties");
+ external2.getParentFile().mkdirs();
+ props.clear();
+ props.setProperty("external2", "2");
+ outputStream = new FileOutputStream(external2);
+ props.store(outputStream, "external2 file");
+ outputStream.close();
+
+ // deploy the bundle
+ BundleDeployRequest request = new BundleDeployRequest();
+ request.setBundleFilesLocation(this.bundleFilesDir);
+ request.setResourceDeployment(new BundleResourceDeployment(deployment, null));
+ request.setBundleManagerProvider(new MockBundleManagerProvider());
+
+ BundleDeployResult results = plugin.deployBundle(request);
+
+ assertResultsSuccess(results);
+
+ // test that files were deployed in the proper place
+ props.clear();
+ loadProperties(props, new FileInputStream(new File(this.destDir, "zero.properties")));
+ assert "0".equals(props.getProperty("zero")) : "did not deploy bundle correctly 0";
+ loadProperties(props, new FileInputStream(new File(this.destDir, "subdir1/one.properties")));
+ assert "1".equals(props.getProperty("one")) : "did not deploy bundle correctly 1";
+ loadProperties(props, new FileInputStream(new File(this.destDir, "subdir2/two.properties")));
+ assert "2".equals(props.getProperty("two")) : "did not deploy bundle correctly 2";
+
+ DeploymentsMetadata metadata = new DeploymentsMetadata(this.destDir);
+ assert metadata.isManaged() == true : "missing metadata directory";
+ assert metadata.getCurrentDeploymentProperties().getManageRootDir() == false : "should not be managing root dir";
+
+ // make sure our unmanaged files/directories weren't removed
+ props.clear();
+ loadProperties(props, new FileInputStream(new File(this.destDir, "external1.properties")));
+ assert "1".equals(props.getProperty("external1")) : "bundle deployment removed our unmanaged file 1";
+ loadProperties(props, new FileInputStream(new File(this.destDir, "extdir/external2.properties")));
+ assert "2".equals(props.getProperty("external2")) : "bundle deployment removed our unmanaged file 2";
+
+ // now purge the bundle - this should only purge those files that were laid down by the bundle plus the metadata directory
+ BundlePurgeRequest purgeRequest = new BundlePurgeRequest();
+ purgeRequest.setLiveResourceDeployment(new BundleResourceDeployment(deployment, null));
+ purgeRequest.setBundleManagerProvider(new MockBundleManagerProvider());
+
+ BundlePurgeResult purgeResults = plugin.purgeBundle(purgeRequest);
+ assertResultsSuccess(purgeResults);
+
+ // make sure our bundle files have been completely purged; the metadata directory should have been purged too
+ assert new File(this.destDir, "zero.properties").exists() == false;
+ assert new File(this.destDir, "subdir1/one.properties").exists() == false;
+ assert new File(this.destDir, "subdir2/two.properties").exists() == false;
+ assert new File(this.destDir, "subdir1").exists() == false;
+ assert new File(this.destDir, "subdir2").exists() == false;
+ assert this.destDir.exists() == true : "deploy dir should still exist, we were told not to fully manage it";
+
+ metadata = new DeploymentsMetadata(this.destDir);
+ assert metadata.getMetadataDirectory().exists() == false : "metadata directory should not exist";
+
+ // make sure our external, unmanaged files still exist - the purge should not have deleted these
+ props.clear();
+ loadProperties(props, new FileInputStream(new File(this.destDir, "external1.properties")));
+ assert "1".equals(props.getProperty("external1")) : "bundle purge removed our unmanaged file 1";
+ loadProperties(props, new FileInputStream(new File(this.destDir, "extdir/external2.properties")));
+ assert "2".equals(props.getProperty("external2")) : "bundle purge removed our unmanaged file 2";
+ }
+
private void upgrade(boolean clean) throws Exception {
testAntBundleInitialInstall(); // install a bundle first
cleanPluginDirs(); // clean everything but the dest dir - we want to upgrade the destination
@@ -441,7 +562,7 @@ public class AntBundlePluginComponentTest {
// test that the prop was replaced in raw file test.properties
Properties realizedProps = new Properties();
- realizedProps.load(new FileInputStream(new File(this.destDir, "config/test.properties")));
+ loadProperties(realizedProps, new FileInputStream(new File(this.destDir, "config/test.properties")));
assert customPropValue.equals(realizedProps.getProperty(customPropName)) : "didn't replace prop";
// test that the archive was extracted properly. These are the files in the archive or removed from original:
@@ -499,6 +620,11 @@ public class AntBundlePluginComponentTest {
assert results.isSuccess() : "Failed to process bundle!: [" + results.getErrorMessage() + "]";
}
+ private void assertResultsSuccess(BundlePurgeResult results) {
+ assert (results.getErrorMessage() == null) : "Failed to purge bundle: [" + results.getErrorMessage() + "]";
+ assert results.isSuccess() : "Failed to purge bundle!: [" + results.getErrorMessage() + "]";
+ }
+
private String getRecipeFromFile(String filename) {
InputStream stream = getClass().getClassLoader().getResourceAsStream(filename);
@@ -510,6 +636,14 @@ public class AntBundlePluginComponentTest {
return new String(StreamUtil.slurp(new FileInputStream(file)));
}
+ private void loadProperties(Properties realizedProps, FileInputStream fileInputStream) throws Exception {
+ try {
+ realizedProps.load(fileInputStream);
+ } finally {
+ fileInputStream.close();
+ }
+ }
+
private class MockBundleManagerProvider implements BundleManagerProvider {
public void auditDeployment(BundleResourceDeployment deployment, String action, String info,
BundleResourceDeploymentHistory.Category category, BundleResourceDeploymentHistory.Status status,
diff --git a/modules/plugins/ant-bundle/src/test/resources/test-bundle-no-manage-root-dir.xml b/modules/plugins/ant-bundle/src/test/resources/test-bundle-no-manage-root-dir.xml
new file mode 100644
index 0000000..6b20bf2
--- /dev/null
+++ b/modules/plugins/ant-bundle/src/test/resources/test-bundle-no-manage-root-dir.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+
+<project name="simple-build" default="main"
+ xmlns:rhq="antlib:org.rhq.bundle">
+
+ <rhq:bundle name="testNoManageRootDirBundle" version="1.0">
+ <rhq:deployment-unit name="simulated-war" manageRootDir="false">
+ <rhq:file name="zero.properties" destinationFile="zero.properties"/>
+ <rhq:file name="one.properties" destinationFile="subdir1/one.properties"/>
+ <rhq:file name="two.properties" destinationFile="subdir2/two.properties"/>
+ </rhq:deployment-unit>
+ </rhq:bundle>
+
+ <target name="main"/>
+
+</project>
\ No newline at end of file
commit 83d54210f5f40c2a0d9c66dc175327beb6af2360
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jan 25 12:23:57 2011 -0500
test the new manage root dir prop
diff --git a/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java b/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
index ae06f0d..a969164 100644
--- a/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
+++ b/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
@@ -199,6 +199,7 @@ public class AntBundlePluginComponentTest {
assert deploymentProps.getDeploymentId() == deployment.getId();
assert deploymentProps.getBundleName().equals(bundle.getName());
assert deploymentProps.getBundleVersion().equals(bundleVersion.getVersion());
+ assert deploymentProps.getManageRootDir() == true;
DeploymentProperties currentProps = metadata.getCurrentDeploymentProperties();
assert deploymentProps.equals(currentProps);
@@ -300,6 +301,7 @@ public class AntBundlePluginComponentTest {
assert deploymentProps.getDeploymentId() == deployment.getId();
assert deploymentProps.getBundleName().equals(bundle.getName());
assert deploymentProps.getBundleVersion().equals(bundleVersion.getVersion());
+ assert deploymentProps.getManageRootDir() == true;
DeploymentProperties currentProps = metadata.getCurrentDeploymentProperties();
assert deploymentProps.equals(currentProps);
DeploymentProperties previousProps = metadata.getPreviousDeploymentProperties(deployment.getId());
@@ -471,6 +473,7 @@ public class AntBundlePluginComponentTest {
assert deploymentProps.getDeploymentId() == deployment.getId();
assert deploymentProps.getBundleName().equals(bundle.getName());
assert deploymentProps.getBundleVersion().equals(bundleVersion.getVersion());
+ assert deploymentProps.getManageRootDir() == true;
DeploymentProperties currentProps = metadata.getCurrentDeploymentProperties();
assert deploymentProps.equals(currentProps);
@@ -488,6 +491,7 @@ public class AntBundlePluginComponentTest {
assert previousProps.getDeploymentId() == 123 : "bad previous deployment metadata"; // testAntBundleInitialInstall used 123
assert previousProps.getBundleName().equals(deploymentProps.getBundleName());
assert previousProps.getBundleVersion().equals("2.5"); // testAntBundleInitialInstall deployed version 2.5
+ assert previousProps.getManageRootDir() == true;
}
private void assertResultsSuccess(BundleDeployResult results) {
commit a4c5c2432c68c27ecc43abfb0352cd47408ca02e
Merge: a71b855... f149eac...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jan 25 15:13:53 2011 +0100
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit a71b855a4c26a94114e583b2639fff36450948ed
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jan 25 15:13:16 2011 +0100
Better mark that the resource in parens is the parent.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
index 25b5394..42600be 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
@@ -542,7 +542,7 @@ public class StandaloneContainer {
Set<Resource> resources = getResources();
for (Resource res : resources) {
if (res.getName().matches(pattern)) {
- System.out.println(res.getId() + ": " + res.getName() + " ( " + res.getParentResource() + " )");
+ System.out.println(res.getId() + ": " + res.getName() + " (parent= " + res.getParentResource() + " )");
dollarR = res.getId();
}
}
commit 3ff9c793cc2b0052c531acee6f2438434c8573dd
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Jan 25 12:26:32 2011 +0100
CliSender implemented. Not so much the supporting infrastructure around it.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
index 5c84c62..c329527 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
@@ -53,7 +53,8 @@ public class AlertDefinitionCriteria extends Criteria {
private List<Integer> filterResourceGroupIds; // requires overrides
private Boolean filterEnabled;
private Boolean filterDeleted = false; // find enabled definitions by default
-
+ private List<String> filterNotificationSenderNames;
+
private boolean fetchAlerts;
private boolean fetchGroupAlertDefinition;
private boolean fetchConditions;
@@ -62,12 +63,13 @@ public class AlertDefinitionCriteria extends Criteria {
private PageOrdering sortName;
private PageOrdering sortPriority;
- public AlertDefinitionCriteria() {
+ public AlertDefinitionCriteria() {
filterOverrides.put("alertTemplateParentId", "parentId = ?");
filterOverrides.put("alertTemplateResourceTypeId", "resourceType.id = ?");
filterOverrides.put("alertTemplateResourceTypeName", "resourceType.name like ?");
filterOverrides.put("resourceIds", "resource.id IN ( ? )");
filterOverrides.put("resourceGroupIds", "resourceGroup.id IN ( ? )");
+ filterOverrides.put("notificationSenderNames", "alertNotifications.senderName IN ( ? )");
}
@Override
@@ -119,6 +121,11 @@ public class AlertDefinitionCriteria extends Criteria {
this.filterDeleted = filterDeleted;
}
+ public void addFilterNotificationNames(String... notificationNames) {
+ fetchAlertNotifications(true);
+ this.filterNotificationSenderNames = Arrays.asList(notificationNames);
+ }
+
public void fetchAlerts(boolean fetchAlerts) {
this.fetchAlerts = fetchAlerts;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
index 03aba63..c5507cb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
@@ -707,7 +707,6 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
return queryRunner.execute();
}
- @Override
public String[] getAlertNotificationConfigurationPreview(Subject sessionSubject, AlertNotification[] notifications) {
if (notifications == null || notifications.length == 0) {
return new String[0];
diff --git a/modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliSender.java b/modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliSender.java
index 61d795a..b094beb 100644
--- a/modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliSender.java
+++ b/modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliSender.java
@@ -20,12 +20,17 @@
package org.rhq.enterprise.server.plugins.alertCli;
import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
+import java.io.PrintWriter;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
import java.util.Collections;
import javax.script.ScriptEngine;
@@ -42,6 +47,7 @@ import org.rhq.core.domain.alert.notification.SenderResult;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.content.PackageVersion;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.client.LocalClient;
import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
@@ -54,15 +60,21 @@ import org.rhq.enterprise.server.util.LookupUtil;
* @author Lukas Krejci
*/
public class CliSender extends AlertSender<ServerPluginComponent> {
+
+ public static final String PROP_PACKAGE_ID = "packageId";
+ public static final String PROP_USER_ID = "userId";
+
private static final Log LOG = LogFactory.getLog(CliSender.class);
public SenderResult send(Alert alert) {
SenderResult result = new SenderResult();
BufferedReader reader = null;
try {
- ScriptEngine engine = getScriptEngine(alert);
+ ByteArrayOutputStream scriptOutputStream = new ByteArrayOutputStream();
+
+ ScriptEngine engine = getScriptEngine(alert, scriptOutputStream);
- PropertySimple packageIdProp = alertParameters.getSimple("packageId");
+ PropertySimple packageIdProp = alertParameters.getSimple(PROP_PACKAGE_ID);
if (packageIdProp == null) {
return SenderResult
@@ -79,14 +91,19 @@ public class CliSender extends AlertSender<ServerPluginComponent> {
reader = new BufferedReader(new InputStreamReader(packageBits));
- Object ret = engine.eval(reader);
-
- //TODO what to do with the return value, if any
+ engine.eval(reader);
+ String scriptOutput = scriptOutputStream.toString(Charset.defaultCharset().name());
+
+ result.setSummary(scriptOutput);
+
+ result.addSuccessMessage("The script executed successfully. Its output is stored in the summary.");
+
return result;
- } catch (Exception e) {
- //TODO I don't like this
+ } catch (IllegalArgumentException e) {
return SenderResult.getSimpleFailure(e.getMessage());
+ } catch (Exception e) {
+ return SenderResult.getSimpleFailure(ThrowableUtil.getAllMessages(e));
} finally {
if (reader != null) {
try {
@@ -98,13 +115,19 @@ public class CliSender extends AlertSender<ServerPluginComponent> {
}
}
- private ScriptEngine getScriptEngine(Alert alert) throws ScriptException, IOException {
- Subject overlord = LookupUtil.getSubjectManager().getOverlord();
-
- LocalClient client = new LocalClient(overlord);
+ private ScriptEngine getScriptEngine(Alert alert, OutputStream scriptOutput) throws ScriptException, IOException, IllegalArgumentException {
+ int userId = alertParameters.getSimple(PROP_USER_ID).getIntegerValue();
+
+ Subject user = LookupUtil.getSubjectManager().getSubjectById(userId);
+
+ if (user == null) {
+ throw new IllegalArgumentException("The script cannot run because the user (id " + userId + ") configured to run it doesn't exist anymore.");
+ }
+
+ LocalClient client = new LocalClient(user);
- //TODO define some meaningful printwriter
- StandardBindings bindings = new StandardBindings(null, client);
+ PrintWriter output = new PrintWriter(scriptOutput);
+ StandardBindings bindings = new StandardBindings(output, client);
bindings.put("alert", alert);
return ScriptEngineFactory.getScriptEngine("JavaScript", new PackageFinder(Collections.<File> emptyList()),
diff --git a/modules/enterprise/server/plugins/alert-cli/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/alert-cli/src/main/resources/META-INF/rhq-serverplugin.xml
index ffcbb4b..6408c88 100644
--- a/modules/enterprise/server/plugins/alert-cli/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/alert-cli/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -22,5 +22,6 @@
<alert-configuration>
<c:simple-property name="packageId" type="integer" required="true" description="The id of the package containing the script to execute."/>
+ <c:simple-property name="userId" type="integer" required="true" description="The user the script will be run as."/>
</alert-configuration>
</alert-plugin>
\ No newline at end of file
commit b8e6d9bb7c056043ce828b6d11acf9964ef036b5
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Jan 25 12:08:06 2011 +0100
moving OSGiVersionComparator from core-util to core-domain so that GWT compilation has access to its source.
This is not ideal, because logically the OSGiVersionComparator should belong to just util, but in order to support
the GWT compilation, we'd have to create a whole new GWT module from core-util just because of this single class that
doesn't seem to be used anywhere else anyway.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageVersion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageVersion.java
index 8d2b9b4..8b7735d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageVersion.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageVersion.java
@@ -47,7 +47,7 @@ import org.hibernate.annotations.NamedQuery;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.resource.ProductVersion;
-import org.rhq.core.util.OSGiVersionComparator;
+import org.rhq.core.domain.util.OSGiVersionComparator;
/**
* Represents a specific version of a {@link Package}. This does <i>not</i> represent an installed package found
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/OSGiVersionComparator.java b/modules/core/domain/src/main/java/org/rhq/core/domain/util/OSGiVersionComparator.java
new file mode 100644
index 0000000..1f3936d
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/OSGiVersionComparator.java
@@ -0,0 +1,94 @@
+ /*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.util;
+
+import java.util.Comparator;
+
+/**
+ * The specification for what makes up an OSGi compliant version string and how they can be compared was taken from
+ * here:
+ * http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse.platform.doc....
+ *
+ * @author Charles Crouch
+ *
+ */
+public class OSGiVersionComparator implements Comparator<String> {
+ public OSGiVersionComparator() {
+ }
+
+ public int compare(String string1, String string2) {
+ Version ver1 = new Version(string1);
+ Version ver2 = new Version(string2);
+
+ int result = ver1.major - ver2.major;
+ if (result == 0) {
+ result = ver1.minor - ver2.minor;
+ if (result == 0) {
+ result = ver1.micro - ver2.micro;
+ if (result == 0) {
+ result = ver1.qualifier.compareTo(ver2.qualifier);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private class Version {
+ int major;
+ int minor;
+ int micro;
+ String qualifier = "";
+
+ Version(String version) {
+ String[] parts = version.split("\\.");
+
+ try {
+ switch (parts.length) {
+ case 4: {
+ qualifier = parts[3];
+ }
+
+ case 3: {
+ micro = Integer.parseInt(parts[2]);
+ }
+
+ case 2: {
+ minor = Integer.parseInt(parts[1]);
+ }
+
+ case 1: {
+ major = Integer.parseInt(parts[0]);
+ break;
+ }
+
+ default: {
+ throw new IllegalArgumentException("Malformed version string [" + version + "]");
+ }
+ }
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("Malformed version string [" + version + "]");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/util/OSGiVersionComparatorTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/util/OSGiVersionComparatorTest.java
new file mode 100644
index 0000000..d5959ea
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/util/OSGiVersionComparatorTest.java
@@ -0,0 +1,82 @@
+ /*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.util;
+
+import org.rhq.core.domain.util.OSGiVersionComparator;
+
+import junit.framework.TestCase;
+
+public class OSGiVersionComparatorTest extends TestCase {
+ public OSGiVersionComparatorTest(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*
+ * Test method for 'net.hyperic.hq.ui.action.resource.common.patch.JBossONVersionComparator.compare(Object, Object)'
+ */
+ public void testCompare() {
+ OSGiVersionComparator comparator = new OSGiVersionComparator();
+
+ assertTrue("1.2 > 1.1", comparator.compare("1.2", "1.1") > 0);
+ assertTrue("1.1 < 1.2", comparator.compare("1.1", "1.2") < 0);
+ assertTrue("1.0 = 1.0", comparator.compare("1.0", "1.0") == 0);
+ assertTrue("9.9 < 9.22", comparator.compare("9.9", "9.22") < 0);
+ assertTrue("9.9 < 10.2", comparator.compare("9.9", "10.2") < 0);
+ assertTrue("9 < 10", comparator.compare("9", "10") < 0);
+ assertTrue("1.2.13.BETA > 1.2.13.ALPHA", comparator.compare("1.2.13.BETA", "1.2.13.ALPHA") > 0);
+ assertTrue("4.0.4.GA_CP_2006_06 > 4.0.4.GA", comparator.compare("4.0.4.GA_CP_2006_06", "4.0.4.GA") > 0);
+ }
+
+ public void testInvalidComparisons() {
+ OSGiVersionComparator comparator = new OSGiVersionComparator();
+ try {
+ assertTrue("EA > 1.2", comparator.compare("EA", "1.2") > 0);
+ fail("Should have thrown an IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ }
+
+ ;
+ try {
+ assertTrue("1.2.alpha < 1.2.beta", comparator.compare("1.2.alpha", "1.2.beta") < 0);
+ fail("Should have thrown an IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ }
+
+ ;
+ try {
+ assertTrue("1.2.3.4.5 < 1.2.3.4.6", comparator.compare("1.2.3.4.5", "1.2.3.4.6") < 0);
+ fail("Should have thrown an IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ }
+
+ ;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/OSGiVersionComparator.java b/modules/core/util/src/main/java/org/rhq/core/util/OSGiVersionComparator.java
deleted file mode 100644
index 0b6a30d..0000000
--- a/modules/core/util/src/main/java/org/rhq/core/util/OSGiVersionComparator.java
+++ /dev/null
@@ -1,94 +0,0 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.core.util;
-
-import java.util.Comparator;
-
-/**
- * The specification for what makes up an OSGi compliant version string and how they can be compared was taken from
- * here:
- * http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse.platform.doc....
- *
- * @author Charles Crouch
- *
- */
-public class OSGiVersionComparator implements Comparator<String> {
- public OSGiVersionComparator() {
- }
-
- public int compare(String string1, String string2) {
- Version ver1 = new Version(string1);
- Version ver2 = new Version(string2);
-
- int result = ver1.major - ver2.major;
- if (result == 0) {
- result = ver1.minor - ver2.minor;
- if (result == 0) {
- result = ver1.micro - ver2.micro;
- if (result == 0) {
- result = ver1.qualifier.compareTo(ver2.qualifier);
- }
- }
- }
-
- return result;
- }
-
- private class Version {
- int major;
- int minor;
- int micro;
- String qualifier = "";
-
- Version(String version) {
- String[] parts = version.split("\\.");
-
- try {
- switch (parts.length) {
- case 4: {
- qualifier = parts[3];
- }
-
- case 3: {
- micro = Integer.parseInt(parts[2]);
- }
-
- case 2: {
- minor = Integer.parseInt(parts[1]);
- }
-
- case 1: {
- major = Integer.parseInt(parts[0]);
- break;
- }
-
- default: {
- throw new IllegalArgumentException("Malformed version string [" + version + "]");
- }
- }
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException("Malformed version string [" + version + "]");
- }
- }
- }
-}
\ No newline at end of file
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/OSGiVersionComparatorTest.java b/modules/core/util/src/test/java/org/rhq/core/util/OSGiVersionComparatorTest.java
deleted file mode 100644
index dd108fc..0000000
--- a/modules/core/util/src/test/java/org/rhq/core/util/OSGiVersionComparatorTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.core.util;
-
-import junit.framework.TestCase;
-
-public class OSGiVersionComparatorTest extends TestCase {
- public OSGiVersionComparatorTest(String arg0) {
- super(arg0);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /*
- * Test method for 'net.hyperic.hq.ui.action.resource.common.patch.JBossONVersionComparator.compare(Object, Object)'
- */
- public void testCompare() {
- OSGiVersionComparator comparator = new OSGiVersionComparator();
-
- assertTrue("1.2 > 1.1", comparator.compare("1.2", "1.1") > 0);
- assertTrue("1.1 < 1.2", comparator.compare("1.1", "1.2") < 0);
- assertTrue("1.0 = 1.0", comparator.compare("1.0", "1.0") == 0);
- assertTrue("9.9 < 9.22", comparator.compare("9.9", "9.22") < 0);
- assertTrue("9.9 < 10.2", comparator.compare("9.9", "10.2") < 0);
- assertTrue("9 < 10", comparator.compare("9", "10") < 0);
- assertTrue("1.2.13.BETA > 1.2.13.ALPHA", comparator.compare("1.2.13.BETA", "1.2.13.ALPHA") > 0);
- assertTrue("4.0.4.GA_CP_2006_06 > 4.0.4.GA", comparator.compare("4.0.4.GA_CP_2006_06", "4.0.4.GA") > 0);
- }
-
- public void testInvalidComparisons() {
- OSGiVersionComparator comparator = new OSGiVersionComparator();
- try {
- assertTrue("EA > 1.2", comparator.compare("EA", "1.2") > 0);
- fail("Should have thrown an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
-
- ;
- try {
- assertTrue("1.2.alpha < 1.2.beta", comparator.compare("1.2.alpha", "1.2.beta") < 0);
- fail("Should have thrown an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
-
- ;
- try {
- assertTrue("1.2.3.4.5 < 1.2.3.4.6", comparator.compare("1.2.3.4.5", "1.2.3.4.6") < 0);
- fail("Should have thrown an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
-
- ;
- }
-}
\ No newline at end of file
commit 4979cf7f751b5fbf7559e3887c89e96516089f55
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Jan 25 12:05:22 2011 +0100
Package types can now exist independently of the resource types.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 2d8d1fc..76b00e9 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.102</db.schema.version>
+ <db.schema.version>2.103</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index dec8587..f262087 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -112,7 +112,7 @@
<column name="IS_CREATION_DATA" type="BOOLEAN" required="true"/>
<column name="SUPPORTS_ARCHITECTURE" type="BOOLEAN" required="true"/>
- <column name="RESOURCE_TYPE_ID" type="INTEGER" references="RHQ_RESOURCE_TYPE" required="true"/>
+ <column name="RESOURCE_TYPE_ID" type="INTEGER" references="RHQ_RESOURCE_TYPE" required="false"/>
<column name="DEPLOYMENT_CONFIG_DEF_ID" type="INTEGER" references="RHQ_CONFIG_DEF" required="false"/>
<column name="PACKAGE_EXTRA_CONFIG_ID" type="INTEGER" references="RHQ_CONFIG_DEF" required="false"/>
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 975c778..a5ef90a 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3296,6 +3296,10 @@
</schema-directSQL>
</schemaSpec>
+ <schemaSpec version="2.103">
+ <!-- package types no longer require to be coupled with a resource type. They can exist on their own. -->
+ <schema-alterColumn table="RHQ_PACKAGE_TYPE" column="RESOURCE_TYPE_ID" nullable="true"/>
+ </schemaSpec>
</dbupgrade>
</target>
</project>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
index 380a46f..c400bc6 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
@@ -129,7 +129,7 @@ public class PackageType implements Serializable {
@OneToMany(fetch = FetchType.LAZY, mappedBy = "packageType", cascade = { CascadeType.REMOVE })
private Set<Package> packages;
- @JoinColumn(name = "RESOURCE_TYPE_ID", referencedColumnName = "ID", nullable = false)
+ @JoinColumn(name = "RESOURCE_TYPE_ID", referencedColumnName = "ID", nullable = true)
@ManyToOne
@XmlTransient
private ResourceType resourceType;
@@ -289,7 +289,8 @@ public class PackageType implements Serializable {
/**
* The resource type that defined this package type. Resources of this resource type can have packages of this
- * package type installed on them.
+ * package type installed on them. This can be null if this package type only exists in support of some serverside-only
+ * functionality.
*/
public ResourceType getResourceType() {
return this.resourceType;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java
index 2431230..4052693 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java
@@ -1301,7 +1301,9 @@ public class ContentManagerBean implements ContentManagerLocal, ContentManagerRe
q.setParameter("packageTypeName", pv.getGeneralPackage().getPackageType().getName());
q.setParameter("architectureName", pv.getArchitecture().getName());
q.setParameter("version", pv.getVersion());
- q.setParameter("resourceTypeId", pv.getGeneralPackage().getPackageType().getResourceType().getId());
+
+ ResourceType rt = pv.getGeneralPackage().getPackageType().getResourceType();
+ q.setParameter("resourceTypeId", rt != null ? rt.getId() : null);
List<PackageVersion> found = q.getResultList();
if (error != null && found.size() == 0) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java
index 3670ea2..a9fae13 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java
@@ -1616,26 +1616,29 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
ContentProviderPackageDetailsKey key = newDetails.getContentProviderPackageDetailsKey();
// find the new package's associated resource type (should already exist)
- ResourceType rt = new ResourceType();
- rt.setName(key.getResourceTypeName());
- rt.setPlugin(key.getResourceTypePluginName());
+ ResourceType rt = null;
+ if (key.getResourceTypeName() != null && key.getResourceTypePluginName() != null) {
+ rt = new ResourceType();
+ rt.setName(key.getResourceTypeName());
+ rt.setPlugin(key.getResourceTypePluginName());
- if (!knownResourceTypes.containsKey(rt)) {
- q = entityManager.createNamedQuery(ResourceType.QUERY_FIND_BY_NAME_AND_PLUGIN);
- q.setParameter("name", rt.getName());
- q.setParameter("plugin", rt.getPlugin());
+ if (!knownResourceTypes.containsKey(rt)) {
+ q = entityManager.createNamedQuery(ResourceType.QUERY_FIND_BY_NAME_AND_PLUGIN);
+ q.setParameter("name", rt.getName());
+ q.setParameter("plugin", rt.getPlugin());
- try {
- rt = (ResourceType) q.getSingleResult();
- knownResourceTypes.put(rt, rt); // cache it so we don't have to keep querying the DB
- knownProductVersions.put(rt, new HashMap<String, ProductVersion>());
- } catch (NoResultException nre) {
- log.warn("Content source adapter found a package for an unknown resource type ["
- + key.getResourceTypeName() + "|" + key.getResourceTypePluginName() + "] Skipping it.");
- continue; // skip this one but move on to the next
- }
- } else {
- rt = knownResourceTypes.get(rt);
+ try {
+ rt = (ResourceType) q.getSingleResult();
+ knownResourceTypes.put(rt, rt); // cache it so we don't have to keep querying the DB
+ knownProductVersions.put(rt, new HashMap<String, ProductVersion>());
+ } catch (NoResultException nre) {
+ log.warn("Content source adapter found a package for an unknown resource type ["
+ + key.getResourceTypeName() + "|" + key.getResourceTypePluginName() + "] Skipping it.");
+ continue; // skip this one but move on to the next
+ }
+ } else {
+ rt = knownResourceTypes.get(rt);
+ }
}
// find the new package's type (package types should already exist, agent plugin descriptors define them)
@@ -1643,7 +1646,7 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
if (!knownPackageTypes.containsKey(pt)) {
q = entityManager.createNamedQuery(PackageType.QUERY_FIND_BY_RESOURCE_TYPE_ID_AND_NAME);
- q.setParameter("typeId", rt.getId());
+ q.setParameter("typeId", rt != null ? rt.getId() : null);
q.setParameter("name", pt.getName());
try {
@@ -1664,7 +1667,7 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
q = entityManager.createNamedQuery(Package.QUERY_FIND_BY_NAME_PKG_TYPE_RESOURCE_TYPE);
q.setParameter("name", newDetails.getName());
q.setParameter("packageTypeName", newDetails.getPackageTypeName());
- q.setParameter("resourceTypeId", rt.getId());
+ q.setParameter("resourceTypeId", rt != null ? rt.getId() : null);
Package pkg;
try {
pkg = (Package) q.getSingleResult();
@@ -1753,7 +1756,12 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
// For each resource version that is supported, make sure we have an entry for that in product version
Set<String> resourceVersions = newDetails.getResourceVersions();
- if (resourceVersions != null) {
+
+ // the check for null resource type shouldn't be necessary here because
+ // the package shouldn't declare any resource versions if it doesn't declare a resource type.
+ // Nevertheless, let's make that check just to prevent disasters caused by "malicious" content
+ // providers.
+ if (resourceVersions != null && rt != null) {
Map<String, ProductVersion> cachedProductVersions = knownProductVersions.get(rt); // we are guaranteed that this returns non-null
for (String version : resourceVersions) {
ProductVersion productVersion = cachedProductVersions.get(version);
@@ -1765,6 +1773,9 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
ProductVersionPackageVersion mapping = new ProductVersionPackageVersion(productVersion, pv);
entityManager.merge(mapping); // use merge just in case this mapping somehow already exists
}
+ } else if (resourceVersions != null) {
+ log.info("Misbehaving content provider detected. It declares resource versions " + resourceVersions
+ + " but no resource type in package " + newDetails + ".");
}
// now create the mapping between the package version and content source
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderPackageDetailsKey.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderPackageDetailsKey.java
index b6b2dac..c9cc00a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderPackageDetailsKey.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderPackageDetailsKey.java
@@ -54,22 +54,23 @@ public class ContentProviderPackageDetailsKey extends PackageDetailsKey {
}
/**
- * The name of the {@link ResourceType} that this package's type belongs to. All package types are defined and
+ * The name of the {@link ResourceType} that this package's type belongs to. Package types are usually defined and
* supported by a particular {@link ResourceType}, this name is part of the natural key of a resource type. See
* {@link #getResourceTypePluginName() plugin name} for the other part.
*
- * @return resource type name
+ * @return resource type name or null if the package type isn't tied to a resource type
*/
public String getResourceTypeName() {
return resourceTypeName;
}
/**
- * The name of the plugin that defined the {@link ResourceType} that this package's type belongs to. All package
- * types are defined and supported by a particular {@link ResourceType}, this plugin name is part of the natural key
+ * The name of the plugin that defined the {@link ResourceType} that this package's type belongs to. Package
+ * types are usually defined and supported by a particular {@link ResourceType}, this plugin name is part of the natural key
* of a resource type. See {@link #getResourceTypeName() resource type name} for the other part.
*
- * @return the name of the plugin that defines the resource type that defined the package type
+ * @return the name of the plugin that defines the resource type that defined the package type or null if the package
+ * type isn't tied to a resource type
*/
public String getResourceTypePluginName() {
return resourceTypePluginName;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java
index 48c26a3..a0c141a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java
@@ -239,10 +239,12 @@ public class PackageSourceSynchronizer {
PackageVersion pv = pvcs.getPackageVersionContentSourcePK().getPackageVersion();
org.rhq.core.domain.content.Package p = pv.getGeneralPackage();
ResourceType rt = p.getPackageType().getResourceType();
-
+ String resourceTypeName = rt != null ? rt.getName() : null;
+ String resourceTypePlugin = rt != null ? rt.getPlugin() : null;
+
ContentProviderPackageDetailsKey key;
key = new ContentProviderPackageDetailsKey(p.getName(), pv.getVersion(), p.getPackageType().getName(), pv
- .getArchitecture().getName(), rt.getName(), rt.getPlugin());
+ .getArchitecture().getName(), resourceTypeName, resourceTypePlugin);
ContentProviderPackageDetails details = new ContentProviderPackageDetails(key);
details.setClassification(pv.getGeneralPackage().getClassification());
commit f149eacf6233511341a81b1c6b67b8754217da2f
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jan 24 17:33:08 2011 -0500
don't blindly remove the full deploy dir if we were told not to fully manage the deploy dir
this is to support ear/war bundle deployment into a jboss-as deploy/ dir
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java
index 162ba4d..189c420 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java
@@ -102,6 +102,13 @@ public class DeploymentUnitType extends AbstractBundleType {
try {
boolean dryRun = getProject().isDryRun();
+ boolean willManageRootDir = Boolean.parseBoolean(this.manageRootDir);
+ File deployDir = getProject().getDeployDir();
+ TemplateEngine templateEngine = createTemplateEngine();
+ int deploymentId = getProject().getDeploymentId();
+ DeploymentProperties deploymentProps = new DeploymentProperties(deploymentId, getProject().getBundleName(),
+ getProject().getBundleVersion(), getProject().getBundleDescription());
+ deploymentProps.setManageRootDir(willManageRootDir);
if (this.preinstallTarget != null) {
getProject().auditLog(AuditStatus.SUCCESS, "Pre-Install Started", "The pre install target will start",
@@ -126,12 +133,6 @@ public class DeploymentUnitType extends AbstractBundleType {
"The pre install target has finished", null, null);
}
- int deploymentId = getProject().getDeploymentId();
- DeploymentProperties deploymentProps = new DeploymentProperties(deploymentId, getProject().getBundleName(),
- getProject().getBundleVersion(), getProject().getBundleDescription());
- File deployDir = getProject().getDeployDir();
- TemplateEngine templateEngine = createTemplateEngine();
-
boolean haveSomethingToDo = false;
if (!this.files.isEmpty()) {
haveSomethingToDo = true;
@@ -154,7 +155,6 @@ public class DeploymentUnitType extends AbstractBundleType {
"You must specify at least one file to deploy via nested file, archive, url-file, url-archive types in your recipe");
}
- boolean willManageRootDir = Boolean.parseBoolean(this.manageRootDir);
if (willManageRootDir) {
log("Managing the root directory of this deployment unit - unrelated files found will be removed",
Project.MSG_VERBOSE);
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentProperties.java b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentProperties.java
index c476988..3553413 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentProperties.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentProperties.java
@@ -34,11 +34,15 @@ import java.util.Properties;
public class DeploymentProperties extends Properties {
private static final long serialVersionUID = 1L;
+ // required properties that must always exist
private static final String DEPLOYMENT_ID = "deployment.id";
private static final String BUNDLE_NAME = "bundle.name";
private static final String BUNDLE_VERSION = "bundle.version";
private static final String BUNDLE_DESCRIPTION = "bundle.description";
+ // optional properties
+ private static final String MANAGE_ROOT_DIR = "manage.root.dir";
+
public static DeploymentProperties loadFromFile(File file) throws Exception {
DeploymentProperties props = new DeploymentProperties();
FileInputStream is = new FileInputStream(file);
@@ -190,4 +194,20 @@ public class DeploymentProperties extends Properties {
setProperty(BUNDLE_DESCRIPTION, description);
}
}
+
+ /**
+ * @return the flag to indicate if the entire root directory content is to be managed.
+ * If there is no property, this method returns a default of <code>true</code>
+ */
+ public boolean getManageRootDir() {
+ String str = getProperty(MANAGE_ROOT_DIR);
+ if (str == null) {
+ return true;
+ }
+ return Boolean.parseBoolean(str);
+ }
+
+ public void setManageRootDir(boolean willManageRootDir) {
+ setProperty(MANAGE_ROOT_DIR, Boolean.toString(willManageRootDir));
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
index 71d5e06..da52896 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
@@ -218,8 +218,9 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_bundle_dest_purgeSuccessful(destination.getName()),
Message.Severity.Info));
- // Bundle destination is purged, go back to bundle destinations root view
- CoreGUI.goToView(LinkManager.getBundleDestinationLink(bundle.getId(), 0), true);
+ // Bundle destination is purged, go back to bundle destination view
+ CoreGUI.goToView(LinkManager.getBundleDestinationLink(bundle.getId(), destination
+ .getId()), true);
}
});
}
diff --git a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
index 817b647..201d212 100644
--- a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
+++ b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
@@ -180,67 +180,118 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
String deployDirAbsolutePath = deployDir.getAbsolutePath();
BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();
+ boolean manageAllDeployDir = true;
+ boolean errorPurgingDeployDirContent = false;
+ File metadataDirectoryToPurge = null;
+
// If the receipe copied file(s) outside of the deployment directory (external, raw files), they will still exist.
// Let's get the metadata information that tells us if such files exist, and if so, remove them.
+ // Since we are iterating over the manage files anyway, let's also remove the files/subdirs under the deploy directory too.
DeploymentsMetadata metadata = new DeploymentsMetadata(deployDir);
if (metadata.isManaged()) {
+ metadataDirectoryToPurge = metadata.getMetadataDirectory();
+ manageAllDeployDir = metadata.getCurrentDeploymentProperties().getManageRootDir();
int totalExternalFiles = 0;
- ArrayList<String> deleteSuccesses = new ArrayList<String>(0);
- ArrayList<String> deleteFailures = new ArrayList<String>(0);
- FileHashcodeMap fileHashcodes = metadata.getCurrentDeploymentFileHashcodes();
- for (String filePath : fileHashcodes.keySet()) {
+ ArrayList<String> externalDeleteSuccesses = new ArrayList<String>(0);
+ ArrayList<String> externalDeleteFailures = new ArrayList<String>(0);
+ FileHashcodeMap deployDirFileHashcodes = metadata.getCurrentDeploymentFileHashcodes();
+ for (String filePath : deployDirFileHashcodes.keySet()) {
File file = new File(filePath);
if (file.isAbsolute()) {
totalExternalFiles++;
if (file.exists()) {
if (file.delete()) {
- deleteSuccesses.add(filePath);
+ externalDeleteSuccesses.add(filePath);
} else {
- deleteFailures.add(filePath);
+ externalDeleteFailures.add(filePath);
}
} else {
- deleteSuccesses.add(filePath); // someone already deleted it, consider it removed successfully
+ externalDeleteSuccesses.add(filePath); // someone already deleted it, consider it removed successfully
+ }
+ } else {
+ // a relative path means it is inside the deploy dir (i.e. its relative to deployDir).
+ // note that we only remove child directories and files that are direct children of the deploy dir itself;
+ // we do not purge the deploy dir itself, in case we are not managing the full deploy dir.
+ String parentDir = file.getParent();
+ if (parentDir == null) {
+ // this file is directly in the deploy dir
+ file = new File(deployDir, filePath);
+ file.delete();
+ } else {
+ // this file is under some subdirectory under the deploy dir - purge the subdirectory completely
+ file = new File(deployDir, parentDir);
+ FileUtil.purge(file, true);
+ }
+ if (file.exists()) {
+ errorPurgingDeployDirContent = true;
}
}
}
if (totalExternalFiles > 0) {
- if (!deleteSuccesses.isEmpty()) {
+ if (!externalDeleteSuccesses.isEmpty()) {
StringBuilder deleteSuccessesDetails = new StringBuilder();
- for (String path : deleteSuccesses) {
+ for (String path : externalDeleteSuccesses) {
deleteSuccessesDetails.append(path).append("\n");
}
bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge", "External files were purged",
- Category.AUDIT_MESSAGE, Status.SUCCESS, "[" + deleteSuccesses.size() + "] of ["
+ Category.AUDIT_MESSAGE, Status.SUCCESS, "[" + externalDeleteSuccesses.size() + "] of ["
+ totalExternalFiles
+ "] external files were purged. See attached details for the list",
deleteSuccessesDetails.toString());
}
- if (!deleteFailures.isEmpty()) {
+ if (!externalDeleteFailures.isEmpty()) {
StringBuilder deleteFailuresDetails = new StringBuilder();
- for (String path : deleteFailures) {
+ for (String path : externalDeleteFailures) {
deleteFailuresDetails.append(path).append("\n");
}
bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
"External files failed to be purged", Category.AUDIT_MESSAGE, Status.FAILURE, "["
- + deleteFailures.size() + "] of [" + totalExternalFiles
+ + externalDeleteFailures.size() + "] of [" + totalExternalFiles
+ "] external files failed to be purged. See attached details for the list",
deleteFailuresDetails.toString());
}
}
}
- // completely purge the deployment directory.
- FileUtil.purge(deployDir, true);
-
- if (!deployDir.exists()) {
- bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
- "The destination directory has been purged", Category.AUDIT_MESSAGE, Status.SUCCESS,
- "Directory purged: " + deployDirAbsolutePath, null);
+ // if we are managing the full deploy dir, completely purge the deployment directory.
+ // otherwise, just report that we deleted what we were responsible for.
+ if (manageAllDeployDir) {
+ FileUtil.purge(deployDir, true);
+ if (!deployDir.exists()) {
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "The destination directory has been purged", Category.AUDIT_MESSAGE, Status.SUCCESS,
+ "Directory purged: " + deployDirAbsolutePath, null);
+ } else {
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "The destination directory failed to be purged", Category.AUDIT_MESSAGE, Status.FAILURE,
+ "The directory that failed to be purged: " + deployDirAbsolutePath, null);
+ }
} else {
- bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
- "The destination directory failed to be purged", Category.AUDIT_MESSAGE, Status.FAILURE,
- "The directory that failed to be purged: " + deployDirAbsolutePath, null);
+ if (!errorPurgingDeployDirContent) {
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "The managed bundle content was removed from the destination directory; "
+ + "other unmanaged content may still remain", Category.AUDIT_MESSAGE, Status.SUCCESS,
+ "Deploy Directory: " + deployDirAbsolutePath, null);
+ } else {
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "Not all managed bundle content was able to be removed from the destination directory. "
+ + "That managed content along with other unmanaged content still remain",
+ Category.AUDIT_MESSAGE, Status.FAILURE, "Deploy Directory: " + deployDirAbsolutePath, null);
+ }
+
+ // make sure we remove the metadata directory, too - since it may still have sensitive files that were backed up
+ if (metadataDirectoryToPurge != null) {
+ FileUtil.purge(metadataDirectoryToPurge, true);
+ if (metadataDirectoryToPurge.exists()) {
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "Failed to purge the metadata directory from the destination directory. "
+ + "It may still contain backed up files from previous bundle deployments.",
+ Category.AUDIT_MESSAGE, Status.FAILURE, "Metadata Directory: "
+ + metadataDirectoryToPurge.getAbsolutePath(), null);
+ }
+ }
}
+
} catch (Throwable t) {
log.error("Failed to purge bundle [" + request + "]", t);
result.setErrorMessage(t);
commit aeac14f0fd67d08b39b33d6feeccb453a7ad5aa5
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Jan 24 22:35:38 2011 -0500
partial impl of group Operations>Schedule subtab
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
new file mode 100644
index 0000000..db32a81
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
@@ -0,0 +1,284 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010-2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * 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.common.detail.operation.schedule;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.TextAreaItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+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.components.form.AbstractRecordEditor;
+import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.components.trigger.JobTriggerEditor;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Ian Springer
+ */
+public abstract class AbstractOperationScheduleDetailsView extends AbstractRecordEditor {
+
+ private static final String FIELD_OPERATION_DESCRIPTION = "operationDescription";
+ private static final String FIELD_OPERATION_PARAMETERS = "operationParameters";
+
+ private Map<String, String> operationNameToDescriptionMap = new HashMap<String, String>();
+ private Map<String, ConfigurationDefinition> operationNameToParametersDefinitionMap =
+ new HashMap<String, ConfigurationDefinition>();
+ private StaticTextItem operationDescriptionItem;
+ private StaticTextItem operationParametersItem;
+ private LocatableHLayout operationParametersConfigurationHolder;
+ private JobTriggerEditor triggerEditor;
+ private Configuration parameters;
+ private EnhancedDynamicForm notesForm;
+
+ public AbstractOperationScheduleDetailsView(String locatorId, OperationScheduleDataSource dataSource,
+ ResourceType resourceType, int scheduleId) {
+ super(locatorId, dataSource, scheduleId, "Scheduled Operation", null);
+
+ Set<OperationDefinition> operationDefinitions = resourceType.getOperationDefinitions();
+ for (OperationDefinition operationDefinition : operationDefinitions) {
+ this.operationNameToDescriptionMap.put(operationDefinition.getName(), operationDefinition.getDescription());
+ this.operationNameToParametersDefinitionMap.put(operationDefinition.getName(),
+ operationDefinition.getParametersConfigurationDefinition());
+ }
+ }
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ super.renderView(viewPath);
+
+ // Existing schedules are not editable. This may change in the future.
+ boolean isReadOnly = (getRecordId() != 0);
+ init(isReadOnly);
+ }
+
+ @Override
+ protected List<FormItem> createFormItems(EnhancedDynamicForm form) {
+ List<FormItem> items = new ArrayList<FormItem>();
+
+ SelectItem operationNameItem = new SelectItem(ResourceOperationScheduleDataSource.Field.OPERATION_NAME);
+ items.add(operationNameItem);
+ operationNameItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ refreshOperationDescriptionItem();
+ refreshOperationParametersItem();
+ }
+ });
+
+ this.operationDescriptionItem = new StaticTextItem(FIELD_OPERATION_DESCRIPTION, "Operation Description");
+ items.add(this.operationDescriptionItem);
+
+ this.operationParametersItem = new StaticTextItem(FIELD_OPERATION_PARAMETERS, "Operation Parameters");
+ items.add(this.operationParametersItem);
+
+ return items;
+ }
+
+ @Override
+ protected LocatableVLayout buildContentPane() {
+ LocatableVLayout contentPane = super.buildContentPane();
+
+ this.operationParametersConfigurationHolder = new LocatableHLayout(extendLocatorId("ConfigHolder"));
+ this.operationParametersConfigurationHolder.setVisible(false);
+ contentPane.addMember(this.operationParametersConfigurationHolder);
+
+ HTMLFlow hr = new HTMLFlow("<p/><hr/><p/>");
+ contentPane.addMember(hr);
+
+ if (isNewRecord()) {
+ this.triggerEditor = new JobTriggerEditor(extendLocatorId("TriggerEditor"));
+ contentPane.addMember(this.triggerEditor);
+ hr = new HTMLFlow("<p/><hr/><p/>");
+ contentPane.addMember(hr);
+ }
+
+ this.notesForm = new EnhancedDynamicForm(extendLocatorId("NotesForm"), isReadOnly(),
+ isNewRecord());
+ this.notesForm.setWidth100();
+
+ List<FormItem> notesFields = new ArrayList<FormItem>();
+
+ if (!isNewRecord()) {
+ StaticTextItem nextFireTimeItem = new StaticTextItem(OperationScheduleDataSource.Field.NEXT_FIRE_TIME);
+ notesFields.add(nextFireTimeItem);
+ }
+
+ TextItem timeoutItem = new TextItem(OperationScheduleDataSource.Field.TIMEOUT, "Timeout (in seconds)");
+ notesFields.add(timeoutItem);
+
+ TextAreaItem notesItem = new TextAreaItem(ResourceOperationScheduleDataSource.Field.DESCRIPTION, "Notes");
+ notesItem.setWidth(450);
+ notesItem.setHeight(150);
+ notesFields.add(notesItem);
+
+ this.notesForm.setFields(notesFields.toArray(new FormItem[notesFields.size()]));
+
+ contentPane.addMember(this.notesForm);
+
+ return contentPane;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ refreshOperationDescriptionItem();
+ refreshOperationParametersItem();
+ }
+
+ @Override
+ protected String getTitleFieldName() {
+ return ResourceOperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME;
+ }
+
+ @Override
+ protected Record createNewRecord() {
+ Record record = super.createNewRecord();
+ Subject sessionSubject = UserSessionManager.getSessionSubject();
+ OperationScheduleDataSource.SubjectRecord subjectRecord =
+ new OperationScheduleDataSource.SubjectRecord(sessionSubject);
+ record.setAttribute(ResourceOperationScheduleDataSource.Field.SUBJECT, subjectRecord);
+ return record;
+ }
+
+ @Override
+ protected void editRecord(Record record) {
+ refreshOperationDescriptionItem();
+ refreshOperationParametersItem();
+
+ if (!isNewRecord()) {
+ FormItem nextFireTimeItem = this.notesForm.getField(ResourceOperationScheduleDataSource.Field.NEXT_FIRE_TIME);
+ nextFireTimeItem.setValue(getForm().getValue(ResourceOperationScheduleDataSource.Field.NEXT_FIRE_TIME));
+ }
+
+ FormItem notesItem = this.notesForm.getField(ResourceOperationScheduleDataSource.Field.DESCRIPTION);
+ notesItem.setValue(getForm().getValue(ResourceOperationScheduleDataSource.Field.DESCRIPTION));
+
+ super.editRecord(record);
+ }
+
+ @Override
+ protected void save(DSRequest requestProperties) {
+ requestProperties.setAttribute("parameters", this.parameters);
+
+ if (!this.triggerEditor.validate()) {
+ // TODO: print error Message
+ return;
+ }
+ EnhancedDynamicForm form = getForm();
+
+ Record jobTriggerRecord = new ListGridRecord();
+
+ Date startTime = this.triggerEditor.getStartTime();
+ jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.START_TIME, startTime);
+
+ Date endTime = this.triggerEditor.getEndTime();
+ jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.END_TIME, endTime);
+
+ Integer repeatCount = this.triggerEditor.getRepeatCount();
+ jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.REPEAT_COUNT, repeatCount);
+
+ Long repeatInterval = this.triggerEditor.getRepeatInterval();
+ jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.REPEAT_INTERVAL, repeatInterval);
+
+ String cronExpression = this.triggerEditor.getCronExpression();
+ jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.CRON_EXPRESSION, cronExpression);
+
+ form.setValue("jobTrigger", jobTriggerRecord);
+
+ FormItem notesItem = this.notesForm.getField(ResourceOperationScheduleDataSource.Field.DESCRIPTION);
+ form.setValue(ResourceOperationScheduleDataSource.Field.DESCRIPTION, (String)notesItem.getValue());
+
+ super.save(requestProperties);
+ }
+
+ private void refreshOperationDescriptionItem() {
+ String operationName = getSelectedOperationName();
+ String value;
+ if (operationName == null) {
+ value = "<i>Select an operation.</i>";
+ } else {
+ value = this.operationNameToDescriptionMap.get(operationName);
+ }
+ this.operationDescriptionItem.setValue(value);
+ }
+
+ private void refreshOperationParametersItem() {
+ String operationName = getSelectedOperationName();
+ String value;
+ if (operationName == null) {
+ value = "<i>Select an operation.</i>";
+ } else {
+ ConfigurationDefinition parametersDefinition = this.operationNameToParametersDefinitionMap.get(operationName);
+ if (parametersDefinition == null || parametersDefinition.getPropertyDefinitions().isEmpty()) {
+ value = "<i>" + MSG.view_operationCreateWizard_parametersStep_noParameters() + "</i>";
+
+ for (Canvas child : this.operationParametersConfigurationHolder.getChildren()) {
+ child.destroy();
+ }
+ this.operationParametersConfigurationHolder.hide();
+ } else {
+ value = isNewRecord() ? "<i>Enter parameters below...</i>" : "";
+
+ for (Canvas child : this.operationParametersConfigurationHolder.getChildren()) {
+ child.destroy();
+ }
+ Configuration defaultConfiguration = (parametersDefinition.getDefaultTemplate() != null) ?
+ parametersDefinition.getDefaultTemplate().createConfiguration() : new Configuration();
+ ConfigurationEditor configurationEditor = new ConfigurationEditor("ParametersEditor", parametersDefinition,
+ defaultConfiguration);
+ configurationEditor.setReadOnly(isReadOnly());
+ this.parameters = configurationEditor.getConfiguration();
+ this.operationParametersConfigurationHolder.addMember(configurationEditor);
+ this.operationParametersConfigurationHolder.show();
+ }
+ }
+ this.operationParametersItem.setValue(value);
+ }
+
+ private String getSelectedOperationName() {
+ FormItem operationNameItem = getForm().getField(ResourceOperationScheduleDataSource.Field.OPERATION_NAME);
+ return (String)operationNameItem.getValue();
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
index ec95731..3813b98 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
@@ -35,6 +35,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.bean.OperationSchedule;
import org.rhq.core.domain.resource.ResourceType;
@@ -57,6 +58,7 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
public static final String SUBJECT = "subject";
public static final String DESCRIPTION = "description";
public static final String NEXT_FIRE_TIME = "nextFireTime";
+ public static final String TIMEOUT = "timeout";
// job trigger fields
public static final String START_TIME = "startTime";
@@ -112,6 +114,10 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
DataSourceDateTimeField nextFireTimeField = new DataSourceDateTimeField(Field.NEXT_FIRE_TIME,
"Next Scheduled Execution");
nextFireTimeField.setCanEdit(false);
+ fields.add(nextFireTimeField);
+
+ DataSourceIntegerField timeoutField = createIntegerField(Field.TIMEOUT, "Timeout (in seconds)", 30, null, false);
+ fields.add(timeoutField);
return fields;
}
@@ -127,11 +133,15 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
to.setJobGroup(from.getAttribute(Field.JOB_GROUP));
SubjectRecord subjectRecord = (SubjectRecord) from.getAttributeAsRecord(Field.SUBJECT);
to.setSubject(subjectRecord.toSubject());
- to.setParameters((Configuration)from.getAttributeAsObject(Field.PARAMETERS));
+ Configuration parameters = (Configuration) from.getAttributeAsObject(Field.PARAMETERS);
+ to.setParameters(parameters);
to.setOperationName(from.getAttribute(Field.OPERATION_NAME));
to.setOperationDisplayName(from.getAttribute(Field.OPERATION_DISPLAY_NAME));
to.setDescription(from.getAttribute(Field.DESCRIPTION));
to.setNextFireTime(from.getAttributeAsDate(Field.NEXT_FIRE_TIME));
+ if (parameters != null) {
+ parameters.put(new PropertySimple(OperationDefinition.TIMEOUT_PARAM_NAME, from.getAttributeAsInt(Field.TIMEOUT)));
+ }
to.setJobTrigger(createJobTrigger(from.getAttributeAsRecord("jobTrigger")));
@@ -152,6 +162,7 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
to.setAttribute(Field.OPERATION_DISPLAY_NAME, from.getOperationDisplayName());
to.setAttribute(Field.DESCRIPTION, from.getDescription());
to.setAttribute(Field.NEXT_FIRE_TIME, from.getNextFireTime());
+ to.setAttribute(Field.TIMEOUT, from.getParameters().getSimpleValue(OperationDefinition.TIMEOUT_PARAM_NAME, null));
JobTrigger jobTrigger = from.getJobTrigger();
Record jobTriggerRecord = new ListGridRecord();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
deleted file mode 100644
index bc405b1..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2010-2011, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * 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.common.detail.operation.schedule;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.form.fields.TextAreaItem;
-import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
-import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
-
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
-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.components.form.AbstractRecordEditor;
-import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.components.trigger.JobTriggerEditor;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-
-/**
- * @author Ian Springer
- */
-public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
-
- private static final String FIELD_OPERATION_DESCRIPTION = "operationDescription";
- private static final String FIELD_OPERATION_PARAMETERS = "operationParameters";
-
- private ResourceComposite resourceComposite;
- private Map<String, String> operationNameToDescriptionMap = new HashMap<String, String>();
- private Map<String, ConfigurationDefinition> operationNameToParametersDefinitionMap =
- new HashMap<String, ConfigurationDefinition>();
- private StaticTextItem operationDescriptionItem;
- private StaticTextItem operationParametersItem;
- private LocatableHLayout operationParametersConfigurationHolder;
- private JobTriggerEditor triggerEditor;
- private Configuration parameters;
- private EnhancedDynamicForm notesForm;
-
- public ResourceOperationScheduleDetailsView(String locatorId, ResourceComposite resourceComposite, int scheduleId) {
- super(locatorId, new ResourceOperationScheduleDataSource(resourceComposite), scheduleId, "Scheduled Operation", null);
-
- this.resourceComposite = resourceComposite;
- ResourceType resourceType = this.resourceComposite.getResource().getResourceType();
- Set<OperationDefinition> operationDefinitions = resourceType.getOperationDefinitions();
- for (OperationDefinition operationDefinition : operationDefinitions) {
- this.operationNameToDescriptionMap.put(operationDefinition.getName(), operationDefinition.getDescription());
- this.operationNameToParametersDefinitionMap.put(operationDefinition.getName(),
- operationDefinition.getParametersConfigurationDefinition());
- }
- }
-
- @Override
- public void renderView(ViewPath viewPath) {
- super.renderView(viewPath);
-
- // Existing schedules are not editable. This may change in the future.
- boolean isReadOnly = (getRecordId() != 0);
- init(isReadOnly);
- }
-
- @Override
- protected List<FormItem> createFormItems(EnhancedDynamicForm form) {
- List<FormItem> items = new ArrayList<FormItem>();
-
- SelectItem operationNameItem = new SelectItem(ResourceOperationScheduleDataSource.Field.OPERATION_NAME);
- items.add(operationNameItem);
- operationNameItem.addChangedHandler(new ChangedHandler() {
- public void onChanged(ChangedEvent event) {
- refreshOperationDescriptionItem();
- refreshOperationParametersItem();
- }
- });
-
- this.operationDescriptionItem = new StaticTextItem(FIELD_OPERATION_DESCRIPTION, "Operation Description");
- items.add(this.operationDescriptionItem);
-
- this.operationParametersItem = new StaticTextItem(FIELD_OPERATION_PARAMETERS, "Operation Parameters");
- items.add(this.operationParametersItem);
-
- return items;
- }
-
- @Override
- protected LocatableVLayout buildContentPane() {
- LocatableVLayout contentPane = super.buildContentPane();
-
- this.operationParametersConfigurationHolder = new LocatableHLayout(extendLocatorId("ConfigHolder"));
- this.operationParametersConfigurationHolder.setVisible(false);
- contentPane.addMember(this.operationParametersConfigurationHolder);
-
- HTMLFlow hr = new HTMLFlow("<p/><hr/><p/>");
- contentPane.addMember(hr);
-
- if (isNewRecord()) {
- this.triggerEditor = new JobTriggerEditor(extendLocatorId("TriggerEditor"));
- contentPane.addMember(this.triggerEditor);
- hr = new HTMLFlow("<p/><hr/><p/>");
- contentPane.addMember(hr);
- }
-
- this.notesForm = new EnhancedDynamicForm(extendLocatorId("NotesForm"), isReadOnly(),
- isNewRecord());
- this.notesForm.setWidth100();
-
- List<FormItem> notesFields = new ArrayList<FormItem>();
-
- if (!isNewRecord()) {
- StaticTextItem nextFireTimeItem = new StaticTextItem(ResourceOperationScheduleDataSource.Field.NEXT_FIRE_TIME,
- "Next Scheduled Execution");
- notesFields.add(nextFireTimeItem);
- }
-
- TextAreaItem notesItem = new TextAreaItem(ResourceOperationScheduleDataSource.Field.DESCRIPTION, "Notes");
- notesItem.setWidth(450);
- notesItem.setHeight(150);
- notesFields.add(notesItem);
-
- this.notesForm.setFields(notesFields.toArray(new FormItem[notesFields.size()]));
-
- contentPane.addMember(this.notesForm);
-
- return contentPane;
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
- refreshOperationDescriptionItem();
- refreshOperationParametersItem();
- }
-
- @Override
- protected String getTitleFieldName() {
- return ResourceOperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME;
- }
-
- @Override
- protected Record createNewRecord() {
- Record record = super.createNewRecord();
- Subject sessionSubject = UserSessionManager.getSessionSubject();
- OperationScheduleDataSource.SubjectRecord subjectRecord =
- new OperationScheduleDataSource.SubjectRecord(sessionSubject);
- record.setAttribute(ResourceOperationScheduleDataSource.Field.SUBJECT, subjectRecord);
- return record;
- }
-
- @Override
- protected void editRecord(Record record) {
- refreshOperationDescriptionItem();
- refreshOperationParametersItem();
-
- if (!isNewRecord()) {
- FormItem nextFireTimeItem = this.notesForm.getField(ResourceOperationScheduleDataSource.Field.NEXT_FIRE_TIME);
- nextFireTimeItem.setValue(getForm().getValue(ResourceOperationScheduleDataSource.Field.NEXT_FIRE_TIME));
- }
-
- FormItem notesItem = this.notesForm.getField(ResourceOperationScheduleDataSource.Field.DESCRIPTION);
- notesItem.setValue(getForm().getValue(ResourceOperationScheduleDataSource.Field.DESCRIPTION));
-
- super.editRecord(record);
- }
-
- @Override
- protected void save(DSRequest requestProperties) {
- requestProperties.setAttribute("parameters", this.parameters);
-
- if (!this.triggerEditor.validate()) {
- // TODO: print error Message
- return;
- }
- EnhancedDynamicForm form = getForm();
-
- Record jobTriggerRecord = new ListGridRecord();
-
- Date startTime = this.triggerEditor.getStartTime();
- jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.START_TIME, startTime);
-
- Date endTime = this.triggerEditor.getEndTime();
- jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.END_TIME, endTime);
-
- Integer repeatCount = this.triggerEditor.getRepeatCount();
- jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.REPEAT_COUNT, repeatCount);
-
- Long repeatInterval = this.triggerEditor.getRepeatInterval();
- jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.REPEAT_INTERVAL, repeatInterval);
-
- String cronExpression = this.triggerEditor.getCronExpression();
- jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.CRON_EXPRESSION, cronExpression);
-
- form.setValue("jobTrigger", jobTriggerRecord);
-
- FormItem notesItem = this.notesForm.getField(ResourceOperationScheduleDataSource.Field.DESCRIPTION);
- form.setValue(ResourceOperationScheduleDataSource.Field.DESCRIPTION, (String)notesItem.getValue());
-
- super.save(requestProperties);
- }
-
- private void refreshOperationDescriptionItem() {
- String operationName = getSelectedOperationName();
- String value;
- if (operationName == null) {
- value = "<i>Select an operation.</i>";
- } else {
- value = this.operationNameToDescriptionMap.get(operationName);
- }
- this.operationDescriptionItem.setValue(value);
- }
-
- private void refreshOperationParametersItem() {
- String operationName = getSelectedOperationName();
- String value;
- if (operationName == null) {
- value = "<i>Select an operation.</i>";
- } else {
- ConfigurationDefinition parametersDefinition = this.operationNameToParametersDefinitionMap.get(operationName);
- if (parametersDefinition == null || parametersDefinition.getPropertyDefinitions().isEmpty()) {
- value = "<i>" + MSG.view_operationCreateWizard_parametersStep_noParameters() + "</i>";
-
- for (Canvas child : this.operationParametersConfigurationHolder.getChildren()) {
- child.destroy();
- }
- this.operationParametersConfigurationHolder.hide();
- } else {
- value = isNewRecord() ? "<i>Enter parameters below...</i>" : "";
-
- for (Canvas child : this.operationParametersConfigurationHolder.getChildren()) {
- child.destroy();
- }
- Configuration defaultConfiguration = (parametersDefinition.getDefaultTemplate() != null) ?
- parametersDefinition.getDefaultTemplate().createConfiguration() : new Configuration();
- ConfigurationEditor configurationEditor = new ConfigurationEditor("ParametersEditor", parametersDefinition,
- defaultConfiguration);
- configurationEditor.setReadOnly(isReadOnly());
- this.parameters = configurationEditor.getConfiguration();
- this.operationParametersConfigurationHolder.addMember(configurationEditor);
- this.operationParametersConfigurationHolder.show();
- }
- }
- this.operationParametersItem.setValue(value);
- }
-
- private String getSelectedOperationName() {
- FormItem operationNameItem = getForm().getField(ResourceOperationScheduleDataSource.Field.OPERATION_NAME);
- return (String)operationNameItem.getValue();
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 8c4d6a2..9b18b47 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -57,6 +57,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.H
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.MembersView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule.GroupOperationScheduleListView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.ActivityView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
@@ -295,8 +296,9 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
private void updateOperationsTab(int groupId, GroupCategory groupCategory, Set<ResourceTypeFacet> facets) {
if (updateTab(this.operationsTab, groupCategory == GroupCategory.COMPATIBLE
&& facets.contains(ResourceTypeFacet.OPERATION), true)) {
- updateSubTab(this.operationsTab, this.operationsSchedule, new FullHTMLPane(this.operationsSchedule.extendLocatorId("View"),
- "/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId=" + groupId), true, true);
+ updateSubTab(this.operationsTab, this.operationsSchedule,
+ new GroupOperationScheduleListView(this.operationsSchedule.extendLocatorId("View"),
+ this.groupComposite), true, true);
updateSubTab(this.operationsTab, this.operationsHistory, new FullHTMLPane(this.operationsHistory.extendLocatorId("View"),
"/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId), true, true);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
new file mode 100644
index 0000000..d104eb2
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
@@ -0,0 +1,105 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, 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.inventory.groups.detail.operation.schedule;
+
+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 org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.operation.bean.GroupOperationSchedule;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
+
+import java.util.List;
+
+/**
+ * A DataSource for {@link org.rhq.core.domain.operation.bean.GroupOperationSchedule}s for a given
+ * {@link org.rhq.core.domain.resource.group.ResourceGroup}.
+ *
+ * @author Ian Springer
+ */
+public class GroupOperationScheduleDataSource extends OperationScheduleDataSource<GroupOperationSchedule> {
+
+ private ResourceGroupComposite groupComposite;
+
+ public GroupOperationScheduleDataSource(ResourceGroupComposite groupComposite) {
+ super(groupComposite.getResourceGroup().getResourceType());
+ this.groupComposite = groupComposite;
+ }
+
+ @Override
+ protected GroupOperationSchedule createOperationSchedule() {
+ GroupOperationSchedule groupOperationSchedule = new GroupOperationSchedule();
+ groupOperationSchedule.setGroup(this.groupComposite.getResourceGroup());
+ return groupOperationSchedule;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+ operationService.findScheduledGroupOperations(this.groupComposite.getResourceGroup().getId(),
+ new AsyncCallback<List<GroupOperationSchedule>>() {
+ public void onSuccess(List<GroupOperationSchedule> result) {
+ Record[] records = buildRecords(result);
+ response.setData(records);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onFailure(Throwable caught) {
+ throw new RuntimeException("Failed to find scheduled operations for "
+ + groupComposite.getResourceGroup() + ".", caught);
+ }
+ });
+ }
+
+ @Override
+ protected void executeAdd(Record recordToAdd, final DSRequest request, final DSResponse response) {
+ Configuration parameters = (Configuration) request.getAttributeAsObject("parameters");
+ recordToAdd.setAttribute(Field.PARAMETERS, parameters);
+ final GroupOperationSchedule scheduleToAdd = copyValues(recordToAdd);
+ // TODO
+ /*operationService.scheduleResourceOperation(scheduleToAdd, new AsyncCallback<Integer>() {
+ public void onSuccess(Integer scheduleId) {
+ scheduleToAdd.setId(scheduleId);
+ sendSuccessResponse(request, response, scheduleToAdd);
+ }
+
+ public void onFailure(Throwable caught) {
+ throw new RuntimeException("Failed to add " + scheduleToAdd, caught);
+ }
+ });*/
+ }
+
+ @Override
+ protected void executeRemove(Record recordToRemove, final DSRequest request, final DSResponse response) {
+ final GroupOperationSchedule scheduleToRemove = copyValues(recordToRemove);
+ // TODO
+ /*operationService.unscheduleResourceOperation(scheduleToRemove, new AsyncCallback<Void>() {
+ public void onSuccess(Void result) {
+ sendSuccessResponse(request, response, scheduleToRemove);
+ }
+
+ public void onFailure(Throwable caught) {
+ throw new RuntimeException(caught);
+ }
+ });*/
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
new file mode 100644
index 0000000..b6a37bf
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
@@ -0,0 +1,16 @@
+package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule;
+
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
+
+/**
+ *
+ */
+public class GroupOperationScheduleDetailsView extends AbstractOperationScheduleDetailsView {
+
+ public GroupOperationScheduleDetailsView(String locatorId, ResourceGroupComposite groupComposite, int scheduleId) {
+ super(locatorId, new GroupOperationScheduleDataSource(groupComposite),
+ groupComposite.getResourceGroup().getResourceType(), scheduleId);
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
new file mode 100644
index 0000000..f3b376b
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
@@ -0,0 +1,54 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, 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.inventory.groups.detail.operation.schedule;
+
+import com.smartgwt.client.widgets.Canvas;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleDataSource;
+
+/**
+ * @author Ian Springer
+ */
+public class GroupOperationScheduleListView extends OperationScheduleListView {
+
+ private static final String TITLE = null;
+
+ private ResourceGroupComposite groupComposite;
+
+ public GroupOperationScheduleListView(String locatorId, ResourceGroupComposite groupComposite) {
+ super(locatorId, new GroupOperationScheduleDataSource(groupComposite), TITLE);
+ this.groupComposite = groupComposite;
+ }
+
+ @Override
+ protected boolean hasControlPermission() {
+ return this.groupComposite.getResourcePermission().isControl();
+ }
+
+ @Override
+ public Canvas getDetailsView(int scheduleId) {
+ return new GroupOperationScheduleDetailsView(extendLocatorId("DetailsView"),
+ this.groupComposite, scheduleId);
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
new file mode 100644
index 0000000..70f2c18
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
@@ -0,0 +1,18 @@
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule;
+
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
+
+/**
+ *
+ */
+public class ResourceOperationScheduleDetailsView extends AbstractOperationScheduleDetailsView {
+
+ public ResourceOperationScheduleDetailsView(String locatorId, ResourceComposite resourceComposite, int scheduleId) {
+ super(locatorId, new ResourceOperationScheduleDataSource(resourceComposite),
+ resourceComposite.getResource().getResourceType(), scheduleId);
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
index 14bb294..0e362f0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
@@ -23,7 +23,7 @@ import com.smartgwt.client.widgets.Canvas;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.ResourceOperationScheduleDetailsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
/**
* @author Ian Springer
@@ -46,7 +46,7 @@ public class ResourceOperationScheduleListView extends OperationScheduleListView
@Override
public Canvas getDetailsView(int scheduleId) {
- return new ResourceOperationScheduleDetailsView(extendLocatorId("DetailsView"),
+ return new ResourceOperationScheduleDetailsView(extendLocatorId("DetailsView"),
this.resourceComposite, scheduleId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index f43417f..47d9d49 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -36,14 +36,17 @@ import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
import com.smartgwt.client.util.JSOHelper;
+import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator;
import com.smartgwt.client.widgets.form.validator.LengthRangeValidator;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.hibernate.validator.RangeValidator;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.resource.ResourceCategory;
@@ -553,4 +556,21 @@ public abstract class RPCDataSource<T> extends DataSource {
return textField;
}
+ protected DataSourceIntegerField createIntegerField(String name, String title, Integer minValue, Integer maxValue,
+ Boolean required) {
+ DataSourceIntegerField textField = new DataSourceIntegerField(name, title);
+ textField.setRequired(required);
+ if (minValue != null || maxValue != null) {
+ IntegerRangeValidator integerRangeValidator = new IntegerRangeValidator();
+ if (minValue != null) {
+ integerRangeValidator.setMin(minValue);
+ }
+ if (maxValue != null) {
+ integerRangeValidator.setMax(maxValue);
+ }
+ textField.setValidators(integerRangeValidator);
+ }
+ return textField;
+ }
+
}
commit 4bb0d3d34ea5758d6360a38b12c872cd999c257a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jan 24 14:04:54 2011 -0500
refresh the tree
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
index e01ae47..71d5e06 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
@@ -219,7 +219,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
new Message(MSG.view_bundle_dest_purgeSuccessful(destination.getName()),
Message.Severity.Info));
// Bundle destination is purged, go back to bundle destinations root view
- CoreGUI.goToView(LinkManager.getBundleDestinationLink(bundle.getId(), 0));
+ CoreGUI.goToView(LinkManager.getBundleDestinationLink(bundle.getId(), 0), true);
}
});
}
commit 4aaf0e861d4538640de7ae062aa7a61a564e19e6
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jan 24 12:51:35 2011 -0500
put the username in the audit trail before purging
make sure we load all the data needed by the plugin container
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index 909c6ae..a81ded5 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -808,6 +808,11 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
bvc.fetchBundle(true); // will eagerly fetch the bundle type
PageList<BundleVersion> bvs = bundleManager.findBundleVersionsByCriteria(subject, bvc);
liveDeployment.setBundleVersion(bvs.get(0)); // wire up the full bundle version back into the live deployment
+ // the bundle type doesn't eagerly load the resource type - the remote plugin container needs that too
+ ResourceTypeCriteria rtc = new ResourceTypeCriteria();
+ rtc.addFilterBundleTypeId(liveDeployment.getBundleVersion().getBundle().getBundleType().getId());
+ PageList<ResourceType> rts = resourceTypeManager.findResourceTypesByCriteria(subject, rtc);
+ liveDeployment.getBundleVersion().getBundle().getBundleType().setResourceType(rts.get(0));
// we need to obtain the resources for all resource deployments - our first criteria can't fetch this deep, we have to do another query.
List<Integer> resourceDeployIds = new ArrayList<Integer>();
@@ -831,6 +836,13 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
Map<BundleResourceDeployment, String> failedToPurge = new HashMap<BundleResourceDeployment, String>();
for (BundleResourceDeployment resourceDeploy : resourceDeploys) {
try {
+ // first put the user name that requested the purge in the audit trail
+ BundleResourceDeploymentHistory history = new BundleResourceDeploymentHistory(subject.getName(),
+ "Purge Requested", "User [" + subject.getName() + "] requested to purge this deployment", null,
+ BundleResourceDeploymentHistory.Status.SUCCESS, null, null);
+ bundleManager.addBundleResourceDeploymentHistory(subject, resourceDeploy.getId(), history);
+
+ // get a connection to the agent and tell it to purge the bundle from the file system
Subject overlord = subjectManager.getOverlord();
AgentClient agentClient = agentManager.getAgentClient(overlord, resourceDeploy.getResource().getId());
BundleAgentService bundleAgentService = agentClient.getBundleAgentService();
commit 33102e3c93fe12e53beec85fa2e62cea625e2da6
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Jan 24 14:56:15 2011 -0500
fix several bugs on the Administration/Configuration/Templates view: 1) no platform services were getting loaded, 2) server type tree was flat, and 3) even leaf nodes in server type tree had an expand icon
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java
index 4e4a549..9df8f83 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java
@@ -202,8 +202,6 @@ public class ResourceTypeTreeNodeBuilder {
setAttribute(ATTRIB_DISABLED_ALERT_TEMPLATES, composite.getDisabledAlertCount());
setAttribute(ATTRIB_DISABLED_METRIC_TEMPLATES, composite.getEnabledMetricCount());
setAttribute(ATTRIB_ENABLED_METRIC_TEMPLATES, composite.getDisabledMetricCount());
-
- setIsFolder(true);
}
@Override
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java
index e225f7e..f153c81 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java
@@ -397,7 +397,16 @@ public class ResourceTypeManagerBean implements ResourceTypeManagerLocal, Resour
@SuppressWarnings("unchecked")
List<ResourceTypeTemplateCountComposite> results = (List<ResourceTypeTemplateCountComposite>) templateCountQuery.getResultList();
- // we don't need to send all the data in resource types over the wire, so we'll be scrubbing the types
+ for (ResourceTypeTemplateCountComposite result : results) {
+ ResourceType type = result.getType();
+
+ // TODO (ips, 01/24/11): I tried to fetch the parents via the
+ // ResourceType.FIND_ALL_TEMPLATE_COUNT_COMPOSITES named query,
+ // but was unable to get it working. This will suffice for the time being.
+ type.getParentResourceTypes().size();
+ }
+
+ // we don't need to send all the data in resource types over the wire, so we'll be scrubbing the types;
// to avoid the scrubbed types getting persisted back to the db, let's clear the persistence context
entityManager.clear();
@@ -405,23 +414,9 @@ public class ResourceTypeManagerBean implements ResourceTypeManagerLocal, Resour
for (ResourceTypeTemplateCountComposite result : results) {
ResourceType type = result.getType();
- // scrub it to avoid sending data over the wire we don't need
+ // scrub it to avoid sending data over the wire we don't need;
// some of these are eagerly loaded, but my paranoia says assume everything is eagerly loaded to purge it all
- type.setBundleType(null);
- type.setChildResourceTypes(null);
- type.setChildSubCategories(null);
- type.setClassLoaderType(null);
- type.setEventDefinitions(null);
- type.setMetricDefinitions(null);
- type.setOperationDefinitions(null);
- type.setPackageTypes(null);
- type.setPluginConfigurationDefinition(null);
- type.setProcessScans(null);
- type.setProductVersions(null);
- type.setResourceConfigurationDefinition(null);
- type.setResourceGroups(null);
- type.setResources(null);
- type.setSubCategory(null);
+ scrubType(type);
compositeMap.put(type.getId(), result);
}
@@ -429,6 +424,24 @@ public class ResourceTypeManagerBean implements ResourceTypeManagerLocal, Resour
return compositeMap;
}
+ private void scrubType(ResourceType type) {
+ type.setBundleType(null);
+ type.setChildResourceTypes(null);
+ type.setChildSubCategories(null);
+ type.setClassLoaderType(null);
+ type.setEventDefinitions(null);
+ type.setMetricDefinitions(null);
+ type.setOperationDefinitions(null);
+ type.setPackageTypes(null);
+ type.setPluginConfigurationDefinition(null);
+ type.setProcessScans(null);
+ type.setProductVersions(null);
+ type.setResourceConfigurationDefinition(null);
+ type.setResourceGroups(null);
+ type.setResources(null);
+ type.setSubCategory(null);
+ }
+
@SuppressWarnings("unchecked")
public List<ResourceType> getResourceTypesByPlugin(String pluginName) {
final String queryName = ResourceType.QUERY_FIND_BY_PLUGIN;
commit 7e43113ccdab09c369bdc3d48ede36d5f6097397
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Jan 24 11:58:19 2011 -0500
make sure isLdap field is read-only in user details view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
index ffd8517..e1f1042 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
@@ -146,11 +146,10 @@ public class UserEditView extends AbstractRecordEditor<UsersDataSource> {
items.add(nameItem);
}
- RadioGroupItem isLdapItem = new RadioGroupItem(UsersDataSource.Field.LDAP);
- isLdapItem.setVertical(false);
+ StaticTextItem isLdapItem = new StaticTextItem(UsersDataSource.Field.LDAP);
items.add(isLdapItem);
- boolean isLdap = Boolean.valueOf(isLdapItem.getValueAsString());
+ boolean isLdap = Boolean.valueOf(form.getValueAsString(UsersDataSource.Field.LDAP));
// Only display the password fields for non-LDAP users (i.e. users that have an associated RHQ Principal).
if (!isLdap) {
commit edfb4d47c9a2a4e0092235e72ec5fa5979d34852
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Jan 21 19:20:28 2011 -0500
bug with recent metrics when there are results but no chartable data.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
index 70fbf40..9930108 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
@@ -603,6 +603,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
@Override
public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> results) {
if (!results.isEmpty()) {
+ boolean someChartedData = false;
//iterate over the retrieved charting data
for (int index = 0; index < displayOrder.length; index++) {
@@ -668,8 +669,13 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
//if graph content returned
if ((md.getName().trim().indexOf("Trait.") == -1) && (lastValue != -1)) {
column.addMember(row);
+ someChartedData = true;
}
}
+ if (!someChartedData) {// when there are results but no chartable entries.
+ LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ }
//call out to 3rd party javascript lib
graphSparkLines();
} else {
commit 16650ee89c43a8cc90574b351999e85bc317c846
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Jan 21 12:18:41 2011 -0500
some documentation.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
index 3529fe9..70fbf40 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
@@ -113,6 +113,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
initializeUi();
}
+ /**Defines layout for the Activity page.
+ */
private void initializeUi() {
setPadding(5);
setMembersMargin(5);
@@ -190,6 +192,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
loadData();
}
+ /**Initiates data request.
+ */
private void loadData() {
getRecentAlerts();
getRecentOperations();
commit 5a7fda1de19ebcc2582c263f03e335450df5982e
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Jan 21 12:14:56 2011 -0500
i)refactor ActivitView2 ii)fix config updates query bug using criteria.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
index 8742787..3529fe9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
@@ -42,7 +42,6 @@ import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.content.InstalledPackageHistory;
import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.criteria.InstalledPackageCriteria;
-import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
@@ -72,15 +71,23 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Simeon Pinder
*/
public class ActivityView2 extends LocatableHLayout implements RefreshableView {
- private LocatableVLayout leftPane;
- private LocatableVLayout rightPane;
- private LocatableCanvas recentMeasurementsContent = new LocatableCanvas(extendLocatorId("RecentMetricsContent"));
- private LocatableCanvas recentAlertsContent = new LocatableCanvas(extendLocatorId("RecentAlertsContent"));
- private LocatableCanvas recentOobContent = new LocatableCanvas(extendLocatorId("RecentOobsContent"));
- private LocatableCanvas recentConfigurationContent = new LocatableCanvas(extendLocatorId("RecentConfigContent"));
- private LocatableCanvas recentOperationsContent = new LocatableCanvas(extendLocatorId("RecentOperationsContent"));
- private LocatableCanvas recentEventsContent = new LocatableCanvas(extendLocatorId("RecentEventsContent"));
- private LocatableCanvas recentPkgHistoryContent = new LocatableCanvas(extendLocatorId("RecentPkgHistoryContent"));
+
+ //Locatable ui references
+ private LocatableVLayout leftPane = new LocatableVLayout(extendLocatorId("Left"));;
+ private LocatableVLayout rightPane = new LocatableVLayout(extendLocatorId("Right"));;
+ private LocatableCanvas recentMeasurementsContent = new LocatableCanvas(leftPane
+ .extendLocatorId("RecentMetricsContent"));
+ private LocatableCanvas recentAlertsContent = new LocatableCanvas(leftPane.extendLocatorId("RecentAlertsContent"));
+ private LocatableCanvas recentOobContent = new LocatableCanvas(leftPane.extendLocatorId("RecentOobsContent"));
+ private LocatableCanvas recentConfigurationContent = new LocatableCanvas(rightPane
+ .extendLocatorId("RecentConfigContent"));
+ private LocatableCanvas recentOperationsContent = new LocatableCanvas(rightPane
+ .extendLocatorId("RecentOperationsContent"));
+ private LocatableCanvas recentEventsContent = new LocatableCanvas(rightPane.extendLocatorId("RecentEventsContent"));
+ private LocatableCanvas recentPkgHistoryContent = new LocatableCanvas(rightPane
+ .extendLocatorId("RecentPkgHistoryContent"));
+
+ //retrieve localized text
private String RECENT_MEASUREMENTS = MSG.common_title_recent_measurements();
private String RECENT_MEASUREMENTS_NONE = MSG.view_resource_inventory_activity_no_recent_metrics();
private String RECENT_ALERTS = MSG.common_title_recent_alerts();
@@ -122,18 +129,17 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
divider5.setWidth("50%");
//leftPane
- leftPane = new LocatableVLayout(extendLocatorId("Left"));
leftPane.setWidth("50%");
leftPane.setPadding(5);
leftPane.setMembersMargin(5);
leftPane.setAutoHeight();
+
//recentMetrics.xhtml
LocatableHLayout recentMetricsTitle = new TitleWithIcon(leftPane, "RecentMetrics",
"subsystems/monitor/Monitor_24.png", RECENT_MEASUREMENTS);
leftPane.addMember(recentMetricsTitle);
leftPane.addMember(recentMeasurementsContent);
recentMeasurementsContent.setHeight(20);
- recentMeasurementsContent.setContents(RECENT_MEASUREMENTS_NONE);
leftPane.addMember(divider1);
//recentAlerts.xhtml
LocatableHLayout recentAlertsTitle = new TitleWithIcon(leftPane, "RecentAlerts",
@@ -150,7 +156,6 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
recentOobContent.setHeight(20);
//rightPane
- rightPane = new LocatableVLayout(extendLocatorId("Right"));
rightPane.setWidth("50%");
rightPane.setPadding(5);
rightPane.setMembersMargin(5);
@@ -175,7 +180,6 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
rightPane.addMember(recentEventsTitle);
rightPane.addMember(recentEventsContent);
recentEventsContent.setHeight(20);
- // recentEventsContent.setContents(RECENT_EVENTS_NONE);
rightPane.addMember(divider5);
//recentPackageHistory.xhtml
LocatableHLayout recentPkgHistoryTitle = new TitleWithIcon(leftPane, "RecentPkgHistory",
@@ -200,6 +204,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
protected void onDraw() {
super.onDraw();
+ //TODO:spinder cleanup members before on draw?
addMember(leftPane);
addMember(rightPane);
refresh();
@@ -210,9 +215,14 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
// int resourceId = this.resourceComposite.getResource().getId();
// this.iFrame.setContentsURL("/rhq/resource/summary/overview-plain.xhtml?id=" + resourceId);
markForRedraw();
+ //call out to 3rd party javascript lib
+ graphSparkLines();
}
+ /**Creates the section top titles with icon for regions of Activity page.
+ */
class TitleWithIcon extends LocatableHLayout {
+
public TitleWithIcon(String locatorId) {
super(locatorId);
}
@@ -251,36 +261,19 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(3);
- StaticTextItem iconItem = new StaticTextItem();
- FormItemIcon img = new FormItemIcon();
- img.setSrc(ImageManager.getAlertIcon(alert.getAlertDefinition().getPriority()));
- img.setWidth(16);
- img.setHeight(16);
- img.setPrompt(alert.getAlertDefinition().getPriority().getDisplayName());
- iconItem.setIcons(img);
- iconItem.setShowTitle(false);
-
- LinkItem link = new LinkItem();
- link.setLinkTitle(alert.getAlertDefinition().getName() + ": ");
- link.setTitle(alert.getAlertDefinition().getName());
- link.setValue(ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Alerts/History/"
- + alert.getId());
- link.setTarget("_self");
- link.setShowTitle(false);
-
- StaticTextItem time = new StaticTextItem();
- time.setDefaultValue(GwtRelativeDurationConverter.format(alert.getCtime()));
- time.setShowTitle(false);
- time.setShowPickerIcon(false);
- time.setWrap(false);
+ StaticTextItem iconItem = newTextItemIcon(ImageManager.getAlertIcon(alert.getAlertDefinition()
+ .getPriority()), alert.getAlertDefinition().getPriority().getDisplayName());
+ LinkItem link = newLinkItem(alert.getAlertDefinition().getName() + ": ",
+ ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Alerts/History/" + alert.getId());
+ StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(alert.getCtime()));
row.setItems(iconItem, link, time);
column.addMember(row);
}
} else {
- column.setContents(RECENT_ALERTS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_ALERTS_NONE);
+ column.addMember(row);
}
- recentAlertsContent.setContents("");
for (Canvas child : recentAlertsContent.getChildren()) {
child.destroy();
}
@@ -321,41 +314,20 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(3);
- StaticTextItem iconItem = new StaticTextItem();
- FormItemIcon img = new FormItemIcon();
- img.setSrc(ImageManager.getOperationResultsIcon(report.getOriginal().getOperationStatus()));
- img.setWidth(16);
- img.setHeight(16);
- img.setPrompt(report.getOriginal().getOperationStatus().getDisplayName());
- iconItem.setIcons(img);
- iconItem.setShowTitle(false);
-
- LinkItem link = new LinkItem();
- link.setLinkTitle(report.getOriginal().getOperationName() + ": ");
- link.setTitle(report.getOriginal().getOperationName());
- link.setValue(ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Operations/History/"
- + report.getOriginal().getOperationHistoryId());
- link.setTarget("_self");
- link.setShowTitle(false);
-
- StaticTextItem time = new StaticTextItem();
- time.setDefaultValue(GwtRelativeDurationConverter.format(report.getOriginal()
+ StaticTextItem iconItem = newTextItemIcon(ImageManager.getOperationResultsIcon(report
+ .getOriginal().getOperationStatus()), report.getOriginal().getOperationStatus()
+ .getDisplayName());
+ LinkItem link = newLinkItem(report.getOriginal().getOperationName() + ": ",
+ ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Operations/History/"
+ + report.getOriginal().getOperationHistoryId());
+ StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(report.getOriginal()
.getOperationStartTime()));
- time.setShowTitle(false);
- time.setShowPickerIcon(false);
- time.setWrap(false);
row.setItems(iconItem, link, time);
column.addMember(row);
}
} else {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
- row.setNumCols(3);
- StaticTextItem none = new StaticTextItem();
- none.setShowTitle(false);
- none.setDefaultValue(RECENT_OPERATIONS_NONE);
- none.setWrap(false);
- row.setItems(none);
+ LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_OPERATIONS_NONE);
column.addMember(row);
}
for (Canvas child : recentOperationsContent.getChildren()) {
@@ -373,15 +345,11 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
private void getRecentConfigurationUpdates() {
final int resourceId = this.resourceComposite.getResource().getId();
- //construct criteria( last five config updates for resourceId sorted by cTime)
- ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
- criteria.addFilterResourceIds(resourceId);
- PageControl pageControl = new PageControl(0, 5);
- criteria.addSortCtime(PageOrdering.DESC);
- criteria.setPageControl(pageControl);
+ PageControl lastFive = new PageControl(0, 5);
+ lastFive.initDefaultOrderingField("cu.createdTime", PageOrdering.DESC);
- GWTServiceLookup.getConfigurationService().findResourceConfigurationUpdatesByCriteria(criteria,
- new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
+ GWTServiceLookup.getConfigurationService().findResourceConfigurationUpdates(resourceId, null, null, true,
+ lastFive, new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
@Override
public void onFailure(Throwable caught) {
@@ -399,45 +367,23 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(3);
- StaticTextItem iconItem = new StaticTextItem();
- FormItemIcon img = new FormItemIcon();
- img.setSrc(ImageManager.getResourceConfigurationIcon(update.getStatus()));
- img.setWidth(16);
- img.setHeight(16);
- iconItem.setIcons(img);
- iconItem.setShowTitle(false);
-
- LinkItem link = new LinkItem();
+ StaticTextItem iconItem = newTextItemIcon(ImageManager.getResourceConfigurationIcon(update
+ .getStatus()), null);
String linkTitle = MSG.view_resource_inventory_activity_changed_by() + " "
+ update.getSubjectName() + ":";
if ((update.getSubjectName() == null) || (update.getSubjectName().trim().isEmpty())) {
linkTitle = MSG.common_msg_changeAutoDetected();
- ;
}
- link.setLinkTitle(linkTitle);
- link.setTitle(linkTitle);
- link.setValue(ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Configuration/History/"
- + update.getId());
- link.setTarget("_self");
- link.setShowTitle(false);
-
- StaticTextItem time = new StaticTextItem();
- time.setDefaultValue(GwtRelativeDurationConverter.format(update.getCreatedTime()));
- time.setShowTitle(false);
- time.setShowPickerIcon(false);
- time.setWrap(false);
- row.setItems(iconItem, link, time);
+ LinkItem link = newLinkItem(linkTitle, ReportDecorator.GWT_RESOURCE_URL + resourceId
+ + "/Configuration/History/" + update.getId());
+ StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(update
+ .getCreatedTime()));
+ row.setItems(iconItem, link, time);
column.addMember(row);
}
} else {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
- row.setNumCols(3);
- StaticTextItem none = new StaticTextItem();
- none.setShowTitle(false);
- none.setDefaultValue(RECENT_CONFIGURATIONS_NONE);
- none.setWrap(false);
- row.setItems(none);
+ LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_CONFIGURATIONS_NONE);
column.addMember(row);
}
//cleanup
@@ -489,36 +435,18 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
row.setWidth(10);//pack.
//icon
- StaticTextItem iconItem = new StaticTextItem();
- FormItemIcon img = new FormItemIcon();
- img.setSrc(ImageManager.getEventSeverityIcon(tuple.getLefty()));
- img.setWidth(16);
- img.setHeight(16);
- img.setPrompt(tuple.getLefty().name());
- iconItem.setIcons(img);
- iconItem.setShowTitle(false);
-
+ StaticTextItem iconItem = newTextItemIcon(ImageManager.getEventSeverityIcon(tuple
+ .getLefty()), tuple.getLefty().name());
//count
- StaticTextItem count = new StaticTextItem();
- count.setDefaultValue(tuple.righty);
- count.setShowTitle(false);
- count.setShowPickerIcon(false);
- count.setWrap(false);
+ StaticTextItem count = newTextItem(String.valueOf(tuple.righty));
row.setItems(iconItem, count);
column.addMember(row);
}
} else {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
- row.setNumCols(3);
- StaticTextItem none = new StaticTextItem();
- none.setShowTitle(false);
- none.setDefaultValue(RECENT_EVENTS_NONE);
- none.setWrap(false);
- row.setItems(none);
+ LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_EVENTS_NONE);
column.addMember(row);
}
- recentEventsContent.setContents("");
//cleanup
for (Canvas child : recentEventsContent.getChildren()) {
child.destroy();
@@ -551,32 +479,17 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(2);
- LinkItem link = new LinkItem();
- link.setLinkTitle(oob.getScheduleName() + ":");
- link.setTitle(oob.getScheduleName() + ":");
- //TODO: change link after charting updated for gwt.
- link.setValue("/resource/common/monitor/Visibility.do?m=" + oob.getDefinitionId() + "&id="
- + resourceId + "&mode=chartSingleMetricSingleResource");
- link.setTarget("_self");
- link.setShowTitle(false);
-
- StaticTextItem time = new StaticTextItem();
- time.setDefaultValue(GwtRelativeDurationConverter.format(oob.getTimestamp()));
- time.setShowTitle(false);
- time.setShowPickerIcon(false);
- time.setWrap(false);
- row.setItems(link, time);
+ String title = oob.getScheduleName() + ":";
+ String destination = "/resource/common/monitor/Visibility.do?m=" + oob.getDefinitionId()
+ + "&id=" + resourceId + "&mode=chartSingleMetricSingleResource";
+ LinkItem link = newLinkItem(title, destination);
+ StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(oob.getTimestamp()));
+ row.setItems(link, time);
column.addMember(row);
}
} else {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
- row.setNumCols(3);
- StaticTextItem none = new StaticTextItem();
- none.setShowTitle(false);
- none.setDefaultValue(RECENT_OOB_NONE);
- none.setWrap(false);
- row.setItems(none);
+ LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_OOB_NONE);
column.addMember(row);
}
recentOobContent.setContents("");
@@ -615,41 +528,19 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(3);
- StaticTextItem iconItem = new StaticTextItem();
- FormItemIcon img = new FormItemIcon();
- img.setSrc("subsystems/content/Content_16.png");
- img.setWidth(16);
- img.setHeight(16);
- iconItem.setIcons(img);
- iconItem.setShowTitle(false);
-
- LinkItem link = new LinkItem();
- link.setLinkTitle(history.getPackageVersion().getFileName() + ":");
- link.setTitle(history.getPackageVersion().getFileName() + ":");
-
- //TODO: spinder. Upgrade link when content available in coreGui. Not yet iframed correctly.
- link.setValue("/rhq/resource/content/audit-trail-item.xhtml?id=" + resourceId
- + "&selectedHistoryId=" + history.getId());
- link.setTarget("_self");
- link.setShowTitle(false);
-
- StaticTextItem time = new StaticTextItem();
- time.setDefaultValue(GwtRelativeDurationConverter.format(history.getTimestamp()));
- time.setShowTitle(false);
- time.setShowPickerIcon(false);
- time.setWrap(false);
- row.setItems(iconItem, link, time);
+ StaticTextItem iconItem = newTextItemIcon("subsystems/content/Content_16.png", null);
+ String title = history.getPackageVersion().getFileName() + ":";
+ String destination = "/rhq/resource/content/audit-trail-item.xhtml?id=" + resourceId
+ + "&selectedHistoryId=" + history.getId();
+ LinkItem link = newLinkItem(title, destination);
+ StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(history
+ .getTimestamp()));
+ row.setItems(iconItem, link, time);
column.addMember(row);
}
} else {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
- row.setNumCols(3);
- StaticTextItem none = new StaticTextItem();
- none.setShowTitle(false);
- none.setDefaultValue(RECENT_PKG_HISTORY_NONE);
- none.setWrap(false);
- row.setItems(none);
+ LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_PKG_HISTORY_NONE);
column.addMember(row);
}
//cleanup
@@ -669,6 +560,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
private void getRecentMetrics() {
//display container
final LocatableVLayout column = new LocatableVLayout(recentMeasurementsContent.extendLocatorId("Content"));
+ column.setHeight(10);//pack
final int resourceId = this.resourceComposite.getResource().getId();
//retrieve all relevant measurement definition ids.
@@ -757,24 +649,17 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
graphContainer.setCanvas(graph);
//Link/title element
- LinkItem link = new LinkItem();
- link.setLinkTitle(md.getDisplayName() + ":");
//TODO: spinder, change link whenever portal.war/graphing is removed.
- link
- .setValue("/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
- + resourceId + "&m=" + md.getId());
- link.setTarget("_self");
- link.setShowTitle(false);
+ String title = md.getDisplayName() + ":";
+ String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
+ + resourceId + "&m=" + md.getId();
+ LinkItem link = newLinkItem(title, destination);
//Value
- StaticTextItem value = new StaticTextItem();
String convertedValue = lastValue + " " + md.getUnits();
convertedValue = convertLastValueForDisplay(lastValue, md);
+ StaticTextItem value = newTextItem(convertedValue);
- value.setDefaultValue(convertedValue);
- value.setShowTitle(false);
- value.setShowPickerIcon(false);
- value.setWrap(false);
row.setItems(graphContainer, link, value);
//if graph content returned
if ((md.getName().trim().indexOf("Trait.") == -1) && (lastValue != -1)) {
@@ -784,7 +669,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
//call out to 3rd party javascript lib
graphSparkLines();
} else {
- column.setContents(RECENT_MEASUREMENTS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
}
}
});
@@ -793,7 +679,6 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
for (Canvas child : recentMeasurementsContent.getChildren()) {
child.destroy();
}
- recentMeasurementsContent.setContents("");
recentMeasurementsContent.addChild(column);
// graphSparkLines();
recentMeasurementsContent.markForRedraw();
@@ -824,6 +709,62 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
return convertedValue;
}
+ /** Create empty display row(LocatableDynamicForm) that is constently defined and displayed.
+ *
+ * @param column Locatable parent colum.
+ * @param emptyMessage Contents of the empty region
+ * @return
+ */
+ private LocatableDynamicForm createEmptyDisplayRow(Locatable column, String emptyMessage) {
+ LocatableDynamicForm row = null;
+ if (column != null) {
+ row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ } else {
+ row = new LocatableDynamicForm(extendLocatorId("ContentForm"));
+ }
+
+ row.setNumCols(3);
+ StaticTextItem none = new StaticTextItem();
+ none.setShowTitle(false);
+ none.setDefaultValue(emptyMessage);
+ none.setWrap(false);
+ row.setItems(none);
+ return row;
+ }
+
+ private StaticTextItem newTextItemIcon(String imageSrc, String mouseOver) {
+ StaticTextItem iconItem = new StaticTextItem();
+ FormItemIcon img = new FormItemIcon();
+ img.setSrc(imageSrc);
+ img.setWidth(16);
+ img.setHeight(16);
+ if (mouseOver != null) {
+ img.setPrompt(mouseOver);
+ }
+ iconItem.setIcons(img);
+ iconItem.setShowTitle(false);
+ return iconItem;
+ }
+
+ private LinkItem newLinkItem(String title, String destination) {
+ LinkItem link = new LinkItem();
+ link.setLinkTitle(title);
+ link.setTitle(title);
+ link.setValue(destination);
+ link.setTarget("_self");
+ link.setShowTitle(false);
+ return link;
+ }
+
+ private StaticTextItem newTextItem(String contents) {
+ StaticTextItem item = new StaticTextItem();
+ item.setDefaultValue(contents);
+ item.setShowTitle(false);
+ item.setShowPickerIcon(false);
+ item.setWrap(false);
+ return item;
+ }
+
//This is a JSNI call out to the third party javascript lib to execute on the data inserted into the DOM.
public static native void graphSparkLines()
/*-{
commit 648349254f258114f42aef91e83e6cb3e4461879
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Jan 21 02:59:40 2011 -0500
missing message and i18n for activityView page.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
index 898f8c6..8742787 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
@@ -408,10 +408,14 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
iconItem.setShowTitle(false);
LinkItem link = new LinkItem();
- link.setLinkTitle(MSG.view_resource_inventory_activity_changed_by() + " "
- + update.getSubjectName() + ":");
- link.setTitle(MSG.view_resource_inventory_activity_changed_by() + " "
- + update.getSubjectName() + ":");
+ String linkTitle = MSG.view_resource_inventory_activity_changed_by() + " "
+ + update.getSubjectName() + ":";
+ if ((update.getSubjectName() == null) || (update.getSubjectName().trim().isEmpty())) {
+ linkTitle = MSG.common_msg_changeAutoDetected();
+ ;
+ }
+ link.setLinkTitle(linkTitle);
+ link.setTitle(linkTitle);
link.setValue(ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Configuration/History/"
+ update.getId());
link.setTarget("_self");
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 b8b4d13..cd939a9 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
@@ -185,6 +185,7 @@ common_title_welcome = Welcome
# Common Messages
#--------------
common_msg_areYouSure = Are You Sure?
+common_msg_changeAutoDetected = Change auto-detected
common_msg_deleteConfirm = Are you sure you want to delete the # selected {0}?
common_msg_emphasizedNotePrefix = NOTE:
common_msg_loading = Loading...
commit 2305ba83c61ef939214ac2c390e8766190924603
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Jan 21 02:41:35 2011 -0500
i)fix copy paste error in ImageManager ii)update recent configuration region.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
index c9afaec..da0b477 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
@@ -380,7 +380,7 @@ public class ImageManager {
icon = "_warning";
break;
case ERROR:
- icon = "_info";
+ icon = "_error";
break;
case FATAL:
icon = "_fatal";
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
index 789e778..898f8c6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
@@ -20,7 +20,6 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -249,8 +248,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.setHeight(10);
if (!result.isEmpty()) {
for (Alert alert : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent
- .extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(3);
StaticTextItem iconItem = new StaticTextItem();
@@ -320,8 +318,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.setHeight(10);
if (!result.isEmpty()) {
for (DisambiguationReport<ResourceOperationLastCompletedComposite> report : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
- .extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(3);
StaticTextItem iconItem = new StaticTextItem();
@@ -352,8 +349,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
- .extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(3);
StaticTextItem none = new StaticTextItem();
none.setShowTitle(false);
@@ -376,10 +372,14 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
*/
private void getRecentConfigurationUpdates() {
final int resourceId = this.resourceComposite.getResource().getId();
+
+ //construct criteria( last five config updates for resourceId sorted by cTime)
ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
criteria.addFilterResourceIds(resourceId);
PageControl pageControl = new PageControl(0, 5);
+ criteria.addSortCtime(PageOrdering.DESC);
criteria.setPageControl(pageControl);
+
GWTServiceLookup.getConfigurationService().findResourceConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
@@ -391,12 +391,12 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
@Override
public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
- LocatableVLayout column = new LocatableVLayout(recentOperationsContent.extendLocatorId("Content"));
+ LocatableVLayout column = new LocatableVLayout(recentConfigurationContent
+ .extendLocatorId("Content"));
column.setHeight(10);
if (!result.isEmpty()) {
for (ResourceConfigurationUpdate update : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
- .extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(3);
StaticTextItem iconItem = new StaticTextItem();
@@ -409,16 +409,16 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
LinkItem link = new LinkItem();
link.setLinkTitle(MSG.view_resource_inventory_activity_changed_by() + " "
- + update.getSubjectName());
+ + update.getSubjectName() + ":");
link.setTitle(MSG.view_resource_inventory_activity_changed_by() + " "
- + update.getSubjectName());
+ + update.getSubjectName() + ":");
link.setValue(ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Configuration/History/"
+ update.getId());
link.setTarget("_self");
link.setShowTitle(false);
StaticTextItem time = new StaticTextItem();
- time.setDefaultValue(new Date(update.getCreatedTime()).toString());
+ time.setDefaultValue(GwtRelativeDurationConverter.format(update.getCreatedTime()));
time.setShowTitle(false);
time.setShowPickerIcon(false);
time.setWrap(false);
@@ -427,8 +427,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
- .extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(3);
StaticTextItem none = new StaticTextItem();
none.setShowTitle(false);
@@ -481,8 +480,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
if (!results.isEmpty()) {
for (GwtTuple<EventSeverity, Integer> tuple : results) {
- LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent
- .extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(2);
row.setWidth(10);//pack.
@@ -507,8 +505,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent
- .extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(3);
StaticTextItem none = new StaticTextItem();
none.setShowTitle(false);
@@ -547,8 +544,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.setHeight(10);
if (!result.isEmpty()) {
for (MeasurementOOBComposite oob : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(recentOobContent
- .extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(2);
LinkItem link = new LinkItem();
@@ -570,8 +566,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = new LocatableDynamicForm(recentOobContent
- .extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(3);
StaticTextItem none = new StaticTextItem();
none.setShowTitle(false);
@@ -613,8 +608,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.setHeight(10);
if (!result.isEmpty()) {
for (InstalledPackageHistory history : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(recentPkgHistoryContent
- .extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(3);
StaticTextItem iconItem = new StaticTextItem();
@@ -645,8 +639,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = new LocatableDynamicForm(recentPkgHistoryContent
- .extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
row.setNumCols(3);
StaticTextItem none = new StaticTextItem();
none.setShowTitle(false);
commit 96dd3c548fcae2334c91117289310980f941ccd9
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Jan 21 01:25:00 2011 -0500
updating recent events region of Activity page. Added GWT serializable version of Tuple.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java
index ebe1326..22aec4a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java
@@ -23,6 +23,7 @@
package org.rhq.enterprise.gui.coregui.client.gwt;
import java.util.List;
+import java.util.Map;
import com.google.gwt.user.client.rpc.RemoteService;
@@ -54,4 +55,6 @@ public interface EventGWTService extends RemoteService {
int deleteEventsForContext(EntityContext context, List<Integer> eventIds) throws RuntimeException;
int purgeEventsForContext(EntityContext context) throws RuntimeException;
+
+ Map<EventSeverity, Integer> getEventCountsBySeverity(int resourceId, long startDate, long endDate);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
index d034f93..789e778 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
@@ -18,10 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import com.allen_sauer.gwt.log.client.Log;
@@ -40,9 +42,9 @@ import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.content.InstalledPackageHistory;
import org.rhq.core.domain.criteria.AlertCriteria;
-import org.rhq.core.domain.criteria.EventCriteria;
import org.rhq.core.domain.criteria.InstalledPackageCriteria;
import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
+import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
@@ -57,6 +59,7 @@ import org.rhq.enterprise.gui.coregui.client.RefreshableView;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
+import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
import org.rhq.enterprise.gui.coregui.client.util.measurement.GwtMonitorUtils;
import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
@@ -173,7 +176,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
rightPane.addMember(recentEventsTitle);
rightPane.addMember(recentEventsContent);
recentEventsContent.setHeight(20);
- recentEventsContent.setContents(RECENT_EVENTS_NONE);
+ // recentEventsContent.setContents(RECENT_EVENTS_NONE);
rightPane.addMember(divider5);
//recentPackageHistory.xhtml
LocatableHLayout recentPkgHistoryTitle = new TitleWithIcon(leftPane, "RecentPkgHistory",
@@ -444,73 +447,85 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
});
}
+ /** Fetches recent events and updates the DynamicForm instance with the latest
+ * event information over last 24hrs.
+ */
private void getRecentEventUpdates() {
+
final int resourceId = this.resourceComposite.getResource().getId();
- EventCriteria criteria = new EventCriteria();
- // criteria.addFilterResourceIds(resourceId);
long now = System.currentTimeMillis();
long nowMinus24Hours = now - (24 * 60 * 60 * 1000);
- criteria.addFilterResourceId(resourceId);
- PageControl pageControl = PageControl.getUnlimitedInstance();
- criteria.setPageControl(pageControl);
- //Error retrieving recent event counts for resource [" + resourceId + "]:"
- // GWTServiceLookup.getEventService().getEventCountsBySeverity(resourceId, nowMinus24Hours, now,
- // new AsyncCallback<Map<EventSeverity, Integer>>() {
- // @Override
- // public void onFailure(Throwable caught) {
- // Log.debug("Error retrieving recent event counts for resource [" + resourceId + "]:"
- // + caught.getMessage());
- // }
- //
- // @Override
- // public void onSuccess(Map<EventSeverity, Integer> result) {
- // LocatableVLayout column = new LocatableVLayout(recentOperationsContent.extendLocatorId("Content"));
- // column.setHeight(10);
- // if (!result.isEmpty()) {
- // for (Entry<EventSeverity, Integer> entry : result.entrySet()) {
- // EventSeverity severity = entry.getKey();
- // LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
- // .extendLocatorId("ContentForm"));
- // row.setNumCols(2);
- //
- // StaticTextItem iconItem = new StaticTextItem();
- // FormItemIcon img = new FormItemIcon();
- // img.setSrc(ImageManager.getEventSeverityIcon(severity));
- // // img.set
- // img.setWidth(16);
- // img.setHeight(16);
- // iconItem.setIcons(img);
- // iconItem.setShowTitle(false);
- //
- // StaticTextItem time = new StaticTextItem();
- // time.setDefaultValue(entry.getValue());
- // time.setShowTitle(false);
- // time.setShowPickerIcon(false);
- // time.setWrap(false);
- // row.setItems(iconItem, time);
- //
- // column.addMember(row);
- // }
- // } else {
- // LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent
- // .extendLocatorId("ContentForm"));
- // row.setNumCols(3);
- // StaticTextItem none = new StaticTextItem();
- // none.setShowTitle(false);
- // none.setDefaultValue(RECENT_EVENTS_NONE);
- // none.setWrap(false);
- // row.setItems(none);
- // column.addMember(row);
- // }
- // //cleanup
- // for (Canvas child : recentEventsContent.getChildren()) {
- // child.destroy();
- // }
- // recentEventsContent.addChild(column);
- // recentEventsContent.markForRedraw();
- // }
- // });
+ GWTServiceLookup.getEventService().getEventCountsBySeverity(resourceId, nowMinus24Hours, now,
+ new AsyncCallback<Map<EventSeverity, Integer>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent event counts for resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(Map<EventSeverity, Integer> eventCounts) {
+ //Now populated Tuples
+ List<GwtTuple<EventSeverity, Integer>> results = new ArrayList<GwtTuple<EventSeverity, Integer>>();
+ for (EventSeverity severity : eventCounts.keySet()) {
+ int count = eventCounts.get(severity);
+ if (count > 0) {
+ results.add(new GwtTuple<EventSeverity, Integer>(severity, count));
+ }
+ }
+ //build display
+ LocatableVLayout column = new LocatableVLayout(recentEventsContent.extendLocatorId("Content"));
+ column.setHeight(10);
+
+ if (!results.isEmpty()) {
+ for (GwtTuple<EventSeverity, Integer> tuple : results) {
+ LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent
+ .extendLocatorId("ContentForm"));
+ row.setNumCols(2);
+ row.setWidth(10);//pack.
+
+ //icon
+ StaticTextItem iconItem = new StaticTextItem();
+ FormItemIcon img = new FormItemIcon();
+ img.setSrc(ImageManager.getEventSeverityIcon(tuple.getLefty()));
+ img.setWidth(16);
+ img.setHeight(16);
+ img.setPrompt(tuple.getLefty().name());
+ iconItem.setIcons(img);
+ iconItem.setShowTitle(false);
+
+ //count
+ StaticTextItem count = new StaticTextItem();
+ count.setDefaultValue(tuple.righty);
+ count.setShowTitle(false);
+ count.setShowPickerIcon(false);
+ count.setWrap(false);
+ row.setItems(iconItem, count);
+
+ column.addMember(row);
+ }
+ } else {
+ LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent
+ .extendLocatorId("ContentForm"));
+ row.setNumCols(3);
+ StaticTextItem none = new StaticTextItem();
+ none.setShowTitle(false);
+ none.setDefaultValue(RECENT_EVENTS_NONE);
+ none.setWrap(false);
+ row.setItems(none);
+ column.addMember(row);
+ }
+ recentEventsContent.setContents("");
+ //cleanup
+ for (Canvas child : recentEventsContent.getChildren()) {
+ child.destroy();
+ }
+ recentEventsContent.addChild(column);
+ recentEventsContent.markForRedraw();
+ }
+ });
}
/** Fetches OOB measurements and updates the DynamicForm instance with the latest 5
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/GwtTuple.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/GwtTuple.java
new file mode 100644
index 0000000..3ec7ccc
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/GwtTuple.java
@@ -0,0 +1,83 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.util;
+
+/**
+ * A GWT serializable version of org.rhq.enterprise.server.alert.engine.internal.Tuple
+ *
+ * @author Simeon Pinder
+ * @author Joseph Marques
+ */
+public class GwtTuple<L, R> {
+ public L lefty;
+ public R righty;
+
+ public GwtTuple(L lefty, R righty) {
+ this.lefty = lefty;
+ this.righty = righty;
+ }
+
+ public L getLefty() {
+ return this.lefty;
+ }
+
+ public R getRighty() {
+ return this.righty;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = (31 * result) + ((lefty == null) ? 0 : lefty.hashCode());
+ result = (31 * result) + ((righty == null) ? 0 : righty.hashCode());
+ return result;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || (!(obj instanceof GwtTuple))) {
+ return false;
+ }
+
+ final GwtTuple<L, R> other = (GwtTuple<L, R>) obj;
+
+ if (lefty == null) {
+ if (other.lefty != null) {
+ return false;
+ }
+ } else if (!lefty.equals(other.lefty)) {
+ return false;
+ }
+
+ if (righty == null) {
+ if (other.righty != null) {
+ return false;
+ }
+ } else if (!righty.equals(other.righty)) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
index 9654a9d..1aa9949 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
@@ -23,6 +23,7 @@
package org.rhq.enterprise.gui.coregui.server.gwt;
import java.util.List;
+import java.util.Map;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.EventCriteria;
@@ -77,14 +78,14 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
}
}
- // public Map<EventSeverity, Integer> getEventCountsBySeverity(int resourceId, long startDate, long endDate) {
- // try {
- // return SerialUtility.prepare(eventManager.getEventCountsBySeverity(getSessionSubject(), resourceId,
- // startDate, endDate), "EventService.getEventCountsBySeverity");
- // } catch (Exception e) {
- // throw new RuntimeException(ThrowableUtil.getAllMessages(e));
- // }
- // }
+ public Map<EventSeverity, Integer> getEventCountsBySeverity(int resourceId, long startDate, long endDate) {
+ try {
+ return SerialUtility.prepare(eventManager.getEventCountsBySeverity(getSessionSubject(), resourceId,
+ startDate, endDate), "EventService.getEventCountsBySeverity");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
public PageList<Event> findEventsByCriteria(EventCriteria criteria) throws RuntimeException {
try {
commit a2b3c650b73f90919370a87245c8c0a337216b7e
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Jan 20 21:30:43 2011 -0500
update oob region details.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
index 3181eef..d034f93 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
@@ -513,12 +513,11 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
// });
}
+ /** Fetches OOB measurements and updates the DynamicForm instance with the latest 5
+ * oob change details.
+ */
private void getRecentOobs() {
final int resourceId = this.resourceComposite.getResource().getId();
- AlertCriteria criteria = new AlertCriteria();
- criteria.addFilterResourceIds(resourceId);
- PageControl pageControl = new PageControl(0, 5);
- criteria.setPageControl(pageControl);
GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForResource(resourceId, 5,
new AsyncCallback<PageList<MeasurementOOBComposite>>() {
@Override
@@ -535,32 +534,25 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
for (MeasurementOOBComposite oob : result) {
LocatableDynamicForm row = new LocatableDynamicForm(recentOobContent
.extendLocatorId("ContentForm"));
- row.setNumCols(3);
+ row.setNumCols(2);
+
+ LinkItem link = new LinkItem();
+ link.setLinkTitle(oob.getScheduleName() + ":");
+ link.setTitle(oob.getScheduleName() + ":");
+ //TODO: change link after charting updated for gwt.
+ link.setValue("/resource/common/monitor/Visibility.do?m=" + oob.getDefinitionId() + "&id="
+ + resourceId + "&mode=chartSingleMetricSingleResource");
+ link.setTarget("_self");
+ link.setShowTitle(false);
+
+ StaticTextItem time = new StaticTextItem();
+ time.setDefaultValue(GwtRelativeDurationConverter.format(oob.getTimestamp()));
+ time.setShowTitle(false);
+ time.setShowPickerIcon(false);
+ time.setWrap(false);
+ row.setItems(link, time);
- // StaticTextItem iconItem = new StaticTextItem();
- // FormItemIcon img = new FormItemIcon();
- // img.setSrc(ImageManager.getAlertIcon(alert.getAlertDefinition().getPriority()));
- // img.setWidth(16);
- // img.setHeight(16);
- // iconItem.setIcons(img);
- // iconItem.setShowTitle(false);
- //
- // LinkItem link = new LinkItem();
- // link.setLinkTitle(alert.getAlertDefinition().getName());
- // link.setTitle(alert.getAlertDefinition().getName());
- // link.setValue(ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Alerts/Definitions/"
- // + alert.getAlertDefinition().getId());
- // link.setTarget("_self");
- // link.setShowTitle(false);
- //
- // StaticTextItem time = new StaticTextItem();
- // time.setDefaultValue(new Date(alert.getAlertDefinition().getCtime()).toString());
- // time.setShowTitle(false);
- // time.setShowPickerIcon(false);
- // time.setWrap(false);
- // row.setItems(iconItem, link, time);
- //
- // column.addMember(row);
+ column.addMember(row);
}
} else {
LocatableDynamicForm row = new LocatableDynamicForm(recentOobContent
commit 0d7321357b81f8a502359546a2eefe58145dcaf3
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jan 21 16:06:28 2011 -0500
make the messagebar a little wider. also be able to double click it to make it go away so it stops being annoying
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
index 9aecd39..1731a7a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
@@ -23,6 +23,8 @@ import com.google.gwt.user.client.Timer;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
@@ -56,12 +58,21 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
setAlign(Alignment.CENTER);
label.setAlign(Alignment.CENTER);
- label.setWidth("400px");
+ label.setWidth("600px");
label.setHeight("25px");
setLabelEmpty();
addMember(label);
+ // sometimes its annoying to have the error message hang around for too long
+ // let the user click the message so it goes away on demand
+ addDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ clearMessage(true);
+ }
+ });
+
CoreGUI.getMessageCenter().addMessageListener(this);
}
commit 050324bde98297eb19e51efc636c9f056631d90f
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jan 21 14:20:26 2011 -0500
purge external files as well as the deploy dir
diff --git a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
index ca528ea..817b647 100644
--- a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
+++ b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
@@ -62,6 +62,7 @@ import org.rhq.core.util.file.FileUtil;
import org.rhq.core.util.stream.StreamUtil;
import org.rhq.core.util.updater.DeployDifferences;
import org.rhq.core.util.updater.DeploymentsMetadata;
+import org.rhq.core.util.updater.FileHashcodeMap;
/**
* @author John Mazzitelli
@@ -170,9 +171,6 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
return result;
}
- // TODO: this is copied from FileTemplate bundle plugin - I think we want to be more smart here since
- // we have more metadata about the live deployment to be purged in our .rhqdeployments (specifically about
- // the external raw files that we should delete)
public BundlePurgeResult purgeBundle(BundlePurgeRequest request) {
BundlePurgeResult result = new BundlePurgeResult();
try {
@@ -182,8 +180,56 @@ public class AntBundlePluginComponent implements ResourceComponent, BundleFacet
String deployDirAbsolutePath = deployDir.getAbsolutePath();
BundleManagerProvider bundleManagerProvider = request.getBundleManagerProvider();
+ // If the receipe copied file(s) outside of the deployment directory (external, raw files), they will still exist.
+ // Let's get the metadata information that tells us if such files exist, and if so, remove them.
+ DeploymentsMetadata metadata = new DeploymentsMetadata(deployDir);
+ if (metadata.isManaged()) {
+ int totalExternalFiles = 0;
+ ArrayList<String> deleteSuccesses = new ArrayList<String>(0);
+ ArrayList<String> deleteFailures = new ArrayList<String>(0);
+ FileHashcodeMap fileHashcodes = metadata.getCurrentDeploymentFileHashcodes();
+ for (String filePath : fileHashcodes.keySet()) {
+ File file = new File(filePath);
+ if (file.isAbsolute()) {
+ totalExternalFiles++;
+ if (file.exists()) {
+ if (file.delete()) {
+ deleteSuccesses.add(filePath);
+ } else {
+ deleteFailures.add(filePath);
+ }
+ } else {
+ deleteSuccesses.add(filePath); // someone already deleted it, consider it removed successfully
+ }
+ }
+ }
+ if (totalExternalFiles > 0) {
+ if (!deleteSuccesses.isEmpty()) {
+ StringBuilder deleteSuccessesDetails = new StringBuilder();
+ for (String path : deleteSuccesses) {
+ deleteSuccessesDetails.append(path).append("\n");
+ }
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge", "External files were purged",
+ Category.AUDIT_MESSAGE, Status.SUCCESS, "[" + deleteSuccesses.size() + "] of ["
+ + totalExternalFiles
+ + "] external files were purged. See attached details for the list",
+ deleteSuccessesDetails.toString());
+ }
+ if (!deleteFailures.isEmpty()) {
+ StringBuilder deleteFailuresDetails = new StringBuilder();
+ for (String path : deleteFailures) {
+ deleteFailuresDetails.append(path).append("\n");
+ }
+ bundleManagerProvider.auditDeployment(deploymentToPurge, "Purge",
+ "External files failed to be purged", Category.AUDIT_MESSAGE, Status.FAILURE, "["
+ + deleteFailures.size() + "] of [" + totalExternalFiles
+ + "] external files failed to be purged. See attached details for the list",
+ deleteFailuresDetails.toString());
+ }
+ }
+ }
+
// completely purge the deployment directory.
- // TODO: if the receipe copied a file outside of the deployment directory, it will still exist. How do we remove those?
FileUtil.purge(deployDir, true);
if (!deployDir.exists()) {
commit b832dafa882f0533d0038dfb7195cd3383cc30fb
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jan 21 11:01:05 2011 -0500
call with overlord
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index 3f56380..909c6ae 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -847,7 +847,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
// marks the live deployment "no longer live"
- bundleManager._finalizePurge(subject, liveDeployment, failedToPurge);
+ bundleManager._finalizePurge(subjectManager.getOverlord(), liveDeployment, failedToPurge);
// throw an exception if we failed to purge one or more resource deployments.
// since we are not in a tx context, we lose nothing. All DB updates have already been committed by now
commit 330fc2f698e7001fd3347c1284bc2ad33d92557e
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jan 21 16:38:28 2011 -0500
Don't generate errors when trying to switch to an invalid subtab, this can
happen due to our attempt at sticky tabbing. If it's not there just go
to the default subtab silently.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
index 0ad75df..2242211 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
@@ -216,7 +216,8 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo
// Do *not* select the tab and trigger the tab selected event until the subtab has been selected first.
subtab = (subtabName != null) ? tab.getSubTabByName(subtabName) : tab.getDefaultSubTab();
if (subtab == null || tab.getLayout().isSubTabDisabled(subtab)) {
- CoreGUI.getErrorHandler().handleError(MSG.view_tabs_invalidSubTab(subtabName));
+ // due to our attempt to perform sticky tabbing we may request an invalid subtab when
+ // switching resources. Just silently go to the default tab/subtab.
subtab = tab.getLayout().getDefaultSubTab();
}
tab.getLayout().selectSubTab(subtab);
commit 6807fb472cdb8d7f611423327ad505e79089b779
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jan 21 16:21:50 2011 -0500
Fix uninventory messages that say "delete". this confuses users.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index ff8d83c..51f5a28 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -166,19 +166,19 @@ public class ResourceSearchView extends Table {
availabilityField);
addTableAction(extendLocatorId("Uninventory"), MSG.common_button_uninventory(), MSG
- .view_inventory_resources_deleteConfirm(), new AbstractTableAction(TableActionEnablement.ANY) {
+ .view_inventory_resources_uninventoryConfirm(), new AbstractTableAction(TableActionEnablement.ANY) {
public void executeAction(ListGridRecord[] selection, Object actionValue) {
int[] resourceIds = TableUtility.getIds(selection);
ResourceGWTServiceAsync resourceManager = GWTServiceLookup.getResourceService();
resourceManager.uninventoryResources(resourceIds, new AsyncCallback<List<Integer>>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_inventory_resources_deleteFailed(), caught);
+ CoreGUI.getErrorHandler().handleError(MSG.view_inventory_resources_uninventoryFailed(), caught);
}
public void onSuccess(List<Integer> result) {
CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_inventory_resources_deleteSuccessful(), Severity.Info));
+ new Message(MSG.view_inventory_resources_uninventorySuccessful(), Severity.Info));
ResourceSearchView.this.refresh();
}
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 424cf7b..b8b4d13 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
@@ -1305,6 +1305,9 @@ view_inventory_resource_loadFailed = Resource with id [{0}] does not exist or is
view_inventory_resources_deleteConfirm = Are you sure you want to delete the selected resources?
view_inventory_resources_deleteSuccessful = You have successfully deleted the selected resources
view_inventory_resources_deleteFailed = Failed to delete the selected resources
+view_inventory_resources_uninventoryConfirm = Are you sure you want to uninventory the selected resources?
+view_inventory_resources_uninventorySuccessful = You have successfully uninventoried the selected resources
+view_inventory_resources_uninventoryFailed = Failed to uninventory the selected resources
view_inventory_resources_loadFailed = Failed to load resource composite data
view_inventory_resources_title = Member Resources
view_inventory_resources_title_children = Child Resources
commit a3afdeaa8bc543f6c7b81945b36377f96b02df2e
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jan 21 16:12:42 2011 -0500
Speed up InventorySummary by reducing the number of resource/group
queries/dbRoundTrips from 5 to 2.
- remove some now unused queries and methods
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
index dff6d58..dd14c13 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
@@ -307,6 +307,17 @@ import org.rhq.core.domain.util.Summary;
+ " FROM Resource res " //
+ " WHERE res.resourceType.category = :category " //
+ " AND (:inventoryStatus = res.inventoryStatus OR :inventoryStatus is null) "),
+ @NamedQuery(name = Resource.QUERY_FIND_RESOURCE_SUMMARY_BY_INVENTORY_STATUS, query = "" //
+ + "SELECT res.resourceType.category, count(*) " //
+ + " FROM Resource res " //
+ + " WHERE res.id IN (SELECT rr.id FROM Resource rr JOIN rr.implicitGroups g JOIN g.roles r JOIN r.subjects s WHERE s = :subject)"
+ + " AND (:inventoryStatus = res.inventoryStatus OR :inventoryStatus is null) " //
+ + " GROUP BY res.resourceType.category "),
+ @NamedQuery(name = Resource.QUERY_FIND_RESOURCE_SUMMARY_BY_INVENTORY_STATUS_ADMIN, query = "" //
+ + "SELECT res.resourceType.category, count(*) " //
+ + " FROM Resource res " //
+ + " WHERE (:inventoryStatus = res.inventoryStatus OR :inventoryStatus is null) " //
+ + " GROUP BY res.resourceType.category "),
// Returns all platforms that is either of a given inventory status itself or
// one of its top level servers have one of the inventory statuses (for auto-discovery queue).
@@ -347,12 +358,9 @@ import org.rhq.core.domain.util.Summary;
+ " WHERE res.resourceType = :type " //
+ " AND res.id IN (SELECT rr.id FROM Resource rr JOIN rr.implicitGroups g JOIN g.roles r JOIN r.subjects s WHERE s = :subject)"
+ " AND res.id IN ( :ids ) "),
- @NamedQuery(name = Resource.QUERY_FIND_IDS_BY_TYPE_IDS, query =
- "SELECT r.id "
- + "FROM Resource r "
+ @NamedQuery(name = Resource.QUERY_FIND_IDS_BY_TYPE_IDS, query = "SELECT r.id " + "FROM Resource r "
+ "WHERE r.resourceType.id IN (:resourceTypeIds)"),
- @NamedQuery(name = Resource.QUERY_FIND_COUNT_BY_TYPES, query =
- "SELECT COUNT(r) FROM Resource r WHERE r.resourceType.id IN (:resourceTypeIds)"),
+ @NamedQuery(name = Resource.QUERY_FIND_COUNT_BY_TYPES, query = "SELECT COUNT(r) FROM Resource r WHERE r.resourceType.id IN (:resourceTypeIds)"),
@NamedQuery(name = Resource.QUERY_FIND_BY_TYPE_AND_IDS_ADMIN, query = "" //
+ "SELECT res " //
+ " FROM Resource res " //
@@ -788,6 +796,9 @@ public class Resource implements Comparable<Resource>, Serializable {
public static final String QUERY_FIND_BY_CATEGORY_AND_INVENTORY_STATUS = "Resource.findByCategoryAndInventoryStatus";
public static final String QUERY_FIND_BY_CATEGORY_AND_INVENTORY_STATUS_ADMIN = "Resource.findByCategoryAndInventoryStatus_admin";
+ public static final String QUERY_FIND_RESOURCE_SUMMARY_BY_INVENTORY_STATUS = "Resource.findResourceSummaryByInventoryStatus";
+ public static final String QUERY_FIND_RESOURCE_SUMMARY_BY_INVENTORY_STATUS_ADMIN = "Resource.findResourceSummaryByInventoryStatus_admin";
+
public static final String QUERY_FIND_QUEUED_PLATFORMS_BY_INVENTORY_STATUS = "Resource.findQueuedPlatformsByInventoryStatus";
public static final String QUERY_FIND_BY_TYPE = "Resource.findByType";
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
index 810c8df..0a34e0c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
@@ -103,12 +103,18 @@ import org.rhq.core.domain.tagging.Tag;
+ " AND (type.plugin = :pluginName OR :pluginName is null) "
+ " AND (type.category = :category OR :category is null) ) ) "),
- @NamedQuery(name = ResourceGroup.QUERY_FIND_ALL_BY_CATEGORY_COUNT, query = "SELECT COUNT(DISTINCT rg) "
- + " FROM ResourceGroup AS rg JOIN rg.roles r JOIN r.subjects s " + " WHERE s = :subject "
- + " AND rg.visible = true " + " AND rg.groupCategory = :category "),
-
- @NamedQuery(name = ResourceGroup.QUERY_FIND_ALL_BY_CATEGORY_COUNT_admin, query = "SELECT COUNT(rg) "
- + " FROM ResourceGroup AS rg " + " WHERE rg.groupCategory = :category " + " AND rg.visible = true "),
+ @NamedQuery(name = ResourceGroup.QUERY_FIND_RESOURCE_GROUP_SUMMARY, query = "" //
+ + "SELECT rg.groupCategory, COUNT(DISTINCT rg) " //
+ + " FROM ResourceGroup AS rg JOIN rg.roles r JOIN r.subjects s " //
+ + " WHERE s = :subject " //
+ + " AND rg.visible = true " //
+ + " GROUP BY rg.groupCategory "),
+
+ @NamedQuery(name = ResourceGroup.QUERY_FIND_RESOURCE_GROUP_SUMMARY_admin, query = "" //
+ + "SELECT rg.groupCategory, COUNT(rg) " //
+ + " FROM ResourceGroup AS rg " //
+ + " WHERE rg.visible = true " //
+ + " GROUP BY rg.groupCategory "),
@NamedQuery(name = ResourceGroup.QUERY_FIND_BY_NAME, query = "SELECT rg FROM ResourceGroup AS rg WHERE LOWER(rg.name) = LOWER(:name)"),
@NamedQuery(name = ResourceGroup.QUERY_FIND_BY_CLUSTER_KEY, query = "SELECT rg FROM ResourceGroup AS rg WHERE rg.clusterKey = :clusterKey"),
@@ -192,8 +198,8 @@ public class ResourceGroup extends Group {
private static final long serialVersionUID = 1L;
//------- Names of Named Queries -------
- public static final String QUERY_FIND_ALL_BY_CATEGORY_COUNT = "ResourceGroup.findAllByCategory_Count";
- public static final String QUERY_FIND_ALL_BY_CATEGORY_COUNT_admin = "ResourceGroup.findAllByCategory_Count_admin";
+ public static final String QUERY_FIND_RESOURCE_GROUP_SUMMARY = "ResourceGroup.findResourceGroupSummary";
+ public static final String QUERY_FIND_RESOURCE_GROUP_SUMMARY_admin = "ResourceGroup.findResourceGroupSummary_admin";
public static final String QUERY_FIND_BY_NAME = "ResourceGroup.findByName";
public static final String QUERY_FIND_BY_CLUSTER_KEY = "ResourceGroup.findByClusterKey";
@@ -552,7 +558,7 @@ public class ResourceGroup extends Group {
this.roles.add(role);
}
- public void removeRole(Role role) {
+ public void removeRole(Role role) {
this.roles.remove(role);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
index f308609..70fbc3e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/summary/InventorySummaryPortlet.java
@@ -76,7 +76,7 @@ public class InventorySummaryPortlet extends LocatableVLayout implements AutoRef
form.destroy();
}
- resourceBossService.getInventorySummaryForLoggedInUser(new AsyncCallback<InventorySummary>() {
+ resourceBossService.getInventorySummary(new AsyncCallback<InventorySummary>() {
public void onFailure(Throwable throwable) {
CoreGUI.getErrorHandler().handleError(MSG.view_portlet_inventory_error1(), throwable);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceBossGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceBossGWTService.java
index 30531ad..afa44cb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceBossGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceBossGWTService.java
@@ -25,7 +25,6 @@ package org.rhq.enterprise.gui.coregui.client.gwt;
import com.google.gwt.user.client.rpc.RemoteService;
-import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.InventorySummary;
/**
@@ -33,8 +32,6 @@ import org.rhq.core.domain.resource.InventorySummary;
*/
public interface ResourceBossGWTService extends RemoteService {
- InventorySummary getInventorySummaryForLoggedInUser() throws RuntimeException;
-
- InventorySummary getInventorySummary(Subject user) throws RuntimeException;
+ InventorySummary getInventorySummary() throws RuntimeException;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java
index 046443d..34019fe 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java
@@ -23,7 +23,6 @@
package org.rhq.enterprise.gui.coregui.server.gwt;
-import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.InventorySummary;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceBossGWTService;
@@ -39,14 +38,10 @@ public class ResourceBossGWTServiceImpl extends AbstractGWTServiceImpl implement
private ResourceBossLocal resourceBoss = LookupUtil.getResourceBoss();
- public InventorySummary getInventorySummaryForLoggedInUser() {
- Subject subject = getSessionSubject();
- return getInventorySummary(subject);
- }
-
- public InventorySummary getInventorySummary(Subject user) throws RuntimeException {
+ public InventorySummary getInventorySummary() {
try {
- return resourceBoss.getInventorySummary(user);
+ // note: this does not need to be sent through SerialUtility.prepare as it has no entities
+ return resourceBoss.getInventorySummary(getSessionSubject());
} catch (Throwable t) {
throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceBossBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceBossBean.java
index ce7449f..a8480b6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceBossBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceBossBean.java
@@ -24,8 +24,6 @@ import javax.ejb.Stateless;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.InventorySummary;
-import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerLocal;
@@ -52,14 +50,15 @@ public class ResourceBossBean implements ResourceBossLocal {
public InventorySummary getInventorySummary(Subject user) {
InventorySummary summary = new InventorySummary();
- summary.setPlatformCount(resourceManager.getResourceCountByCategory(user, ResourceCategory.PLATFORM,
- InventoryStatus.COMMITTED));
- summary.setServerCount(resourceManager.getResourceCountByCategory(user, ResourceCategory.SERVER,
- InventoryStatus.COMMITTED));
- summary.setServiceCount(resourceManager.getResourceCountByCategory(user, ResourceCategory.SERVICE,
- InventoryStatus.COMMITTED));
- summary.setCompatibleGroupCount(groupManager.getResourceGroupCountByCategory(user, GroupCategory.COMPATIBLE));
- summary.setMixedGroupCount(groupManager.getResourceGroupCountByCategory(user, GroupCategory.MIXED));
+
+ int[] categoryCounts = resourceManager.getResourceCountSummary(user, InventoryStatus.COMMITTED);
+ summary.setPlatformCount(categoryCounts[0]);
+ summary.setServerCount(categoryCounts[1]);
+ summary.setServiceCount(categoryCounts[2]);
+
+ categoryCounts = groupManager.getResourceGroupCountSummary(user);
+ summary.setMixedGroupCount(categoryCounts[0]);
+ summary.setCompatibleGroupCount(categoryCounts[1]);
summary.setGroupDefinitionCount(groupDefinitionManager.getGroupDefinitionCount(user));
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 5f62fa9..e9d3b30 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -1091,6 +1091,38 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
return new PageList<Resource>(results, (int) count, pageControl);
}
+ @SuppressWarnings("unchecked")
+ public int[] getResourceCountSummary(Subject user, InventoryStatus status) {
+ Query query;
+ if (authorizationManager.isInventoryManager(user)) {
+ query = entityManager.createNamedQuery(Resource.QUERY_FIND_RESOURCE_SUMMARY_BY_INVENTORY_STATUS_ADMIN);
+ } else {
+ query = entityManager.createNamedQuery(Resource.QUERY_FIND_RESOURCE_SUMMARY_BY_INVENTORY_STATUS);
+ query.setParameter("subject", user);
+ }
+
+ query.setParameter("inventoryStatus", status);
+
+ int[] counts = new int[3];
+ List<Object[]> resultList = query.getResultList();
+
+ for (Object[] row : resultList) {
+ switch ((ResourceCategory) row[0]) {
+ case PLATFORM:
+ counts[0] = ((Long) row[1]).intValue();
+ break;
+ case SERVER:
+ counts[1] = ((Long) row[1]).intValue();
+ break;
+ case SERVICE:
+ counts[2] = ((Long) row[1]).intValue();
+ break;
+ }
+ }
+
+ return counts;
+ }
+
public int getResourceCountByCategory(Subject user, ResourceCategory category, InventoryStatus status) {
Query queryCount;
if (authorizationManager.isInventoryManager(user)) {
@@ -1211,6 +1243,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
return result;
}
+ @SuppressWarnings("unchecked")
public List<AutoGroupComposite> findResourcesAutoGroups(Subject subject, int[] resourceIds) {
List<AutoGroupComposite> results = new ArrayList<AutoGroupComposite>();
List<Integer> ids = ArrayUtils.wrapInList(resourceIds);
@@ -2009,6 +2042,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
String resourceKey = (String) prefetched[i++];
Integer parentId = (Integer) prefetched[i++];
+ @SuppressWarnings("unused")
String parentName = (String) prefetched[i++];
AvailabilityType availType = (AvailabilityType) prefetched[i++];
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
index 38d68b6..88a82e0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
@@ -218,7 +218,15 @@ public interface ResourceManagerLocal {
String pluginName, Resource parentResource, String searchString, boolean attachParentResource,
PageControl pageControl);
- // TODO GH: This would be more useful if it used a groupby to return a map of categories to their size
+ /**
+ * Get a summary of counts, by category, of the user's viewable resources having the provided inventory status.
+ *
+ * @param user
+ * @param status
+ * @return A 3 element int array with counts for platform, service, service as a[0], a[1], a[2], respectively.
+ */
+ int[] getResourceCountSummary(Subject user, InventoryStatus status);
+
int getResourceCountByCategory(Subject user, ResourceCategory category, InventoryStatus status);
int getResourceCountByTypeAndIds(Subject user, ResourceType type, int[] resourceIds);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
index a6c26e2..f4eb0b5 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
@@ -386,21 +386,31 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
group.getAlertDefinitions().size();
}
- public int getResourceGroupCountByCategory(Subject subject, GroupCategory category) {
- Query queryCount;
-
- if (authorizationManager.isInventoryManager(subject)) {
- queryCount = entityManager.createNamedQuery(ResourceGroup.QUERY_FIND_ALL_BY_CATEGORY_COUNT_admin);
+ @SuppressWarnings("unchecked")
+ public int[] getResourceGroupCountSummary(Subject user) {
+ Query query;
+ if (authorizationManager.isInventoryManager(user)) {
+ query = entityManager.createNamedQuery(ResourceGroup.QUERY_FIND_RESOURCE_GROUP_SUMMARY_admin);
} else {
- queryCount = entityManager.createNamedQuery(ResourceGroup.QUERY_FIND_ALL_BY_CATEGORY_COUNT);
- queryCount.setParameter("subject", subject);
+ query = entityManager.createNamedQuery(ResourceGroup.QUERY_FIND_RESOURCE_GROUP_SUMMARY);
+ query.setParameter("subject", user);
}
- queryCount.setParameter("category", category);
+ int[] counts = new int[2];
+ List<Object[]> resultList = query.getResultList();
- long count = (Long) queryCount.getSingleResult();
+ for (Object[] row : resultList) {
+ switch ((GroupCategory) row[0]) {
+ case MIXED:
+ counts[0] = ((Long) row[1]).intValue();
+ break;
+ case COMPATIBLE:
+ counts[1] = ((Long) row[1]).intValue();
+ break;
+ }
+ }
- return (int) count;
+ return counts;
}
@RequiredPermission(Permission.MANAGE_INVENTORY)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
index a0481b1..19cf42b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
@@ -67,7 +67,13 @@ public interface ResourceGroupManagerLocal {
ResourceGroup getResourceGroupById(Subject user, int id, GroupCategory category)
throws ResourceGroupNotFoundException;
- int getResourceGroupCountByCategory(Subject subject, GroupCategory category);
+ /**
+ * Get a summary of counts, by category, of the user's assigned, visible groups.
+ *
+ * @param user
+ * @return A 2 element int array with counts for mixed, compatible as a[0], a[1] respectively.
+ */
+ int[] getResourceGroupCountSummary(Subject user);
void enableRecursivityForGroup(Subject subject, int groupId) throws ResourceGroupNotFoundException,
ResourceGroupUpdateException;
commit bbadd202d97f72963f89684d08be5b8c4dbe5bd7
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jan 21 14:23:57 2011 -0500
Prevent a down agent from ruining the entire load of
PlatformSummaryPortlet. (when a Live data fetch fails).
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
index 2a3f023..95dd1df 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
@@ -138,7 +138,13 @@ public class PlatformSummaryPortlet extends LocatableListGrid implements Portlet
measurementService.findLiveData(resource.getId(), pmd.getDefinitionIds(),
new AsyncCallback<Set<MeasurementData>>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_portlet_platform_type_error_1(), caught);
+ // this can happen if the agent is down, don't crash out of the entire portlet
+ record.setAttribute("cpu", MSG.common_val_na());
+ record.setAttribute("memory", MSG.common_val_na());
+
+ setSortField(1);
+ refreshFields();
+ markForRedraw();
}
public void onSuccess(Set<MeasurementData> result) {
commit beab6a18acbc371d63deda331f9b1715014c5a79
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jan 19 11:56:51 2011 -0500
FavoriteResource Portlet Work - fixed configure() impl
...from the "how did this ever work at all" department. I guess something
must have changed in execution sequence that brought to the surface the
fact that this portlet was trying to set some listGrid state before the
listGrid was ready. Dashboards with this portlet would blow up.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
index dcf5c60..d861fad 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/FavoriteResourcesPortlet.java
@@ -29,6 +29,7 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.events.FieldStateChangedEvent;
import com.smartgwt.client.widgets.grid.events.FieldStateChangedHandler;
@@ -69,6 +70,8 @@ public class FavoriteResourcesPortlet extends ResourceSearchView implements Auto
@Override
protected void configureTable() {
+ super.configureTable();
+
Set<Integer> favoriteIds = UserSessionManager.getUserPreferences().getFavoriteResources();
Integer[] favArray = favoriteIds.toArray(new Integer[favoriteIds.size()]);
@@ -91,23 +94,22 @@ public class FavoriteResourcesPortlet extends ResourceSearchView implements Auto
}
});
- super.configureTable();
+ DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+ if ((null != storedPortlet && null != storedPortlet.getConfiguration())) {
+
+ PropertySimple tablePrefs = storedPortlet.getConfiguration().getSimple(CFG_TABLE_PREFS);
+ ListGrid listGrid = getListGrid();
+ if (null != tablePrefs && null != listGrid) {
+ String state = tablePrefs.getStringValue();
+ listGrid.setViewState(state);
+ }
+ }
}
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
if (null == this.portletWindow && null != portletWindow) {
this.portletWindow = portletWindow;
}
-
- if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
- return;
- }
-
- if (storedPortlet.getConfiguration().getSimple(CFG_TABLE_PREFS) != null) {
- String state = storedPortlet.getConfiguration().getSimple(CFG_TABLE_PREFS).getStringValue();
- getListGrid().setViewState(state);
- }
-
}
public Canvas getHelpCanvas() {
13 years, 3 months
[rhq] 4 commits - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java | 18 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java | 21 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java | 15 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java | 30 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java | 139 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java | 11
18 files changed, 154 insertions(+), 152 deletions(-)
New commits:
commit bb15343956a366d077ef1d2707688678b6c7d77f
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jan 25 17:33:58 2011 -0500
Fix a selenium locator id issue in Dash update
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index dbe0505..f652874 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -163,6 +163,10 @@ public class DashboardsView extends LocatableVLayout implements BookmarkableView
Canvas[] members = getMembers();
removeMembers(members);
+ if (null != tabSet) {
+ tabSet.destroy();
+ }
+
this.dashboardsByName = new HashMap<String, Dashboard>(dashboards.size());
for (Dashboard dashboard : dashboards) {
this.dashboardsByName.put(dashboard.getName(), dashboard);
commit a27efb2e62c8e579c7cb33756f5f1e8a2172fb03
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jan 25 17:33:23 2011 -0500
Where we were destroying a Layout's members with explicit code I replaced
it with a call to the existing SeleniumUtility.destroyMembers(). This
ensures that the member is both removed from the parent layout and
destroyed.
There are several remnaining places in the code where we call removeMembers()
without any destroy(). This is very possible fine but may also be a spot
where we could run into Id conflict.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
index 22417ce..01a5571 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
@@ -55,6 +55,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* A tree view of all known ResourceTypes, which includes summaries of metric schedule and alert definition templates
@@ -185,30 +186,21 @@ public class ResourceTypeTreeView extends LocatableVLayout implements Bookmarkab
* @param canvasToShow the canvas to show in the parent
*/
private void switchToCanvas(Layout parentCanvas, Canvas canvasToShow) {
- Canvas[] members = getMembers();
- if (members != null) {
- for (Canvas c : members) {
- parentCanvas.removeMember(c);
- }
- }
+ SeleniumUtility.destroyMembers(parentCanvas);
+
parentCanvas.addMember(canvasToShow);
parentCanvas.markForRedraw();
}
private void prepareSubCanvas(Layout parentCanvas, Canvas canvasToShow, boolean showBackButton) {
- Canvas[] members = getMembers();
- if (members != null) {
- for (Canvas c : members) {
- parentCanvas.removeMember(c);
- c.destroy();
- }
- }
+ SeleniumUtility.destroyMembers(parentCanvas);
if (showBackButton) {
String backLink = LinkManager.getAdminTemplatesLink().substring(1); // strip the #
BackButton backButton = new BackButton(extendLocatorId("BackButton"), "Back to List", backLink);
parentCanvas.addMember(backButton);
}
+
parentCanvas.addMember(canvasToShow);
parentCanvas.markForRedraw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
index 594cbb4..265167a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
@@ -29,7 +29,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.core.DataClass;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
@@ -87,9 +86,7 @@ public class AlertDetailsView extends LocatableVLayout implements BookmarkableVi
}
private void show(Alert alert) {
- for (Canvas child : getMembers()) {
- removeChild(child);
- }
+ destroyMembers();
Log.info("AlertDetailsView-Alert: " + alert);
ListGridRecord record = AlertDataSource.convert(alert);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
index 22f5569..6d2f8f6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
@@ -64,6 +64,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.Single
import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourcePicker.OkHandler;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* This notification form will be used for the Resource Operation sender. This form lets
@@ -521,22 +522,12 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
}
private void hideOperationArguments() {
- Canvas[] canvii = operationArgumentsCanvasItem.getMembers();
- if (canvii != null) {
- for (Canvas canvas : canvii) {
- canvas.destroy();
- }
- }
+ SeleniumUtility.destroyMembers(operationArgumentsCanvasItem);
markForRedraw();
}
private void showOperationArguments(ConfigurationDefinition def, Configuration config) {
- Canvas[] canvii = operationArgumentsCanvasItem.getMembers();
- if (canvii != null) {
- for (Canvas canvas : canvii) {
- canvas.destroy();
- }
- }
+ SeleniumUtility.destroyMembers(operationArgumentsCanvasItem);
if (def != null) {
ConfigurationEditor configEditor = new ConfigurationEditor(extendLocatorId("opArgs"), def, config);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java
index b66a340..2aab6e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleTopView.java
@@ -40,6 +40,7 @@ import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.content.repository.tree.ContentRepositoryTreeView;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableSectionStack;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* This is the main bundle view with left hand side trees and right hand side list/details view.
@@ -136,9 +137,8 @@ public class BundleTopView extends LocatableHLayout implements BookmarkableView
}
private void setContent(Canvas newContent) {
- for (Canvas c : contentCanvas.getMembers()) {
- c.destroy();
- }
+ SeleniumUtility.destroyMembers(contentCanvas);
+
contentCanvas.addMember(newContent);
contentCanvas.markForRedraw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
index cd25235..682b3d8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -293,9 +293,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* therefore, we need to explicitly destroy what's already there (presumably the detailsView
* in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
*/
- for (Canvas child : detailsHolder.getMembers()) {
- child.destroy();
- }
+ SeleniumUtility.destroyMembers(detailsHolder);
buildDetailsView();
}
@@ -335,9 +333,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
@Override
public void execute(boolean b) {
- for (Canvas child : detailsHolder.getMembers()) {
- child.destroy();
- }
+ SeleniumUtility.destroyMembers(detailsHolder);
contents.animateShow(AnimationEffect.WIPE);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java
index a964f0f..522c9cd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TagEditorView.java
@@ -30,7 +30,6 @@ import java.util.Set;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.TextMatchStyle;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.events.ClickEvent;
@@ -110,9 +109,7 @@ public class TagEditorView extends LocatableLayout {
}
private void setup() {
- for (Canvas child : getMembers()) {
- child.destroy();
- }
+ destroyMembers();
Layout layout = vertical ? new LocatableVLayout(getLocatorId()) : new LocatableHLayout(getLocatorId());
if (!vertical)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java
index b3e869a..9d5c382 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java
@@ -74,9 +74,7 @@ public class ResourceOperationHistoryDetailsView extends LocatableVLayout implem
protected void onDraw() {
super.onDraw();
- for (Canvas child : getMembers()) {
- child.destroy();
- }
+ destroyMembers();
if (this.operationHistory != null) {
displayDetails(operationHistory);
@@ -139,7 +137,8 @@ public class ResourceOperationHistoryDetailsView extends LocatableVLayout implem
errorLinkItem.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- final Window winModal = new LocatableWindow(ResourceOperationHistoryDetailsView.this.extendLocatorId("errorWin"));
+ final Window winModal = new LocatableWindow(ResourceOperationHistoryDetailsView.this
+ .extendLocatorId("errorWin"));
winModal.setTitle(MSG.common_title_details());
winModal.setOverflow(Overflow.VISIBLE);
winModal.setShowMinimizeButton(false);
@@ -260,5 +259,5 @@ public class ResourceOperationHistoryDetailsView extends LocatableVLayout implem
}
return errMsg;
}
-
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
index becbd02..6f27e8f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
@@ -26,7 +26,6 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Label;
import org.rhq.core.domain.measurement.DataType;
@@ -62,9 +61,7 @@ public class GraphListView extends LocatableVLayout implements ResourceSelectLis
protected void onDraw() {
super.onDraw();
- for (Canvas c : getMembers()) {
- c.destroy();
- }
+ destroyMembers();
addMember(new AvailabilityBarView(resource));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java
index 8fb1e41..5064527 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java
@@ -46,4 +46,9 @@ public class LocatableHLayout extends HLayout implements Locatable {
public String extendLocatorId(String extension) {
return this.locatorId + "_" + extension;
}
+
+ public void destroyMembers() {
+ SeleniumUtility.destroyMembers(this);
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java
index 7a2e99b..17c1f9c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java
@@ -31,4 +31,8 @@ public class LocatableLayout extends Layout implements Locatable {
return this.locatorId + "_" + extension;
}
+ public void destroyMembers() {
+ SeleniumUtility.destroyMembers(this);
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
index 160cf18..43893a6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
@@ -156,7 +156,16 @@ public class SeleniumUtility {
* @param layout
*/
static public <T extends Layout> void destroyMembers(T layout) {
- for (Canvas currentMember : layout.getMembers()) {
+ if (null == layout) {
+ return;
+ }
+
+ Canvas[] members = layout.getMembers();
+ if (null == members) {
+ return;
+ }
+
+ for (Canvas currentMember : members) {
layout.removeMember(currentMember);
currentMember.destroy();
}
commit 8ffdb1319a0a610e1222eb6b453b95a8d6965643
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jan 25 17:17:56 2011 -0500
Selenium Locator Work - Activity2 subtab
This class suffered from two main issues with its locator impl.
1) You don't need locators on "inaccessible" widgets. Often H/V/Layouts
are used purely for formatting and are not really part of any widget
parent-child identification scheme. In this case just use non-Locatable
widgets to keep things as simple as possible. I made these conversions in
a few places.
2) You can't use static locatorIds on multiple widgets. Basically, avoid
re-using the same locatorId for widgets created inside of a loop. There
were a few places like this where result rows are being looped through.
Note that not all data is conducive to unique identifiers. In several places
the best that we can do is to use unique rowNums in the locators.
In general tried to shorten up he locator id strings as possible. They need
to be unique and descriptive, but as short as needed is good.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
index 9930108..442dfce 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView2.java
@@ -36,6 +36,8 @@ import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.FormItemIcon;
import com.smartgwt.client.widgets.form.fields.LinkItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
@@ -59,11 +61,9 @@ import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecor
import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
import org.rhq.enterprise.gui.coregui.client.util.measurement.GwtMonitorUtils;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* The content pane of the Resource Summary>Activity tab.
@@ -73,19 +73,15 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
public class ActivityView2 extends LocatableHLayout implements RefreshableView {
//Locatable ui references
- private LocatableVLayout leftPane = new LocatableVLayout(extendLocatorId("Left"));;
- private LocatableVLayout rightPane = new LocatableVLayout(extendLocatorId("Right"));;
- private LocatableCanvas recentMeasurementsContent = new LocatableCanvas(leftPane
- .extendLocatorId("RecentMetricsContent"));
- private LocatableCanvas recentAlertsContent = new LocatableCanvas(leftPane.extendLocatorId("RecentAlertsContent"));
- private LocatableCanvas recentOobContent = new LocatableCanvas(leftPane.extendLocatorId("RecentOobsContent"));
- private LocatableCanvas recentConfigurationContent = new LocatableCanvas(rightPane
- .extendLocatorId("RecentConfigContent"));
- private LocatableCanvas recentOperationsContent = new LocatableCanvas(rightPane
- .extendLocatorId("RecentOperationsContent"));
- private LocatableCanvas recentEventsContent = new LocatableCanvas(rightPane.extendLocatorId("RecentEventsContent"));
- private LocatableCanvas recentPkgHistoryContent = new LocatableCanvas(rightPane
- .extendLocatorId("RecentPkgHistoryContent"));
+ private VLayout leftPane = new VLayout();;
+ private VLayout rightPane = new VLayout();;
+ private LocatableCanvas recentMeasurementsContent = new LocatableCanvas(extendLocatorId("RecentMetrics"));
+ private LocatableCanvas recentAlertsContent = new LocatableCanvas(extendLocatorId("RecentAlerts"));
+ private LocatableCanvas recentOobContent = new LocatableCanvas(extendLocatorId("RecentOobs"));
+ private LocatableCanvas recentConfigurationContent = new LocatableCanvas(extendLocatorId("RecentConfig"));
+ private LocatableCanvas recentOperationsContent = new LocatableCanvas(extendLocatorId("RecentOperations"));
+ private LocatableCanvas recentEventsContent = new LocatableCanvas(extendLocatorId("RecentEvents"));
+ private LocatableCanvas recentPkgHistoryContent = new LocatableCanvas(extendLocatorId("RecentPkgHistory"));
//retrieve localized text
private String RECENT_MEASUREMENTS = MSG.common_title_recent_measurements();
@@ -137,22 +133,19 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
leftPane.setAutoHeight();
//recentMetrics.xhtml
- LocatableHLayout recentMetricsTitle = new TitleWithIcon(leftPane, "RecentMetrics",
- "subsystems/monitor/Monitor_24.png", RECENT_MEASUREMENTS);
+ HLayout recentMetricsTitle = new TitleWithIcon("subsystems/monitor/Monitor_24.png", RECENT_MEASUREMENTS);
leftPane.addMember(recentMetricsTitle);
leftPane.addMember(recentMeasurementsContent);
recentMeasurementsContent.setHeight(20);
leftPane.addMember(divider1);
//recentAlerts.xhtml
- LocatableHLayout recentAlertsTitle = new TitleWithIcon(leftPane, "RecentAlerts",
- "subsystems/alert/Flag_blue_24.png", RECENT_ALERTS);
+ HLayout recentAlertsTitle = new TitleWithIcon("subsystems/alert/Flag_blue_24.png", RECENT_ALERTS);
leftPane.addMember(recentAlertsTitle);
leftPane.addMember(recentAlertsContent);
recentAlertsContent.setHeight(20);
leftPane.addMember(divider2);
//recentOOBs.xhtml
- LocatableHLayout recentOobsTitle = new TitleWithIcon(leftPane, "RecentOobs",
- "subsystems/monitor/Monitor_failed_24.png", RECENT_OOB);
+ HLayout recentOobsTitle = new TitleWithIcon("subsystems/monitor/Monitor_failed_24.png", RECENT_OOB);
leftPane.addMember(recentOobsTitle);
leftPane.addMember(recentOobContent);
recentOobContent.setHeight(20);
@@ -163,29 +156,26 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
rightPane.setMembersMargin(5);
rightPane.setAutoHeight();
//recentConfigUpdates.xhtml
- LocatableHLayout recentConfigUpdatesTitle = new TitleWithIcon(leftPane, "RecentConfigUpdates",
- "subsystems/configure/Configure_24.png", RECENT_CONFIGURATIONS);
+ HLayout recentConfigUpdatesTitle = new TitleWithIcon("subsystems/configure/Configure_24.png",
+ RECENT_CONFIGURATIONS);
rightPane.addMember(recentConfigUpdatesTitle);
rightPane.addMember(recentConfigurationContent);
recentConfigurationContent.setHeight(20);
rightPane.addMember(divider3);
//recentOperations.xhtml
- LocatableHLayout recentOperationsTitle = new TitleWithIcon(leftPane, "RecentOperations",
- "subsystems/control/Operation_24.png", RECENT_OPERATIONS);
+ HLayout recentOperationsTitle = new TitleWithIcon("subsystems/control/Operation_24.png", RECENT_OPERATIONS);
rightPane.addMember(recentOperationsTitle);
rightPane.addMember(recentOperationsContent);
recentOperationsContent.setHeight(20);
rightPane.addMember(divider4);
//recentEventCounts.xhtml
- LocatableHLayout recentEventsTitle = new TitleWithIcon(leftPane, "RecentEvent",
- "subsystems/event/Events_24.png", RECENT_EVENTS);
+ HLayout recentEventsTitle = new TitleWithIcon("subsystems/event/Events_24.png", RECENT_EVENTS);
rightPane.addMember(recentEventsTitle);
rightPane.addMember(recentEventsContent);
recentEventsContent.setHeight(20);
rightPane.addMember(divider5);
//recentPackageHistory.xhtml
- LocatableHLayout recentPkgHistoryTitle = new TitleWithIcon(leftPane, "RecentPkgHistory",
- "subsystems/content/Content_24.png", RECENT_PKG_HISTORY);
+ HLayout recentPkgHistoryTitle = new TitleWithIcon("subsystems/content/Content_24.png", RECENT_PKG_HISTORY);
rightPane.addMember(recentPkgHistoryTitle);
rightPane.addMember(recentPkgHistoryContent);
recentPkgHistoryContent.setHeight(20);
@@ -225,14 +215,10 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
/**Creates the section top titles with icon for regions of Activity page.
*/
- class TitleWithIcon extends LocatableHLayout {
+ class TitleWithIcon extends HLayout {
- public TitleWithIcon(String locatorId) {
- super(locatorId);
- }
-
- public TitleWithIcon(Locatable parentContainer, String locatorIdentifier, String imageUrl, String title) {
- super(parentContainer.extendLocatorId(locatorIdentifier));
+ public TitleWithIcon(String imageUrl, String title) {
+ super();
Img titleImage = new Img(imageUrl, 24, 24);
HTMLFlow titleElement = new HTMLFlow();
titleElement.setWidth("*");
@@ -258,11 +244,15 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
GWTServiceLookup.getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
@Override
public void onSuccess(PageList<Alert> result) {
- LocatableVLayout column = new LocatableVLayout(recentAlertsContent.extendLocatorId("Content"));
+ VLayout column = new VLayout();
column.setHeight(10);
if (!result.isEmpty()) {
+ int rowNum = 0;
for (Alert alert : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ // alert history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
row.setNumCols(3);
StaticTextItem iconItem = newTextItemIcon(ImageManager.getAlertIcon(alert.getAlertDefinition()
@@ -275,7 +265,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_ALERTS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentAlertsContent.extendLocatorId("None"),
+ RECENT_ALERTS_NONE);
column.addMember(row);
}
for (Canvas child : recentAlertsContent.getChildren()) {
@@ -311,11 +302,15 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
@Override
public void onSuccess(List<DisambiguationReport<ResourceOperationLastCompletedComposite>> result) {
- LocatableVLayout column = new LocatableVLayout(recentOperationsContent.extendLocatorId("Content"));
+ VLayout column = new VLayout();
column.setHeight(10);
if (!result.isEmpty()) {
+ int rowNum = 0;
for (DisambiguationReport<ResourceOperationLastCompletedComposite> report : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ // operation history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
+ .extendLocatorId(String.valueOf(rowNum)));
row.setNumCols(3);
StaticTextItem iconItem = newTextItemIcon(ImageManager.getOperationResultsIcon(report
@@ -331,7 +326,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_OPERATIONS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentOperationsContent
+ .extendLocatorId("None"), RECENT_OPERATIONS_NONE);
column.addMember(row);
}
for (Canvas child : recentOperationsContent.getChildren()) {
@@ -363,12 +359,15 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
@Override
public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
- LocatableVLayout column = new LocatableVLayout(recentConfigurationContent
- .extendLocatorId("Content"));
+ VLayout column = new VLayout();
column.setHeight(10);
if (!result.isEmpty()) {
+ int rowNum = 0;
for (ResourceConfigurationUpdate update : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ // config update history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
+ .extendLocatorId(String.valueOf(rowNum)));
row.setNumCols(3);
StaticTextItem iconItem = newTextItemIcon(ImageManager.getResourceConfigurationIcon(update
@@ -387,7 +386,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_CONFIGURATIONS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentConfigurationContent
+ .extendLocatorId("None"), RECENT_CONFIGURATIONS_NONE);
column.addMember(row);
}
//cleanup
@@ -429,12 +429,16 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
}
}
//build display
- LocatableVLayout column = new LocatableVLayout(recentEventsContent.extendLocatorId("Content"));
+ VLayout column = new VLayout();
column.setHeight(10);
if (!results.isEmpty()) {
+ int rowNum = 0;
for (GwtTuple<EventSeverity, Integer> tuple : results) {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ // event history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent
+ .extendLocatorId(String.valueOf(rowNum)));
row.setNumCols(2);
row.setWidth(10);//pack.
@@ -448,7 +452,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_EVENTS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentEventsContent.extendLocatorId("None"),
+ RECENT_EVENTS_NONE);
column.addMember(row);
}
//cleanup
@@ -476,11 +481,12 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
@Override
public void onSuccess(PageList<MeasurementOOBComposite> result) {
- LocatableVLayout column = new LocatableVLayout(recentAlertsContent.extendLocatorId("Content"));
+ VLayout column = new VLayout();
column.setHeight(10);
if (!result.isEmpty()) {
for (MeasurementOOBComposite oob : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(recentOobContent.extendLocatorId(oob
+ .getScheduleName()));
row.setNumCols(2);
String title = oob.getScheduleName() + ":";
@@ -493,7 +499,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_OOB_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentOobContent.extendLocatorId("None"),
+ RECENT_OOB_NONE);
column.addMember(row);
}
recentOobContent.setContents("");
@@ -525,11 +532,13 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
@Override
public void onSuccess(PageList<InstalledPackageHistory> result) {
- LocatableVLayout column = new LocatableVLayout(recentPkgHistoryContent.extendLocatorId("Content"));
+ VLayout column = new VLayout();
column.setHeight(10);
if (!result.isEmpty()) {
for (InstalledPackageHistory history : result) {
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(recentPkgHistoryContent
+ .extendLocatorId(history.getPackageVersion().getFileName()
+ + history.getPackageVersion().getVersion()));
row.setNumCols(3);
StaticTextItem iconItem = newTextItemIcon("subsystems/content/Content_16.png", null);
@@ -544,7 +553,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
column.addMember(row);
}
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_PKG_HISTORY_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentPkgHistoryContent
+ .extendLocatorId("None"), RECENT_PKG_HISTORY_NONE);
column.addMember(row);
}
//cleanup
@@ -563,7 +573,7 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
*/
private void getRecentMetrics() {
//display container
- final LocatableVLayout column = new LocatableVLayout(recentMeasurementsContent.extendLocatorId("Content"));
+ final VLayout column = new VLayout();
column.setHeight(10);//pack
final int resourceId = this.resourceComposite.getResource().getId();
@@ -635,7 +645,8 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
commaDelimitedList += d.getValue() + ",";
}
}
- LocatableDynamicForm row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
+ LocatableDynamicForm row = new LocatableDynamicForm(recentMeasurementsContent
+ .extendLocatorId(md.getName()));
row.setNumCols(3);
HTMLFlow graph = new HTMLFlow();
// String contents = "<span id='sparkline_" + index + "' class='dynamicsparkline' width='0'>"
@@ -673,13 +684,15 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
}
}
if (!someChartedData) {// when there are results but no chartable entries.
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_MEASUREMENTS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"), RECENT_MEASUREMENTS_NONE);
column.addMember(row);
}
//call out to 3rd party javascript lib
graphSparkLines();
} else {
- LocatableDynamicForm row = createEmptyDisplayRow(column, RECENT_MEASUREMENTS_NONE);
+ LocatableDynamicForm row = createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"), RECENT_MEASUREMENTS_NONE);
column.addMember(row);
}
}
@@ -725,13 +738,9 @@ public class ActivityView2 extends LocatableHLayout implements RefreshableView {
* @param emptyMessage Contents of the empty region
* @return
*/
- private LocatableDynamicForm createEmptyDisplayRow(Locatable column, String emptyMessage) {
+ private LocatableDynamicForm createEmptyDisplayRow(String locatorId, String emptyMessage) {
LocatableDynamicForm row = null;
- if (column != null) {
- row = new LocatableDynamicForm(column.extendLocatorId("ContentForm"));
- } else {
- row = new LocatableDynamicForm(extendLocatorId("ContentForm"));
- }
+ row = new LocatableDynamicForm(locatorId);
row.setNumCols(3);
StaticTextItem none = new StaticTextItem();
commit 9208c64bbd017abca809113633547dbb18fdea85
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jan 25 17:09:32 2011 -0500
Selenium Locator Work - Fix a problem in AbstractSelector.onDestroy().
We have to be careful of destroying things manually that are also destroyed
automatically by SmartGwt. In general, destroying a parent will destroy
it's children automatically. For example, destroying a SectionStack as a
whole, destroying a Layout, Window, etc.
We are still usually on the hook for member canvas's.
Calling destroy() on a widget that has already been destroyed will
force an unwanted reinitialization (onInit) of the widget (just so it can
be properly destroyed immediately following). This behavior isn't great in
smartgwt, I wonder if they could change this...
This instance of the issue was in the Alert Notification Sender definition
call chain. I'm sure it would have cropped up in other places as well.
Also, in general we don't use markForDestroy() but rather destroy() for
immediate removal from the DOM. This protectes against selenium ID
conflict.
- there is still one onInit() reinvocation I'm not able to explain. I
protected against it.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
index 0b8bfbd..7d2ae83 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
@@ -35,8 +35,8 @@ public class ResourceOperationLastCompletedComposite extends OperationLastComple
//no args constructor. Not to be used. java bean/serialization requirement
private ResourceOperationLastCompletedComposite() {
super();
- this.resourceTypeName = "(unitialized type)";
- this.resourceName = "(unitialized)";
+ this.resourceTypeName = "(uninitialized type)";
+ this.resourceName = "(uninitialized)";
this.resourceId = 0;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
index c36e7c2..bcea118 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewNotificationEditor.java
@@ -29,7 +29,6 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
@@ -39,6 +38,7 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+import com.smartgwt.client.widgets.layout.Layout;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
@@ -47,6 +47,7 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
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.SeleniumUtility;
/**
* @author John Mazzitelli
@@ -60,9 +61,10 @@ public class NewNotificationEditor extends LocatableDynamicForm {
private SelectItem notificationSenderSelectItem;
private CanvasItem senderCanvasItem;
+ private boolean senderCanvasInitialized = false;
- public NewNotificationEditor(String locatorId, AlertDefinition alertDefinition,
- List<AlertNotification> notifs, AlertNotification notifToEdit, Runnable closeFunc) {
+ public NewNotificationEditor(String locatorId, AlertDefinition alertDefinition, List<AlertNotification> notifs,
+ AlertNotification notifToEdit, Runnable closeFunc) {
super(locatorId);
this.alertDefinition = alertDefinition;
@@ -114,6 +116,7 @@ public class NewNotificationEditor extends LocatableDynamicForm {
notificationSenderSelectItem.setValueMap(senders);
notificationSenderSelectItem.setDisabled(false);
notificationSenderSelectItem.redraw();
+
switchToAlertSender(result[0]);
senderCanvasItem.show();
} else {
@@ -203,11 +206,15 @@ public class NewNotificationEditor extends LocatableDynamicForm {
}
private void switchToAlertSender(String newAlertSender) {
- Canvas oldCanvas = senderCanvasItem.getCanvas();
- if (oldCanvas != null) {
- oldCanvas.markForDestroy();
- }
AbstractNotificationSenderForm newCanvas = createNotificationSenderForm(newAlertSender);
+ // wipe existing DOM to avoid id conflicts. Use this flag to avoid having getCanvas() general a default
+ // Canvas on the first "switch".
+ if (senderCanvasInitialized) {
+ Layout senderLayout = (Layout) senderCanvasItem.getCanvas();
+ SeleniumUtility.destroyMembers(senderLayout);
+ senderLayout.destroy();
+ }
+ senderCanvasInitialized = true;
senderCanvasItem.setCanvas(newCanvas);
markForRedraw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
index d63159b..970fb66 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -258,8 +258,7 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
ListGrid listGrid = (ListGrid) event.getSource();
ListGridRecord[] selectedRows = listGrid.getSelection();
if (selectedRows != null && selectedRows.length == 1) {
- AlertNotification notif = (getDataSource())
- .copyValues(selectedRows[0]);
+ AlertNotification notif = (getDataSource()).copyValues(selectedRows[0]);
popupNotificationEditor(notif);
}
}
@@ -306,7 +305,7 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
winModal.addCloseClickHandler(new CloseClickHandler() {
@Override
public void onCloseClick(CloseClientEvent event) {
- winModal.markForDestroy();
+ winModal.destroy();
}
});
@@ -314,7 +313,7 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
alertDefinition, notifications, notifToEdit, new Runnable() {
@Override
public void run() {
- winModal.markForDestroy();
+ winModal.destroy();
table.refresh();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java
index 726bdc5..7e45d52 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java
@@ -56,12 +56,22 @@ public class SystemUsersNotificationSenderForm extends AbstractNotificationSende
private SubjectSelector selector;
+ private boolean isInitialized = false;
+
public SystemUsersNotificationSenderForm(String locatorId, AlertNotification notif, String sender) {
super(locatorId, notif, sender);
}
@Override
protected void onInit() {
+ // for reasons I'm not sure about, perhaps due to the way NewNotificationEditor destroys its own parent
+ // via callback, this onInit may be called a second time, during the destroy() call chain. Prevent
+ // it from re-executing.
+ if (isInitialized) {
+ return;
+ }
+ isInitialized = true;
+
super.onInit();
String subjectIds = getConfiguration().getSimpleValue(PROPNAME, ""); // we know the subject plugin defines this
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
index e23c0f1..062a47f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
@@ -65,6 +65,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTransferImgButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
@@ -202,6 +203,11 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
addMember(this.hlayout);
}
+ @Override
+ protected void onDestroy() {
+ SeleniumUtility.destroyMembers(hlayout);
+ }
+
private SectionStack buildAvailableItemsStack() {
SectionStack availableSectionStack = new SectionStack();
availableSectionStack.setWidth(300);
@@ -265,7 +271,7 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
}
// Add event handlers.
-
+
this.availableGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
updateButtonEnablement();
@@ -311,7 +317,7 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
}
} else {
availableRecords.addAll(Arrays.asList(allRecords));
- }
+ }
availableGrid.setData(availableRecords.toArray(new Record[availableRecords.size()]));
} finally {
updateButtonEnablement();
@@ -507,26 +513,6 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
return MSG.view_selector_assigned(itemTitle);
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
-
- assignedGrid.destroy();
-
- if (!isReadOnly) {
- if (availableFilterForm != null) {
- availableFilterForm.destroy();
- }
-
- availableGrid.destroy();
-
- addButton.destroy();
- removeButton.destroy();
- addAllButton.destroy();
- removeAllButton.destroy();
- }
- }
-
protected void updateButtonEnablement() {
if (!isReadOnly) {
addButton.setDisabled(!availableGrid.anySelected());
13 years, 3 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java | 24 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 9 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java | 79 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java | 54 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java | 16 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java | 41 -----
6 files changed, 162 insertions(+), 61 deletions(-)
New commits:
commit bf649fa1066cd6d7b261c942f6527ba1ca7e4872
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Jan 25 19:25:29 2011 -0500
implement group Operations>History subtab; remove ability to schedule new operations off Resource Operations>History subtab (may add back later depending on feedback from UXD team)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java
index 1152459..c320d10 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java
@@ -18,29 +18,22 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history;
-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.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
-import org.rhq.core.domain.operation.ResourceOperationHistory;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.core.domain.operation.OperationHistory;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import java.util.Date;
+import java.util.List;
+
/**
* @author Greg Hinkle
*/
-public abstract class OperationHistoryDataSource extends RPCDataSource<ResourceOperationHistory> {
+public abstract class OperationHistoryDataSource<T extends OperationHistory> extends RPCDataSource<T> {
public static abstract class Field {
public static final String ID = "id";
@@ -92,18 +85,17 @@ public abstract class OperationHistoryDataSource extends RPCDataSource<ResourceO
}
@Override
- public ResourceOperationHistory copyValues(Record from) {
- throw new UnsupportedOperationException("ResourceOperationHistory is read only.");
+ public T copyValues(Record from) {
+ throw new UnsupportedOperationException("OperationHistory is read only.");
}
@Override
- public ListGridRecord copyValues(ResourceOperationHistory from) {
+ public ListGridRecord copyValues(T from) {
ListGridRecord record = new ListGridRecord();
record.setAttribute(Field.ID, from.getId());
record.setAttribute(Field.CREATED_TIME, from.getCreatedTime());
record.setAttribute(Field.STARTED_TIME, new Date(from.getStartedTime()));
record.setAttribute(Field.DURATION, from.getDuration());
- record.setAttribute(Field.RESOURCE, from.getResource());
record.setAttribute(Field.SUBJECT, from.getSubjectName());
record.setAttribute(Field.OPERATION_DEFINITION, from.getOperationDefinition());
record.setAttribute(Field.OPERATION_NAME, from.getOperationDefinition().getDisplayName());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 9b18b47..cca83f5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -57,6 +57,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.H
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.MembersView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule.GroupOperationScheduleListView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.ActivityView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
@@ -233,7 +234,7 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
updateSummaryTab();
updateMonitoringTab(groupId, groupCategory, facets);
updateInventoryTab(groupId, facets);
- updateOperationsTab(groupId, groupCategory, facets);
+ updateOperationsTab(groupCategory, facets);
updateAlertsTab(groupComposite, groupCategory);
updateConfigurationTab(groupId, groupCategory, facets);
updateEventsTab(groupComposite, groupCategory, facets);
@@ -293,14 +294,14 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION), true);
}
- private void updateOperationsTab(int groupId, GroupCategory groupCategory, Set<ResourceTypeFacet> facets) {
+ private void updateOperationsTab(GroupCategory groupCategory, Set<ResourceTypeFacet> facets) {
if (updateTab(this.operationsTab, groupCategory == GroupCategory.COMPATIBLE
&& facets.contains(ResourceTypeFacet.OPERATION), true)) {
updateSubTab(this.operationsTab, this.operationsSchedule,
new GroupOperationScheduleListView(this.operationsSchedule.extendLocatorId("View"),
this.groupComposite), true, true);
- updateSubTab(this.operationsTab, this.operationsHistory, new FullHTMLPane(this.operationsHistory.extendLocatorId("View"),
- "/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId), true, true);
+ updateSubTab(this.operationsTab, this.operationsHistory, new GroupOperationHistoryListView(
+ this.operationsHistory.extendLocatorId("View"), this.groupComposite), true, true);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java
new file mode 100644
index 0000000..d02949a
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java
@@ -0,0 +1,79 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, 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.inventory.groups.detail.operation.history;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
+import org.rhq.core.domain.operation.GroupOperationHistory;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.OperationHistoryDataSource;
+
+import java.util.Arrays;
+
+/**
+ * @author Ian Springer
+ */
+public class GroupOperationHistoryDataSource extends OperationHistoryDataSource<GroupOperationHistory> {
+
+ public static abstract class Field extends OperationHistoryDataSource.Field {
+ public static final String GROUP = "group";
+ }
+
+ public static abstract class CriteriaField {
+ public static final String GROUP_ID = "groupId";
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+ GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
+
+ if (request.getCriteria().getValues().containsKey(CriteriaField.GROUP_ID)) {
+ int groupId = Integer.parseInt((String)request.getCriteria().getValues().get(
+ CriteriaField.GROUP_ID));
+ criteria.addFilterResourceGroupIds(Arrays.asList(groupId));
+ }
+
+ criteria.setPageControl(getPageControl(request));
+
+ operationService.findGroupOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<GroupOperationHistory>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.dataSource_operationHistory_error_fetchFailure(), caught);
+ }
+
+ public void onSuccess(PageList<GroupOperationHistory> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @Override
+ public ListGridRecord copyValues(GroupOperationHistory from) {
+ ListGridRecord record = super.copyValues(from);
+ record.setAttribute(Field.GROUP, from.getGroup());
+ return record;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
new file mode 100644
index 0000000..9206e4f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
@@ -0,0 +1,54 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, 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.inventory.groups.detail.operation.history;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.widgets.Canvas;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource;
+
+/**
+ * @author Ian Springer
+ */
+public class GroupOperationHistoryListView extends AbstractOperationHistoryListView {
+
+ private ResourceGroupComposite groupComposite;
+
+ public GroupOperationHistoryListView(String locatorId, ResourceGroupComposite groupComposite) {
+ super(locatorId, new ResourceOperationHistoryDataSource(), null,
+ new Criteria(GroupOperationHistoryDataSource.CriteriaField.GROUP_ID,
+ String.valueOf(groupComposite.getResourceGroup().getId())));
+ this.groupComposite = groupComposite;
+ }
+
+ @Override
+ protected void configureTable() {
+ super.configureTable();
+
+ // TODO: Add Delete button.
+ }
+
+ @Override
+ public Canvas getDetailsView(int id) {
+ return new Canvas();
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
index e350042..447ec17 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
@@ -23,8 +23,12 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
+import org.rhq.core.domain.operation.OperationHistory;
import org.rhq.core.domain.operation.ResourceOperationHistory;
+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.inventory.common.detail.operation.history.OperationHistoryDataSource;
@@ -32,7 +36,11 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.h
/**
* @author Ian Springer
*/
-public class ResourceOperationHistoryDataSource extends OperationHistoryDataSource {
+public class ResourceOperationHistoryDataSource extends OperationHistoryDataSource<ResourceOperationHistory> {
+
+ public static abstract class Field extends OperationHistoryDataSource.Field {
+ public static final String RESOURCE = "resource";
+ }
public static abstract class CriteriaField {
public static final String RESOURCE_ID = "resourceId";
@@ -63,5 +71,11 @@ public class ResourceOperationHistoryDataSource extends OperationHistoryDataSour
});
}
+ @Override
+ public ListGridRecord copyValues(ResourceOperationHistory from) {
+ ListGridRecord record = super.copyValues(from);
+ record.setAttribute(Field.RESOURCE, from.getResource());
+ return record;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
index 172da98..086b39d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
@@ -19,26 +19,11 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history;
-import java.util.EnumSet;
-
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.menu.IMenuButton;
-import com.smartgwt.client.widgets.menu.Menu;
-import com.smartgwt.client.widgets.menu.MenuItem;
-import com.smartgwt.client.widgets.menu.events.ClickHandler;
-import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
-
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.ResourceOperationHistoryDetailsView;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationCreateWizard;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableMenu;
/**
* @author Ian Springer
@@ -58,31 +43,7 @@ public class ResourceOperationHistoryListView extends AbstractOperationHistoryLi
protected void configureTable() {
super.configureTable();
- if (this.resourceComposite.getResourcePermission().isControl()) {
- final Resource resource = this.resourceComposite.getResource();
- final Menu operationMenu = new LocatableMenu(this.extendLocatorId("Operation"));
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.operations),
- new ResourceTypeRepository.TypeLoadedCallback() {
- public void onTypesLoaded(ResourceType type) {
- for (final OperationDefinition operationDefinition : type.getOperationDefinitions()) {
- MenuItem menuItem = new MenuItem(operationDefinition.getDisplayName());
- operationMenu.addItem(menuItem);
- menuItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- new OperationCreateWizard(resource, operationDefinition).startOperationWizard();
- }
- });
- }
- }
- });
-
- IMenuButton operationsButton = new LocatableIMenuButton(this.extendLocatorId("Run"),
- MSG.view_operationHistoryList_button_runOperation(), operationMenu);
- operationsButton.setShowMenuBelow(false);
- operationsButton.setAutoFit(true);
- addExtraWidget(operationsButton);
- }
+ // TODO: Add Delete button.
}
@Override
13 years, 3 months
[rhq] modules/enterprise
by Simeon Pinder
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java | 48 ++++------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/ResourceOperationJob.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/support/SupportManagerBean.java | 6 +
4 files changed, 28 insertions(+), 30 deletions(-)
New commits:
commit 20771d028323aba36aafd18837a029a53d16e081
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Jan 25 18:33:09 2011 -0500
BZ-672705: adding missing upgrade to overlord for getAgentClient().
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
index 8bfa5cd..45f7832 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
@@ -166,17 +166,15 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
}
}
- public int scheduleResourceOperation(Subject subject, ResourceOperationSchedule schedule)
- throws ScheduleException {
+ public int scheduleResourceOperation(Subject subject, ResourceOperationSchedule schedule) throws ScheduleException {
JobTrigger jobTrigger = schedule.getJobTrigger();
Trigger trigger = convertToTrigger(jobTrigger);
try {
- ResourceOperationSchedule resourceOperationSchedule = scheduleResourceOperation(subject,
- schedule.getResource().getId(), schedule.getOperationName(), schedule.getParameters(), trigger,
- schedule.getDescription());
+ ResourceOperationSchedule resourceOperationSchedule = scheduleResourceOperation(subject, schedule
+ .getResource().getId(), schedule.getOperationName(), schedule.getParameters(), trigger, schedule
+ .getDescription());
return resourceOperationSchedule.getId();
- }
- catch (SchedulerException e) {
+ } catch (SchedulerException e) {
throw new ScheduleException(e);
}
}
@@ -496,7 +494,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
int entityId;
if (entityIdObj != null) {
// for jobs created using RHQ 4.0 or later, the map will contain an entityId entry
- entityId = Integer.valueOf((String)entityIdObj);
+ entityId = Integer.valueOf((String) entityIdObj);
} else {
// for jobs created prior to upgrading to RHQ 4.0, the map will not contain an entityId entry,
// so we'll need to lookup the entity id from the DB.
@@ -915,7 +913,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
boolean canceled = false;
try {
- agent = agentManager.getAgentClient(subject, resourceId);
+ agent = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
// since this method is usually called by the UI, we want to quickly determine if we can even talk to the agent
if (agent.ping(5000L)) {
@@ -1477,8 +1475,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
Subject overlord = subjectManager.getOverlord();
for (ResourceOperationScheduleComposite composite : results) {
try {
- ResourceOperationSchedule sched = getResourceOperationSchedule(subject, composite.getJobId()
- .toString());
+ ResourceOperationSchedule sched = getResourceOperationSchedule(subject, composite.getJobId().toString());
OperationDefinition def = getSupportedResourceOperation(overlord, composite.getResourceId(), sched
.getOperationName(), false);
composite.setOperationName((def.getDisplayName() != null) ? def.getDisplayName() : sched
@@ -1531,8 +1528,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
Subject overlord = subjectManager.getOverlord();
for (GroupOperationScheduleComposite composite : results) {
try {
- GroupOperationSchedule sched = getGroupOperationSchedule(subject, composite.getJobId()
- .toString());
+ GroupOperationSchedule sched = getGroupOperationSchedule(subject, composite.getJobId().toString());
OperationDefinition def = getSupportedGroupOperation(overlord, composite.getGroupId(), sched
.getOperationName(), false);
composite.setOperationName((def.getDisplayName() != null) ? def.getDisplayName() : sched
@@ -1816,7 +1812,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
query.setParameter("jobName", jobName);
String jobGroup = jobId.getJobGroup();
query.setParameter("jobGroup", jobGroup);
- OperationScheduleEntity operationScheduleEntity = (OperationScheduleEntity)query.getSingleResult();
+ OperationScheduleEntity operationScheduleEntity = (OperationScheduleEntity) query.getSingleResult();
return operationScheduleEntity;
}
@@ -1892,8 +1888,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
Trigger[] triggers;
try {
triggers = scheduler.getTriggersOfJob(jobDetail.getName(), jobDetail.getGroup());
- }
- catch (SchedulerException e) {
+ } catch (SchedulerException e) {
throw new RuntimeException("Failed to lookup trigger for job [" + jobDetail.getFullName() + "].", e);
}
if (triggers.length == 0) {
@@ -1909,7 +1904,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
private static JobTrigger convertToJobTrigger(Trigger trigger) {
JobTrigger schedule;
if (trigger instanceof SimpleTrigger) {
- SimpleTrigger simpleTrigger = (SimpleTrigger)trigger;
+ SimpleTrigger simpleTrigger = (SimpleTrigger) trigger;
Date startTime = simpleTrigger.getStartTime();
if (startTime != null) {
// later
@@ -1953,7 +1948,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
}
}
} else if (trigger instanceof CronTrigger) {
- CronTrigger cronTrigger = (CronTrigger)trigger;
+ CronTrigger cronTrigger = (CronTrigger) trigger;
schedule = JobTrigger.createCronTrigger(cronTrigger.getCronExpression());
} else {
throw new IllegalStateException("Unsupported Quartz trigger type: " + trigger.getClass().getName());
@@ -1967,8 +1962,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
CronTrigger cronTrigger = new CronTrigger();
try {
cronTrigger.setCronExpression(jobTrigger.getCronExpression());
- }
- catch (ParseException e) {
+ } catch (ParseException e) {
throw new RuntimeException(e);
}
trigger = cronTrigger;
@@ -1976,18 +1970,18 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
SimpleTrigger simpleTrigger = new SimpleTrigger();
Date startTime = null;
switch (jobTrigger.getStartType()) {
- case NOW:
- startTime = new Date();
- break;
- case DATETIME:
- startTime = jobTrigger.getStartDate();
- break;
+ case NOW:
+ startTime = new Date();
+ break;
+ case DATETIME:
+ startTime = jobTrigger.getStartDate();
+ break;
}
simpleTrigger.setStartTime(startTime);
// TODO (ips): Finish implementing this.
- trigger= simpleTrigger;
+ trigger = simpleTrigger;
}
return trigger;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/ResourceOperationJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/ResourceOperationJob.java
index e0ac109..d85c323 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/ResourceOperationJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/ResourceOperationJob.java
@@ -177,7 +177,7 @@ public class ResourceOperationJob extends OperationJob {
}
AgentManagerLocal agentManager = LookupUtil.getAgentManager();
- AgentClient agentClient = agentManager.getAgentClient(schedule.getSubject(), resource.getId());
+ AgentClient agentClient = agentManager.getAgentClient(getOverlord(), resource.getId());
agentClient.getOperationAgentService().invokeOperation(resourceHistory.getJobId().toString(),
resource.getId(), schedule.getOperationName(), schedule.getParameters());
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index e9d3b30..770a69c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -279,7 +279,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
AgentClient agentClient = null;
try {
// The test code does not always generate agents for the resources. Catch and log any problem but continue
- agentClient = agentManager.getAgentClient(user, resourceId);
+ agentClient = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
} catch (Throwable t) {
log.warn("No AgentClient found for resource [" + resource
+ "]. Unable to inform agent of inventory removal (this may be ok): " + t);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/support/SupportManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/support/SupportManagerBean.java
index b81b0a8..8ef6dc4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/support/SupportManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/support/SupportManagerBean.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.cloud.Server;
import org.rhq.core.util.stream.StreamUtil;
import org.rhq.enterprise.server.agentclient.AgentClient;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.cloud.instance.ServerManagerLocal;
import org.rhq.enterprise.server.core.AgentManagerLocal;
@@ -60,11 +61,14 @@ public class SupportManagerBean implements SupportManagerLocal, SupportManagerRe
@EJB
private ServerManagerLocal serverManager;
+ @EJB
+ private SubjectManagerLocal subjectManager;
+
@RequiredPermission(Permission.MANAGE_INVENTORY)
public InputStream getSnapshotReportStream(Subject subject, int resourceId, String name, String description)
throws Exception {
- AgentClient agentClient = this.agentManager.getAgentClient(subject, resourceId);
+ AgentClient agentClient = this.agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
SupportAgentService supportService = agentClient.getSupportAgentService();
InputStream snapshotStream = supportService.getSnapshotReport(resourceId, name, description);
13 years, 3 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java | 10 +++++-----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java | 8 ++++++++
2 files changed, 13 insertions(+), 5 deletions(-)
New commits:
commit 0715ed6e2d1d6d21cfea0e4064fdeb506f91da59
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Jan 25 18:34:34 2011 -0500
username is no longer editable on user edit page (fixes https://bugzilla.redhat.com/show_bug.cgi?id=672684)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
index e1f1042..314d279 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
@@ -138,13 +138,13 @@ public class UserEditView extends AbstractRecordEditor<UsersDataSource> {
List<FormItem> items = new ArrayList<FormItem>();
// Username field should be editable when creating a new user, but should be read-only for existing users.
- if (form.isNewRecord()) {
- TextItem nameItem = new TextItem(UsersDataSource.Field.NAME);
- items.add(nameItem);
+ FormItem nameItem;
+ if (isNewRecord()) {
+ nameItem = new TextItem(UsersDataSource.Field.NAME);
} else {
- StaticTextItem nameItem = new StaticTextItem(UsersDataSource.Field.NAME);
- items.add(nameItem);
+ nameItem = new StaticTextItem(UsersDataSource.Field.NAME);
}
+ items.add(nameItem);
StaticTextItem isLdapItem = new StaticTextItem(UsersDataSource.Field.LDAP);
items.add(isLdapItem);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
index ff2568f..1941085 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
@@ -213,6 +213,14 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
throw new PermissionException("You cannot disable the system user [" + subjectToModify.getName() + "].");
}
+ Subject attachedSubject = getSubjectById(subjectToModify.getId());
+ if (attachedSubject == null) {
+ throw new IllegalArgumentException("No user exists with id [" + subjectToModify.getId() + "].");
+ }
+ if (!attachedSubject.getName().equals(subjectToModify.getName())) {
+ throw new IllegalArgumentException("You cannot change a user's username.");
+ }
+
Set<Role> newRoles = subjectToModify.getRoles();
if (newRoles != null) {
Set<Role> currentRoles = new HashSet<Role>(roleManager.findRolesBySubject(subjectToModify.getId(),
13 years, 3 months