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

Returns a new instance of FileSetAuditService.



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

def initialize(file_set)
  @file_set = file_set
end

Instance Attribute Details

#file_setObject (readonly)

Returns the value of attribute file_set.



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

def file_set
  @file_set
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

Parameters:

  • log (Hash) (defaults to: {})

    container for messages, mapping file ids to status



34
35
36
37
# File 'app/services/curation_concerns/file_set_audit_service.rb', line 34

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

Parameters:

  • file (Hydra::PCDM::File) (defaults to: file_set.original_file)

    the file to get the audit status for, defaults to the original_file.



13
14
15
# File 'app/services/curation_concerns/file_set_audit_service.rb', line 13

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



20
21
22
23
24
25
26
27
28
29
# File 'app/services/curation_concerns/file_set_audit_service.rb', line 20

def logged_audit_status
  audit_results = ChecksumAuditLog.logs_for(file_set.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