Class: PushmiPullyu::AIP::Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/pushmi_pullyu/aip/downloader.rb

Overview

Download all of the metadata/datastreams and associated data related to an object

Defined Under Namespace

Classes: JupiterAuthenticationError, JupiterCopyError, JupiterDownloadError

Constant Summary collapse

PREDICATE_URIS =
{
  filename: 'http://purl.org/dc/terms/title',
  member_files: 'http://pcdm.org/models#hasFile',
  member_file_sets: 'http://pcdm.org/models#hasMember',
  type: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(entity, aip_directory) ⇒ Downloader

Returns a new instance of Downloader.



23
24
25
26
27
# File 'lib/pushmi_pullyu/aip/downloader.rb', line 23

def initialize(entity, aip_directory)
  @entity = entity
  @entity_identifier = "[#{entity[:type]} - #{entity[:uuid]}]".freeze
  @aip_directory = aip_directory
end

Instance Method Details

#runObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/pushmi_pullyu/aip/downloader.rb', line 29

def run
  PushmiPullyu.logger.info("#{@entity_identifier}: Retreiving data from Jupiter ...")

  authenticate_http_calls
  make_directories

  # Main object metadata
  download_and_log(object_aip_paths[:main_object_remote],
                   object_aip_paths[:main_object_local])
  download_and_log(object_aip_paths[:file_sets_remote],
                   object_aip_paths[:file_sets_local])

  # Get file paths for processing
  file_paths = get_file_paths(object_aip_paths[:file_paths_remote])

  file_paths[:files].each do |file_path|
    file_uuid = file_path[:file_uuid]
    make_file_set_directories(file_uuid)
    copy_and_log(file_uuid, file_path)
    file_aip_path = file_aip_paths(file_uuid)
    download_and_log(file_aip_path[:fixity_remote],
                     file_aip_path[:fixity_local])
    download_and_log(file_aip_path[:file_set_remote],
                     file_aip_path[:file_set_local])
  end
end