Class: PurlFetcher::Client::PublishShelve

Inherits:
Object
  • Object
show all
Defined in:
lib/purl_fetcher/client/publish_shelve.rb

Overview

High-level client for publishing and shelving.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cocina:, filepath_map:) ⇒ PublishShelve

Returns a new instance of PublishShelve.

Parameters:

  • cocina (Cocina::Models::DRO, Cocina::Models::Collection)

    the Cocina data object

  • filepath_map (Hash<String,String>)

    map of relative filepaths to absolute filepaths



13
14
15
16
# File 'lib/purl_fetcher/client/publish_shelve.rb', line 13

def initialize(cocina:, filepath_map:)
  @cocina = cocina
  @filepath_map = filepath_map
end

Class Method Details

.publish_and_shelveObject



7
8
9
# File 'lib/purl_fetcher/client/publish_shelve.rb', line 7

def self.publish_and_shelve(...)
  new(...).publish_and_shelve
end

Instance Method Details

#publish_and_shelveObject



18
19
20
21
22
23
24
25
26
# File 'lib/purl_fetcher/client/publish_shelve.rb', line 18

def publish_and_shelve
  logger.debug("Starting publish and shelve for: #{cocina.externalIdentifier}")

  direct_upload_responses = PurlFetcher::Client::UploadFiles.upload(file_metadata: , filepath_map: filepath_map)
  file_uploads = direct_upload_responses.map { |response| [ response.filename, response.signed_id ] }.to_h

  PurlFetcher::Client::Publish.publish(cocina: cocina, file_uploads: file_uploads)
  logger.debug("Publish and shelve complete")
end