Class: Robots::SdrRepo::SdrRecovery::RecoveryRestore

Inherits:
Robots::SdrRepo::SdrRobot show all
Defined in:
lib/sdr_recovery/recovery_restore.rb

Overview

A robot for copying the recovered object versions to online storage

Instance Method Summary collapse

Methods inherited from Robots::SdrRepo::SdrRobot

#create_workflow_rows, #get_workflow_status, #get_workflow_xml, #process_item, #transmit, #update_workflow_error_status, #update_workflow_status

Constructor Details

#initialize(opts = {}) ⇒ RecoveryRestore

Returns set workflow name, step name, log location, log severity level


17
18
19
# File 'lib/sdr_recovery/recovery_restore.rb', line 17

def initialize(opts = {})
  super(self.class.workflow_name, self.class.step_name, opts)
end

Instance Method Details

#perform(druid) ⇒ void

This method returns an undefined value.

Returns process an object from the queue through this robot See LyberCore::Robot#work

Parameters:

  • druid (String)

    The item to be processed


24
25
26
27
# File 'lib/sdr_recovery/recovery_restore.rb', line 24

def perform(druid)
  LyberCore::Log.debug("( #{__FILE__} : #{__LINE__} ) Enter perform")
  recovery_restore(druid)
end

#recovery_restore(druid) ⇒ void

This method returns an undefined value.

Returns transfer recovered object files to repository storage.

Parameters:

  • druid (String)

    The object identifier


31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/sdr_recovery/recovery_restore.rb', line 31

def recovery_restore(druid)
  LyberCore::Log.debug("( #{__FILE__} : #{__LINE__} ) Enter recovery_restore")
  storage_object = Moab::StorageServices.storage_object(druid, create=true)
  recovery_path = Pathname(Sdr::Config.sdr_recovery_home).join(druid.sub('druid:', ''))
  storage_object.restore_object(recovery_path)
  result = storage_object.verify_object_storage
  if result.verified == false
    LyberCore::Log.info result.to_json(verbose=false)
    raise ItemError.new("Failed validation")
  end
rescue StandardError => e
  raise ItemError.new("Failed restore")
end

#verification_files(druid) ⇒ Object


58
59
60
61
62
# File 'lib/sdr_recovery/recovery_restore.rb', line 58

def verification_files(druid)
  files = []
  files << Moab::StorageServices.object_path(druid).to_s
  files
end

#verification_queries(druid) ⇒ Object


45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/sdr_recovery/recovery_restore.rb', line 45

def verification_queries(druid)
  storage_url = Sdr::Config.sdr_storage_url
  workflow_url = Dor::Config.workflow.url
  queries = []
  queries << [
      "#{storage_url}/objects/#{druid}",
      200, /<html>/]
  queries << [
      "#{workflow_url}/sdr/objects/#{druid}/workflows/sdrRecoveryWF",
      200, /completed/]
  queries
end