Class: CurationConcerns::FileSetAuditService

Inherits:
Object
  • Object
show all
Defined in:
app/services/curation_concerns/file_set_audit_service.rb

Constant Summary collapse

NO_RUNS =
999

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_set) ⇒ FileSetAuditService



6
7
8
9
10
11
12
13
# File 'app/services/curation_concerns/file_set_audit_service.rb', line 6

def initialize(file_set)
  if file_set.is_a?(String)
    @id = file_set
  else
    @id = file_set.id
    @file_set = file_set
  end
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'app/services/curation_concerns/file_set_audit_service.rb', line 3

def id
  @id
end

Instance Method Details

#audit(log = {}) ⇒ Object

Audits each version of each file if it hasn’t been audited recently Returns the set of most recent audit status for each version of the content file



41
42
43
44
# File 'app/services/curation_concerns/file_set_audit_service.rb', line 41

def audit(log = {})
  file_set.files.each { |f| log[f.id] = audit_file(f) }
  log
end

#human_readable_audit_status(file = file_set.original_file) ⇒ Object

provides a human readable version of the audit status This may trigger audits to be run if required



20
21
22
# File 'app/services/curation_concerns/file_set_audit_service.rb', line 20

def human_readable_audit_status(file = file_set.original_file)
  audit_stat(file)
end

#logged_audit_statusObject

Check the file by only what is in the audit log. Do not try to access the versions if we do not have access to them. Use this when a file_set is loaded from solr instead of fedora



27
28
29
30
31
32
33
34
35
36
# File 'app/services/curation_concerns/file_set_audit_service.rb', line 27

def logged_audit_status
  audit_results = ChecksumAuditLog.logs_for(id, "original_file")
                                  .collect { |result| result["pass"] }

  if audit_results.length > 0
    stat_to_string(audit_results.reduce(true) { |sum, value| sum && value })
  else
    'Audits have not yet been run on this file.'
  end
end