Skip to content

Commit 1ee330a

Browse files
committed
Call after_update_* from edit_with_params
When changes are made to the endpoints or authentications workers which run with an open connection like event catchers and streaming refresh workers have to be restarted. This was done via `after_update_authentication` called from `update_authentication`. The issue is that this method is no longer called when providers are updated via the API with DDF parameters.
1 parent bd821db commit 1ee330a

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

app/models/ext_management_system.rb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,30 @@ def self.create_from_params(params, endpoints, authentications)
175175

176176
def edit_with_params(params, endpoints, authentications)
177177
tap do |ems|
178+
endpoints_changed = false
179+
authentications_changed = false
180+
178181
transaction do
179182
# Remove endpoints/attributes that are not arriving in the arguments above
180-
ems.endpoints.where.not(:role => nil).where.not(:role => endpoints.map { |ep| ep['role'] }).delete_all
181-
ems.authentications.where.not(:authtype => nil).where.not(:authtype => authentications.map { |au| au['authtype'] }).delete_all
183+
endpoints_to_delete = ems.endpoints.where.not(:role => nil).where.not(:role => endpoints.map { |ep| ep['role'] })
184+
authentications_to_delete = ems.authentications.where.not(:authtype => nil).where.not(:authtype => authentications.map { |au| au['authtype'] })
185+
186+
endpoints_changed ||= endpoints_to_delete.delete_all > 0
187+
authentications_changed ||= authentications_to_delete.delete_all > 0
182188

183189
ems.assign_attributes(params)
184-
ems.endpoints = endpoints.map(&method(:assign_nested_endpoint))
190+
ems.endpoints = endpoints.map(&method(:assign_nested_endpoint))
185191
ems.authentications = authentications.map(&method(:assign_nested_authentication))
186192

193+
endpoints_changed ||= ems.endpoints.any?(&:changed?)
194+
authentications_changed ||= ems.authentications.any?(&:changed?)
195+
187196
ems.provider.save! if ems.provider.present? && ems.provider.changed?
188197
ems.save!
189198
end
199+
200+
after_update_endpoints if endpoints_changed
201+
after_update_authentication if authentications_changed
190202
end
191203
end
192204

@@ -867,6 +879,10 @@ def after_update_authentication
867879
stop_event_monitor_queue_on_credential_change
868880
end
869881

882+
def after_update_endpoints
883+
stop_event_monitor_queue_on_credential_change
884+
end
885+
870886
###################################
871887
# Event Monitor
872888
###################################

0 commit comments

Comments
 (0)