modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
| 29 +---
modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
| 1
modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
| 8 -
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
| 1
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
| 32 ----
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationStoreUIBean.java
| 72 ----------
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java
| 26 +--
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
| 24 ---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
| 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
| 3
10 files changed, 34 insertions(+), 167 deletions(-)
New commits:
commit cc8f2db67869ec32176c5160bc2adb195fdbb678
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 09:46:42 2010 -0400
small fix to dbsetup script data
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
index da98622..380ef0f 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
@@ -5,18 +5,18 @@
<!-- overlord-created, global, default saved searches -->
<table name="RHQ_SAVED_SEARCH">
<data ID="1"
- CONTEXT="Resource"
+ CONTEXT="RESOURCE"
NAME="Downed Platforms"
DESCRIPTION="All downed machines across the entire enterprise"
- PATTERN="down platform"
+ PATTERN="availability=down category=platform"
LAST_COMPUTE_TIME="0"
SUBJECT_ID="1"
GLOBAL="TRUE" />
<data ID="2"
- CONTEXT="Resource"
+ CONTEXT="RESOURCE"
NAME="Downed Servers"
DESCRIPTION="All downed servers across the entire enterprise"
- PATTERN="down server"
+ PATTERN="availability=down category=server"
LAST_COMPUTE_TIME="0"
SUBJECT_ID="1"
GLOBAL="TRUE" />
commit d2ce45f0122e499162151ef8e927d9d5086dc5ed
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 17:32:52 2010 -0400
remove name field from alert notifications
diff --git
a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
index 0fa4ee8..07c7590 100644
---
a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
+++
b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
@@ -75,9 +75,8 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask
{
String propertyName = "subjectId";
String senderName = "System Users";
- String name = "User Notifications";
- persist(data, propertyName, senderName, name);
+ persist(data, propertyName, senderName);
}
private void upgradeRoleNotifications() throws SQLException {
@@ -91,9 +90,8 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask
{
String propertyName = "roleId";
String senderName = "System Roles";
- String name = "Role Notifications";
- persist(data, propertyName, senderName, name);
+ persist(data, propertyName, senderName);
}
private void upgradeEmailNotifications() throws SQLException {
@@ -107,9 +105,8 @@ public class CustomAlertSenderUpgradeTask implements
DatabaseUpgradeTask {
String propertyName = "emailAddress";
String senderName = "Direct Emails";
- String name = "Email Notifications";
- persist(data, propertyName, senderName, name);
+ persist(data, propertyName, senderName);
}
private void upgradeSNMPNotifications() throws SQLException {
@@ -129,7 +126,7 @@ public class CustomAlertSenderUpgradeTask implements
DatabaseUpgradeTask {
// buffer will be 0 the very first time, since definitionId is initially -1
int configId = persistConfiguration("host", host, "port",
port, "oid", oid);
- persistNotification(alertDefinitionId, configId, "SNMP Traps",
"SNMP Notifications");
+ persistNotification(alertDefinitionId, configId, "SNMP Traps");
}
}
@@ -147,11 +144,11 @@ public class CustomAlertSenderUpgradeTask implements
DatabaseUpgradeTask {
// buffer will be 0 the very first time, since definitionId is initially -1
int configId = persistConfiguration("operation-definition-id",
operationDefinitionId, "selection-mode",
"SELF");
- persistNotification(alertDefinitionId, configId, "Resource
Operations", "Operation Invocation");
+ persistNotification(alertDefinitionId, configId, "Resource
Operations");
}
}
- private void persist(List<Object[]> data, String propertyName, String sender,
String name) throws SQLException {
+ private void persist(List<Object[]> data, String propertyName, String sender)
throws SQLException {
int definitionId = -1;
StringBuilder buffer = new StringBuilder();
for (Object[] next : data) {
@@ -162,7 +159,7 @@ public class CustomAlertSenderUpgradeTask implements
DatabaseUpgradeTask {
if (buffer.length() != 0) {
// buffer will be 0 the very first time, since definitionId is
initially -1
int configId = persistConfiguration(propertyName,
buffer.toString());
- persistNotification(definitionId, configId, sender, name);
+ persistNotification(definitionId, configId, sender);
}
buffer = new StringBuilder(); // reset for the next definitionId
}
@@ -176,7 +173,7 @@ public class CustomAlertSenderUpgradeTask implements
DatabaseUpgradeTask {
if (buffer.length() != 0) {
int configId = persistConfiguration(propertyName, buffer.toString());
- persistNotification(definitionId, configId, sender, name);
+ persistNotification(definitionId, configId, sender);
}
}
@@ -197,9 +194,9 @@ public class CustomAlertSenderUpgradeTask implements
DatabaseUpgradeTask {
return configId;
}
- private void persistNotification(int definitionId, int configId, String sender,
String name) throws SQLException {
+ private void persistNotification(int definitionId, int configId, String sender)
throws SQLException {
int notificationId = databaseType.getNextSequenceValue(connection,
"rhq_alert_notification", "id");
- String insertNotificationSQL = getInsertNotificationSQL(notificationId,
definitionId, configId, sender, name);
+ String insertNotificationSQL = getInsertNotificationSQL(notificationId,
definitionId, configId, sender);
databaseType.executeSql(connection, insertNotificationSQL);
}
@@ -214,9 +211,9 @@ public class CustomAlertSenderUpgradeTask implements
DatabaseUpgradeTask {
+ " VALUES ( " + id + ", " + configId + ",
'" + name + "', '" + value + "', 'property' )
";
}
- private String getInsertNotificationSQL(int id, int definitionId, int configId,
String sender, String name) {
- return "INSERT INTO rhq_alert_notification ( id, alert_definition_id,
sender_config_id, sender_name, display_name )" //
- + " VALUES ( " + id + ", " + definitionId + ",
" + configId + ", '" + sender + "', '" + name +
"' ) ";
+ private String getInsertNotificationSQL(int id, int definitionId, int configId,
String sender) {
+ return "INSERT INTO rhq_alert_notification ( id, alert_definition_id,
sender_config_id, sender_name )" //
+ + " VALUES ( " + id + ", " + definitionId + ",
" + configId + ", '" + sender + "' ) ";
}
}
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
index 9617057..b2db5f0 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -137,7 +137,6 @@
<column name="TEMPLATE_ID" required="false"
type="INTEGER" references="RHQ_ALERT_NOTIF_TEMPL(ID)"/>
<column name="SENDER_CONFIG_ID" required="false"
type="INTEGER" references="RHQ_CONFIG(ID)"/>
<column name="SENDER_NAME" required="true"
size="100" type="VARCHAR2" />
- <column name="DISPLAY_NAME" type="VARCHAR2"
size="100" />
</table>
</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 6974780..d028a43 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2060,7 +2060,6 @@
<schema-addColumn table="RHQ_ALERT"
column="ACK_TIME" columnType="LONG" />
<!-- TODO: this needs to change to ack_subject_name -->
<schema-addColumn table="RHQ_ALERT"
column="ACK_SUBJECT" precision="100" columnType="VARCHAR2"
/>
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION"
column="DISPLAY_NAME" precision="100" columnType="VARCHAR2"
/>
<schema-addColumn table="RHQ_ALERT_NOTIFICATION"
column="SENDER_NAME" precision="100" columnType="VARCHAR2"
/>
<schema-addColumn table="RHQ_ALERT_NOTIFICATION"
column="SENDER_CONFIG_ID" columnType="INTEGER" />
<schema-directSQL>
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
index 1a7be46..b77d8b0 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
@@ -85,9 +85,6 @@ public class AlertNotification implements Serializable {
@Column(name = "SENDER_NAME")
private String senderName;
- @Column(name = "DISPLAY_NAME")
- private String displayName;
-
protected AlertNotification() {
} // JPA spec
@@ -115,7 +112,6 @@ public class AlertNotification implements Serializable {
} else {
this.configuration = source.configuration.deepCopy(false);
}
- this.displayName = source.displayName;
this.senderName = source.senderName;
}
@@ -129,8 +125,7 @@ public class AlertNotification implements Serializable {
this.alertNotificationId = alertNotificationId;
}
- public AlertNotification(String displayName, String sender) {
- this.displayName = displayName;
+ public AlertNotification(String sender) {
this.senderName = sender;
}
@@ -147,22 +142,6 @@ public class AlertNotification implements Serializable {
this.alertDefinition = alertDefinition;
}
- public AlertNotification copyWithAlertDefintion(AlertDefinition alertDefinition,
boolean copyIds) {
- Configuration config;
- if (copyIds) {
- config = this.configuration;
- } else {
- config = this.configuration.deepCopy(false);
- }
- AlertNotification notification = new AlertNotification(alertDefinition, config);
- if (copyIds) {
- notification.id = this.id;
- }
- notification.setDisplayName(this.displayName);
- notification.setSenderName(this.senderName);
- return notification;
- }
-
public void prepareForOrphanDelete() {
this.alertDefinition = null;
}
@@ -183,14 +162,6 @@ public class AlertNotification implements Serializable {
this.configuration = configuration;
}
- public String getDisplayName() {
- return displayName;
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
public AlertNotificationTemplate getAlertNotificationTemplate() {
return alertNotificationTemplate;
}
@@ -216,7 +187,6 @@ public class AlertNotification implements Serializable {
sb.append(", id=").append(id);
sb.append(",
notificationTemplate=").append(alertNotificationTemplate);
sb.append(",
senderName='").append(senderName).append('\'');
- sb.append(",
displayName='").append(displayName).append('\'');
sb.append('}');
return sb.toString();
}
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationStoreUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationStoreUIBean.java
deleted file mode 100644
index 05e254e..0000000
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationStoreUIBean.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 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.common;
-
-import java.util.List;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.web.RequestParameter;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-(a)Scope(ScopeType.EVENT)
-@Name("alertNotificationStoreUIBean")
-public class AlertNotificationStoreUIBean {
-
- @RequestParameter("context")
- private String context;
-
- @RequestParameter("contextId")
- private Integer contextId;
-
- private AlertNotificationManagerLocal alertNotificationManager =
LookupUtil.getAlertNotificationManager();
-
- public List<AlertNotification> lookupNotifications(Subject subject) {
- if (context.equals("template")) {
- return this.alertNotificationManager.getNotificationsForTemplate(subject,
contextId);
- } else {
- return
this.alertNotificationManager.getNotificationsForAlertDefinition(subject, contextId);
- }
- }
-
- public AlertNotification addNotification(Subject subject, String senderType, String
notificationName,
- Configuration configuration) {
- if (context.equals("template")) {
- return alertNotificationManager.addAlertNotificationToTemplate(subject,
contextId, senderType,
- notificationName, configuration);
- } else {
- return this.alertNotificationManager.addAlertNotification(subject, contextId,
senderType, notificationName,
- configuration);
- }
- }
-
- public void removeNotifications(Subject subject, Integer[] notificationIds) {
- if (context.equals("template")) {
- this.alertNotificationManager.removeNotificationsFromTemplate(subject,
contextId, notificationIds);
- } else {
- this.alertNotificationManager.removeNotifications(subject, contextId,
notificationIds);
- }
- }
-}
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java
index f696c3c..80cc829 100644
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java
+++
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java
@@ -49,14 +49,16 @@ public class AlertNotificationsUIBean extends
EnterpriseFacesContextUIBean {
@RequestParameter("nid")
private Integer notificationId;
+ @RequestParameter("context")
+ private String context;
+ @RequestParameter("contextId")
+ private Integer contextId;
+
@In
private AlertNotificationManagerLocal alertNotificationManager;
- @In(create = true)
- private AlertNotificationStoreUIBean alertNotificationStoreUIBean;
private List<AlertNotification> alertNotifications;
private Set<AlertNotification> selectedNotifications;
- private String newAlertName;
private String selectedNewSender;
private AlertNotification activeNotification;
private ConfigurationDefinition activeConfigDefinition;
@@ -79,14 +81,6 @@ public class AlertNotificationsUIBean extends
EnterpriseFacesContextUIBean {
this.selectedNotifications = selectedNotifications;
}
- public String getNewAlertName() {
- return newAlertName;
- }
-
- public void setNewAlertName(String newAlertName) {
- this.newAlertName = newAlertName;
- }
-
public String getSelectedNewSender() {
return selectedNewSender;
}
@@ -136,7 +130,8 @@ public class AlertNotificationsUIBean extends
EnterpriseFacesContextUIBean {
}
public void reloadAlertNotifications() {
- this.alertNotifications =
this.alertNotificationStoreUIBean.lookupNotifications(getSubject());
+ this.alertNotifications =
this.alertNotificationManager.getNotificationsForAlertDefinition(getSubject(),
+ contextId);
}
// Sets the initial state of the bean given the requrest parameters, this allows
@@ -175,8 +170,9 @@ public class AlertNotificationsUIBean extends
EnterpriseFacesContextUIBean {
newSenderConfig = new Configuration();
}
- AlertNotification newlyCreated =
this.alertNotificationStoreUIBean.addNotification(getSubject(),
- this.selectedNewSender, this.newAlertName, newSenderConfig);
+ AlertNotification newlyCreated =
this.alertNotificationManager.addAlertNotification(getSubject(),
+ this.contextId, this.selectedNewSender, newSenderConfig);
+
this.alertNotifications.add(newlyCreated); // only add if no errors
this.activeNotification = newlyCreated;
this.selectedNotifications.clear();
@@ -194,7 +190,7 @@ public class AlertNotificationsUIBean extends
EnterpriseFacesContextUIBean {
}
public String removeSelected() {
- this.alertNotificationStoreUIBean.removeNotifications(getSubject(),
getSelectedIds());
+ this.alertNotificationManager.removeNotifications(getSubject(), contextId,
getSelectedIds());
this.alertNotifications.removeAll(this.selectedNotifications); // only remove if
no errors
this.activeNotification = null;
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
index fd83f96..74b978e 100644
---
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
@@ -52,19 +52,13 @@
fastOrderControlsVisible="false"
orderControlsVisible="false"
id="sendersList">
- <rich:column width="20%">
- <f:facet name="header">
- <h:outputText value="Name" />
- </f:facet>
- <h:outputText
value="#{alertNotification.displayName}" />
- </rich:column>
- <rich:column width="20%">
+ <rich:column width="25%">
<f:facet name="header">
<h:outputText value="Type" />
</f:facet>
<h:outputText
value="#{alertNotification.senderName}" />
</rich:column>
- <rich:column width="60%">
+ <rich:column width="75%">
<f:facet name="header">
<h:outputText value="Configuration"
/>
</f:facet>
@@ -170,20 +164,6 @@
<input type="hidden" name="contextSubId"
value="#{param.contextSubId}"/>
<div style="height: 100px;">
- <h:outputLabel for="alertNameInput"
value="Alert Notification Name:" />
- <br />
- <h:inputText id="alertNameInput"
-
value="#{alertNotificationsUIBean.newAlertName}"
- maxlength="100"
- required="true" />
-
- <h:message for="alertNameInput"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock" />
- <br /><br />
-
<h:outputLabel for="senderList" value="Alert
Sender Type:" />
<br />
<h:selectOneMenu id="senderList"
value="#{alertNotificationsUIBean.selectedNewSender}">
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 0e7682a..0897dc7 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
@@ -296,7 +296,7 @@ public class AlertNotificationManagerBean implements
AlertNotificationManagerLoc
* {@inheritDoc}
*/
public AlertNotification addAlertNotification(Subject user, int alertDefinitionId,
String senderName,
- String alertName, Configuration configuration) {
+ Configuration configuration) {
AlertDefinition definition = alertDefinitionManager.getAlertDefinition(user,
alertDefinitionId);
if (definition == null) {
@@ -307,7 +307,6 @@ public class AlertNotificationManagerBean implements
AlertNotificationManagerLoc
entityManager.persist(configuration);
AlertNotification notif = new AlertNotification(definition);
notif.setSenderName(senderName);
- notif.setDisplayName(alertName);
notif.setConfiguration(configuration);
entityManager.persist(notif);
definition.getAlertNotifications().add(notif);
@@ -485,7 +484,7 @@ public class AlertNotificationManagerBean implements
AlertNotificationManagerLoc
AlertNotificationTemplate template =
entityManager.find(AlertNotificationTemplate.class, templateId);
entityManager.persist(notificationConfiguration);
- AlertNotification alertNotification = new AlertNotification(notificationName,
sender);
+ AlertNotification alertNotification = new AlertNotification(sender);
alertNotification.setConfiguration(notificationConfiguration);
alertNotification.setAlertNotificationTemplate(template);
entityManager.persist(alertNotification);
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
index 56f1c20..9db80cc 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
@@ -65,10 +65,9 @@ public interface AlertNotificationManagerLocal {
* @param user subject of the caller
* @param alertDefinitionId Id of the alert definition
* @param senderName shortName of the {@link AlertSender}
- * @param alertName name of the new {@link AlertNotification}
* @param configuration Properties for this alert sender.
*/
- AlertNotification addAlertNotification(Subject user, int alertDefinitionId, String
senderName, String alertName,
+ AlertNotification addAlertNotification(Subject user, int alertDefinitionId, String
senderName,
Configuration configuration);
/**