Class: Ddr::Events::FixityCheckEvent

Inherits:
Event
  • Object
show all
Includes:
PreservationEventBehavior, ReindexObjectAfterSave
Defined in:
lib/ddr/events/fixity_check_event.rb

Constant Summary collapse

DETAIL_PREAMBLE =
"Datastream checksum validation results:"
DETAIL_TEMPLATE =
"%{dsid} ... %{validation}"

Constants included from PreservationEventBehavior

PreservationEventBehavior::EVENT_ID_TYPE, PreservationEventBehavior::LINKING_OBJECT_ID_TYPE

Constants inherited from Event

Event::DATE_TIME_FORMAT, Event::DDR_SOFTWARE, Event::DEFAULT_SORT_ORDER, Event::FAILURE, Event::INVALID, Event::OUTCOMES, Event::SUCCESS, Event::SYSTEM, Event::VALID

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PreservationEventBehavior

#as_premis, #preservation_event_type, #to_xml

Methods inherited from Event

#comment_or_summary, #display_type, #event_date_time_s, #failure!, #failure?, for_object, for_pid, #object, #object=, #performed_by, #pid=, repository_software, #success!, #success?, #user=

Class Method Details

.call(*args) ⇒ Object

Message sent by ActiveSupport::Notifications



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ddr/events/fixity_check_event.rb', line 15

def self.call(*args)
  notification = ActiveSupport::Notifications::Event.new(*args)
  result = notification.payload[:result] # FixityCheck::Result instance
  detail = [DETAIL_PREAMBLE]
  result.results.each do |dsid, dsProfile|
    validation = dsProfile["dsChecksumValid"] ? VALID : INVALID
    detail << DETAIL_TEMPLATE % {dsid: dsid, validation: validation}
  end
  create(pid: result.pid,
         event_date_time: notification.time,
         outcome: result.success ? SUCCESS : FAILURE,
         detail: detail.join("\n")
         )
end

Instance Method Details

#to_solrObject



30
31
32
33
# File 'lib/ddr/events/fixity_check_event.rb', line 30

def to_solr
  { Ddr::Index::Fields::LAST_FIXITY_CHECK_ON => event_date_time_s,
    Ddr::Index::Fields::LAST_FIXITY_CHECK_OUTCOME => outcome }
end