From 60b6795436866b3882e11bed02f50ea727bed648 Mon Sep 17 00:00:00 2001
From: Fred Duby
+ Ingest Confirmed? + <%= @deposit.ingest_confirmed %> +
+Depositor User ID: <%= @deposit.depositor_user_id %> diff --git a/db/migrate/20241122163611_add_ingest_confirmed_to_deposits.rb b/db/migrate/20241122163611_add_ingest_confirmed_to_deposits.rb new file mode 100644 index 0000000..3ba9a49 --- /dev/null +++ b/db/migrate/20241122163611_add_ingest_confirmed_to_deposits.rb @@ -0,0 +1,5 @@ +class AddIngestConfirmedToDeposits < ActiveRecord::Migration[7.2] + def change + add_column :deposits, :ingest_confirmed, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index 61e74d8..9593024 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_11_21_213246) do +ActiveRecord::Schema[7.2].define(version: 2024_11_22_163611) do create_table "collections", force: :cascade do |t| t.string "name", null: false t.string "atom_title", null: false @@ -59,6 +59,7 @@ t.string "depositor_user_id" t.string "collection_slug" t.text "asset_pids" + t.boolean "ingest_confirmed" t.index ["collection_id"], name: "index_deposits_on_collection_id" t.index ["collection_slug"], name: "index_deposits_on_collection_slug" t.index ["depositor_id"], name: "index_deposits_on_depositor_id" diff --git a/lib/sword/adapters/hyacinth_adapter.rb b/lib/sword/adapters/hyacinth_adapter.rb index 28b6b39..8737ecc 100644 --- a/lib/sword/adapters/hyacinth_adapter.rb +++ b/lib/sword/adapters/hyacinth_adapter.rb @@ -149,10 +149,12 @@ def expected_and_retrieved_asset_pids_match? Net::HTTP.start(uri.hostname, uri.port, use_ssl: HYACINTH_CONFIG[:use_ssl]) { |http| http.request(get_req) } - unless server_response.nil? - retrieved_pids = - JSON.parse(server_response.body)['ordered_child_digital_objects'].each.map { |pid_hash| pid_hash['pid'] } + unless server_response.is_a? Net::HTTPSuccess + Rails.logger.warn("Item GET failure (Item PID: #{@item_pid}, HTTP code: #{server_response.code})") + return false end + retrieved_pids = + JSON.parse(server_response.body)['ordered_child_digital_objects'].each.map { |pid_hash| pid_hash['pid'] } pids_match = Set.new(@asset_pids) == Set.new(retrieved_pids) unless pids_match Rails.logger.warn("Asset pids mismatch (expected: #{@asset_pids}, retrieved from Hyacinth Item: #{retrieved_pids}") diff --git a/lib/sword/endpoints/mets_to_hyacinth_endpoint.rb b/lib/sword/endpoints/mets_to_hyacinth_endpoint.rb index 2eb0c32..c452154 100644 --- a/lib/sword/endpoints/mets_to_hyacinth_endpoint.rb +++ b/lib/sword/endpoints/mets_to_hyacinth_endpoint.rb @@ -68,7 +68,7 @@ def ingest_into_hyacinth ingest_documents_into_hyacinth ingest_mets_xml_file_into_hyacinth @asset_pids = @hyacinth_adapter.asset_pids - validate_asset_pids + confirm_ingest else Rails.logger.warn "Bypassing ingest into Hyacinth, set bogus PID" # bogus item identifier. Instead, could use string 'NotApplicable' @@ -76,11 +76,13 @@ def ingest_into_hyacinth end end - def validate_asset_pids + def confirm_ingest if @hyacinth_adapter.expected_and_retrieved_asset_pids_match? - Rails.logger.warn("MetsToHyacinthEndpoint: Asset pids match") + Rails.logger.warn("MetsToHyacinthEndpoint: Ingest confirmed") + true else - Rails.logger.warn("MetsToHyacinthEndpoint: ASSET PIDS DO NOT MATCH!!!") + Rails.logger.warn("MetsToHyacinthEndpoint: INGEST NOT CONFIRMED!!!") + false end end