modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AlertDefinitionHandlerBean.java
| 16 +++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
New commits:
commit 0bf59fd0bcd98ad6c659e0755e2862abb3434db8
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Nov 29 12:10:22 2013 +0100
[BZ 1035816] Fix handling of "disable after fire" definitions.
(cherry picked from commit b9e35b5 & eab7656)
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AlertDefinitionHandlerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AlertDefinitionHandlerBean.java
index f608251..3b43bee 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AlertDefinitionHandlerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AlertDefinitionHandlerBean.java
@@ -402,7 +402,7 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
private void setDampeningFromRest(AlertDefinition alertDefinition,
AlertDefinitionRest adr) {
AlertDampening.Category dampeningCategory;
try {
- dampeningCategory =
AlertDampening.Category.valueOf(adr.getDampeningCategory());
+ dampeningCategory =
AlertDampening.Category.valueOf(adr.getDampeningCategory().toUpperCase());
}
catch (Exception e) {
AlertDampening.Category[] vals = AlertDampening.Category.values();
@@ -415,6 +415,16 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
}
throw new BadArgumentException("dampening category","Allowed
values are: " + builder.toString());
}
+ if (dampeningCategory == AlertDampening.Category.ONCE) {
+ // WillRecover = true means to disable after firing
+ // See
org.rhq.enterprise.server.alert.AlertManagerBean.willDefinitionBeDisabled()
+ alertDefinition.setWillRecover(true);
+ dampeningCategory = AlertDampening.Category.NONE;
+ }
+ if (dampeningCategory == AlertDampening.Category.NO_DUPLICATES) {
+ dampeningCategory = AlertDampening.Category.NONE;
+ }
+
AlertDampening dampening = new AlertDampening(dampeningCategory);
if (adr.getDampeningCount()>-1) {
dampening.setValue(adr.getDampeningCount());
@@ -1137,6 +1147,10 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
AlertDampening dampening = def.getAlertDampening();
adr.setDampeningCategory(dampening.getCategory().name());
+ if (dampening.getCategory()== AlertDampening.Category.NONE &&
def.getWillRecover()) {
+ adr.setDampeningCategory(AlertDampening.Category.ONCE.name());
+ }
+
AlertDampening.TimeUnits units = dampening.getValueUnits();
String s = units != null ? " " + units.name() : "";
adr.setDampeningCount(dampening.getValue());