Skip to content
Snippets Groups Projects
Commit 15618eaf authored by Paul Millar's avatar Paul Millar
Browse files

update_oai-pmh: make code DRY-er

parent 6039af5d
No related branches found
No related tags found
1 merge request!64update_oai-pmh Add a back-off strategy, to allow a service to recover
......@@ -16,21 +16,18 @@ def check_oai_pmh_endpoint(endpoint_url)
response = HTTParty.head(queryIdentify_url)
if !response.success?
print_with_time("Error: Identify response has HTTP status code #{response.code}.")
return "Error", []
raise StandardError.new "HTTP status code #{response.code}"
end
response = HTTParty.get(queryIdentify_url)
if response.body.nil? || response.body.empty?
print_with_time("Error: Identify response is empty.")
return "Error", []
raise StandardError.new "empty entity"
end
xml_response = Nokogiri::XML(response.body)
oai_pmh_tag = xml_response.at_xpath('//*[name()="OAI-PMH"]')
if !oai_pmh_tag
print_with_time("Error: Identify response has no OAI-PMH tag.")
return "Error", []
raise StandardError.new "no OAI-PMH tag."
end
addresses = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment