Class: Hyrax::Listeners::FileMetadataListener

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/listeners/file_metadata_listener.rb

Overview

Listens for events related to FileMetadata

Instance Method Summary collapse

Instance Method Details

#on_file_metadata_updated(event) ⇒ void

This method returns an undefined value.

Called when ‘file.metadata.updated’ event is published; reindexes a FileSet when a file claiming to be its ‘pcdm_use:OriginalFile`

Parameters:

  • event (Dry::Events::Event)


14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/hyrax/listeners/file_metadata_listener.rb', line 14

def (event)
  return unless event[:metadata].original_file?

  file_set = Hyrax.query_service.find_by(id: event[:metadata].file_set_id)
  Hyrax.index_adapter.save(resource: file_set)
rescue Valkyrie::Persistence::ObjectNotFoundError => err
  Hyrax.logger.warn "tried to index file with id #{event[:metadata].id} " \
                    "in response to an event of type #{event.id} but " \
                    "encountered an error #{err.message}. should this " \
                    "object be in a FileSet #{event[:metadata]}"
end