Skip to content

Commit

Permalink
lookup url for crossref dois
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 17, 2019
1 parent 42cf036 commit f9f241d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/jobs/url_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def perform(doi_id)
doi = Doi.where(doi: doi_id).first

if doi.present?
response = Doi.get_doi(doi: doi.doi)
response = Doi.get_doi(doi: doi.doi, agency: doi.agency)
url = response.body.dig('data', 'values', 0, 'data', 'value')
if url.present?
if (doi.is_registered_or_findable? || %w(europ ethz crossref).include?(doi.provider_id)) && doi.minted.blank?
Expand Down
8 changes: 4 additions & 4 deletions app/models/concerns/helpable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ def get_dois(options={})
def get_doi(options={})
return OpenStruct.new(body: { "errors" => [{ "title" => "DOI missing" }] }) unless options[:doi].present?

url = Rails.env.production? ? "https://doi.org" : "https://handle.test.datacite.org"
url += "/api/handles/#{options[:doi]}"
response = Maremma.get(url, username: "300%3A#{ENV['HANDLE_USERNAME']}", password: ENV['HANDLE_PASSWORD'], ssl_self_signed: true, timeout: 10)
url = (Rails.env.production? || options[:agency] == "Crossref") ? "https://doi.org" : "https://handle.test.datacite.org"
url += "/#{options[:doi]}"
response = Maremma.get(url, ssl_self_signed: true, timeout: 10)

if response.status == 200
response
response.headers[:location]
else
text = "Error " + response.body["errors"].inspect

Expand Down

0 comments on commit f9f241d

Please sign in to comment.