modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
| 10
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
| 39 -
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
| 15
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java
| 177 --------
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java
| 90 ----
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java
| 76 ---
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java
| 86 ---
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
| 4
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java
| 105 ----
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml
| 136 ------
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml
| 146 ------
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml
| 74 ---
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
| 60 --
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
| 219 ----------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
| 68 ---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
| 7
16 files changed, 24 insertions(+), 1288 deletions(-)
New commits:
commit 33247dceb1a722507ae16190333ffe9f2b09180b
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 12:32:55 2010 -0400
fix NPE seen during very first recalculation of saved search result counts
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
index 0e015e3..db826de 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
@@ -67,7 +67,10 @@ public class SavedSearchResultCountRecalculationJob extends
AbstractStatefulJob
PageList<Resource> results =
resourceManager.findResourcesByCriteria(overlord, criteria);
totalMillis += System.currentTimeMillis();
- if (results.getTotalSize() != next.getResultCount()) {
+ // TODO: should recent count be computed at the time of update/save
for this saved search?
+ // it would obviate the need for null checking here as well as
in the UI for conditional
+ // display of the result count
+ if (next.getResultCount() == null || results.getTotalSize() !=
next.getResultCount()) {
next.setResultCount((long) results.getTotalSize());
savedSearchManager.updateSavedSearch(overlord, next);
updated++;
@@ -76,7 +79,7 @@ public class SavedSearchResultCountRecalculationJob extends
AbstractStatefulJob
} catch (Throwable t) {
// TODO: mark this saved search as "broken" so that future
computation is suppressed for it
errors++;
- LOG.error("Could not calculate result count for
SavedSearch[name=" + next.getName() + ", patter='"
+ LOG.error("Could not calculate result count for
SavedSearch[name=" + next.getName() + ", pattern='"
+ next.getPattern() + "']");
}
}
commit 8bdaceac79897f786743a3607f287581565c9b6d
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 12:32:37 2010 -0400
removal of alert notification templates
* charles explained they will not be released in their current form
* reuse occurs at the alert definitions level (resource/group/type), not a component
thereof
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 b2db5f0..145b8e2 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -119,16 +119,6 @@
</index>
</table>
- <table name="RHQ_ALERT_NOTIF_TEMPL"
tablespace="@@@LARGE_TABLESPACE_FOR_DATA@@@"
- storage-options="freelists 5" cache="true"
logging="false">
- <column name="ID" default="sequence-only"
initial="10001"
- primarykey="true" required="true"
type="INTEGER"/>
- <column name="CTIME" required="true"
type="LONG"/>
- <column name="MTIME" required="true"
type="LONG"/>
- <column name="NAME" required="true" size="100"
type="VARCHAR2"/>
- <column name="DESCRIPTION" required="false"
size="250" type="VARCHAR2"/>
- </table>
-
<table name="RHQ_ALERT_NOTIFICATION"
tablespace="@@@LARGE_TABLESPACE_FOR_DATA@@@"
storage-options="freelists 5" cache="true"
logging="false">
<column name="ID" default="sequence-only"
initial="10001"
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 d028a43..d97a230 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2058,8 +2058,9 @@
<schemaSpec version="2.70">
<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"
/>
+ </schemaSpec>
+ <schemaSpec version="2.70.1">
<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>
@@ -2071,35 +2072,7 @@
</statement>
</schema-directSQL>
</schemaSpec>
- <schemaSpec version="2.70.1">
- <schema-createSequence name="RHQ_ALERT_NOTIF_TEMPL_ID_SEQ"
initial="10001" />
- <schema-directSQL>
- <statement desc="Creating table
RHQ_ALERT_NOTIF_TEMPL">
- CREATE TABLE RHQ_ALERT_NOTIF_TEMPL ( ID INTEGER PRIMARY KEY )
- </statement>
- </schema-directSQL>
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL"
column="ID" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL"
column="CTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL"
column="CTIME" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL"
column="MTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL"
column="MTIME" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL"
column="NAME" precision="100" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL"
column="NAME" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL"
column="DESCRIPTION" precision="250" columnType="VARCHAR2"
/>
- </schemaSpec>
<schemaSpec version="2.70.2">
- <!-- add structures for alert notification templates -->
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION"
column="TEMPLATE_ID" columnType="INTEGER" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_AN_TEMPLATE_ID_FK
- FOREIGN KEY (TEMPLATE_ID)
- REFERENCES RHQ_ALERT_NOTIF_TEMPL (ID)
- </statement>
- </schema-directSQL>
- </schemaSpec>
- <schemaSpec version="2.70.3">
<!-- turn first-class notification data into configuration objects for
custom alert senders -->
<schema-alterColumn table="RHQ_ALERT_NOTIFICATION"
column="NOTIFICATION_TYPE" nullable="TRUE" />
<schema-javaTask className="CustomAlertSenderUpgradeTask"
/>
@@ -2110,7 +2083,7 @@
</schema-directSQL>
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION"
column="NOTIFICATION_TYPE" />
</schemaSpec>
- <schemaSpec version="2.70.4">
+ <schemaSpec version="2.70.3">
<!-- remove first-class alert notification structures from definition
side of the model-->
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION"
column="snmp_host" />
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION"
column="snmp_port" />
@@ -2120,19 +2093,19 @@
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION"
column="subject_id" />
<schema-deleteColumn table="RHQ_ALERT_DEFINITION"
column="operation_def_id" />
</schemaSpec>
- <schemaSpec version="2.70.5">
+ <schemaSpec version="2.70.4">
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG"
column="roles" />
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG"
column="subjects" />
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG"
column="emails" />
</schemaSpec>
- <schemaSpec version="2.70.6">
+ <schemaSpec version="2.70.5">
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG"
column="SENDER" columnType="VARCHAR2" precision="200" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG"
column="RESULT_STATE" columnType="VARCHAR2" precision="20"
/>
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG"
column="MESSAGE" columnType="VARCHAR2" precision="255"
/>
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG"
column="ALL_EMAILS" columnType="VARCHAR2" precision="4000"
/>
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG"
column="EMAILS_FAILED" columnType="VARCHAR2"
precision="4000" />
</schemaSpec>
- <schemaSpec version="2.70.7">
+ <schemaSpec version="2.70.6">
<schema-directSQL>
<statement>
DROP INDEX RHQ_ALERT_IDX_ALERT
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 b77d8b0..b9c0401 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
@@ -49,7 +49,7 @@ import org.rhq.core.domain.configuration.Configuration;
@NamedQueries( {
@NamedQuery(name = AlertNotification.DELETE_BY_ID, query = "DELETE FROM
AlertNotification an WHERE an.id IN ( :ids )"),
@NamedQuery(name = AlertNotification.QUERY_DELETE_BY_RESOURCES, query = "DELETE
FROM AlertNotification an WHERE an.alertDefinition IN ( SELECT ad FROM AlertDefinition ad
WHERE ad.resource.id IN ( :resourceIds ) )"),
- @NamedQuery(name = AlertNotification.QUERY_DELETE_ORPHANED, query = "DELETE FROM
AlertNotification an WHERE an.alertDefinition IS NULL AND an.alertNotificationTemplate IS
NULL") })
+ @NamedQuery(name = AlertNotification.QUERY_DELETE_ORPHANED, query = "DELETE FROM
AlertNotification an WHERE an.alertDefinition IS NULL") })
@SequenceGenerator(name = "RHQ_ALERT_NOTIFICATION_ID_SEQ", sequenceName =
"RHQ_ALERT_NOTIFICATION_ID_SEQ")
@Table(name = "RHQ_ALERT_NOTIFICATION")
public class AlertNotification implements Serializable {
@@ -74,10 +74,6 @@ public class AlertNotification implements Serializable {
@ManyToOne
private AlertDefinition alertDefinition;
- @JoinColumn(name = "TEMPLATE_ID")
- @ManyToOne
- private AlertNotificationTemplate alertNotificationTemplate;
-
@JoinColumn(name = "SENDER_CONFIG_ID", referencedColumnName =
"ID")
@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
private Configuration configuration;
@@ -162,14 +158,6 @@ public class AlertNotification implements Serializable {
this.configuration = configuration;
}
- public AlertNotificationTemplate getAlertNotificationTemplate() {
- return alertNotificationTemplate;
- }
-
- public void setAlertNotificationTemplate(AlertNotificationTemplate
alertNotificationTemplate) {
- this.alertNotificationTemplate = alertNotificationTemplate;
- }
-
public int getAlertDefinitionId() {
return alertDefinitionId;
}
@@ -185,7 +173,6 @@ public class AlertNotification implements Serializable {
sb.append("{alertDefinitionId=").append(alertDefinitionId);
sb.append(", alertNotificationId=").append(alertNotificationId);
sb.append(", id=").append(id);
- sb.append(",
notificationTemplate=").append(alertNotificationTemplate);
sb.append(",
senderName='").append(senderName).append('\'');
sb.append('}');
return sb.toString();
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java
deleted file mode 100644
index df64a54..0000000
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java
+++ /dev/null
@@ -1,177 +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.core.domain.alert.notification;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.PrePersist;
-import javax.persistence.PreUpdate;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
-
-import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.group.ResourceGroup;
-
-/**
- * An {@link AlertNotificationTemplate} is a group of {@link AlertNotification}. This can
be used to create
- * pre-configured sets of notifications which can then be applied to all types of {@link
AlertDefinition}s -
- * those at the {@link Resource}-level, {@link ResourceGroup}-level, and {@link
ResourceType}-level (a.k.a
- * Alert Template).
- *
- * @author Heiko W. Rupp
- */
-
-@NamedQueries( {
- @NamedQuery(name = AlertNotificationTemplate.FIND_BY_NAME, query = "SELECT t
FROM AlertNotificationTemplate t WHERE t.name = :name"),
- @NamedQuery(name = AlertNotificationTemplate.FIND_ALL, query = "SELECT t FROM
AlertNotificationTemplate AS t") })
-@Entity
-@Table(name = "RHQ_ALERT_NOTIF_TEMPL")
-@SequenceGenerator(name = "RHQ_ALERT_NOTIF_TEMPL_ID_SEQ", sequenceName =
"RHQ_ALERT_NOTIF_TEMPL_ID_SEQ")
-public class AlertNotificationTemplate implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final String FIND_BY_NAME =
"AlertNotificationTemplate.findByName";
- public static final String FIND_ALL = "AlertNotificationTemplate.findAll";
-
- @Column(name = "ID", nullable = false)
- @GeneratedValue(generator = "RHQ_ALERT_NOTIF_TEMPL_ID_SEQ")
- @Id
- private int id;
-
- @Column(name = "CTIME")
- private long ctime;
-
- @Column(name = "MTIME")
- private long mtime;
-
- @Column(name = "NAME")
- private String name;
-
- @Column(name = "DESCRIPTION")
- private String description;
-
- @OneToMany(mappedBy = "alertNotificationTemplate", cascade =
CascadeType.ALL)
- List<AlertNotification> notifications = new
ArrayList<AlertNotification>();
-
- protected AlertNotificationTemplate() {
- // for JPA
- }
-
- public AlertNotificationTemplate(String name, String description) {
- this.name = name;
- this.description = description;
- }
-
- public int getId() {
- return this.id;
- }
-
- public long getCtime() {
- return ctime;
- }
-
- public long getMtime() {
- return mtime;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public List<AlertNotification> getNotifications() {
- return notifications;
- }
-
- public void setNotifications(List<AlertNotification> notifications) {
- this.notifications = notifications;
- }
-
- public List<AlertNotification> addNotification(AlertNotification notification)
{
- this.notifications.add(notification);
- return this.notifications;
- }
-
- @PrePersist
- void onPersist() {
- this.mtime = this.ctime = System.currentTimeMillis();
- }
-
- @PreUpdate
- void onPreUpdate() {
- this.mtime = System.currentTimeMillis();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
-
- AlertNotificationTemplate that = (AlertNotificationTemplate) o;
-
- if (description != null ? !description.equals(that.description) :
that.description != null)
- return false;
- return name.equals(that.name);
-
- }
-
- @Override
- public int hashCode() {
- int result = name.hashCode();
- result = 31 * result + (description != null ? description.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("NotificationTemplate");
- sb.append("{id=").append(id);
- sb.append(", name='").append(name).append('\'');
- sb.append(",
description='").append(description).append('\'');
- sb.append('}');
- return sb.toString();
- }
-}
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java
deleted file mode 100644
index c3bad26..0000000
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java
+++ /dev/null
@@ -1,90 +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.admin.alert;
-
-import javax.faces.application.FacesMessage;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.PAGE)
-@Name("AlertNotificationTemplateDetailsUIBean")
-public class AlertNotificationTemplateDetailsUIBean extends EnterpriseFacesContextUIBean
{
-
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- private AlertNotificationTemplate template;
-
- private void loadTemplate() {
- if (template == null) {
- int templateId =
FacesContextUtility.getRequiredRequestParameter("templateId", Integer.class);
- template =
alertNotificationManager.getAlertNotificationTemplate(getSubject(), templateId);
- }
- }
-
- public AlertNotificationTemplate getTemplate() {
- loadTemplate();
-
- return template;
- }
-
- public int getNotificationCount() {
- loadTemplate();
-
- return template.getNotifications().size();
- }
-
- public String edit() {
- return OUTCOME_EDIT;
- }
-
- public String editNotifications() {
- return OUTCOME_EDIT;
- }
-
- public String save() {
- try {
- alertNotificationManager.updateNotificationTemplate(getSubject(),
template.getId(), template.getName(),
- template.getDescription());
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Alert notification template was successfully modified.");
- } catch (Throwable t) {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Error while saving alert notification template: " +
t.getMessage());
- }
-
- return OUTCOME_SAVE;
- }
-
- public String cancel() {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Alert notification template modifications were cancelled.");
-
- return OUTCOME_CANCELLED;
- }
-
-}
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java
deleted file mode 100644
index dd63d29..0000000
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java
+++ /dev/null
@@ -1,76 +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.admin.alert;
-
-import java.util.List;
-
-import javax.faces.application.FacesMessage;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.util.PageControl;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.core.gui.util.StringUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.PAGE)
-@Name("ListAlertNotificationTemplatesUIBean")
-public class ListAlertNotificationTemplatesUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- public PageList<AlertNotificationTemplate> getAlertNotificationTemplates() {
- List<AlertNotificationTemplate> templates =
alertNotificationManager.listNotificationTemplates(getSubject());
- return new PageList<AlertNotificationTemplate>(templates, new
PageControl(0, templates.size()));
- }
-
- public String deleteSelectedAlertNotificationTemplates() {
- try {
- Subject subject = getSubject();
- String[] selectedNotificationTemplates = getSelectedNotificationTemplates();
- Integer[] selectedNotificationTemplateIds =
StringUtility.getIntegerArray(selectedNotificationTemplates);
- int deleted = alertNotificationManager
- .deleteNotificationTemplates(subject, selectedNotificationTemplateIds);
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Deleted
" + deleted
- + " alert notification templates");
- } catch (Throwable t) {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Deletion
failed: " + t.getMessage());
- }
-
- return OUTCOME_SUCCESS;
- }
-
- public String createNewAlertNotificationTemplate() {
- return OUTCOME_CREATE;
- }
-
- private String[] getSelectedNotificationTemplates() {
- String[] results =
FacesContextUtility.getRequest().getParameterValues("selectedNotificationTemplates");
- return results;
- }
-
-}
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java
deleted file mode 100644
index b2e0b07..0000000
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java
+++ /dev/null
@@ -1,86 +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.admin.alert;
-
-import java.util.ArrayList;
-
-import javax.faces.application.FacesMessage;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.PAGE)
-@Name("NewAlertNotificationTemplateUIBean")
-public class NewAlertNotificationTemplateUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- private String name;
- private String description;
-
- private int createdTemplateId; // will be set as a result of create(), used for JSF
navigation rules
-
- public String create() {
- try {
- AlertNotificationTemplate template =
alertNotificationManager.createNotificationTemplate(this.name,
- this.description, new ArrayList<AlertNotification>(), true);
- createdTemplateId = template.getId();
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Created new
alert notification template");
- } catch (Throwable t) {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Creation
failed: " + t.getMessage());
- }
-
- return OUTCOME_SUCCESS;
- }
-
- public String cancel() {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Template
creation cancelled.");
- return OUTCOME_CANCELLED;
- }
-
- public int getCreatedTemplateId() {
- return createdTemplateId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
-}
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
index 758383a..eb7d500 100644
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
+++
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
@@ -59,13 +59,15 @@ public class CustomContentUIBean extends EnterpriseFacesContextUIBean
{
AlertNotification activeNotification =
alertNotificationManager.getAlertNotification(getSubject(),
alertNotificationId);
+ if (activeNotification == null) {
+ return; // this was just removed on the previous request
+ }
String senderName = activeNotification.getSenderName();
AlertSenderInfo info =
alertNotificationManager.getAlertInfoForSender(senderName);
if (info != null && info.getUiSnippetUrl() != null) {
this.contentUrl = info.getUiSnippetUrl().toString();
- //this.contentUrl = "rhq/custom/plugin/alert/" + senderName +
"/" + info.getUiSnippetShortPath();
}
String backingBeanName =
alertNotificationManager.getBackingBeanNameForSender(senderName);
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java
deleted file mode 100644
index 5b7cbeb..0000000
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java
+++ /dev/null
@@ -1,105 +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 java.util.Map;
-import java.util.TreeMap;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.EVENT)
-@Name("definitionNotificationsUIBean")
-public class DefinitionNotificationsUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationsUIBean alertNotificationsUIBean;
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- private String selectedTemplate;
- private Boolean clearExistingNotifications;
- private Map<String, String> notificationTemplates;
-
- public String getSelectedTemplate() {
- return selectedTemplate;
- }
-
- public void setSelectedTemplate(String selectedTemplate) {
- this.selectedTemplate = selectedTemplate;
- }
-
- public Boolean getClearExistingNotifications() {
- return clearExistingNotifications;
- }
-
- public void setClearExistingNotifications(Boolean clearExistingNotifications) {
- this.clearExistingNotifications = clearExistingNotifications;
- }
-
- public Map<String, String> getNotificationTemplates() {
- return this.notificationTemplates;
- }
-
- public String addAlertSenderFromTemplate() {
- int alertDefinitionId =
FacesContextUtility.getRequiredRequestParameter("ad", Integer.class);
-
this.alertNotificationManager.applyNotificationTemplateToAlertDefinition(getSelectedTemplate(),
- alertDefinitionId, getClearExistingNotifications());
- this.alertNotificationsUIBean.reloadAlertNotifications();
- return "success";
- }
-
- @Create
- public void init() {
- this.notificationTemplates = lookupNotificationTemplates();
- }
-
- private Map<String, String> lookupNotificationTemplates() {
- Map<String, String> result = new TreeMap<String, String>();
- List<AlertNotificationTemplate> templates = this.alertNotificationManager
- .listNotificationTemplates(getSubject());
-
- for (AlertNotificationTemplate template : templates) {
- String displayName = getNotificationDisplayName(template);
- result.put(displayName, template.getName()); // displayed text, option value
- }
-
- return result;
- }
-
- private String getNotificationDisplayName(AlertNotificationTemplate template) {
- StringBuilder builder = new StringBuilder(template.getName());
-
- builder.append(" (");
- builder.append(template.getDescription());
- builder.append(")");
-
- return builder.toString();
- }
-
-}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml
deleted file mode 100644
index 69bfcb3..0000000
---
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml
+++ /dev/null
@@ -1,136 +0,0 @@
-<?xml version="1.0"?>
-
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html
xmlns="http://www.w3.org/1999/xhtml"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:c="http://java.sun.com/jstl/core"
-
xmlns:onc="http://jboss.org/on/component"
-
xmlns:onf="http://jboss.org/on/function"
-
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
-
xmlns:rich="http://richfaces.ajax4jsf.org/rich">
-
-<ui:composition template="/rhq/layout/main.xhtml">
-
- <ui:param name="pageTitle" value="Alert Notification Template
Details"/>
-
- <ui:define name="breadcrumbs">
- <h:outputLink
value="/rhq/admin/alert/template/notification/list.xhtml">
- <h:outputText value="Alert Notification Templates" />
- </h:outputLink>
- <h:outputText value=" > " />
- <h:outputLink
value="/rhq/admin/alert/template/notification/details.xhtml">
- <f:param name="templateId"
value="#{AlertNotificationTemplateDetailsUIBean.template.id}" />
- <f:param name="mode" value="view" />
- <h:outputText value="Details for
'#{AlertNotificationTemplateDetailsUIBean.template.name}'" />
- </h:outputLink>
- </ui:define>
-
- <ui:define name="body">
-
- <ui:param name="mode" value="#{param.mode}" />
-
- <br/>
- <h:messages showDetail="true"
- globalOnly="true"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock"
- layout="table" />
-
- <h:form id="alertNotificationTemplateDetailsForm">
-
- <input type="hidden" name="templateId"
value="#{param.templateId}" />
- <input type="hidden" name="mode"
value="#{param.mode}" />
-
- <rich:panel>
- <f:facet name="header">
- General Properties
- </f:facet>
- <table width="100%">
- <tr>
- <td align="right" style="white-space:
no-wrap;"><b>Name<span
class="required-marker-text">*</span>:</b></td>
- <td align="left">
- <h:inputText rendered="${mode eq 'edit'}"
value="#{AlertNotificationTemplateDetailsUIBean.template.name}" />
- <h:outputText rendered="${mode ne 'edit'}"
value="#{AlertNotificationTemplateDetailsUIBean.template.name}" />
- </td>
- </tr>
- <tr>
- <td align="right" style="white-space:
no-wrap;"><b>Description:</b></td>
- <td align="left">
- <h:inputText rendered="${mode eq 'edit'}"
value="#{AlertNotificationTemplateDetailsUIBean.template.description}" />
- <h:outputText rendered="${mode ne 'edit'}"
value="#{AlertNotificationTemplateDetailsUIBean.template.description}" />
- </td>
- </tr>
- <tr>
- <td align="right" style="white-space:
no-wrap;"><b>Date Created:</b></td>
- <td align="left">
- <h:outputText
value="#{AlertNotificationTemplateDetailsUIBean.template.ctime}">
- <f:converter converterId="UserDateTimeConverter"
/>
- </h:outputText>
- </td>
- </tr>
- <tr>
- <td align="right" style="white-space:
no-wrap;"><b>Last Modified:</b></td>
- <td align="left">
- <h:outputText
value="#{AlertNotificationTemplateDetailsUIBean.template.mtime}">
- <f:converter converterId="UserDateTimeConverter"
/>
- </h:outputText>
- </td>
- </tr>
- </table>
- <h:panelGroup layout="block">
- <h:panelGrid columns="3" styleClass="buttons-table"
columnClasses="button-cell" >
- <h:commandButton
action="#{AlertNotificationTemplateDetailsUIBean.edit}"
- value="EDIT" styleClass="buttonmed"
id="editPropertiesButton"
- rendered="${mode ne 'edit'}"/>
- <h:commandButton
action="#{AlertNotificationTemplateDetailsUIBean.save}"
- value="SAVE" styleClass="buttonmed"
id="saveButton"
- rendered="${mode eq 'edit'}"/>
- <h:commandButton
action="#{AlertNotificationTemplateDetailsUIBean.cancel}"
- value="CANCEL"
styleClass="buttonmed" id="cancelButton" immediate="true"
- rendered="${mode eq 'edit'}"/>
- </h:panelGrid>
- </h:panelGroup>
- </rich:panel>
- <br/>
- <rich:panel rendered="${mode ne 'edit'}">
- <f:facet name="header">
- Notification Actions
- </f:facet>
- <table width="100%">
- <tr>
- <td align="right" style="white-space: no-wrap;"
width="20%"><b>Sender Info:</b></td>
- <td align="left">
- <h:outputText
value="#{AlertNotificationTemplateDetailsUIBean.notificationCount} " />
- <h:outputText
value="${msg['alert.current.detail.notify.Message']}" />
- </td>
- </tr>
- </table>
- <h:panelGroup layout="block">
- <h:panelGrid columns="3" styleClass="buttons-table"
columnClasses="button-cell" >
- <h:commandButton
action="#{AlertNotificationTemplateDetailsUIBean.editNotifications}"
- value="EDIT" styleClass="buttonmed"
id="editNotificationsButton" />
- </h:panelGrid>
- </h:panelGroup>
- </rich:panel>
-
- <ui:remove>
- <ui:include src="/rhq/common/alert/notification/details.xhtml"
- rendered="${mode eq 'edit'}">
- <ui:param name="redirect"
value="/rhq/admin/alert/template/notification/details.xhtml?mode=view&templateId=#{param.templateId}"
/>
- </ui:include>
- </ui:remove>
-
- </h:form>
-
- </ui:define>
-
-</ui:composition>
-
-</html>
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml
deleted file mode 100644
index 3b2c868..0000000
---
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml
+++ /dev/null
@@ -1,146 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<html
xmlns="http://www.w3.org/1999/xhtml"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:c="http://java.sun.com/jstl/core"
-
xmlns:onc="http://jboss.org/on/component"
-
xmlns:a4j="http://richfaces.org/a4j"
-
xmlns:rich="http://richfaces.ajax4jsf.org/rich">
-
-<ui:composition template="/rhq/layout/main.xhtml">
-
- <ui:param name="pageTitle" value="List Alert Notification
Templates"/>
-
- <ui:define name="metaHeaders">
- <style>
- #senderName {
- display: none;
- }
- </style>
- </ui:define>
-
- <ui:define name="breadcrumbs">
- <h:outputLink
value="/rhq/admin/alert/template/notification/list.xhtml">
- <h:outputText value="Alert Notification Templates" />
- </h:outputLink>
- </ui:define>
-
- <ui:define name="body">
- <br/>
- <h:messages showDetail="true"
- globalOnly="true"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock"
- layout="table" />
-
- <h:form id="listAlertNotificationTemplatesForm">
- <rich:panel>
- <f:facet name="header">
- <h:outputText value="Alert Notification Templates"/>
- </f:facet>
-
- <h:panelGrid columns="1" styleClass="data-table">
- <h:outputText value="*Templates are groups of notifications that can
be applied to alert definitions en masse" />
- <br/>
-
- <ui:param name="notificationTemplateDataModel"
value="#{ListAlertNotificationTemplatesUIBean.alertNotificationTemplates}"/>
- <rich:dataTable id="notificationTemplateDataModel"
- rows="0"
- value="#{notificationTemplateDataModel}"
- var="notificationTemplate"
- width="100%"
- columnsWidth="1%, 30%, 40%, 15%, 15%"
- styleClass="resources-table"
- headerClass="tableRowHeader"
- footerClass="on-pager-footer"
-
onRowMouseOver="this.style.backgroundColor='#E7E7E7'"
-
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
-
- <f:facet name="PageControlView">
- <onc:paginationControl id="NONE" />
- </f:facet>
-
- <rich:column>
- <f:facet name="header">
- <onc:allSelect target="selectedNotificationTemplates"
/>
- </f:facet>
-
- <onc:select name="selectedNotificationTemplates"
value="#{notificationTemplate.id}" />
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="name">
- <h:outputText styleClass="headerText"
value="Name" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputLink
value="/rhq/admin/alert/template/notification/details.xhtml">
- <f:param name="templateId"
value="#{notificationTemplate.id}" />
- <f:param name="mode" value="view" />
- <h:outputText value="#{notificationTemplate.name}"
/>
- </h:outputLink>
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="description">
- <h:outputText styleClass="headerText"
value="Description" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputText value="#{notificationTemplate.description}"
/>
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="ctime">
- <h:outputText styleClass="headerText"
value="Created" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputText value="#{notificationTemplate.ctime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="mtime">
- <h:outputText styleClass="headerText"
value="Last Modified" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputText value="#{notificationTemplate.mtime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </rich:column>
-
- <f:facet name="footer">
- <rich:columnGroup>
- <rich:column colspan="5" width="100%">
- <h:commandButton
action="#{ListAlertNotificationTemplatesUIBean.createNewAlertNotificationTemplate}"
- value="CREATE NEW"
styleClass="on-pager-button buttonsmall"
-
rendered="#{GlobalPermissionsUIBean.inventory}" />
- <onc:selectCommandButton
action="#{ListAlertNotificationTemplatesUIBean.deleteSelectedAlertNotificationTemplates}"
- value="DELETE SELECTED"
target="selectedNotificationTemplates" styleClass="on-pager-button
buttonsmall"
-
rendered="#{GlobalPermissionsUIBean.inventory}" />
- </rich:column>
- </rich:columnGroup>
- </f:facet>
-
- <h:outputText value="Templates are groups of preconfigured alert
notifications that can later be applied to alert definitions" />
-
- </rich:dataTable>
- </h:panelGrid>
- </rich:panel>
- </h:form>
-
- </ui:define>
-</ui:composition>
-
-</html>
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml
deleted file mode 100644
index 25862c1..0000000
---
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0"?>
-
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html
xmlns="http://www.w3.org/1999/xhtml"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:c="http://java.sun.com/jstl/core"
-
xmlns:onc="http://jboss.org/on/component"
-
xmlns:onf="http://jboss.org/on/function"
-
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
-
xmlns:rich="http://richfaces.ajax4jsf.org/rich">
-
-<ui:composition template="/rhq/layout/main.xhtml">
-
- <ui:param name="pageTitle" value="Create New Alert Notification
Template"/>
-
- <ui:define name="breadcrumbs">
- <h:outputLink
value="/rhq/admin/alert/template/notification/list.xhtml">
- <h:outputText value="Alert Notification Templates" />
- </h:outputLink>
- <h:outputText value=" > " />
- <h:outputLink
value="/rhq/admin/alert/template/notification/new.xhtml">
- <h:outputText value="Create New" />
- </h:outputLink>
- </ui:define>
-
- <ui:define name="body">
-
- <h:form>
-
- <rich:panel>
-
- <f:facet name="header">
- General Properties
- </f:facet>
-
- <table>
- <tr>
- <td align="right"><b>Name<span
class="required-marker-text">*</span>:</b></td>
- <td align="left">
- <h:inputText
value="#{NewAlertNotificationTemplateUIBean.name}" size="60"
maxlength="100" />
- </td>
- </tr>
- <tr>
- <td
align="right"><b>Description:</b></td>
- <td align="left">
- <h:inputText
value="#{NewAlertNotificationTemplateUIBean.description}" size="60"
maxlength="250" />
- </td>
- </tr>
- </table>
-
- </rich:panel>
-
- <h:panelGroup layout="block" styleClass="BlockContent">
- <h:panelGrid columns="2" styleClass="buttons-table"
columnClasses="button-cell">
- <h:commandButton
action="#{NewAlertNotificationTemplateUIBean.create}"
- value="CREATE"
styleClass="buttonmed"/>
- <h:commandButton
action="#{NewAlertNotificationTemplateUIBean.cancel}"
- immediate="true"
- value="CANCEL"
styleClass="buttonmed"/>
- </h:panelGrid>
- </h:panelGroup>
-
- </h:form>
-
- </ui:define>
-
-</ui:composition>
-
-</html>
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 74b978e..0c25391 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
@@ -27,10 +27,8 @@
<ui:define name="body">
<a4j:keepAlive beanName="AlertNotificationContextUIBean" />
- <a4j:keepAlive beanName="alertNotificationStoreUIBean" />
<a4j:keepAlive beanName="alertNotificationsUIBean" />
<a4j:keepAlive beanName="customContentUIBean" />
- <a4j:keepAlive beanName="definitionNotificationsUIBean" />
<rich:panel id="existingAlertsPanel">
@@ -98,15 +96,6 @@
operation="show"
event="onclick" />
</h:outputLink>
- <ui:remove>
- <h:outputLink id="addAlertTemplateLink"
styleClass="buttonmed" value="#" rendered="#{param.context ne
'template'}">
- <h:outputText value="Import Templates" />
- <rich:componentControl
for="addAlertFromTemplatePanel"
-
attachTo="addAlertTemplateLink"
- operation="show"
- event="onclick" />
- </h:outputLink>
- </ui:remove>
<h:commandButton id="removeAlertButton"
value="Remove Selected"
action="#{alertNotificationsUIBean.removeSelected}"
@@ -185,55 +174,6 @@
</h:form>
</rich:panel>
</rich:modalPanel>
-
-
- <rich:modalPanel id="addAlertFromTemplatePanel"
moveable="false" autosized="true">
- <rich:panel id="importTemplatesPanel">
- <f:facet name="header">
- <h:outputText value="Import Notifications From Template"
style="white-space: nowrap;"/>
- </f:facet>
-
- <h:form id="newNotificationsFromTemplateForm">
- <input type="hidden" name="ad"
value="#{param.contextId}"/>
- <input type="hidden" name="context"
value="#{param.context}"/>
- <input type="hidden" name="contextId"
value="#{param.contextId}"/>
- <input type="hidden" name="contextSubId"
value="#{param.contextSubId}"/>
-
- <rich:panel
rendered="#{definitionNotificationsUIBean.notificationTemplates.size ne 0}">
- <div style="height: 100px;">
- <h:selectOneMenu id="templateList"
value="#{definitionNotificationsUIBean.selectedTemplate}">
- <f:selectItems
value="#{definitionNotificationsUIBean.notificationTemplates}"/>
- </h:selectOneMenu>
-
- <br/>
-
- <h:selectBooleanCheckbox title="clearExisting"
value="#{definitionNotificationsUIBean.clearExistingNotifications}"/>
- <h:outputText value="Clear existing
notifications"/>
- </div>
- </rich:panel>
-
- <rich:panel
rendered="#{definitionNotificationsUIBean.notificationTemplates.size eq 0}">
- <div style="height: 100px;">
- No Alert Notification Templates have been defined
yet.<br/>
- Please create some in Administration -> System Configuration
-> Alert Notification Templates
- </div>
- </rich:panel>
-
- <h:panelGrid columns="4"
styleClass="buttons-table" columnClasses="button-cell">
- <a4j:commandButton value="OK"
action="#{definitionNotificationsUIBean.addAlertSenderFromTemplate}"
- styleClass="buttonmed"
id="addTemplateButton"
- reRender="sendersList"
-
rendered="#{definitionNotificationsUIBean.notificationTemplates.size ne 0}">
- <rich:componentControl
for="addAlertFromTemplatePanel" attachTo="addTemplateButton"
operation="hide" event="onclick" />
- </a4j:commandButton>
- <h:outputLink id="alertTemplateCancelLink"
styleClass="buttonmed" value="#" style="float: right; margin:
10px;">
- <h:outputText value="Cancel" />
- <rich:componentControl
for="addAlertFromTemplatePanel" attachTo="alertTemplateCancelLink"
operation="hide" event="onclick" />
- </h:outputLink>
- </h:panelGrid>
- </h:form>
- </rich:panel>
- </rich:modalPanel>
</ui:define>
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 0897dc7..3a9a56c 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
@@ -27,7 +27,6 @@ import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@@ -38,7 +37,6 @@ import
org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertDefinitionContext;
import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.configuration.Configuration;
@@ -48,7 +46,6 @@ import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
-import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.plugin.ServerPluginsLocal;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderInfo;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager;
@@ -152,7 +149,9 @@ public class AlertNotificationManagerBean implements
AlertNotificationManagerLoc
try {
bb.internalCleanup();
} catch (Throwable t) {
- LOG.error("removeNotifications, calling
backingBean.internalCleanup() resulted in " + t.getMessage());
+ LOG
+ .error("removeNotifications, calling
backingBean.internalCleanup() resulted in " + t.getMessage(),
+ t);
}
}
@@ -163,30 +162,6 @@ public class AlertNotificationManagerBean implements
AlertNotificationManagerLoc
return removed;
}
- public int removeNotificationsFromTemplate(Subject subject, int templateId, Integer[]
notificationIds) {
- if ((notificationIds == null) || (notificationIds.length == 0)) {
- return 0;
- }
-
- AlertNotificationTemplate templ =
entityManager.find(AlertNotificationTemplate.class, templateId);
- Set<Integer> notificationIdSet = new
HashSet<Integer>(Arrays.asList(notificationIds));
- List<AlertNotification> notifications = templ.getNotifications();
- List<AlertNotification> toBeRemoved = new
ArrayList<AlertNotification>();
-
- int removed = 0;
- for (AlertNotification notification : notifications) {
- if (notificationIdSet.contains(notification.getId())) {
- toBeRemoved.add(notification);
- removed--;
- }
- }
-
- templ.getNotifications().removeAll(toBeRemoved);
-
- return removed;
-
- }
-
public int purgeOrphanedAlertNotifications() {
Query purgeQuery =
entityManager.createNamedQuery(AlertNotification.QUERY_DELETE_ORPHANED);
return purgeQuery.executeUpdate();
@@ -350,191 +325,15 @@ public class AlertNotificationManagerBean implements
AlertNotificationManagerLoc
entityManager.flush();
}
- /**
- * Take the passed NotificationTemplate and apply its Notifications to the passed
AlertDefinition
- * @param templateName name of a pre-defined alert NotificationTemplate
- * @param alertDefinitionId id of an AlertDefinition on which the template should be
applied
- * @param removeOldNotifications Shall old Notifications on the Definition be
removed?
- */
- public void applyNotificationTemplateToAlertDefinition(String templateName, int
alertDefinitionId,
- boolean removeOldNotifications) {
-
- AlertNotificationTemplate template =
getNotificationTemplateByName(templateName);
-
- AlertDefinition definition = getDetachedAlertDefinition(alertDefinitionId);
-
- applyNotificationTemplateToAlertDefinition(template, definition,
removeOldNotifications);
- }
-
- private AlertNotificationTemplate getNotificationTemplateByName(String templateName)
{
- Query q =
entityManager.createNamedQuery(AlertNotificationTemplate.FIND_BY_NAME);
- q.setParameter("name", templateName);
- AlertNotificationTemplate template;
- try {
- template = (AlertNotificationTemplate) q.getSingleResult();
- } catch (NoResultException nre) {
- LOG.info("There is no alert notification template with name '"
+ templateName + "'");
- template = new AlertNotificationTemplate("dummy", null);
- }
- return template;
- }
-
- /**
- * Take the passed NotificationTemplate and apply its Notifications to the passed
AlertDefinition
- * @param template NotificationTemplate to apply
- * @param def AlertDefinition to apply the template to
- * @param removeOldNotifications Shall old Notifications on the Definition be
removed?
- */
- public void applyNotificationTemplateToAlertDefinition(AlertNotificationTemplate
template, AlertDefinition def,
- boolean removeOldNotifications) {
-
- if (removeOldNotifications)
- def.getAlertNotifications().clear();
-
- for (AlertNotification notif : template.getNotifications()) {
- AlertNotification notification = new AlertNotification(notif, true);
- notification.setAlertDefinition(notif.getAlertDefinition());
- entityManager.persist(notification.getConfiguration());
- entityManager.persist(notification);
- def.addAlertNotification(notification); // Attach a copy, as the ones in the
template should not be shared
- }
- }
-
- /**
- * Create a new NotificationTemplate from the passed parameters. The passed
AlertNotification objects need to have the
- * name and sender and any configuration properties already set; alert definitions
must not be set.
- * @param name name of this notification template. Must be unique
- * @param description description of the template
- * @param notifications notifications that make up the template
- * @param copyNotifications
- * @return the newly created template
- * @throws IllegalArgumentException when a template with the passed name already
exists
- */
- @SuppressWarnings("unchecked")
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public AlertNotificationTemplate createNotificationTemplate(String name, String
description,
- List<AlertNotification> notifications, boolean copyNotifications) throws
IllegalArgumentException {
-
- Query q =
entityManager.createNamedQuery(AlertNotificationTemplate.FIND_BY_NAME);
- q.setParameter("name", name);
- List<AlertNotificationTemplate> tmp = q.getResultList();
- if (tmp.size() > 0) {
- throw new IllegalArgumentException("AlertNotificationTemplate with name
[" + name + "] already exists");
- }
-
- AlertNotificationTemplate templ = new AlertNotificationTemplate(name,
description);
- entityManager.persist(templ);
- for (AlertNotification n : notifications) {
- if (copyNotifications) {
- // AlertNotification alNo = n.copyWithAlertDefintion()
TODO implement / fix this
- } else {
- n.setAlertNotificationTemplate(templ);
- templ.addNotification(n);
- entityManager.persist(n);
- }
-
- }
- return templ;
- }
-
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public void updateNotificationTemplate(Subject subject, int templateId, String
newName, String newDescription) {
- AlertNotificationTemplate template = getAlertNotificationTemplate(subject,
templateId);
- template.setName(newName);
- template.setDescription(newDescription);
- entityManager.merge(template);
- }
-
- /**
- * Delete the passed Notification Templates
- * @param subject subject of the caller
- * @param templateIds ids of the templates to delete
- * @return number of templates deleted
- */
- public int deleteNotificationTemplates(Subject subject, Integer[] templateIds) {
- if (templateIds.length == 0)
- return 0;
-
- int num = 0;
- for (int id : templateIds) {
- AlertNotificationTemplate templ =
entityManager.find(AlertNotificationTemplate.class, id);
- if (templ == null) {
- LOG.warn("No notification template found with id [" + id +
"]");
- continue;
- }
- entityManager.remove(templ);
- num++;
- }
-
- return num;
- }
-
- /**
- * Add a new alert Notification to a template
- * @param user subject of the caller
- * @param templateName name of the NotificationTemplate to use
- * @param sender the alert sender to use
- * @param notificationName the name of this notification
- * @param notificationConfiguration the configuration of this AlertNotification
- * @return the new AlertNotification
- */
- public AlertNotification addAlertNotificationToTemplate(Subject user, int templateId,
String sender,
- String notificationName, Configuration notificationConfiguration) {
-
- AlertNotificationTemplate template =
entityManager.find(AlertNotificationTemplate.class, templateId);
-
- entityManager.persist(notificationConfiguration);
- AlertNotification alertNotification = new AlertNotification(sender);
- alertNotification.setConfiguration(notificationConfiguration);
- alertNotification.setAlertNotificationTemplate(template);
- entityManager.persist(alertNotification);
- template.addNotification(alertNotification);
-
- return alertNotification;
-
- }
-
- public List<AlertNotification> getNotificationsForTemplate(Subject subject, int
templateId) {
-
- AlertNotificationTemplate template =
entityManager.find(AlertNotificationTemplate.class, templateId);
- if (template == null) {
- LOG.error("DId not find notification template for id [" +
templateId + "]");
- return new ArrayList<AlertNotification>();
- }
-
- List<AlertNotification> notifications = template.getNotifications();
- for (AlertNotification notification : notifications) {
- notification.getConfiguration().getProperties().size(); // eager load
- }
-
- return notifications;
- }
-
- /**
- * Get all defined notification templates in the system along with their
AlertNotifications
- * @param user Subject of the caller
- * @return List of all defined alert notification templates
- */
- @SuppressWarnings("unchecked")
- public List<AlertNotificationTemplate> listNotificationTemplates(Subject user)
{
-
- Query q = entityManager.createNamedQuery(AlertNotificationTemplate.FIND_ALL);
- List<AlertNotificationTemplate> ret = q.getResultList();
-
- return ret;
- }
-
public AlertNotification getAlertNotification(Subject user, int alertNotificationId)
{
AlertNotification notification = entityManager.find(AlertNotification.class,
alertNotificationId);
- notification.getConfiguration().getProperties().size(); // eager load the alert
properties
+ if (notification == null) {
+ return null;
+ }
+ if (notification.getConfiguration() != null) { // an "incomplete"
notification might not have a config yet
+ notification.getConfiguration().getProperties().size(); // eager load the
alert properties
+ }
return notification;
}
- public AlertNotificationTemplate getAlertNotificationTemplate(Subject user, int
alertNotificationTemplateId) {
- AlertNotificationTemplate template =
entityManager.find(AlertNotificationTemplate.class,
- alertNotificationTemplateId);
- template.getNotifications().size(); // eager load the children alert
notifications
- return template;
- }
-
}
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 9db80cc..bfa4dbf 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
@@ -22,9 +22,7 @@ import java.util.List;
import javax.ejb.Local;
-import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@@ -93,15 +91,6 @@ public interface AlertNotificationManagerLocal {
AlertSenderInfo getAlertInfoForSender(String shortName);
/**
- * Take the passed NotificationTemplate and apply its Notifications to the passed
AlertDefinition
- * @param template NotificationTemplate to apply
- * @param def AlertDefinition to apply the template to
- * @param removeOldNotifications Shall old Notifications on the Definition be
removed?
- */
- void applyNotificationTemplateToAlertDefinition(AlertNotificationTemplate template,
AlertDefinition def,
- boolean removeOldNotifications);
-
- /**
* Return the backing bean for the AlertSender with the passed shortNama
* @param shortName name of a sender
* @param alertNotificationId
@@ -111,62 +100,5 @@ public interface AlertNotificationManagerLocal {
String getBackingBeanNameForSender(String shortName);
- /**
- * Create a new NotificationTemplate from the passed parameters. The passed
AlertNotification objects need to have the
- * name and sender and any configuration properties already set; alert definitions
must not be set.
- * @param name name of this notification template. Must be unique
- * @param description description of the template
- * @param notifications notifications that make up the template
- * @param copyNotifications
- * @return the newly created template
- * @throws IllegalArgumentException when a template with the passed name already
exists
- */
- AlertNotificationTemplate createNotificationTemplate(String name, String
description,
- List<AlertNotification> notifications, boolean copyNotifications) throws
IllegalArgumentException;
-
- void updateNotificationTemplate(Subject subject, int templateId, String newName,
String newDescription);
-
- /**
- * Get all defined notification templates in the system along with their
AlertNotifications
- * @param user Subject of the caller
- * @return List of all defined alert notification templates
- */
- List<AlertNotificationTemplate> listNotificationTemplates(Subject user);
-
AlertNotification getAlertNotification(Subject user, int alertNotificationId);
-
- AlertNotificationTemplate getAlertNotificationTemplate(Subject user, int
alertNotificationTemplateId);
-
- /**
- * Take the passed NotificationTemplate and apply its Notifications to the passed
AlertDefinition
- * @param templateName name of a pre-defined alert NotificationTemplate
- * @param alertDefinitionId id of an AlertDefinition on which the template should be
applied
- * @param removeOldNotifications Shall old Notifications on the Definition be
removed?
- */
- void applyNotificationTemplateToAlertDefinition(String templateName, int
alertDefinitionId,
- boolean removeOldNotifications);
-
- /**
- * Add a new alert Notification to a template
- * @param user subject of the caller
- * @param templateName name of the NotificationTemplate to use
- * @param sender the alert sender to use
- * @param notificationName the name of this notification
- * @param notificationConfiguration the configuration of this AlertNotification
- * @return the new AlertNotification
- */
- AlertNotification addAlertNotificationToTemplate(Subject user, int templateId, String
sender,
- String notificationName, Configuration notificationConfiguration);
-
- int removeNotificationsFromTemplate(Subject subject, int templateId, Integer[]
notificationIds);
-
- List<AlertNotification> getNotificationsForTemplate(Subject subject, int
templateId);
-
- /**
- * Delete the passed Notification Templates
- * @param subject subject of the caller
- * @param templateIds ids of the templates to delete
- * @return number of templates deleted
- */
- int deleteNotificationTemplates(Subject subject, Integer[] templateIds);
}