Class: AuditJob

Inherits:
ActiveFedoraIdBasedJob show all
Defined in:
app/jobs/audit_job.rb

Constant Summary collapse

PASS =
'Passing Audit Run'.freeze
FAIL =
'Failing Audit Run'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ActiveFedoraIdBasedJob

#object

Constructor Details

#initialize(id, path, uri) ⇒ AuditJob

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


16
17
18
19
20
# File 'app/jobs/audit_job.rb', line 16

def initialize(id, path, uri)
  super(id)
  self.path = path
  self.uri = uri
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



9
10
11
# File 'app/jobs/audit_job.rb', line 9

def id
  @id
end

#pathObject

Returns the value of attribute path.



9
10
11
# File 'app/jobs/audit_job.rb', line 9

def path
  @path
end

#uriObject

Returns the value of attribute uri.



9
10
11
# File 'app/jobs/audit_job.rb', line 9

def uri
  @uri
end

Instance Method Details

#queue_nameObject



2
3
4
# File 'app/jobs/audit_job.rb', line 2

def queue_name
  :audit
end

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/jobs/audit_job.rb', line 22

def run
  log = run_audit
  fixity_ok = (log.pass == 1)
  unless fixity_ok
    # send the user a message about the failing audit
     = generic_file.depositor
    user = User.find_by_user_key()
    logger.warn "User '#{}' not found" unless user
    job_user = User.audituser
    file_title = generic_file.title.first
    message = "The audit run at #{log.created_at} for #{file_title} (#{uri}) failed."
    subject = FAIL
    job_user.send_message(user, message, subject)
  end
  fixity_ok
end