Class: KPM::Listener

Inherits:
Killbill::Plugin::Notification
  • Object
show all
Defined in:
lib/kpm/listener.rb

Instance Method Summary collapse

Instance Method Details

#on_event(event) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/kpm/listener.rb', line 12

def on_event(event)

  return unless [:BROADCAST_SERVICE].include?(event.event_type)

  unless ::KPM::PluginsInstaller.instance.initialized?
    @logger.warn "KPM plugin wasn't started properly - check logs"
    return
  end

   = event..nil? ? {} : JSON.parse(event.)
  command = ['commandType']
  return if command != 'INSTALL_PLUGIN' && command != 'UNINSTALL_PLUGIN'

  service = ['service']
  event_json = ['eventJson'].nil? ? {} : JSON.parse(['eventJson'])

  properties = properties_to_hash(event_json['properties'])

  @logger.info "Received #{event.event_type} event: service=#{service} command=#{command} event=#{event_json}"

  # pluginKey is the only mandatory property
  if event_json['pluginKey'].nil?
    @logger.info("Cannot run #{command}: missing pluginKey property")
    return false
  end

  handle_event(command,
               event_json['pluginKey'],
               properties['pluginArtifactId'],
               event_json['pluginVersion'],
               properties['pluginGroupId'],
               properties['pluginPackaging'],
               properties['pluginClassifier'],
               properties['pluginType'],
               properties['forceDownload'] == 'true')
end

#start_pluginObject



5
6
7
8
9
10
# File 'lib/kpm/listener.rb', line 5

def start_plugin
  super
  ::KPM::PluginsInstaller.instance.initialize!(@root, @conf_dir, @kb_apis, @logger)
  # We don't know yet
  @kb_version = nil
end