modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
| 30 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/subsystem/SubsystemAlertDefinitionUIBean.java
| 88 +++
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listConditions.xhtml
| 3
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml
| 4
modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertDefinitions.xhtml
| 12
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
| 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
| 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
| 9
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/AlertTokenReplacer.java
| 231 ++++++++++
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
| 39 +
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsSender.java
| 10
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
| 90 +++
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java
| 83 +++
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenClass.java
| 20
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenReplacer.java
| 178 -------
modules/enterprise/server/plugins/alert-operations/src/main/token2confluence.xsl
| 28 +
modules/enterprise/server/plugins/alert-operations/src/test/java/org/rhq/enterprise/server/plugins/alertOperations/TokenReplacementTest.java
| 72 ++-
modules/enterprise/server/plugins/alert-operations/tokens.xml
| 137 +++++
18 files changed, 786 insertions(+), 261 deletions(-)
New commits:
commit d882f2088e1f27d64376550e1b984cf33fcd2923
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 2 15:04:05 2010 +0100
Prevent NPE
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index e5684d2..c3eda0e 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -2129,7 +2129,8 @@ public class ResourceManagerBean implements ResourceManagerLocal,
ResourceManage
resourceId = parent.getId();
}
parent = getParentResource(resourceId);
- int parentId = parent.getId();
+ if (parent==null)
+ break;
if
(parent.getResourceType().getCategory().equals(ResourceCategory.PLATFORM)){
resource = parent;
parent = null;
@@ -2177,7 +2178,7 @@ public class ResourceManagerBean implements ResourceManagerLocal,
ResourceManage
//we can't assume the ordering of the provided results and the disambiguation
query results
//will be the same.
-
+
//this list contains the resulting reports in the same order as the original
results
List<MutableDisambiguationReport<T>> reports = new
ArrayList<MutableDisambiguationReport<T>>(results.size());
@@ -2267,7 +2268,7 @@ public class ResourceManagerBean implements ResourceManagerLocal,
ResourceManage
String parentName = (String) parentsResult[2 * i + 2];
parents.add(new ResourceParentFlyweight(parentId, parentName));
}
-
+
//update all the reports that correspond to this resourceId
for(MutableDisambiguationReport<T> report :
reportsByResourceId.get(resourceId)) {
report.typeName = typeName;
@@ -2282,7 +2283,7 @@ public class ResourceManagerBean implements ResourceManagerLocal,
ResourceManage
for (MutableDisambiguationReport<T> report : reports) {
resolution.add(report.getReport());
}
-
+
return new ResourceNamesDisambiguationResult<T>(resolution,
typeResolutionNeeded, parentResolutionNeeded,
pluginResolutionNeeded);
}
commit 53f788862170e0bd8e837d4da6996d3fdff796da
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 2 11:40:09 2010 +0100
Move to a better place in the file hierarchy
diff --git
a/modules/enterprise/server/plugins/alert-operations/src/main/token2confluence.xsl
b/modules/enterprise/server/plugins/alert-operations/src/main/token2confluence.xsl
new file mode 100644
index 0000000..1d1a2d9
--- /dev/null
+++ b/modules/enterprise/server/plugins/alert-operations/src/main/token2confluence.xsl
@@ -0,0 +1,28 @@
+<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:output method="text" indent="no"
xml:space="default"/>
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="/">
+h2. Tokens for alert-operations sender
+
+Those tokens can be used in operation definition properties like
+'tokenclass.token' e.g. "alert.id" or "resource.name"
+ <xsl:apply-templates />
+ </xsl:template>
+
+ <xsl:template match="tokenClass">
+h3. *Token Class '<xsl:value-of select="@name"/>'*
<xsl:value-of select="@description"/>
+ <xsl:apply-templates >
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="token">
+* *<xsl:value-of select="@name"/>*: _<xsl:value-of
select="descr"/>_<xsl:text/>
+ </xsl:template>
+
+ <xsl:template match="fullName"/>
+ <xsl:template match="descr"/>
+
+</xsl:stylesheet>
\ No newline at end of file
diff --git a/modules/enterprise/server/plugins/alert-operations/token2confluence.xsl
b/modules/enterprise/server/plugins/alert-operations/token2confluence.xsl
deleted file mode 100644
index 1d1a2d9..0000000
--- a/modules/enterprise/server/plugins/alert-operations/token2confluence.xsl
+++ /dev/null
@@ -1,28 +0,0 @@
-<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
- <xsl:output method="text" indent="no"
xml:space="default"/>
- <xsl:strip-space elements="*"/>
-
- <xsl:template match="/">
-h2. Tokens for alert-operations sender
-
-Those tokens can be used in operation definition properties like
-'tokenclass.token' e.g. "alert.id" or "resource.name"
- <xsl:apply-templates />
- </xsl:template>
-
- <xsl:template match="tokenClass">
-h3. *Token Class '<xsl:value-of select="@name"/>'*
<xsl:value-of select="@description"/>
- <xsl:apply-templates >
- <xsl:sort select="@name"/>
- </xsl:apply-templates>
- </xsl:template>
-
- <xsl:template match="token">
-* *<xsl:value-of select="@name"/>*: _<xsl:value-of
select="descr"/>_<xsl:text/>
- </xsl:template>
-
- <xsl:template match="fullName"/>
- <xsl:template match="descr"/>
-
-</xsl:stylesheet>
\ No newline at end of file
commit 00727947b1936074c04a13d0d6c4d34ab1233e60
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 2 11:39:41 2010 +0100
Add an option to specify an output file.
diff --git
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
index 7b2d7ff..a51f2fb 100644
---
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
+++
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
@@ -18,6 +18,11 @@
*/
package org.rhq.enterprise.server.plugins.alertOperations;
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
import java.util.EnumSet;
import java.util.Set;
@@ -35,9 +40,20 @@ public class PrintTokens {
public static void main(String[] args) throws Exception {
+ OutputStream out;
+ if (args.length==0)
+ out = new BufferedOutputStream(System.out);
+ else {
+ File file = new File(args[0]);
+ System.err.println("writing to " + file.getAbsolutePath());
+ out = new BufferedOutputStream(new FileOutputStream(file));
+ }
+
String text = createTokenDescription();
- System.out.println(text);
+ out.write(text.getBytes());
+ out.flush();
+ out.close();
}
/**
commit ada3ff33262675a7fd00298f078608aae0559a2e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 2 10:03:24 2010 +0100
Optimization of the style sheet
diff --git a/modules/enterprise/server/plugins/alert-operations/token2confluence.xsl
b/modules/enterprise/server/plugins/alert-operations/token2confluence.xsl
index 8a2b14f..1d1a2d9 100644
--- a/modules/enterprise/server/plugins/alert-operations/token2confluence.xsl
+++ b/modules/enterprise/server/plugins/alert-operations/token2confluence.xsl
@@ -1,19 +1,25 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no"
xml:space="default"/>
+ <xsl:strip-space elements="*"/>
<xsl:template match="/">
h2. Tokens for alert-operations sender
+
+Those tokens can be used in operation definition properties like
+'tokenclass.token' e.g. "alert.id" or "resource.name"
<xsl:apply-templates />
</xsl:template>
<xsl:template match="tokenClass">
-h3. *<xsl:value-of select="@name"/>*: <xsl:value-of
select="@description"/>
- <xsl:apply-templates/>
+h3. *Token Class '<xsl:value-of select="@name"/>'*
<xsl:value-of select="@description"/>
+ <xsl:apply-templates >
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
</xsl:template>
<xsl:template match="token">
-* *<xsl:value-of select="@name"/>*: _<xsl:value-of
select="descr"/>_
+* *<xsl:value-of select="@name"/>*: _<xsl:value-of
select="descr"/>_<xsl:text/>
</xsl:template>
<xsl:template match="fullName"/>
commit a197c85ba3abdcf2e5bc6cf45a21f292f90ee6d3
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 1 22:20:25 2010 +0100
Fix generated xml, provide a list of tokens and a way to translate them to confluence
markup.
diff --git
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
index 79ff62e..7b2d7ff 100644
---
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
+++
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
@@ -58,7 +58,7 @@ public class PrintTokens {
Set<Token> tokens = Token.getByTokenClass(tc);
for (Token token : tokens) {
builder.append(" <token
name=\"").append(token.getName()).append(CLOSE);
- builder.append("
<fullName>").append(token.getText()).append(CLOSE);
+ builder.append("
<fullName>").append(token.getText()).append("</fullName>\n");
builder.append("
<descr>").append(token.getDescription()).append("</descr>\n");
builder.append(" </token>\n");
diff --git a/modules/enterprise/server/plugins/alert-operations/token2confluence.xsl
b/modules/enterprise/server/plugins/alert-operations/token2confluence.xsl
new file mode 100644
index 0000000..8a2b14f
--- /dev/null
+++ b/modules/enterprise/server/plugins/alert-operations/token2confluence.xsl
@@ -0,0 +1,22 @@
+<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:output method="text" indent="no"
xml:space="default"/>
+
+ <xsl:template match="/">
+h2. Tokens for alert-operations sender
+ <xsl:apply-templates />
+ </xsl:template>
+
+ <xsl:template match="tokenClass">
+h3. *<xsl:value-of select="@name"/>*: <xsl:value-of
select="@description"/>
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="token">
+* *<xsl:value-of select="@name"/>*: _<xsl:value-of
select="descr"/>_
+ </xsl:template>
+
+ <xsl:template match="fullName"/>
+ <xsl:template match="descr"/>
+
+</xsl:stylesheet>
\ No newline at end of file
diff --git a/modules/enterprise/server/plugins/alert-operations/tokens.xml
b/modules/enterprise/server/plugins/alert-operations/tokens.xml
new file mode 100644
index 0000000..2c29789
--- /dev/null
+++ b/modules/enterprise/server/plugins/alert-operations/tokens.xml
@@ -0,0 +1,137 @@
+<!-- this file was generated from the Token + TokenClass enums via PrintTokens tool
-->
+<tokenClasses>
+ <tokenClass name="alert" description="Information about the alert
itself">
+ <token name="willBeDisabled">
+ <fullName>alert.willBeDisabled</fullName>
+ <descr>Will the alert definition be disabled after firing?</descr>
+ </token>
+ <token name="id">
+ <fullName>alert.id</fullName>
+ <descr>The id of this particular alert</descr>
+ </token>
+ <token name="url">
+ <fullName>alert.url</fullName>
+ <descr>Url to the alert details page</descr>
+ </token>
+ <token name="name">
+ <fullName>alert.name</fullName>
+ <descr>Name from the defining alert definition</descr>
+ </token>
+ <token name="priority">
+ <fullName>alert.priority</fullName>
+ <descr>Priority of this alert</descr>
+ </token>
+ <token name="description">
+ <fullName>alert.description</fullName>
+ <descr>Description of this alert</descr>
+ </token>
+ <token name="firedAt">
+ <fullName>alert.firedAt</fullName>
+ <descr>Time the alert fired</descr>
+ </token>
+ <token name="conditions">
+ <fullName>alert.conditions</fullName>
+ <descr>A text representation of the conditions that led to this
alert</descr>
+ </token>
+ <token name="willRecover">
+ <fullName>alert.willRecover</fullName>
+ <descr>?? TODO</descr>
+ </token>
+ </tokenClass>
+ <tokenClass name="resource" description="Information about the
resource that triggered the alert">
+ <token name="id">
+ <fullName>resource.id</fullName>
+ <descr>Id of the resource</descr>
+ </token>
+ <token name="platformType">
+ <fullName>resource.platformType</fullName>
+ <descr>Type of the platform the resource is on</descr>
+ </token>
+ <token name="platformName">
+ <fullName>resource.platformName</fullName>
+ <descr>Name of the platform the resource is on</descr>
+ </token>
+ <token name="typeName">
+ <fullName>resource.typeName</fullName>
+ <descr>Resource type name</descr>
+ </token>
+ <token name="name">
+ <fullName>resource.name</fullName>
+ <descr>Name of the resource</descr>
+ </token>
+ <token name="platformId">
+ <fullName>resource.platformId</fullName>
+ <descr>Id of the platform the resource is on</descr>
+ </token>
+ <token name="parentName">
+ <fullName>resource.parentName</fullName>
+ <descr>Name of the parent resource</descr>
+ </token>
+ <token name="parentId">
+ <fullName>resource.parentId</fullName>
+ <descr>Id of the parent resource</descr>
+ </token>
+ <token name="typeId">
+ <fullName>resource.typeId</fullName>
+ <descr>Resource type id</descr>
+ </token>
+ </tokenClass>
+ <tokenClass name="targetResource" description="Information about the
resource the alert is fired on ">
+ <token name="parentId">
+ <fullName>targetResource.parentId</fullName>
+ <descr>Id of the target's parent resource</descr>
+ </token>
+ <token name="platformName">
+ <fullName>targetResource.platformName</fullName>
+ <descr>Name of the platform the target resource is on</descr>
+ </token>
+ <token name="platformId">
+ <fullName>targetResource.platformId</fullName>
+ <descr>Id of the platform the target resource is on</descr>
+ </token>
+ <token name="parentName">
+ <fullName>targetResource.parentName</fullName>
+ <descr>Name of the target's parent resource</descr>
+ </token>
+ <token name="typeId">
+ <fullName>targetResource.typeId</fullName>
+ <descr>Resource type of the target resource id</descr>
+ </token>
+ <token name="platformType">
+ <fullName>targetResource.platformType</fullName>
+ <descr>Type of the platform the target resource is on</descr>
+ </token>
+ <token name="name">
+ <fullName>targetResource.name</fullName>
+ <descr>Name of the target resource</descr>
+ </token>
+ <token name="id">
+ <fullName>targetResource.id</fullName>
+ <descr>Id of the target resource</descr>
+ </token>
+ <token name="typeName">
+ <fullName>targetResource.typeName</fullName>
+ <descr>Resource type name of the target resource</descr>
+ </token>
+ </tokenClass>
+ <tokenClass name="operation" description="Information about the
triggered operation">
+ <token name="id">
+ <fullName>operation.id</fullName>
+ <descr>Id of the operation fired</descr>
+ </token>
+ <token name="name">
+ <fullName>operation.name</fullName>
+ <descr>Name of the operation fired</descr>
+ </token>
+ </tokenClass>
+ <tokenClass name="test" description="Just some dummies for internal
testing purposes">
+ <token name="echo">
+ <fullName>test.echo</fullName>
+ <descr>Echo the input</descr>
+ </token>
+ <token name="fix">
+ <fullName>test.fix</fullName>
+ <descr>Return a fixed string</descr>
+ </token>
+ </tokenClass>
+</tokenClasses>
commit 653e41c57c1fb6facc52ba3d22c20259f9717141
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 1 21:47:17 2010 +0100
Support more tokens
diff --git
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/AlertTokenReplacer.java
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/AlertTokenReplacer.java
new file mode 100644
index 0000000..e8c61dd
--- /dev/null
+++
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/AlertTokenReplacer.java
@@ -0,0 +1,231 @@
+/*
+ * 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.server.plugins.alertOperations;
+
+import java.util.Date;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.alert.Alert;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.server.alert.AlertManagerLocal;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * Helper to replace tokens by their values
+ * @author Heiko W. Rupp
+ */
+public class AlertTokenReplacer {
+
+ private final Log log = LogFactory.getLog(AlertTokenReplacer.class);
+ public static final String NOT_YET_IMPLEMENTED = " - not yet implemented
-";
+ protected static final String THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG =
"TheQuickBrownFoxJumpsOverTheLazyDOg";
+ private Alert alert;
+ private Pattern pattern;
+ private OperationDefinition operationDefinition;
+ private Resource targetResource;
+
+ public AlertTokenReplacer(Alert alert, OperationDefinition operationDefinition,
Resource targetResource) {
+ this.alert = alert;
+ this.operationDefinition = operationDefinition;
+ pattern = Pattern.compile("<%\\s*([a-z]+\\.[a-z0-9]+)\\s*%>");
+ }
+
+ /**
+ * Replace all tokens on the input line. If no tokens are found the input is
returned.
+ * Tokens have the form '<i><% class.sub %></i>'
+ * @param input a line of text
+ * @return input with tokens replaced.
+ * @see org.rhq.enterprise.server.plugins.alertOperations.Token
+ * @see org.rhq.enterprise.server.plugins.alertOperations.TokenClass
+ */
+ public String replaceTokens(String input) {
+
+ String work = input;
+ Matcher matcher = pattern.matcher(work);
+ if (!matcher.find()) {
+ log.warn("No tokens found in " + input);
+ return input;
+ }
+ matcher.reset();
+
+ do {
+ matcher = pattern.matcher(work);
+ if (!matcher.find()) {
+ break;
+ }
+ String replacement = replaceToken(matcher.group(1)
);
+ String s = matcher.replaceFirst(replacement);
+ work = s;
+
+ } while (true);
+
+ return work;
+ }
+
+
+
+ /**
+ * Replace the token string passed (without the token delimiters ) with the actual
value
+ * @param tokenString Input like alert.id
+ * @return replacement string or the input if the token was not valid.
+ */
+ public String replaceToken(String tokenString) {
+
+ // Ok, we have at least one token. Now split the tokenString and loop over the
tokens
+
+ if (!tokenString.contains("."))
+ return tokenString;
+
+ String tmp = tokenString.substring(0, tokenString.indexOf("."));
+ TokenClass tc = TokenClass.getByText(tmp);
+ if (tc==null) {
+ log.warn("Unknown token class in [" + tokenString + "], not
replacing tokens");
+ return tokenString;
+ }
+
+ Token token = Token.getByText(tokenString);
+ if (token == null) {
+ log.warn("No known token found in [" + tokenString + "], not
replacing token");
+ return tokenString;
+ }
+ String ret = null;
+ switch (tc) {
+ case ALERT:
+ ret = replaceAlertToken(token,alert);
+ break;
+ case RESOURCE:
+ ret =
replaceResourceToken(token,alert.getAlertDefinition().getResource());
+ break;
+ case TARGET_RESOURCE:
+ // Create a "pseudo" token to feed it into the plain resource
replacement code
+ String text = "resource." + token.getName();
+ Token tok = Token.getByText(text);
+ ret = replaceResourceToken(tok, targetResource);
+ break;
+ case OPERATION:
+ ret = replaceOperationToken(token);
+ break;
+ case TEST:
+ switch (token) {
+ case TEST_ECHO:
+ ret = tokenString;
+ break;
+ case TEST_FIX:
+ ret = THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG;
+ break;
+ default:
+ ret = NOT_YET_IMPLEMENTED;
+ }
+ break;
+ }
+ return ret;
+ }
+
+ private String replaceAlertToken(Token token, Alert alert) {
+
+ AlertManagerLocal mgr = LookupUtil.getAlertManager();
+
+ switch (token) {
+ case ALERT_ID:
+ return String.valueOf(alert.getId());
+ case ALERT_FIRE_TIME:
+ return new Date(alert.getCtime()).toString(); // TODO use a specific impl
here?
+ case ALERT_WILL_RECOVER:
+ return String.valueOf(alert.getAlertDefinition().getWillRecover());
+ case ALERT_WILL_DISABLE:
+ return String.valueOf(mgr.willDefinitionBeDisabled(alert));
+ case ALERT_DEF_NAME:
+ return alert.getAlertDefinition().getName();
+ case ALERT_DEF_DESC:
+ return alert.getAlertDefinition().getDescription();
+ case ALERT_DEF_PRIO:
+ return alert.getAlertDefinition().getPriority().getName();
+ case ALERT_URL:
+ return mgr.prettyPrintAlertURL(alert);
+ case ALERT_CONDITIONS:
+ return mgr.prettyPrintAlertConditions(alert,false);
+
+
+ default:
+ return NOT_YET_IMPLEMENTED;
+ }
+
+ }
+
+ private String replaceResourceToken(Token token, Resource resource) {
+
+ ResourceManagerLocal mgr = LookupUtil.getResourceManager();
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+ Resource parent;
+ Resource platform = mgr.getPlaformOfResource(overlord,resource.getId());
+
+ switch (token) {
+ case RESOURCE_ID:
+ return String.valueOf(resource.getId());
+ case RESOURCE_NAME:
+ return resource.getName();
+ case RESOURCE_PARENT_ID:
+ parent = mgr.getParentResource(resource.getId());
+ if (parent==null)
+ return "0";
+ else
+ return String.valueOf(parent.getId());
+ case RESOURCE_PARENT_NAME:
+ parent = mgr.getParentResource(resource.getId());
+ if (parent==null)
+ return "0";
+ else
+ return String.valueOf(parent.getId());
+ case RESOURCE_TYPE_ID:
+ return String.valueOf(resource.getResourceType().getId());
+ case RESOURCE_TYPE_NAME:
+ return resource.getResourceType().getName();
+ case RESOURCE_PLATFORM_ID:
+ return String.valueOf(platform.getId());
+ case RESOURCE_PLATFORM_NAME:
+ return platform.getName();
+ case RESOURCE_PLATFORM_TYPE:
+ return platform.getResourceType().getName();
+
+ default:
+ return NOT_YET_IMPLEMENTED;
+ }
+ }
+
+ private String replaceOperationToken(Token token) {
+
+ switch (token) {
+ case OPERATION_ID:
+ return String.valueOf(operationDefinition.getId());
+ case OPERATION_NAME:
+ return operationDefinition.getName();
+
+
+ default:
+ return NOT_YET_IMPLEMENTED;
+ }
+ }
+}
diff --git
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsSender.java
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsSender.java
index 4f6c88e..635085a 100644
---
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsSender.java
+++
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsSender.java
@@ -78,9 +78,11 @@ public class OperationsSender extends AlertSender {
Subject subject = LookupUtil.getSubjectManager().getOverlord(); // TODO get real
subject
List<OperationDefinition> opdefs =
opMgr.findSupportedResourceOperations(subject,resourceId,false);
- for (OperationDefinition opdef : opdefs ) {
- if (opdef.getId() == opId) {
- opName = opdef.getName();
+ OperationDefinition opDef = null;
+ for (OperationDefinition tmp : opdefs ) {
+ if (tmp.getId() == opId) {
+ opName = tmp.getName();
+ opDef = tmp;
break;
}
}
@@ -110,7 +112,7 @@ public class OperationsSender extends AlertSender {
if (parameters!=null && tokenMode.equals(INTERPRETED)) {
Map<String,PropertySimple> propsMap =
parameters.getSimpleProperties();
if (!propsMap.isEmpty()) {
- TokenReplacer tr = new TokenReplacer(alert);
+ AlertTokenReplacer tr = new AlertTokenReplacer(alert, opDef, null);
for (PropertySimple prop : propsMap.values()) {
String tmp = prop.getStringValue();
tmp = tr.replaceTokens(tmp);
diff --git
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
index 78ac850..79ff62e 100644
---
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
+++
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
@@ -35,6 +35,17 @@ public class PrintTokens {
public static void main(String[] args) throws Exception {
+ String text = createTokenDescription();
+
+ System.out.println(text);
+ }
+
+ /**
+ * Do the work and return an xml structure that lists available token classes and
+ * tokens along with their descriptions.
+ * @return String with an XML representation of the available tokens
+ */
+ public static String createTokenDescription() {
EnumSet<TokenClass> tokenClasses = EnumSet.allOf(TokenClass.class);
StringBuilder builder = new StringBuilder("<tokenClasses>\n");
@@ -58,7 +69,6 @@ public class PrintTokens {
}
builder.append("</tokenClasses>\n");
-
- System.out.println(builder.toString());
+ return builder.toString();
}
}
diff --git
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java
index e665bd4..2d810f0 100644
---
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java
+++
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java
@@ -43,11 +43,25 @@ public enum Token {
// resource that triggered the alert related tokens
RESOURCE_ID(TokenClass.RESOURCE, "id", "Id of the resource"),
RESOURCE_NAME(TokenClass.RESOURCE, "name", "Name of the
resource"),
+ RESOURCE_PARENT_ID(TokenClass.RESOURCE, "parentId", "Id of the parent
resource"),
+ RESOURCE_PARENT_NAME(TokenClass.RESOURCE, "parentName", "Name of the
parent resource"),
+ RESOURCE_TYPE_ID(TokenClass.RESOURCE,"typeId","Resource type
id"),
+ RESOURCE_TYPE_NAME(TokenClass.RESOURCE,"typeName","Resource type
name"),
+ RESOURCE_PLATFORM_ID(TokenClass.RESOURCE,"platformId", "Id of the
platform the resource is on"),
+ RESOURCE_PLATFORM_NAME(TokenClass.RESOURCE,"platformName", "Name of
the platform the resource is on"),
+ RESOURCE_PLATFORM_TYPE(TokenClass.RESOURCE,"platformType", "Type of
the platform the resource is on"),
// resource the operation is run on related tokens
TRESOURCE_ID(TokenClass.TARGET_RESOURCE, "id","Id of the target
resource"),
TRESOURCE_NAME(TokenClass.TARGET_RESOURCE, "name", "Name of the target
resource"),
+ TRESOURCE_PARENT_ID(TokenClass.TARGET_RESOURCE, "parentId", "Id of the
target's parent resource"),
+ TRESOURCE_PARENT_NAME(TokenClass.TARGET_RESOURCE, "parentName", "Name
of the target's parent resource"),
+ TRESOURCE_TYPE_ID(TokenClass.TARGET_RESOURCE,"typeId","Resource type
of the target resource id"),
+ TRESOURCE_TYPE_NAME(TokenClass.TARGET_RESOURCE,"typeName","Resource
type name of the target resource"),
+ TRESOURCE_PLATFORM_ID(TokenClass.TARGET_RESOURCE,"platformId", "Id of
the platform the target resource is on"),
+ TRESOURCE_PLATFORM_NAME(TokenClass.TARGET_RESOURCE,"platformName",
"Name of the platform the target resource is on"),
+ TRESOURCE_PLATFORM_TYPE(TokenClass.TARGET_RESOURCE,"platformType",
"Type of the platform the target resource is on"),
// Information about the fired operation
@@ -56,9 +70,7 @@ public enum Token {
// only for testing
TEST_ECHO(TokenClass.TEST,"echo", "Echo the input"),
- TEST_FIX(TokenClass.TEST,"fix", "Return a fixed string")
-
- ;
+ TEST_FIX(TokenClass.TEST,"fix", "Return a fixed string");
private TokenClass tc;
diff --git
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenReplacer.java
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenReplacer.java
deleted file mode 100644
index 0b230b4..0000000
---
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenReplacer.java
+++ /dev/null
@@ -1,178 +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.server.plugins.alertOperations;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.alert.Alert;
-import org.rhq.core.domain.resource.Resource;
-
-/**
- * Helper to replace tokens by their values
- * @author Heiko W. Rupp
- */
-public class TokenReplacer {
-
- private final Log log = LogFactory.getLog(TokenReplacer.class);
- private static final String NOT_YET_IMPLEMENTED = " - not yet implemented
-";
- protected static final String THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG =
"TheQuickBrownFoxJumpsOverTheLazyDOg";
- private Alert alert;
- private Pattern pattern;
-
- public TokenReplacer(Alert alert) {
- this.alert = alert;
- pattern = Pattern.compile("<%\\s*([a-z]+\\.[a-z0-9]+)\\s*%>");
- }
-
- /**
- * Replace all tokens on the input line. If no tokens are found the input is
returned.
- * Tokens have the form '<i><% class.sub %></i>'
- * @param input a line of text
- * @return input with tokens replaced.
- * @see org.rhq.enterprise.server.plugins.alertOperations.Token
- * @see org.rhq.enterprise.server.plugins.alertOperations.TokenClass
- */
- public String replaceTokens(String input) {
-
- String work = input;
- Matcher matcher = pattern.matcher(work);
- if (!matcher.find()) {
- log.warn("No tokens found in " + input);
- return input;
- }
- matcher.reset();
-
- do {
-// System.out.println(input);
- matcher = pattern.matcher(work);
- if (!matcher.find()) {
- break;
- }
-// System.out.println(matcher.regionStart() + ":" +
matcher.regionEnd() + input.substring(matcher.regionStart(),matcher.regionEnd()));
-// System.out.println(matcher.group(1));
- String replacement = replaceToken(matcher.group(1)
);
- String s = matcher.replaceFirst(replacement);
-// System.out.println(s);
- work = s;
-
-// System.out.println("----");
- } while (true);
-
- return work;
- }
-
-
-
- /**
- * Replace the token string passed (without the token delimiters ) with the actual
value
- * @param tokenString Input like alert.id
- * @return replacement string or the input if the token was not valid.
- */
- public String replaceToken(String tokenString) {
-
- // Ok, we have at least one token. Now split the tokenString and loop over the
tokens
-
- if (!tokenString.contains("."))
- return tokenString;
-
- String tmp = tokenString.substring(0, tokenString.indexOf("."));
- TokenClass tc = TokenClass.getByText(tmp);
- if (tc==null) {
- log.warn("Unknown token class in [" + tokenString + "], not
replacing tokens");
- return tokenString;
- }
-
- Token token = Token.getByText(tokenString);
- if (token == null) {
- log.warn("No known token found in [" + tokenString + "], not
replacing token");
- return tokenString;
- }
- String ret = null;
- switch (tc) {
- case ALERT:
- ret = replaceAlertToken(token,alert);
- break;
- case RESOURCE:
- ret =
replaceResourceToken(token,alert.getAlertDefinition().getResource());
- break;
- case TARGET_RESOURCE:
- Resource resource = null; // TODO
- ret = replaceTargetResourceToken(token, resource);
- break;
- case TEST:
- switch (token) {
- case TEST_ECHO:
- ret = tokenString;
- break;
- case TEST_FIX:
- ret = THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG;
- break;
- default:
- ret = NOT_YET_IMPLEMENTED;
- }
- break;
- }
- return ret;
- }
-
- private String replaceAlertToken(Token token, Alert alert) {
-
- switch (token) {
- case ALERT_ID:
- return String.valueOf(alert.getId());
- case ALERT_URL:
- return NOT_YET_IMPLEMENTED;
-
- default:
- return NOT_YET_IMPLEMENTED;
- }
-
- }
-
- private String replaceResourceToken(Token token, Resource resource) {
-
- switch (token) {
- case RESOURCE_ID:
- return String.valueOf(resource.getId());
- case RESOURCE_NAME:
- return resource.getName();
-
- default:
- return NOT_YET_IMPLEMENTED;
- }
- }
-
- private String replaceTargetResourceToken(Token token, Resource resource) {
-
- switch (token) {
- case TRESOURCE_ID:
- return String.valueOf(resource.getId());
- case TRESOURCE_NAME:
- return resource.getName();
-
- default:
- return NOT_YET_IMPLEMENTED;
- }
- }
-
-}
diff --git
a/modules/enterprise/server/plugins/alert-operations/src/test/java/org/rhq/enterprise/server/plugins/alertOperations/TokenReplacementTest.java
b/modules/enterprise/server/plugins/alert-operations/src/test/java/org/rhq/enterprise/server/plugins/alertOperations/TokenReplacementTest.java
index f41fc85..cf6c48d 100644
---
a/modules/enterprise/server/plugins/alert-operations/src/test/java/org/rhq/enterprise/server/plugins/alertOperations/TokenReplacementTest.java
+++
b/modules/enterprise/server/plugins/alert-operations/src/test/java/org/rhq/enterprise/server/plugins/alertOperations/TokenReplacementTest.java
@@ -18,12 +18,15 @@
*/
package org.rhq.enterprise.server.plugins.alertOperations;
+import java.util.EnumSet;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.testng.annotations.Test;
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.resource.Resource;
/**
@@ -42,17 +45,18 @@ public class TokenReplacementTest {
public void testSimpleReplacement() throws Exception {
Alert al = new Alert();
- TokenReplacer tr = new TokenReplacer(al);
+ AlertTokenReplacer tr = new AlertTokenReplacer(al, null, null);
String res = tr.replaceToken("test.fix");
assert res != null;
- assert res.equals(TokenReplacer.THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG);
+ assert
res.equals(AlertTokenReplacer.THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG);
res = tr.replaceToken(TEST_ECHO);
assert res != null;
assert res.equals(TEST_ECHO);
+/*
res = tr.replaceToken("alert.id");
assert res != null;
assert res.equals("0");
@@ -62,18 +66,19 @@ public class TokenReplacementTest {
AlertDefinition def = new AlertDefinition();
def.setResource(r);
al = new Alert(def, System.currentTimeMillis());
- tr = new TokenReplacer(al);
+ tr = new AlertTokenReplacer(al, null, null);
res = tr.replaceToken("resource.id");
assert "1234".equals(res);
res = tr.replaceToken("resource.name");
assert "A resource".equals(res);
+*/
}
public void testInvalidTokenString() {
Alert al = new Alert();
- TokenReplacer tr = new TokenReplacer(al);
+ AlertTokenReplacer tr = new AlertTokenReplacer(al, null, null);
String res = tr.replaceToken(FOO_BAR);
@@ -93,13 +98,13 @@ public class TokenReplacementTest {
public void testFullTokenSimple() {
Alert al = new Alert();
- TokenReplacer tr = new TokenReplacer(al);
+ AlertTokenReplacer tr = new AlertTokenReplacer(al, null, null);
String res = tr.replaceTokens("<%test.fix%>");
assert res != null;
assert !res.equals("<%test.fix%>") : "Res was " + res;
- assert res.equals(TokenReplacer.THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG);
+ assert
res.equals(AlertTokenReplacer.THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG);
String TF2 = "<% test.fix %>";
res = tr.replaceTokens(TF2);
@@ -120,16 +125,67 @@ public class TokenReplacementTest {
assert res != null;
assert res.equals(FOO_BAR) : "Res was " + res;
+/*
Resource r = new Resource(1234);
r.setName("A resource");
AlertDefinition def = new AlertDefinition();
def.setResource(r);
al = new Alert(def, System.currentTimeMillis());
- tr = new TokenReplacer(al);
+ tr = new AlertTokenReplacer(al, null, null);
res = tr.replaceTokens("<% test.fix%><%resource.id%>");
assert res!=null;
- assert
res.equals(TokenReplacer.THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG+"1234");
+ assert
res.equals(AlertTokenReplacer.THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG+"1234");
+*/
+ }
+
+ public void testOperationTokens() {
+ Resource r = new Resource(1234);
+ AlertDefinition def = new AlertDefinition();
+ def.setResource(r);
+ Alert al = new Alert(def, System.currentTimeMillis());
+
+ AlertTokenReplacer tr;
+ OperationDefinition opDef = new
OperationDefinition(123,"helloOps",null,"This is a test",0,"Just
testing");
+ tr = new AlertTokenReplacer(al,opDef, null);
+ String res = tr.replaceTokens("<%operation.id%>");
+ assert res!=null;
+ assert res.equals("123") : "Result is " + res;
+ res = tr.replaceTokens("<%operation.name%>");
+ assert res!=null;
+ assert res.equals("helloOps");
+ }
+
+ public void testTokenPrinter() {
+
+ String result = PrintTokens.createTokenDescription();
+ assert result != null;
+ assert !result.isEmpty();
+ assert result.contains("<token ");
}
+/*
+ public void testReplaceAllTokens() {
+
+ EnumSet<Token> tokens = EnumSet.allOf(Token.class);
+
+ Resource r = new Resource(1234);
+ AlertDefinition def = new AlertDefinition();
+ def.setResource(r);
+ Alert al = new Alert(def, System.currentTimeMillis());
+
+ AlertTokenReplacer tr;
+ OperationDefinition opDef = new
OperationDefinition(123,"helloOps",null,"This is a test",0,"Just
testing");
+ tr = new AlertTokenReplacer(al,opDef, null);
+
+ for (Token token : tokens) {
+
+ String input = "<%" + token.getText() + "%>";
+ String res = tr.replaceTokens(input);
+ assert res != null;
+ assert !res.isEmpty();
+ assert !res.equals(AlertTokenReplacer.NOT_YET_IMPLEMENTED) :
"Replacement for token [" + token.getText() + "] is not implemented";
+ }
+ }
+*/
}
commit 15ff7e397d9a01af13937c7d806679918e2dda7d
Author: Justin Harris <jharris(a)redhat.com>
Date: Mon Mar 1 11:26:37 2010 -0500
BZ 568796 - Changing input length on metric baseline % field.
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 2000efd..668d175 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
@@ -372,7 +372,8 @@
converter="#{metricPercentConverter}"
required="true"
requiredMessage="#{alertMessages.percentRange}"
-
validatorMessage="#{alertMessages.percentRange}">
+
validatorMessage="#{alertMessages.percentRange}"
+ size="6">
<f:validateDoubleRange
minimum="0.0" maximum="1000.0" />
</h:inputText>
<h:outputLabel
for="metricBaselinePercent" value="
#{messages['alert.config.props.CB.Content.Percent']} " />
commit dd92239d4a43a1ae899353f3268857de832ead3e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 1 14:04:55 2010 +0100
Provide token descriptions and a way to get a full list of tokens defined.
diff --git
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
new file mode 100644
index 0000000..78ac850
--- /dev/null
+++
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/PrintTokens.java
@@ -0,0 +1,64 @@
+/*
+ * 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.server.plugins.alertOperations;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Print the available tokens to stdout, for documentation generation purposes
+ * @author Heiko W. Rupp
+ */
+public class PrintTokens {
+
+ private final Log log = LogFactory.getLog(PrintTokens.class);
+ private static final String CLOSE = "\">\n";
+
+ public static void main(String[] args) throws Exception {
+
+ EnumSet<TokenClass> tokenClasses = EnumSet.allOf(TokenClass.class);
+
+ StringBuilder builder = new StringBuilder("<tokenClasses>\n");
+
+ for (TokenClass tc : tokenClasses ) {
+ builder.append(" <tokenClass
name=\"").append(tc.getText()).
+ append("\"").append("
description=\"").append(tc.getDescription()).
+ append(CLOSE);
+
+ Set<Token> tokens = Token.getByTokenClass(tc);
+ for (Token token : tokens) {
+ builder.append(" <token
name=\"").append(token.getName()).append(CLOSE);
+ builder.append("
<fullName>").append(token.getText()).append(CLOSE);
+ builder.append("
<descr>").append(token.getDescription()).append("</descr>\n");
+ builder.append(" </token>\n");
+
+ }
+
+ builder.append(" </tokenClass>\n");
+
+ }
+
+ builder.append("</tokenClasses>\n");
+
+ System.out.println(builder.toString());
+ }
+}
diff --git
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java
index bcd7570..e665bd4 100644
---
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java
+++
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/Token.java
@@ -19,39 +19,59 @@
package org.rhq.enterprise.server.plugins.alertOperations;
import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Set;
/**
- * Tokens that can be replaced in
+ * Tokens that can be replaced in operation parameters
* @author Heiko W. Rupp
*/
public enum Token {
// Alert related tokens
- ALERT_ID(TokenClass.ALERT, "id"),
- ALERT_URL(TokenClass.ALERT, "url"),
+ ALERT_ID(TokenClass.ALERT, "id","The id of this particular
alert"),
+ ALERT_URL(TokenClass.ALERT, "url","Url to the alert details
page"),
+ ALERT_FIRE_TIME(TokenClass.ALERT, "firedAt","Time the alert
fired"),
+ ALERT_WILL_RECOVER(TokenClass.ALERT,"willRecover","?? TODO"),
+ ALERT_CONDITIONS(TokenClass.ALERT,"conditions","A text representation
of the conditions that led to this alert"),
+ ALERT_DEF_NAME(TokenClass.ALERT,"name","Name from the defining alert
definition"),
+ ALERT_DEF_DESC(TokenClass.ALERT,"description","Description of this
alert"),
+ ALERT_DEF_PRIO(TokenClass.ALERT,"priority", "Priority of this
alert"),
+ ALERT_WILL_DISABLE(TokenClass.ALERT,"willBeDisabled","Will the alert
definition be disabled after firing?"),
+
// resource that triggered the alert related tokens
- RESOURCE_ID(TokenClass.RESOURCE, "id"),
- RESOURCE_NAME(TokenClass.RESOURCE, "name"),
+ RESOURCE_ID(TokenClass.RESOURCE, "id", "Id of the resource"),
+ RESOURCE_NAME(TokenClass.RESOURCE, "name", "Name of the
resource"),
// resource the operation is run on related tokens
- TRESOURCE_ID(TokenClass.TARGET_RESOURCE, "id"),
- TRESOURCE_NAME(TokenClass.TARGET_RESOURCE, "name"),
+ TRESOURCE_ID(TokenClass.TARGET_RESOURCE, "id","Id of the target
resource"),
+ TRESOURCE_NAME(TokenClass.TARGET_RESOURCE, "name", "Name of the target
resource"),
+
+ // Information about the fired operation
+ OPERATION_ID(TokenClass.OPERATION,"id","Id of the operation
fired"),
+ OPERATION_NAME(TokenClass.OPERATION,"name","Name of the operation
fired"),
// only for testing
- TEST_ECHO(TokenClass.TEST,"echo"),
- TEST_FIX(TokenClass.TEST,"fix")
+ TEST_ECHO(TokenClass.TEST,"echo", "Echo the input"),
+ TEST_FIX(TokenClass.TEST,"fix", "Return a fixed string")
;
+ private TokenClass tc;
+ private String name;
private String text;
+ private String description;
- private Token(TokenClass tc, String text) {
+ private Token(TokenClass tc, String name, String description) {
- this.text = tc.getText() + "." + text;
+ this.tc = tc;
+ this.name = name;
+ this.text = tc.getText() + "." + name;
+ this.description = description;
}
/**
@@ -69,4 +89,29 @@ public enum Token {
}
return null;
}
+
+ public static Set<Token> getByTokenClass(TokenClass tokenClass) {
+
+ Set<Token> tokens = new HashSet<Token>();
+
+ EnumSet<Token> es = EnumSet.allOf(Token.class);
+ for (Token t : es) {
+ if (t.tc == tokenClass)
+ tokens.add(t);
+ }
+
+ return tokens;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public String getDescription() {
+ return description;
+ }
}
diff --git
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenClass.java
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenClass.java
index 5125a72..16cb240 100644
---
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenClass.java
+++
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/TokenClass.java
@@ -26,22 +26,30 @@ import java.util.EnumSet;
*/
public enum TokenClass {
- ALERT("alert"),
- RESOURCE("resource"),
- TARGET_RESOURCE("targetResource"),
- TEST("test");
+ ALERT("alert","Information about the alert itself"),
+ RESOURCE("resource","Information about the resource that triggered the
alert"),
+ TARGET_RESOURCE("targetResource","Information about the resource the
alert is fired on "),
+ OPERATION("operation","Information about the triggered
operation"),
+ //
+ TEST("test","Just some dummies for internal testing purposes");
private String text;
+ private String description;
- private TokenClass(String text) {
+ private TokenClass(String text,String description) {
this.text = text;
+ this.description = description;
}
public String getText() {
return text;
}
- /**
+ public String getDescription() {
+ return description;
+ }
+
+ /**
* Return the tokenclass that matches the input text or null if not found.
* The token delimiters need to be already stripped from the input
* @param input a token text like <i>alert</i>, which would return the
commit ac9103aaf2c5c999bd6f1d940ff0159072b2cbad
Merge: 79afeae... 6278e70...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 1 10:47:39 2010 +0100
Merge branch 'master' into alertPlugin
commit 79afeae9fab3bcf14508792f0007c1c773934e36
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 1 10:46:53 2010 +0100
Provide a way to initialize the backing bean after it got created and the
alertParameters got injected.
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
index 0896c6e..ccb5d7d 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
@@ -288,6 +288,12 @@ public class AlertNotificationManagerBean implements
AlertNotificationManagerLoc
Configuration config2 = config.deepCopy(true);
bean.setAlertParameters(config2);
+ try {
+ bean.internalInit();
+ }
+ catch (Throwable t ) {
+ LOG.error("getBackinBean, calling backingBean.internalInit()
resulted in " + t.getMessage());
+ }
}
}
return bean;
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
index e4b2d20..12312f2 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
@@ -40,6 +40,13 @@ public class CustomAlertSenderBackingBean {
public void setAlertParameters(Configuration alertParameters) {
this.alertParameters = alertParameters;
}
+
+ /**
+ * This method is called after constructing the bean and injecting the
+ * #alertParameters
+ */
+ public void internalInit() {}
+
/**
* This method is called when the alert notification that uses this backing bean
* is removed, so that the backing bean can do some cleanup work
diff --git
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
index 98fa0e9..dc41f01 100644
---
a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
+++
b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
@@ -67,19 +67,32 @@ public class OperationsBackingBean extends
CustomAlertSenderBackingBean {
log.info("new " + hashCode());
}
- @Create
- public void init() {
- log.info("init");
+ @Override
+ public void internalInit() {
+/* log.info("internalInit");
+ try {
+ getResId();
+ getResourceName();
+ obtainOperationIds();
+ getOperationId();
+ lookupConfiguration();
+ }
+ catch (Throwable t) {
+ t.printStackTrace();
+ }*/
}
+
@Override
public void internalCleanup() {
+ log.info("internalCleanup");
PropertySimple parameterConfigProp =
alertParameters.getSimple(OperationsSender.PARAMETERS_CONFIG);
if (parameterConfigProp!=null) {
Integer paramId = parameterConfigProp.getIntegerValue();
if (paramId!=null) {
ConfigurationManagerLocal cmgr = LookupUtil.getConfigurationManager();
cmgr.deleteConfigurations(Arrays.asList(paramId));
+ cleanProperty(alertParameters,OperationsSender.PARAMETERS_CONFIG);
}
}
}
@@ -92,6 +105,8 @@ public class OperationsBackingBean extends CustomAlertSenderBackingBean
{
persistProperty(alertParameters, OperationsSender.RESOURCE_ID,resId);
cleanProperty(alertParameters,OperationsSender.OPERATION_ID);
cleanProperty(alertParameters,OperationsSender.USABLE);
+ operationIds = new HashMap<String,Integer>(); // Clean out operations
dropdown
+ operationId = null;
}
@@ -116,25 +131,25 @@ public class OperationsBackingBean extends
CustomAlertSenderBackingBean {
private void lookupConfiguration() {
-// log.info("getCD: " + configurationDefinition);
try {
// Subject subject = EnterpriseFacesContextUtility.getSubject();
Subject subject = LookupUtil.getSubjectManager().getOverlord(); // TODO
replace with real subject
-// int operationId =
Integer.valueOf(FacesContextUtility.getRequiredRequestParameter("opId"));
OperationManagerLocal opMan = LookupUtil.getOperationManager();
obtainOperationIds();
- OperationDefinition operationDefinition =
opMan.getOperationDefinition(subject, operationId);
- configurationDefinition =
operationDefinition.getParametersConfigurationDefinition();
+ if (operationId!=null) {
+ OperationDefinition operationDefinition =
opMan.getOperationDefinition(subject, operationId);
+ configurationDefinition =
operationDefinition.getParametersConfigurationDefinition();
- // call a SLSB method to get around lazy initialization of configDefs and
configTemplates
- ConfigurationManagerLocal configurationManager =
LookupUtil.getConfigurationManager();
- configuration =
configurationManager.getConfigurationFromDefaultTemplate(configurationDefinition);
-// Configuration newConfiguration = configuration.deepCopy(false);
-log.info("gConfig: " + configuration + ", " +
configuration.hashCode() + ", " +
configuration.getSimpleValue("detailedDiscovery","-unset-"));
+ // call a SLSB method to get around lazy initialization of configDefs and
configTemplates
+ ConfigurationManagerLocal configurationManager =
LookupUtil.getConfigurationManager();
+ configuration =
configurationManager.getConfigurationFromDefaultTemplate(configurationDefinition);
+ // Configuration newConfiguration = configuration.deepCopy(false);
+ log.info("lookupConfiguration: " + configuration + ",
" + configuration.hashCode() );
+ }
} catch (Exception e) {
e.printStackTrace();
}
commit f944f3d58c4d7719ea075429faa1dc938737ecf1
Author: James Livingston <jlivings(a)redhat.com>
Date: Fri Feb 26 10:53:48 2010 +0100
BZ 560859 - Add mechanism to enable/disable alert definitions for multiple resources
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/subsystem/SubsystemAlertDefinitionUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/subsystem/SubsystemAlertDefinitionUIBean.java
index 5831f3e..2e8d49c 100644
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/subsystem/SubsystemAlertDefinitionUIBean.java
+++
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/subsystem/SubsystemAlertDefinitionUIBean.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2010 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -73,13 +73,13 @@ public class SubsystemAlertDefinitionUIBean extends SubsystemView {
private SelectItem[] categoryFilterItems;
private IntExtractor<AlertDefinitionComposite> RESOURCE_ID_EXTRACTOR = new
IntExtractor<AlertDefinitionComposite>() {
-
+
public int extract(AlertDefinitionComposite object) {
Resource resource = object.getAlertDefinition().getResource();
return resource == null ? 0 : resource.getId();
}
};
-
+
public SubsystemAlertDefinitionUIBean() {
datePattern =
EnterpriseFacesContextUtility.getWebUser().getWebPreferences().getDateTimeDisplayPreferences()
.getDateTimeFormatTrigger();
@@ -178,6 +178,84 @@ public class SubsystemAlertDefinitionUIBean extends SubsystemView {
return "success";
}
+ public String disableSelected() {
+ Integer[] selected = getSelectedItems();
+
+ try {
+ Subject subject = getSubject();
+
+ List<Integer> resourceDefinitions = new ArrayList<Integer>();
+ List<Integer> groupDefinitions = new ArrayList<Integer>();
+ List<Integer> typeDefinitions = new ArrayList<Integer>();
+
+ for (Integer definitionId : selected) {
+ if (alertDefinitionManager.isTemplate(definitionId)) {
+ typeDefinitions.add(definitionId);
+ } else if (alertDefinitionManager.isGroupAlertDefinition(definitionId))
{
+ groupDefinitions.add(definitionId);
+ } else {
+ resourceDefinitions.add(definitionId);
+ }
+ }
+
+ // delete resources first
+ alertDefinitionManager.disableAlertDefinitions(subject, resourceDefinitions
+ .toArray(new Integer[resourceDefinitions.size()]));
+
+ // then delete templates and group alert defs, which are both tolerant of
missing child definitions
+ groupAlertDefinitionManager.disableGroupAlertDefinitions(subject,
groupDefinitions
+ .toArray(new Integer[groupDefinitions.size()]));
+ alertTemplateManager.removeAlertTemplates(subject,
typeDefinitions.toArray(new Integer[typeDefinitions
+ .size()]));
+
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Disable
selected alert definitions.");
+ } catch (Exception e) {
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Failed to
disable selected alert definitions.",
+ e);
+ }
+
+ return "success";
+ }
+
+ public String enableSelected() {
+ Integer[] selected = getSelectedItems();
+
+ try {
+ Subject subject = getSubject();
+
+ List<Integer> resourceDefinitions = new ArrayList<Integer>();
+ List<Integer> groupDefinitions = new ArrayList<Integer>();
+ List<Integer> typeDefinitions = new ArrayList<Integer>();
+
+ for (Integer definitionId : selected) {
+ if (alertDefinitionManager.isTemplate(definitionId)) {
+ typeDefinitions.add(definitionId);
+ } else if (alertDefinitionManager.isGroupAlertDefinition(definitionId))
{
+ groupDefinitions.add(definitionId);
+ } else {
+ resourceDefinitions.add(definitionId);
+ }
+ }
+
+ // delete resources first
+ alertDefinitionManager.enableAlertDefinitions(subject, resourceDefinitions
+ .toArray(new Integer[resourceDefinitions.size()]));
+
+ // then delete templates and group alert defs, which are both tolerant of
missing child definitions
+ groupAlertDefinitionManager.enableGroupAlertDefinitions(subject,
groupDefinitions
+ .toArray(new Integer[groupDefinitions.size()]));
+ alertTemplateManager.removeAlertTemplates(subject,
typeDefinitions.toArray(new Integer[typeDefinitions
+ .size()]));
+
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Enable
selected alert definitions.");
+ } catch (Exception e) {
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Failed to
enable selected alert definitions.",
+ e);
+ }
+
+ return "success";
+ }
+
@Override
public DataModel getDataModel() {
if (dataModel == null) {
@@ -229,7 +307,7 @@ public class SubsystemAlertDefinitionUIBean extends SubsystemView {
protected IntExtractor<AlertDefinitionComposite> getResourceIdExtractor()
{
return RESOURCE_ID_EXTRACTOR;
}
-
+
private void getDataFromRequest() {
SubsystemAlertDefinitionUIBean outer = SubsystemAlertDefinitionUIBean.this;
outer.resourceFilter =
FacesContextUtility.getOptionalRequestParameter(FORM_PREFIX +
"resourceFilter");
@@ -255,4 +333,4 @@ public class SubsystemAlertDefinitionUIBean extends SubsystemView {
return null;
}
}
-}
\ No newline at end of file
+}
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertDefinitions.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertDefinitions.xhtml
index 2cc9a52..a1caee7 100644
---
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertDefinitions.xhtml
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertDefinitions.xhtml
@@ -189,7 +189,7 @@
<f:param name="ad"
value="#{item.original.alertDefinition.parentId}"/>
<h:outputText value="View Template" />
</h:outputLink>
-
+
<h:outputLink value="/alerts/Config.do"
rendered="#{not empty item.original.alertDefinition.groupAlertDefinition}">
<f:param name="mode" value="viewRoles"/>
<f:param name="groupId"
value="#{item.original.alertDefinition.groupAlertDefinition.resourceGroup.id}"/>
@@ -197,8 +197,8 @@
<f:param name="ad"
value="#{item.original.alertDefinition.groupAlertDefinition.id}"/>
<h:outputText value="View Group Definition" />
</h:outputLink>
-
- <h:outputText value="N/A"
+
+ <h:outputText value="N/A"
rendered="#{item.original.alertDefinition.parentId
eq 0 and empty item.original.alertDefinition.groupAlertDefinition}" />
</rich:column>
@@ -208,6 +208,12 @@
<onc:selectCommandButton
action="#{SubsystemAlertDefinitionUIBean.deleteSelected}"
value="DELETE SELECTED"
target="selectedItems" styleClass="on-pager-button buttonsmall"
rendered="#{GlobalPermissionsUIBean.superuser}" />
+ <onc:selectCommandButton
action="#{SubsystemAlertDefinitionUIBean.disableSelected}"
+ value="DISABLE SELECTED"
target="selectedItems" styleClass="on-pager-button buttonsmall"
+
rendered="#{GlobalPermissionsUIBean.superuser}" />
+ <onc:selectCommandButton
action="#{SubsystemAlertDefinitionUIBean.enableSelected}"
+ value="ENABLE SELECTED"
target="selectedItems" styleClass="on-pager-button buttonsmall"
+
rendered="#{GlobalPermissionsUIBean.superuser}" />
<ui:param name="paginationDataTableName"
value="alertDefinitionDataTable"/>
<ui:param name="paginationDataModel"
value="#{alertDefinitionDataModel}"/>
commit c06cf9c470abf7d8c1bfff7b9969ce68de607105
Author: Justin Harris <jharris(a)redhat.com>
Date: Thu Feb 25 16:28:03 2010 -0500
BZ 562816 - Fixed lazy init excepion by going through entity manager directly instead
of using the alert definition manager.
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
index f3d97c3..b0d92d4 100644
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
+++
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
@@ -22,21 +22,15 @@ package org.rhq.enterprise.gui.alert;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
+import javax.persistence.EntityManager;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.faces.FacesMessages;
-import org.jboss.seam.log.Log;
import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertDampening;
import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.enterprise.server.alert.AlertDefinitionManagerLocal;
-import org.rhq.enterprise.server.alert.AlertDefinitionUpdateException;
-import org.rhq.enterprise.server.alert.InvalidAlertDefinitionException;
/**
*
@@ -46,18 +40,12 @@ import
org.rhq.enterprise.server.alert.InvalidAlertDefinitionException;
@Name("alertUIBean")
public class AlertUIBean implements Serializable {
- @Logger
- private Log log;
- @In("#{webUser.subject}")
- private Subject subject;
- @In
- private FacesMessages facesMessages;
@In
private AlertDescriber alertDescriber;
@In
- private AlertDefinitionManagerLocal alertDefinitionManager;
- @In
private AlertDefinition alertDefinition;
+ @In
+ private EntityManager entityManager;
private List<String> alertConditions;
private String alertDampening;
@@ -78,16 +66,8 @@ public class AlertUIBean implements Serializable {
}
public String saveAlertDefinition() {
- try {
- alertDefinitionManager.updateAlertDefinition(this.subject,
- this.alertDefinition.getId(), this.alertDefinition, false);
- } catch (InvalidAlertDefinitionException e) {
- facesMessages.add("There was an error finding the requested alert
definition.");
- log.error("Invalid alert definition: " +
this.alertDefinition.toSimpleString(), e);
- } catch (AlertDefinitionUpdateException e) {
- facesMessages.add("There was an error updating the definition for "
+ this.alertDefinition.getName());
- log.error("Error updating alert definition: " +
this.alertDefinition.toSimpleString(), e);
- }
+ AlertDefinition def = entityManager.merge(this.alertDefinition);
+ entityManager.persist(def);
return null;
}
commit 2a18d950b525c722a947803b158bc885d82ecec6
Author: Justin Harris <jharris(a)redhat.com>
Date: Thu Feb 25 12:24:48 2010 -0500
Changing ui:composition to ui:decorate to get page title working properly.
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 2e9cc8b..eec04d4 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
@@ -27,7 +27,7 @@
</c:otherwise>
</c:choose>
- <ui:composition template="/rhq/layout/main.xhtml">
+ <ui:decorate template="/rhq/layout/main.xhtml">
<ui:param name="pageTitle" value="#{title}"/>
@@ -272,5 +272,5 @@
</rich:modalPanel>
</ui:define>
- </ui:composition>
+ </ui:decorate>
</html>