Sha256: a5415c46d187b2ff7135990197cb29cdfdce44c3ec9c223f1078a8522c525554

Contents?: true

Size: 1.3 KB

Versions: 65

Compression:

Stored size: 1.3 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::Index::Fields::LAST_FIXITY_CHECK_ON => event_date_time_s,
          Ddr::Index::Fields::LAST_FIXITY_CHECK_OUTCOME => outcome }
      end

      protected

      def default_software
        self.class.repository_software
      end

    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
ddr-models-2.4.8 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.7 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.6 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.5 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.4 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.3 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.2 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.1 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.0 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.0.rc6 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.0.rc5 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.0.rc4 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.0.rc3 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.0.rc2 lib/ddr/events/fixity_check_event.rb
ddr-models-2.4.0.rc1 lib/ddr/events/fixity_check_event.rb
ddr-models-2.3.2 lib/ddr/events/fixity_check_event.rb
ddr-models-2.3.1 lib/ddr/events/fixity_check_event.rb
ddr-models-2.3.0 lib/ddr/events/fixity_check_event.rb
ddr-models-2.2.0 lib/ddr/events/fixity_check_event.rb
ddr-models-2.1.3 lib/ddr/events/fixity_check_event.rb