Hello mooli tayer,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/24703
to review the following change.
Change subject: tools: notifier: remove sql link between
notification_subscribers and users.
......................................................................
tools: notifier: remove sql link between notification_subscribers and users.
This is done in preperation to snmp notifications which have no
connections to engine users. This includes removing subscriber_id
from event_notification_hist and not using a users email instead of
a notification_subscriber email.
Change-Id: Ibb91d064c5ecec5b335c32636ac432299c5f96f6
Signed-off-by: Mooli Tayer <[email protected]>
---
M
backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/dao/EventsManager.java
M packaging/dbscripts/event_sp.sql
M packaging/dbscripts/upgrade/03_04_0600_event_notification_methods.sql
3 files changed, 18 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/03/24703/1
diff --git
a/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/dao/EventsManager.java
b/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/dao/EventsManager.java
index 39478dd..e5fe42e 100644
---
a/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/dao/EventsManager.java
+++
b/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/dao/EventsManager.java
@@ -244,7 +244,6 @@
cs.setString(4, sendResult.getReason());
cs.setTimestamp(5, new java.sql.Timestamp(new Date().getTime()));
cs.setBoolean(6, sendResult.isSent());
- cs.setString(7, subscriber.getSubscriberId() != null ?
subscriber.getSubscriberId().toString() : null);
cs.executeUpdate();
} catch (SQLException e) {
throw new NotificationServiceException("Could not insert event
notification history event", e);
diff --git a/packaging/dbscripts/event_sp.sql b/packaging/dbscripts/event_sp.sql
index 3087f6c..9b6c4e0 100644
--- a/packaging/dbscripts/event_sp.sql
+++ b/packaging/dbscripts/event_sp.sql
@@ -15,13 +15,12 @@
v_method_type CHAR(10),
v_reason CHAR(255) ,
v_sent_at TIMESTAMP WITH TIME ZONE,
- v_status BOOLEAN,
- v_subscriber_id VARCHAR(100))
+ v_status BOOLEAN)
RETURNS VOID
AS $procedure$
BEGIN
-INSERT INTO event_notification_hist(audit_log_id, event_name, method_type,
reason, sent_at, status, subscriber_id)
- VALUES(v_audit_log_id, v_event_name, v_method_type, v_reason,
v_sent_at, v_status, v_subscriber_id::uuid);
+INSERT INTO event_notification_hist(audit_log_id, event_name, method_type,
reason, sent_at, status)
+ VALUES(v_audit_log_id, v_event_name, v_method_type, v_reason,
v_sent_at, v_status);
END; $procedure$
LANGUAGE plpgsql;
diff --git
a/packaging/dbscripts/upgrade/03_04_0600_event_notification_methods.sql
b/packaging/dbscripts/upgrade/03_04_0600_event_notification_methods.sql
index ddace54..4187bc5 100644
--- a/packaging/dbscripts/upgrade/03_04_0600_event_notification_methods.sql
+++ b/packaging/dbscripts/upgrade/03_04_0600_event_notification_methods.sql
@@ -13,3 +13,18 @@
UPDATE event_subscriber SET notification_method = 'EMAIL';
ALTER TABLE event_subscriber ALTER notification_method SET NOT NULL;
+
+------------------------------------------------------------------------------------------
+-- Remove the connection between a subscription address and the subscribing
system user --
+------------------------------------------------------------------------------------------
+
+-- Up to this change if a subscriber had no email it's address was taken from
the users table
+-- this behaviour is removed from here on.
+UPDATE event_subscriber AS es
+SET method_address = u.email
+FROM event_subscriber AS es2
+ INNER JOIN users u ON es2.subscriber_id = u.user_id
+WHERE (es.method_address is NULL OR trim(both from es.method_address) = '');
+
+-- change events history table
+ALTER TABLE event_notification_hist DROP COLUMN subscriber_id;
--
To view, visit http://gerrit.ovirt.org/24703
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb91d064c5ecec5b335c32636ac432299c5f96f6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Alon Bar-Lev <[email protected]>
Gerrit-Reviewer: mooli tayer <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches