modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertConditionMessages.java | 60 --------
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertMessages.java | 70 ++++++++++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/description/ControlDescriber.java | 7 -
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/alertDefinitionProperties.xhtml | 10 +
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listConditions.xhtml | 38 ++---
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml | 3
6 files changed, 104 insertions(+), 84 deletions(-)
New commits:
commit c8338b898b50fbfe86e07d4c25cba30deb9c3139
Merge: a99099e... 4714eb8...
Author: Justin Harris <jharris(a)redhat.com>
Date: Wed Feb 24 12:24:53 2010 -0500
Merge remote branch 'origin/alertPlugin' into bugz
commit a99099ea48d165b4a272949d2fce9e2815a3b061
Author: Justin Harris <jharris(a)redhat.com>
Date: Wed Feb 24 12:21:04 2010 -0500
Fix for BZ 561900
Adding in length and null value validation for alert definition names.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertConditionMessages.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertConditionMessages.java
deleted file mode 100644
index 62a6fc0..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertConditionMessages.java
+++ /dev/null
@@ -1,60 +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.alert;
-
-import java.text.MessageFormat;
-import java.util.Map;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-(a)Scope(ScopeType.APPLICATION)
-@Name("alertConditionMessages")
-public class AlertConditionMessages {
-
- @In
- private Map<String, String> messages;
-
- public String getThreshold() {
- return translate("errors.double", "Threshold");
- }
-
- public String getPercentRange() {
- return translate("errors.range", "Threshold", "0%", "1000%");
- }
-
- public String getDampeningCount() {
- return translate("errors.integer", "Dampening Count");
- }
-
- public String getDampeningEvaluation() {
- return translate("errors.integer", "Dampening Evaluations");
- }
-
- public String getTimePeriod() {
- return translate("errors.integer", "Time Period");
- }
-
- private String translate(String key, Object... params) {
- String message = messages.get(key);
-
- return MessageFormat.format(message, params);
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertMessages.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertMessages.java
new file mode 100644
index 0000000..79062ef
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertMessages.java
@@ -0,0 +1,70 @@
+/*
+ * 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.alert;
+
+import java.text.MessageFormat;
+import java.util.Map;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
+(a)Scope(ScopeType.APPLICATION)
+@Name("alertMessages")
+public class AlertMessages {
+
+ @In
+ private Map<String, String> messages;
+
+ public String getNameRequired() {
+ String name = translate("alerts.config.DefinitionList.ListHeader.AlertName");
+ return translate("errors.required", name);
+ }
+
+ public String getNameLength() {
+ String name = translate("alerts.config.DefinitionList.ListHeader.AlertName");
+ return translate("errors.maxlength", name);
+ }
+
+ public String getThreshold() {
+ return translate("errors.double", "Threshold");
+ }
+
+ public String getPercentRange() {
+ return translate("errors.range", "Threshold", "0%", "1000%");
+ }
+
+ public String getDampeningCount() {
+ return translate("errors.integer", "Dampening Count");
+ }
+
+ public String getDampeningEvaluation() {
+ return translate("errors.integer", "Dampening Evaluations");
+ }
+
+ public String getTimePeriod() {
+ return translate("errors.integer", "Time Period");
+ }
+
+ private String translate(String key, Object... params) {
+ String message = messages.get(key);
+
+ return MessageFormat.format(message, params);
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/alertDefinitionProperties.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/alertDefinitionProperties.xhtml
index 9439c5f..fd8e260 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/alertDefinitionProperties.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/alertDefinitionProperties.xhtml
@@ -17,7 +17,15 @@
<h:panelGrid columns="2" border="1" cellpadding="5" style="margin: 15px;">
<h:outputLabel for="alertNameInput" value="Name: " />
- <h:inputText id="alertNameInput" value="#{alertDefinition.name}" style="width: 300px;" />
+ <h:inputText id="alertNameInput"
+ value="#{alertDefinition.name}"
+ style="width: 300px;"
+ maxlength="100"
+ required="true"
+ requiredMessage="#{alertMessages.nameRequired}"
+ validatorMessage="#{alertMessages.nameLength}">
+ <f:validateLength maximum="100" />
+ </h:inputText>
<h:outputLabel for="alertDescriptionInput" value="Description: " />
<h:inputTextarea id="alertDescriptionInput" value="#{alertDefinition.description}" style="width: 300px;" />
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listConditions.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listConditions.xhtml
index a5500e4..2000efd 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listConditions.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listConditions.xhtml
@@ -170,9 +170,9 @@
value="#{alertDefinition.alertDampening.value}"
size="4"
required="true"
- requiredMessage="#{alertConditionMessages.dampeningCount}"
- validatorMessage="#{alertConditionMessages.dampeningCount}"
- converterMessage="#{alertConditionMessages.dampeningCount}">
+ requiredMessage="#{alertMessages.dampeningCount}"
+ validatorMessage="#{alertMessages.dampeningCount}"
+ converterMessage="#{alertMessages.dampeningCount}">
<f:validateDoubleRange minimum="0" />
</h:inputText>
<h:outputText value=" #{messages['alert.config.props.CB.Content.DampenConsecutiveCount.2']}" />
@@ -184,9 +184,9 @@
value="#{alertDefinition.alertDampening.value}"
size="4"
required="true"
- requiredMessage="#{alertConditionMessages.dampeningCount}"
- validatorMessage="#{alertConditionMessages.dampeningCount}"
- converterMessage="#{alertConditionMessages.dampeningCount}">
+ requiredMessage="#{alertMessages.dampeningCount}"
+ validatorMessage="#{alertMessages.dampeningCount}"
+ converterMessage="#{alertMessages.dampeningCount}">
<f:validateLongRange minimum="0" />
</h:inputText>
<h:outputText value=" #{messages['alert.config.props.CB.Content.DampenPartialCount.2']} " />
@@ -194,9 +194,9 @@
value="#{alertDefinition.alertDampening.period}"
size="4"
required="true"
- requiredMessage="#{alertConditionMessages.dampeningEvaluation}"
- validatorMessage="#{alertConditionMessages.dampeningEvaluation}"
- converterMessage="#{alertConditionMessages.dampeningEvaluation}">
+ requiredMessage="#{alertMessages.dampeningEvaluation}"
+ validatorMessage="#{alertMessages.dampeningEvaluation}"
+ converterMessage="#{alertMessages.dampeningEvaluation}">
<f:validateLongRange minimum="0" />
</h:inputText>
<h:outputText value=" #{messages['alert.config.props.CB.Content.DampenPartialCount.3']}" />
@@ -208,9 +208,9 @@
value="#{alertDefinition.alertDampening.value}"
size="4"
required="true"
- requiredMessage="#{alertConditionMessages.dampeningCount}"
- validatorMessage="#{alertConditionMessages.dampeningCount}"
- converterMessage="#{alertConditionMessages.dampeningCount}">
+ requiredMessage="#{alertMessages.dampeningCount}"
+ validatorMessage="#{alertMessages.dampeningCount}"
+ converterMessage="#{alertMessages.dampeningCount}">
<f:validateLongRange minimum="0" />
</h:inputText>
<h:outputText value=" #{messages['alert.config.props.CB.Content.DampenDurationCount.2']} " />
@@ -218,9 +218,9 @@
value="#{alertDefinition.alertDampening.period}"
size="4"
required="true"
- requiredMessage="#{alertConditionMessages.timePeriod}"
- validatorMessage="#{alertConditionMessages.timePeriod}"
- converterMessage="#{alertConditionMessages.timePeriod}">
+ requiredMessage="#{alertMessages.timePeriod}"
+ validatorMessage="#{alertMessages.timePeriod}"
+ converterMessage="#{alertMessages.timePeriod}">
<f:validateLongRange minimum="0" />
</h:inputText>
<h:selectOneMenu value="#{alertDefinition.alertDampening.periodUnits}">
@@ -341,8 +341,8 @@
<h:inputText id="metricThresholdAbsolute"
value="#{alertConditionsUIBean.threshold}"
required="true"
- requiredMessage="#{alertConditionMessages.threshold}"
- validatorMessage="#{alertConditionMessages.threshold}">
+ requiredMessage="#{alertMessages.threshold}"
+ validatorMessage="#{alertMessages.threshold}">
<f:validateDoubleRange minimum="0.0" />
</h:inputText>
<h:outputLabel for="metricThresholdAbsolute" value="#{messages['alert.config.props.CB.Content.AbsoluteValue']}" />
@@ -371,8 +371,8 @@
value="#{alertConditionsUIBean.currentCondition.threshold}"
converter="#{metricPercentConverter}"
required="true"
- requiredMessage="#{alertConditionMessages.percentRange}"
- validatorMessage="#{alertConditionMessages.percentRange}">
+ requiredMessage="#{alertMessages.percentRange}"
+ validatorMessage="#{alertMessages.percentRange}">
<f:validateDoubleRange minimum="0.0" maximum="1000.0" />
</h:inputText>
<h:outputLabel for="metricBaselinePercent" value=" #{messages['alert.config.props.CB.Content.Percent']} " />
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml
index a987e65..dd349a1 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml
@@ -77,8 +77,7 @@
</ui:define>
<ui:define name="body">
- <h:messages showDetail="true"
- globalOnly="true"
+ <h:messages showSummary="true"
infoClass="InfoBlock"
warnClass="WarnBlock"
errorClass="ErrorBlock"
commit 38fb361e5cdb167bb5a947596586194d941e4221
Author: Justin Harris <jharris(a)redhat.com>
Date: Wed Feb 24 10:55:35 2010 -0500
Fix for BZ 567375
Changed method of resource id lookup in control describer.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/description/ControlDescriber.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/description/ControlDescriber.java
index bcf5d25..ab1bd8a 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/description/ControlDescriber.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/description/ControlDescriber.java
@@ -18,9 +18,11 @@
*/
package org.rhq.enterprise.gui.alert.description;
+import org.jboss.seam.Component;
import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertConditionCategory;
import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.operation.OperationManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -53,12 +55,13 @@ public class ControlDescriber extends AlertConditionDescriber {
private OperationDefinition getDefinition(AlertCondition condition) {
OperationManagerLocal operationManager = LookupUtil.getOperationManager();
- Integer resourceTypeId = condition.getAlertDefinition().getResource().getResourceType().getId();
+ // this is not a seam component, so look it up in the component contexts
+ ResourceType resourceType = (ResourceType)Component.getInstance("resourceType");
String operationName = condition.getName();
try {
return operationManager.getOperationDefinitionByResourceTypeAndName(
- resourceTypeId, operationName, false);
+ resourceType.getId(), operationName, false);
} catch (Exception e) {
return null;
}