[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationEditView.java | 1 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/CurrentGroupPluginConfigurationView.java | 1 +
2 files changed, 2 insertions(+)
New commits:
commit f35264dc9dd83f02ca1c38bc4171995ce3dbe3d3
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 25 16:38:17 2011 -0500
BZ 680167 forgot to reset the refreshing flag on load error, otherwise it would never refresh again on load failure
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationEditView.java
index c924352..cb789b5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationEditView.java
@@ -162,6 +162,7 @@ public class GroupResourceConfigurationEditView extends LocatableVLayout impleme
this.configurationService.findResourceConfigurationsForGroup(group.getId(),
new AsyncCallback<List<DisambiguationReport<ResourceConfigurationComposite>>>() {
public void onFailure(Throwable caught) {
+ refreshing = false;
CoreGUI.getErrorHandler().handleError(MSG.view_group_resConfig_edit_loadFail(group.toString()),
caught);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/CurrentGroupPluginConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/CurrentGroupPluginConfigurationView.java
index 9a124e5..f6ace09 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/CurrentGroupPluginConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/CurrentGroupPluginConfigurationView.java
@@ -165,6 +165,7 @@ public class CurrentGroupPluginConfigurationView extends LocatableVLayout implem
this.configurationService.findPluginConfigurationsForGroup(group.getId(),
new AsyncCallback<List<DisambiguationReport<ResourceConfigurationComposite>>>() {
public void onFailure(Throwable caught) {
+ refreshing = false;
CoreGUI.getErrorHandler().handleError(
MSG.view_group_pluginConfig_members_fetchFailureConn(group.toString()), caught);
}
13 years, 2 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java | 9 +++++++++
1 file changed, 9 insertions(+)
New commits:
commit 1471bf460ce020fd91fcdf4c30f4d8e09b2640db
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 25 16:36:20 2011 -0500
BZ 680167 - this has the bug too - after adding the refreshing stuff, it is working better now (no dup queries)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
index 605ea83..98949f6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
@@ -62,6 +62,8 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
private ConfigurationEditor editor;
private IButton saveButton;
+ private boolean refreshing = false;
+
public ResourceConfigurationEditView(String locatorId, ResourceComposite resourceComposite) {
super(locatorId);
@@ -99,6 +101,11 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
@Override
public void refresh() {
+ if (this.refreshing) {
+ return; // we are already in the process of refreshing, don't do it again
+ }
+
+ this.refreshing = true;
this.saveButton.disable();
GWTServiceLookup.getConfigurationService().getLatestResourceConfigurationUpdate(resource.getId(),
@@ -121,6 +128,7 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
editor.setReadOnly(!resourcePermission.isConfigureWrite());
addMember(editor);
markForRedraw();
+ refreshing = false;
// TODO (ips): If editor != null, use editor.reload() instead.
}
});
@@ -128,6 +136,7 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
@Override
public void onFailure(Throwable caught) {
+ refreshing = false;
CoreGUI.getErrorHandler().handleError("Cannot load resource config", caught);
}
});
13 years, 2 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/CurrentGroupPluginConfigurationView.java | 8 ++++++++
1 file changed, 8 insertions(+)
New commits:
commit 53bd82755c6fb065b66f6980e2f59459119f5e4e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 25 16:18:22 2011 -0500
BZ 680167 - this follows the same pattern as did GroupResourceConfigurationEditView
so I'm adding the "refreshing" check. however, in my testing, even though it used
the same pattern I did not see the same double querying. I don't know why this
is different, but to prevent this from happening anyway, I added the
refreshing check, it can't hurt.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/CurrentGroupPluginConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/CurrentGroupPluginConfigurationView.java
index e33773c..9a124e5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/CurrentGroupPluginConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/CurrentGroupPluginConfigurationView.java
@@ -73,6 +73,8 @@ public class CurrentGroupPluginConfigurationView extends LocatableVLayout implem
private ConfigurationEditor editor;
private IButton saveButton;
+ private boolean refreshing = false;
+
public CurrentGroupPluginConfigurationView(String locatorId, ResourceGroupComposite groupComposite) {
super(locatorId);
@@ -112,6 +114,11 @@ public class CurrentGroupPluginConfigurationView extends LocatableVLayout implem
@Override
public void refresh() {
+ if (this.refreshing) {
+ return; // we are already in the process of refreshing, don't do it again
+ }
+
+ this.refreshing = true;
this.saveButton.disable();
if (editor != null) {
editor.destroy();
@@ -132,6 +139,7 @@ public class CurrentGroupPluginConfigurationView extends LocatableVLayout implem
this.editor.addPropertyValueChangeListener(this);
this.editor.setReadOnly(!this.resourcePermission.isConfigureWrite());
addMember(this.editor);
+ this.refreshing = false;
}
}
13 years, 2 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java | 117 ++++++++--
1 file changed, 103 insertions(+), 14 deletions(-)
New commits:
commit 1424976ad69ff143ae71651dbdc0cabb45bc567d
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 25 15:28:05 2011 -0500
add ability to set an auto-refresh timer.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java
index dfab374..0a6a0c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java
@@ -18,8 +18,13 @@
*/
package org.rhq.enterprise.gui.coregui.client.test.i18n;
+import java.util.LinkedHashMap;
import java.util.List;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+import com.google.gwt.event.logical.shared.ValueChangeHandler;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.Timer;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.RecordList;
import com.smartgwt.client.data.SortSpecifier;
@@ -46,6 +51,8 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
*/
public class TestRemoteServiceStatisticsView extends Table {
+ public static final String TABLE_TITLE = "Remote Service Statistics";
+
// these are used both as the name of the fields, titles of the headers and the columns of the CSV output
private static final String FIELD_SERVICENAME = "serviceName";
private static final String FIELD_METHODNAME = "methodName";
@@ -58,13 +65,23 @@ public class TestRemoteServiceStatisticsView extends Table {
private static final SortSpecifier[] defaultSorts = new SortSpecifier[] { new SortSpecifier("average",
SortDirection.DESCENDING) };
- // if this is true, this view is hosted by a standalone Window
- private boolean inWindow = false;
+ // if this is not null, this view is hosted by this standalone Window
+ private StatisticsWindow window = null;
+ private Timer timer = null;
+ private boolean refreshOnPageChange = false;
public TestRemoteServiceStatisticsView(String locatorId) {
- super(locatorId, "Remote Service Statistics", null, defaultSorts, null, false);
+ super(locatorId, TABLE_TITLE, null, defaultSorts, null, false);
+
+ timer = new Timer() {
+ @Override
+ public void run() {
+ refresh();
+ }
+ };
}
+ @SuppressWarnings("unchecked")
@Override
protected void configureTable() {
ListGridField serviceName = new ListGridField(FIELD_SERVICENAME, "Service Name");
@@ -101,14 +118,6 @@ public class TestRemoteServiceStatisticsView extends Table {
}
});
- addTableAction(extendLocatorId("refresh"), MSG.common_button_refresh(), new AbstractTableAction(
- TableActionEnablement.ALWAYS) {
- @Override
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- refresh();
- }
- });
-
addTableAction(extendLocatorId("export"), "Export To CSV",
new AbstractTableAction(TableActionEnablement.ALWAYS) {
@Override
@@ -140,7 +149,62 @@ public class TestRemoteServiceStatisticsView extends Table {
}
});
- if (!inWindow) {
+ if (window != null) {
+ LinkedHashMap<String, Integer> timerValues = new LinkedHashMap<String, Integer>();
+ timerValues.put("Now", Integer.valueOf("-2"));
+ timerValues.put(MSG.common_val_never(), Integer.valueOf("-1"));
+ timerValues.put("On Page Change", Integer.valueOf("0"));
+ timerValues.put("1", Integer.valueOf("1"));
+ timerValues.put("5", Integer.valueOf("5"));
+ timerValues.put("10", Integer.valueOf("10"));
+ timerValues.put("30", Integer.valueOf("30"));
+ timerValues.put("60", Integer.valueOf("60"));
+ History.addValueChangeHandler(new ValueChangeHandler<String>() {
+ @Override
+ public void onValueChange(ValueChangeEvent<String> event) {
+ if (refreshOnPageChange) {
+ refresh();
+ }
+ }
+ });
+
+ addTableAction(extendLocatorId("refreshTimer"), "Refresh", null, timerValues, new AbstractTableAction(
+ TableActionEnablement.ALWAYS) {
+ @Override
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+
+ Integer timeout = (Integer) actionValue;
+
+ // if being asked to refresh now, just refresh but don't touch our schedules
+ if (timeout == null || timeout.intValue() == -2) {
+ refresh();
+ return;
+ }
+
+ // cancel everything - will reinstate if user elected to do one of these
+ timer.cancel();
+ refreshOnPageChange = false;
+
+ if (timeout.intValue() == -1) {
+ setTableTitle(TABLE_TITLE);
+ } else if (timeout.intValue() == 0) {
+ refreshOnPageChange = true;
+ setTableTitle(TABLE_TITLE + " (refresh on page change)");
+ } else {
+ timer.scheduleRepeating(timeout.intValue() * 1000);
+ setTableTitle(TABLE_TITLE + " (refresh every " + timeout + "s)");
+ }
+ }
+ });
+ } else { // not in the standalone window
+ addTableAction(extendLocatorId("refresh"), MSG.common_button_refresh(), new AbstractTableAction(
+ TableActionEnablement.ALWAYS) {
+ @Override
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ refresh();
+ }
+ });
+
addTableAction(extendLocatorId("showInWin"), "Show In Window", new AbstractTableAction(
TableActionEnablement.ALWAYS) {
@Override
@@ -166,6 +230,9 @@ public class TestRemoteServiceStatisticsView extends Table {
public void refresh() {
super.refresh();
getListGrid().setRecords(transform(RemoteServiceStatistics.getAll()));
+ if (window != null) {
+ window.blink();
+ }
}
private ListGridRecord[] transform(List<Summary> stats) {
@@ -220,9 +287,11 @@ public class TestRemoteServiceStatisticsView extends Table {
}
class StatisticsWindow extends LocatableWindow {
+ private Timer blinkTimer;
+
public StatisticsWindow(String locatorId) {
super(locatorId);
- setTitle("Remote Service Statistics");
+ setTitle(TABLE_TITLE);
setShowMinimizeButton(true);
setShowMaximizeButton(true);
setShowCloseButton(true);
@@ -242,8 +311,28 @@ public class TestRemoteServiceStatisticsView extends Table {
TestRemoteServiceStatisticsView view;
view = new TestRemoteServiceStatisticsView(extendLocatorId("StatsViewInWin"));
- view.inWindow = true;
+ view.window = this;
addItem(view);
+
+ final String origColor = getBodyColor();
+ blinkTimer = new Timer() {
+ @Override
+ public void run() {
+ setBodyColor(origColor);
+ setTitle(TABLE_TITLE);
+ }
+ };
+ }
+
+ public void blink() {
+ // window.flash() isn't working so do it ourselves
+ if (getMinimized()) {
+ setTitle(TABLE_TITLE + " *");
+ } else {
+ setBodyColor(getHiliteBodyColor());
+ }
+ redraw();
+ blinkTimer.schedule(250);
}
}
}
13 years, 2 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/AbstractRecordEditor.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ExecutionSchedule.java | 311 -------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationCreateWizard.java | 157 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationParametersStep.java | 78 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationSchedulingStep.java | 430 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 6
9 files changed, 40 insertions(+), 998 deletions(-)
New commits:
commit 899277fc716afccc33bf413acaf0c513e20f6ad6
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Feb 25 13:51:46 2011 -0500
switch operations context menu on resource tree to link to operations>schedule subtab, rather than opening a wizard; delete the schedule-operation wizard classes, which are no longer used
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/AbstractRecordEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/AbstractRecordEditor.java
index b2a45b7..e4f061b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/AbstractRecordEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/AbstractRecordEditor.java
@@ -105,12 +105,7 @@ public abstract class AbstractRecordEditor<DS extends RPCDataSource> extends Loc
viewPath.next();
String parentViewPath = viewPath.getParentViewPath();
- if (!viewPath.isEnd()) {
- CoreGUI.getErrorHandler().handleError(MSG.widget_recordEditor_error_invalidViewPath(viewPath.toString()));
- CoreGUI.goToView(parentViewPath);
- } else {
- this.listViewPath = parentViewPath; // e.g. Administration/Security/Roles
- }
+ this.listViewPath = parentViewPath; // e.g. Administration/Security/Roles
}
/**
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
index e808b76..2e18af7 100644
--- 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
@@ -99,18 +99,17 @@ public abstract class AbstractOperationScheduleDataSource<T extends OperationSch
DataSourceTextField operationNameField = createTextField(Field.OPERATION_NAME, "Operation", 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);
+ operationNameField.setValueMap(valueMap);
+ fields.add(operationNameField);
+
+ DataSourceTextField operationDisplayNameField = createTextField(Field.OPERATION_DISPLAY_NAME, "Operation", null,
+ 100, true);
+ fields.add(operationDisplayNameField);
DataSourceField subjectField = new DataSourceField(Field.SUBJECT, FieldType.ANY, "Owner");
subjectField.setCanEdit(false);
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 807d6a9..0600e5a 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
@@ -74,6 +74,7 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
protected static final int FIRST_COLUMN_WIDTH = 140;
+ private Map<Integer, String> operationIdToNameMap = new HashMap<Integer, String>();
private Map<String, String> operationNameToDescriptionMap = new HashMap<String, String>();
private Map<String, ConfigurationDefinition> operationNameToParametersDefinitionMap =
new HashMap<String, ConfigurationDefinition>();
@@ -83,6 +84,7 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
private JobTriggerEditor triggerEditor;
private Configuration parameters;
private EnhancedDynamicForm notesForm;
+ private Integer operationDefinitionId;
public AbstractOperationScheduleDetailsView(String locatorId, AbstractOperationScheduleDataSource dataSource,
ResourceType resourceType, int scheduleId) {
@@ -90,6 +92,7 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
Set<OperationDefinition> operationDefinitions = resourceType.getOperationDefinitions();
for (OperationDefinition operationDefinition : operationDefinitions) {
+ this.operationIdToNameMap.put(operationDefinition.getId(), operationDefinition.getName());
this.operationNameToDescriptionMap.put(operationDefinition.getName(), operationDefinition.getDescription());
this.operationNameToParametersDefinitionMap.put(operationDefinition.getName(),
operationDefinition.getParametersConfigurationDefinition());
@@ -102,6 +105,11 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
public void renderView(ViewPath viewPath) {
super.renderView(viewPath);
+ if (!viewPath.isEnd()) {
+ this.operationDefinitionId = viewPath.getCurrentAsInt();
+ viewPath.next();
+ }
+
// Existing schedules are not editable. This may change in the future.
boolean isReadOnly = (!hasControlPermission() || (getRecordId() != 0));
init(isReadOnly);
@@ -205,10 +213,17 @@ public abstract class AbstractOperationScheduleDetailsView extends AbstractRecor
@Override
protected Record createNewRecord() {
Record record = super.createNewRecord();
+
+ if (this.operationDefinitionId != null) {
+ String operationName = this.operationIdToNameMap.get(this.operationDefinitionId);
+ record.setAttribute(AbstractOperationScheduleDataSource.Field.OPERATION_NAME, operationName);
+ }
+
Subject sessionSubject = UserSessionManager.getSessionSubject();
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/ExecutionSchedule.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ExecutionSchedule.java
deleted file mode 100644
index 26d53a8..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ExecutionSchedule.java
+++ /dev/null
@@ -1,311 +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.schedule;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.HashSet;
-
-import com.google.gwt.i18n.client.DateTimeFormat;
-
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.Messages;
-
-/**
- * @author Greg Hinkle
- */
-public class ExecutionSchedule implements Serializable {
-
- private static final Messages MSG = CoreGUI.getMessages();
-
- public enum Start {
- Immediately, Future
- };
-
- public enum End {
- Never, EndOn
- };
-
- public enum Recurr {
- Once, EveryNMinutes, Hourly, Daily, Weekly, Monthly
- };
-
- public enum DayOfWeek {
- Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
- };
-
- private Start start = Start.Immediately;
-
- // start.Future
- private Recurr recurr = Recurr.Once;
-
- // Once
- private Date onceDateTime;
-
-
- // EveryNMinutes
- private Integer minuteInterval;
-
-
- // Hourly
- private Integer minuteInHour;
-
-
- // Daily
- private Date timeOfDay;
-
-
- // Weekly
- // Time of Day above
- private HashSet<DayOfWeek> daysOfWeek; // Can't use EnumSet because it doesn't have default instantiator
-
-
- // Monthly
- // Time of Day above
- private Integer dayOfMonth;
-
-
- // Used for all start.Future except for once
- private Date startDate;
-
- private Date endDate;
-
-
- public Start getStart() {
- return start;
- }
-
- public void setStart(Start start) {
- this.start = start;
- }
-
- public Recurr getRecurr() {
- return recurr;
- }
-
- public void setRecurr(Recurr recurr) {
- this.recurr = recurr;
- }
-
- public Date getOnceDateTime() {
- return onceDateTime;
- }
-
- public void setOnceDateTime(Date onceDateTime) {
- this.onceDateTime = onceDateTime;
- }
-
- public Integer getMinuteInterval() {
- return minuteInterval;
- }
-
- public void setMinuteInterval(Integer minuteInterval) {
- this.minuteInterval = minuteInterval;
- }
-
- public Integer getMinuteInHour() {
- return minuteInHour;
- }
-
- public void setMinuteInHour(Integer minuteInHour) {
- this.minuteInHour = minuteInHour;
- }
-
- public HashSet<DayOfWeek> getDaysOfWeek() {
- return daysOfWeek;
- }
-
- public void setDaysOfWeek(HashSet<DayOfWeek> daysOfWeek) {
- this.daysOfWeek = daysOfWeek;
- }
-
- public Integer getDayOfMonth() {
- return dayOfMonth;
- }
-
- public void setDayOfMonth(Integer dayOfMonth) {
- this.dayOfMonth = dayOfMonth;
- }
-
- public Date getStartDate() {
- return startDate;
- }
-
- public void setStartDate(Date startDate) {
- this.startDate = startDate;
- }
-
- public Date getEndDate() {
- return endDate;
- }
-
- public void setEndDate(Date endDate) {
- this.endDate = endDate;
- }
-
- public Date getTimeOfDay() {
- return timeOfDay;
- }
-
- public void setTimeOfDay(Date timeOfDay) {
- this.timeOfDay = timeOfDay;
- }
-
- public String getMessage() {
- DateTimeFormat dateFormat = DateTimeFormat.getMediumDateFormat();
- DateTimeFormat timeFormat = DateTimeFormat.getMediumTimeFormat();
-
- String message;
- switch (start) {
-
- case Immediately:
- message = MSG.view_operationCreateWizard_executionSchedule_willExecuteOnce(
- MSG.view_operationCreateWizard_executionSchedule_immediately());
- break;
-
- case Future:
- if (recurr == Recurr.Once) {
- message = MSG.view_operationCreateWizard_executionSchedule_willExecuteOnce(
- MSG.view_operationCreateWizard_executionSchedule_onceAtGivenTime(onceDateTime.toString()));
- } else {
- String recurrenceMessage;
- switch (recurr) {
- case EveryNMinutes:
- recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyNMinutes(minuteInterval.toString());
- break;
- case Hourly:
- recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyHourOnNthMinute(suffix(minuteInHour));
- break;
- case Daily:
- recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyDayAtGivenTime(timeFormat.format(timeOfDay));
- break;
- case Weekly:
- recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyWeekOnGivenDayAtGivenTime(daysOfWeek.toString(), timeFormat.format(timeOfDay));
- break;
- case Monthly:
- recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyMonthOnNthDayAtGivenTime(suffix(dayOfMonth), timeFormat.format(timeOfDay));
- break;
- default:
- recurrenceMessage = "";
- }
-
- if (endDate != null) {
- message = MSG.view_operationCreateWizard_executionSchedule_willExecuteRecurringWithEnd(
- recurrenceMessage, dateFormat.format(startDate), dateFormat.format(endDate));
- } else {
- message = MSG.view_operationCreateWizard_executionSchedule_willExecuteRecurring(
- recurrenceMessage, dateFormat.format(startDate));
- }
- }
- break;
-
- default:
- message = "";
-
- }
-
- return message;
- }
-
-
- public String getCronString() {
-
- /* Cron fields
- 1. Seconds
- 2. Minutes
- 3. Hours
- 4. Day-of-Month
- 5. Month
- 6. Day-of-Week
- 7. Year (optional field)
- */
-
- String cseconds, cminutes = null, chours = null, cdayOfMonth = null, cmonth = null, cdayOfWeek = null;
-
- cseconds = "0";
-
- switch (start) {
-
- case Immediately:
- return null; // No cron string for immediate execution
-
- case Future:
-
- if (recurr == Recurr.Once) {
- return null; // No cron string for non recurring
- } else {
- switch (recurr) {
- case EveryNMinutes:
- cminutes = "0/" + minuteInterval;
- chours = cdayOfMonth = cmonth = "*";
- cdayOfWeek = "?";
- break;
- case Hourly:
- cminutes = "" + minuteInHour;
- chours = "*";
- cdayOfMonth = cmonth = cdayOfWeek = "*";
- break;
- case Daily:
- cminutes = "" + timeOfDay.getMinutes();
- chours = "" + timeOfDay.getHours();
- cdayOfMonth = cmonth = cdayOfWeek = "*";
- break;
- case Weekly:
- cminutes = "" + timeOfDay.getMinutes();
- chours = "" + timeOfDay.getHours();
- cdayOfMonth = "?";
- cmonth = "*";
- cdayOfWeek = daysOfWeek.toString();
- break;
- case Monthly:
- cminutes = "" + timeOfDay.getMinutes();
- chours = "" + timeOfDay.getHours();
- cdayOfMonth = "" + dayOfMonth;
- cmonth = "*";
- cdayOfWeek = "?";
- break;
- }
- }
- break;
- }
- return cseconds + " " + cminutes + " " + chours + " " + cdayOfMonth + " " + cmonth + " " + cdayOfWeek;
-
- }
-
- public static String suffix(int number) {
- String result;
- String numberAsString = String.valueOf(number);
- int last = number % 10;
- switch (last) {
- case 1:
- result = MSG.common_val_n1st(numberAsString);
- break;
- case 2:
- result = MSG.common_val_n2nd(numberAsString);
- break;
- case 3:
- result = MSG.common_val_n3rd(numberAsString);
- break;
- default:
- result = MSG.common_val_nth(numberAsString);
- }
- return result;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationCreateWizard.java
deleted file mode 100644
index fc3c6f2..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationCreateWizard.java
+++ /dev/null
@@ -1,157 +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.schedule;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.widgets.IButton;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard;
-import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardStep;
-import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardView;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-
-/**
- * @author Greg Hinkle
- */
-public class OperationCreateWizard extends AbstractWizard {
-
- private Resource resource;
- private OperationDefinition operationDefinition;
-
- private OperationParametersStep parametersStep;
- private OperationSchedulingStep schedulingStep;
-
- private WizardView view;
-
- private IButton executeNowButton;
- private IButton executeButton;
-
- public OperationCreateWizard(Resource resource, OperationDefinition operationDefinition) {
- this.resource = resource;
- this.operationDefinition = operationDefinition;
- }
-
- public void startOperationWizard() {
-
- parametersStep = new OperationParametersStep(operationDefinition);
- schedulingStep = new OperationSchedulingStep();
-
- ArrayList<WizardStep> steps = new ArrayList<WizardStep>();
- steps.add(parametersStep);
- steps.add(schedulingStep);
- setSteps(steps);
-
- executeNowButton = new IButton(MSG.view_operationCreateWizard_button_executeImmediately());
- executeNowButton.setAutoFit(true);
- executeNowButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- execute();
- }
- });
-
- executeButton = new IButton(MSG.view_operationCreateWizard_button_execute());
- executeButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- execute();
- }
- });
-
- view = new WizardView(this);
- view.displayDialog();
- }
-
- public String getWindowTitle() {
- return MSG.view_operationCreateWizard_title();
- }
-
- public String getTitle() {
- return MSG.view_operationCreateWizard_header(operationDefinition.getDisplayName(), resource.getName());
- }
-
- public String getSubtitle() {
- return operationDefinition.getDescription();
- }
-
- public List<IButton> getCustomButtons(int step) {
- switch (step) {
- case 0:
- return Arrays.asList(executeNowButton);
- case 1:
- return Arrays.asList(executeButton);
- default:
- return Collections.emptyList();
- }
- }
-
- private void execute() {
- Configuration parameters = parametersStep.getParameterConfiguration();
- final ExecutionSchedule schedule = schedulingStep.getExecutionSchedule();
-
- // TODO: get the description and timeout from user input
- String description = "";
- int timeout = 0;
-
- AsyncCallback<Void> operationCallback = new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_operationCreateWizard_error_scheduleOperationFailure(),
- caught);
- }
-
- public void onSuccess(Void result) {
- String opName = operationDefinition.getDisplayName();
- String cron = schedule.getCronString();
- if (cron == null) {
- cron = MSG.common_val_na();
- }
- String concise = MSG.view_operationCreateWizard_message_scheduleOperationSuccess_short(opName);
- String message = MSG.view_operationCreateWizard_message_scheduleOperationSuccess(opName, String
- .valueOf(resource.getId()), cron);
-
- CoreGUI.getMessageCenter().notify(new Message(concise, message, Message.Severity.Info));
- }
- };
-
- if (schedule.getStart() == ExecutionSchedule.Start.Immediately) {
- GWTServiceLookup.getOperationService().invokeResourceOperation(resource.getId(),
- operationDefinition.getName(), parameters, description, timeout, operationCallback);
- } else {
- GWTServiceLookup.getOperationService().scheduleResourceOperation(resource.getId(),
- operationDefinition.getName(), parameters, description, timeout, schedule.getCronString(),
- operationCallback);
- }
-
- view.closeDialog();
- }
-
- public void cancel() {
- // TODO: revert back to original state
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationParametersStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationParametersStep.java
deleted file mode 100644
index 8ce2ada..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationParametersStep.java
+++ /dev/null
@@ -1,78 +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.schedule;
-
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
-
-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.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
-import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
-
-/**
- * @author Greg Hinkle
- */
-public class OperationParametersStep extends AbstractWizardStep {
-
- private OperationDefinition definition;
-
- private ConfigurationEditor configurationEditor;
-
- public OperationParametersStep(OperationDefinition operationDefinition) {
- super();
- this.definition = operationDefinition;
- }
-
- public Canvas getCanvas(Locatable parent) {
- if (definition.getParametersConfigurationDefinition() != null) {
- if (configurationEditor == null) {
- ConfigurationDefinition configurationDefinition = definition.getParametersConfigurationDefinition();
- Configuration defaultConfiguration = configurationDefinition.getDefaultTemplate() != null ? configurationDefinition
- .getDefaultTemplate().createConfiguration()
- : new Configuration();
- if (parent != null) {
- configurationEditor = new ConfigurationEditor(parent.extendLocatorId("OperationParams"),
- configurationDefinition, defaultConfiguration);
- } else {
- configurationEditor = new ConfigurationEditor("OperationParams", configurationDefinition,
- defaultConfiguration);
- }
- }
- return configurationEditor;
- } else {
- return new HTMLFlow(MSG.view_operationCreateWizard_parametersStep_noParameters());
- }
- }
-
- public boolean nextPage() {
- return true; // TODO: Implement this method.
- }
-
- public String getName() {
- return MSG.view_operationCreateWizard_parametersStep_name();
- }
-
- public Configuration getParameterConfiguration() {
- return configurationEditor != null ? configurationEditor.getConfiguration() : null;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationSchedulingStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationSchedulingStep.java
deleted file mode 100644
index 1db4791..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationSchedulingStep.java
+++ /dev/null
@@ -1,430 +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.schedule;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import com.smartgwt.client.types.FormErrorOrientation;
-import com.smartgwt.client.types.TimeFormatter;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.FormItemIfFunction;
-import com.smartgwt.client.widgets.form.ValuesManager;
-import com.smartgwt.client.widgets.form.events.ItemChangedEvent;
-import com.smartgwt.client.widgets.form.events.ItemChangedHandler;
-import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.form.fields.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.DateItem;
-import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.HeaderItem;
-import com.smartgwt.client.widgets.form.fields.IntegerItem;
-import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
-import com.smartgwt.client.widgets.form.fields.SpacerItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.form.fields.TimeItem;
-import com.smartgwt.client.widgets.form.validator.CustomValidator;
-
-import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
-
-/**
- * @author Greg Hinkle
- */
-public class OperationSchedulingStep extends AbstractWizardStep implements ItemChangedHandler {
-
- private DynamicForm form;
- private ValuesManager valuesManager;
-
- private ExecutionSchedule executionSchedule = new ExecutionSchedule();
-
- public Canvas getCanvas(Locatable parent) {
-
- if (form == null) {
- valuesManager = new ValuesManager();
- if (parent != null) {
- form = new LocatableDynamicForm(parent.extendLocatorId("OperationScheduling"));
- } else {
- form = new LocatableDynamicForm("OperationScheduling");
- }
- form.setValuesManager(valuesManager);
- form.setWrapItemTitles(false);
- form.setErrorOrientation(FormErrorOrientation.RIGHT);
- form.setWidth100();
- form.setPadding(10);
- form.setNumCols(3);
- // form.setColWidths("15%", "35%", "15%", "*");
- form.setValidateOnChange(true);
-
- final RadioGroupItem start = new RadioGroupItem("start", MSG
- .view_operationCreateWizard_schedulingStep_name());
- start.setColSpan(3);
- start.setValueMap(enumValueMap(ExecutionSchedule.Start.class)); // "Immediately", "Future"
- start.setRedrawOnChange(true);
- start.setValue("Immediately");
-
- HeaderItem scheduleHeader = new HeaderItem("scheduleHeader");
- scheduleHeader.setValue(MSG.view_operationCreateWizard_schedulingStep_label_schedule());
- scheduleHeader.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !"Immediately".equals(form.getValueAsString("start"));
- }
- });
-
- RadioGroupItem recurr = new RadioGroupItem("recurr", MSG
- .view_operationCreateWizard_schedulingStep_label_recurrence());
- recurr.setValueMap(enumValueMap(ExecutionSchedule.Recurr.class)); // "Once", "EveryNMinutes", "Hourly", "Daily", "Weekly", "Monthly");
- recurr.setRedrawOnChange(true);
- recurr.setValue(ExecutionSchedule.Recurr.Once.name());
- recurr.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"));
- }
- });
-
- CanvasItem onceForm = new CanvasItem("once", MSG.view_operationCreateWizard_schedulingStep_label_onceAt());
- onceForm.setShowTitle(false);
- onceForm.setCanvas(getOnceForm());
- onceForm.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && ExecutionSchedule.Recurr.Once.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- CanvasItem everyNMinuteForm = new CanvasItem("everyNMinutesForm", MSG
- .view_operationCreateWizard_schedulingStep_label_everyNMinutes());
- everyNMinuteForm.setShowTitle(false);
- everyNMinuteForm.setCanvas(getEveryNMinutesForm());
- everyNMinuteForm.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && ExecutionSchedule.Recurr.EveryNMinutes.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- CanvasItem hourlyForm = new CanvasItem("hourlyForm", MSG
- .view_operationCreateWizard_schedulingStep_label_hourly());
- hourlyForm.setShowTitle(false);
- hourlyForm.setCanvas(getHourlyForm());
- hourlyForm.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !"Immediately".equals(form.getValueAsString("start"))
- && ExecutionSchedule.Recurr.Hourly.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- CanvasItem dailyForm = new CanvasItem("daily", MSG.view_operationCreateWizard_schedulingStep_label_daily());
- dailyForm.setShowTitle(false);
- dailyForm.setCanvas(getDailyForm());
- dailyForm.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && ExecutionSchedule.Recurr.Daily.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- CanvasItem weeklyForm = new CanvasItem("weekly", MSG
- .view_operationCreateWizard_schedulingStep_label_weekly());
- weeklyForm.setShowTitle(false);
- weeklyForm.setCanvas(getWeeklyForm());
- weeklyForm.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && ExecutionSchedule.Recurr.Weekly.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- CanvasItem monthlyForm = new CanvasItem("monthly", MSG
- .view_operationCreateWizard_schedulingStep_label_monthly());
- monthlyForm.setShowTitle(false);
- monthlyForm.setCanvas(getMonthlyForm());
- monthlyForm.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && ExecutionSchedule.Recurr.Monthly.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- HeaderItem rangeHeader = new HeaderItem("timePeriod");
- rangeHeader.setValue(MSG.view_operationCreateWizard_schedulingStep_label_timePeriod());
- rangeHeader.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && !ExecutionSchedule.Recurr.Once.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- DateItem startDate = new DateItem("startDate", MSG
- .view_operationCreateWizard_schedulingStep_label_startDate());
- startDate.setStartRow(true);
- startDate.setStartDate(new Date());
- startDate.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && !"Once".equals(form.getValueAsString("recurr"));
- }
- });
-
- final RadioGroupItem end = new RadioGroupItem("endType", MSG
- .view_operationCreateWizard_schedulingStep_label_endDate());
- end.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && !"Once".equals(form.getValueAsString("recurr"));
- }
- });
- end.setStartRow(true);
- // TODO: i18n
- end.setValueMap("Never", "End On");
- end.setRedrawOnChange(true);
- end.setValue("Never");
-
- DateItem endDate = new DateItem("endDate", MSG.view_operationCreateWizard_schedulingStep_label_endDate());
- endDate.setStartRow(true);
- endDate.setStartDate(new Date());
- endDate.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && !"Once".equals(form.getValueAsString("recurr"))
- && !"Never".equals(form.getValueAsString("endType"));
- }
- });
- endDate.setValidators(new CustomValidator() {
- @Override
- protected boolean condition(Object o) {
- return (((Date) form.getValue("startDate")).before((Date) o));
- }
- });
-
- StaticTextItem messageItem = new StaticTextItem("message");
- messageItem.setValue(MSG.view_operationCreateWizard_schedulingStep_label_willExecuteImmediately());
- messageItem.setStartRow(true);
- messageItem.setColSpan(3);
- messageItem.setShowTitle(false);
- messageItem.setCellStyle("HeaderLabel");
-
- form.setItems(start, scheduleHeader, recurr, onceForm, everyNMinuteForm, hourlyForm, dailyForm, weeklyForm,
- monthlyForm, rangeHeader, startDate, end, endDate, new SpacerItem(), messageItem);
-
- form.addItemChangedHandler(this);
- }
-
- return form;
- }
-
- private DynamicForm getOnceForm() {
- DynamicForm form = new DynamicForm();
- form.setValuesManager(valuesManager);
- form.setPadding(10);
- form.setIsGroup(true);
- form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_onceAt());
- form.addItemChangedHandler(this);
-
- form.setWrapItemTitles(false);
- form.setNumCols(2);
-
- DateItem startDate = new DateItem("onceStartDate", MSG
- .view_operationCreateWizard_schedulingStep_label_startDate());
- startDate.setValue(new Date());
-
- TimeItem startTime = new TimeItem("onceStartDate", MSG
- .view_operationCreateWizard_schedulingStep_label_startDate());
- startTime.setValue(new Date());
- startTime.setDisplayFormat(TimeFormatter.TOSHORTPADDEDTIME);
- startTime.setUseMask(true);
- form.setItems(startDate, startTime);
- return form;
- }
-
- private DynamicForm getEveryNMinutesForm() {
- DynamicForm form = new DynamicForm();
- form.setValuesManager(valuesManager);
- form.setPadding(10);
- form.setIsGroup(true);
- form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_everyNMinutes());
- form.addItemChangedHandler(this);
-
- form.setWrapItemTitles(false);
- form.setNumCols(2);
-
- IntegerItem everyNMinutes = new IntegerItem();
- everyNMinutes.setName("minuteInterval");
- everyNMinutes.setTitle(MSG.view_operationCreateWizard_schedulingStep_label_minuteInterval());
- everyNMinutes.setValue(60);
-
- form.setItems(everyNMinutes);
- return form;
- }
-
- private DynamicForm getHourlyForm() {
- DynamicForm form = new DynamicForm();
- form.setValuesManager(valuesManager);
- form.setPadding(10);
- form.setIsGroup(true);
- form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_hourly());
- form.addItemChangedHandler(this);
-
- form.setWrapItemTitles(false);
- form.setNumCols(2);
-
- IntegerItem minuteOfHour = new IntegerItem();
- minuteOfHour.setName("minuteOfHour");
- minuteOfHour.setTitle(MSG.view_operationCreateWizard_schedulingStep_label_minuteOfHour());
- minuteOfHour.setValue(5);
-
- form.setItems(minuteOfHour);
- return form;
- }
-
- private DynamicForm getDailyForm() {
- DynamicForm form = new DynamicForm();
- form.setValuesManager(valuesManager);
- form.setPadding(10);
- form.setWrapItemTitles(false);
- form.setIsGroup(true);
- form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_daily());
- form.addItemChangedHandler(this);
-
- TimeItem timeOfDay = new TimeItem("timeOfDay", MSG.view_operationCreateWizard_schedulingStep_label_timeOfDay());
- timeOfDay.setValue(new Date());
- timeOfDay.setDisplayFormat(TimeFormatter.TOSHORTPADDEDTIME);
- timeOfDay.setUseMask(true);
-
- form.setItems(timeOfDay);
- return form;
- }
-
- private DynamicForm getWeeklyForm() {
- DynamicForm form = new DynamicForm();
- form.setValuesManager(valuesManager);
- form.setPadding(10);
- form.setIsGroup(true);
- form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_weekly());
- form.addItemChangedHandler(this);
-
- form.setWrapItemTitles(false);
-
- TimeItem timeOfDay = new TimeItem("dayOfWeek", MSG.view_operationCreateWizard_schedulingStep_label_dayOfWeek());
- timeOfDay.setValue(new Date());
- timeOfDay.setDisplayFormat(TimeFormatter.TOSHORTPADDEDTIME);
- timeOfDay.setUseMask(true);
-
- ExecutionSchedule.DayOfWeek[] daysOfWeek = ExecutionSchedule.DayOfWeek.values();
- List<String> dayList = new ArrayList<String>();
- for (ExecutionSchedule.DayOfWeek dayOfWeek : daysOfWeek) {
- dayList.add(dayOfWeek.name());
- }
- FormItem[] items = new FormItem[8];
- items[0] = timeOfDay;
- int i = 1;
- for (String day : dayList) {
- CheckboxItem dayItem = new CheckboxItem(day);
- dayItem.setShowTitle(false);
- items[i++] = dayItem;
- }
- form.setItems(items);
- return form;
- }
-
- private DynamicForm getMonthlyForm() {
- DynamicForm form = new DynamicForm();
- form.setValuesManager(valuesManager);
- form.setPadding(10);
- form.setWrapItemTitles(false);
- form.setIsGroup(true);
- form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_monthly());
- form.addItemChangedHandler(this);
-
- IntegerItem dayItem = new IntegerItem();
- dayItem.setName("dayOfMonth");
- dayItem.setTitle(MSG.view_operationCreateWizard_schedulingStep_label_dayOfMonth());
- dayItem.setValue(1);
-
- TimeItem timeOfDay = new TimeItem("timeOfDay", MSG.view_operationCreateWizard_schedulingStep_label_timeOfDay());
- timeOfDay.setValue(new Date());
- timeOfDay.setDisplayFormat(TimeFormatter.TOSHORTPADDEDTIME);
- timeOfDay.setUseMask(true);
-
- form.setItems(dayItem, timeOfDay);
- return form;
- }
-
- public boolean nextPage() {
- return true; // TODO: Implement this method.
- }
-
- public String getName() {
- return MSG.view_operationCreateWizard_schedulingStep_name();
- }
-
- public void onItemChanged(ItemChangedEvent itemChangeEvent) {
-
- executionSchedule.setStart(ExecutionSchedule.Start.valueOf(valuesManager.getValueAsString("start")));
- executionSchedule.setRecurr(ExecutionSchedule.Recurr.valueOf(valuesManager.getValueAsString("recurr")));
-
- Date onceDate = (Date) valuesManager.getValues().get("onceStartDate");
- executionSchedule.setOnceDateTime(onceDate);
-
- executionSchedule.setMinuteInterval(Integer.parseInt(valuesManager.getValueAsString("minuteInterval")));
-
- executionSchedule.setMinuteInHour(Integer.parseInt(valuesManager.getValueAsString("minuteOfHour")));
-
- executionSchedule.setTimeOfDay((Date) valuesManager.getValues().get("timeOfDay"));
-
- HashSet<ExecutionSchedule.DayOfWeek> selectedDays = new HashSet<ExecutionSchedule.DayOfWeek>(); //.noneOf(ExecutionSchedule.DayOfWeek.class);
- for (ExecutionSchedule.DayOfWeek d : EnumSet.allOf(ExecutionSchedule.DayOfWeek.class)) {
- if (valuesManager.getValues().containsKey(d.name())) {
- selectedDays.add(d);
- }
- }
- executionSchedule.setDaysOfWeek(selectedDays);
-
- executionSchedule.setDayOfMonth(Integer.parseInt(valuesManager.getValueAsString("dayOfMonth")));
-
- executionSchedule.setStartDate((Date) valuesManager.getValues().get("startDate"));
-
- if ("Never".equals(valuesManager.getValues().get("endType"))) {
- executionSchedule.setEndDate(null);
- } else {
- executionSchedule.setEndDate((Date) valuesManager.getValues().get("endDate"));
- }
-
- form.setValue("message", executionSchedule.getMessage());
- }
-
- private LinkedHashMap<String, String> enumValueMap(Class<? extends Enum> e) {
- LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
- for (Object o : EnumSet.allOf(e)) {
- Enum v = (Enum) o;
- map.put(v.name(), v.name()); // localize
- }
- return map;
- }
-
- public ExecutionSchedule getExecutionSchedule() {
- return executionSchedule;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 89a87fb..4af193b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -80,6 +80,16 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
private static final String BASE_VIEW_PATH = "Resource";
+ public static class Tab {
+ public static final String OPERATIONS = "Operations";
+ // TODO: other tabs
+ }
+
+ public static class OperationsSubTab {
+ public static final String SCHEDULES = "Schedules";
+ public static final String HISTORY = "History";
+ }
+
private Integer resourceId;
private ResourceComposite resourceComposite;
@@ -189,13 +199,12 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
.view_tabs_common_history()), null);
eventsTab.registerSubTabs(eventHistory);
tabs.add(eventsTab);
-
- operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), new ViewName("Operations", MSG
+ operationsTab = new TwoLevelTab(getTabSet().extendLocatorId(Tab.OPERATIONS), new ViewName(Tab.OPERATIONS, MSG
.view_tabs_common_operations()), "/images/icons/Operation_grey_16.png");
- this.operationsSchedules = new SubTab(operationsTab.extendLocatorId("Schedules"), new ViewName("Schedules", MSG
- .view_tabs_common_schedules()), null);
- this.operationsHistory = new SubTab(operationsTab.extendLocatorId("History"), new ViewName("History", MSG
- .view_tabs_common_history()), null);
+ this.operationsSchedules = new SubTab(operationsTab.extendLocatorId(OperationsSubTab.SCHEDULES),
+ new ViewName(OperationsSubTab.SCHEDULES, MSG.view_tabs_common_schedules()), null);
+ this.operationsHistory = new SubTab(operationsTab.extendLocatorId(OperationsSubTab.HISTORY),
+ new ViewName(OperationsSubTab.HISTORY, MSG.view_tabs_common_history()), null);
operationsTab.registerSubTabs(this.operationsSchedules, this.operationsHistory);
tabs.add(operationsTab);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 98e5755..cf34caf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -77,7 +77,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.InventoryView;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationCreateWizard;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupContextMenu;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupDetailView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeDatasource.AutoGroupTreeNode;
@@ -413,7 +412,7 @@ public class ResourceTreeView extends LocatableVLayout {
// Operations Menu
MenuItem operations = new MenuItem(MSG.view_tree_common_contextMenu_operations());
- enabled = (resourcePermission.isControl() && null == resourceType.getOperationDefinitions() && !resourceType
+ enabled = (resourcePermission.isControl() && (resourceType.getOperationDefinitions() != null) && !resourceType
.getOperationDefinitions().isEmpty());
operations.setEnabled(enabled);
if (enabled) {
@@ -422,7 +421,8 @@ public class ResourceTreeView extends LocatableVLayout {
MenuItem operationItem = new MenuItem(operationDefinition.getDisplayName());
operationItem.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
- new OperationCreateWizard(resource, operationDefinition).startOperationWizard();
+ CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(), ResourceDetailView.Tab.OPERATIONS,
+ ResourceDetailView.OperationsSubTab.SCHEDULES) + "/0/" + operationDefinition.getId());
}
});
opSubMenu.addItem(operationItem);
13 years, 2 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java | 69 ++++++++--
1 file changed, 58 insertions(+), 11 deletions(-)
New commits:
commit fbe4a6b41ac9f60f013b4de67fb05b59594c16d5
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 25 13:48:04 2011 -0500
show stats in window so you can navigate around and see the stats
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java
index 40fae1f..dfab374 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java
@@ -26,7 +26,6 @@ import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.types.SortDirection;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.grid.ListGridField;
@@ -59,6 +58,9 @@ public class TestRemoteServiceStatisticsView extends Table {
private static final SortSpecifier[] defaultSorts = new SortSpecifier[] { new SortSpecifier("average",
SortDirection.DESCENDING) };
+ // if this is true, this view is hosted by a standalone Window
+ private boolean inWindow = false;
+
public TestRemoteServiceStatisticsView(String locatorId) {
super(locatorId, "Remote Service Statistics", null, defaultSorts, null, false);
}
@@ -68,16 +70,25 @@ public class TestRemoteServiceStatisticsView extends Table {
ListGridField serviceName = new ListGridField(FIELD_SERVICENAME, "Service Name");
ListGridField methodName = new ListGridField(FIELD_METHODNAME, "Method Name");
ListGridField count = new ListGridField(FIELD_COUNT, "Count");
- count.setAlign(Alignment.CENTER);
ListGridField slowest = new ListGridField(FIELD_SLOWEST, "Slowest (ms)");
- slowest.setAlign(Alignment.RIGHT);
ListGridField average = new ListGridField(FIELD_AVERAGE, "Average (ms)");
- average.setAlign(Alignment.RIGHT);
ListGridField fastest = new ListGridField(FIELD_FASTEST, "Fastest (ms)");
- fastest.setAlign(Alignment.RIGHT);
ListGridField stddev = new ListGridField(FIELD_STDDEV, "Std Dev");
+
+ count.setAlign(Alignment.CENTER);
+ slowest.setAlign(Alignment.RIGHT);
+ average.setAlign(Alignment.RIGHT);
+ fastest.setAlign(Alignment.RIGHT);
stddev.setAlign(Alignment.RIGHT);
+ serviceName.setWidth("20%");
+ methodName.setWidth("*");
+ count.setWidth("8%");
+ slowest.setWidth("13%");
+ average.setWidth("13%");
+ fastest.setWidth("13%");
+ stddev.setWidth("8%");
+
getListGrid().setFields(serviceName, methodName, count, slowest, average, fastest, stddev);
refresh();
@@ -128,6 +139,17 @@ public class TestRemoteServiceStatisticsView extends Table {
.show();
}
});
+
+ if (!inWindow) {
+ addTableAction(extendLocatorId("showInWin"), "Show In Window", new AbstractTableAction(
+ TableActionEnablement.ALWAYS) {
+ @Override
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ new StatisticsWindow(extendLocatorId("statsWin")).show();
+ }
+ });
+ }
+
}
@Override
@@ -172,17 +194,14 @@ public class TestRemoteServiceStatisticsView extends Table {
LocatableHTMLPane htmlPane = new LocatableHTMLPane(extendLocatorId("winDetailsPane"));
htmlPane.setMargin(10);
- htmlPane.setDefaultWidth(500);
+ htmlPane.setDefaultWidth(600);
htmlPane.setDefaultHeight(400);
htmlPane.setContents(message);
- setupWindow(title, htmlPane);
- }
-
- private void setupWindow(String title, Canvas item) {
setTitle(title);
setShowMinimizeButton(false);
setShowMaximizeButton(true);
+ setShowCloseButton(true);
setIsModal(true);
setShowModalMask(true);
setAutoSize(true);
@@ -196,7 +215,35 @@ public class TestRemoteServiceStatisticsView extends Table {
markForDestroy();
}
});
- addItem(item);
+ addItem(htmlPane);
+ }
+ }
+
+ class StatisticsWindow extends LocatableWindow {
+ public StatisticsWindow(String locatorId) {
+ super(locatorId);
+ setTitle("Remote Service Statistics");
+ setShowMinimizeButton(true);
+ setShowMaximizeButton(true);
+ setShowCloseButton(true);
+ setIsModal(false);
+ setShowModalMask(false);
+ setWidth(700);
+ setHeight(300);
+ setShowResizer(true);
+ setCanDragResize(true);
+ centerInPage();
+ addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ markForDestroy();
+ }
+ });
+
+ TestRemoteServiceStatisticsView view;
+ view = new TestRemoteServiceStatisticsView(extendLocatorId("StatsViewInWin"));
+ view.inWindow = true;
+ addItem(view);
}
}
}
13 years, 2 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java | 27 +++++-----
1 file changed, 15 insertions(+), 12 deletions(-)
New commits:
commit 35f855ac5fcd9491b2a3c98a31e391cc7ddbdd60
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 25 12:53:04 2011 -0500
take spaces out of remote stats view url
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
index 5e69c1b..8aae428 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
@@ -65,7 +65,7 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
// view IDs for Misc section
private static final ViewName MISC_SECTION_VIEW_ID = new ViewName("Misc");
private static final ViewName PAGE_PLURALIZATION_TEST = new ViewName("PluralizationTest");
- private static final ViewName PAGE_REMOTE_SERVICE_STATISTICS = new ViewName("Remote Service Statistics");
+ private static final ViewName PAGE_REMOTE_SERVICE_STATISTICS = new ViewName("RemoteServiceStatistics");
public TestTopView() {
// This is a top level view, so our locator id can simply be our view id.
@@ -124,11 +124,12 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
}
});
- NavigationItem readOnlyConfigEditorItem = new NavigationItem(PAGE_READONLY_CONFIG_EDITOR, null, new ViewFactory() {
- public Canvas createView() {
- return new TestReadOnlyConfigurationView(extendLocatorId(PAGE_READONLY_CONFIG_EDITOR.getName()));
- }
- });
+ NavigationItem readOnlyConfigEditorItem = new NavigationItem(PAGE_READONLY_CONFIG_EDITOR, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new TestReadOnlyConfigurationView(extendLocatorId(PAGE_READONLY_CONFIG_EDITOR.getName()));
+ }
+ });
NavigationItem groupConfigEditorItem = new NavigationItem(PAGE_GROUP_CONFIG_EDITOR, null, new ViewFactory() {
public Canvas createView() {
@@ -136,14 +137,16 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
}
});
- NavigationItem readOnlyGroupConfigEditorItem = new NavigationItem(PAGE_READONLY_GROUP_CONFIG_EDITOR, null, new ViewFactory() {
- public Canvas createView() {
- return new TestReadOnlyGroupConfigurationView(extendLocatorId(PAGE_READONLY_GROUP_CONFIG_EDITOR.getName()));
- }
- });
+ NavigationItem readOnlyGroupConfigEditorItem = new NavigationItem(PAGE_READONLY_GROUP_CONFIG_EDITOR, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new TestReadOnlyGroupConfigurationView(extendLocatorId(PAGE_READONLY_GROUP_CONFIG_EDITOR
+ .getName()));
+ }
+ });
return new NavigationSection(CONFIGURATION_SECTION_VIEW_ID, configEditorItem, readOnlyConfigEditorItem,
- groupConfigEditorItem, readOnlyGroupConfigEditorItem);
+ groupConfigEditorItem, readOnlyGroupConfigEditorItem);
}
private NavigationSection buildMiscSection() {
13 years, 2 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java | 110 ++++++++--
1 file changed, 95 insertions(+), 15 deletions(-)
New commits:
commit af1289322da7f4173229e8920407e9002965e492
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 25 12:24:56 2011 -0500
be able to export the stats as CSV text. pops up the text in a window so you can copy-n-paste into your favorite spreadsheet software
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java
index 4757ff4..40fae1f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/i18n/TestRemoteServiceStatisticsView.java
@@ -20,10 +20,15 @@ package org.rhq.enterprise.gui.coregui.client.test.i18n;
import java.util.List;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.RecordList;
import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.types.SortDirection;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -32,6 +37,8 @@ import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
import org.rhq.enterprise.gui.coregui.client.util.rpc.RemoteServiceStatistics;
import org.rhq.enterprise.gui.coregui.client.util.rpc.RemoteServiceStatistics.Record.Summary;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/**
* A view that gives a display of statistics for all remote services executed since the application was loaded.
@@ -40,6 +47,15 @@ import org.rhq.enterprise.gui.coregui.client.util.rpc.RemoteServiceStatistics.Re
*/
public class TestRemoteServiceStatisticsView extends Table {
+ // these are used both as the name of the fields, titles of the headers and the columns of the CSV output
+ private static final String FIELD_SERVICENAME = "serviceName";
+ private static final String FIELD_METHODNAME = "methodName";
+ private static final String FIELD_COUNT = "count";
+ private static final String FIELD_SLOWEST = "slowest";
+ private static final String FIELD_AVERAGE = "average";
+ private static final String FIELD_FASTEST = "fastest";
+ private static final String FIELD_STDDEV = "stddev";
+
private static final SortSpecifier[] defaultSorts = new SortSpecifier[] { new SortSpecifier("average",
SortDirection.DESCENDING) };
@@ -49,23 +65,23 @@ public class TestRemoteServiceStatisticsView extends Table {
@Override
protected void configureTable() {
- ListGridField serviceName = new ListGridField("serviceName", "Service Name");
- ListGridField methodName = new ListGridField("methodName", "Method Name");
- ListGridField count = new ListGridField("count", "Count");
+ ListGridField serviceName = new ListGridField(FIELD_SERVICENAME, "Service Name");
+ ListGridField methodName = new ListGridField(FIELD_METHODNAME, "Method Name");
+ ListGridField count = new ListGridField(FIELD_COUNT, "Count");
count.setAlign(Alignment.CENTER);
- ListGridField slowest = new ListGridField("slowest", "Slowest (ms)");
+ ListGridField slowest = new ListGridField(FIELD_SLOWEST, "Slowest (ms)");
slowest.setAlign(Alignment.RIGHT);
- ListGridField average = new ListGridField("average", "Average (ms)");
+ ListGridField average = new ListGridField(FIELD_AVERAGE, "Average (ms)");
average.setAlign(Alignment.RIGHT);
- ListGridField fastest = new ListGridField("fastest", "Fastest (ms)");
+ ListGridField fastest = new ListGridField(FIELD_FASTEST, "Fastest (ms)");
fastest.setAlign(Alignment.RIGHT);
- ListGridField stddev = new ListGridField("stddev", "Std Dev");
+ ListGridField stddev = new ListGridField(FIELD_STDDEV, "Std Dev");
stddev.setAlign(Alignment.RIGHT);
getListGrid().setFields(serviceName, methodName, count, slowest, average, fastest, stddev);
refresh();
- addTableAction(extendLocatorId("delete"), MSG.common_button_delete(), MSG.common_msg_areYouSure(),
+ addTableAction(extendLocatorId("deleteAll"), MSG.common_button_delete_all(), MSG.common_msg_areYouSure(),
new AbstractTableAction(TableActionEnablement.ALWAYS) {
@Override
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -81,6 +97,37 @@ public class TestRemoteServiceStatisticsView extends Table {
refresh();
}
});
+
+ addTableAction(extendLocatorId("export"), "Export To CSV",
+ new AbstractTableAction(TableActionEnablement.ALWAYS) {
+ @Override
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ StringBuilder csv = new StringBuilder();
+ csv.append(FIELD_SERVICENAME).append(',') //
+ .append(FIELD_METHODNAME).append(',') //
+ .append(FIELD_COUNT).append(',') //
+ .append(FIELD_SLOWEST).append(',') //
+ .append(FIELD_AVERAGE).append(',') //
+ .append(FIELD_FASTEST).append(',') //
+ .append(FIELD_STDDEV).append('\n');
+
+ RecordList records = getListGrid().getDataAsRecordList();
+ int recordsSize = records.getLength();
+ for (int i = 0; i < recordsSize; i++) {
+ Record record = records.get(i);
+ csv.append(record.getAttribute(FIELD_SERVICENAME)).append(',') //
+ .append(record.getAttribute(FIELD_METHODNAME)).append(',') //
+ .append(record.getAttribute(FIELD_COUNT)).append(',') //
+ .append(record.getAttribute(FIELD_SLOWEST)).append(',') //
+ .append(record.getAttribute(FIELD_AVERAGE)).append(',') //
+ .append(record.getAttribute(FIELD_FASTEST)).append(',') //
+ .append(record.getAttribute(FIELD_STDDEV)).append('\n');
+ }
+
+ new MessageWindow(extendLocatorId("csv"), "Export To CSV", "<pre>" + csv.toString() + "</pre>")
+ .show();
+ }
+ });
}
@Override
@@ -109,14 +156,47 @@ public class TestRemoteServiceStatisticsView extends Table {
private ListGridRecord transform(Summary stat) {
ListGridRecord record = new ListGridRecord();
- record.setAttribute("serviceName", stat.serviceName);
- record.setAttribute("methodName", stat.methodName);
- record.setAttribute("count", stat.count);
- record.setAttribute("slowest", stat.slowest);
- record.setAttribute("average", stat.average);
- record.setAttribute("fastest", stat.fastest);
- record.setAttribute("stddev", stat.stddev);
+ record.setAttribute(FIELD_SERVICENAME, stat.serviceName);
+ record.setAttribute(FIELD_METHODNAME, stat.methodName);
+ record.setAttribute(FIELD_COUNT, stat.count);
+ record.setAttribute(FIELD_SLOWEST, stat.slowest);
+ record.setAttribute(FIELD_AVERAGE, stat.average);
+ record.setAttribute(FIELD_FASTEST, stat.fastest);
+ record.setAttribute(FIELD_STDDEV, stat.stddev);
return record;
}
+ class MessageWindow extends LocatableWindow {
+ public MessageWindow(String locatorId, String title, String message) {
+ super(locatorId);
+
+ LocatableHTMLPane htmlPane = new LocatableHTMLPane(extendLocatorId("winDetailsPane"));
+ htmlPane.setMargin(10);
+ htmlPane.setDefaultWidth(500);
+ htmlPane.setDefaultHeight(400);
+ htmlPane.setContents(message);
+
+ setupWindow(title, htmlPane);
+ }
+
+ private void setupWindow(String title, Canvas item) {
+ setTitle(title);
+ setShowMinimizeButton(false);
+ setShowMaximizeButton(true);
+ setIsModal(true);
+ setShowModalMask(true);
+ setAutoSize(true);
+ setAutoCenter(true);
+ setShowResizer(true);
+ setCanDragResize(true);
+ centerInPage();
+ addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ markForDestroy();
+ }
+ });
+ addItem(item);
+ }
+ }
}
13 years, 2 months
[rhq] Branch 'cli-alert-notifs' - 8 commits - modules/core modules/enterprise
by lkrejci
modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java | 6
modules/core/domain/src/main/java/org/rhq/core/domain/util/OSGiVersion.java | 153 ++++++
modules/core/domain/src/main/java/org/rhq/core/domain/util/OSGiVersionComparator.java | 62 --
modules/enterprise/binding/src/main/java/org/rhq/bindings/SandboxedScriptEngine.java | 1
modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java | 15
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java | 227 +++++-----
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java | 18
modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/JsEngineInitializer.java | 6
modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ResourceTypeFingerprint.java | 182 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java | 46 +-
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java | 11
modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliComponent.java | 159 ++++---
modules/enterprise/server/plugins/alert-cli/src/main/java/org/rhq/enterprise/server/plugins/alertCli/CliSender.java | 28 -
modules/enterprise/server/plugins/alert-cli/src/main/resources/META-INF/rhq-serverplugin.xml | 18
18 files changed, 737 insertions(+), 216 deletions(-)
New commits:
commit 28f92d3dfcd8ac86c89e241b52a1dee6084f9a3f
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 25 17:52:56 2011 +0100
Caching custom interfaces for resource proxies obtained from ProxyFactory.
This is especially important in the server environment so that we don't waste the permgen if we don't have to.
By relying on the resource type structure to determine equality of resource types, plugin updates are seemlessly supported.
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java
index 480a5dd..6f15e81 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java
@@ -4,10 +4,10 @@ import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
import javax.jws.WebParam;
@@ -27,6 +27,7 @@ import javassist.util.proxy.MethodHandler;
import javassist.util.proxy.ProxyFactory;
import org.rhq.bindings.util.ConfigurationClassBuilder;
+import org.rhq.bindings.util.ResourceTypeFingerprint;
import org.rhq.core.domain.resource.ResourceCreationDataType;
/**
@@ -36,8 +37,16 @@ import org.rhq.core.domain.resource.ResourceCreationDataType;
*/
public class ResourceClientFactory {
+ private static class CacheRecord {
+ public ResourceTypeFingerprint fingerprint;
+ public Class<?> iface;
+ }
+
private static final Log LOG = LogFactory.getLog(ResourceClientFactory.class);
+ //keys are resource type ids
+ private static HashMap<Integer, CacheRecord> CUSTOM_CLASS_CACHE = new HashMap<Integer, CacheRecord>();
+
private RhqFacade rhqFacade;
private PrintWriter outputWriter;
@@ -46,8 +55,6 @@ public class ResourceClientFactory {
this.outputWriter = outputWriter;
}
- private static AtomicInteger classIndex = new AtomicInteger();
-
public RhqFacade getRemoteClient() {
return rhqFacade;
}
@@ -60,73 +67,22 @@ public class ResourceClientFactory {
ResourceClientProxy proxy = new ResourceClientProxy(this, resourceId);
Class<?> customInterface = null;
- try {
- // define the dynamic class
- ClassPool pool = ClassPool.getDefault();
- CtClass customClass = pool.makeInterface(ResourceClientProxy.class.getName() + "__Custom__"
- + classIndex.getAndIncrement());
-
- for (String key : proxy.allProperties.keySet()) {
- Object prop = proxy.allProperties.get(key);
-
- if (prop instanceof ResourceClientProxy.Measurement) {
- ResourceClientProxy.Measurement m = (ResourceClientProxy.Measurement) prop;
- String name = ResourceClientProxy.getterName(key);
-
- try {
- ResourceClientProxy.class.getMethod(name);
- } catch (NoSuchMethodException nsme) {
- CtMethod method = CtNewMethod.abstractMethod(pool.get(ResourceClientProxy.Measurement.class.getName()),
- ResourceClientProxy.getterName(key), new CtClass[0], new CtClass[0], customClass);
- customClass.addMethod(method);
- }
- } else if (prop instanceof ResourceClientProxy.Operation) {
- ResourceClientProxy.Operation o = (ResourceClientProxy.Operation) prop;
-
- LinkedHashMap<String, CtClass> types = ConfigurationClassBuilder.translateParameters(o
- .getDefinition().getParametersConfigurationDefinition());
-
- CtClass[] params = new CtClass[types.size()];
- int x = 0;
- for (String param : types.keySet()) {
- params[x++] = types.get(param);
- }
-
- CtMethod method = CtNewMethod.abstractMethod(ConfigurationClassBuilder.translateConfiguration(o
- .getDefinition().getResultsConfigurationDefinition()), ResourceClientProxy.simpleName(key), params,
- new javassist.CtClass[0], customClass);
-
- // Setup @WebParam annotations so the signatures have the config prop names
- Annotation[][] newAnnotations = new Annotation[params.length][1];
- int i = 0;
- for (String paramName : types.keySet()) {
- newAnnotations[i] = new Annotation[1];
-
- newAnnotations[i][0] = new Annotation(WebParam.class.getName(), method.getMethodInfo()
- .getConstPool());
- newAnnotations[i][0].addMemberValue("name", new StringMemberValue(paramName, method
- .getMethodInfo().getConstPool()));
- i++;
- }
-
- ParameterAnnotationsAttribute newAnnotationsAttribute = new ParameterAnnotationsAttribute(
- method.getMethodInfo().getConstPool(), ParameterAnnotationsAttribute.visibleTag);
- newAnnotationsAttribute.setAnnotations(newAnnotations);
- method.getMethodInfo().addAttribute(newAnnotationsAttribute);
-
- customClass.addMethod(method);
- }
+ synchronized (CUSTOM_CLASS_CACHE) {
+ Integer resourceTypeId = proxy.getResourceType().getId();
+ CacheRecord record = CUSTOM_CLASS_CACHE.get(resourceTypeId);
+
+ //if we don't have a cached custom interface for this resource type
+ //or if the resource type has changed, generate the custom iface for it.
+ if (record == null || !record.fingerprint.equals(proxy.fingerprint)) {
+ record = new CacheRecord();
+ record.fingerprint = proxy.fingerprint;
+ record.iface = defineCustomInterface(proxy);
+ CUSTOM_CLASS_CACHE.put(resourceTypeId, record);
}
-
- customInterface = customClass.toClass();
- } catch (NotFoundException e) {
- LOG.error("Could not create custom interface for resource with id " + resourceId, e);
- } catch (CannotCompileException e) {
- LOG.error("Could not create custom interface for resource with id " + resourceId, e);
- } catch (Exception e) {
- LOG.error("Could not create custom interface for resource with id " + resourceId, e);
+
+ customInterface = record.iface;
}
-
+
if (customInterface != null) {
List<Class<?>> interfaces = new ArrayList<Class<?>>();
@@ -185,4 +141,73 @@ public class ResourceClientFactory {
protected MethodHandler instantiateMethodHandler(ResourceClientProxy proxy, List<Class<?>> interfaces, RhqFacade remoteClient) {
return new ResourceClientProxy.ClientProxyMethodHandler(proxy, remoteClient);
}
+
+ private Class<?> defineCustomInterface(ResourceClientProxy proxy) {
+ try {
+ // define the dynamic class
+ ClassPool pool = ClassPool.getDefault();
+ CtClass customClass = pool.makeInterface(ResourceClientProxy.class.getName() + proxy.fingerprint);
+
+ for (String key : proxy.allProperties.keySet()) {
+ Object prop = proxy.allProperties.get(key);
+
+ if (prop instanceof ResourceClientProxy.Measurement) {
+ String name = ResourceClientProxy.getterName(key);
+
+ try {
+ ResourceClientProxy.class.getMethod(name);
+ } catch (NoSuchMethodException nsme) {
+ CtMethod method = CtNewMethod.abstractMethod(pool.get(ResourceClientProxy.Measurement.class.getName()),
+ ResourceClientProxy.getterName(key), new CtClass[0], new CtClass[0], customClass);
+ customClass.addMethod(method);
+ }
+ } else if (prop instanceof ResourceClientProxy.Operation) {
+ ResourceClientProxy.Operation o = (ResourceClientProxy.Operation) prop;
+
+ LinkedHashMap<String, CtClass> types = ConfigurationClassBuilder.translateParameters(o
+ .getDefinition().getParametersConfigurationDefinition());
+
+ CtClass[] params = new CtClass[types.size()];
+ int x = 0;
+ for (String param : types.keySet()) {
+ params[x++] = types.get(param);
+ }
+
+ CtMethod method = CtNewMethod.abstractMethod(ConfigurationClassBuilder.translateConfiguration(o
+ .getDefinition().getResultsConfigurationDefinition()), ResourceClientProxy.simpleName(key), params,
+ new javassist.CtClass[0], customClass);
+
+ // Setup @WebParam annotations so the signatures have the config prop names
+ Annotation[][] newAnnotations = new Annotation[params.length][1];
+ int i = 0;
+ for (String paramName : types.keySet()) {
+ newAnnotations[i] = new Annotation[1];
+
+ newAnnotations[i][0] = new Annotation(WebParam.class.getName(), method.getMethodInfo()
+ .getConstPool());
+ newAnnotations[i][0].addMemberValue("name", new StringMemberValue(paramName, method
+ .getMethodInfo().getConstPool()));
+ i++;
+ }
+
+ ParameterAnnotationsAttribute newAnnotationsAttribute = new ParameterAnnotationsAttribute(
+ method.getMethodInfo().getConstPool(), ParameterAnnotationsAttribute.visibleTag);
+ newAnnotationsAttribute.setAnnotations(newAnnotations);
+ method.getMethodInfo().addAttribute(newAnnotationsAttribute);
+
+ customClass.addMethod(method);
+ }
+ }
+
+ return customClass.toClass();
+ } catch (NotFoundException e) {
+ LOG.error("Could not create custom interface for resource with id " + proxy.getId(), e);
+ } catch (CannotCompileException e) {
+ LOG.error("Could not create custom interface for resource with id " + proxy.getId(), e);
+ } catch (Exception e) {
+ LOG.error("Could not create custom interface for resource with id " + proxy.getId(), e);
+ }
+
+ return null;
+ }
}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java
index 5b49e18..b850605 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java
@@ -29,10 +29,14 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import javassist.util.proxy.MethodHandler;
import org.rhq.bindings.util.ConfigurationClassBuilder;
import org.rhq.bindings.util.LazyLoadScenario;
+import org.rhq.bindings.util.ResourceTypeFingerprint;
import org.rhq.bindings.util.ScriptUtil;
import org.rhq.bindings.util.ShortOutput;
import org.rhq.core.domain.configuration.Configuration;
@@ -74,6 +78,8 @@ import org.rhq.enterprise.server.resource.ResourceTypeNotFoundException;
*/
public class ResourceClientProxy {
+ private static final Log LOG = LogFactory.getLog(ResourceClientProxy.class);
+
private ResourceClientFactory proxyFactory;
private RhqFacade remoteClient;
private int resourceId;
@@ -81,6 +87,8 @@ public class ResourceClientProxy {
Map<String, Object> allProperties = new HashMap<String, Object>();
+ ResourceTypeFingerprint fingerprint;
+
// Metadata
private List<MeasurementDefinition> measurementDefinitions;
private Map<String, Measurement> measurementMap = new HashMap<String, Measurement>();
@@ -197,6 +205,14 @@ public class ResourceClientProxy {
initOperations();
initConfigDefs();
initContent();
+
+ List<PackageType> packageTypes = new ArrayList<PackageType>();
+ for(ContentType ct : contentTypes.values()) {
+ packageTypes.add(ct.getPackageType());
+ }
+
+ fingerprint = new ResourceTypeFingerprint(resource.getResourceType(), measurementDefinitions,
+ operationDefinitions, packageTypes, pluginConfigurationDefinition, resourceConfigurationDefinition);
}
private void initConfigDefs() {
@@ -267,7 +283,7 @@ public class ResourceClientProxy {
contentTypes.put(packageType.getName(), new ContentType(packageType));
}
} catch (ResourceTypeNotFoundException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ LOG.error("Could not find resource type while creating content mappings of the resource proxy for resource with id " + resourceId, e);
}
}
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ResourceTypeFingerprint.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ResourceTypeFingerprint.java
new file mode 100644
index 0000000..fa20b86
--- /dev/null
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/util/ResourceTypeFingerprint.java
@@ -0,0 +1,182 @@
+/*
+ * 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.bindings.util;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.util.MessageDigestGenerator;
+
+/**
+ * This type is used as an identification of a resource type not based
+ * on its id but rather on its structure.
+ *
+ * @author Lukas Krejci
+ */
+public class ResourceTypeFingerprint {
+
+ private String digest;
+
+ public ResourceTypeFingerprint(ResourceType rt, Collection<MeasurementDefinition> measurements,
+ Collection<OperationDefinition> operations, Collection<PackageType> packageTypes,
+ ConfigurationDefinition pluginConfigurationDefinition, ConfigurationDefinition resourceConfigurationDefinition) {
+
+ digest = computeDigest(rt, measurements, operations, packageTypes, pluginConfigurationDefinition,
+ resourceConfigurationDefinition);
+ }
+
+ @Override
+ public int hashCode() {
+ return digest.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof ResourceTypeFingerprint)) {
+ return false;
+ }
+
+ ResourceTypeFingerprint o = (ResourceTypeFingerprint) other;
+
+ return digest.equals(o.digest);
+ }
+
+ @Override
+ public String toString() {
+ return digest;
+ }
+
+ private static String computeDigest(ResourceType rt, Collection<MeasurementDefinition> measurements,
+ Collection<OperationDefinition> operations, Collection<PackageType> packageTypes,
+ ConfigurationDefinition pluginConfigurationDefinition, ConfigurationDefinition resourceConfigurationDefinition) {
+
+ StringBuilder representation = new StringBuilder();
+
+ addResourceTypeRepresentation(rt, representation);
+ addMeasurementDefinitionsRepresentations(measurements, representation);
+ addOperationDefinitionsRepresentations(operations, representation);
+ addPackageTypesRepresentations(packageTypes, representation);
+ addRepresentation(pluginConfigurationDefinition, representation);
+ addRepresentation(resourceConfigurationDefinition, representation);
+
+ return new MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(representation.toString());
+ }
+
+ private static void addResourceTypeRepresentation(ResourceType rt, StringBuilder bld) {
+ bld.append(rt.getName()).append(rt.getPlugin());
+ }
+
+ private static void addMeasurementDefinitionsRepresentations(Collection<MeasurementDefinition> defs,
+ StringBuilder bld) {
+ if (defs == null) {
+ bld.append("null");
+ } else {
+ for (MeasurementDefinition d : defs) {
+ addRepresentation(d, bld);
+ }
+ }
+ }
+
+ private static void addOperationDefinitionsRepresentations(Collection<OperationDefinition> defs, StringBuilder bld) {
+ if (defs == null) {
+ bld.append("null");
+ } else {
+ for (OperationDefinition d : defs) {
+ addRepresentation(d, bld);
+ }
+ }
+ }
+
+ private static void addPackageTypesRepresentations(Collection<PackageType> defs, StringBuilder bld) {
+ if (defs == null) {
+ bld.append("null");
+ } else {
+ for (PackageType d : defs) {
+ addRepresentation(d, bld);
+ }
+ }
+ }
+
+ private static void addRepresentation(MeasurementDefinition md, StringBuilder bld) {
+ bld.append(md.getName());
+ }
+
+ private static void addRepresentation(OperationDefinition od, StringBuilder bld) {
+ bld.append(od.getName());
+ addRepresentation(od.getResultsConfigurationDefinition(), bld);
+ addRepresentation(od.getParametersConfigurationDefinition(), bld);
+ }
+
+ private static void addRepresentation(PackageType pt, StringBuilder bld) {
+ bld.append(pt.getName());
+ }
+
+ private static void addRepresentation(ConfigurationDefinition cd, StringBuilder bld) {
+ if (cd == null) {
+ bld.append("null");
+ } else {
+ addRepresentation(cd.getPropertyDefinitions(), bld);
+ }
+ }
+
+ private static void addRepresentation(Map<String, PropertyDefinition> defs, StringBuilder bld) {
+ for (Map.Entry<String, PropertyDefinition> entry : defs.entrySet()) {
+ PropertyDefinition def = entry.getValue();
+ addRepresentation(def, bld);
+ }
+ }
+
+ private static void addRepresentation(PropertyDefinition def, StringBuilder bld) {
+ if (def instanceof PropertyDefinitionSimple) {
+ addRepresentation((PropertyDefinitionSimple) def, bld);
+ } else if (def instanceof PropertyDefinitionMap) {
+ addRepresentation((PropertyDefinitionMap) def, bld);
+ } else if (def instanceof PropertyDefinitionList) {
+ addRepresentation((PropertyDefinitionList) def, bld);
+ }
+ }
+
+ private static void addRepresentation(PropertyDefinitionSimple p, StringBuilder bld) {
+ bld.append(p.getName()).append(p.getType().name());
+ }
+
+ private static void addRepresentation(PropertyDefinitionMap pm, StringBuilder bld) {
+ bld.append(pm.getName());
+ addRepresentation(pm.getPropertyDefinitions(), bld);
+ }
+
+ private static void addRepresentation(PropertyDefinitionList pl, StringBuilder bld) {
+ bld.append(pl.getName());
+ addRepresentation(pl.getMemberDefinition(), bld);
+ }
+}
commit d64951a6f0b4478e85156cb08bd1e9ca772b97f1
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 25 15:31:10 2011 +0100
remove e.printStacktrace(), import classes instead of using full names.
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java
index 2112073..480a5dd 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientFactory.java
@@ -1,14 +1,30 @@
package org.rhq.bindings.client;
import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.jws.WebParam;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javassist.CannotCompileException;
import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtMethod;
import javassist.CtNewMethod;
+import javassist.NotFoundException;
import javassist.bytecode.ParameterAnnotationsAttribute;
+import javassist.bytecode.annotation.Annotation;
+import javassist.bytecode.annotation.StringMemberValue;
import javassist.util.proxy.MethodHandler;
+import javassist.util.proxy.ProxyFactory;
import org.rhq.bindings.util.ConfigurationClassBuilder;
import org.rhq.core.domain.resource.ResourceCreationDataType;
@@ -20,17 +36,19 @@ import org.rhq.core.domain.resource.ResourceCreationDataType;
*/
public class ResourceClientFactory {
- private org.rhq.bindings.client.RhqFacade rhqFacade;
+ private static final Log LOG = LogFactory.getLog(ResourceClientFactory.class);
+
+ private RhqFacade rhqFacade;
private PrintWriter outputWriter;
- public ResourceClientFactory(org.rhq.bindings.client.RhqFacade remoteClient, PrintWriter outputWriter) {
+ public ResourceClientFactory(RhqFacade remoteClient, PrintWriter outputWriter) {
this.rhqFacade = remoteClient;
this.outputWriter = outputWriter;
}
- private static java.util.concurrent.atomic.AtomicInteger classIndex = new java.util.concurrent.atomic.AtomicInteger();
+ private static AtomicInteger classIndex = new AtomicInteger();
- public org.rhq.bindings.client.RhqFacade getRemoteClient() {
+ public RhqFacade getRemoteClient() {
return rhqFacade;
}
@@ -38,60 +56,60 @@ public class ResourceClientFactory {
return outputWriter;
}
- public org.rhq.bindings.client.ResourceClientProxy getResource(int resourceId) {
+ public ResourceClientProxy getResource(int resourceId) {
- org.rhq.bindings.client.ResourceClientProxy proxy = new org.rhq.bindings.client.ResourceClientProxy(this, resourceId);
- java.lang.Class<?> customInterface = null;
+ ResourceClientProxy proxy = new ResourceClientProxy(this, resourceId);
+ Class<?> customInterface = null;
try {
// define the dynamic class
- javassist.ClassPool pool = ClassPool.getDefault();
- javassist.CtClass customClass = pool.makeInterface(org.rhq.bindings.client.ResourceClientProxy.class.getName() + "__Custom__"
+ ClassPool pool = ClassPool.getDefault();
+ CtClass customClass = pool.makeInterface(ResourceClientProxy.class.getName() + "__Custom__"
+ classIndex.getAndIncrement());
- for (java.lang.String key : proxy.allProperties.keySet()) {
- java.lang.Object prop = proxy.allProperties.get(key);
+ for (String key : proxy.allProperties.keySet()) {
+ Object prop = proxy.allProperties.get(key);
- if (prop instanceof org.rhq.bindings.client.ResourceClientProxy.Measurement) {
- org.rhq.bindings.client.ResourceClientProxy.Measurement m = (org.rhq.bindings.client.ResourceClientProxy.Measurement) prop;
- java.lang.String name = org.rhq.bindings.client.ResourceClientProxy.getterName(key);
+ if (prop instanceof ResourceClientProxy.Measurement) {
+ ResourceClientProxy.Measurement m = (ResourceClientProxy.Measurement) prop;
+ String name = ResourceClientProxy.getterName(key);
try {
- org.rhq.bindings.client.ResourceClientProxy.class.getMethod(name);
- } catch (java.lang.NoSuchMethodException nsme) {
- javassist.CtMethod method = CtNewMethod.abstractMethod(pool.get(org.rhq.bindings.client.ResourceClientProxy.Measurement.class.getName()),
- org.rhq.bindings.client.ResourceClientProxy.getterName(key), new javassist.CtClass[0], new javassist.CtClass[0], customClass);
+ ResourceClientProxy.class.getMethod(name);
+ } catch (NoSuchMethodException nsme) {
+ CtMethod method = CtNewMethod.abstractMethod(pool.get(ResourceClientProxy.Measurement.class.getName()),
+ ResourceClientProxy.getterName(key), new CtClass[0], new CtClass[0], customClass);
customClass.addMethod(method);
}
- } else if (prop instanceof org.rhq.bindings.client.ResourceClientProxy.Operation) {
- org.rhq.bindings.client.ResourceClientProxy.Operation o = (org.rhq.bindings.client.ResourceClientProxy.Operation) prop;
+ } else if (prop instanceof ResourceClientProxy.Operation) {
+ ResourceClientProxy.Operation o = (ResourceClientProxy.Operation) prop;
- java.util.LinkedHashMap<java.lang.String, javassist.CtClass> types = ConfigurationClassBuilder.translateParameters(o
+ LinkedHashMap<String, CtClass> types = ConfigurationClassBuilder.translateParameters(o
.getDefinition().getParametersConfigurationDefinition());
- javassist.CtClass[] params = new javassist.CtClass[types.size()];
+ CtClass[] params = new CtClass[types.size()];
int x = 0;
- for (java.lang.String param : types.keySet()) {
+ for (String param : types.keySet()) {
params[x++] = types.get(param);
}
- javassist.CtMethod method = CtNewMethod.abstractMethod(ConfigurationClassBuilder.translateConfiguration(o
- .getDefinition().getResultsConfigurationDefinition()), org.rhq.bindings.client.ResourceClientProxy.simpleName(key), params,
+ CtMethod method = CtNewMethod.abstractMethod(ConfigurationClassBuilder.translateConfiguration(o
+ .getDefinition().getResultsConfigurationDefinition()), ResourceClientProxy.simpleName(key), params,
new javassist.CtClass[0], customClass);
// Setup @WebParam annotations so the signatures have the config prop names
- javassist.bytecode.annotation.Annotation[][] newAnnotations = new javassist.bytecode.annotation.Annotation[params.length][1];
+ Annotation[][] newAnnotations = new Annotation[params.length][1];
int i = 0;
- for (java.lang.String paramName : types.keySet()) {
- newAnnotations[i] = new javassist.bytecode.annotation.Annotation[1];
+ for (String paramName : types.keySet()) {
+ newAnnotations[i] = new Annotation[1];
- newAnnotations[i][0] = new javassist.bytecode.annotation.Annotation(javax.jws.WebParam.class.getName(), method.getMethodInfo()
+ newAnnotations[i][0] = new Annotation(WebParam.class.getName(), method.getMethodInfo()
.getConstPool());
- newAnnotations[i][0].addMemberValue("name", new javassist.bytecode.annotation.StringMemberValue(paramName, method
+ newAnnotations[i][0].addMemberValue("name", new StringMemberValue(paramName, method
.getMethodInfo().getConstPool()));
i++;
}
- javassist.bytecode.ParameterAnnotationsAttribute newAnnotationsAttribute = new javassist.bytecode.ParameterAnnotationsAttribute(
+ ParameterAnnotationsAttribute newAnnotationsAttribute = new ParameterAnnotationsAttribute(
method.getMethodInfo().getConstPool(), ParameterAnnotationsAttribute.visibleTag);
newAnnotationsAttribute.setAnnotations(newAnnotations);
method.getMethodInfo().addAttribute(newAnnotationsAttribute);
@@ -101,17 +119,17 @@ public class ResourceClientFactory {
}
customInterface = customClass.toClass();
- } catch (javassist.NotFoundException e) {
- e.printStackTrace();
- } catch (javassist.CannotCompileException e) {
- e.printStackTrace();
- } catch (java.lang.Exception e) {
- e.printStackTrace();
+ } catch (NotFoundException e) {
+ LOG.error("Could not create custom interface for resource with id " + resourceId, e);
+ } catch (CannotCompileException e) {
+ LOG.error("Could not create custom interface for resource with id " + resourceId, e);
+ } catch (Exception e) {
+ LOG.error("Could not create custom interface for resource with id " + resourceId, e);
}
if (customInterface != null) {
- java.util.List<java.lang.Class<?>> interfaces = new java.util.ArrayList<java.lang.Class<?>>();
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
interfaces.add(customInterface);
if (proxy.resourceConfigurationDefinition != null) {
interfaces.add(getResourceConfigurableInterface());
@@ -126,21 +144,21 @@ public class ResourceClientFactory {
interfaces.addAll(getAdditionalInterfaces(proxy));
- javassist.util.proxy.ProxyFactory proxyFactory = new javassist.util.proxy.ProxyFactory();
- proxyFactory.setInterfaces(interfaces.toArray(new java.lang.Class[interfaces.size()]));
- proxyFactory.setSuperclass(org.rhq.bindings.client.ResourceClientProxy.class);
- org.rhq.bindings.client.ResourceClientProxy proxied = null;
+ ProxyFactory proxyFactory = new ProxyFactory();
+ proxyFactory.setInterfaces(interfaces.toArray(new Class[interfaces.size()]));
+ proxyFactory.setSuperclass(ResourceClientProxy.class);
+ ResourceClientProxy proxied = null;
try {
- proxied = (org.rhq.bindings.client.ResourceClientProxy) proxyFactory.create(new java.lang.Class[]{}, new java.lang.Object[]{},
+ proxied = (ResourceClientProxy) proxyFactory.create(new Class[]{}, new Object[]{},
instantiateMethodHandler(proxy, interfaces, rhqFacade));
- } catch (java.lang.InstantiationException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- } catch (java.lang.IllegalAccessException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- } catch (java.lang.NoSuchMethodException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- } catch (java.lang.reflect.InvocationTargetException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (InstantiationException e) {
+ LOG.error("Could not instantiate a ResourceClientProxy, this is a bug.", e);
+ } catch (IllegalAccessException e) {
+ LOG.error("Could not instantiate a ResourceClientProxy, this is a bug.", e);
+ } catch (NoSuchMethodException e) {
+ LOG.error("Could not instantiate a ResourceClientProxy, this is a bug.", e);
+ } catch (InvocationTargetException e) {
+ LOG.error("Could not instantiate a ResourceClientProxy, this is a bug.", e);
}
return proxied;
}
@@ -149,22 +167,22 @@ public class ResourceClientFactory {
}
protected Class<?> getResourceConfigurableInterface() {
- return org.rhq.bindings.client.ResourceClientProxy.ResourceConfigurable.class;
+ return ResourceClientProxy.ResourceConfigurable.class;
}
protected Class<?> getPluginConfigurableInterface() {
- return org.rhq.bindings.client.ResourceClientProxy.PluginConfigurable.class;
+ return ResourceClientProxy.PluginConfigurable.class;
}
protected Class<?> getContentBackedInterface() {
- return org.rhq.bindings.client.ResourceClientProxy.ContentBackedResource.class;
+ return ResourceClientProxy.ContentBackedResource.class;
}
protected Set<Class<?>> getAdditionalInterfaces(ResourceClientProxy proxy) {
return Collections.emptySet();
}
- protected MethodHandler instantiateMethodHandler(ResourceClientProxy proxy, List<Class<?>> interfaces, org.rhq.bindings.client.RhqFacade remoteClient) {
- return new org.rhq.bindings.client.ResourceClientProxy.ClientProxyMethodHandler(proxy, remoteClient);
+ protected MethodHandler instantiateMethodHandler(ResourceClientProxy proxy, List<Class<?>> interfaces, RhqFacade remoteClient) {
+ return new ResourceClientProxy.ClientProxyMethodHandler(proxy, remoteClient);
}
}
commit 80edc2625c2e8348f52647cfb6910ea6cd4a3315
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 25 13:36:46 2011 +0100
Suggesting the package version in the upload form of the CLI notification editor.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/OSGiVersion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/util/OSGiVersion.java
new file mode 100644
index 0000000..0c9d664
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/OSGiVersion.java
@@ -0,0 +1,153 @@
+/*
+ * 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;
+
+/**
+ * A simple representation of an OSGi formatted version string.
+ *
+ * All fields except the "major" part of the version can be undefined.
+ *
+ * @author Lukas Krejci
+ */
+public class OSGiVersion {
+ private int major;
+ private Integer minor;
+ private Integer micro;
+ private String qualifier;
+
+ public OSGiVersion() {
+
+ }
+
+ public OSGiVersion(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 + "]");
+ }
+ }
+
+ /**
+ * @return the major
+ */
+ public int getMajor() {
+ return major;
+ }
+
+ /**
+ * @param major the major to set
+ */
+ public void setMajor(int major) {
+ this.major = major;
+ }
+
+ /**
+ * @return the minor
+ */
+ public Integer getMinorIfDefined() {
+ return minor;
+ }
+
+ public int getMinor() {
+ return minor == null ? 0 : minor;
+ }
+
+ /**
+ * @param minor the minor to set
+ */
+ public void setMinor(Integer minor) {
+ this.minor = minor;
+ }
+
+ /**
+ * @return the micro
+ */
+ public int getMicro() {
+ return micro == null ? 0 : micro;
+ }
+
+ public Integer getMicroIfDefined() {
+ return micro;
+ }
+
+ /**
+ * @param micro the micro to set
+ */
+ public void setMicro(Integer micro) {
+ this.micro = micro;
+ }
+
+ /**
+ * @return the qualifier
+ */
+ public String getQualifier() {
+ return qualifier;
+ }
+
+ /**
+ * @param qualifier the qualifier to set
+ */
+ public void setQualifier(String qualifier) {
+ this.qualifier = qualifier;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder bld = new StringBuilder();
+ bld.append(major);
+
+ if (minor != null) {
+ bld.append(".").append(minor);
+ }
+
+ if (micro != null) {
+ bld.append(".").append(micro);
+ }
+
+ if (qualifier != null) {
+ bld.append(".").append(qualifier);
+ }
+
+ return bld.toString();
+ }
+}
\ No newline at end of file
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
index 1f3936d..70cdc74 100644
--- 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
@@ -37,58 +37,32 @@ public class OSGiVersionComparator implements Comparator<String> {
}
public int compare(String string1, String string2) {
- Version ver1 = new Version(string1);
- Version ver2 = new Version(string2);
+ OSGiVersion ver1 = new OSGiVersion(string1);
+ OSGiVersion ver2 = new OSGiVersion(string2);
- int result = ver1.major - ver2.major;
+ int result = ver1.getMajor() - ver2.getMajor();
if (result == 0) {
- result = ver1.minor - ver2.minor;
+ result = ver1.getMinor() - ver2.getMinor();
if (result == 0) {
- result = ver1.micro - ver2.micro;
+ result = ver1.getMicro() - ver2.getMicro();
if (result == 0) {
- result = ver1.qualifier.compareTo(ver2.qualifier);
+ if (ver1.getQualifier() != null) {
+ if (ver2.getQualifier() == null) {
+ result = 1;
+ } else {
+ ver1.getQualifier().compareTo(ver2.getQualifier());
+ }
+ } else {
+ if (ver2.getQualifier() == null) {
+ result = 0;
+ } else {
+ result = -1;
+ }
+ }
}
}
}
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/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java
index 69a2a65..e8d1c1c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java
@@ -28,6 +28,10 @@ import com.smartgwt.client.types.TitleOrientation;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.events.FormSubmitFailedEvent;
import com.smartgwt.client.widgets.form.events.FormSubmitFailedHandler;
+import com.smartgwt.client.widgets.form.events.ItemChangeEvent;
+import com.smartgwt.client.widgets.form.events.ItemChangeHandler;
+import com.smartgwt.client.widgets.form.events.ItemChangedEvent;
+import com.smartgwt.client.widgets.form.events.ItemChangedHandler;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.FormItemIcon;
@@ -35,6 +39,7 @@ import com.smartgwt.client.widgets.form.fields.PasswordItem;
import com.smartgwt.client.widgets.form.fields.SectionItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.UploadItem;
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;
@@ -49,6 +54,7 @@ import org.rhq.core.domain.content.composite.PackageAndLatestVersionComposite;
import org.rhq.core.domain.criteria.PackageCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.criteria.SubjectCriteria;
+import org.rhq.core.domain.util.OSGiVersion;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
@@ -570,6 +576,40 @@ public class CliNotificationSenderForm extends AbstractNotificationSenderForm {
};
uploadForm.addFormHandler(uploadSuccessHandler);
+ uploadForm.addItemChangeHandler(new ItemChangeHandler() {
+ public void onItemChange(ItemChangeEvent event) {
+ if (event.getItem() instanceof UploadItem) {
+ String fileName = event.getNewValue().toString();
+
+ if (config.allPackages != null) {
+ for(PackageAndLatestVersionComposite plv : config.allPackages) {
+ if (plv.getGeneralPackage().getName().equals(fileName)) {
+ try {
+ OSGiVersion v = new OSGiVersion(plv.getLatestPackageVersion().getVersion());
+ if (v.getMicroIfDefined() != null) {
+ v.setMicro(v.getMicro() + 1);
+ } else if (v.getMinorIfDefined() != null) {
+ v.setMinor(v.getMinor() + 1);
+ } else {
+ v.setMajor(v.getMajor() + 1);
+ }
+
+ uploadForm.getField("editableVersion").setValue(v.toString());
+ return;
+ } catch (IllegalArgumentException e) {
+ //ok, can't suggest anything
+ return;
+ }
+ }
+ }
+
+ //no existing package exists with the same name as the file being uploaded
+ uploadForm.getField("editableVersion").setValue("1.0");
+ }
+ }
+ }
+ });
+
return uploadForm;
}
commit efe26a4bc40b213c69507be5ad6679ab77c9893d
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 25 13:35:55 2011 +0100
small changes in the script engine factory, more useful configuration preview and error messages in the CliSender.
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java
index 7472953..345017f 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/ScriptEngineFactory.java
@@ -80,15 +80,24 @@ public class ScriptEngineFactory {
ScriptEngine engine = initializer.instantiate(packageFinder.findPackages("org.rhq.core.domain"));
- injectStandardBindings(engine, bindings);
+ injectStandardBindings(engine, bindings, true);
return engine;
}
- public static void injectStandardBindings(ScriptEngine engine, StandardBindings bindings) {
+ /**
+ * Injects the values provided in the bindings into the {@link ScriptContext#ENGINE_SCOPE engine scope}
+ * of the provided script engine.
+ *
+ * @param engine the engine
+ * @param bindings the bindings
+ * @param deleteExistingBindings true if the existing bindings should be replaced by the provided ones, false
+ * if the provided bindings should be added to the existing ones (possibly overwriting bindings with the same name).
+ */
+ public static void injectStandardBindings(ScriptEngine engine, StandardBindings bindings, boolean deleteExistingBindings) {
bindings.preInject(engine);
- Bindings engineBindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
+ Bindings engineBindings = deleteExistingBindings ? engine.createBindings() : engine.getBindings(ScriptContext.ENGINE_SCOPE);
for(Map.Entry<String, Object> entry : bindings.entrySet()) {
engineBindings.put(entry.getKey(), entry.getValue());
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/JsEngineInitializer.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/JsEngineInitializer.java
index eba36f3..3aa4616 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/JsEngineInitializer.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/engine/JsEngineInitializer.java
@@ -20,7 +20,6 @@
package org.rhq.bindings.engine;
import java.lang.reflect.Method;
-import java.util.List;
import java.util.Set;
import javax.script.ScriptEngine;
@@ -34,13 +33,14 @@ import javax.script.ScriptException;
*/
public class JsEngineInitializer implements ScriptEngineInitializer {
+ private ScriptEngineManager engineManager = new ScriptEngineManager();
+
public boolean implementsLanguage(String language) {
return language != null && ("JavaScript".equals(language) || "ECMAScript".equals(language));
}
public ScriptEngine instantiate(Set<String> packages) throws ScriptException {
- ScriptEngineManager sem = new ScriptEngineManager();
- ScriptEngine eng = sem.getEngineByName("JavaScript");
+ ScriptEngine eng = engineManager.getEngineByName("JavaScript");
for(String pkg : packages) {
eng.eval("importPackage(" + pkg + ")");
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
index dfc2b4c..8da9d9f 100644
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java
@@ -181,7 +181,7 @@ public class ScriptCommand implements ClientCommand {
bindings.put("configurationEditor", new ConfigurationEditor(client));
bindings.put("rhq", new Controller(client));
- ScriptEngineFactory.injectStandardBindings(jsEngine, bindings);
+ ScriptEngineFactory.injectStandardBindings(jsEngine, bindings, true);
ScriptEngineFactory.bindIndirectionMethods(jsEngine, "configurationEditor", bindings.get("configurationEditor"));
ScriptEngineFactory.bindIndirectionMethods(jsEngine, "rhq", bindings.get("rhq"));
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 a9ee867..3916c8a 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
@@ -25,19 +25,14 @@ 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.charset.Charset;
import java.util.ArrayDeque;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.atomic.AtomicInteger;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
@@ -54,7 +49,6 @@ import org.rhq.core.domain.alert.Alert;
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.PackageType;
import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.criteria.RepoCriteria;
@@ -64,7 +58,6 @@ import org.rhq.enterprise.server.auth.SessionManager;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
import org.rhq.enterprise.server.content.RepoManagerLocal;
-import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSender;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderValidationResults;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -256,6 +249,10 @@ public class CliSender extends AlertSender<CliComponent> {
RepoManagerLocal rm = LookupUtil.getRepoManagerLocal();
final PackageVersion versionToUse = rm.getLatestPackageVersion(LookupUtil.getSubjectManager().getOverlord(), packageId, repoId, null);
+ if (versionToUse == null) {
+ throw new IllegalArgumentException("The package with id " + packageId + " either doesn't exist at all or doesn't have any version. Can't execute a CLI script without a script to run.");
+ }
+
PipedInputStream ret = new PipedInputStream();
final PipedOutputStream out = new PipedOutputStream(ret);
@@ -308,11 +305,16 @@ public class CliSender extends AlertSender<CliComponent> {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
RepoManagerLocal rm = LookupUtil.getRepoManagerLocal();
PackageVersion versionToUse = rm.getLatestPackageVersion(overlord, config.packageId, config.repoId);
-
- ret = ret.replace("$packageName", versionToUse.getDisplayName());
- ret = ret.replace("$packageVersion", versionToUse.getDisplayVersion() == null ? versionToUse.getVersion()
- : versionToUse.getDisplayVersion());
-
+
+ if (versionToUse != null) {
+ ret = ret.replace("$packageName", versionToUse.getDisplayName());
+ ret = ret.replace("$packageVersion", versionToUse.getDisplayVersion() == null ? versionToUse.getVersion()
+ : versionToUse.getDisplayVersion());
+ } else {
+ ret = ret.replace("$packageName", "unknown script with package id " + config.packageId);
+ ret = ret.replace("$packageVersion", "no version");
+ }
+
RepoCriteria criteria = new RepoCriteria();
criteria.addFilterId(config.repoId);
@@ -382,7 +384,7 @@ public class CliSender extends AlertSender<CliComponent> {
engine = ScriptEngineFactory.getScriptEngine("JavaScript",
new PackageFinder(Collections.<File> emptyList()), bindings);
} else {
- ScriptEngineFactory.injectStandardBindings(engine, bindings);
+ ScriptEngineFactory.injectStandardBindings(engine, bindings, true);
}
++ENGINES_IN_USE;
commit 9a16c738c5429d182ec5732013911574e8f3eeea
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 25 13:34:31 2011 +0100
remove unused import
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/SandboxedScriptEngine.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/SandboxedScriptEngine.java
index faf3e15..ed3de18 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/SandboxedScriptEngine.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/SandboxedScriptEngine.java
@@ -26,7 +26,6 @@ import java.security.CodeSource;
import java.security.Permission;
import java.security.PermissionCollection;
import java.security.Permissions;
-import java.security.Principal;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.security.ProtectionDomain;
commit 45ceab2c82a6d2718295abeab0413f9ac8bc6064
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 25 13:34:11 2011 +0100
Make the CLI alert plugin controls for managing invalid alert definitions actually work and return more useful data.
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 e38a452..e8b6895 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
@@ -69,8 +69,10 @@ public class AlertDefinitionCriteria extends Criteria {
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 ( ? )");
+ filterOverrides.put("resourceGroupIds", "resourceGroup.id IN ( ? )");
+ filterOverrides.put("notificationSenderNames", "id IN (" +
+ "SELECT notif.alertDefinition.id FROM AlertNotification notif " +
+ "WHERE notif.senderName IN ( ? ))");
filterOverrides.put("filterIds", "id IN ( ? )");
}
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
index 93c5fee..2835ab9 100644
--- 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
@@ -22,8 +22,10 @@ package org.rhq.enterprise.server.plugins.alertCli;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
@@ -35,15 +37,20 @@ import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.content.PackageCategory;
import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+import org.rhq.core.domain.criteria.Criteria.Restriction;
+import org.rhq.core.domain.criteria.PackageVersionCriteria;
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.domain.util.PageList;
import org.rhq.core.util.IntExtractor;
import org.rhq.enterprise.server.alert.AlertDefinitionManagerLocal;
import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.content.ContentManagerLocal;
+import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.plugin.pc.ControlFacet;
import org.rhq.enterprise.server.plugin.pc.ControlResults;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
@@ -51,6 +58,7 @@ 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;
+import org.rhq.enterprise.server.xmlschema.generated.serverplugin.alert.AlertPluginDescriptorType;
/**
* The plugin component for controlling the CLI alerts.
@@ -73,7 +81,8 @@ public class CliComponent implements ServerPluginComponent, ControlFacet {
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_MISSING_USERS = "missingUsers";
+ private static final String PROP_MISSING_SCRIPTS = "missingScripts";
private static final String PROP_ALERT_DEFINITION = "alertDefinition";
private static final String PROP_ALERT_DEFINITION_ID = "alertDefinitionId";
private static final String PROP_USER_NAME = "userName";
@@ -87,7 +96,7 @@ public class CliComponent implements ServerPluginComponent, ControlFacet {
private SubjectManagerLocal subjectManager;
public void initialize(ServerPluginContext context) throws Exception {
- pluginName = context.getPluginEnvironment().getPluginDescriptor().getName();
+ pluginName = ((AlertPluginDescriptorType)context.getPluginEnvironment().getPluginDescriptor()).getShortName();
subjectManager = LookupUtil.getSubjectManager();
ContentManagerLocal cm = LookupUtil.getContentManager();
@@ -147,34 +156,33 @@ public class CliComponent implements ServerPluginComponent, ControlFacet {
}
private void checkAlertsValidity(ControlResults results, Configuration parameters) {
- List<AlertNotification> invalidNotifs = getAllCliNotificationsWithInvalidUser();
+ List<AlertNotification> allCliNotifications = getAllCliNotifications(null);
+
+ Configuration resConfig = results.getComplexResults();
- for(AlertNotification cliNotification : invalidNotifs) {
- AlertDefinition def = cliNotification.getAlertDefinition();
-
- 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_ID, def.getId()));
- alertDefinitionMap.put(new PropertySimple(PROP_ALERT_DEFINITION_NAME, def.getName()));
- alertDefinitionMap.put(new PropertySimple(PROP_RESOURCE_ID, def.getResource().getId()));
-
- misconfigured.add(alertDefinitionMap);
- }
+ PropertyList missingUsersList = new PropertyList(PROP_MISSING_USERS);
+ resConfig.put(missingUsersList);
+
+ List<AlertNotification> invalidNotifs = getCliNotificationsWithInvalidUser(allCliNotifications);
+ convertNotificationsToInvalidAlertDefResults(missingUsersList, invalidNotifs);
+
+ PropertyList missingScriptsList = new PropertyList(PROP_MISSING_SCRIPTS);
+ resConfig.put(missingScriptsList);
+
+ invalidNotifs = getCliNotificationsWithInvalidPackage(allCliNotifications);
+ convertNotificationsToInvalidAlertDefResults(missingScriptsList, invalidNotifs);
//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(),
+
+ List<Property> allMissing = new ArrayList<Property>();
+ allMissing.addAll(missingUsersList.getList());
+ allMissing.addAll(missingScriptsList.getList());
+
+ if (allMissing.size() > 0) {
+ ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
+
+ List<DisambiguationReport<Property>> disambiguated = resourceManager.disambiguate(allMissing,
new IntExtractor<Property>() {
public int extract(Property object) {
PropertyMap map = (PropertyMap) object;
@@ -200,7 +208,7 @@ public class CliComponent implements ServerPluginComponent, ControlFacet {
PropertySimple userNameProp = parameters.getSimple(PROP_USER_NAME);
PropertySimple alertDefIdsProp = parameters.getSimple(PROP_ALERT_DEF_IDS);
- if (userNameProp == null) {
+ if (userNameProp == null || userNameProp.getStringValue() == null || userNameProp.getStringValue().trim().length() == 0) {
throw new IllegalArgumentException("User name not specified.");
}
@@ -214,16 +222,15 @@ public class CliComponent implements ServerPluginComponent, ControlFacet {
//now get the list of the alert notifications to update
List<AlertNotification> notifsToReAssign = null;
- if (alertDefIdsProp == null || alertDefIdsProp.getStringValue().trim().length() == 0) {
- notifsToReAssign = getAllCliNotificationsWithInvalidUser();
+ if (alertDefIdsProp == null || alertDefIdsProp.getStringValue() == null || alertDefIdsProp.getStringValue().trim().length() == 0) {
+ notifsToReAssign = getCliNotificationsWithInvalidUser(getAllCliNotifications(null));
} else {
List<Integer> alertDefIds = asIdList(alertDefIdsProp.getStringValue().split("\\s*,\\s*"));
List<AlertDefinition> defs = getAlertDefinitionsWithCliNotifications(alertDefIds);
notifsToReAssign = new ArrayList<AlertNotification>();
for(AlertDefinition def : defs) {
- AlertNotification cliNotif = getCliNotification(def.getAlertNotifications());
- if (cliNotif != null) {
+ for(AlertNotification cliNotif : getCliNotifications(def.getAlertNotifications())) {
notifsToReAssign.add(cliNotif);
}
}
@@ -236,17 +243,18 @@ public class CliComponent implements ServerPluginComponent, ControlFacet {
notificationManager.massReconfigure(notifIds, updates);
}
- private AlertNotification getCliNotification(List<AlertNotification> notifications) {
+ private List<AlertNotification> getCliNotifications(List<AlertNotification> notifications) {
+ ArrayList<AlertNotification> ret = new ArrayList<AlertNotification>();
for(AlertNotification n : notifications) {
if (pluginName.equals(n.getSenderName())) {
- return n;
+ ret.add(n);
}
}
- return null;
+ return ret;
}
- private List<AlertDefinition> getAlertDefinitionsWithCliNotifications(Collection<Integer> ids) {
+ private List<AlertDefinition> getAlertDefinitionsWithCliNotifications(Collection<Integer> alertDefIds) {
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
AlertDefinitionManagerLocal manager = LookupUtil.getAlertDefinitionManager();
@@ -256,29 +264,33 @@ public class CliComponent implements ServerPluginComponent, ControlFacet {
criteria.addFilterNotificationNames(pluginName);
criteria.setPageControl(PageControl.getUnlimitedInstance());
criteria.fetchAlertNotifications(true);
- if (ids != null) {
- criteria.addFilterIds(ids.toArray(new Integer[ids.size()]));
+ if (alertDefIds != null) {
+ criteria.addFilterIds(alertDefIds.toArray(new Integer[alertDefIds.size()]));
}
return manager.findAlertDefinitionsByCriteria(overlord, criteria);
}
- private List<AlertNotification> getAllCliNotificationsWithInvalidUser() {
+ private List<AlertNotification> getAllCliNotifications(Collection<Integer> alertDefIds) {
List<AlertNotification> ret = new ArrayList<AlertNotification>();
- SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
-
- List<AlertDefinition> defs = getAlertDefinitionsWithCliNotifications(null);
+ List<AlertDefinition> defs = getAlertDefinitionsWithCliNotifications(alertDefIds);
for(AlertDefinition def : defs) {
List<AlertNotification> notifications = def.getAlertNotifications();
- AlertNotification cliNotification = getCliNotification(notifications);
-
- if (cliNotification == null) {
- //we always should find this but a little bit of paranoia never hurt anyone
- continue;
- }
+ ret.addAll(getCliNotifications(notifications));
+ }
+
+ return ret;
+ }
+
+ private List<AlertNotification> getCliNotificationsWithInvalidUser(List<AlertNotification> allNotifications) {
+ List<AlertNotification> ret = new ArrayList<AlertNotification>();
+
+ SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
+
+ for(AlertNotification cliNotification : allNotifications) {
Subject checkSubject = null;
@@ -297,6 +309,59 @@ public class CliComponent implements ServerPluginComponent, ControlFacet {
return ret;
}
+ private List<AlertNotification> getCliNotificationsWithInvalidPackage(List<AlertNotification> allNotifications) {
+ List<AlertNotification> ret = new ArrayList<AlertNotification>();
+
+ ContentManagerLocal contentManager = LookupUtil.getContentManager();
+ SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
+
+ Subject overlord = subjectManager.getOverlord();
+
+ PackageVersionCriteria crit = new PackageVersionCriteria();
+ crit.setRestriction(Restriction.COUNT_ONLY);
+
+ for(AlertNotification cliNotification : allNotifications) {
+
+ int count = 0;
+
+ String packageId = cliNotification.getConfiguration().getSimpleValue(CliSender.PROP_PACKAGE_ID, null);
+ if (packageId != null) {
+ crit.addFilterPackageId(Integer.valueOf(packageId));
+
+ PageList<PackageVersion> res = contentManager.findPackageVersionsByCriteria(overlord, crit);
+ count = res.getTotalSize();
+ }
+
+ if (count == 0) {
+ ret.add(cliNotification);
+ }
+ }
+
+ return ret;
+ }
+
+ private void convertNotificationsToInvalidAlertDefResults(PropertyList results, List<AlertNotification> invalidNotifications) {
+ Set<AlertDefinition> processedDefs = new HashSet<AlertDefinition>();
+
+ for(AlertNotification cliNotification : invalidNotifications) {
+ AlertDefinition def = cliNotification.getAlertDefinition();
+
+ if (!processedDefs.add(def)) {
+ //skip this definition - it has more than one incorrect notifs and we already
+ //included it in the output.
+ continue;
+ }
+
+ PropertyMap alertDefinitionMap = new PropertyMap(PROP_ALERT_DEFINITION);
+
+ alertDefinitionMap.put(new PropertySimple(PROP_ALERT_DEFINITION_ID, def.getId()));
+ alertDefinitionMap.put(new PropertySimple(PROP_ALERT_DEFINITION_NAME, def.getName()));
+ alertDefinitionMap.put(new PropertySimple(PROP_RESOURCE_ID, def.getResource().getId()));
+
+ results.add(alertDefinitionMap);
+ }
+ }
+
private List<Integer> asIdList(String... ids) {
List<Integer> ret = new ArrayList<Integer>();
for(String id : ids) {
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 4f60e6f..c4dcdea 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
@@ -15,14 +15,18 @@
</serverplugin:help>
<serverplugin:plugin-component class="CliComponent">
- <serverplugin:control name="checkAlertsValidity">
+ <serverplugin:control name="checkAlertsValidity" 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. Also the script can be deleted from a repo, or the repo itself can be deleted, at which point there is not script to run. This operation returns a list of such misconfigured alert definitions.">
<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:list-property name="missingUsers" displayName="Alerts with notifications referencing non-existent user.">
+ <c:map-property name="alertDefinition">
+ <c:simple-property name="alertDefinitionId" />
+ <c:simple-property name="alertDefinitionName" />
+ <c:simple-property name="resourceId" />
+ <c:simple-property name="resourcePath" />
+ </c:map-property>
+ </c:list-property>
+
+ <c:list-property name="missingScripts" displayName="Alerts with notifications referencing non-existent scripts.">
<c:map-property name="alertDefinition">
<c:simple-property name="alertDefinitionId" />
<c:simple-property name="alertDefinitionName" />
commit 86c740a3822f79167facb90b64d85d5667cb52db
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 25 13:32:34 2011 +0100
Deleting a user will cause all the repos s/he owned to have no owner and thus become readonly to anyone except repository managers. Deleting a user will therefore not cause disappearance of any packages s/he previously created and that might be used throughout the inventory as backing content for resources or as CLI scripts.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
index c1014e2..ecf97ce 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
@@ -126,7 +126,9 @@ import org.rhq.core.domain.resource.Resource;
@NamedQuery(name = Repo.QUERY_CHECK_REPO_OWNED_BY_SUBJECT_ID, query = "SELECT COUNT(r) FROM Repo r" //
+ " WHERE r.id = :repoId"
- + " AND r.owner.id = :subjectId")
+ + " AND r.owner.id = :subjectId"),
+ @NamedQuery(name = Repo.QUERY_UPDATE_REMOVE_OWNER_FROM_REPOS_OWNED_BY_SUBJECT, query = "" +
+ "UPDATE Repo r SET r.owner = null WHERE r.owner.id = :ownerId")
})
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_REPO_ID_SEQ")
@Table(name = "RHQ_REPO")
@@ -152,6 +154,7 @@ public class Repo implements Serializable {
public static final String QUERY_FIND_CANDIDATES_WITH_ONLY_CONTENT_SOURCE = "Repo.findCandidatesWithOnlyContentSource";
public static final String QUERY_CHECK_REPO_VISIBLE_BY_SUBJECT_ID = "Repo.findVisibleReposBySubjectId";
public static final String QUERY_CHECK_REPO_OWNED_BY_SUBJECT_ID = "Repo.isRepoOwnedBySubjectId";
+ public static final String QUERY_UPDATE_REMOVE_OWNER_FROM_REPOS_OWNED_BY_SUBJECT = "Repo.removeOwnerFromReposOwnerBySubject";
private static final long serialVersionUID = 1L;
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 b3a25c9..3c5cc9e 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
@@ -61,6 +61,7 @@ import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.authz.RoleManagerLocal;
+import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.core.CustomJaasDeploymentServiceMBean;
import org.rhq.enterprise.server.exception.LoginException;
import org.rhq.enterprise.server.resource.group.LdapGroupManagerLocal;
@@ -103,6 +104,10 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
@IgnoreDependency
private RoleManagerLocal roleManager;
+ @EJB
+ @IgnoreDependency
+ private RepoManagerLocal repoManager;
+
private SessionManager sessionManager = SessionManager.getInstance();
/**
@@ -754,6 +759,8 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
}
alertNotificationManager.cleanseAlertNotificationBySubject(doomedSubject.getId());
+ repoManager.removeOwnershipOfSubject(doomedSubject.getId());
+
entityManager.remove(doomedSubject);
return;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
index 9dbf92b..6eadde8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
@@ -694,6 +694,13 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
}
}
+ public void removeOwnershipOfSubject(int subjectId) {
+ Query q = entityManager.createNamedQuery(Repo.QUERY_UPDATE_REMOVE_OWNER_FROM_REPOS_OWNED_BY_SUBJECT);
+ q.setParameter("ownerId", subjectId);
+
+ q.executeUpdate();
+ }
+
@RequiredPermission(Permission.MANAGE_REPOSITORIES)
public RepoGroup createRepoGroup(Subject subject, RepoGroup repoGroup) throws RepoException {
validateRepoGroup(repoGroup);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java
index 99ab618..bc22d81 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java
@@ -210,6 +210,17 @@ public interface RepoManagerLocal {
*/
void importCandidateRepo(Subject subject, List<Integer> repoIds) throws RepoException;
+ /**
+ * When a user gets deleted, all of his/her repos remain intact but become
+ * unassigned to any user. This way no links to packages are broken upon user deletion
+ * and repository manager can then decide what to do with the leftover repos.
+ * <p>
+ * This method therefore sets the owner of all repos owned by provided subject to null.
+ *
+ * @param subjectId
+ */
+ void removeOwnershipOfSubject(int subjectId);
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// The following are shared with the Remote Interface
commit 49d947b89a34847fa71b16124600ff0ddd511a64
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Feb 22 23:46:40 2011 +0100
fail the validation if another user is entered with incorrect credentials.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java
index 61b3f3d..69a2a65 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java
@@ -593,7 +593,11 @@ public class CliNotificationSenderForm extends AbstractNotificationSenderForm {
config.selectedSubject = result;
verifyUserButton.setIcons(result == null ? authFailureIcon : authSuccessIcon);
markForRedraw();
- action.onSuccess(null);
+ if (result == null) {
+ action.onFailure(null);
+ } else {
+ action.onSuccess(null);
+ }
}
});
}
13 years, 2 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
New commits:
commit 20155e8d267c81294f4c68ab35d70c19313d9766
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Feb 25 11:25:31 2011 -0500
add back refresh protection for message bar clearing
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index 4a55504..fbcd0de 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -357,12 +357,14 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
public void renderView(final ViewPath viewPath) {
Window.setTitle(getViewPathTitle(viewPath));
- // when navigating, clear any message, the user is probably no longer interested
- coreGUI.footer.getMessageBar().clearMessage(true);
-
// keep our CoreGUI session alive by refreshing the session timer each time the user performs navigation
UserSessionManager.refresh();
+ // clear any message when navigating to a new view (not refreshing), the user is probably no longer interested
+ if (!viewPath.isRefresh()) {
+ coreGUI.footer.getMessageBar().clearMessage(true);
+ }
+
if (viewPath.isEnd()) {
// default view
History.newItem(DEFAULT_VIEW_PATH);
13 years, 2 months