Sha256: defa591904b7a7af93b6b3e87b3b7f5e558127f2fecd6fa2a2be315b4a2b00d4

Contents?: true

Size: 1.57 KB

Versions: 37

Compression:

Stored size: 1.57 KB

Contents

class AuditJob < ActiveJob::Base
  # URI of the resource to audit.
  # This URI could include the actual resource (e.g. content) and the version to audit:
  #     http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content/fcr:versions/version1
  # but it could also just be:
  #     http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content
  # @param [FileSet] the parent object
  # @param [String] file_id used to find the file within its parent object (usually "original_file")
  # @param [String] uri of the specific file/version to be audited
  def perform(file_set, file_id, uri)
    log = run_audit(file_set, file_id, uri)
    fixity_ok = log.pass == 1
    unless fixity_ok
      if CurationConcerns.config.callback.set?(:after_audit_failure)
        login = file_set.depositor
        user = User.find_by_user_key(login)
        CurationConcerns.config.callback.run(:after_audit_failure, file_set, user, log.created_at)
      end
    end
    fixity_ok
  end

  protected

    def run_audit(file_set, file_id, uri)
      begin
        fixity_ok = ActiveFedora::FixityService.new(uri).check
      rescue Ldp::NotFound
        error_msg = 'resource not found'
      end

      if fixity_ok
        passing = 1
        ChecksumAuditLog.prune_history(file_set.id, file_id)
      else
        logger.warn "***AUDIT*** Audit failed for #{uri} #{error_msg}"
        passing = 0
      end
      ChecksumAuditLog.create!(pass: passing, file_set_id: file_set.id, version: uri, file_id: file_id)
    end

  private

    def logger
      ActiveFedora::Base.logger || CurationConcerns::NullLogger.new
    end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
curation_concerns-1.7.8 app/jobs/audit_job.rb
curation_concerns-1.7.7 app/jobs/audit_job.rb
curation_concerns-2.0.0 app/jobs/audit_job.rb
curation_concerns-2.0.0.rc2 app/jobs/audit_job.rb
curation_concerns-1.7.6 app/jobs/audit_job.rb
curation_concerns-1.7.5 app/jobs/audit_job.rb
curation_concerns-1.7.4 app/jobs/audit_job.rb
curation_concerns-1.7.3 app/jobs/audit_job.rb
curation_concerns-1.7.2 app/jobs/audit_job.rb
curation_concerns-2.0.0.rc1 app/jobs/audit_job.rb
curation_concerns-1.7.1 app/jobs/audit_job.rb
curation_concerns-1.7.0 app/jobs/audit_job.rb
curation_concerns-1.7.0.beta1 app/jobs/audit_job.rb
curation_concerns-1.6.3 app/jobs/audit_job.rb
curation_concerns-1.6.2 app/jobs/audit_job.rb
curation_concerns-1.6.1 app/jobs/audit_job.rb
curation_concerns-1.6.0 app/jobs/audit_job.rb
curation_concerns-1.5.0 app/jobs/audit_job.rb
curation_concerns-1.4.0 app/jobs/audit_job.rb
curation_concerns-1.3.3 app/jobs/audit_job.rb