Class: Hyrax::Listeners::FileMetadataListener
- Inherits:
-
Object
- Object
- Hyrax::Listeners::FileMetadataListener
- Defined in:
- app/services/hyrax/listeners/file_metadata_listener.rb
Overview
Listens for events related to FileMetadata
Instance Method Summary collapse
-
#on_file_characterized(event) ⇒ void
Called when ‘file.characterized’ event is published; allows post-characterization handling, like derivatives generation.
-
#on_file_metadata_updated(event) ⇒ void
Called when ‘file.metadata.updated’ event is published; reindexes a FileSet when a file claiming to be its ‘pcdm_use:OriginalFile`.
-
#on_object_file_uploaded(event) ⇒ void
Called when ‘object.file.uploaded’ event is published.
Instance Method Details
#on_file_characterized(event) ⇒ void
This method returns an undefined value.
Called when ‘file.characterized’ event is published; allows post-characterization handling, like derivatives generation.
14 15 16 17 |
# File 'app/services/hyrax/listeners/file_metadata_listener.rb', line 14 def on_file_characterized(event) CreateDerivativesJob .perform_later(event[:file_set], event[:file_id], event[:path_hint]) end |
#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`
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/services/hyrax/listeners/file_metadata_listener.rb', line 25 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.}. should this " \ "object be in a FileSet #{event[:metadata]}" end |
#on_object_file_uploaded(event) ⇒ void
This method returns an undefined value.
Called when ‘object.file.uploaded’ event is published
41 42 43 44 45 46 |
# File 'app/services/hyrax/listeners/file_metadata_listener.rb', line 41 def on_object_file_uploaded(event) # Run characterization Hyrax.config .characterization_service .run(metadata: event[:metadata], file: event[:metadata].file) end |