From a409a016d9d1d5ef4c2c132146ebc7d1d9b0752e Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Tue, 18 Jun 2019 06:47:22 +0200 Subject: [PATCH] don't set url for crossref dois. datacite/levriero#56 --- app/models/concerns/helpable.rb | 8 ++++---- app/models/doi.rb | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/concerns/helpable.rb b/app/models/concerns/helpable.rb index 51ad50cd4..1ecad142b 100644 --- a/app/models/concerns/helpable.rb +++ b/app/models/concerns/helpable.rb @@ -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? || options[:agency] == "Crossref") ? "https://doi.org" : "https://handle.test.datacite.org" - url += "/#{options[:doi]}" - response = Maremma.get(url, ssl_self_signed: true, timeout: 10) + 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) if response.status == 200 - response.headers[:location] + response else text = "Error " + response.body["errors"].inspect diff --git a/app/models/doi.rb b/app/models/doi.rb index b9285d55f..8edf86746 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -560,9 +560,9 @@ def validatable? # update URL in handle system for registered and findable state # providers europ and ethz do their own handle registration, so fetch url from handle system instead def update_url - return nil if current_user.nil? || !is_registered_or_findable? + return nil if current_user.nil? || !is_registered_or_findable? || %w(Crossref).include?(agency) - if %w(europ ethz crossref).include?(provider_id) || %w(Crossref).include?(agency) + if %w(europ ethz).include?(provider_id) UrlJob.perform_later(doi) else HandleJob.perform_later(doi)