Skip to content

Commit

Permalink
WIP: hyacinth ingest verification and resubmit
Browse files Browse the repository at this point in the history
  • Loading branch information
fcd1 committed Nov 19, 2024
1 parent 34c0600 commit 6ea5384
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/sword/adapters/hyacinth_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,24 @@ def ingest_asset(parent_pid,
@hyacinth_server_response
end

def verify_ingest(pid)
# just to be safe, reset response instance
@hyacinth_server_response = nil
uri = URI(HYACINTH_CONFIG[:url])
uri = "#{uri}/digital_objects/"#{pid}.json
get_req = Net::HTTP::Post.new(uri)
# puts post_req.body.inspect
get_req.basic_auth(HYACINTH_CONFIG[:username],
HYACINTH_CONFIG[:password])
Rails.logger.warn("verify ingest for pid #{pid}") if HYACINTH_CONFIG[:log_ingest]
@hyacinth_server_response = Net::HTTP.start(uri.hostname,
uri.port,
use_ssl: HYACINTH_CONFIG[:use_ssl]) { |http| http.request(post_req) }
Rails.logger.warn("ingest_item: Completed ingest request to Hyacinth") if HYACINTH_CONFIG[:log_ingest]
# puts @hyacinth_response.inspect
@hyacinth_server_response
end

def last_ingest_successful?
unless @hyacinth_server_response.nil?
@hyacinth_server_response.body['success']
Expand Down
12 changes: 12 additions & 0 deletions lib/sword/endpoints/mets_to_hyacinth_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ def initialize(collection_slug, depositor_user_id)
@mets_parser = Sword::Parsers::MetsParser.new
end

def resubmit_into_hyacinth(collection_slug, attempt)
unless (HYACINTH_CONFIG[:bypass_ingest] or COLLECTIONS[:slug][collection_slug][:bypass_hyacinth_ingest])
@collection_slug = collection_slug
@num_attempts = attempt +1
# @adapter_item_identifier stores the parent pid returned
# from Hyacinth
@adapter_item_identifier = ingest_item_into_hyacinth
ingest_documents_into_hyacinth
ingest_mets_xml_file_into_hyacinth
end
end

def ingest_item_into_hyacinth
# populate metadata for hyacinth item object and ingest it into hyacinth
@hyacinth_adapter.hyacinth_project =
Expand Down

0 comments on commit 6ea5384

Please sign in to comment.