Class: Actions::Candlepin::ImportPoolHandler

Inherits:
Object
  • Object
show all
Defined in:
app/lib/actions/candlepin/import_pool_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ ImportPoolHandler

Returns a new instance of ImportPoolHandler.



20
21
22
# File 'app/lib/actions/candlepin/import_pool_handler.rb', line 20

def initialize(logger)
  @logger = logger
end

Instance Method Details

#handle(message) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/lib/actions/candlepin/import_pool_handler.rb', line 24

def handle(message)
  @logger.debug("message received from subscriptions queue ")
  @logger.debug("message subject: #{message.subject}")

  ::User.current = ::User.anonymous_admin

  wrapped_message = MessageWrapper.new(message)
  case message.subject
  when /entitlement\.created/
    import_pool(wrapped_message.content['referenceId'])
  when /entitlement\.deleted/
    import_or_remove_pool(wrapped_message.content['referenceId'])
  when /pool\.created/
    import_pool(wrapped_message.content['entityId'])
  when /pool\.deleted/
    remove_pool(wrapped_message.content['entityId'])
  when /compliance\.created/
    reindex_consumer(wrapped_message)
  end
end