Class: Robots::SdrRepo::SdrMigration::MigrationComplete

Inherits:
Robots::SdrRepo::SdrIngest::CompleteDeposit show all
Defined in:
lib/sdr_migration/migration_complete.rb

Overview

A robot for completing the migration of the queued objects Most methods inherit from complete-deposit robot's class

Instance Method Summary collapse

Methods inherited from Robots::SdrRepo::SdrIngest::CompleteDeposit

#initialize, #perform

Methods inherited from Robots::SdrRepo::SdrRobot

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

Constructor Details

This class inherits a constructor from Robots::SdrRepo::SdrIngest::CompleteDeposit

Instance Method Details

#cleanup_deposit_files(druid, bag_pathname) ⇒ Boolean

Returns Cleanup the temp deposit files, raising an error if cleanup failes after 3 attempts

Parameters:

  • druid (String)

    The object identifier

  • bag_pathname (Object)

    The temp location of the bag containing the object version being deposited

Returns:

  • (Boolean)

    Cleanup the temp deposit files, raising an error if cleanup failes after 3 attempts


34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/sdr_migration/migration_complete.rb', line 34

def cleanup_deposit_files(druid, bag_pathname)
  # retry up to 3 times
  sleep_time = [0, 2, 6]
  attempts ||= 0
  bag_pathname.rmtree
  return true
rescue StandardError => e
  if (attempts += 1) < sleep_time.size
    sleep sleep_time[attempts].to_i
    retry
  else
    raise ItemError.new("Failed cleanup deposit (#{attempts} attempts)")
  end
end

#complete_deposit(druid, storage_object) ⇒ void

This method returns an undefined value.

Returns complete ingest of the item, cleanup temp deposit data.

Parameters:

  • druid (String)

    The object identifier

  • storage_object (StorageObject)

    The representation of a digitial object's storage directory


20
21
22
23
24
25
26
27
28
29
# File 'lib/sdr_migration/migration_complete.rb', line 20

def complete_deposit(druid, storage_object)
  new_version = storage_object.ingest_bag
  result = new_version.verify_version_storage
  if result.verified == false
    LyberCore::Log.info result.to_json(verbose=false)
    raise ItemError.new("Failed validation")
  end
  bag_pathname = storage_object.deposit_bag_pathname
  cleanup_deposit_files(druid, bag_pathname)
end

#verification_files(druid) ⇒ Object


62
63
64
65
66
# File 'lib/sdr_migration/migration_complete.rb', line 62

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

#verification_queries(druid) ⇒ Object


49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/sdr_migration/migration_complete.rb', line 49

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/sdrMigrationWF",
      200, /completed/]
  queries
end