Sha256: fca02f822c788616b8bce3d027968218ab17bc6df2a706ca1d0e77226b96fa92

Contents?: true

Size: 1.29 KB

Versions: 27

Compression:

Stored size: 1.29 KB

Contents

module Ddr
  module Events
    class FixityCheckEvent < Event

      include PreservationEventBehavior
      include ReindexObjectAfterSave

      self.preservation_event_type = :fix
      self.description = "Validation of datastream checksums"

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

      # Message sent by ActiveSupport::Notifications
      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

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

      protected

      def default_software
        self.class.repository_software
      end

    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
ddr-models-1.13.2 lib/ddr/events/fixity_check_event.rb
ddr-models-1.13.1 lib/ddr/events/fixity_check_event.rb
ddr-models-1.13.0 lib/ddr/events/fixity_check_event.rb
ddr-models-1.11.8 lib/ddr/events/fixity_check_event.rb
ddr-models-1.12.3 lib/ddr/events/fixity_check_event.rb
ddr-models-1.11.7 lib/ddr/events/fixity_check_event.rb
ddr-models-1.12.2 lib/ddr/events/fixity_check_event.rb
ddr-models-1.11.6 lib/ddr/events/fixity_check_event.rb
ddr-models-1.12.1 lib/ddr/events/fixity_check_event.rb
ddr-models-1.11.5 lib/ddr/events/fixity_check_event.rb
ddr-models-1.12.0 lib/ddr/events/fixity_check_event.rb
ddr-models-1.11.4 lib/ddr/events/fixity_check_event.rb
ddr-models-1.11.3 lib/ddr/events/fixity_check_event.rb
ddr-models-1.11.2 lib/ddr/events/fixity_check_event.rb
ddr-models-1.11.1 lib/ddr/events/fixity_check_event.rb
ddr-models-1.11.0 lib/ddr/events/fixity_check_event.rb
ddr-models-1.10.0 lib/ddr/events/fixity_check_event.rb
ddr-models-1.9.0 lib/ddr/events/fixity_check_event.rb
ddr-models-1.8.1 lib/ddr/events/fixity_check_event.rb
ddr-models-1.8.0 lib/ddr/events/fixity_check_event.rb